mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-16 10:30:47 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
127
openclaw/test/scripts/check-channel-agnostic-boundaries.test.ts
Normal file
127
openclaw/test/scripts/check-channel-agnostic-boundaries.test.ts
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
findChannelAgnosticBoundaryViolations,
|
||||
findAcpUserFacingChannelNameViolations,
|
||||
findChannelCoreReverseDependencyViolations,
|
||||
findSystemMarkLiteralViolations,
|
||||
} from "../../scripts/check-channel-agnostic-boundaries.mjs";
|
||||
|
||||
describe("check-channel-agnostic-boundaries", () => {
|
||||
it("flags direct channel module imports", () => {
|
||||
const source = `
|
||||
import { getThreadBindingManager } from "../discord/monitor/thread-bindings.js";
|
||||
const x = 1;
|
||||
`;
|
||||
expect(findChannelAgnosticBoundaryViolations(source)).toEqual([
|
||||
{
|
||||
line: 2,
|
||||
reason: 'imports channel module "../discord/monitor/thread-bindings.js"',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("flags channel config path access", () => {
|
||||
const source = `
|
||||
const x = cfg.channels.discord?.threadBindings?.enabled;
|
||||
`;
|
||||
expect(findChannelAgnosticBoundaryViolations(source)).toEqual([
|
||||
{
|
||||
line: 2,
|
||||
reason: 'references config path "channels.discord"',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("flags channel-literal comparisons", () => {
|
||||
const source = `
|
||||
if (channel === "discord") {
|
||||
return true;
|
||||
}
|
||||
`;
|
||||
expect(findChannelAgnosticBoundaryViolations(source)).toEqual([
|
||||
{
|
||||
line: 2,
|
||||
reason: 'compares with channel id literal (channel === "discord")',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("flags object literals with explicit channel ids", () => {
|
||||
const source = `
|
||||
const payload = { channel: "telegram" };
|
||||
`;
|
||||
expect(findChannelAgnosticBoundaryViolations(source)).toEqual([
|
||||
{
|
||||
line: 2,
|
||||
reason: 'assigns channel id literal to "channel" ("telegram")',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("ignores non-channel literals and unrelated text", () => {
|
||||
const source = `
|
||||
const msg = "discord";
|
||||
const payload = { mode: "persistent" };
|
||||
const x = cfg.session.threadBindings?.enabled;
|
||||
`;
|
||||
expect(findChannelAgnosticBoundaryViolations(source)).toEqual([]);
|
||||
});
|
||||
|
||||
it("reverse-deps mode flags channel module re-exports", () => {
|
||||
const source = `
|
||||
export { resolveThreadBindingIntroText } from "../discord/monitor/thread-bindings.messages.js";
|
||||
`;
|
||||
expect(findChannelCoreReverseDependencyViolations(source)).toEqual([
|
||||
{
|
||||
line: 2,
|
||||
reason: 're-exports channel module "../discord/monitor/thread-bindings.messages.js"',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("reverse-deps mode ignores channel literals when no imports are present", () => {
|
||||
const source = `
|
||||
const channel = "discord";
|
||||
const x = cfg.channels.discord?.threadBindings?.enabled;
|
||||
`;
|
||||
expect(findChannelCoreReverseDependencyViolations(source)).toEqual([]);
|
||||
});
|
||||
|
||||
it("user-facing text mode flags channel names in string literals", () => {
|
||||
const source = `
|
||||
const message = "Bind a Discord thread first.";
|
||||
`;
|
||||
expect(findAcpUserFacingChannelNameViolations(source)).toEqual([
|
||||
{
|
||||
line: 2,
|
||||
reason: 'user-facing text references channel name ("Bind a Discord thread first.")',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("user-facing text mode ignores channel names in import specifiers", () => {
|
||||
const source = `
|
||||
import { x } from "../discord/monitor/thread-bindings.js";
|
||||
`;
|
||||
expect(findAcpUserFacingChannelNameViolations(source)).toEqual([]);
|
||||
});
|
||||
|
||||
it("system-mark guard flags hardcoded gear literals", () => {
|
||||
const source = `
|
||||
const line = "⚙️ Thread bindings enabled.";
|
||||
`;
|
||||
expect(findSystemMarkLiteralViolations(source)).toEqual([
|
||||
{
|
||||
line: 2,
|
||||
reason: 'hardcoded system mark literal ("⚙️ Thread bindings enabled.")',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("system-mark guard ignores module import specifiers", () => {
|
||||
const source = `
|
||||
import { x } from "../infra/system-message.js";
|
||||
`;
|
||||
expect(findSystemMarkLiteralViolations(source)).toEqual([]);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue