@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,374 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const node_fs_1 = require("node:fs");
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
const node_fs_2 = require("node:fs");
|
|
6
|
+
const node_os_1 = require("node:os");
|
|
7
|
+
const vitest_1 = require("vitest");
|
|
8
|
+
const doctrine_js_1 = require("./doctrine.js");
|
|
9
|
+
function makeTempDir() {
|
|
10
|
+
const root = (0, node_fs_2.mkdtempSync)((0, node_path_1.join)((0, node_os_1.tmpdir)(), "polaris-doctrine-"));
|
|
11
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(root, "smartdocs", "docs", "raw"), { recursive: true });
|
|
12
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(root, "smartdocs", "docs", "doctrine", "candidate"), { recursive: true });
|
|
13
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(root, "smartdocs", "docs", "doctrine", "active"), { recursive: true });
|
|
14
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(root, "smartdocs", "docs", "doctrine", "deprecated"), { recursive: true });
|
|
15
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(root, "smartdocs", "docs", "specs", "active"), { recursive: true });
|
|
16
|
+
return root;
|
|
17
|
+
}
|
|
18
|
+
(0, vitest_1.describe)("doctrineDraft", () => {
|
|
19
|
+
let repoRoot;
|
|
20
|
+
(0, vitest_1.beforeEach)(() => {
|
|
21
|
+
repoRoot = makeTempDir();
|
|
22
|
+
});
|
|
23
|
+
(0, vitest_1.it)("moves a file from smartdocs/docs/raw/ to smartdocs/docs/doctrine/candidate/ with candidate marker", () => {
|
|
24
|
+
const source = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "raw", "some-doc.md");
|
|
25
|
+
(0, node_fs_1.writeFileSync)(source, "# Some Doc\n\nContent here.");
|
|
26
|
+
const result = (0, doctrine_js_1.doctrineDraft)(source, { repoRoot, runId: "test-run-001" });
|
|
27
|
+
(0, vitest_1.expect)(result.destination).toBe((0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "candidate", "some-doc.md"));
|
|
28
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(result.destination)).toBe(true);
|
|
29
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(source)).toBe(false);
|
|
30
|
+
const content = (0, node_fs_1.readFileSync)(result.destination, "utf-8");
|
|
31
|
+
(0, vitest_1.expect)(content.startsWith(doctrine_js_1.CANDIDATE_MARKER)).toBe(true);
|
|
32
|
+
(0, vitest_1.expect)(content).toContain("# Some Doc");
|
|
33
|
+
});
|
|
34
|
+
(0, vitest_1.it)("emits a doctrine-draft event to lifecycle.jsonl", () => {
|
|
35
|
+
const source = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "raw", "event-doc.md");
|
|
36
|
+
(0, node_fs_1.writeFileSync)(source, "# Event Doc");
|
|
37
|
+
const result = (0, doctrine_js_1.doctrineDraft)(source, { repoRoot, runId: "test-run-001" });
|
|
38
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(result.lifecyclePath)).toBe(true);
|
|
39
|
+
const event = JSON.parse((0, node_fs_1.readFileSync)(result.lifecyclePath, "utf-8").trim().split("\n")[0]);
|
|
40
|
+
(0, vitest_1.expect)(event.event).toBe("doctrine-draft");
|
|
41
|
+
(0, vitest_1.expect)(event.run_id).toBe("test-run-001");
|
|
42
|
+
(0, vitest_1.expect)(event.source).toBe(source);
|
|
43
|
+
(0, vitest_1.expect)(event.destination).toBe(result.destination);
|
|
44
|
+
});
|
|
45
|
+
(0, vitest_1.it)("throws if source does not exist", () => {
|
|
46
|
+
(0, vitest_1.expect)(() => (0, doctrine_js_1.doctrineDraft)((0, node_path_1.join)(repoRoot, "smartdocs", "docs", "raw", "nonexistent.md"), { repoRoot })).toThrow("Source file not found");
|
|
47
|
+
});
|
|
48
|
+
(0, vitest_1.it)("throws if source is not in smartdocs/docs/raw/", () => {
|
|
49
|
+
const source = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "active", "wrong.md");
|
|
50
|
+
(0, node_fs_1.writeFileSync)(source, "# Wrong location");
|
|
51
|
+
(0, vitest_1.expect)(() => (0, doctrine_js_1.doctrineDraft)(source, { repoRoot })).toThrow("doctrineDraft source must be in smartdocs/docs/raw/");
|
|
52
|
+
});
|
|
53
|
+
(0, vitest_1.it)("throws if destination already exists", () => {
|
|
54
|
+
const source = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "raw", "dupe.md");
|
|
55
|
+
(0, node_fs_1.writeFileSync)(source, "# Dupe");
|
|
56
|
+
const dest = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "candidate", "dupe.md");
|
|
57
|
+
(0, node_fs_1.writeFileSync)(dest, "# Already there");
|
|
58
|
+
(0, vitest_1.expect)(() => (0, doctrine_js_1.doctrineDraft)(source, { repoRoot })).toThrow("Destination already exists");
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
(0, vitest_1.describe)("doctrinePromote", () => {
|
|
62
|
+
let repoRoot;
|
|
63
|
+
(0, vitest_1.beforeEach)(() => {
|
|
64
|
+
repoRoot = makeTempDir();
|
|
65
|
+
});
|
|
66
|
+
const governanceFrontMatter = [
|
|
67
|
+
"---",
|
|
68
|
+
"status: candidate",
|
|
69
|
+
"doc-type: doctrine",
|
|
70
|
+
"confidence: 0.9",
|
|
71
|
+
"recommended-action: promote",
|
|
72
|
+
"overlap-analysis: none",
|
|
73
|
+
"---",
|
|
74
|
+
"",
|
|
75
|
+
].join("\n");
|
|
76
|
+
(0, vitest_1.it)("moves a file from candidate/ to active/ and strips the candidate marker", () => {
|
|
77
|
+
const candidatePath = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "candidate", "my-doctrine.md");
|
|
78
|
+
(0, node_fs_1.writeFileSync)(candidatePath, `${doctrine_js_1.CANDIDATE_MARKER}\n${governanceFrontMatter}# My Doctrine\n\nContent.`);
|
|
79
|
+
const result = (0, doctrine_js_1.doctrinePromote)(candidatePath, { repoRoot, runId: "test-run-002" });
|
|
80
|
+
(0, vitest_1.expect)(result.destination).toBe((0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "active", "my-doctrine.md"));
|
|
81
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(result.destination)).toBe(true);
|
|
82
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(candidatePath)).toBe(false);
|
|
83
|
+
const content = (0, node_fs_1.readFileSync)(result.destination, "utf-8");
|
|
84
|
+
(0, vitest_1.expect)(content).not.toContain(doctrine_js_1.CANDIDATE_MARKER);
|
|
85
|
+
(0, vitest_1.expect)(content).toContain("# My Doctrine");
|
|
86
|
+
});
|
|
87
|
+
(0, vitest_1.it)("emits a doctrine-promote event to lifecycle.jsonl", () => {
|
|
88
|
+
const candidatePath = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "candidate", "promoted.md");
|
|
89
|
+
(0, node_fs_1.writeFileSync)(candidatePath, `${doctrine_js_1.CANDIDATE_MARKER}\n${governanceFrontMatter}# Promoted`);
|
|
90
|
+
const result = (0, doctrine_js_1.doctrinePromote)(candidatePath, { repoRoot, runId: "test-run-002" });
|
|
91
|
+
const lines = (0, node_fs_1.readFileSync)(result.lifecyclePath, "utf-8").trim().split("\n");
|
|
92
|
+
const promoteEvent = lines.map((l) => JSON.parse(l)).find((e) => e.event === "doctrine-promote");
|
|
93
|
+
(0, vitest_1.expect)(promoteEvent).toBeDefined();
|
|
94
|
+
(0, vitest_1.expect)(promoteEvent.event).toBe("doctrine-promote");
|
|
95
|
+
(0, vitest_1.expect)(promoteEvent.run_id).toBe("test-run-002");
|
|
96
|
+
});
|
|
97
|
+
(0, vitest_1.it)("throws if source is not in smartdocs/docs/doctrine/candidate/", () => {
|
|
98
|
+
const source = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "raw", "wrong.md");
|
|
99
|
+
(0, node_fs_1.writeFileSync)(source, `${doctrine_js_1.CANDIDATE_MARKER}\n# Wrong`);
|
|
100
|
+
(0, vitest_1.expect)(() => (0, doctrine_js_1.doctrinePromote)(source, { repoRoot })).toThrow("doctrinePromote source must be in smartdocs/docs/doctrine/candidate/");
|
|
101
|
+
});
|
|
102
|
+
(0, vitest_1.it)("throws if file is missing the candidate marker", () => {
|
|
103
|
+
const source = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "candidate", "unmarked.md");
|
|
104
|
+
(0, node_fs_1.writeFileSync)(source, "# No marker");
|
|
105
|
+
(0, vitest_1.expect)(() => (0, doctrine_js_1.doctrinePromote)(source, { repoRoot })).toThrow("not in candidate state");
|
|
106
|
+
});
|
|
107
|
+
(0, vitest_1.it)("throws if source does not exist", () => {
|
|
108
|
+
(0, vitest_1.expect)(() => (0, doctrine_js_1.doctrinePromote)((0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "candidate", "ghost.md"), { repoRoot })).toThrow("Source file not found");
|
|
109
|
+
});
|
|
110
|
+
(0, vitest_1.it)("rejects file missing governance fields", () => {
|
|
111
|
+
const candidatePath = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "candidate", "no-gov.md");
|
|
112
|
+
(0, node_fs_1.writeFileSync)(candidatePath, `${doctrine_js_1.CANDIDATE_MARKER}\n# Missing governance`);
|
|
113
|
+
(0, vitest_1.expect)(() => (0, doctrine_js_1.doctrinePromote)(candidatePath, { repoRoot })).toThrow('missing required governance field "doc-type"');
|
|
114
|
+
});
|
|
115
|
+
(0, vitest_1.it)("rejects file with recommended-action: hold", () => {
|
|
116
|
+
const candidatePath = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "candidate", "on-hold.md");
|
|
117
|
+
const content = [
|
|
118
|
+
doctrine_js_1.CANDIDATE_MARKER,
|
|
119
|
+
"---",
|
|
120
|
+
"doc-type: doctrine",
|
|
121
|
+
"confidence: 0.5",
|
|
122
|
+
"recommended-action: hold",
|
|
123
|
+
"overlap-analysis: none",
|
|
124
|
+
"---",
|
|
125
|
+
"",
|
|
126
|
+
"# On hold",
|
|
127
|
+
].join("\n");
|
|
128
|
+
(0, node_fs_1.writeFileSync)(candidatePath, content);
|
|
129
|
+
(0, vitest_1.expect)(() => (0, doctrine_js_1.doctrinePromote)(candidatePath, { repoRoot })).toThrow('recommended-action must be "promote" but got "hold"');
|
|
130
|
+
});
|
|
131
|
+
(0, vitest_1.it)("succeeds with all required governance fields present", () => {
|
|
132
|
+
const candidatePath = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "candidate", "governed.md");
|
|
133
|
+
const content = [
|
|
134
|
+
doctrine_js_1.CANDIDATE_MARKER,
|
|
135
|
+
"---",
|
|
136
|
+
"doc-type: doctrine",
|
|
137
|
+
"confidence: 0.95",
|
|
138
|
+
"recommended-action: promote",
|
|
139
|
+
"overlap-analysis: none",
|
|
140
|
+
"---",
|
|
141
|
+
"",
|
|
142
|
+
"# Governed doc",
|
|
143
|
+
].join("\n");
|
|
144
|
+
(0, node_fs_1.writeFileSync)(candidatePath, content);
|
|
145
|
+
const result = (0, doctrine_js_1.doctrinePromote)(candidatePath, { repoRoot, runId: "test-run-gov" });
|
|
146
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(result.destination)).toBe(true);
|
|
147
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(candidatePath)).toBe(false);
|
|
148
|
+
});
|
|
149
|
+
(0, vitest_1.it)("moves co-located .provenance.json sidecar alongside the .md", () => {
|
|
150
|
+
const candidatePath = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "candidate", "with-prov.md");
|
|
151
|
+
const provenanceSrc = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "candidate", "with-prov.provenance.json");
|
|
152
|
+
const content = [
|
|
153
|
+
doctrine_js_1.CANDIDATE_MARKER,
|
|
154
|
+
"---",
|
|
155
|
+
"doc-type: doctrine",
|
|
156
|
+
"confidence: 0.9",
|
|
157
|
+
"recommended-action: promote",
|
|
158
|
+
"overlap-analysis: none",
|
|
159
|
+
"---",
|
|
160
|
+
"",
|
|
161
|
+
"# With Provenance",
|
|
162
|
+
].join("\n");
|
|
163
|
+
(0, node_fs_1.writeFileSync)(candidatePath, content);
|
|
164
|
+
(0, node_fs_1.writeFileSync)(provenanceSrc, JSON.stringify({ classifiedAs: "doctrine-candidate" }));
|
|
165
|
+
const result = (0, doctrine_js_1.doctrinePromote)(candidatePath, { repoRoot, runId: "test-run-prov" });
|
|
166
|
+
const provenanceDest = result.destination.replace(/\.md$/, ".provenance.json");
|
|
167
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(provenanceDest)).toBe(true);
|
|
168
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(provenanceSrc)).toBe(false);
|
|
169
|
+
});
|
|
170
|
+
(0, vitest_1.it)("succeeds without error when no .provenance.json sidecar exists", () => {
|
|
171
|
+
const candidatePath = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "candidate", "no-prov.md");
|
|
172
|
+
const content = [
|
|
173
|
+
doctrine_js_1.CANDIDATE_MARKER,
|
|
174
|
+
"---",
|
|
175
|
+
"doc-type: doctrine",
|
|
176
|
+
"confidence: 0.9",
|
|
177
|
+
"recommended-action: promote",
|
|
178
|
+
"overlap-analysis: none",
|
|
179
|
+
"---",
|
|
180
|
+
"",
|
|
181
|
+
"# No Provenance",
|
|
182
|
+
].join("\n");
|
|
183
|
+
(0, node_fs_1.writeFileSync)(candidatePath, content);
|
|
184
|
+
const result = (0, doctrine_js_1.doctrinePromote)(candidatePath, { repoRoot, runId: "test-run-noprov" });
|
|
185
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(result.destination)).toBe(true);
|
|
186
|
+
});
|
|
187
|
+
(0, vitest_1.it)("emits audit.jsonl event on successful promotion", () => {
|
|
188
|
+
const candidatePath = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "candidate", "audited.md");
|
|
189
|
+
const content = [
|
|
190
|
+
doctrine_js_1.CANDIDATE_MARKER,
|
|
191
|
+
"---",
|
|
192
|
+
"doc-type: doctrine",
|
|
193
|
+
"confidence: 0.9",
|
|
194
|
+
"recommended-action: promote",
|
|
195
|
+
"overlap-analysis: minimal overlap with existing docs",
|
|
196
|
+
"---",
|
|
197
|
+
"",
|
|
198
|
+
"# Audited doc",
|
|
199
|
+
].join("\n");
|
|
200
|
+
(0, node_fs_1.writeFileSync)(candidatePath, content);
|
|
201
|
+
const result = (0, doctrine_js_1.doctrinePromote)(candidatePath, { repoRoot, runId: "test-run-audit" });
|
|
202
|
+
const auditPath = (0, node_path_1.join)(repoRoot, ".taskchain_artifacts", "polaris-doctrine", "test-run-audit", "audit.jsonl");
|
|
203
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(auditPath)).toBe(true);
|
|
204
|
+
const auditEvent = JSON.parse((0, node_fs_1.readFileSync)(auditPath, "utf-8").trim());
|
|
205
|
+
(0, vitest_1.expect)(auditEvent.event).toBe("doctrine-promoted");
|
|
206
|
+
(0, vitest_1.expect)(auditEvent.run_id).toBe("test-run-audit");
|
|
207
|
+
(0, vitest_1.expect)(auditEvent.doc_type).toBe("doctrine");
|
|
208
|
+
(0, vitest_1.expect)(auditEvent.confidence).toBe(0.9);
|
|
209
|
+
(0, vitest_1.expect)(auditEvent.recommended_action).toBe("promote");
|
|
210
|
+
(0, vitest_1.expect)(auditEvent.overlap_analysis).toBe("minimal overlap with existing docs");
|
|
211
|
+
(0, vitest_1.expect)(auditEvent.promoted_by).toBe("polaris-cli");
|
|
212
|
+
(0, vitest_1.expect)(result.destination).toBeDefined();
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
(0, vitest_1.describe)("addCandidateGovernanceMetadata", () => {
|
|
216
|
+
(0, vitest_1.it)("adds governance fields to content without front matter", () => {
|
|
217
|
+
const result = (0, doctrine_js_1.addCandidateGovernanceMetadata)("# Hello", "doctrine");
|
|
218
|
+
(0, vitest_1.expect)(result).toContain("doc-type: doctrine");
|
|
219
|
+
(0, vitest_1.expect)(result).toContain("confidence: 0.0");
|
|
220
|
+
(0, vitest_1.expect)(result).toContain("recommended-action: hold");
|
|
221
|
+
(0, vitest_1.expect)(result).toContain("overlap-analysis: pending");
|
|
222
|
+
(0, vitest_1.expect)(result).toContain("# Hello");
|
|
223
|
+
});
|
|
224
|
+
(0, vitest_1.it)("merges governance fields into existing front matter without overwriting existing keys", () => {
|
|
225
|
+
const content = "---\nstatus: candidate\ndoc-type: existing-type\n---\n\n# Hello";
|
|
226
|
+
const result = (0, doctrine_js_1.addCandidateGovernanceMetadata)(content, "doctrine");
|
|
227
|
+
(0, vitest_1.expect)(result).toContain("doc-type: existing-type");
|
|
228
|
+
(0, vitest_1.expect)(result).not.toContain("doc-type: doctrine");
|
|
229
|
+
(0, vitest_1.expect)(result).toContain("confidence: 0.0");
|
|
230
|
+
(0, vitest_1.expect)(result).toContain("recommended-action: hold");
|
|
231
|
+
(0, vitest_1.expect)(result).toContain("overlap-analysis: pending");
|
|
232
|
+
});
|
|
233
|
+
(0, vitest_1.it)("does not modify content when all governance fields already present", () => {
|
|
234
|
+
const content = [
|
|
235
|
+
"---",
|
|
236
|
+
"doc-type: doctrine",
|
|
237
|
+
"confidence: 0.9",
|
|
238
|
+
"recommended-action: promote",
|
|
239
|
+
"overlap-analysis: none",
|
|
240
|
+
"---",
|
|
241
|
+
"",
|
|
242
|
+
"# Hello",
|
|
243
|
+
].join("\n");
|
|
244
|
+
const result = (0, doctrine_js_1.addCandidateGovernanceMetadata)(content, "other");
|
|
245
|
+
(0, vitest_1.expect)(result).toBe(content);
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
(0, vitest_1.describe)("doctrineDeprecate", () => {
|
|
249
|
+
let repoRoot;
|
|
250
|
+
(0, vitest_1.beforeEach)(() => {
|
|
251
|
+
repoRoot = makeTempDir();
|
|
252
|
+
});
|
|
253
|
+
(0, vitest_1.it)("moves a file from active/ to deprecated/ with deprecation provenance header", () => {
|
|
254
|
+
const activePath = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "active", "old-doctrine.md");
|
|
255
|
+
(0, node_fs_1.writeFileSync)(activePath, "# Old Doctrine\n\nOriginal content.");
|
|
256
|
+
const result = (0, doctrine_js_1.doctrineDeprecate)(activePath, { repoRoot, runId: "test-run-003" });
|
|
257
|
+
(0, vitest_1.expect)(result.destination).toBe((0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "deprecated", "old-doctrine.md"));
|
|
258
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(result.destination)).toBe(true);
|
|
259
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(activePath)).toBe(false);
|
|
260
|
+
const content = (0, node_fs_1.readFileSync)(result.destination, "utf-8");
|
|
261
|
+
(0, vitest_1.expect)(content).toContain("polaris:doctrine-deprecated");
|
|
262
|
+
(0, vitest_1.expect)(content).toContain("# Old Doctrine");
|
|
263
|
+
});
|
|
264
|
+
(0, vitest_1.it)("emits a doctrine-deprecate event to lifecycle.jsonl", () => {
|
|
265
|
+
const activePath = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "active", "deprecated.md");
|
|
266
|
+
(0, node_fs_1.writeFileSync)(activePath, "# Deprecated");
|
|
267
|
+
const result = (0, doctrine_js_1.doctrineDeprecate)(activePath, { repoRoot, runId: "test-run-003" });
|
|
268
|
+
const event = JSON.parse((0, node_fs_1.readFileSync)(result.lifecyclePath, "utf-8").trim().split("\n")[0]);
|
|
269
|
+
(0, vitest_1.expect)(event.event).toBe("doctrine-deprecate");
|
|
270
|
+
(0, vitest_1.expect)(event.run_id).toBe("test-run-003");
|
|
271
|
+
(0, vitest_1.expect)(event.deprecated_at).toBeDefined();
|
|
272
|
+
});
|
|
273
|
+
(0, vitest_1.it)("throws if source is not in smartdocs/docs/doctrine/active/", () => {
|
|
274
|
+
const source = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "candidate", "wrong.md");
|
|
275
|
+
(0, node_fs_1.writeFileSync)(source, `${doctrine_js_1.CANDIDATE_MARKER}\n# Wrong`);
|
|
276
|
+
(0, vitest_1.expect)(() => (0, doctrine_js_1.doctrineDeprecate)(source, { repoRoot })).toThrow("doctrineDeprecate source must be in smartdocs/docs/doctrine/active/");
|
|
277
|
+
});
|
|
278
|
+
(0, vitest_1.it)("throws if source does not exist", () => {
|
|
279
|
+
(0, vitest_1.expect)(() => (0, doctrine_js_1.doctrineDeprecate)((0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "active", "ghost.md"), { repoRoot })).toThrow("Source file not found");
|
|
280
|
+
});
|
|
281
|
+
(0, vitest_1.it)("moves co-located .provenance.json sidecar alongside the .md", () => {
|
|
282
|
+
const activePath = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "active", "prov-dep.md");
|
|
283
|
+
const provenanceSrc = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "active", "prov-dep.provenance.json");
|
|
284
|
+
(0, node_fs_1.writeFileSync)(activePath, "# Prov Dep\n\nContent.");
|
|
285
|
+
(0, node_fs_1.writeFileSync)(provenanceSrc, JSON.stringify({ classifiedAs: "doctrine-candidate" }));
|
|
286
|
+
const result = (0, doctrine_js_1.doctrineDeprecate)(activePath, { repoRoot, runId: "test-run-dep-prov" });
|
|
287
|
+
const provenanceDest = result.destination.replace(/\.md$/, ".provenance.json");
|
|
288
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(provenanceDest)).toBe(true);
|
|
289
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(provenanceSrc)).toBe(false);
|
|
290
|
+
});
|
|
291
|
+
(0, vitest_1.it)("succeeds without error when no .provenance.json sidecar exists", () => {
|
|
292
|
+
const activePath = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "doctrine", "active", "no-prov-dep.md");
|
|
293
|
+
(0, node_fs_1.writeFileSync)(activePath, "# No Prov\n\nContent.");
|
|
294
|
+
const result = (0, doctrine_js_1.doctrineDeprecate)(activePath, { repoRoot, runId: "test-run-dep-noprov" });
|
|
295
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(result.destination)).toBe(true);
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
(0, vitest_1.describe)("specPromote", () => {
|
|
299
|
+
let repoRoot;
|
|
300
|
+
(0, vitest_1.beforeEach)(() => {
|
|
301
|
+
repoRoot = makeTempDir();
|
|
302
|
+
});
|
|
303
|
+
(0, vitest_1.it)("promotes a raw spec to specs/active/ with no conflicts", () => {
|
|
304
|
+
const src = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "raw", "my-spec.md");
|
|
305
|
+
(0, node_fs_1.writeFileSync)(src, "# My Spec\n\nThis spec must use the new API.");
|
|
306
|
+
const result = (0, doctrine_js_1.specPromote)(src, { repoRoot, runId: "spec-run-001" });
|
|
307
|
+
(0, vitest_1.expect)(result.halted).toBe(false);
|
|
308
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(result.destination)).toBe(true);
|
|
309
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(src)).toBe(false);
|
|
310
|
+
(0, vitest_1.expect)(result.destination).toContain("specs/active/my-spec.md");
|
|
311
|
+
});
|
|
312
|
+
(0, vitest_1.it)("moves co-located .provenance.json sidecar alongside the .md", () => {
|
|
313
|
+
const src = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "raw", "prov-spec.md");
|
|
314
|
+
const provSrc = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "raw", "prov-spec.provenance.json");
|
|
315
|
+
(0, node_fs_1.writeFileSync)(src, "# Prov Spec\n\nMust always validate inputs.");
|
|
316
|
+
(0, node_fs_1.writeFileSync)(provSrc, JSON.stringify({ linkedMapArea: "src/api", classifiedAs: "spec-raw" }));
|
|
317
|
+
const result = (0, doctrine_js_1.specPromote)(src, { repoRoot, runId: "spec-run-prov" });
|
|
318
|
+
(0, vitest_1.expect)(result.halted).toBe(false);
|
|
319
|
+
const provDest = result.destination.replace(/\.md$/, ".provenance.json");
|
|
320
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(provDest)).toBe(true);
|
|
321
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(provSrc)).toBe(false);
|
|
322
|
+
});
|
|
323
|
+
(0, vitest_1.it)("halts when incoming content conflicts with an active spec", () => {
|
|
324
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(repoRoot, "smartdocs", "docs", "specs", "active", "existing.md"), "# Existing\n\nAgents must always validate inputs.");
|
|
325
|
+
const src = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "raw", "conflict-spec.md");
|
|
326
|
+
(0, node_fs_1.writeFileSync)(src, "# Conflict\n\nAgents must never validate inputs.");
|
|
327
|
+
const result = (0, doctrine_js_1.specPromote)(src, { repoRoot, runId: "spec-run-conflict" });
|
|
328
|
+
(0, vitest_1.expect)(result.halted).toBe(true);
|
|
329
|
+
(0, vitest_1.expect)(result.conflicts.length).toBeGreaterThan(0);
|
|
330
|
+
(0, vitest_1.expect)(result.conflicts[0].type).toBe("content");
|
|
331
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(src)).toBe(true);
|
|
332
|
+
(0, vitest_1.expect)(result.destination).toBe("");
|
|
333
|
+
});
|
|
334
|
+
(0, vitest_1.it)("proceeds past content conflicts when approve is true", () => {
|
|
335
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(repoRoot, "smartdocs", "docs", "specs", "active", "existing.md"), "# Existing\n\nAgents must always validate inputs.");
|
|
336
|
+
const src = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "raw", "override-spec.md");
|
|
337
|
+
(0, node_fs_1.writeFileSync)(src, "# Override\n\nAgents must never validate inputs.");
|
|
338
|
+
const result = (0, doctrine_js_1.specPromote)(src, { repoRoot, runId: "spec-run-approve", approve: true });
|
|
339
|
+
(0, vitest_1.expect)(result.halted).toBe(false);
|
|
340
|
+
(0, vitest_1.expect)(result.conflicts.length).toBeGreaterThan(0);
|
|
341
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(result.destination)).toBe(true);
|
|
342
|
+
});
|
|
343
|
+
(0, vitest_1.it)("halts on map conflict when linkedMapArea already covered by active spec", () => {
|
|
344
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(repoRoot, "smartdocs", "docs", "specs", "active", "api-spec.md"), "# API Spec\n\nCovers src/api route logic.");
|
|
345
|
+
const src = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "raw", "map-conflict.md");
|
|
346
|
+
const provSrc = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "raw", "map-conflict.provenance.json");
|
|
347
|
+
(0, node_fs_1.writeFileSync)(src, "# Map Conflict\n\nNew spec for the API.");
|
|
348
|
+
(0, node_fs_1.writeFileSync)(provSrc, JSON.stringify({ linkedMapArea: "src/api", classifiedAs: "spec-raw" }));
|
|
349
|
+
const result = (0, doctrine_js_1.specPromote)(src, { repoRoot, runId: "spec-run-map" });
|
|
350
|
+
(0, vitest_1.expect)(result.halted).toBe(true);
|
|
351
|
+
const mapConflict = result.conflicts.find((c) => c.type === "map");
|
|
352
|
+
(0, vitest_1.expect)(mapConflict).toBeDefined();
|
|
353
|
+
});
|
|
354
|
+
(0, vitest_1.it)("throws if source is not in smartdocs/docs/raw/", () => {
|
|
355
|
+
const src = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "specs", "active", "wrong.md");
|
|
356
|
+
(0, node_fs_1.writeFileSync)(src, "# Wrong");
|
|
357
|
+
(0, vitest_1.expect)(() => (0, doctrine_js_1.specPromote)(src, { repoRoot })).toThrow("specPromote source must be in smartdocs/docs/raw/");
|
|
358
|
+
});
|
|
359
|
+
(0, vitest_1.it)("throws if destination already exists", () => {
|
|
360
|
+
const src = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "raw", "dupe-spec.md");
|
|
361
|
+
(0, node_fs_1.writeFileSync)(src, "# Dupe");
|
|
362
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(repoRoot, "smartdocs", "docs", "specs", "active", "dupe-spec.md"), "# Already there");
|
|
363
|
+
(0, vitest_1.expect)(() => (0, doctrine_js_1.specPromote)(src, { repoRoot })).toThrow("Destination already exists");
|
|
364
|
+
});
|
|
365
|
+
(0, vitest_1.it)("emits lifecycle event on successful promote", () => {
|
|
366
|
+
const src = (0, node_path_1.join)(repoRoot, "smartdocs", "docs", "raw", "lifecycle-spec.md");
|
|
367
|
+
(0, node_fs_1.writeFileSync)(src, "# Lifecycle Spec\n\nContent here.");
|
|
368
|
+
const result = (0, doctrine_js_1.specPromote)(src, { repoRoot, runId: "spec-lifecycle-001" });
|
|
369
|
+
(0, vitest_1.expect)((0, node_fs_1.existsSync)(result.lifecyclePath)).toBe(true);
|
|
370
|
+
const event = JSON.parse((0, node_fs_1.readFileSync)(result.lifecyclePath, "utf-8").trim().split("\n")[0]);
|
|
371
|
+
(0, vitest_1.expect)(event.event).toBe("spec-promote");
|
|
372
|
+
(0, vitest_1.expect)(event.run_id).toBe("spec-lifecycle-001");
|
|
373
|
+
});
|
|
374
|
+
});
|