@warpgogol/forge 5.3.4 → 6.2.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.
Files changed (253) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/bin/cli.ts +7 -2
  3. package/dist/bin/cli.js +7 -2
  4. package/dist/bin/cli.js.map +1 -1
  5. package/dist/os/adr/adr.module.d.ts.map +1 -1
  6. package/dist/os/adr/adr.module.js +2 -0
  7. package/dist/os/adr/adr.module.js.map +1 -1
  8. package/dist/os/audit/audit.module.d.ts.map +1 -1
  9. package/dist/os/audit/audit.module.js +2 -0
  10. package/dist/os/audit/audit.module.js.map +1 -1
  11. package/dist/os/compass/compass.module.d.ts.map +1 -1
  12. package/dist/os/compass/compass.module.js +47 -15
  13. package/dist/os/compass/compass.module.js.map +1 -1
  14. package/dist/os/compass/handlers/compass-audit-handler.d.ts +2 -0
  15. package/dist/os/compass/handlers/compass-audit-handler.d.ts.map +1 -1
  16. package/dist/os/compass/handlers/compass-audit-handler.js +40 -10
  17. package/dist/os/compass/handlers/compass-audit-handler.js.map +1 -1
  18. package/dist/os/compass/handlers/compass-docs-validate.d.ts +13 -0
  19. package/dist/os/compass/handlers/compass-docs-validate.d.ts.map +1 -0
  20. package/dist/os/compass/handlers/compass-docs-validate.js +328 -0
  21. package/dist/os/compass/handlers/compass-docs-validate.js.map +1 -0
  22. package/dist/os/compass/handlers/summary-record.d.ts +11 -2
  23. package/dist/os/compass/handlers/summary-record.d.ts.map +1 -1
  24. package/dist/os/compass/handlers/summary-record.js +95 -15
  25. package/dist/os/compass/handlers/summary-record.js.map +1 -1
  26. package/dist/os/core/core.module.d.ts.map +1 -1
  27. package/dist/os/core/core.module.js +124 -73
  28. package/dist/os/core/core.module.js.map +1 -1
  29. package/dist/os/core/handlers/file-size-lint.d.ts.map +1 -1
  30. package/dist/os/core/handlers/file-size-lint.js +2 -0
  31. package/dist/os/core/handlers/file-size-lint.js.map +1 -1
  32. package/dist/os/exploration/exploration.module.d.ts.map +1 -1
  33. package/dist/os/exploration/exploration.module.js +3 -0
  34. package/dist/os/exploration/exploration.module.js.map +1 -1
  35. package/dist/os/naming/naming-convention.d.ts.map +1 -1
  36. package/dist/os/naming/naming-convention.js +11 -1
  37. package/dist/os/naming/naming-convention.js.map +1 -1
  38. package/dist/os/naming/naming.module.d.ts.map +1 -1
  39. package/dist/os/naming/naming.module.js +9 -2
  40. package/dist/os/naming/naming.module.js.map +1 -1
  41. package/dist/os/notes/notes.module.d.ts.map +1 -1
  42. package/dist/os/notes/notes.module.js +17 -6
  43. package/dist/os/notes/notes.module.js.map +1 -1
  44. package/dist/os/plan/plan.module.d.ts.map +1 -1
  45. package/dist/os/plan/plan.module.js +2 -0
  46. package/dist/os/plan/plan.module.js.map +1 -1
  47. package/dist/os/plugin/plugin.module.d.ts.map +1 -1
  48. package/dist/os/plugin/plugin.module.js +9 -2
  49. package/dist/os/plugin/plugin.module.js.map +1 -1
  50. package/dist/os/program/program.module.d.ts.map +1 -1
  51. package/dist/os/program/program.module.js +19 -4
  52. package/dist/os/program/program.module.js.map +1 -1
  53. package/dist/os/queue/handlers/queue-validate.d.ts.map +1 -1
  54. package/dist/os/queue/handlers/queue-validate.js +154 -7
  55. package/dist/os/queue/handlers/queue-validate.js.map +1 -1
  56. package/dist/os/queue/manifest.d.ts +17 -1
  57. package/dist/os/queue/manifest.d.ts.map +1 -1
  58. package/dist/os/queue/manifest.js +127 -6
  59. package/dist/os/queue/manifest.js.map +1 -1
  60. package/dist/os/queue/queue.module.d.ts.map +1 -1
  61. package/dist/os/queue/queue.module.js +32 -4
  62. package/dist/os/queue/queue.module.js.map +1 -1
  63. package/dist/os/queue/types.d.ts +100 -1
  64. package/dist/os/queue/types.d.ts.map +1 -1
  65. package/dist/os/queue/types.js +44 -0
  66. package/dist/os/queue/types.js.map +1 -1
  67. package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
  68. package/dist/os/rfc/handlers/implement-stamp.js +30 -8
  69. package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
  70. package/dist/os/rfc/rfc.module.d.ts.map +1 -1
  71. package/dist/os/rfc/rfc.module.js +25 -6
  72. package/dist/os/rfc/rfc.module.js.map +1 -1
  73. package/dist/os/rfc/types.d.ts +12 -2
  74. package/dist/os/rfc/types.d.ts.map +1 -1
  75. package/dist/os/rfc/types.js +2 -2
  76. package/dist/os/rfc/types.js.map +1 -1
  77. package/dist/os/rfc/verification-evidence.d.ts +21 -0
  78. package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
  79. package/dist/os/rfc/verification-evidence.js +134 -23
  80. package/dist/os/rfc/verification-evidence.js.map +1 -1
  81. package/dist/os/rfc/verification-refresh.d.ts.map +1 -1
  82. package/dist/os/rfc/verification-refresh.js +66 -37
  83. package/dist/os/rfc/verification-refresh.js.map +1 -1
  84. package/dist/os/session/handlers/save.d.ts.map +1 -1
  85. package/dist/os/session/handlers/save.js +42 -5
  86. package/dist/os/session/handlers/save.js.map +1 -1
  87. package/dist/os/session/session.module.d.ts.map +1 -1
  88. package/dist/os/session/session.module.js +5 -0
  89. package/dist/os/session/session.module.js.map +1 -1
  90. package/dist/os/spec/live-spec-merge.d.ts.map +1 -1
  91. package/dist/os/spec/live-spec-merge.js +55 -134
  92. package/dist/os/spec/live-spec-merge.js.map +1 -1
  93. package/dist/os/spec/live-spec-rebuild.d.ts +32 -0
  94. package/dist/os/spec/live-spec-rebuild.d.ts.map +1 -0
  95. package/dist/os/spec/live-spec-rebuild.js +272 -0
  96. package/dist/os/spec/live-spec-rebuild.js.map +1 -0
  97. package/dist/os/spec/live-spec-shared.d.ts +62 -0
  98. package/dist/os/spec/live-spec-shared.d.ts.map +1 -0
  99. package/dist/os/spec/live-spec-shared.js +315 -0
  100. package/dist/os/spec/live-spec-shared.js.map +1 -0
  101. package/dist/os/spec/live-spec-types.d.ts +17 -1
  102. package/dist/os/spec/live-spec-types.d.ts.map +1 -1
  103. package/dist/os/spec/live-spec-types.js +3 -0
  104. package/dist/os/spec/live-spec-types.js.map +1 -1
  105. package/dist/os/spec/live-spec-validate.d.ts.map +1 -1
  106. package/dist/os/spec/live-spec-validate.js +105 -2
  107. package/dist/os/spec/live-spec-validate.js.map +1 -1
  108. package/dist/os/spec/spec-materialize.d.ts +2 -0
  109. package/dist/os/spec/spec-materialize.d.ts.map +1 -1
  110. package/dist/os/spec/spec-materialize.js +45 -5
  111. package/dist/os/spec/spec-materialize.js.map +1 -1
  112. package/dist/os/spec/spec-schema.d.ts +19 -0
  113. package/dist/os/spec/spec-schema.d.ts.map +1 -1
  114. package/dist/os/spec/spec-schema.js +30 -0
  115. package/dist/os/spec/spec-schema.js.map +1 -1
  116. package/dist/os/spec/spec-status.d.ts +4 -0
  117. package/dist/os/spec/spec-status.d.ts.map +1 -1
  118. package/dist/os/spec/spec-status.js +19 -1
  119. package/dist/os/spec/spec-status.js.map +1 -1
  120. package/dist/os/spec/spec-validate.d.ts.map +1 -1
  121. package/dist/os/spec/spec-validate.js +55 -8
  122. package/dist/os/spec/spec-validate.js.map +1 -1
  123. package/dist/os/spec/spec.module.d.ts.map +1 -1
  124. package/dist/os/spec/spec.module.js +84 -8
  125. package/dist/os/spec/spec.module.js.map +1 -1
  126. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts.map +1 -1
  127. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js +10 -4
  128. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js.map +1 -1
  129. package/dist/os/werkstatt/werkstatt.module.d.ts.map +1 -1
  130. package/dist/os/werkstatt/werkstatt.module.js +13 -4
  131. package/dist/os/werkstatt/werkstatt.module.js.map +1 -1
  132. package/dist/os/workflow/workflow.module.d.ts.map +1 -1
  133. package/dist/os/workflow/workflow.module.js +13 -5
  134. package/dist/os/workflow/workflow.module.js.map +1 -1
  135. package/dist/src/cli-flags.d.ts.map +1 -1
  136. package/dist/src/cli-flags.js +25 -5
  137. package/dist/src/cli-flags.js.map +1 -1
  138. package/dist/src/config/forge-config.d.ts +3 -0
  139. package/dist/src/config/forge-config.d.ts.map +1 -1
  140. package/dist/src/config/forge-config.js +2 -0
  141. package/dist/src/config/forge-config.js.map +1 -1
  142. package/dist/src/onboarding/doctor.d.ts.map +1 -1
  143. package/dist/src/onboarding/doctor.js +2 -3
  144. package/dist/src/onboarding/doctor.js.map +1 -1
  145. package/dist/src/onboarding/init.d.ts.map +1 -1
  146. package/dist/src/onboarding/init.js +8 -3
  147. package/dist/src/onboarding/init.js.map +1 -1
  148. package/dist/src/pipeline-status.d.ts +14 -1
  149. package/dist/src/pipeline-status.d.ts.map +1 -1
  150. package/dist/src/pipeline-status.js +28 -8
  151. package/dist/src/pipeline-status.js.map +1 -1
  152. package/dist/src/types.d.ts +7 -1
  153. package/dist/src/types.d.ts.map +1 -1
  154. package/dist/src/types.js +6 -0
  155. package/dist/src/types.js.map +1 -1
  156. package/dist/src/utils/generated-marker.d.ts +8 -0
  157. package/dist/src/utils/generated-marker.d.ts.map +1 -1
  158. package/dist/src/utils/generated-marker.js +25 -0
  159. package/dist/src/utils/generated-marker.js.map +1 -1
  160. package/dist/src/validators/skill-validate.d.ts.map +1 -1
  161. package/dist/src/validators/skill-validate.js +2 -4
  162. package/dist/src/validators/skill-validate.js.map +1 -1
  163. package/os/adr/adr.module.ts +2 -0
  164. package/os/audit/audit.module.ts +2 -0
  165. package/os/compass/compass.module.ts +49 -15
  166. package/os/compass/handlers/compass-audit-handler.ts +51 -10
  167. package/os/compass/handlers/compass-docs-validate.ts +361 -0
  168. package/os/compass/handlers/summary-record.ts +106 -15
  169. package/os/compass/handlers/tests/compass-audit-record.test.ts +2 -1
  170. package/os/compass/handlers/tests/compass-audit-validate.test.ts +92 -3
  171. package/os/compass/handlers/tests/compass-docs-validate.test.ts +203 -0
  172. package/os/compass/handlers/tests/compass-ledger-scope.test.ts +2 -1
  173. package/os/compass/handlers/tests/compass-policy.test.ts +7 -1
  174. package/os/compass/handlers/tests/summary-record.test.ts +127 -0
  175. package/os/core/core.module.ts +147 -75
  176. package/os/core/docs-archive.test.ts +136 -0
  177. package/os/core/handlers/file-size-lint.ts +2 -0
  178. package/os/exploration/exploration.module.ts +3 -0
  179. package/os/naming/naming-convention.ts +11 -1
  180. package/os/naming/naming.module.ts +9 -2
  181. package/os/notes/notes.module.ts +17 -6
  182. package/os/plan/plan-0000-template.md +150 -0
  183. package/os/plan/plan.module.ts +2 -0
  184. package/os/plugin/plugin.module.ts +9 -2
  185. package/os/program/program.module.ts +19 -4
  186. package/os/queue/decision-ledger.test.ts +163 -0
  187. package/os/queue/handlers/queue-validate.ts +190 -8
  188. package/os/queue/manifest.ts +201 -7
  189. package/os/queue/queue-validate.test.ts +303 -0
  190. package/os/queue/queue.module.ts +32 -4
  191. package/os/queue/types.ts +56 -1
  192. package/os/rfc/handlers/implement-stamp.ts +37 -8
  193. package/os/rfc/rfc-read-only-no-side-effects.test.ts +1 -0
  194. package/os/rfc/rfc.module.ts +27 -6
  195. package/os/rfc/types.ts +18 -3
  196. package/os/rfc/verification-emit.test.ts +305 -0
  197. package/os/rfc/verification-evidence.ts +149 -24
  198. package/os/rfc/verification-refresh.test.ts +222 -1
  199. package/os/rfc/verification-refresh.ts +74 -38
  200. package/os/session/handlers/save.ts +37 -5
  201. package/os/session/session.module.ts +5 -0
  202. package/os/spec/live-spec-idempotency.pbt.test.ts +222 -0
  203. package/os/spec/live-spec-list-show-validate.test.ts +10 -6
  204. package/os/spec/live-spec-merge.test.ts +187 -7
  205. package/os/spec/live-spec-merge.ts +71 -155
  206. package/os/spec/live-spec-rebuild.test.ts +317 -0
  207. package/os/spec/live-spec-rebuild.ts +356 -0
  208. package/os/spec/live-spec-shared.ts +378 -0
  209. package/os/spec/live-spec-types.ts +21 -1
  210. package/os/spec/live-spec-validate.test.ts +317 -0
  211. package/os/spec/live-spec-validate.ts +106 -2
  212. package/os/spec/spec-materialize.test.ts +192 -0
  213. package/os/spec/spec-materialize.ts +48 -4
  214. package/os/spec/spec-schema.ts +49 -0
  215. package/os/spec/spec-status.ts +24 -0
  216. package/os/spec/spec-validate.test.ts +66 -0
  217. package/os/spec/spec-validate.ts +62 -8
  218. package/os/spec/spec.module.ts +85 -8
  219. package/os/werkstatt/handlers/werkstatt-operation-validate.ts +10 -4
  220. package/os/werkstatt/werkstatt.module.ts +13 -4
  221. package/os/workflow/workflow.module.ts +13 -5
  222. package/package.json +1 -1
  223. package/skills/_shared/fo-pipeline-conventions.md +126 -1
  224. package/skills/fo/fo-doc-audit/SKILL.md +4 -4
  225. package/skills/fo/fo-explore/SKILL.md +2 -1
  226. package/skills/fo/fo-fix/SKILL.md +11 -3
  227. package/skills/fo/fo-handoff/SKILL.md +4 -6
  228. package/skills/fo/fo-idea-create-rfc/SKILL.md +2 -1
  229. package/skills/fo/fo-idea-enhance/SKILL.md +23 -4
  230. package/skills/fo/fo-idea-i-just-want-to-see-the-result/SKILL.md +86 -22
  231. package/skills/fo/fo-idea-implement/SKILL.md +53 -10
  232. package/skills/fo/fo-idea-plan/SKILL.md +28 -6
  233. package/skills/fo/fo-review/SKILL.md +69 -8
  234. package/skills/fo/fo-session-retro/SKILL.md +3 -2
  235. package/skills/fo/fo-step-commit/SKILL.md +2 -0
  236. package/skills/shared/grilling/SKILL.md +12 -0
  237. package/skills/shared/writing-great-skills/GLOSSARY.md +2 -0
  238. package/skills/shared/writing-great-skills/SKILL.md +2 -1
  239. package/src/cli-flags.ts +23 -5
  240. package/src/config/forge-config.ts +4 -0
  241. package/src/onboarding/doctor.ts +2 -3
  242. package/src/onboarding/init.ts +8 -3
  243. package/src/pipeline-status.ts +32 -8
  244. package/src/tests/cli-flags.test.ts +20 -0
  245. package/src/tests/cli-output.test.ts +13 -7
  246. package/src/tests/fixtures/agents-generate-business-before.txt +7 -7
  247. package/src/tests/implement-stamp.test.ts +38 -0
  248. package/src/tests/session-handlers.test.ts +33 -0
  249. package/src/types.ts +13 -1
  250. package/src/utils/generated-marker.ts +28 -0
  251. package/src/validators/skill-validate.ts +2 -4
  252. package/skills/fo/fo-idea-implement/ADR-FLOW.md +0 -179
  253. package/skills/fo/fo-review/AXES.md +0 -70
@@ -0,0 +1,13 @@
1
+ import type { Diagnostic } from "../../../src/types.ts";
2
+ import type { ForgeCommandInput, ForgeCommandResult, ForgeRuntimeContext } from "../../../src/types.ts";
3
+ export declare function runCompassDocsValidate(input: ForgeCommandInput, context: ForgeRuntimeContext): Promise<ForgeCommandResult<{
4
+ command: "compass.docs.validate";
5
+ status: "pass" | "fail";
6
+ scanned: {
7
+ xmlFiles: number;
8
+ pathsChecked: number;
9
+ idsChecked: number;
10
+ };
11
+ diagnostics: Diagnostic[];
12
+ }>>;
13
+ //# sourceMappingURL=compass-docs-validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compass-docs-validate.d.ts","sourceRoot":"","sources":["../../../../os/compass/handlers/compass-docs-validate.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AA6M/B,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,iBAAiB,EACxB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CACR,kBAAkB,CAAC;IACjB,OAAO,EAAE,uBAAuB,CAAC;IACjC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IACxE,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B,CAAC,CACH,CAsHA"}
@@ -0,0 +1,328 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>RFC-1242: validate that the live root docs/*.xml corpus describes the repository as it exists — every path token, workspace id, and knowledge-graph link target must resolve to a real file, directory, or declared node.</purpose>
4
+ <non-goals>
5
+ <item>Do not scan archived trees, vendored specs, sessions/metrics, or authored RFC/ADR/plan bodies — frozen history and forward-looking prose legitimately name paths that do not exist.</item>
6
+ <item>Do not validate markdown link targets — only the XML semantic layer is gated (markdown sweep is manual).</item>
7
+ <item>Do not mutate anything — this handler is read-only; pruning lives on compass.audit.validate --prune.</item>
8
+ </non-goals>
9
+ </MODULE_CONTRACT>
10
+ <KEY_DECISIONS>
11
+ <item>Tag-stack tokenizer over an XML dependency — small authored corpus; a balance check catches literal-tag breakage (COMPASS-DOC-00).</item>
12
+ <item>Link targets resolve to declared node ids OR file/dir conventions (DOC-03) — dangling-by-convention stays a warning, never an error.</item>
13
+ </KEY_DECISIONS>
14
+ <CHANGE_SUMMARY>
15
+ <item>RFC-1242: review fixes — self-close detection strips quoted attr values first (a="foo/" no longer fakes a self-close), non-backticked path tokens get the same ellipsis strip, docs.* link slugs keep their basename prefix (docs.plans.plan-rfc-* resolves).</item>
16
+ <item>RFC-1242: created — scan docs/*.xml for unresolvable paths, workspace ids, and link targets (COMPASS-DOC-00..03).</item>
17
+ <item>RFC-1249: wire werkstatt.commands.validate into packages.check + retire CMD-OUTPUT debt</item>
18
+ </CHANGE_SUMMARY>
19
+ */
20
+ import { resolve } from "node:path";
21
+ import { resolveIo } from "../../../src/utils/io.js";
22
+ const DOCS_GLOB = "*.xml";
23
+ // Well-formedness: minimal tag-stack check. Skips comments, CDATA, PIs and
24
+ // declarations; a literal `<name` inside prose opens a tag that never balances
25
+ // → COMPASS-DOC-00. The corpus is authored XML without < in attribute values.
26
+ function checkWellFormed(file, source) {
27
+ const stack = [];
28
+ let i = 0;
29
+ let line = 1;
30
+ const advanceLine = (chunk) => {
31
+ for (const c of chunk)
32
+ if (c === "\n")
33
+ line++;
34
+ };
35
+ while (i < source.length) {
36
+ const open = source.indexOf("<", i);
37
+ if (open === -1)
38
+ break;
39
+ advanceLine(source.slice(i, open));
40
+ const rest = source.slice(open);
41
+ // comments / CDATA / PI / declarations
42
+ if (rest.startsWith("<!--")) {
43
+ const end = source.indexOf("-->", open + 4);
44
+ if (end === -1)
45
+ return { line, message: "unterminated comment" };
46
+ advanceLine(source.slice(open, end + 3));
47
+ i = end + 3;
48
+ continue;
49
+ }
50
+ if (rest.startsWith("<![CDATA[")) {
51
+ const end = source.indexOf("]]>", open + 9);
52
+ if (end === -1)
53
+ return { line, message: "unterminated CDATA" };
54
+ advanceLine(source.slice(open, end + 3));
55
+ i = end + 3;
56
+ continue;
57
+ }
58
+ if (rest.startsWith("<?")) {
59
+ const end = source.indexOf("?>", open + 2);
60
+ if (end === -1)
61
+ return { line, message: "unterminated processing instruction" };
62
+ advanceLine(source.slice(open, end + 2));
63
+ i = end + 2;
64
+ continue;
65
+ }
66
+ if (rest.startsWith("<!")) {
67
+ const end = source.indexOf(">", open + 2);
68
+ if (end === -1)
69
+ return { line, message: "unterminated declaration" };
70
+ advanceLine(source.slice(open, end + 1));
71
+ i = end + 1;
72
+ continue;
73
+ }
74
+ const tagMatch = /^<(\/?)([A-Za-z_][\w:.-]*)((?:"[^"]*"|'[^']*'|[^>"'])*)?(\/?)>/.exec(rest);
75
+ if (!tagMatch) {
76
+ // `<` not starting a tag — literal text, tolerated.
77
+ advanceLine(source.slice(open, open + 1));
78
+ i = open + 1;
79
+ continue;
80
+ }
81
+ const [, closing, name, attrs = "", selfClose] = tagMatch;
82
+ advanceLine(tagMatch[0]);
83
+ i = open + tagMatch[0].length;
84
+ if (closing === "/") {
85
+ const top = stack.pop();
86
+ if (!top || top.name !== name) {
87
+ return {
88
+ line,
89
+ message: `mismatched closing tag </${name}>${top ? ` — expected </${top.name}> opened at line ${top.line}` : " — no open tag"}`,
90
+ };
91
+ }
92
+ continue;
93
+ }
94
+ const attrsUnquoted = attrs.replace(/"[^"]*"|'[^']*'/g, "");
95
+ if (selfClose !== "/" && !attrsUnquoted.trimEnd().endsWith("/")) {
96
+ stack.push({ name, line });
97
+ }
98
+ }
99
+ if (stack.length > 0) {
100
+ const top = stack[stack.length - 1];
101
+ return { line: top.line, message: `unclosed tag <${top.name}>` };
102
+ }
103
+ return null;
104
+ }
105
+ function extractRefs(source) {
106
+ const refs = { paths: [], workspaceIds: [], linkTargets: [] };
107
+ const lineOf = (index) => source.slice(0, index).split("\n").length;
108
+ for (const m of source.matchAll(/<path>([\s\S]*?)<\/path>/g)) {
109
+ refs.paths.push({ value: m[1] ?? "", line: lineOf(m.index) });
110
+ }
111
+ for (const m of source.matchAll(/<workspace\s[^>]*?id="([^"]+)"/g)) {
112
+ refs.workspaceIds.push({ id: m[1], line: lineOf(m.index) });
113
+ }
114
+ for (const m of source.matchAll(/<node\s[^>]*>/g)) {
115
+ // DOC-02 only applies to ids that claim a workspace: <workspace> entries
116
+ // and workspace-typed nodes. Layer/symbolic ids (apps.rules,
117
+ // packages.rules, changelog.*) name semantic handles, not directories.
118
+ const id = /\bid="([^"]+)"/.exec(m[0])?.[1];
119
+ const type = /\btype="([^"]+)"/.exec(m[0])?.[1];
120
+ if (id && type === "workspace") {
121
+ refs.workspaceIds.push({ id, line: lineOf(m.index) });
122
+ }
123
+ }
124
+ for (const m of source.matchAll(/<link\s[^>]*?target="([^"]+)"/g)) {
125
+ refs.linkTargets.push({ target: m[1], line: lineOf(m.index) });
126
+ }
127
+ return refs;
128
+ }
129
+ // Normalize a <path> payload into checkable path tokens. Each backticked
130
+ // fragment is one candidate — splitting on commas inside would shred brace
131
+ // expansions (`{a,b}`) and ellipsis ranges (`docs/x/…` … `leaf`). A bare tail
132
+ // fragment after an `…` outside the backticks resolves under the previous
133
+ // fragment's directory (range shorthand for two versions of the same dir).
134
+ function pathTokens(raw) {
135
+ const tokens = [];
136
+ const fragments = [...raw.matchAll(/`([^`]*)`/g)].map((m) => m[1].trim());
137
+ if (fragments.length === 0) {
138
+ return raw
139
+ .split(/[\s,]+/)
140
+ .map((t) => t
141
+ .trim()
142
+ .replace(/(?:…|\.\.\.).*$/, "")
143
+ .replace(/\/+$/, ""))
144
+ .filter((t) => t.length > 0 && !t.startsWith("<") && t !== "…" && t !== "+");
145
+ }
146
+ const joinsWithEllipsis = raw.replace(/`[^`]*`/g, "").includes("…");
147
+ let parentDir = null;
148
+ for (const frag of fragments) {
149
+ const cleaned = frag.replace(/(?:…|\.\.\.).*$/, "").replace(/\/+$/, "");
150
+ if (!cleaned || cleaned === "+")
151
+ continue;
152
+ if (joinsWithEllipsis && !cleaned.includes("/") && parentDir) {
153
+ tokens.push(`${parentDir}/${cleaned}`);
154
+ continue;
155
+ }
156
+ tokens.push(cleaned);
157
+ parentDir = cleaned.split("/").slice(0, -1).join("/") || parentDir;
158
+ }
159
+ return tokens;
160
+ }
161
+ /** Directory prefix that must exist for a path token (glob tails trimmed). */
162
+ function pathCheckTarget(token) {
163
+ const globIdx = token.search(/[*{[]/);
164
+ if (globIdx === -1)
165
+ return token;
166
+ const prefix = token.slice(0, globIdx);
167
+ return prefix.replace(/\/[^/]*$/, "") || ".";
168
+ }
169
+ /** Resolve a workspace-style id to the package/service directory it names. */
170
+ function workspaceIdTarget(id) {
171
+ const pkg = /^pkg-([a-z0-9-]+)$/.exec(id);
172
+ if (pkg)
173
+ return `packages/${pkg[1]}`;
174
+ const svc = /^svc-([a-z0-9-]+)$/.exec(id);
175
+ if (svc)
176
+ return `services/${svc[1]}`;
177
+ const app = /^app-([a-z0-9-]+)$/.exec(id);
178
+ if (app)
179
+ return `apps/${app[1]}`;
180
+ const dotted = /^(packages|apps|services)\.([a-z0-9-]+)/.exec(id);
181
+ if (dotted)
182
+ return `${dotted[1]}/${dotted[2]}`;
183
+ return null;
184
+ }
185
+ /**
186
+ * DOC-03 resolution for dotted link targets: declared node id (checked by the
187
+ * caller) or a file/dir convention — docs.<dir>.<slug> → docs/<dir>/<slug>*,
188
+ * packages./apps./services. → workspace dir, spec.<x> → docs/specs/<x>*,
189
+ * dna-N → docs/architecture-dna.md, dotted command names → command manifest.
190
+ */
191
+ async function linkTargetResolves(target, declaredIds, io, docsDir, commandNames) {
192
+ if (declaredIds.has(target))
193
+ return "node";
194
+ if (commandNames.has(target))
195
+ return "file";
196
+ if (/^dna-\d+$/.test(target)) {
197
+ return (await io.exists(resolve(docsDir, "architecture-dna.md"))) ? "file" : "none";
198
+ }
199
+ const docsId = /^docs\.([a-z-]+)\.(.+)$/.exec(target);
200
+ if (docsId) {
201
+ const [, dir, slug] = docsId;
202
+ const hits = await io.glob(`${dir}/**/*${slug}*.md`, { cwd: docsDir }).catch(() => []);
203
+ if (hits.length > 0)
204
+ return "file";
205
+ // generic fallback: any file whose basename contains the slug under docs/
206
+ const broad = await io.glob(`**/*${slug}*`, { cwd: docsDir }).catch(() => []);
207
+ if (broad.length > 0)
208
+ return "file";
209
+ return "none";
210
+ }
211
+ const ws = workspaceIdTarget(target);
212
+ if (ws)
213
+ return (await io.exists(ws)) ? "file" : "none";
214
+ const spec = /^spec\.([a-z0-9-]+)$/.exec(target);
215
+ if (spec) {
216
+ const hits = await io.glob(`specs/${spec[1]}*/**`, { cwd: docsDir }).catch(() => []);
217
+ const dirs = await io.glob(`specs/${spec[1]}*`, { cwd: docsDir }).catch(() => []);
218
+ return hits.length + dirs.length > 0 ? "file" : "none";
219
+ }
220
+ return "none";
221
+ }
222
+ export async function runCompassDocsValidate(input, context) {
223
+ const io = resolveIo(context.io);
224
+ const docsDir = resolve(context.workspaceRoot, "docs");
225
+ const diagnostics = [];
226
+ let pathsChecked = 0;
227
+ let idsChecked = 0;
228
+ // Command-name convention for DOC-03: dotted targets like ratgeber.hub.validate
229
+ // resolve when the command registry lists them.
230
+ const commandNames = new Set();
231
+ const manifestPath = resolve(docsDir, "command-manifest.generated.yaml");
232
+ if (await io.exists(manifestPath)) {
233
+ const manifest = await io.readFile(manifestPath);
234
+ for (const m of manifest.matchAll(/^\s*- name: ([\w.-]+)\s*$/gm)) {
235
+ commandNames.add(m[1]);
236
+ }
237
+ }
238
+ const xmlFiles = (await io.glob(DOCS_GLOB, { cwd: docsDir })).sort();
239
+ const declaredNodeIds = new Set();
240
+ // Pass 1: collect declared node ids so link targets can resolve across files.
241
+ const sources = new Map();
242
+ for (const rel of xmlFiles) {
243
+ const abs = resolve(docsDir, rel);
244
+ const source = await io.readFile(abs);
245
+ sources.set(rel, source);
246
+ for (const m of source.matchAll(/<node\s[^>]*?id="([^"]+)"/g)) {
247
+ declaredNodeIds.add(m[1]);
248
+ }
249
+ }
250
+ for (const rel of xmlFiles) {
251
+ const file = `docs/${rel}`;
252
+ const source = sources.get(rel);
253
+ const malformed = checkWellFormed(file, source);
254
+ if (malformed) {
255
+ diagnostics.push({
256
+ ruleId: "COMPASS-DOC-00",
257
+ severity: "error",
258
+ file,
259
+ line: malformed.line,
260
+ message: `file is not well-formed XML: ${malformed.message}`,
261
+ });
262
+ continue; // refs from a broken file are noise
263
+ }
264
+ const refs = extractRefs(source);
265
+ for (const { value, line } of refs.paths) {
266
+ for (const token of pathTokens(value)) {
267
+ pathsChecked++;
268
+ const target = pathCheckTarget(token);
269
+ if (!(await io.exists(resolve(context.workspaceRoot, target)))) {
270
+ diagnostics.push({
271
+ ruleId: "COMPASS-DOC-01",
272
+ severity: "error",
273
+ file,
274
+ line,
275
+ message: `<path> references '${token}' — does not exist under the workspace root`,
276
+ fixHint: "Repoint to the live path or remove the stale reference",
277
+ });
278
+ }
279
+ }
280
+ }
281
+ for (const { id, line } of refs.workspaceIds) {
282
+ const target = workspaceIdTarget(id);
283
+ if (!target)
284
+ continue;
285
+ idsChecked++;
286
+ if (!(await io.exists(resolve(context.workspaceRoot, target)))) {
287
+ diagnostics.push({
288
+ ruleId: "COMPASS-DOC-02",
289
+ severity: "error",
290
+ file,
291
+ line,
292
+ message: `id '${id}' names workspace path '${target}' — does not exist`,
293
+ fixHint: "Repoint to the live package or remove the stale entry",
294
+ });
295
+ }
296
+ }
297
+ for (const { target, line } of refs.linkTargets) {
298
+ idsChecked++;
299
+ const resolved = await linkTargetResolves(target, declaredNodeIds, io, docsDir, commandNames);
300
+ if (resolved === "none") {
301
+ diagnostics.push({
302
+ ruleId: "COMPASS-DOC-03",
303
+ severity: "warning",
304
+ file,
305
+ line,
306
+ message: `link target '${target}' resolves to no declared node and no file`,
307
+ });
308
+ }
309
+ }
310
+ }
311
+ const errors = diagnostics.filter((d) => d.severity === "error");
312
+ for (const d of diagnostics) {
313
+ context.logger[d.severity === "error" ? "error" : "warn"](`[compass.docs.validate] ${d.ruleId}: ${d.file}${d.line ? `:${d.line}` : ""}: ${d.message}`);
314
+ }
315
+ return {
316
+ data: {
317
+ command: "compass.docs.validate",
318
+ status: errors.length === 0 ? "pass" : "fail",
319
+ scanned: { xmlFiles: xmlFiles.length, pathsChecked, idsChecked },
320
+ diagnostics,
321
+ },
322
+ exitCode: errors.length > 0 ? 1 : 0,
323
+ summary: errors.length === 0
324
+ ? `[compass.docs.validate] OK (${xmlFiles.length} files, ${pathsChecked} paths, ${idsChecked} ids)`
325
+ : `[compass.docs.validate] ${errors.length} error(s)`,
326
+ };
327
+ }
328
+ //# sourceMappingURL=compass-docs-validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compass-docs-validate.js","sourceRoot":"","sources":["../../../../os/compass/handlers/compass-docs-validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;EAkBE;AAEF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAQrD,MAAM,SAAS,GAAG,OAAO,CAAC;AAE1B,2EAA2E;AAC3E,+EAA+E;AAC/E,8EAA8E;AAC9E,SAAS,eAAe,CAAC,IAAY,EAAE,MAAc;IACnD,MAAM,KAAK,GAA0C,EAAE,CAAC;IACxD,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,EAAE;QACpC,KAAK,MAAM,CAAC,IAAI,KAAK;YAAE,IAAI,CAAC,KAAK,IAAI;gBAAE,IAAI,EAAE,CAAC;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AAO,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CACvD,2BAA2B,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,CAC5F,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE;YACJ,OAAO,EAAE,uBAAuB;YAChC,MAAM,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;YAC7C,OAAO,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE;YAChE,WAAW;SACZ;QACD,QAAQ,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,OAAO,EACL,MAAM,CAAC,MAAM,KAAK,CAAC;YACjB,CAAC,CAAC,+BAA+B,QAAQ,CAAC,MAAM,WAAW,YAAY,WAAW,UAAU,OAAO;YACnG,CAAC,CAAC,2BAA2B,MAAM,CAAC,MAAM,WAAW;KAC1D,CAAC;AACJ,CAAC"}
@@ -7,7 +7,7 @@ export interface SummaryRecordInput {
7
7
  text?: string;
8
8
  workpiece?: string;
9
9
  }
10
- export type SummaryRecordSkipReason = "no-block" | "duplicate" | "unparseable";
10
+ export type SummaryRecordSkipReason = "no-block" | "duplicate" | "unparseable" | "id-in-diff";
11
11
  export interface SummaryRecordResult {
12
12
  command: "compass.summary.record";
13
13
  status: "pass";
@@ -34,6 +34,13 @@ export declare function mergeHistoryIds(existing: string[], incoming: string[],
34
34
  export declare function getLineCommentPrefix(filePath: string): string | null;
35
35
  export declare function buildChangeSummaryBlock(items: string[], historyIds: string[], filePath: string): string;
36
36
  export declare function stripConventionalPrefix(subject: string): string;
37
+ /**
38
+ * Remove a trailing git-trailer block: the contiguous tail of strict
39
+ * trailer lines and admitted markdown-link lines. A blank line ends the
40
+ * tail paragraph. Returns the message without the block; when the tail
41
+ * holds no strict trailer line the message is returned unchanged.
42
+ */
43
+ export declare function stripGitTrailers(message: string): string;
37
44
  export declare function sanitizeItemText(text: string): string;
38
45
  export declare function isValidGovernanceId(id: string, policy: CompassPolicy): boolean;
39
46
  interface RecordOutcome {
@@ -44,8 +51,10 @@ interface RecordOutcome {
44
51
  /**
45
52
  * Append `ID: text` to one file's CHANGE_SUMMARY and collapse the window.
46
53
  * Returns the outcome; writes the file only when mutated and not dry-run.
54
+ * `headSource` is the file's content at HEAD (when resolvable) — it enables
55
+ * the id-in-diff dedup; pass undefined outside git workspaces.
47
56
  */
48
- export declare function recordSummaryItem(absPath: string, relPath: string, id: string, text: string, dryRun: boolean, policy: CompassPolicy): Promise<RecordOutcome>;
57
+ export declare function recordSummaryItem(absPath: string, relPath: string, id: string, text: string, dryRun: boolean, policy: CompassPolicy, headSource?: string): Promise<RecordOutcome>;
49
58
  export declare function runCompassSummaryRecord(input: ForgeCommandInput, context: ForgeRuntimeContext): Promise<ForgeCommandResult<SummaryRecordResult>>;
50
59
  export {};
51
60
  //# sourceMappingURL=summary-record.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"summary-record.d.ts","sourceRoot":"","sources":["../../../../os/compass/handlers/summary-record.ts"],"names":[],"mappings":"AAuCA,OAAO,EAAgD,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAOhG,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAO/B,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAOvC,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,C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ClB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,uBAAuB,CAAC;CACtC;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,aAAa,CAAC,CA8CxB;AASD,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,iBAAiB,EACxB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC,CAqElD"}
1
+ {"version":3,"file":"summary-record.d.ts","sourceRoot":"","sources":["../../../../os/compass/handlers/summary-record.ts"],"names":[],"mappings":"AAiCA,OAAO,EAAgD,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAOhG,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAO/B,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAOvC,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,uBAAuB,GAAG,UAAU,GAAG,WAAW,GAAG,aAAa,GAAG,YAAY,CAAC;AAE9F,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,wBAAwB,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,uBAAuB,CAAA;KAAE,CAAC,CAAC;IAClE,qBAAqB,EA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uB,CAC3C,KAAK,EAAE,iBAAiB,EACxB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC,CAoFlD"}
@@ -15,23 +15,17 @@ items to CHANGE_SUMMARY blocks per RFC-1095. Collapses the 5-item window into
15
15
  <item>Item text is sanitized on record — literal Compass tags would corrupt history parsing.</item>
16
16
  </KEY_DECISIONS>
17
17
  <CHANGE_SUMMARY>
18
- <item>RFC-1097: steps 1-4 — compass.migrate codemod
19
-
20
- Add the v1 to v2 Compass header codemod: migrateFile pure transform (collapse, strip, seed, reorder, purpose-flag actions), migrateWorkspace walker, runCompassMigrate handler with dirty-tree refusal and --force/--files/--dry-run flags, module registration, and 15 unit tests.</item>
21
- <item>RFC-1097: sweep — packages/forge + services clean
22
-
23
- 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>
24
- <item>RFC-1097: sweep — engine package clean
25
-
26
- Sweep batch 4: 73 Compass headers on headerless engine files (certification, component-runtime, isolation, evolution, testing), real KEY_DECISIONS on 75 files (kernel, cache, dht, swim, gitmesh, runtime), ~80 purpose expansions (CONTRACT-02/PURPOSE-02), non-goals on 13 CONTRACT-03 files, CS-07 history literal fix repo-wide (253 files). Policy: .template.ts/.template.astro excludedPaths. engine package now 0 diagnostics.</item>
27
18
  <item>RFC-1097: AC-4 banned literal in os/compass handlers
28
19
 
29
20
  compass-migrate-handler hint used a consumer-specific run command — switched to generic 'pnpm exec forge run' convention. Reworded recorded CHANGE_SUMMARY items in 3 handlers to drop the consumer-specific literal. compass-policy AC-4 test green (65/65).</item>
30
21
  <item>RFC-1220: step 2 — fail-closed guards in history paths</item>
31
- <history>RFC-1095</history>
22
+ <item>RFC-1233: stripGitTrailers at the record point + sanitizeItemText star-slash guard — commit-message trailers (Token: value / Token #value, plus markdown-link attribution lines like "Generated with [X](url)") no longer pollute injected items.</item>
23
+ <item>Session-retro 2026-10-08: id-in-diff dedup — auto-inject skips when the worktree diff already carries a same-ID item (HEAD-vs-worktree via git show HEAD:path), closing the descriptive+generic duplicate class seen on RFC-1237.</item>
24
+ <item>RFC-1249: wire werkstatt.commands.validate into packages.check + retire CMD-OUTPUT debt</item>
25
+ <history>CONTRACT-02, PURPOSE-02, RFC-1095, RFC-1097</history>
32
26
  </CHANGE_SUMMARY>
33
27
  */
34
- import { existsSync } from "../../../src/utils/sync-fs.js";
28
+ import { execFile, existsSync } from "../../../src/utils/sync-fs.js";
35
29
  import { ambientIo, resolveIo } from "../../../src/utils/io.js";
36
30
  import { resolve, relative } from "node:path";
37
31
  import { detectRiskClass, getWorkspaceRelativeSegments } from "./compass-inventory.js";
@@ -117,12 +111,54 @@ export function buildChangeSummaryBlock(items, historyIds, filePath) {
117
111
  export function stripConventionalPrefix(subject) {
118
112
  return subject.replace(CONVENTIONAL_PREFIX_RE, "").trim();
119
113
  }
114
+ // RFC-1233: git-trailer tail block — strict `Token: value` / `Token #value`
115
+ // lines (interpret-trailers shape, empty value allowed), plus lines ending
116
+ // in a markdown link (the observed "Generated with [X](url)" attribution
117
+ // boilerplate has no separator). A link-shaped line is admitted only when
118
+ // the block also contains at least one strict trailer line — a lone link
119
+ // tail is prose.
120
+ const TRAILER_LINE_RE = /^[A-Za-z0-9-]+(:| #)\s*.*$/;
121
+ const MARKDOWN_LINK_TAIL_RE = /^.*\[[^\]]*\]\([^)]+\)\s*$/;
122
+ /**
123
+ * Remove a trailing git-trailer block: the contiguous tail of strict
124
+ * trailer lines and admitted markdown-link lines. A blank line ends the
125
+ * tail paragraph. Returns the message without the block; when the tail
126
+ * holds no strict trailer line the message is returned unchanged.
127
+ */
128
+ export function stripGitTrailers(message) {
129
+ const lines = message.trimEnd().split("\n");
130
+ let start = lines.length;
131
+ let sawStrict = false;
132
+ while (start > 0) {
133
+ const line = lines[start - 1].trim();
134
+ if (line === "")
135
+ break;
136
+ if (TRAILER_LINE_RE.test(line)) {
137
+ sawStrict = true;
138
+ start--;
139
+ }
140
+ else if (MARKDOWN_LINK_TAIL_RE.test(line)) {
141
+ start--;
142
+ }
143
+ else {
144
+ break;
145
+ }
146
+ }
147
+ if (!sawStrict || start === lines.length)
148
+ return message;
149
+ return lines.slice(0, start).join("\n").trimEnd();
150
+ }
120
151
  // Literal Compass block tags inside an item corrupt block parsing — a commit
121
152
  // message saying "collapsed into history" would be matched by HISTORY_RE and
122
153
  // produce phantom non-ID tokens (CS-07). Strip the angle brackets on record.
123
154
  const COMPASS_TAG_LITERAL_RE = /<\/?(?:CHANGE_SUMMARY|MODULE_CONTRACT|KEY_DECISIONS|history|item|purpose|non-goals)>/g;
124
155
  export function sanitizeItemText(text) {
125
- return text.replace(COMPASS_TAG_LITERAL_RE, (tag) => tag.replace(/[<>]/g, ""));
156
+ return (text
157
+ .replace(COMPASS_TAG_LITERAL_RE, (tag) => tag.replace(/[<>]/g, ""))
158
+ // RFC-1233: a literal star-slash sequence would terminate the
159
+ // surrounding block comment when the item lands in /* ... */ headers.
160
+ // ∕ (U+2215) is visually near-identical, idempotent, and never re-forms.
161
+ .replace(/\*\//g, "*\u2215"));
126
162
  }
127
163
  export function isValidGovernanceId(id, policy) {
128
164
  return policy.idPatternFull.test(id);
@@ -130,8 +166,10 @@ export function isValidGovernanceId(id, policy) {
130
166
  /**
131
167
  * Append `ID: text` to one file's CHANGE_SUMMARY and collapse the window.
132
168
  * Returns the outcome; writes the file only when mutated and not dry-run.
169
+ * `headSource` is the file's content at HEAD (when resolvable) — it enables
170
+ * the id-in-diff dedup; pass undefined outside git workspaces.
133
171
  */
134
- export async function recordSummaryItem(absPath, relPath, id, text, dryRun, policy) {
172
+ export async function recordSummaryItem(absPath, relPath, id, text, dryRun, policy, headSource) {
135
173
  const source = await io.readFile(absPath);
136
174
  const blockMatch = source.match(CHANGE_SUMMARY_BLOCK_RE);
137
175
  // Header-region guard: a CHANGE_SUMMARY is a header only when it sits at the
@@ -158,6 +196,21 @@ export async function recordSummaryItem(absPath, relPath, id, text, dryRun, poli
158
196
  if (items.some((item) => normalizeItemText(item) === normalizedNew)) {
159
197
  return { recorded: false, collapsed: false, skipReason: "duplicate" };
160
198
  }
199
+ // A same-ID item already in the worktree but absent from HEAD means the
200
+ // pending change already carries a hand-authored record for this governance
201
+ // ID — the auto-injected subject-derived item would duplicate it at lower
202
+ // specificity (observed 2026-10-08: 27 files carried descriptive + generic
203
+ // RFC-1237 items). HEAD-resident same-ID items do NOT suppress: consecutive
204
+ // commits under one RFC legitimately stack step items.
205
+ if (headSource !== undefined) {
206
+ const headBlock = headSource.match(CHANGE_SUMMARY_BLOCK_RE);
207
+ const headItems = headBlock ? parseChangeSummary(headBlock[0]).items : [];
208
+ const idInWorktree = items.some((item) => leadingGovernanceId(item, policy) === id);
209
+ const idInHead = headItems.some((item) => leadingGovernanceId(item, policy) === id);
210
+ if (idInWorktree && !idInHead) {
211
+ return { recorded: false, collapsed: false, skipReason: "id-in-diff" };
212
+ }
213
+ }
161
214
  const nextItems = [...items, newItem];
162
215
  const collapsedIds = [];
163
216
  while (nextItems.length > CHANGE_SUMMARY_WINDOW) {
@@ -175,6 +228,27 @@ export async function recordSummaryItem(absPath, relPath, id, text, dryRun, poli
175
228
  }
176
229
  return { recorded: true, collapsed };
177
230
  }
231
+ function execGit(cwd, args) {
232
+ return new Promise((resolve) => {
233
+ execFile("git", args, { cwd, timeout: 5000 }, (err, stdout) => {
234
+ resolve(err ? null : stdout);
235
+ });
236
+ });
237
+ }
238
+ /**
239
+ * Read `path`'s content at HEAD — the baseline for the id-in-diff dedup.
240
+ * Returns undefined when the file is untracked or the workspace is not a git
241
+ * repo (the dedup then falls back to exact-text matching only).
242
+ */
243
+ async function readHeadSource(gitTop, absPath) {
244
+ if (!gitTop)
245
+ return undefined;
246
+ const rel = relative(gitTop, absPath).replace(/\\/g, "/");
247
+ if (rel === "" || rel.startsWith(".."))
248
+ return undefined;
249
+ const source = await execGit(gitTop, ["show", `HEAD:${rel}`]);
250
+ return source ?? undefined;
251
+ }
178
252
  function riskReminderNeeded(relPath, source, policy) {
179
253
  const segments = relPath.split("/").filter(Boolean);
180
254
  const workspaceRel = getWorkspaceRelativeSegments(segments, policy).join("/");
@@ -198,7 +272,10 @@ export async function runCompassSummaryRecord(input, context) {
198
272
  ? rawFiles.split(/\s+/).filter(Boolean)
199
273
  : [];
200
274
  const rawText = input.flags["text"];
201
- const text = typeof rawText === "string" && rawText.trim().length > 0 ? rawText.trim() : id;
275
+ // RFC-1233: strip the git-trailer block at the single injection point —
276
+ // ecosystem.commit and mission.git.commit both pipe the raw message here.
277
+ const stripped = typeof rawText === "string" ? stripGitTrailers(rawText).trim() : "";
278
+ const text = stripped.length > 0 ? stripped : id;
202
279
  const result = {
203
280
  command: "compass.summary.record",
204
281
  status: "pass",
@@ -207,6 +284,8 @@ export async function runCompassSummaryRecord(input, context) {
207
284
  skipped: [],
208
285
  keyDecisionsReminders: [],
209
286
  };
287
+ const gitTopRaw = await execGit(baseRoot, ["rev-parse", "--show-toplevel"]);
288
+ const gitTop = gitTopRaw?.trim() || null;
210
289
  for (const file of files) {
211
290
  const absPath = resolve(baseRoot, file);
212
291
  const relPath = relative(baseRoot, absPath).replace(/\\/g, "/");
@@ -216,7 +295,8 @@ export async function runCompassSummaryRecord(input, context) {
216
295
  continue;
217
296
  }
218
297
  try {
219
- const outcome = await recordSummaryItem(absPath, relPath, id, text, context.dryRun, policy);
298
+ const headSource = await readHeadSource(gitTop, absPath);
299
+ const outcome = await recordSummaryItem(absPath, relPath, id, text, context.dryRun, policy, headSource);
220
300
  if (outcome.skipReason) {
221
301
  result.skipped.push({ file, reason: outcome.skipReason });
222
302
  continue;