@lsctech/polaris 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -0
- package/dist/__mocks__/tool-server-linear.js +34 -0
- package/dist/cli/adopt-approve.js +60 -0
- package/dist/cli/adopt-cognition.js +199 -0
- package/dist/cli/adopt-instructions.js +143 -0
- package/dist/cli/adopt-rules.js +169 -0
- package/dist/cli/adopt-scan.js +25 -0
- package/dist/cli/adopt-smartdocs.js +192 -0
- package/dist/cli/adoption-inventory.js +350 -0
- package/dist/cli/adoption-plan.js +222 -0
- package/dist/cli/args.js +28 -0
- package/dist/cli/args.test.js +30 -0
- package/dist/cli/branding.js +41 -0
- package/dist/cli/graph.js +358 -0
- package/dist/cli/index.js +127 -0
- package/dist/cli/index.test.js +162 -0
- package/dist/cli/init-detect.js +61 -0
- package/dist/cli/init.js +492 -0
- package/dist/cli/init.test.js +259 -0
- package/dist/cli/librarian.js +32 -0
- package/dist/cli/medic.js +96 -0
- package/dist/cli/startup.test.js +23 -0
- package/dist/cli/tracker.js +130 -0
- package/dist/cli/tracker.test.js +126 -0
- package/dist/cli/version.js +10 -0
- package/dist/cli/version.test.js +11 -0
- package/dist/cli/worker.js +287 -0
- package/dist/cluster-state/fixtures/test-clusters.json +19 -0
- package/dist/cluster-state/store.js +302 -0
- package/dist/cluster-state/store.test.js +145 -0
- package/dist/cluster-state/types.js +2 -0
- package/dist/cognition/archive.js +158 -0
- package/dist/cognition/closeout-librarian-types.js +161 -0
- package/dist/cognition/cognition.test.js +623 -0
- package/dist/cognition/index.js +41 -0
- package/dist/cognition/librarian-dispatch.js +391 -0
- package/dist/cognition/librarian-dispatch.test.js +247 -0
- package/dist/cognition/librarian-packet.js +313 -0
- package/dist/cognition/librarian-types.js +57 -0
- package/dist/cognition/route-cognition-delta.js +350 -0
- package/dist/cognition/summary-delta.js +279 -0
- package/dist/cognition/validate.js +162 -0
- package/dist/config/defaults.js +98 -0
- package/dist/config/doctor.js +273 -0
- package/dist/config/index.js +14 -0
- package/dist/config/loader.js +58 -0
- package/dist/config/provider-detect.js +60 -0
- package/dist/config/provider-detect.test.js +119 -0
- package/dist/config/schema.js +2 -0
- package/dist/config/show.js +44 -0
- package/dist/config/show.test.js +42 -0
- package/dist/config/validator.js +675 -0
- package/dist/config/validator.test.js +77 -0
- package/dist/docs/canon-check.js +334 -0
- package/dist/docs/canon-check.test.js +207 -0
- package/dist/docs/doctrine.js +133 -0
- package/dist/docs/doctrine.test.js +139 -0
- package/dist/docs/index.js +168 -0
- package/dist/docs/index.test.js +83 -0
- package/dist/docs/ingest.js +295 -0
- package/dist/docs/ingest.test.js +71 -0
- package/dist/docs/migrate.js +165 -0
- package/dist/docs/migrate.test.js +136 -0
- package/dist/docs/seed-instructions.js +147 -0
- package/dist/docs/seed-instructions.test.js +137 -0
- package/dist/docs/validate-instructions.js +267 -0
- package/dist/docs/validate-instructions.test.js +238 -0
- package/dist/finalize/artifact-policy.js +214 -0
- package/dist/finalize/artifact-policy.test.js +84 -0
- package/dist/finalize/delivery-integrity.js +141 -0
- package/dist/finalize/finalize.test.js +210 -0
- package/dist/finalize/github.js +41 -0
- package/dist/finalize/index.js +474 -0
- package/dist/finalize/linear.js +213 -0
- package/dist/finalize/run-report.js +47 -0
- package/dist/finalize/steps/01-map-update.js +11 -0
- package/dist/finalize/steps/02-map-validate.js +11 -0
- package/dist/finalize/steps/03-schema-validate.js +11 -0
- package/dist/finalize/steps/04-run-checks.js +118 -0
- package/dist/finalize/steps/05-generate-report.js +14 -0
- package/dist/finalize/steps/06-commit.js +39 -0
- package/dist/finalize/steps/07-push.js +10 -0
- package/dist/finalize/steps/08-create-pr.js +9 -0
- package/dist/finalize/steps/09-update-state.js +9 -0
- package/dist/finalize/steps/10-append-jsonl.js +23 -0
- package/dist/finalize/steps/11-update-linear.js +22 -0
- package/dist/finalize/steps/12-archive.js +21 -0
- package/dist/graph/adapter/c/adapter.js +45 -0
- package/dist/graph/adapter/c/extract.js +135 -0
- package/dist/graph/adapter/c/index.js +10 -0
- package/dist/graph/adapter/c/runtime.js +67 -0
- package/dist/graph/adapter/cpp/adapter.js +45 -0
- package/dist/graph/adapter/cpp/extract.js +159 -0
- package/dist/graph/adapter/cpp/index.js +10 -0
- package/dist/graph/adapter/cpp/runtime.js +61 -0
- package/dist/graph/adapter/csharp/adapter.js +45 -0
- package/dist/graph/adapter/csharp/extract.js +127 -0
- package/dist/graph/adapter/csharp/index.js +10 -0
- package/dist/graph/adapter/csharp/runtime.js +61 -0
- package/dist/graph/adapter/dart/adapter.js +56 -0
- package/dist/graph/adapter/dart/extract.js +130 -0
- package/dist/graph/adapter/dart/index.js +10 -0
- package/dist/graph/adapter/dart/runtime.js +61 -0
- package/dist/graph/adapter/go/adapter.js +45 -0
- package/dist/graph/adapter/go/extract.js +112 -0
- package/dist/graph/adapter/go/index.js +10 -0
- package/dist/graph/adapter/go/runtime.js +58 -0
- package/dist/graph/adapter/kotlin-java/extract-common.js +83 -0
- package/dist/graph/adapter/kotlin-java/index.js +15 -0
- package/dist/graph/adapter/kotlin-java/java-adapter.js +45 -0
- package/dist/graph/adapter/kotlin-java/java-extract.js +42 -0
- package/dist/graph/adapter/kotlin-java/kotlin-adapter.js +48 -0
- package/dist/graph/adapter/kotlin-java/kotlin-extract.js +58 -0
- package/dist/graph/adapter/kotlin-java/runtime.js +75 -0
- package/dist/graph/adapter/python/adapter.js +45 -0
- package/dist/graph/adapter/python/extract.js +121 -0
- package/dist/graph/adapter/python/index.js +10 -0
- package/dist/graph/adapter/python/runtime.js +70 -0
- package/dist/graph/adapter/registry.js +82 -0
- package/dist/graph/adapter/rust/adapter.js +45 -0
- package/dist/graph/adapter/rust/extract.js +110 -0
- package/dist/graph/adapter/rust/index.js +10 -0
- package/dist/graph/adapter/rust/runtime.js +74 -0
- package/dist/graph/adapter/shell/adapter.js +34 -0
- package/dist/graph/adapter/shell/extract.js +98 -0
- package/dist/graph/adapter/shell/index.js +8 -0
- package/dist/graph/adapter/svelte/adapter.js +91 -0
- package/dist/graph/adapter/svelte/extract.js +41 -0
- package/dist/graph/adapter/svelte/index.js +8 -0
- package/dist/graph/adapter/swift/adapter.js +45 -0
- package/dist/graph/adapter/swift/extract.js +120 -0
- package/dist/graph/adapter/swift/index.js +10 -0
- package/dist/graph/adapter/swift/runtime.js +70 -0
- package/dist/graph/adapter/types.js +2 -0
- package/dist/graph/adapter/typescript-javascript/adapter.js +72 -0
- package/dist/graph/adapter/typescript-javascript/extract.js +115 -0
- package/dist/graph/adapter/typescript-javascript/index.js +10 -0
- package/dist/graph/adapter/typescript-javascript/runtime.js +97 -0
- package/dist/graph/capability/index.js +105 -0
- package/dist/graph/governance.js +104 -0
- package/dist/graph/parser/extract.js +5 -0
- package/dist/graph/parser/loader.js +2 -0
- package/dist/graph/parser/pipeline.js +194 -0
- package/dist/graph/query/index.js +277 -0
- package/dist/graph/query/types.js +5 -0
- package/dist/graph/resolver/build-edges.js +211 -0
- package/dist/graph/resolver/index.js +23 -0
- package/dist/graph/resolver/resolve-imports.js +168 -0
- package/dist/graph/store/adapter.js +132 -0
- package/dist/graph/store/queries.js +124 -0
- package/dist/graph/store/types.js +4 -0
- package/dist/ignore/defaults.js +41 -0
- package/dist/ignore/parser.js +39 -0
- package/dist/lint/map-reference-validator.js +72 -0
- package/dist/loop/abort.js +188 -0
- package/dist/loop/abort.test.js +151 -0
- package/dist/loop/adapters/__tests__/terminal-cli.test.js +92 -0
- package/dist/loop/adapters/agent-subtask.js +137 -0
- package/dist/loop/adapters/agent-subtask.test.js +151 -0
- package/dist/loop/adapters/cli-subtask-bridge.js +108 -0
- package/dist/loop/adapters/index.js +9 -0
- package/dist/loop/adapters/registry.js +17 -0
- package/dist/loop/adapters/terminal-cli.js +403 -0
- package/dist/loop/adapters/types.js +2 -0
- package/dist/loop/adapters/worker-instructions.js +85 -0
- package/dist/loop/body-parser.js +226 -0
- package/dist/loop/bootstrap-packet.js +97 -0
- package/dist/loop/bootstrap-packet.test.js +171 -0
- package/dist/loop/branch-governance.js +54 -0
- package/dist/loop/budget.js +63 -0
- package/dist/loop/budget.test.js +163 -0
- package/dist/loop/checkpoint.js +325 -0
- package/dist/loop/compact-return.js +59 -0
- package/dist/loop/continue.js +645 -0
- package/dist/loop/continue.test.js +337 -0
- package/dist/loop/dispatch-boundary.js +335 -0
- package/dist/loop/dispatch-state.js +223 -0
- package/dist/loop/dispatch-state.test.js +186 -0
- package/dist/loop/dispatch.js +1236 -0
- package/dist/loop/dispatch.test.js +499 -0
- package/dist/loop/ephemeral-smoke.test.js +160 -0
- package/dist/loop/evidence-backfill.js +216 -0
- package/dist/loop/execution-adapter.js +141 -0
- package/dist/loop/execution-adapter.test.js +66 -0
- package/dist/loop/finalize-evidence.js +169 -0
- package/dist/loop/git-custody.js +250 -0
- package/dist/loop/impl-packet-input.js +38 -0
- package/dist/loop/index.js +270 -0
- package/dist/loop/ledger.js +49 -0
- package/dist/loop/ledger.test.js +127 -0
- package/dist/loop/lifecycle-dispatch.js +348 -0
- package/dist/loop/lifecycle-dispatch.test.js +318 -0
- package/dist/loop/lifecycle.js +93 -0
- package/dist/loop/lifecycle.test.js +150 -0
- package/dist/loop/orphan-recovery.js +276 -0
- package/dist/loop/orphan-recovery.test.js +236 -0
- package/dist/loop/parent.js +1566 -0
- package/dist/loop/parent.test.js +738 -0
- package/dist/loop/provider-sealed-packet.test.js +164 -0
- package/dist/loop/resume.js +295 -0
- package/dist/loop/resume.test.js +172 -0
- package/dist/loop/run-bootstrap.js +234 -0
- package/dist/loop/run-preflight.js +203 -0
- package/dist/loop/status.js +665 -0
- package/dist/loop/status.test.js +235 -0
- package/dist/loop/wait.js +86 -0
- package/dist/loop/worker-packet.js +406 -0
- package/dist/loop/worker-packet.test.js +243 -0
- package/dist/loop/worker-prompt.js +260 -0
- package/dist/loop/worker-prompt.test.js +247 -0
- package/dist/loop/worker.js +498 -0
- package/dist/loop/worker.test.js +372 -0
- package/dist/map/atlas.js +77 -0
- package/dist/map/backfill.js +171 -0
- package/dist/map/backfill.test.js +120 -0
- package/dist/map/index.js +255 -0
- package/dist/map/inference.js +73 -0
- package/dist/map/inference.test.js +35 -0
- package/dist/map/query.js +157 -0
- package/dist/map/query.test.js +174 -0
- package/dist/map/update.js +355 -0
- package/dist/map/update.test.js +67 -0
- package/dist/map/validate.js +153 -0
- package/dist/map/validate.test.js +90 -0
- package/dist/map/welfare.js +86 -0
- package/dist/mcp/lib/invoke.js +35 -0
- package/dist/mcp/lib/redact.js +24 -0
- package/dist/mcp/lib/redact.test.js +112 -0
- package/dist/mcp/lib/root.js +41 -0
- package/dist/mcp/lib/root.test.js +114 -0
- package/dist/mcp/server.js +15 -0
- package/dist/mcp/tools/claim-child.js +119 -0
- package/dist/mcp/tools/claim-child.test.js +69 -0
- package/dist/mcp/tools/current-state.js +73 -0
- package/dist/mcp/tools/current-state.test.js +114 -0
- package/dist/mcp/tools/dispatch-result.js +186 -0
- package/dist/mcp/tools/dispatch-result.test.js +109 -0
- package/dist/mcp/tools/index.js +222 -0
- package/dist/mcp/tools/index.test.js +172 -0
- package/dist/mcp/tools/linear.js +74 -0
- package/dist/mcp/tools/loop-continue.js +159 -0
- package/dist/mcp/tools/loop-continue.test.js +186 -0
- package/dist/mcp/tools/loop-dry-run.js +15 -0
- package/dist/mcp/tools/status.js +65 -0
- package/dist/medic/chart-id.js +75 -0
- package/dist/medic/chart-schema.js +139 -0
- package/dist/runs/index.js +119 -0
- package/dist/runs/index.test.js +184 -0
- package/dist/runs/ledger-tail.js +15 -0
- package/dist/runs/list.js +29 -0
- package/dist/runs/reconcile.js +74 -0
- package/dist/runs/show.js +10 -0
- package/dist/runtime/audit/logger.js +15 -0
- package/dist/runtime/audit/reader.js +42 -0
- package/dist/runtime/checkpoint.js +89 -0
- package/dist/runtime/continuation/confirmed.js +225 -0
- package/dist/runtime/continuation/confirmed.test.js +421 -0
- package/dist/runtime/continuation/dry-run.js +74 -0
- package/dist/runtime/execution-window.js +106 -0
- package/dist/runtime/scheduling/child-selector.js +16 -0
- package/dist/runtime/state.js +43 -0
- package/dist/runtime/status.js +46 -0
- package/dist/runtime/verification/envelope.js +80 -0
- package/dist/runtime/verification/fingerprint.js +26 -0
- package/dist/skill-packet/cli.test.js +105 -0
- package/dist/skill-packet/generator.js +225 -0
- package/dist/skill-packet/generator.test.js +159 -0
- package/dist/skill-packet/index.js +49 -0
- package/dist/skill-packet/types.js +2 -0
- package/dist/smartdocs-engine/audit.js +194 -0
- package/dist/smartdocs-engine/audit.test.js +122 -0
- package/dist/smartdocs-engine/canon-check.js +340 -0
- package/dist/smartdocs-engine/canon-check.test.js +234 -0
- package/dist/smartdocs-engine/doctrine.js +633 -0
- package/dist/smartdocs-engine/doctrine.test.js +374 -0
- package/dist/smartdocs-engine/index.js +456 -0
- package/dist/smartdocs-engine/index.test.js +82 -0
- package/dist/smartdocs-engine/ingest.js +495 -0
- package/dist/smartdocs-engine/ingest.test.js +163 -0
- package/dist/smartdocs-engine/migrate.js +217 -0
- package/dist/smartdocs-engine/migrate.test.js +200 -0
- package/dist/smartdocs-engine/seed-instructions.js +335 -0
- package/dist/smartdocs-engine/seed-instructions.test.js +275 -0
- package/dist/smartdocs-engine/smartdoc-ignore.js +258 -0
- package/dist/smartdocs-engine/smartdoc-ignore.test.js +146 -0
- package/dist/smartdocs-engine/validate-instructions.js +366 -0
- package/dist/smartdocs-engine/validate-instructions.test.js +283 -0
- package/dist/tracker/adapters/github/index.js +305 -0
- package/dist/tracker/adapters/jira/index.js +293 -0
- package/dist/tracker/adapters/linear/http-errors.test.js +51 -0
- package/dist/tracker/adapters/linear/index.js +621 -0
- package/dist/tracker/adapters/linear/index.test.js +238 -0
- package/dist/tracker/adapters/linear.js +50 -0
- package/dist/tracker/adapters/local/index.js +10 -0
- package/dist/tracker/adapters/local-file/index.js +159 -0
- package/dist/tracker/adapters/mcp-bridge.js +158 -0
- package/dist/tracker/adapters/mcp-bridge.test.js +12 -0
- package/dist/tracker/adapters/spec/index.js +146 -0
- package/dist/tracker/capabilities.js +2 -0
- package/dist/tracker/index.js +49 -0
- package/dist/tracker/lifecycle-policy.js +139 -0
- package/dist/tracker/lifecycle-transition.js +164 -0
- package/dist/tracker/local-graph.js +98 -0
- package/dist/tracker/migration.js +56 -0
- package/dist/tracker/schema.js +86 -0
- package/dist/tracker/sync/index.js +404 -0
- package/dist/tracker/sync/queue-store.js +95 -0
- package/dist/tracker/sync/queue-store.test.js +104 -0
- package/dist/tracker/types.js +11 -0
- package/dist/types/linear.js +3 -0
- package/dist/types/result-packet.js +12 -0
- package/dist/types/runtime-state.js +2 -0
- package/dist/types/work-contract.js +2 -0
- package/dist/utils/monotonic-timestamp.js +13 -0
- package/dist/utils/monotonic-timestamp.test.js +19 -0
- package/package.json +64 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const node_os_1 = require("node:os");
|
|
7
|
+
const canon_check_js_1 = require("./canon-check.js");
|
|
8
|
+
function makeTestDir() {
|
|
9
|
+
const dir = (0, node_path_1.join)((0, node_os_1.tmpdir)(), `canon-check-test-${Date.now()}`);
|
|
10
|
+
(0, node_fs_1.mkdirSync)(dir, { recursive: true });
|
|
11
|
+
return dir;
|
|
12
|
+
}
|
|
13
|
+
function makeTelemetryFile(dir) {
|
|
14
|
+
const telDir = (0, node_path_1.join)(dir, "telemetry");
|
|
15
|
+
(0, node_fs_1.mkdirSync)(telDir, { recursive: true });
|
|
16
|
+
return (0, node_path_1.join)(telDir, "telemetry.jsonl");
|
|
17
|
+
}
|
|
18
|
+
(0, vitest_1.describe)("runCanonCheck", () => {
|
|
19
|
+
let testDir;
|
|
20
|
+
let telemetryFile;
|
|
21
|
+
(0, vitest_1.beforeEach)(() => {
|
|
22
|
+
testDir = makeTestDir();
|
|
23
|
+
telemetryFile = makeTelemetryFile(testDir);
|
|
24
|
+
});
|
|
25
|
+
(0, vitest_1.afterEach)(() => {
|
|
26
|
+
(0, node_fs_1.rmSync)(testDir, { recursive: true, force: true });
|
|
27
|
+
});
|
|
28
|
+
(0, vitest_1.describe)("aligned outcome", () => {
|
|
29
|
+
(0, vitest_1.it)("returns aligned when no changed files are provided", () => {
|
|
30
|
+
const result = (0, canon_check_js_1.runCanonCheck)({
|
|
31
|
+
repoRoot: testDir,
|
|
32
|
+
changedFiles: [],
|
|
33
|
+
runId: "test-run-1",
|
|
34
|
+
telemetryFile,
|
|
35
|
+
});
|
|
36
|
+
(0, vitest_1.expect)(result.outcome).toBe("aligned");
|
|
37
|
+
(0, vitest_1.expect)(result.conflicts).toEqual([]);
|
|
38
|
+
});
|
|
39
|
+
(0, vitest_1.it)("returns aligned when no POLARIS.md or canon dirs exist", () => {
|
|
40
|
+
const result = (0, canon_check_js_1.runCanonCheck)({
|
|
41
|
+
repoRoot: testDir,
|
|
42
|
+
changedFiles: ["src/loop/continue.ts"],
|
|
43
|
+
runId: "test-run-1",
|
|
44
|
+
telemetryFile,
|
|
45
|
+
});
|
|
46
|
+
(0, vitest_1.expect)(result.outcome).toBe("aligned");
|
|
47
|
+
(0, vitest_1.expect)(result.conflicts).toEqual([]);
|
|
48
|
+
});
|
|
49
|
+
(0, vitest_1.it)("returns aligned when POLARIS.md has no rules mentioning changed files as deleted", () => {
|
|
50
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(testDir, "src", "loop"), { recursive: true });
|
|
51
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(testDir, "src", "loop", "continue.ts"), "// placeholder");
|
|
52
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(testDir, "POLARIS.md"), [
|
|
53
|
+
"# POLARIS.md",
|
|
54
|
+
"",
|
|
55
|
+
"## Editing rules",
|
|
56
|
+
"- State writes must use checkpoint.ts",
|
|
57
|
+
"- Keep loop files small",
|
|
58
|
+
"",
|
|
59
|
+
"## Architecture assumptions",
|
|
60
|
+
"- Bootstrap packets are immutable once written",
|
|
61
|
+
].join("\n"));
|
|
62
|
+
const result = (0, canon_check_js_1.runCanonCheck)({
|
|
63
|
+
repoRoot: testDir,
|
|
64
|
+
changedFiles: ["src/loop/continue.ts"],
|
|
65
|
+
runId: "test-run-1",
|
|
66
|
+
telemetryFile,
|
|
67
|
+
});
|
|
68
|
+
(0, vitest_1.expect)(result.outcome).toBe("aligned");
|
|
69
|
+
(0, vitest_1.expect)(result.conflicts).toEqual([]);
|
|
70
|
+
});
|
|
71
|
+
(0, vitest_1.it)("sets canonFilesInspected based on found canon files", () => {
|
|
72
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(testDir, "POLARIS.md"), "# POLARIS.md\n## Editing rules\n- No special rules\n");
|
|
73
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(testDir, "src"), { recursive: true });
|
|
74
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(testDir, "src", "foo.ts"), "// code");
|
|
75
|
+
const result = (0, canon_check_js_1.runCanonCheck)({
|
|
76
|
+
repoRoot: testDir,
|
|
77
|
+
changedFiles: ["src/foo.ts"],
|
|
78
|
+
runId: "test-run-1",
|
|
79
|
+
telemetryFile,
|
|
80
|
+
});
|
|
81
|
+
(0, vitest_1.expect)(result.canonFilesInspected).toBeGreaterThan(0);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
(0, vitest_1.describe)("SUMMARY.md exclusion", () => {
|
|
85
|
+
(0, vitest_1.it)("excludes SUMMARY.md from triggering canon lookup", () => {
|
|
86
|
+
// Create a POLARIS.md that would normally be found
|
|
87
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(testDir, "POLARIS.md"), "# POLARIS.md\n");
|
|
88
|
+
const result = (0, canon_check_js_1.runCanonCheck)({
|
|
89
|
+
repoRoot: testDir,
|
|
90
|
+
changedFiles: ["SUMMARY.md"],
|
|
91
|
+
runId: "test-summary-exclude",
|
|
92
|
+
telemetryFile,
|
|
93
|
+
});
|
|
94
|
+
// Should not find any canon files because SUMMARY.md was ignored
|
|
95
|
+
(0, vitest_1.expect)(result.canonFilesInspected).toBe(0);
|
|
96
|
+
(0, vitest_1.expect)(result.outcome).toBe("aligned");
|
|
97
|
+
});
|
|
98
|
+
(0, vitest_1.it)("does not report conflicts for SUMMARY.md even if it contains 'must' and 'deleted'", () => {
|
|
99
|
+
// Create a SUMMARY.md with modal verbs that would normally trigger checkDocFile
|
|
100
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(testDir, "SUMMARY.md"), "Agents must not use old-file.ts as it is deleted.");
|
|
101
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(testDir, "docs", "doctrine", "active"), { recursive: true });
|
|
102
|
+
const result = (0, canon_check_js_1.runCanonCheck)({
|
|
103
|
+
repoRoot: testDir,
|
|
104
|
+
changedFiles: ["src/some-file.ts"],
|
|
105
|
+
runId: "test-summary-no-conflict",
|
|
106
|
+
telemetryFile,
|
|
107
|
+
});
|
|
108
|
+
(0, vitest_1.expect)(result.conflicts).toHaveLength(0);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
(0, vitest_1.describe)("stale-implementation outcome", () => {
|
|
112
|
+
(0, vitest_1.it)("returns stale-implementation when POLARIS.md says a file is deleted but it still exists", () => {
|
|
113
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(testDir, "src", "loop"), { recursive: true });
|
|
114
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(testDir, "src", "loop", "old-module.ts"), "// still here");
|
|
115
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(testDir, "POLARIS.md"), [
|
|
116
|
+
"# POLARIS.md",
|
|
117
|
+
"",
|
|
118
|
+
"## Architecture assumptions",
|
|
119
|
+
"- old-module.ts has been deleted and must not be used",
|
|
120
|
+
].join("\n"));
|
|
121
|
+
const result = (0, canon_check_js_1.runCanonCheck)({
|
|
122
|
+
repoRoot: testDir,
|
|
123
|
+
changedFiles: ["src/loop/old-module.ts"],
|
|
124
|
+
runId: "test-run-1",
|
|
125
|
+
telemetryFile,
|
|
126
|
+
});
|
|
127
|
+
(0, vitest_1.expect)(result.outcome).toBe("stale-implementation");
|
|
128
|
+
(0, vitest_1.expect)(result.conflicts.length).toBeGreaterThan(0);
|
|
129
|
+
(0, vitest_1.expect)(result.conflicts[0].type).toBe("stale-implementation");
|
|
130
|
+
});
|
|
131
|
+
(0, vitest_1.it)("emits canon-conflict-halt telemetry event on stale-implementation", () => {
|
|
132
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(testDir, "src"), { recursive: true });
|
|
133
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(testDir, "src", "legacy.ts"), "// still exists");
|
|
134
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(testDir, "POLARIS.md"), [
|
|
135
|
+
"# POLARIS.md",
|
|
136
|
+
"",
|
|
137
|
+
"## Architecture assumptions",
|
|
138
|
+
"- legacy.ts has been removed and should not be referenced",
|
|
139
|
+
].join("\n"));
|
|
140
|
+
(0, canon_check_js_1.runCanonCheck)({
|
|
141
|
+
repoRoot: testDir,
|
|
142
|
+
changedFiles: ["src/legacy.ts"],
|
|
143
|
+
runId: "test-run-halt",
|
|
144
|
+
telemetryFile,
|
|
145
|
+
childId: "POL-99",
|
|
146
|
+
});
|
|
147
|
+
const lines = (0, node_fs_1.readFileSync)(telemetryFile, "utf-8")
|
|
148
|
+
.trim()
|
|
149
|
+
.split("\n")
|
|
150
|
+
.map((l) => JSON.parse(l));
|
|
151
|
+
const halt = lines.find((e) => e.event === "canon-conflict-halt");
|
|
152
|
+
(0, vitest_1.expect)(halt).toBeTruthy();
|
|
153
|
+
(0, vitest_1.expect)(halt.run_id).toBe("test-run-halt");
|
|
154
|
+
(0, vitest_1.expect)(halt.child_id).toBe("POL-99");
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
(0, vitest_1.describe)("telemetry events", () => {
|
|
158
|
+
(0, vitest_1.it)("emits canon-check-start event", () => {
|
|
159
|
+
(0, canon_check_js_1.runCanonCheck)({
|
|
160
|
+
repoRoot: testDir,
|
|
161
|
+
changedFiles: ["src/foo.ts"],
|
|
162
|
+
runId: "test-run-tel",
|
|
163
|
+
telemetryFile,
|
|
164
|
+
childId: "POL-51",
|
|
165
|
+
});
|
|
166
|
+
const lines = (0, node_fs_1.readFileSync)(telemetryFile, "utf-8")
|
|
167
|
+
.trim()
|
|
168
|
+
.split("\n")
|
|
169
|
+
.map((l) => JSON.parse(l));
|
|
170
|
+
const start = lines.find((e) => e.event === "canon-check-start");
|
|
171
|
+
(0, vitest_1.expect)(start).toBeTruthy();
|
|
172
|
+
(0, vitest_1.expect)(start.run_id).toBe("test-run-tel");
|
|
173
|
+
(0, vitest_1.expect)(start.child_id).toBe("POL-51");
|
|
174
|
+
(0, vitest_1.expect)(typeof start.changed_files_count).toBe("number");
|
|
175
|
+
});
|
|
176
|
+
(0, vitest_1.it)("emits canon-check-result event for aligned outcome", () => {
|
|
177
|
+
(0, canon_check_js_1.runCanonCheck)({
|
|
178
|
+
repoRoot: testDir,
|
|
179
|
+
changedFiles: [],
|
|
180
|
+
runId: "test-run-aligned",
|
|
181
|
+
telemetryFile,
|
|
182
|
+
});
|
|
183
|
+
const lines = (0, node_fs_1.readFileSync)(telemetryFile, "utf-8")
|
|
184
|
+
.trim()
|
|
185
|
+
.split("\n")
|
|
186
|
+
.map((l) => JSON.parse(l));
|
|
187
|
+
const result = lines.find((e) => e.event === "canon-check-result");
|
|
188
|
+
(0, vitest_1.expect)(result).toBeTruthy();
|
|
189
|
+
(0, vitest_1.expect)(result.outcome).toBe("aligned");
|
|
190
|
+
(0, vitest_1.expect)(result.conflicts).toEqual([]);
|
|
191
|
+
});
|
|
192
|
+
(0, vitest_1.it)("sets child_id to null when not provided", () => {
|
|
193
|
+
(0, canon_check_js_1.runCanonCheck)({
|
|
194
|
+
repoRoot: testDir,
|
|
195
|
+
changedFiles: [],
|
|
196
|
+
runId: "test-run-no-child",
|
|
197
|
+
telemetryFile,
|
|
198
|
+
});
|
|
199
|
+
const lines = (0, node_fs_1.readFileSync)(telemetryFile, "utf-8")
|
|
200
|
+
.trim()
|
|
201
|
+
.split("\n")
|
|
202
|
+
.map((l) => JSON.parse(l));
|
|
203
|
+
const start = lines.find((e) => e.event === "canon-check-start");
|
|
204
|
+
(0, vitest_1.expect)(start.child_id).toBeNull();
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
(0, vitest_1.describe)("config flags", () => {
|
|
208
|
+
(0, vitest_1.it)("does not alter return value — callers control skip logic", () => {
|
|
209
|
+
// canon-check itself has no checkOnContinue/checkOnFinalize logic;
|
|
210
|
+
// skipping is the caller's responsibility. Just verify function is callable.
|
|
211
|
+
const checkResult = (0, canon_check_js_1.runCanonCheck)({
|
|
212
|
+
repoRoot: testDir,
|
|
213
|
+
changedFiles: [],
|
|
214
|
+
runId: "test-flag",
|
|
215
|
+
telemetryFile,
|
|
216
|
+
});
|
|
217
|
+
(0, vitest_1.expect)(checkResult).toBeDefined();
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
(0, vitest_1.describe)("POLARIS.md nearest ancestor lookup", () => {
|
|
221
|
+
(0, vitest_1.it)("finds POLARIS.md in a parent directory", () => {
|
|
222
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(testDir, "src", "loop", "deep"), { recursive: true });
|
|
223
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(testDir, "src", "loop", "deep", "file.ts"), "// code");
|
|
224
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(testDir, "src", "POLARIS.md"), "# POLARIS.md\n## Editing rules\n- no rules\n");
|
|
225
|
+
const result = (0, canon_check_js_1.runCanonCheck)({
|
|
226
|
+
repoRoot: testDir,
|
|
227
|
+
changedFiles: ["src/loop/deep/file.ts"],
|
|
228
|
+
runId: "test-ancestor",
|
|
229
|
+
telemetryFile,
|
|
230
|
+
});
|
|
231
|
+
(0, vitest_1.expect)(result.canonFilesInspected).toBeGreaterThan(0);
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
});
|