@warpgogol/forge 2.8.0 → 2.8.2

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 (271) hide show
  1. package/AGENTS.md +1 -1
  2. package/README.md +23 -13
  3. package/README.uk.md +19 -12
  4. package/dist/os/session/handlers/validate.d.ts.map +1 -1
  5. package/dist/os/session/handlers/validate.js +23 -1
  6. package/dist/os/session/handlers/validate.js.map +1 -1
  7. package/dist/os/session/types.d.ts +31 -1
  8. package/dist/os/session/types.d.ts.map +1 -1
  9. package/dist/os/session/types.js +7 -0
  10. package/dist/os/session/types.js.map +1 -1
  11. package/os/adr/adr.module.ts +158 -0
  12. package/os/adr/frontmatter-io.ts +80 -0
  13. package/os/adr/handlers/archive.ts +244 -0
  14. package/os/adr/handlers/implement-stamp.ts +331 -0
  15. package/os/adr/handlers/list-create.ts +207 -0
  16. package/os/adr/handlers/validate.test.ts +232 -0
  17. package/os/adr/handlers/validate.ts +429 -0
  18. package/os/adr/index.ts +33 -0
  19. package/os/adr/types.ts +141 -0
  20. package/os/audit/audit.module.ts +48 -0
  21. package/os/audit/frontmatter-io.ts +84 -0
  22. package/os/audit/handlers/archive.ts +239 -0
  23. package/os/audit/index.ts +23 -0
  24. package/os/audit/types.ts +29 -0
  25. package/os/compass/compass.module.ts +186 -0
  26. package/os/compass/handlers/compass-audit-handler.ts +382 -0
  27. package/os/compass/handlers/compass-change-summary-handler.ts +272 -0
  28. package/os/compass/handlers/compass-inventory-handler.ts +294 -0
  29. package/os/compass/handlers/compass-inventory.ts +521 -0
  30. package/os/compass/handlers/git-revision.ts +137 -0
  31. package/os/compass/handlers/resolve-scan-root-workpiece.test.ts +65 -0
  32. package/os/compass/handlers/resolve-scan-root.ts +79 -0
  33. package/os/compass/index.ts +33 -0
  34. package/os/core/core.module.ts +948 -0
  35. package/os/core/handlers/assets-check.ts +122 -0
  36. package/os/core/handlers/assets-helpers.ts +174 -0
  37. package/os/core/handlers/assets-list.ts +99 -0
  38. package/os/core/handlers/build.ts +155 -0
  39. package/os/core/handlers/determinism-check.ts +354 -0
  40. package/os/core/handlers/dev.ts +127 -0
  41. package/os/core/handlers/invariant-engine.test.ts +681 -0
  42. package/os/core/handlers/knowledge-compact.ts +248 -0
  43. package/os/core/handlers/lifecycle-handlers.test.ts +524 -0
  44. package/os/core/handlers/note-frontmatter-validate.test.ts +93 -0
  45. package/os/core/handlers/note-link-validate.test.ts +117 -0
  46. package/os/core/handlers/note-orphan-detect.test.ts +94 -0
  47. package/os/core/handlers/package-health.test.ts +226 -0
  48. package/os/core/handlers/package-health.ts +231 -0
  49. package/os/core/handlers/pinned-check.ts +200 -0
  50. package/os/core/handlers/pinned-init.ts +333 -0
  51. package/os/core/handlers/pinned-types.ts +50 -0
  52. package/os/core/handlers/pinned-validate.ts +301 -0
  53. package/os/core/handlers/profile-resolve.ts +92 -0
  54. package/os/core/handlers/release-prepare.ts +294 -0
  55. package/os/core/handlers/release-publish.ts +211 -0
  56. package/os/core/handlers/validate.ts +262 -0
  57. package/os/core/handlers/workspace-deps.ts +55 -0
  58. package/os/core/index.ts +13 -0
  59. package/os/exploration/exploration.module.ts +90 -0
  60. package/os/exploration/frontmatter-io.ts +77 -0
  61. package/os/exploration/handlers/archive.ts +159 -0
  62. package/os/exploration/handlers/list.ts +77 -0
  63. package/os/exploration/handlers/show.ts +107 -0
  64. package/os/exploration/index.ts +25 -0
  65. package/os/exploration/types.ts +65 -0
  66. package/os/mission/handlers/archive.test.ts +391 -0
  67. package/os/mission/handlers/archive.ts +453 -0
  68. package/os/mission/index.ts +1 -0
  69. package/os/mission/mission.module.ts +48 -0
  70. package/os/mission/types.ts +41 -0
  71. package/os/naming/index.ts +14 -0
  72. package/os/naming/naming-convention.test.ts +163 -0
  73. package/os/naming/naming-convention.ts +378 -0
  74. package/os/naming/naming.module.ts +36 -0
  75. package/os/notes/index.ts +10 -0
  76. package/os/notes/notes.module.ts +109 -0
  77. package/os/plan/frontmatter-io.ts +82 -0
  78. package/os/plan/handlers/archive.ts +238 -0
  79. package/os/plan/index.ts +23 -0
  80. package/os/plan/plan.module.ts +48 -0
  81. package/os/plan/types.ts +29 -0
  82. package/os/program/discovery.ts +294 -0
  83. package/os/program/handlers/complete.ts +419 -0
  84. package/os/program/handlers/lease.ts +433 -0
  85. package/os/program/handlers/seal.ts +332 -0
  86. package/os/program/handlers/validate.ts +213 -0
  87. package/os/program/lease.ts +156 -0
  88. package/os/program/program.module.ts +212 -0
  89. package/os/program/schemas.ts +218 -0
  90. package/os/program/state.ts +264 -0
  91. package/os/rfc/acceptance.ts +344 -0
  92. package/os/rfc/decision-log.ts +310 -0
  93. package/os/rfc/dna-trace.ts +280 -0
  94. package/os/rfc/frontmatter-io.test.ts +132 -0
  95. package/os/rfc/frontmatter-io.ts +130 -0
  96. package/os/rfc/handlers/archive.ts +300 -0
  97. package/os/rfc/handlers/check.ts +238 -0
  98. package/os/rfc/handlers/implement-stamp.ts +515 -0
  99. package/os/rfc/handlers/index-graph.ts +237 -0
  100. package/os/rfc/handlers/lifecycle.test.ts +127 -0
  101. package/os/rfc/handlers/lifecycle.ts +249 -0
  102. package/os/rfc/handlers/list-create.ts +296 -0
  103. package/os/rfc/handlers/pipeline-status.ts +173 -0
  104. package/os/rfc/handlers/shared.ts +121 -0
  105. package/os/rfc/handlers/supersede-propose.ts +241 -0
  106. package/os/rfc/handlers/validate-rules.test.ts +891 -0
  107. package/os/rfc/handlers/validate-rules.ts +984 -0
  108. package/os/rfc/handlers/validate.ts +166 -0
  109. package/os/rfc/handlers.ts +19 -0
  110. package/os/rfc/index.ts +97 -0
  111. package/os/rfc/rfc.module.ts +416 -0
  112. package/os/rfc/types.ts +596 -0
  113. package/os/rfc/verification-evidence.ts +244 -0
  114. package/os/session/atif-parser.ts +166 -0
  115. package/os/session/frontmatter-io.ts +163 -0
  116. package/os/session/handlers/archive.ts +288 -0
  117. package/os/session/handlers/list.ts +174 -0
  118. package/os/session/handlers/save.ts +348 -0
  119. package/os/session/handlers/validate.ts +250 -0
  120. package/os/session/index.ts +50 -0
  121. package/os/session/session.module.ts +126 -0
  122. package/os/session/types.ts +203 -0
  123. package/os/spec/live-spec-list-show-validate.test.ts +257 -0
  124. package/os/spec/live-spec-list.ts +78 -0
  125. package/os/spec/live-spec-merge.test.ts +261 -0
  126. package/os/spec/live-spec-merge.ts +413 -0
  127. package/os/spec/live-spec-show.ts +117 -0
  128. package/os/spec/live-spec-types.ts +93 -0
  129. package/os/spec/live-spec-validate.ts +170 -0
  130. package/os/spec/spec-materialize.ts +390 -0
  131. package/os/spec/spec-schema.ts +174 -0
  132. package/os/spec/spec-status.ts +284 -0
  133. package/os/spec/spec-validate.ts +513 -0
  134. package/os/spec/spec.module.ts +135 -0
  135. package/os/werkstatt/handlers/lock.ts +168 -0
  136. package/os/werkstatt/handlers/schema.ts +47 -0
  137. package/os/werkstatt/handlers/werkstatt-lock-recover.ts +175 -0
  138. package/os/werkstatt/handlers/werkstatt-lock-status.ts +73 -0
  139. package/os/werkstatt/handlers/werkstatt-operation-validate.ts +104 -0
  140. package/os/werkstatt/index.ts +39 -0
  141. package/os/werkstatt/werkstatt.module.ts +62 -0
  142. package/os/workflow/handlers.ts +304 -0
  143. package/os/workflow/index.ts +28 -0
  144. package/os/workflow/types.ts +99 -0
  145. package/os/workflow/workflow.module.ts +54 -0
  146. package/package.json +3 -3
  147. package/profiles/godot-csharp.yaml +4 -4
  148. package/profiles/knowledge-typescript-turborepo.yaml +110 -0
  149. package/profiles/phaser-turborepo.yaml +5 -5
  150. package/skills/_shared/fo-session-summary.md +132 -16
  151. package/skills/fo/fo-add-tests/pbt-guide.md +13 -13
  152. package/skills/fo/fo-doc-audit/SKILL.md +6 -6
  153. package/skills/fo/fo-handoff/SKILL.md +5 -0
  154. package/skills/fo/fo-idea/SKILL.md +1 -1
  155. package/skills/fo/fo-review/SKILL.md +1 -1
  156. package/skills/fo/fo-session-retro/SKILL.md +8 -0
  157. package/skills/fo/fo-session-save/SKILL.md +8 -0
  158. package/src/cli-output.ts +59 -0
  159. package/src/config/__tests__/resolve-terminology.test.ts +45 -0
  160. package/src/config/forge-config.ts +524 -0
  161. package/src/forge-module.ts +39 -0
  162. package/src/index.ts +172 -0
  163. package/src/knowledge/__tests__/promote.test.ts +219 -0
  164. package/src/knowledge/__tests__/serialize.test.ts +192 -0
  165. package/src/knowledge/budgets.ts +202 -0
  166. package/src/knowledge/compact.ts +405 -0
  167. package/src/knowledge/index.ts +53 -0
  168. package/src/knowledge/parse.ts +227 -0
  169. package/src/knowledge/promote.ts +156 -0
  170. package/src/knowledge/schema.ts +112 -0
  171. package/src/knowledge/serialize.ts +72 -0
  172. package/src/migration-adapters/__tests__/ignored-files.test.ts +51 -0
  173. package/src/migration-adapters/__tests__/registry.test.ts +131 -0
  174. package/src/migration-adapters/__tests__/types.test.ts +86 -0
  175. package/src/migration-adapters/git-utils.ts +71 -0
  176. package/src/migration-adapters/ignored-files.ts +221 -0
  177. package/src/migration-adapters/index.ts +21 -0
  178. package/src/migration-adapters/node-typescript-pnpm/index.ts +189 -0
  179. package/src/migration-adapters/phaser-pnpm/index.ts +189 -0
  180. package/src/migration-adapters/registry.ts +61 -0
  181. package/src/migration-adapters/types.ts +68 -0
  182. package/src/onboarding/__tests__/workspace-discovery.test.ts +134 -0
  183. package/src/onboarding/agents-generate.ts +443 -0
  184. package/src/onboarding/create.ts +427 -0
  185. package/src/onboarding/doctor.ts +1297 -0
  186. package/src/onboarding/init.ts +337 -0
  187. package/src/onboarding/invariant-engine.ts +448 -0
  188. package/src/onboarding/memory-scaffold.ts +189 -0
  189. package/src/onboarding/nested-agents-generate.ts +93 -0
  190. package/src/onboarding/nested-agents-templates.ts +233 -0
  191. package/src/onboarding/profile-validate.ts +139 -0
  192. package/src/onboarding/scaffold-project.ts +299 -0
  193. package/src/onboarding/scaffold.ts +143 -0
  194. package/src/onboarding/upgrade.ts +558 -0
  195. package/src/onboarding/workspace-discovery.ts +167 -0
  196. package/src/profiles/__tests__/profile-schema.test.ts +228 -0
  197. package/src/profiles/__tests__/stack-profile.test.ts +190 -0
  198. package/src/profiles/__tests__/terminology-utils.test.ts +71 -0
  199. package/src/profiles/profile-schema.ts +350 -0
  200. package/src/profiles/stack-profile.ts +188 -0
  201. package/src/profiles/terminology-utils.ts +36 -0
  202. package/src/registry.ts +185 -0
  203. package/src/skill-schema.ts +37 -0
  204. package/src/tests/acceptance-criteria.test.ts +99 -0
  205. package/src/tests/adr-implement-stamp.test.ts +368 -0
  206. package/src/tests/agents-generate-domain.test.ts +317 -0
  207. package/src/tests/agents-generate.test.ts +458 -0
  208. package/src/tests/bindings-schema.test.ts +314 -0
  209. package/src/tests/budgets.test.ts +213 -0
  210. package/src/tests/cli-output.test.ts +196 -0
  211. package/src/tests/compact.test.ts +796 -0
  212. package/src/tests/create.test.ts +289 -0
  213. package/src/tests/doctor-autonomy.test.ts +98 -0
  214. package/src/tests/doctor-bindings.test.ts +286 -0
  215. package/src/tests/doctor-domain.test.ts +113 -0
  216. package/src/tests/exploration-handlers.test.ts +256 -0
  217. package/src/tests/fixtures/agents-generate-business-before.txt +288 -0
  218. package/src/tests/forge-config.test.ts +420 -0
  219. package/src/tests/fs-atomic.test.ts +96 -0
  220. package/src/tests/fs.test.ts +103 -0
  221. package/src/tests/generated-marker.test.ts +161 -0
  222. package/src/tests/hash.test.ts +37 -0
  223. package/src/tests/implement-stamp.test.ts +505 -0
  224. package/src/tests/init-bindings.test.ts +183 -0
  225. package/src/tests/knowledge-parse.test.ts +307 -0
  226. package/src/tests/knowledge-pbt.test.ts +164 -0
  227. package/src/tests/memory-scaffold.test.ts +192 -0
  228. package/src/tests/migration-adapters.test.ts +480 -0
  229. package/src/tests/package-files.test.ts +54 -0
  230. package/src/tests/pinned-check.test.ts +194 -0
  231. package/src/tests/pinned-init.test.ts +126 -0
  232. package/src/tests/profile-schema.test.ts +194 -0
  233. package/src/tests/profile-validate.test.ts +120 -0
  234. package/src/tests/program-lease.test.ts +245 -0
  235. package/src/tests/program-paths-extended.test.ts +117 -0
  236. package/src/tests/program-paths.test.ts +98 -0
  237. package/src/tests/program-property.test.ts +139 -0
  238. package/src/tests/program-schemas.test.ts +445 -0
  239. package/src/tests/program-spec-node.test.ts +250 -0
  240. package/src/tests/promote.test.ts +481 -0
  241. package/src/tests/registry.test.ts +73 -0
  242. package/src/tests/scaffold-project.test.ts +150 -0
  243. package/src/tests/session-handlers.test.ts +503 -0
  244. package/src/tests/session-pbt.test.ts +190 -0
  245. package/src/tests/skill-schema.test.ts +146 -0
  246. package/src/tests/skill-validate-knowledge.test.ts +26 -0
  247. package/src/tests/skill-validate.test.ts +254 -0
  248. package/src/tests/stack-profile.test.ts +221 -0
  249. package/src/tests/string-utils.test.ts +42 -0
  250. package/src/tests/upgrade.test.ts +428 -0
  251. package/src/tests/werkstatt-lock.test.ts +343 -0
  252. package/src/tests/workspace-discovery-domain.test.ts +112 -0
  253. package/src/tests/workspace-discovery.test.ts +135 -0
  254. package/src/types.ts +221 -0
  255. package/src/utils/__tests__/fs-idempotent.test.ts +73 -0
  256. package/src/utils/__tests__/fs-trash.test.ts +45 -0
  257. package/src/utils/fs-atomic.ts +93 -0
  258. package/src/utils/fs-idempotent.ts +41 -0
  259. package/src/utils/fs-trash-sync.ts +37 -0
  260. package/src/utils/fs-trash.ts +24 -0
  261. package/src/utils/fs.ts +74 -0
  262. package/src/utils/generated-marker.ts +166 -0
  263. package/src/utils/hash.ts +19 -0
  264. package/src/utils/index.ts +29 -0
  265. package/src/utils/string-utils.ts +19 -0
  266. package/src/validators/__tests__/note-orphan-detect.test.ts +94 -0
  267. package/src/validators/note-frontmatter-validate.ts +142 -0
  268. package/src/validators/note-link-validate.ts +145 -0
  269. package/src/validators/note-orphan-detect.ts +146 -0
  270. package/src/validators/port-validate.ts +97 -0
  271. package/src/validators/skill-validate.ts +831 -0
@@ -0,0 +1,596 @@
1
+ /***************************************************************
2
+ * <MODULE_CONTRACT>
3
+ * <purpose>
4
+ * Defines types and constants for managing RFC lifecycle,
5
+ * including statuses, kinds, and scopes, facilitating
6
+ * structured proposal submissions.
7
+ * </purpose>
8
+ * * * <non-goals>
9
+ * <item>Do not implement RFC processing or validation logic here.</item>
10
+ * <item>Do not handle user input or command execution related to RFCs.</item>
11
+ * <item>Do not manage the storage or retrieval of RFC documents.</item>
12
+ * </non-goals>
13
+ * </MODULE_CONTRACT>
14
+ * * <CHANGE_SUMMARY>
15
+ <item>Tidied by compass.changesummary.tidy; see git history for prior entries.</item>
16
+ <item>RFC-0465: added specRef field to RfcFrontmatter interface and RFC_KNOWN_KEYS array for PBP spec traceability.</item>
17
+ <item>RFC-0478: added versionBump field to RfcFrontmatter interface and RFC_KNOWN_KEYS array for platform versioning enforcement.</item>
18
+ <item>RFC-0480: added breaksC field to RfcFrontmatter interface and RFC_KNOWN_KEYS array for Layer C protection.</item>
19
+ <item>RFC-0795: added dependsOn, batch fields to RfcFrontmatter and RFC_KNOWN_KEYS; added RFC-IMP-07 to RfcImplementStampRule; added batch/dependsOn to RfcListEntry.</item>
20
+ </CHANGE_SUMMARY>
21
+ ***************************************************************/
22
+
23
+ import type { Diagnostic } from "../../src/types.ts";
24
+
25
+ /**
26
+ * The lifecycle status of an RFC.
27
+ *
28
+ * Transitions:
29
+ * draft → reviewing → accepted → implemented
30
+ * ↘ rejected
31
+ * any → superseded (when a new RFC replaces this one)
32
+ *
33
+ * Only a person with role "architecture" may change status.
34
+ * Agents may only create RFCs in "draft" status.
35
+ *
36
+ * Derived decision mapping (not stored, computed when needed):
37
+ * "pending" ← draft | reviewing
38
+ * "approved" ← accepted | implemented | superseded
39
+ * "rejected" ← rejected
40
+ */
41
+ export type RfcStatus =
42
+ | "draft" // Idea formed; no decision made yet.
43
+ | "reviewing" // Under discussion; awaiting architectural decision.
44
+ | "accepted" // Decision made; implementation may begin.
45
+ | "implemented" // Normative change is live in code/docs/CLI.
46
+ | "rejected" // Consciously not accepted; reason recorded.
47
+ | "superseded"; // Historically relevant; replaced by another RFC.
48
+
49
+ export const RFC_STATUSES: readonly RfcStatus[] = [
50
+ "draft",
51
+ "reviewing",
52
+ "accepted",
53
+ "implemented",
54
+ "rejected",
55
+ "superseded",
56
+ ] as const;
57
+
58
+ /**
59
+ * The nature of the change an RFC proposes.
60
+ *
61
+ * "architecture" — introduces or modifies an architectural invariant.
62
+ * "contract" — adds or revises a page, component, semantic, brand, or quality contract.
63
+ * "command" — adds, changes, or removes a site-kernel CLI command.
64
+ * "policy" — establishes a governance, ownership, or agent-behavior rule.
65
+ * "deprecation" — officially retires a rule, command, or document.
66
+ */
67
+ export type RfcKind = "architecture" | "contract" | "command" | "policy" | "deprecation";
68
+
69
+ export const RFC_KINDS: readonly RfcKind[] = [
70
+ "architecture",
71
+ "contract",
72
+ "command",
73
+ "policy",
74
+ "deprecation",
75
+ ] as const;
76
+
77
+ /**
78
+ * Whether the RFC affects a single app or the whole workspace.
79
+ *
80
+ * "workspace" — applies to all apps and/or shared packages.
81
+ * "app" — applies to one specific app; may be promoted later.
82
+ */
83
+ export type RfcScope = "app" | "workspace";
84
+
85
+ export const RFC_SCOPES: readonly RfcScope[] = ["app", "workspace"] as const; // ─── Frontmatter ─────────────────────────────────────────────────────────────
86
+ /**
87
+ * Tracks which OS commands this RFC adds, changes, or removes.
88
+ * Used by rfc.validate to cross-check that proposed commands
89
+ * exist in the registry once status reaches "implemented".
90
+ */
91
+ export interface RfcCommands {
92
+ /** Commands this RFC intends to add. */
93
+ proposed?: string[];
94
+ /** Commands added by this RFC (populated when implemented). */
95
+ added?: string[];
96
+ /** Commands modified by this RFC (populated when implemented). */
97
+ changed?: string[];
98
+ /** Commands removed by this RFC (populated when implemented). */
99
+ removed?: string[];
100
+ }
101
+
102
+ /**
103
+ * The canonical frontmatter shape for every RFC file.
104
+ *
105
+ * RFC files live in `docs/rfcs/` and are named `RFC-XXXX-kebab-title.md`.
106
+ * The frontmatter is the machine-readable contract;
107
+ * the markdown body is the human-readable explanation.
108
+ *
109
+ * Design note: `decision` and `agentPolicy` fields from earlier proposals
110
+ * are intentionally omitted. Decision is derived from status deterministically.
111
+ * Agent policy is defined globally in AGENTS.md, not per-RFC.
112
+ */
113
+ export interface RfcFrontmatter {
114
+ /** Unique identifier. Format: RFC-XXXX (zero-padded to 4 digits). */
115
+ id: string;
116
+
117
+ /** Short imperative title. Sentence-case, no trailing period. */
118
+ title: string;
119
+
120
+ status: RfcStatus;
121
+ kind: RfcKind;
122
+ scope: RfcScope;
123
+
124
+ /** Primary owners. At least one required. Use handle strings, e.g. "architecture". */
125
+ owners: string[];
126
+
127
+ /** Optional additional reviewers. */
128
+ reviewers?: string[];
129
+
130
+ /** ISO 8601 date of creation. */
131
+ createdAt: string;
132
+
133
+ /** ISO 8601 date of last frontmatter update. */
134
+ updatedAt: string;
135
+
136
+ /** ISO 8601 date when the RFC was enhanced via fo-idea-enhance (audit findings integrated). */
137
+ enhancedAt?: string;
138
+
139
+ /** ISO 8601 date when status became "implemented". */
140
+ implementedAt?: string;
141
+
142
+ /** ISO 8601 date when status became "rejected" or "superseded". */
143
+ closedAt?: string;
144
+
145
+ /**
146
+ * IDs of RFCs this RFC supersedes.
147
+ * Those RFCs must set supersededBy to this RFC's id.
148
+ */
149
+ supersedes?: string[];
150
+
151
+ /**
152
+ * ID of the RFC that supersedes this one (if any).
153
+ * Set when this RFC is superseded.
154
+ */
155
+ supersededBy?: string;
156
+
157
+ /**
158
+ * IDs of RFCs this RFC amends — partially modifies without retiring.
159
+ * Weaker than `supersedes`: the amended RFC keeps its status.
160
+ * Those RFCs must list this RFC's id in `amendedBy`.
161
+ */
162
+ amends?: string[];
163
+
164
+ /**
165
+ * IDs of RFCs that amend this one (partial later modifications).
166
+ * Non-terminal: being amended does NOT change this RFC's status.
167
+ */
168
+ amendedBy?: string[];
169
+
170
+ /**
171
+ * Cross-references to Architecture DNA invariants, anti-patterns,
172
+ * spec documents, or other RFCs.
173
+ *
174
+ * Use identifiers like: "DNA-5", "AP-3", "RFC-0001",
175
+ * "PAGE-MANDATORY-ARTIFACTS", "COMPONENT-THREE-WAY-MIRROR"
176
+ */
177
+ related?: string[];
178
+
179
+ commands?: RfcCommands;
180
+
181
+ /** App directory names affected by this RFC. */
182
+ appsImpacted?: string[];
183
+
184
+ /** Package names affected by this RFC. */
185
+ packagesImpacted?: string[];
186
+
187
+ /**
188
+ * Observable signals that confirm this RFC is fully implemented
189
+ * and working as intended. Written as plain statements, not checklist items.
190
+ */
191
+ successSignals?: string[];
192
+
193
+ /**
194
+ * Explicit list of what this RFC does NOT cover.
195
+ * Prevents scope creep in implementation.
196
+ */
197
+ nonGoals?: string[];
198
+
199
+ /**
200
+ * RFC-0268: OPTIONAL machine-checkable acceptance probes. Executed by
201
+ * `rfc.acceptance.run`, never automatically inside `rfc.validate` (which
202
+ * must stay fast and side-effect free).
203
+ */
204
+ acceptance?: AcceptanceProbe[];
205
+
206
+ /**
207
+ * RFC-0331: DNA invariants this RFC satisfies. Each entry is a DNA-NN identifier.
208
+ * Required for RFCs created on or after RFC_METADATA_CUTOFF (V-24).
209
+ */
210
+ satisfies?: string[];
211
+
212
+ /**
213
+ * RFC-0396: Traceability to a vendored spec node.
214
+ * Format: "<spec-id>/<node-id>", e.g. "pbp-specification-package/RFC-PBP-000".
215
+ * Set by spec.materialize; optional for non-spec RFCs.
216
+ */
217
+ specRef?: string;
218
+
219
+ /**
220
+ * RFC-0478: Platform versioning enforcement. Declares the SemVer delta
221
+ * this RFC produces when implemented. Required for post-cutoff implemented
222
+ * RFCs (V-29). Values: "minor" (Breaks-B, requires migrator), "patch" (safe),
223
+ * "none" (prose-only), "major" (architectural, manually reserved).
224
+ */
225
+ versionBump?: "minor" | "patch" | "none" | "major";
226
+
227
+ /**
228
+ * RFC-0480: Declares that this RFC changes Layer C external surfaces
229
+ * (URL schema, JSON-LD types, sitemap shape). If true, the RFC must
230
+ * modify files in packages/ontology/src/external-surfaces/. Validated
231
+ * by V-30.
232
+ */
233
+ breaksC?: boolean;
234
+
235
+ /**
236
+ * RFC-0711: Declares that this RFC contributes to a living feature spec
237
+ * under docs/specs/live/<domain>.md. When true, the domain is auto-derived
238
+ * from packagesImpacted[0]. When a string, used as an explicit domain override.
239
+ * Absent or false means no living spec merge occurs.
240
+ */
241
+ liveSpec?: boolean | string;
242
+
243
+ /**
244
+ * RFC-0795: IDs of RFCs that must be `implemented` before this RFC
245
+ * can be stamped `implemented` via `rfc.implement.stamp`.
246
+ * Direct dependencies only — not transitive.
247
+ * Each entry must match ^RFC-\d{4}$ and exist in docs/rfcs/.
248
+ * Validated by V-33 (referential integrity) and RFC-IMP-07 (stamp gate).
249
+ */
250
+ dependsOn?: string[];
251
+
252
+ /**
253
+ * RFC-0795: Kebab-case slug grouping RFCs designed as a coherent set.
254
+ * Example: "engine-consolidation", "pbp-locale-fixes".
255
+ * Must match /^[a-z0-9]+(-[a-z0-9]+)*$/.
256
+ * Optional — RFCs without a batch are standalone.
257
+ * Filterable via `rfc.list --batch <slug>`.
258
+ */
259
+ batch?: string;
260
+ } // ─── RFC-0268: acceptance probes ───────────────────────────────────────────
261
+
262
+ /**
263
+ * Closed probe vocabulary (v1). `run` commands are restricted to the
264
+ * site-kernel CLI itself (string must start with "site-kernel ") — no
265
+ * arbitrary shell, keeping the probe surface auditable and platform-independent.
266
+ */
267
+ export type AcceptanceProbe =
268
+ | { probe: "run"; command: string; expect: { exitCode: number } }
269
+ | { probe: "file-exists"; path: string }
270
+ | { probe: "file-contains"; path: string; pattern: string }
271
+ | { probe: "command-registered"; name: string }
272
+ // RFC-0333: black-box expectation against the rendered site. Executed
273
+ // ONLY by qa.independent.run (needs a built dist); rfc.acceptance.run
274
+ // reports it as skipped.
275
+ | {
276
+ probe: "page";
277
+ path: string;
278
+ expectStatus?: number;
279
+ selector?: string;
280
+ textPattern?: string;
281
+ allowConsoleErrors?: boolean;
282
+ };
283
+
284
+ export interface ProbeResult {
285
+ probe: AcceptanceProbe;
286
+ ok: boolean;
287
+ /** Actual exit code / resolution info. */
288
+ detail: string;
289
+ }
290
+
291
+ export interface RfcAcceptanceRunResult {
292
+ command: "rfc.acceptance.run";
293
+ status: "pass" | "fail";
294
+ diagnostics: Diagnostic[];
295
+ results: Array<{ rfcId: string; probeResults: ProbeResult[] }>;
296
+ } // ─── RFC-0330: verification evidence ─────────────────────────────────────────
297
+ export interface VerificationEvidenceProbeRecord {
298
+ probe: AcceptanceProbe;
299
+ ok: boolean;
300
+ detail: string;
301
+ durationMs: number;
302
+ }
303
+
304
+ export interface VerificationEvidence {
305
+ rfcId: string;
306
+ title: string;
307
+ rfcStatus: RfcStatus;
308
+ emittedAt: string;
309
+ commit: string;
310
+ workingTreeDirty: boolean;
311
+ kernelVersion: string;
312
+ rfcFileHash: string;
313
+ acceptanceHash: string;
314
+ probes: VerificationEvidenceProbeRecord[];
315
+ overall: "pass" | "fail";
316
+ filesModified?: string[];
317
+ }
318
+
319
+ export interface RfcVerificationEmitResult {
320
+ command: "rfc.verification.emit";
321
+ status: "pass" | "fail";
322
+ emitted: Array<{ rfcId: string; file: string; overall: "pass" | "fail" }>;
323
+ skipped: Array<{ rfcId: string; reason: "no-probes" }>;
324
+ diagnostics: Diagnostic[];
325
+ } // ─── Validation ──────────────────────────────────────────────────────────────
326
+ export interface RfcValidationViolation {
327
+ rfcId: string;
328
+ file: string;
329
+ rule: string;
330
+ message: string;
331
+ severity: "error" | "warning";
332
+ }
333
+
334
+ export interface Marker {
335
+ line: number;
336
+ text: string;
337
+ severity: "warn" | "error";
338
+ }
339
+
340
+ export interface RfcValidationResult {
341
+ command: "rfc.validate";
342
+ status: "pass" | "fail";
343
+ count: number;
344
+ violations: RfcValidationViolation[];
345
+ markers?: Marker[];
346
+ } // ─── Command results ─────────────────────────────────────────────────────────
347
+
348
+ export interface RfcCommandLifecycleDiagnosticData {
349
+ rfcId: string;
350
+ command: string;
351
+ status: RfcStatus;
352
+ bucket: "proposed" | "added" | "changed" | "removed";
353
+ }
354
+
355
+ export interface RfcCommandLifecycleViolation {
356
+ rfcId: string;
357
+ file: string;
358
+ rule: "RFC-CMD-01" | "RFC-CMD-02" | "RFC-CMD-03" | "RFC-CMD-04" | "RFC-CMD-05";
359
+ message: string;
360
+ severity: "error" | "warning";
361
+ data: RfcCommandLifecycleDiagnosticData;
362
+ }
363
+
364
+ export interface RfcCommandLifecycleValidationResult {
365
+ command: "rfc.command-lifecycle.validate";
366
+ status: "pass" | "fail";
367
+ count: number;
368
+ violations: RfcCommandLifecycleViolation[];
369
+ }
370
+
371
+ /** Compact RFC summary for list output. */
372
+ export interface RfcListEntry {
373
+ id: string;
374
+ title: string;
375
+ status: RfcStatus;
376
+ kind: RfcKind;
377
+ scope: RfcScope;
378
+ owners: string[];
379
+ createdAt: string;
380
+ updatedAt: string;
381
+ file: string;
382
+ /** RFC-0795: batch slug if this RFC belongs to a coherent set. */
383
+ batch?: string;
384
+ /** RFC-0795: direct dependency RFC IDs that must be implemented first. */
385
+ dependsOn?: string[];
386
+ }
387
+
388
+ export interface RfcListResult {
389
+ command: "rfc.list";
390
+ status: "ok";
391
+ count: number;
392
+ entries: RfcListEntry[];
393
+ }
394
+
395
+ export interface RfcCreateResult {
396
+ command: "rfc.create";
397
+ status: "ok";
398
+ file: string;
399
+ id: string;
400
+ satisfies?: string[];
401
+ /** RFC-0329: prior decisions consulted at creation time. */
402
+ consultedDecisions?: ConsultedDecision[];
403
+ }
404
+
405
+ export interface RfcNextIdResult {
406
+ command: "rfc.next-id";
407
+ nextId: string;
408
+ nextNumber: number;
409
+ maxExistingId: string;
410
+ scannedFiles: number;
411
+ } // ─── RFC-0329: decision log ──────────────────────────────────────────────────
412
+ export type DecisionLogEntryKind = "rejected-rfc" | "superseded-rfc" | "rejected-alternative";
413
+
414
+ export interface DecisionLogEntry {
415
+ kind: DecisionLogEntryKind;
416
+ rfcId: string;
417
+ title: string;
418
+ status: RfcStatus;
419
+ closedAt?: string;
420
+ supersededBy?: string;
421
+ decisionSummary?: string;
422
+ alternativesText?: string;
423
+ file: string;
424
+ }
425
+
426
+ export interface DecisionLogResult {
427
+ command: "rfc.decision-log.generate";
428
+ status: "ok" | "drift";
429
+ count: number;
430
+ entries: DecisionLogEntry[];
431
+ written?: string[];
432
+ }
433
+
434
+ export interface ConsultedDecision {
435
+ rfcId: string;
436
+ kind: DecisionLogEntryKind;
437
+ title: string;
438
+ score: number;
439
+ file: string;
440
+ } // ─── RFC-0334: supersede propose ─────────────────────────────────────────────
441
+ export interface RfcSupersedeProposeResult {
442
+ command: "rfc.supersede.propose";
443
+ status: "ok";
444
+ file: string;
445
+ id: string;
446
+ supersedesTarget: string;
447
+ invariants: string[];
448
+ consultedDecisions: ConsultedDecision[];
449
+ }
450
+
451
+ export interface RfcCheckViolation {
452
+ rfcId: string;
453
+ file: string;
454
+ kind: "missing-file" | "missing-feature-flag";
455
+ /** The artifact path or flag key that is missing. */
456
+ artifact: string;
457
+ message: string;
458
+ }
459
+
460
+ export interface RfcCheckResult {
461
+ command: "rfc.check";
462
+ status: "pass" | "fail";
463
+ checkedRfcs: number;
464
+ violations: RfcCheckViolation[];
465
+ }
466
+
467
+ /** One entry in the rfc.index.generate relationship index. */
468
+ export interface RfcIndexEntry {
469
+ id: string;
470
+ title: string;
471
+ status: RfcStatus;
472
+ kind: RfcKind;
473
+ createdAt: string;
474
+ implementedAt: string;
475
+ closedAt: string;
476
+ supersedes: string[];
477
+ supersededBy: string;
478
+ amends: string[];
479
+ amendedBy: string[];
480
+ related: string[];
481
+ file: string;
482
+ }
483
+
484
+ export interface RfcIndexResult {
485
+ command: "rfc.index.generate";
486
+ status: "ok";
487
+ count: number;
488
+ entries: RfcIndexEntry[];
489
+ /** Path written, if --write was passed. */
490
+ written?: string;
491
+ }
492
+
493
+ export interface RfcGraphResult {
494
+ command: "rfc.graph";
495
+ status: "ok";
496
+ id: string;
497
+ supersedes: string[];
498
+ supersededBy: string;
499
+ amends: string[];
500
+ amendedBy: string[];
501
+ related: string[];
502
+ } // ─── RFC-0476: rfc.implement.stamp ──────────────────────────────────────────
503
+ export interface RfcImplementStampData {
504
+ rfcId: string;
505
+ implementationCommit: string;
506
+ stampedAt: string;
507
+ criteriaChecked: number;
508
+ evidencePath?: string;
509
+ }
510
+
511
+ export type RfcImplementStampRule =
512
+ | "RFC-IMP-01"
513
+ | "RFC-IMP-02"
514
+ | "RFC-IMP-03"
515
+ | "RFC-IMP-04"
516
+ | "RFC-IMP-05"
517
+ | "RFC-IMP-06"
518
+ | "RFC-IMP-07";
519
+
520
+ export interface RfcImplementStampViolation {
521
+ rule: RfcImplementStampRule;
522
+ message: string;
523
+ }
524
+
525
+ export interface RfcImplementStampResult {
526
+ command: "rfc.implement.stamp";
527
+ status: "pass" | "fail";
528
+ data?: RfcImplementStampData;
529
+ violations: RfcImplementStampViolation[];
530
+ } // ─── Constants ───────────────────────────────────────────────────────────────
531
+ export const RFC_DIR = "docs/rfcs";
532
+ export const RFC_TEMPLATE_FILE = "docs/rfcs/rfc-0000-template.md";
533
+ export const RFC_TEMPLATE_FALLBACK_FILE = "os/rfc/rfc-0000-template.md";
534
+ export const RFC_ID_PATTERN = /^RFC-\d{4}$/;
535
+
536
+ /** Required H2 sections for every RFC. */
537
+ export const RFC_FULL_REQUIRED_SECTIONS = [
538
+ "Context",
539
+ "Problem",
540
+ "Decision",
541
+ "Architectural fit",
542
+ "Design",
543
+ "Rollout",
544
+ "Alternatives considered",
545
+ "Risks",
546
+ "Acceptance criteria",
547
+ "Implementation notes for agents",
548
+ ] as const;
549
+
550
+ /** Every frontmatter key the RFC schema sanctions. V-20 warns on anything else. */
551
+ export const RFC_KNOWN_KEYS: readonly string[] = [
552
+ "id",
553
+ "title",
554
+ "status",
555
+ "kind",
556
+ "scope",
557
+ "owners",
558
+ "reviewers",
559
+ "createdAt",
560
+ "updatedAt",
561
+ "enhancedAt",
562
+ "implementedAt",
563
+ "closedAt",
564
+ "supersedes",
565
+ "supersededBy",
566
+ "amends",
567
+ "amendedBy",
568
+ "related",
569
+ "commands",
570
+ "appsImpacted",
571
+ "packagesImpacted",
572
+ "successSignals",
573
+ "nonGoals",
574
+ "acceptance",
575
+ "satisfies",
576
+ "specRef",
577
+ "versionBump",
578
+ "breaksC",
579
+ "liveSpec",
580
+ "dependsOn",
581
+ "batch",
582
+ ] as const;
583
+
584
+ /**
585
+ * RFC-0330 / RFC-0331 / RFC-0335: shared cutoff date for new metadata rules.
586
+ * RFCs created on or after this date are subject to V-23 (evidence), V-24 (DNA-trace),
587
+ * and V-25 (reviewer identity). RFCs created before are exempt.
588
+ */
589
+ export const RFC_METADATA_CUTOFF = "2026-07-07";
590
+
591
+ /**
592
+ * RFC-0478: cutoff date for versionBump enforcement (V-29).
593
+ * RFCs created on or after this date with status "implemented" must declare
594
+ * a versionBump field. RFCs created before are exempt.
595
+ */
596
+ export const RFC_VERSION_BUMP_CUTOFF = "2026-07-21";