@warpgogol/forge 6.2.0 → 6.3.1

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.
Files changed (60) hide show
  1. package/dist/os/compass/compass.module.d.ts.map +1 -1
  2. package/dist/os/compass/compass.module.js +44 -7
  3. package/dist/os/compass/compass.module.js.map +1 -1
  4. package/dist/os/compass/handlers/compass-docs-scaffold.d.ts +22 -0
  5. package/dist/os/compass/handlers/compass-docs-scaffold.d.ts.map +1 -0
  6. package/dist/os/compass/handlers/compass-docs-scaffold.js +304 -0
  7. package/dist/os/compass/handlers/compass-docs-scaffold.js.map +1 -0
  8. package/dist/os/compass/handlers/compass-docs-validate.d.ts.map +1 -1
  9. package/dist/os/compass/handlers/compass-docs-validate.js +62 -10
  10. package/dist/os/compass/handlers/compass-docs-validate.js.map +1 -1
  11. package/dist/os/core/core.module.d.ts.map +1 -1
  12. package/dist/os/core/core.module.js +40 -11
  13. package/dist/os/core/core.module.js.map +1 -1
  14. package/dist/os/core/handlers/package-health.d.ts +6 -1
  15. package/dist/os/core/handlers/package-health.d.ts.map +1 -1
  16. package/dist/os/core/handlers/package-health.js +91 -25
  17. package/dist/os/core/handlers/package-health.js.map +1 -1
  18. package/dist/os/core/handlers/validate.d.ts +11 -1
  19. package/dist/os/core/handlers/validate.d.ts.map +1 -1
  20. package/dist/os/core/handlers/validate.js +29 -1
  21. package/dist/os/core/handlers/validate.js.map +1 -1
  22. package/dist/src/onboarding/agents-generate.d.ts.map +1 -1
  23. package/dist/src/onboarding/agents-generate.js +17 -2
  24. package/dist/src/onboarding/agents-generate.js.map +1 -1
  25. package/dist/src/onboarding/compass-docs/constants.d.ts +9 -0
  26. package/dist/src/onboarding/compass-docs/constants.d.ts.map +1 -0
  27. package/dist/src/onboarding/compass-docs/constants.js +35 -0
  28. package/dist/src/onboarding/compass-docs/constants.js.map +1 -0
  29. package/dist/src/onboarding/doctor.d.ts.map +1 -1
  30. package/dist/src/onboarding/doctor.js +18 -0
  31. package/dist/src/onboarding/doctor.js.map +1 -1
  32. package/docs/reference/cli.md +6 -0
  33. package/docs/reference/compass-docs.md +102 -0
  34. package/docs/reference/forge-yaml.md +15 -0
  35. package/os/compass/compass.module.ts +46 -7
  36. package/os/compass/handlers/compass-docs-scaffold.ts +396 -0
  37. package/os/compass/handlers/compass-docs-validate.ts +67 -10
  38. package/os/core/core.module.ts +50 -11
  39. package/os/core/handlers/package-health.test.ts +92 -9
  40. package/os/core/handlers/package-health.ts +99 -24
  41. package/os/core/handlers/validate.ts +40 -1
  42. package/package.json +1 -1
  43. package/src/onboarding/agents-generate.ts +22 -2
  44. package/src/onboarding/compass-docs/constants.ts +42 -0
  45. package/src/onboarding/doctor.ts +18 -0
  46. package/src/onboarding/templates/compass-docs/development-plan.xml +29 -0
  47. package/src/onboarding/templates/compass-docs/knowledge-graph.xml +57 -0
  48. package/src/onboarding/templates/compass-docs/requirements.xml +28 -0
  49. package/src/onboarding/templates/compass-docs/source-markup.xml +121 -0
  50. package/src/onboarding/templates/compass-docs/technology.xml +30 -0
  51. package/src/onboarding/templates/compass-docs/verification-plan.xml +25 -0
  52. package/src/tests/agents-generate.test.ts +30 -0
  53. package/src/tests/compass-docs-flag.test.ts +99 -0
  54. package/src/tests/compass-docs-scaffold.test.ts +196 -0
  55. package/src/tests/compass-docs-validate-scope.test.ts +178 -0
  56. package/src/tests/doctor-bindings.test.ts +79 -0
  57. package/src/tests/fixtures/agents-generate-business-before.txt +8 -0
  58. package/src/tests/forge-validate-compass-docs.test.ts +154 -0
  59. package/src/tests/package-files.test.ts +3 -0
  60. package/src/tests/package-health-lint-surface.test.ts +153 -0
@@ -9,6 +9,7 @@
9
9
  <CHANGE_SUMMARY>
10
10
  <item>RFC-0674: initial forge.validate handler with profile resolution, --dry-run, and per-artifact execution.</item>
11
11
  <item>RFC-0677: extended with --artifact filtering, violation parsing (outputFormat: json/plain), passed/allPassed fields.</item>
12
+ <item>RFC-1253: compassDocs section — runs compass.docs.validate when bindings.paths.compassDocs resolves non-empty; errors enter allPassed.</item>
12
13
  <item>RFC-1097: step 6 — compass.migrate codemod run
13
14
 
14
15
  Mechanical v1 to v2 header migration across the workspace: 942 files rewritten — CHANGE_SUMMARY windows collapsed into history, forbidden v1 blocks stripped, KEY_DECISIONS seeded from @ai-invariant comments (5 files) or TODO placeholders (103 files), blocks reordered to canonical order.</item>
@@ -21,12 +22,15 @@ Sweep batch 4: 73 Compass headers on headerless engine files (certification, com
21
22
  import { exec } from "../../../src/utils/sync-fs.ts";
22
23
  import { promisify } from "node:util";
23
24
  import type {
25
+ Diagnostic,
24
26
  ForgeCommandInput,
25
27
  ForgeCommandResult,
26
28
  ForgeRuntimeContext,
27
29
  } from "../../../src/types.ts";
30
+ import { loadForgeConfig, resolveBinding } from "../../../src/config/forge-config.ts";
28
31
  import { resolveActiveProfile, resolveLifecycleFlags } from "./profile-resolve.ts";
29
32
  import { runCompassValidation } from "../../compass/handlers/compass-inventory-handler.ts";
33
+ import { runCompassDocsValidate } from "../../compass/handlers/compass-docs-validate.ts";
30
34
 
31
35
  const execAsync = promisify(exec);
32
36
 
@@ -61,12 +65,19 @@ export interface ForgeValidateCompassResult {
61
65
  }>;
62
66
  }
63
67
 
68
+ export interface ForgeValidateCompassDocsResult {
69
+ passed: boolean;
70
+ scanned: { xmlFiles: number; pathsChecked: number; idsChecked: number };
71
+ diagnostics: Diagnostic[];
72
+ }
73
+
64
74
  export interface ForgeValidateResult {
65
75
  command: "forge.validate";
66
76
  profileId: string;
67
77
  artifacts: ForgeValidateArtifactResult[];
68
78
  allPassed: boolean;
69
79
  compass?: ForgeValidateCompassResult;
80
+ compassDocs?: ForgeValidateCompassDocsResult;
70
81
  }
71
82
 
72
83
  export function parseViolations(
@@ -289,7 +300,27 @@ export async function runValidate(
289
300
  // compass.validate not available in this workspace — skip
290
301
  }
291
302
 
292
- const allPassed = artifactsAllPassed && (compassResult?.passed ?? true);
303
+ // RFC-1253: corpus validation by resolved binding — errors enter allPassed.
304
+ let compassDocsResult: ForgeValidateCompassDocsResult | undefined;
305
+ try {
306
+ const config = loadForgeConfig(workspaceRoot, context.forgeRoot);
307
+ const bound = resolveBinding(config, "paths.compassDocs");
308
+ if (Array.isArray(bound) && bound.length > 0) {
309
+ const docsResponse = await runCompassDocsValidate({ argv: [], flags: {} }, context);
310
+ if (docsResponse.data) {
311
+ compassDocsResult = {
312
+ passed: (docsResponse.exitCode ?? 0) === 0,
313
+ scanned: docsResponse.data.scanned,
314
+ diagnostics: docsResponse.data.diagnostics,
315
+ };
316
+ }
317
+ }
318
+ } catch {
319
+ // forge.yaml missing/unreadable — binding unresolved; skip section
320
+ }
321
+
322
+ const allPassed =
323
+ artifactsAllPassed && (compassResult?.passed ?? true) && (compassDocsResult?.passed ?? true);
293
324
 
294
325
  const summaryParts: string[] = [
295
326
  allPassed
@@ -303,6 +334,13 @@ export async function runValidate(
303
334
  : `compass: ${compassResult.failures} failure(s)`,
304
335
  );
305
336
  }
337
+ if (compassDocsResult) {
338
+ summaryParts.push(
339
+ compassDocsResult.passed
340
+ ? `compassDocs: OK (${compassDocsResult.scanned.xmlFiles} files)`
341
+ : `compassDocs: ${compassDocsResult.diagnostics.filter((d) => d.severity === "error").length} error(s)`,
342
+ );
343
+ }
306
344
 
307
345
  return {
308
346
  data: {
@@ -311,6 +349,7 @@ export async function runValidate(
311
349
  artifacts: results,
312
350
  allPassed,
313
351
  compass: compassResult,
352
+ compassDocs: compassDocsResult,
314
353
  },
315
354
  exitCode: allPassed ? 0 : 1,
316
355
  summary: summaryParts.join("; "),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warpgogol/forge",
3
- "version": "6.2.0",
3
+ "version": "6.3.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -7,16 +7,16 @@
7
7
  </non-goals>
8
8
  </MODULE_CONTRACT>
9
9
  <CHANGE_SUMMARY>
10
- <item>RFC-0640: load workspaceTypes from stack profile and pass to generateNestedAgentsMd for profile-driven workspace detection.</item>
11
10
  <item>RFC-0643: terminology substitution on final content, root template selection by register, details field in result.</item>
12
11
  <item>RFC-0664: added project memory layer read discipline section to generated AGENTS.md.</item>
12
+ <item>RFC-1253: emit "Semantic layer — read first" block listing bound paths.compassDocs before the Skills table when the binding resolves non-empty.</item>
13
13
  <item>RFC-1097: step 6 — compass.migrate codemod run
14
14
 
15
15
  Mechanical v1 to v2 header migration across the workspace: 942 files rewritten — CHANGE_SUMMARY windows collapsed into history, forbidden v1 blocks stripped, KEY_DECISIONS seeded from @ai-invariant comments (5 files) or TODO placeholders (103 files), blocks reordered to canonical order.</item>
16
16
  <item>RFC-1097: sweep — packages/forge + services clean
17
17
 
18
18
  Sweep batch 2: real KEY_DECISIONS on 10 files, expanded purposes (CONTRACT-02/PURPOSE-02), headers on mission/index + gen-upstreams, sanitizeItemText in summary.record (literal Compass tags corrupted history), excludedPaths for wrangler types, test-fixtures testPattern. forge+services now 0 diagnostics under --mode error.</item>
19
- <history>RFC-0391, RFC-0393, RFC-0548, RFC-0549, RFC-0551, RFC-0611</history>
19
+ <history>RFC-0391, RFC-0393, RFC-0548, RFC-0549, RFC-0551, RFC-0611, RFC-0640</history>
20
20
  </CHANGE_SUMMARY>
21
21
  */
22
22
 
@@ -304,6 +304,26 @@ export async function runAgentsGenerate(
304
304
  // Build dynamic sections (skills table, capabilities, behavioral layer)
305
305
  const dynamicLines: string[] = [];
306
306
 
307
+ // RFC-1253: Compass corpus read-first block — only when the binding
308
+ // resolves non-empty (DNA-90: instructions live where agents read them).
309
+ const compassDocsReadFirst = resolveBinding(config, "paths.compassDocs");
310
+ if (Array.isArray(compassDocsReadFirst) && compassDocsReadFirst.length > 0) {
311
+ dynamicLines.push("## Semantic layer — read first");
312
+ dynamicLines.push("");
313
+ dynamicLines.push(
314
+ "This repository carries a machine-readable Compass corpus — the semantic layer that answers \u201cwhat reads X, what breaks if I change Y\u201d without a full repository re-scan. For repository-wide, cross-workspace, architectural, shared-package, or high-risk tasks, read these documents before planning or editing code:",
315
+ );
316
+ dynamicLines.push("");
317
+ for (const doc of compassDocsReadFirst) {
318
+ dynamicLines.push(`- \`${doc}\``);
319
+ }
320
+ dynamicLines.push("");
321
+ dynamicLines.push(
322
+ "Treat these XML documents as the primary semantic layer for AI work and keep them synchronized with code, architecture, and verification changes.",
323
+ );
324
+ dynamicLines.push("");
325
+ }
326
+
307
327
  // Skills table (RFC-1154: emitted prettier-normal via alignMarkdownTable)
308
328
  dynamicLines.push("## Skills");
309
329
  dynamicLines.push("");
@@ -0,0 +1,42 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>RFC-1253: canonical identifiers for the consumer-facing Compass docs corpus — schema id, document names, and the default bindings.paths.compassDocs value written by compass.docs.scaffold.</purpose>
4
+ <non-goals>
5
+ <item>Do not read forge.yaml or resolve bindings — constants only; resolution lives in the scaffold/validate handlers.</item>
6
+ <item>Do not add consumer- or stack-specific values (RFC-1096 boundary).</item>
7
+ </non-goals>
8
+ </MODULE_CONTRACT>
9
+ <KEY_DECISIONS>
10
+ <item>Schema id is versioned (`@1`) so a future format bump can gate migration without reparsing content.</item>
11
+ <item>Corpus membership = canonical six ∪ binding paths — DOC-04 checks key off this set, not filename shape.</item>
12
+ </KEY_DECISIONS>
13
+ <CHANGE_SUMMARY>
14
+ <item>RFC-1253: created — schema id, six-name corpus list, default binding paths.</item>
15
+ </CHANGE_SUMMARY>
16
+ */
17
+
18
+ export const COMPASS_DOCS_SCHEMA_ID = "forge/compass-docs@1" as const;
19
+
20
+ /** The six documents a Compass corpus declares, in scaffold write order. */
21
+ export const CANONICAL_CORPUS_DOCS = [
22
+ "requirements",
23
+ "technology",
24
+ "development-plan",
25
+ "knowledge-graph",
26
+ "verification-plan",
27
+ "source-markup",
28
+ ] as const;
29
+
30
+ export type CanonicalCorpusDoc = (typeof CANONICAL_CORPUS_DOCS)[number];
31
+
32
+ /** Default `bindings.paths.compassDocs` value — the six docs under `docs/`. */
33
+ export const DEFAULT_COMPASS_DOCS_BINDING: readonly string[] = CANONICAL_CORPUS_DOCS.map(
34
+ (name) => `docs/${name}.xml`,
35
+ );
36
+
37
+ /** Docs whose skeleton is authored-intent (TODO + draft) rather than generated-from-state. */
38
+ export const DRAFT_SKELETON_DOCS: ReadonlySet<CanonicalCorpusDoc> = new Set<CanonicalCorpusDoc>([
39
+ "requirements",
40
+ "development-plan",
41
+ "verification-plan",
42
+ ]);
@@ -181,13 +181,31 @@ async function validateBindings(workspaceRoot: string, io: WorkspaceIO): Promise
181
181
 
182
182
  const compassDocs = resolveBinding(config, "paths.compassDocs");
183
183
  if (Array.isArray(compassDocs) && compassDocs.length > 0) {
184
+ let anyMissing = false;
184
185
  for (const docPath of compassDocs) {
185
186
  const exists = await pathExists(join(workspaceRoot, docPath), io);
186
187
  if (exists) {
187
188
  result.resolved.push(`paths.compassDocs[${docPath}]`);
188
189
  } else {
189
190
  result.invalid.push(`paths.compassDocs[${docPath}] (path not found)`);
191
+ anyMissing = true;
190
192
  }
193
+ // RFC-1253: convention notice — corpus docs belong under docs/
194
+ if (typeof docPath === "string" && !docPath.startsWith("docs/")) {
195
+ result.notices.push({
196
+ key: `paths.compassDocs[${docPath}]`,
197
+ rule: "compass-docs-outside-docs",
198
+ suggestion: "Corpus documents conventionally live under docs/ — custom layouts work but drift from scaffold defaults.",
199
+ });
200
+ }
201
+ }
202
+ // RFC-1253: scaffold remediation hint — scaffold creates only missing docs
203
+ if (anyMissing) {
204
+ result.notices.push({
205
+ key: "paths.compassDocs",
206
+ rule: "compass-docs-scaffoldable",
207
+ suggestion: `${resolvePmRunner(config.project.packageManager)} forge compass.docs.scaffold — creates missing corpus docs without overwriting authored ones.`,
208
+ });
191
209
  }
192
210
  } else {
193
211
  result.absent.push("paths.compassDocs");
@@ -0,0 +1,29 @@
1
+ <development-plan>
2
+ <meta>
3
+ <document-id>development-plan</document-id>
4
+ <version>1.0.0</version>
5
+ <status>draft</status>
6
+ <schema>forge/compass-docs@1</schema>
7
+ <scope>repository-root</scope>
8
+ </meta>
9
+
10
+ <!-- TODO: authored-intent document — scaffold cannot invent your roadmap.
11
+ Record phases, ordering constraints, and completion signals here. -->
12
+
13
+ <phases>
14
+ <phase id="phase-01" status="planned">
15
+ <name>TODO — first phase</name>
16
+ <goal>TODO</goal>
17
+ <work>
18
+ <item>TODO</item>
19
+ </work>
20
+ <done-when>
21
+ <item>TODO — observable completion signal</item>
22
+ </done-when>
23
+ </phase>
24
+ </phases>
25
+
26
+ <ordering-constraints>
27
+ <!-- TODO: hard dependencies between phases/items that an executor must honor. -->
28
+ </ordering-constraints>
29
+ </development-plan>
@@ -0,0 +1,57 @@
1
+ <knowledge-graph>
2
+ <meta>
3
+ <document-id>knowledge-graph</document-id>
4
+ <version>1.0.0</version>
5
+ <status>active</status>
6
+ <schema>forge/compass-docs@1</schema>
7
+ <scope>repository-root</scope>
8
+ </meta>
9
+
10
+ <nodes>
11
+ <node id="root.rules" type="instruction-layer">
12
+ <name>Root AGENTS</name>
13
+ <path>`AGENTS.md`</path>
14
+ <role>Repository-wide active instruction layer.</role>
15
+ <links>
16
+ <link rel="binds-to" target="root.docs.requirements" />
17
+ <link rel="binds-to" target="root.docs.technology" />
18
+ <link rel="binds-to" target="root.docs.plan" />
19
+ <link rel="binds-to" target="root.docs.knowledge-graph" />
20
+ <link rel="binds-to" target="root.docs.verification" />
21
+ <link rel="binds-to" target="root.docs.source-markup" />
22
+ {{rootLinks}}
23
+ </links>
24
+ </node>
25
+ <node id="root.docs.requirements" type="document">
26
+ <name>Requirements corpus document</name>
27
+ <path>`docs/requirements.xml`</path>
28
+ <role>Authored goals and durable requirements.</role>
29
+ </node>
30
+ <node id="root.docs.technology" type="document">
31
+ <name>Technology corpus document</name>
32
+ <path>`docs/technology.xml`</path>
33
+ <role>Runtime, package manager, and stack facts.</role>
34
+ </node>
35
+ <node id="root.docs.plan" type="document">
36
+ <name>Development plan corpus document</name>
37
+ <path>`docs/development-plan.xml`</path>
38
+ <role>Phases, ordering constraints, and completion signals.</role>
39
+ </node>
40
+ <node id="root.docs.knowledge-graph" type="document">
41
+ <name>Knowledge graph corpus document</name>
42
+ <path>`docs/knowledge-graph.xml`</path>
43
+ <role>This document — the semantic index of workspaces and instruction layers.</role>
44
+ </node>
45
+ <node id="root.docs.verification" type="document">
46
+ <name>Verification plan corpus document</name>
47
+ <path>`docs/verification-plan.xml`</path>
48
+ <role>Gates, commands, and evidence standards.</role>
49
+ </node>
50
+ <node id="root.docs.source-markup" type="document">
51
+ <name>Source markup corpus document</name>
52
+ <path>`docs/source-markup.xml`</path>
53
+ <role>The Compass source-file markup contract enforced by compass.validate.</role>
54
+ </node>
55
+ {{workspaceNodes}}
56
+ </nodes>
57
+ </knowledge-graph>
@@ -0,0 +1,28 @@
1
+ <requirements>
2
+ <meta>
3
+ <document-id>requirements</document-id>
4
+ <version>1.0.0</version>
5
+ <status>draft</status>
6
+ <schema>forge/compass-docs@1</schema>
7
+ <scope>repository-root</scope>
8
+ </meta>
9
+
10
+ <!-- TODO: authored-intent document — scaffold cannot invent your goals.
11
+ Fill vision, operating-principles, and requirements before relying on
12
+ this document for agent work. -->
13
+
14
+ <vision>
15
+ <statement>TODO — describe what this repository exists to do and what "correct" means for it.</statement>
16
+ </vision>
17
+
18
+ <operating-principles>
19
+ <!-- TODO: 3–6 durable principles that constrain HOW work happens here
20
+ (e.g. generated artifacts are never hand-edited; contracts before code). -->
21
+ <principle id="gp-01">TODO</principle>
22
+ </operating-principles>
23
+
24
+ <requirements-list>
25
+ <!-- TODO: one <requirement id="REQ-NN"> per durable requirement, each with
26
+ <statement>, <rationale>, and <links> to knowledge-graph nodes. -->
27
+ </requirements-list>
28
+ </requirements>
@@ -0,0 +1,121 @@
1
+ <source-markup>
2
+ <meta>
3
+ <document-id>source-markup</document-id>
4
+ <version>1.0.0</version>
5
+ <status>active</status>
6
+ <schema>forge/compass-docs@1</schema>
7
+ <scope>repository-root</scope>
8
+ </meta>
9
+
10
+ <purpose>
11
+ Define the canonical Compass source-file markup contract for authored code in this
12
+ workspace. This document specifies the three-block contract (MODULE_CONTRACT,
13
+ KEY_DECISIONS, CHANGE_SUMMARY), the inline invariant format, the forbidden set,
14
+ the resolved scan policy, and the coverage modes — as enforced by `compass.validate`.
15
+ </purpose>
16
+
17
+ <markup-model>
18
+ <required-header-blocks>
19
+ <block name="MODULE_CONTRACT">
20
+ <purpose>State what the file is for and what it must NOT do.</purpose>
21
+ <required-inner>
22
+ <inner name="purpose">
23
+ <rule>At least 10 words (COMPASS-PURPOSE-01) and at least one standalone lowercase token derived from the file name or exported symbols (COMPASS-PURPOSE-02).</rule>
24
+ </inner>
25
+ <inner name="non-goals">
26
+ <rule>At least one `&lt;item>` stating what the file must NOT do (COMPASS-CONTRACT-03).</rule>
27
+ </inner>
28
+ </required-inner>
29
+ </block>
30
+ <block name="KEY_DECISIONS">
31
+ <purpose>Record current-state design truths of the file — invariants, chosen mechanisms, forbidden approaches. Current truth, not history; rewritten in place when behavior changes.</purpose>
32
+ <required-inner>
33
+ <inner name="item">
34
+ <rule>Required on medium/high riskClass files (COMPASS-KD-01), optional on low. 1–7 items (COMPASS-KD-04), each ≤ 20 words (COMPASS-KD-03). Items MUST NOT start with a governance-ID prefix (COMPASS-KD-05). Empty or TODO-only blocks are COMPASS-KD-02.</rule>
35
+ </inner>
36
+ </required-inner>
37
+ </block>
38
+ <block name="CHANGE_SUMMARY">
39
+ <purpose>Capture the latest COMPASS-relevant changes to the file, compressed.</purpose>
40
+ <required-inner>
41
+ <inner name="item">
42
+ <rule>At most 5 `&lt;item>` entries (COMPASS-CS-05), each carrying a governance ID matching the resolved idPattern (COMPASS-CS-06). The retained items are the 5 newest. An empty block is legal.</rule>
43
+ </inner>
44
+ <inner name="history">
45
+ <rule>Optional single `&lt;history>` element: comma-separated governance IDs collapsed from older items — deduplicated, per-namespace ascending numeric order (COMPASS-CS-07). IDs only, no descriptions, no length cap.</rule>
46
+ </inner>
47
+ </required-inner>
48
+ </block>
49
+ </required-header-blocks>
50
+
51
+ <block-order>
52
+ <rule>Blocks MUST appear in canonical order: MODULE_CONTRACT → KEY_DECISIONS → CHANGE_SUMMARY (COMPASS-ORDER-01).</rule>
53
+ </block-order>
54
+
55
+ <local-invariants>
56
+ <format>// @ai-invariant: ...</format>
57
+ <rules>
58
+ <rule>Required for files with risk class `high` (blast-radius boundaries such as middleware, discovery/runtime cores, registries).</rule>
59
+ <rule>Keep invariants short, durable, and directly relevant to failure prevention.</rule>
60
+ <rule>Optional for non-high-risk files but encouraged when a non-obvious constraint exists.</rule>
61
+ </rules>
62
+ </local-invariants>
63
+
64
+ <forbidden-blocks>
65
+ <forbidden name="MODULE_MAP" reason="Restates export names already visible in the code." />
66
+ <forbidden name="keywords" reason="Restates the filename and purpose." />
67
+ <forbidden name="responsibilities" reason="Restates what the code does; purpose + non-goals carry the non-derivable signal." />
68
+ <forbidden name="COMPASS_BLOCK" reason="No downstream consumer; presence is a validation error." />
69
+ </forbidden-blocks>
70
+ </markup-model>
71
+
72
+ <scan-policy source="resolveCompassPolicy — generic defaults → stack profile → bindings.compass">
73
+ <file-extensions>
74
+ {{fileExtensions}}
75
+ </file-extensions>
76
+ <scan-roots>
77
+ {{scanRoots}}
78
+ </scan-roots>
79
+ <test-patterns>
80
+ {{testPatterns}}
81
+ </test-patterns>
82
+ <ignored-dirs>
83
+ {{ignoredDirs}}
84
+ </ignored-dirs>
85
+ <ignored-dir-prefixes>
86
+ {{ignoredDirPrefixes}}
87
+ </ignored-dir-prefixes>
88
+ <high-risk-paths>
89
+ {{highRiskPaths}}
90
+ </high-risk-paths>
91
+ <excluded-paths>
92
+ {{excludedPaths}}
93
+ </excluded-paths>
94
+ <governance-id-pattern>{{idPattern}}</governance-id-pattern>
95
+ <layer-rules first-match="true">
96
+ {{layerRules}}
97
+ </layer-rules>
98
+ </scan-policy>
99
+
100
+ <coverage-modes>
101
+ <mode name="standard">
102
+ <applies-to>
103
+ <item>Every authored, non-excluded source file under the resolved scan roots.</item>
104
+ </applies-to>
105
+ <requirements>
106
+ <item>`MODULE_CONTRACT` with `&lt;purpose>` (>= 10 words, >= 1 file-derived token) and at least one `&lt;non-goals>&lt;item>`.</item>
107
+ <item>`KEY_DECISIONS` when the file's risk class is `medium` or `high`.</item>
108
+ <item>`CHANGE_SUMMARY` with at most 5 governance-ID items plus optional `&lt;history>`.</item>
109
+ <item>`@ai-invariant` when the file's risk class is `high`.</item>
110
+ </requirements>
111
+ </mode>
112
+ <mode name="none">
113
+ <applies-to>
114
+ <item>Files matched by `excludedPaths` or `ignoredDirs` — generated, vendored, fixture, or tool-owned surfaces.</item>
115
+ </applies-to>
116
+ <requirements>
117
+ <item>No Compass markup required; presence of contract blocks is tolerated but not enforced.</item>
118
+ </requirements>
119
+ </mode>
120
+ </coverage-modes>
121
+ </source-markup>
@@ -0,0 +1,30 @@
1
+ <technology>
2
+ <meta>
3
+ <document-id>technology</document-id>
4
+ <version>1.0.0</version>
5
+ <status>active</status>
6
+ <schema>forge/compass-docs@1</schema>
7
+ <scope>repository-root</scope>
8
+ </meta>
9
+
10
+ <runtime>
11
+ <node>
12
+ <version-range>{{nodeRange}}</version-range>
13
+ <source>`package.json` engines.node</source>
14
+ </node>
15
+ <package-manager>
16
+ <name>{{packageManager}}</name>
17
+ <source>`package.json` packageManager / lockfile</source>
18
+ </package-manager>
19
+ </runtime>
20
+
21
+ <stack>
22
+ <profile id="{{profileId}}">
23
+ <source>`forge.yaml` profile</source>
24
+ </profile>
25
+ </stack>
26
+
27
+ <workspaces>
28
+ {{workspaceRows}}
29
+ </workspaces>
30
+ </technology>
@@ -0,0 +1,25 @@
1
+ <verification-plan>
2
+ <meta>
3
+ <document-id>verification-plan</document-id>
4
+ <version>1.0.0</version>
5
+ <status>draft</status>
6
+ <schema>forge/compass-docs@1</schema>
7
+ <scope>repository-root</scope>
8
+ </meta>
9
+
10
+ <!-- TODO: authored-intent document — scaffold cannot invent your quality bar.
11
+ Record the gates, commands, and evidence standards that prove work is done. -->
12
+
13
+ <gates>
14
+ <gate id="gate-01" blocking="true">
15
+ <name>TODO — e.g. typecheck / lint / tests / package health</name>
16
+ <command>TODO — e.g. `pnpm run build:check`</command>
17
+ <runs-when>TODO — e.g. before every commit / on push / on demand</runs-when>
18
+ </gate>
19
+ </gates>
20
+
21
+ <evidence-standards>
22
+ <!-- TODO: what proof a change must leave behind (probe output, green gate,
23
+ verification artifact) and where it is recorded. -->
24
+ </evidence-standards>
25
+ </verification-plan>
@@ -502,3 +502,33 @@ test("agents-generate nested for service workspace omits entry points", async ()
502
502
  expect(nested).toContain("## Scripts");
503
503
  expect(nested).toContain("## Dependencies");
504
504
  });
505
+
506
+ test("agents-generate emits the semantic-layer read-first block when compassDocs is non-empty (RFC-1253)", async () => {
507
+ await makeForgeYaml(tempDir);
508
+ const result = await runAgentsGenerate({ argv: [], flags: {} }, makeContext(tempDir));
509
+ expect(result.exitCode).toBe(0);
510
+
511
+ const agentsMd = await readFile(join(tempDir, "AGENTS.md"), "utf8");
512
+ expect(agentsMd).toContain("## Semantic layer — read first");
513
+ expect(agentsMd).toContain("`docs/requirements.xml`");
514
+ expect(agentsMd).toContain("primary semantic layer");
515
+ // block must precede the Skills table — reading discipline comes first
516
+ expect(agentsMd.indexOf("## Semantic layer — read first")).toBeLessThan(
517
+ agentsMd.indexOf("## Skills"),
518
+ );
519
+ });
520
+
521
+ test("agents-generate omits the read-first block when compassDocs is absent (RFC-1253)", async () => {
522
+ await makeForgeYaml(tempDir);
523
+ // strip the compassDocs line — binding resolves absent
524
+ const yaml = (await readFile(join(tempDir, "forge.yaml"), "utf8")).replace(
525
+ " compassDocs: [docs/requirements.xml]\n",
526
+ "",
527
+ );
528
+ await writeFile(join(tempDir, "forge.yaml"), yaml, "utf8");
529
+
530
+ const result = await runAgentsGenerate({ argv: [], flags: {} }, makeContext(tempDir));
531
+ expect(result.exitCode).toBe(0);
532
+ const agentsMd = await readFile(join(tempDir, "AGENTS.md"), "utf8");
533
+ expect(agentsMd).not.toContain("## Semantic layer — read first");
534
+ });
@@ -0,0 +1,99 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>
4
+ RFC-1253 AC-9: --compass-docs on forge.init / forge.create / forge.upgrade
5
+ invokes compass.docs.scaffold after the primary operation — corpus docs
6
+ materialize and bindings.paths.compassDocs is written; without the flag the
7
+ lifecycle leaves the corpus untouched.
8
+ </purpose>
9
+ </MODULE_CONTRACT>
10
+ */
11
+
12
+ import { describe, it, expect, beforeEach, afterEach } from "vitest";
13
+ import { mkdtemp, readFile, rm } from "node:fs/promises";
14
+ import { tmpdir } from "node:os";
15
+ import { join } from "node:path";
16
+ import { createForgeCoreModule } from "../../os/core/core.module.ts";
17
+ import { ambientIo } from "../utils/io.ts";
18
+ import type { ForgeCommandInput, ForgeRuntimeContext } from "../types.ts";
19
+
20
+ const FORGE_ROOT = join(import.meta.dirname, "..", "..");
21
+
22
+ const logger = {
23
+ section() {},
24
+ info() {},
25
+ warn() {},
26
+ error() {},
27
+ success() {},
28
+ getEvents() {
29
+ return [];
30
+ },
31
+ };
32
+
33
+ function makeContext(workspaceRoot: string): ForgeRuntimeContext {
34
+ return {
35
+ workspaceRoot,
36
+ forgeRoot: FORGE_ROOT,
37
+ site: undefined,
38
+ siteExplicit: false,
39
+ logger: logger as never,
40
+ dryRun: false,
41
+ outputFormat: "json",
42
+ io: ambientIo,
43
+ actualState: undefined as never,
44
+ fileIntents: [],
45
+ } as unknown as ForgeRuntimeContext;
46
+ }
47
+
48
+ function makeInput(flags: Record<string, unknown>): ForgeCommandInput {
49
+ return { argv: [], flags } as unknown as ForgeCommandInput;
50
+ }
51
+
52
+ describe("--compass-docs lifecycle flag (RFC-1253)", () => {
53
+ let root: string;
54
+
55
+ beforeEach(async () => {
56
+ root = await mkdtemp(join(tmpdir(), "compass-docs-flag-"));
57
+ });
58
+ afterEach(async () => {
59
+ await rm(root, { recursive: true, force: true });
60
+ });
61
+
62
+ it("declares the flag on forge.init, forge.create, and forge.upgrade", async () => {
63
+ const mod = await createForgeCoreModule();
64
+ for (const name of ["forge.init", "forge.create", "forge.upgrade"]) {
65
+ const cmd = mod.commands.find((c) => c.name === name);
66
+ expect(cmd, name).toBeDefined();
67
+ expect(cmd?.flags?.["compass-docs"]).toBeDefined();
68
+ }
69
+ });
70
+
71
+ it("forge.init --compass-docs materializes the corpus and writes the binding", async () => {
72
+ const mod = await createForgeCoreModule();
73
+ const init = mod.commands.find((c) => c.name === "forge.init")!;
74
+
75
+ const result = await init.execute(makeInput({ "compass-docs": true }), makeContext(root));
76
+ expect(result.exitCode).toBe(0);
77
+
78
+ const req = await readFile(join(root, "docs", "requirements.xml"), "utf8");
79
+ expect(req).toContain("<schema>forge/compass-docs@1</schema>");
80
+ const forgeYaml = await readFile(join(root, "forge.yaml"), "utf8");
81
+ expect(forgeYaml).toContain("compassDocs:");
82
+ expect(forgeYaml).toContain("docs/requirements.xml");
83
+ expect((result.data as { compassDocs?: { status?: string } })?.compassDocs?.status).toBe("ok");
84
+ });
85
+
86
+ it("forge.init without the flag leaves the corpus and binding untouched", async () => {
87
+ const mod = await createForgeCoreModule();
88
+ const init = mod.commands.find((c) => c.name === "forge.init")!;
89
+
90
+ const result = await init.execute(makeInput({}), makeContext(root));
91
+ expect(result.exitCode).toBe(0);
92
+
93
+ await expect(readFile(join(root, "docs", "requirements.xml"), "utf8")).rejects.toThrow();
94
+ const forgeYaml = await readFile(join(root, "forge.yaml"), "utf8");
95
+ // the init default template declares the key empty — no corpus paths land
96
+ expect(forgeYaml).toContain("compassDocs: []");
97
+ expect((result.data as { compassDocs?: unknown })?.compassDocs).toBeUndefined();
98
+ });
99
+ });