aw-spec-cli 0.1.3 → 0.1.5

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 (230) hide show
  1. package/README.md +291 -0
  2. package/assets/.agents/agent.json +28 -0
  3. package/assets/.agents/skills/aw-spec-orch/SKILL.md +56 -0
  4. package/assets/.agents/skills/aw-spec-orch-demo/SKILL.md +59 -0
  5. package/assets/.aw-spec/DESIGN-FORMAT.md +151 -0
  6. package/assets/.aw-spec/ORCH-DIALECT.md +156 -0
  7. package/assets/.aw-spec/RULE-PARTITION.md +126 -0
  8. package/assets/.aw-spec/extensions/agent-context/extension.yml +12 -9
  9. package/assets/.aw-spec/extensions.yml +12 -19
  10. package/assets/.aw-spec/integrations/aw-spec.manifest.json +1 -9
  11. package/assets/.aw-spec/interpreter/run-skill.py +1158 -0
  12. package/assets/.aw-spec/orchestrator/AGENT-PROFILE.md +94 -0
  13. package/assets/.aw-spec/orchestrator/README.md +300 -0
  14. package/assets/.aw-spec/orchestrator/adapters/claude_agent_sdk.py +74 -0
  15. package/assets/.aw-spec/orchestrator/adapters/google_antigravity.py +74 -0
  16. package/assets/.aw-spec/orchestrator/modules/delta-design.orch.yaml +105 -0
  17. package/assets/.aw-spec/orchestrator/modules/delta-spec.orch.yaml +79 -0
  18. package/assets/.aw-spec/orchestrator/modules/domain-select.orch.yaml +81 -0
  19. package/assets/.aw-spec/orchestrator/modules/tech-select.orch.yaml +75 -0
  20. package/assets/.aw-spec/orchestrator/orchestrator.py +1721 -0
  21. package/assets/.aw-spec/orchestrator/rev-templates/ai-rules.reference.md +40 -0
  22. package/assets/.aw-spec/orchestrator/rev-templates/comandrulemap.skeleton.md +59 -0
  23. package/assets/.aw-spec/orchestrator/rev-templates/commandtechrulemap.skeleton.md +97 -0
  24. package/assets/.aw-spec/orchestrator/rev-templates/domain-constitution.skeleton.md +61 -0
  25. package/assets/.aw-spec/orchestrator/rev-templates/domain-requirements.skeleton.md +48 -0
  26. package/assets/.aw-spec/orchestrator/rev-templates/domain-rule-file.skeleton.md +39 -0
  27. package/assets/.aw-spec/orchestrator/rev-templates/technical-constitution.skeleton.md +106 -0
  28. package/assets/.aw-spec/orchestrator/rev-templates/technical-rule-file.skeleton.md +54 -0
  29. package/assets/.aw-spec/orchestrator/workflows/_smoke.orch.yaml +160 -0
  30. package/assets/.aw-spec/orchestrator/workflows/aw-spec-add-component.orch.yaml +244 -0
  31. package/assets/.aw-spec/orchestrator/workflows/aw-spec-adopt.orch.yaml +775 -0
  32. package/assets/.aw-spec/orchestrator/workflows/aw-spec-analyze-delta-design.orch.yaml +248 -0
  33. package/assets/.aw-spec/orchestrator/workflows/aw-spec-analyze-design.orch.yaml +261 -0
  34. package/assets/.aw-spec/orchestrator/workflows/aw-spec-analyze-slice.orch.yaml +425 -0
  35. package/assets/.aw-spec/orchestrator/workflows/aw-spec-build.orch.yaml +188 -0
  36. package/assets/.aw-spec/orchestrator/workflows/aw-spec-characterize.orch.yaml +474 -0
  37. package/assets/.aw-spec/orchestrator/workflows/aw-spec-close-delta.orch.yaml +181 -0
  38. package/assets/.aw-spec/orchestrator/workflows/aw-spec-constitution.orch.yaml +284 -0
  39. package/assets/.aw-spec/orchestrator/workflows/aw-spec-demo.orch.yaml +103 -0
  40. package/assets/.aw-spec/orchestrator/workflows/aw-spec-dependency-tree.orch.yaml +69 -0
  41. package/assets/.aw-spec/orchestrator/workflows/aw-spec-deploy.orch.yaml +85 -0
  42. package/assets/.aw-spec/orchestrator/workflows/aw-spec-design.orch.yaml +382 -0
  43. package/assets/.aw-spec/orchestrator/workflows/aw-spec-finalize-delta.orch.yaml +382 -0
  44. package/assets/.aw-spec/orchestrator/workflows/aw-spec-foundation.orch.yaml +246 -0
  45. package/assets/.aw-spec/orchestrator/workflows/aw-spec-implement-delta.orch.yaml +231 -0
  46. package/assets/.aw-spec/orchestrator/workflows/aw-spec-implement.orch.yaml +258 -0
  47. package/assets/.aw-spec/orchestrator/workflows/aw-spec-inventory.orch.yaml +236 -0
  48. package/assets/.aw-spec/orchestrator/workflows/aw-spec-onboard.orch.yaml +949 -0
  49. package/assets/.aw-spec/orchestrator/workflows/aw-spec-parity.orch.yaml +293 -0
  50. package/assets/.aw-spec/orchestrator/workflows/aw-spec-run.orch.yaml +177 -0
  51. package/assets/.aw-spec/orchestrator/workflows/aw-spec-select-domain.orch.yaml +79 -0
  52. package/assets/.aw-spec/orchestrator/workflows/aw-spec-select-feature.orch.yaml +128 -0
  53. package/assets/.aw-spec/orchestrator/workflows/aw-spec-specify.orch.yaml +412 -0
  54. package/assets/.aw-spec/scripts/bash/aw-inventory.sh +14 -0
  55. package/assets/.aw-spec/scripts/bash/aw-parity.sh +13 -0
  56. package/assets/.aw-spec/scripts/bash/aw-rev-constitution.sh +13 -0
  57. package/assets/.aw-spec/scripts/bash/aw-spec-actions.sh +1899 -0
  58. package/assets/.aw-spec/scripts/bash/aw-xref.sh +15 -0
  59. package/assets/.aw-spec/scripts/bash/common.sh +11 -60
  60. package/assets/.aw-spec/scripts/powershell/aw-inventory.ps1 +14 -0
  61. package/assets/.aw-spec/scripts/powershell/aw-parity.ps1 +13 -0
  62. package/assets/.aw-spec/scripts/powershell/aw-rev-constitution.ps1 +13 -0
  63. package/assets/.aw-spec/scripts/powershell/aw-spec-actions.ps1 +1563 -0
  64. package/assets/.aw-spec/scripts/powershell/aw-xref.ps1 +15 -0
  65. package/assets/.aw-spec/scripts/python/aw-inventory.py +683 -0
  66. package/assets/.aw-spec/scripts/python/aw-parity.py +380 -0
  67. package/assets/.aw-spec/scripts/python/aw-rev-constitution.py +312 -0
  68. package/assets/.aw-spec/scripts/python/aw-xref.py +1330 -0
  69. package/assets/.aw-spec/scripts/python/validate_okf.py +349 -0
  70. package/assets/.aw-spec/templates/constitution-domain-template.md +75 -0
  71. package/assets/.aw-spec/templates/constitution-technical-template.md +70 -0
  72. package/assets/.aw-spec/templates/delta-design-template.md +69 -0
  73. package/assets/.aw-spec/templates/delta-spec-template.md +60 -0
  74. package/assets/.aw-spec/templates/design-template.md +383 -0
  75. package/assets/.aw-spec/templates/okf-concept-template.md +103 -0
  76. package/assets/.aw-spec/templates/parity-manifest-template.json +49 -0
  77. package/assets/.aw-spec/templates/source-map-template.md +85 -0
  78. package/assets/.aw-spec/templates/spec-template.md +192 -71
  79. package/assets/.claude/agent.json +27 -0
  80. package/assets/.claude/skills/aw-spec-orch/SKILL.md +55 -0
  81. package/assets/.claude/skills/aw-spec-orch-demo/SKILL.md +59 -0
  82. package/assets/.kilocode/agent.json +28 -0
  83. package/assets/.kilocode/workflows/aw-spec-orch-demo.md +59 -0
  84. package/assets/.kilocode/workflows/aw-spec-orch.md +55 -0
  85. package/assets/docs/architecture/clean-architecture.md +1 -1
  86. package/assets/docs/architecture/cqrs.md +1 -1
  87. package/assets/docs/architecture/eventing.md +1 -1
  88. package/assets/docs/architecture/folder-structure.md +1 -1
  89. package/assets/docs/architecture/modular-monolith.md +1 -1
  90. package/assets/docs/architecture/persistence.md +1 -1
  91. package/assets/docs/architecture/testing.md +1 -1
  92. package/assets/docs/architecture/vertical-slices.md +1 -1
  93. package/assets/docs/components/Email/README.md +1 -1
  94. package/assets/docs/components/Jobs/README.md +1 -1
  95. package/assets/docs/components/QrGenerator/README.md +1 -1
  96. package/assets/docs/components/README.md +1 -1
  97. package/assets/docs/domain/domain-driven-design.md +1 -1
  98. package/assets/docs/domainspecs/healthcare/api-versioning.domain.md +1 -1
  99. package/assets/docs/domainspecs/healthcare/auditing.domain.md +86 -18
  100. package/assets/docs/domainspecs/healthcare/authorization.domain.md +1 -1
  101. package/assets/docs/domainspecs/healthcare/clinical-terms.md +1 -1
  102. package/assets/docs/domainspecs/healthcare/coding-standards.domain.md +1 -1
  103. package/assets/docs/domainspecs/healthcare/comandrulemap.md +58 -124
  104. package/assets/docs/domainspecs/healthcare/commandtechrulemap.md +119 -0
  105. package/assets/docs/domainspecs/healthcare/consent.md +1 -1
  106. package/assets/docs/domainspecs/healthcare/cqrs.domain.md +1 -1
  107. package/assets/docs/domainspecs/healthcare/data-classification.domain.md +1 -1
  108. package/assets/docs/domainspecs/healthcare/dependency-policy.domain.md +1 -1
  109. package/assets/docs/domainspecs/healthcare/dicom.md +1 -1
  110. package/assets/docs/domainspecs/healthcare/domain-driven-design.domain.md +1 -1
  111. package/assets/docs/domainspecs/healthcare/eventing.domain.md +1 -1
  112. package/assets/docs/domainspecs/healthcare/fhir.md +1 -1
  113. package/assets/docs/domainspecs/healthcare/folder-structure.domain.md +1 -1
  114. package/assets/docs/domainspecs/healthcare/hipaa.md +1 -1
  115. package/assets/docs/domainspecs/healthcare/hl7.md +1 -1
  116. package/assets/docs/domainspecs/healthcare/integration-terms.md +1 -1
  117. package/assets/docs/domainspecs/healthcare/persistence.domain.md +1 -1
  118. package/assets/docs/domainspecs/healthcare/terminology.md +1 -1
  119. package/assets/docs/domainspecs/healthcare/testing.domain.md +1 -1
  120. package/assets/docs/domainspecs/healthcare/vertical-slices.domain.md +1 -1
  121. package/assets/docs/domainspecs/healthcare/zero-trust.domain.md +1 -1
  122. package/assets/docs/domainspecs/pharma/api-versioning.domain.md +1 -1
  123. package/assets/docs/domainspecs/pharma/atc.md +1 -1
  124. package/assets/docs/domainspecs/pharma/auditing.domain.md +80 -16
  125. package/assets/docs/domainspecs/pharma/authorization.domain.md +1 -1
  126. package/assets/docs/domainspecs/pharma/coding-standards.domain.md +1 -1
  127. package/assets/docs/domainspecs/pharma/comandrulemap.md +64 -142
  128. package/assets/docs/domainspecs/pharma/commandtechrulemap.md +119 -0
  129. package/assets/docs/domainspecs/pharma/cqrs.domain.md +1 -1
  130. package/assets/docs/domainspecs/pharma/data-classification.domain.md +1 -1
  131. package/assets/docs/domainspecs/pharma/data-provenance.md +1 -1
  132. package/assets/docs/domainspecs/pharma/dependency-policy.domain.md +1 -1
  133. package/assets/docs/domainspecs/pharma/domain-driven-design.domain.md +1 -1
  134. package/assets/docs/domainspecs/pharma/eventing.domain.md +1 -1
  135. package/assets/docs/domainspecs/pharma/fhir.md +1 -1
  136. package/assets/docs/domainspecs/pharma/folder-structure.domain.md +1 -1
  137. package/assets/docs/domainspecs/pharma/hl7.md +1 -1
  138. package/assets/docs/domainspecs/pharma/idmp.md +1 -1
  139. package/assets/docs/domainspecs/pharma/integration-terms.md +1 -1
  140. package/assets/docs/domainspecs/pharma/ndc.md +1 -1
  141. package/assets/docs/domainspecs/pharma/persistence.domain.md +1 -1
  142. package/assets/docs/domainspecs/pharma/pharma-terms.md +1 -1
  143. package/assets/docs/domainspecs/pharma/product-lifecycle.domain.md +1 -1
  144. package/assets/docs/domainspecs/pharma/regulatory-compliance.md +1 -1
  145. package/assets/docs/domainspecs/pharma/terminology.md +1 -1
  146. package/assets/docs/domainspecs/pharma/testing.domain.md +1 -1
  147. package/assets/docs/domainspecs/pharma/vertical-slices.domain.md +1 -1
  148. package/assets/docs/domainspecs/pharma/zero-trust.domain.md +1 -1
  149. package/assets/docs/governance/api-versioning.md +1 -1
  150. package/assets/docs/governance/coding-standards.md +1 -1
  151. package/assets/docs/governance/dependency-policy.md +1 -1
  152. package/assets/docs/requirement-spec.txt +13 -1
  153. package/assets/docs/security/auditing.md +54 -11
  154. package/assets/docs/security/authorization.md +1 -1
  155. package/assets/docs/security/data-classification.md +1 -1
  156. package/assets/docs/security/zero-trust.md +1 -1
  157. package/dist/commands/update.d.ts +3 -0
  158. package/dist/commands/update.d.ts.map +1 -0
  159. package/dist/commands/update.js +142 -0
  160. package/dist/commands/update.js.map +1 -0
  161. package/dist/utils/manifest.d.ts +31 -0
  162. package/dist/utils/manifest.d.ts.map +1 -0
  163. package/dist/utils/manifest.js +91 -0
  164. package/dist/utils/manifest.js.map +1 -0
  165. package/dist/utils/paths.js +2 -2
  166. package/dist/utils/paths.js.map +1 -1
  167. package/dist/utils/update-engine.d.ts +52 -0
  168. package/dist/utils/update-engine.d.ts.map +1 -0
  169. package/dist/utils/update-engine.js +203 -0
  170. package/dist/utils/update-engine.js.map +1 -0
  171. package/package.json +1 -1
  172. package/assets/.agents/skills/aw-spec-addcomponent/SKILL.md +0 -129
  173. package/assets/.agents/skills/aw-spec-agent-context-update/SKILL.md +0 -31
  174. package/assets/.agents/skills/aw-spec-analyze/SKILL.md +0 -296
  175. package/assets/.agents/skills/aw-spec-checklist/SKILL.md +0 -374
  176. package/assets/.agents/skills/aw-spec-clarify/SKILL.md +0 -320
  177. package/assets/.agents/skills/aw-spec-constitution/SKILL.md +0 -194
  178. package/assets/.agents/skills/aw-spec-fast-implement/SKILL.md +0 -268
  179. package/assets/.agents/skills/aw-spec-foundation/SKILL.md +0 -358
  180. package/assets/.agents/skills/aw-spec-implement/SKILL.md +0 -279
  181. package/assets/.agents/skills/aw-spec-minimal-implementation/SKILL.md +0 -209
  182. package/assets/.agents/skills/aw-spec-plan/SKILL.md +0 -221
  183. package/assets/.agents/skills/aw-spec-select-domain/SKILL.md +0 -73
  184. package/assets/.agents/skills/aw-spec-specify/SKILL.md +0 -382
  185. package/assets/.agents/skills/aw-spec-tasks/SKILL.md +0 -259
  186. package/assets/.agents/skills/aw-spec-taskstoissues/SKILL.md +0 -107
  187. package/assets/.aw-spec/integrations/claude.manifest.json +0 -17
  188. package/assets/.aw-spec/scripts/bash/check-prerequisites.sh +0 -189
  189. package/assets/.aw-spec/scripts/bash/create-new-feature.sh +0 -299
  190. package/assets/.aw-spec/scripts/bash/setup-plan.sh +0 -84
  191. package/assets/.aw-spec/scripts/bash/setup-tasks.sh +0 -91
  192. package/assets/.aw-spec/templates/checklist-template.md +0 -40
  193. package/assets/.aw-spec/templates/constitution-template.md +0 -57
  194. package/assets/.aw-spec/templates/plan-template.md +0 -113
  195. package/assets/.aw-spec/templates/tasks-template.md +0 -252
  196. package/assets/.aw-spec/workflows/aw-spec/workflow.yml +0 -77
  197. package/assets/.aw-spec/workflows/workflow-registry.json +0 -13
  198. package/assets/.claude/skills/aw-spec-addcomponent/SKILL.md +0 -129
  199. package/assets/.claude/skills/aw-spec-agent-context-update/SKILL.md +0 -31
  200. package/assets/.claude/skills/aw-spec-analyze/SKILL.md +0 -296
  201. package/assets/.claude/skills/aw-spec-checklist/SKILL.md +0 -374
  202. package/assets/.claude/skills/aw-spec-clarify/SKILL.md +0 -320
  203. package/assets/.claude/skills/aw-spec-constitution/SKILL.md +0 -194
  204. package/assets/.claude/skills/aw-spec-fast-implement/SKILL.md +0 -268
  205. package/assets/.claude/skills/aw-spec-foundation/SKILL.md +0 -358
  206. package/assets/.claude/skills/aw-spec-implement/SKILL.md +0 -279
  207. package/assets/.claude/skills/aw-spec-minimal-implementation/SKILL.md +0 -209
  208. package/assets/.claude/skills/aw-spec-plan/SKILL.md +0 -221
  209. package/assets/.claude/skills/aw-spec-select-domain/SKILL.md +0 -73
  210. package/assets/.claude/skills/aw-spec-specify/SKILL.md +0 -382
  211. package/assets/.claude/skills/aw-spec-tasks/SKILL.md +0 -259
  212. package/assets/.claude/skills/aw-spec-taskstoissues/SKILL.md +0 -107
  213. package/assets/.kilocode/rules/specify-rules.md +0 -4
  214. package/assets/.kilocode/workflows/aw-spec-addcomponent.md +0 -129
  215. package/assets/.kilocode/workflows/aw-spec-agent-context.update.md +0 -31
  216. package/assets/.kilocode/workflows/aw-spec-analyze.md +0 -296
  217. package/assets/.kilocode/workflows/aw-spec-checklist.md +0 -374
  218. package/assets/.kilocode/workflows/aw-spec-clarify.md +0 -320
  219. package/assets/.kilocode/workflows/aw-spec-constitution.md +0 -194
  220. package/assets/.kilocode/workflows/aw-spec-fast-implement.md +0 -263
  221. package/assets/.kilocode/workflows/aw-spec-foundation.md +0 -358
  222. package/assets/.kilocode/workflows/aw-spec-implement.md +0 -279
  223. package/assets/.kilocode/workflows/aw-spec-minimal-implementation.md +0 -204
  224. package/assets/.kilocode/workflows/aw-spec-plan.md +0 -221
  225. package/assets/.kilocode/workflows/aw-spec-select-domain.md +0 -73
  226. package/assets/.kilocode/workflows/aw-spec-specify.md +0 -382
  227. package/assets/.kilocode/workflows/aw-spec-tasks.md +0 -259
  228. package/assets/.kilocode/workflows/aw-spec-taskstoissues.md +0 -107
  229. package/assets/docs/command.txt +0 -295
  230. package/assets/docs/pharma-constitution.my-ref.md +0 -86
@@ -0,0 +1,949 @@
1
+ # =============================================================================
2
+ # aw-spec-onboard (orchestrator) — the entry step of the Brownfield DEVELOPMENT flow
3
+ #
4
+ # Onboard an EXISTING codebase into aw-spec so it can be DEVELOPED (evolved, not
5
+ # migrated) governed exactly like greenfield and as lightly as OpenSpec. Runs ONCE
6
+ # per repo, over the WHOLE codebase (project-level, not per-slice). It does two
7
+ # things, both from a single deterministic whole-repo scan — no slice is adopted yet:
8
+ #
9
+ # 1. FEATURE MAP — a HIGH-LEVEL OKF discovery index of the features/aggregates the
10
+ # code contains (folders/concepts + a bounded-context map + the tech stack). It
11
+ # is a shallow map to pick from, NOT a deep reverse — the deep per-feature
12
+ # reverse (spec.md + design.md) is /aw-spec-orch adopt, done just-in-time when
13
+ # you are about to develop that feature.
14
+ #
15
+ # 2. GOVERNANCE SCAFFOLD — the PROJECT-level governing tier, established once from
16
+ # the whole-repo vantage so forward development is consistent from the first
17
+ # change: the split constitution (technical + domain), the docs/domainspecs/
18
+ # brf-<domain>/ rule-file pack (+ comandrulemap), the domain-constitution
19
+ # source, and the activated domain. Because nothing is adopted yet, this tier is
20
+ # a PROVISIONAL scaffold evidenced by the SCAN (project identity + bounded-context
21
+ # map are firm; principles/rules are marked provisional). adopt then RECONCILES
22
+ # each with the slice's own evidence (BR-/CN-/DC-/IC- ids) when that feature is
23
+ # developed — the "created here, updated when taking each slice" contract.
24
+ #
25
+ # ONBOARD → adopt <Feature> (JIT) → specify → design → analyze-delta-design → implement-delta → build → finalize-delta → analyze-slice → close-delta ← you are here
26
+ #
27
+ # Establishing the PROJECT-scoped constitution here (whole-repo vantage) — not from a
28
+ # single adopted slice — is deliberate: it keeps governance project-scoped from day
29
+ # one and stops a first-adopted feature from biasing it (adopt only ADDS evidence).
30
+ #
31
+ # This is the DEVELOPMENT flow — there is NO migration content: no migration backlog,
32
+ # no seams/adopt-order, no strangler, no parity, no cutover. Modernization/migration
33
+ # is a separate, later phase. Reuses proven machinery unchanged (the scan, the
34
+ # constitution scripts, the neutral rev-templates skeletons); the new agent PROMPTS read
35
+ # the SCAN + representative SOURCE, not adopted docs. It also REVERSE-ENGINEERS the repo's
36
+ # own technical structure into a project-specific design + delta-design template pair
37
+ # (installed as the project template overrides), so forward development follows the
38
+ # as-built architecture, not the greenfield four-layer layout.
39
+ #
40
+ # CODE-DERIVED RULE PACKS + MAPS (both tiers): onboard authors, from the code ALONE
41
+ # (never a greenfield rule file), BOTH the DOMAIN rule-file pack (*.domain.md +
42
+ # comandrulemap.md) AND the TECHNICAL rule-file pack (docs/domainspecs/brf-<domain>/tech/*.md
43
+ # + commandtechrulemap.md), then WIRES each per-workflow. This is what makes the WHOLE
44
+ # forward pipeline AND adopt govern against THIS codebase's rules — resolve-domain /
45
+ # resolve-tech read the activated brf-<domain>'s maps, so no workflow ever falls back to a
46
+ # greenfield docs/architecture / docs/security file. Both packs are evidenced-only (a rule
47
+ # is written only for a concern the code exhibits) and may be seeded with an optional list
48
+ # of concerns to look for (onboard still DECIDES presence + implementation from the code).
49
+ # The technical pack carries ONE file for /specify — tech/domain-modelling.md, the AS-BUILT
50
+ # modelling METHODOLOGY (how this code expresses a domain model: what marks an aggregate
51
+ # root, entity vs value object, where invariants live, the context boundary). It is the
52
+ # code-derived analog of greenfield's docs/domain/domain-driven-design.md, and the only
53
+ # thing this tier is ever allowed to put under `## /aw-spec-specify`. WHAT the model is
54
+ # stays in the domain pack (domain-driven-design.domain.md); HOW to model lives here.
55
+ #
56
+ # Never modifies source — every write lands in the OKF bundle, the specs governance dir,
57
+ # docs/domainspecs/ (domain pack + tech/ pack + both maps), or the
58
+ # .aw-spec/templates/overrides/ design templates.
59
+ #
60
+ # Launch: /aw-spec-orch onboard [domain-name / scope hint] [; concerns: a, b, c]
61
+ # e.g. /aw-spec-orch onboard Pharma
62
+ # e.g. /aw-spec-orch onboard "Pharma; concerns: auditing, concurrency, authorization"
63
+ # =============================================================================
64
+
65
+ name: aw-spec-onboard
66
+ description: Onboard an existing codebase for brownfield DEVELOPMENT — a deterministic whole-repo scan produces a high-level OKF feature map (folders/concepts) PLUS the project-level governance scaffold (split constitution + docs/domainspecs/brf-<domain>/ DOMAIN rule-file pack + comandrulemap + a code-derived TECHNICAL rule-file pack at brf-<domain>/tech/ + commandtechrulemap + activated domain), all provisional-from-scan and refined per slice by adopt. Both rule tiers are reverse-engineered from the CODE alone (never a greenfield rule file), evidenced-only, and WIRED per-workflow so the whole forward pipeline AND adopt govern against THIS codebase — never a greenfield fallback. It also reverse-engineers the repo's own technical structure into a project-specific design + delta-design template pair, installed as the project template overrides. Accepts an optional concerns list to look for (onboard decides which are actually present). No migration content; never modifies source.
67
+ version: 1.3.0
68
+ agent_agnostic: true
69
+ dialect: aw-spec.orchestrator/v1
70
+
71
+ inputs:
72
+ user_input:
73
+ description: >-
74
+ Optional free-text hint. May carry (a) a domain name for the governance pack
75
+ (e.g. Pharma → docs/domainspecs/brf-pharma/); (b) a scope/focus hint for the
76
+ feature map; and/or (c) a CONCERNS LIST to look for, as a "concerns: a, b, c"
77
+ clause (e.g. "Pharma; concerns: auditing, concurrency, authorization"). The
78
+ concerns are a SEARCH HINT only — both rule-pack authors still DECIDE which
79
+ concerns are actually present from the code, and are never limited to the list.
80
+ When omitted, the domain defaults to the PROJECT name from the OKF overview,
81
+ then the repo basename; concerns are auto-discovered from the code.
82
+ required: false
83
+ bind: USER_INPUT
84
+
85
+ scripts:
86
+ inventory:
87
+ sh: .aw-spec/scripts/bash/aw-inventory.sh
88
+ ps1: .aw-spec/scripts/powershell/aw-inventory.ps1
89
+ revcon:
90
+ sh: .aw-spec/scripts/bash/aw-rev-constitution.sh
91
+ ps1: .aw-spec/scripts/powershell/aw-rev-constitution.ps1
92
+ actions:
93
+ sh: .aw-spec/scripts/bash/aw-spec-actions.sh
94
+ ps1: .aw-spec/scripts/powershell/aw-spec-actions.ps1
95
+
96
+ # NO sticky standards. agent_generate ALWAYS injects the standards set (it cannot opt
97
+ # out), so an empty set guarantees no governance skeleton or greenfield exemplar leaks
98
+ # into the feature-map agent. Every step is fed EXACTLY what it needs via build_context;
99
+ # the technical-half author gets its neutral shape skeleton through context, not here.
100
+ standards: []
101
+
102
+ vars:
103
+ bundle_present: "false" # inventory bundle_guard driver
104
+ conformant: "false" # OKF conformance-gate driver
105
+ pack_present: "false" # domain-pack anti-clobber driver
106
+ technical_ok: "false" # technical-half lint guard
107
+ domain_ok: "false" # domain-half lint guard
108
+
109
+ workflow:
110
+
111
+ # ═══════════════════ PART 1 — FEATURE MAP (high-level discovery) ═════════════
112
+ # A deterministic scan + one enrichment agent, mirroring inventory's shape but
113
+ # producing a SHALLOW discovery index (drop the migration backlog / seams /
114
+ # adopt-order — this is development, not migration).
115
+
116
+ # 1. DETERMINISTIC scan of the current codebase → JSON substrate (files, churn,
117
+ # categories, aggregate_signals = candidate feature roots), and reports whether
118
+ # a bundle already holds curation.
119
+ - id: scan
120
+ action: execute_script
121
+ script: { ref: inventory }
122
+ subcommand: scan
123
+ outputs:
124
+ - { name: inventory_json, from: "$.inventory_json" }
125
+ - { name: root, from: "$.root" }
126
+ - { name: head, from: "$.head" }
127
+ - { name: file_count, from: "$.file_count" }
128
+ - { name: aggregate_count, from: "$.aggregate_count" }
129
+ - { name: bundle_dir, from: "$.bundle_dir" }
130
+ - { name: bundle_present, from: "$.bundle_present" }
131
+ - { name: bundle_md_count, from: "$.bundle_md_count" }
132
+
133
+ # 1b. Substance gate: no candidate features → nothing to map.
134
+ - id: require_aggregates
135
+ action: verify_context
136
+ require_true: aggregate_count
137
+ on_false: stop
138
+ on_false_message: "Scan found no candidate features in {{root}} (file_count={{file_count}}). Point /aw-spec-orch onboard at a codebase with a recognizable domain/vertical-slice layout, or scan a subtree that contains one."
139
+
140
+ # 1c. Curation guard (OKF rule): a bundle that already has concept files is
141
+ # curation — regenerating from scratch would destroy it.
142
+ - id: bundle_guard
143
+ action: verify_context
144
+ require_value: bundle_present
145
+ equals: "false"
146
+ on_mismatch: stop
147
+ on_mismatch_message: "The OKF feature-map bundle at {{bundle_dir}} already holds {{bundle_md_count}} concept file(s) — onboard would overwrite that curation. Back up or remove {{bundle_dir}} to re-onboard from scratch."
148
+
149
+ # 2. Pre-execution hooks.
150
+ - id: resolve_pre_hooks
151
+ action: execute_script
152
+ script: { ref: actions }
153
+ subcommand: resolve-hooks
154
+ args: ["--phase", "before_onboard"]
155
+ outputs:
156
+ - { name: before_hooks, from: "$.hooks" }
157
+ - id: dispatch_pre_hooks
158
+ action: dispatch_hooks
159
+ hooks_from_variable: before_hooks
160
+
161
+ # 3. ENRICHMENT — turn the substrate into a HIGH-LEVEL OKF feature map. Context via
162
+ # build_context (agent_generate reads the envelope): the factual substrate, the
163
+ # OKF format authority, and an OPTIONAL DDD vocabulary aid for naming (no
164
+ # migration/pipeline reference — this is development).
165
+ - id: ctx_author
166
+ action: build_context
167
+ context:
168
+ - { path: "{{inventory_json}}" } # the deterministic substrate (aggregate_signals etc.)
169
+ - { path: .aw-spec/templates/okf-concept-template.md } # OKF v0.1 format authority (frontmatter, index, log, rules)
170
+ - { path: docs/domain/domain-driven-design.md, optional: true } # OPTIONAL: aggregate/entity/VO/event vocabulary for naming only
171
+ - id: author_bundle
172
+ action: agent_generate
173
+ tools: "Read,Write,Edit"
174
+ permission_mode: acceptEdits
175
+ task: |
176
+ Act as the OKF enrichment agent for the Brownfield DEVELOPMENT onboard step.
177
+ Produce a CONFORMANT OKF v0.1 knowledge bundle at {{bundle_dir}} that is a
178
+ HIGH-LEVEL FEATURE MAP — a discovery index of the features/aggregates this
179
+ codebase contains, organized BY AGGREGATE ROOT — from the deterministic
180
+ substrate {{inventory_json}} (in context). Follow the OKF concept template in
181
+ context for format (frontmatter, index.md/log.md rules, cross-linking, hard rules).
182
+ Domain/scope hint (optional): {{USER_INPUT}}
183
+
184
+ THIS IS A MAP, NOT A DEEP REVERSE. Keep every feature concept SHALLOW — enough
185
+ to recognize and pick the feature to develop next. The deep per-feature reverse
186
+ (spec.md + design.md) is /aw-spec-orch adopt, run just-in-time when a feature is
187
+ about to be developed. Do NOT deep-model invariants/behaviour here.
188
+
189
+ Read the substrate first. Its `aggregate_signals` are CANDIDATE feature roots,
190
+ each with its files grouped by layer plus detected entities; `git.history.churn`
191
+ ranks significance; the category lists and `top_level_dirs` fill in the rest.
192
+ Signals are input, not decisions — YOU draw the real feature boundaries:
193
+ - Merge a src module and its mirror test module into ONE feature (e.g.
194
+ src/.../MedicinalProducts + tests/.../MedicinalProducts → MedicinalProduct).
195
+ - Treat service-level / shared infrastructure (a shared DbContext, cross-cutting
196
+ adapters, host/service-defaults projects) as a Platform/Shared concept, NOT a
197
+ feature.
198
+ - Fold value objects, entities, domain events, commands and endpoints into the
199
+ feature that OWNS them — one feature concept, not one per type.
200
+
201
+ Write the bundle (all paths under {{bundle_dir}}; bundle-relative links begin
202
+ with "/", per OKF §5.1):
203
+ - `index.md` (bundle root) — frontmatter EXACTLY `okf_version: "0.1"` and nothing
204
+ else; body = sections of bulleted links reusing each concept's `description`.
205
+ - `architecture/overview.md` (type: Reference) — the system at a glance. Its
206
+ `## Purpose` section MUST open with the whole solution/product name in bold
207
+ followed by "is a …" (e.g. "**Medicinal.Healthcare** is a …") — this bold token
208
+ is the PROJECT NAME the governance tier is named after, so get it right. Then:
209
+ the FEATURE MAP (each feature + one-line responsibility — NO seam/clean-torn
210
+ column, NO adopt-order), the tech stack, named external references / integration
211
+ points, and links to every other concept.
212
+ - `architecture/platform.md` (type: Reference) — the SHARED / cross-cutting
213
+ TECHNICAL note: the actual technology base (language, framework, persistence,
214
+ eventing, hosting), the shared infrastructure (DbContext, host/service-defaults),
215
+ cross-cutting concerns (auth posture, concurrency, observability) AS-BUILT. This
216
+ is the evidence the technical constitution is scaffolded from — describe what the
217
+ code ACTUALLY does, mark anything stubbed/optional/inactive as such.
218
+ - `aggregates/<feature>.md` (type: Aggregate) — ONE per feature root, SHALLOW:
219
+ Responsibilities; the entities / value objects / domain events / commands / API
220
+ endpoints / persistence it OWNS (named at a glance from the signal's layer
221
+ files — a list, not a deep model); and the candidate `specs/<Feature>/` slice
222
+ name (feature = aggregate). Set `source_files` to the module's files, grouped
223
+ with YAML comment headers by each file's OWN folder — the path segment that
224
+ VARIES across the files after their shared parent (the layer folder in a
225
+ vertical slice; the tier project in an n-tier app; tests → a single `tests`
226
+ group). Do NOT impose a fixed Domain/Application/UI taxonomy — the CODE's
227
+ folders ARE the grouping. Set `timestamp` to the latest commit time across them.
228
+ - `aggregates/index.md` — the bounded-context / feature map (no frontmatter beyond
229
+ OKF index rules) linking every feature concept.
230
+ - An `index.md` in EVERY subdirectory (no frontmatter).
231
+ - `log.md` (bundle root) — first line under a `## <today's date>` heading must be
232
+ `Commit: ` + backtick + `{{head}}` + backtick (validator rule E4), then a
233
+ one-line Initialization entry noting the concept count.
234
+ Do NOT write a migration-backlog, a seam/clean-torn analysis, or an adopt-order —
235
+ those are migration artifacts and are out of scope for the development flow.
236
+
237
+ Provenance + safety (OKF hard rules):
238
+ - Stamp every concept `origin: reverse-engineered` and `generated_by:
239
+ aw-spec-onboard/1.0.0` in frontmatter.
240
+ - The CODE is the source of truth; capture what IS (quirks included), not what
241
+ SHOULD be. Where intent is unclear from code + git history, add a concrete
242
+ `open_questions` entry rather than inventing one.
243
+ - NEVER fabricate facts, and NEVER emit secrets/tokens/credentials/internal
244
+ hostnames — describe shape, never values.
245
+ - Write ONLY inside {{bundle_dir}}; do NOT modify any source file.
246
+ Report the bundle tree and the concept count by type.
247
+ outputs:
248
+ - { name: bundle_files, from: "$.files" }
249
+
250
+ - id: verify_authored
251
+ action: verify_context
252
+ require_non_empty: bundle_files
253
+ on_empty: stop
254
+ on_empty_message: "No feature-map files were written to {{bundle_dir}}. Ensure the substrate {{inventory_json}} has aggregate_signals and re-run."
255
+
256
+ # 4. CONFORMANCE gate — OKF v0.1 validator (errors block; warnings noted).
257
+ - id: validate_bundle
258
+ action: execute_script
259
+ script: { ref: inventory }
260
+ subcommand: validate
261
+ args: ["--bundle", "{{bundle_dir}}", "--repo-root", "{{root}}"]
262
+ outputs:
263
+ - { name: conformant, from: "$.conformant" }
264
+ - { name: okf_errors, from: "$.errors" }
265
+ - { name: okf_warnings, from: "$.warnings" }
266
+ - { name: concepts, from: "$.concepts" }
267
+
268
+ - id: conformance_gate
269
+ action: verify_context
270
+ require_true: conformant
271
+ on_false: stop
272
+ on_false_message: "The OKF feature map at {{bundle_dir}} is NON-CONFORMANT (errors: {{okf_errors}}). Fix the reported ERRORs (unparseable frontmatter, missing `type`, malformed index.md/log.md) and re-run."
273
+
274
+ # ═══════════════ PART 2 — GOVERNANCE SCAFFOLD (project-level) ════════════════
275
+ # Establish the governing tier ONCE, from the feature map just written (the whole-
276
+ # repo vantage). No slice is adopted, so list-adopted returns slice_count=0 but STILL
277
+ # yields project_name / overview / project_context (domain evidence) and
278
+ # design_context (= overview + platform: the technical evidence) from the bundle.
279
+ # There is NO require_adopted gate here — that is the whole point of onboarding first.
280
+
281
+ - id: project_ctx
282
+ action: execute_script
283
+ script: { ref: revcon }
284
+ subcommand: list-adopted
285
+ outputs:
286
+ - { name: slice_count, from: "$.slice_count" }
287
+ - { name: spec_context, from: "$.spec_context" } # at onboard = project_context (no specs yet)
288
+ - { name: design_context, from: "$.design_context" } # at onboard = overview + platform (the tech evidence)
289
+ - { name: project_context, from: "$.project_context" } # overview + aggregates/index + platform + index
290
+ - { name: project_name, from: "$.project_name" }
291
+ - { name: overview, from: "$.overview" }
292
+
293
+ # Slugify + `brf-` prefix the domain name and create docs/domainspecs/brf-<domain>/.
294
+ # Name: explicit arg → PROJECT name from the OKF overview → repo basename. Guarded
295
+ # against clobbering a pack that already holds .md files.
296
+ - id: pack_setup
297
+ action: execute_script
298
+ script: { ref: revcon }
299
+ subcommand: pack-setup
300
+ args: ["--name", "{{USER_INPUT}}", "--fallback", "{{project_name}}"]
301
+ outputs:
302
+ - { name: domain_slug, from: "$.domain_slug" }
303
+ - { name: pack_dir, from: "$.pack_dir" }
304
+ - { name: comandrulemap, from: "$.comandrulemap" }
305
+ - { name: domain_constitution_source, from: "$.domain_constitution_source" }
306
+ - { name: pack_present, from: "$.pack_present" }
307
+
308
+ - id: pack_guard
309
+ action: verify_context
310
+ require_value: pack_present
311
+ equals: "false"
312
+ on_mismatch: stop
313
+ on_mismatch_message: "The domain pack docs/domainspecs/{{domain_slug}}/ already holds curated rule files — onboard would overwrite them. Back up or remove that folder to re-onboard, or amend it via /aw-spec-orch constitution."
314
+
315
+ # ── DOMAIN RULE-FILE PACK (provisional, evidenced by the SCAN) ───────────────
316
+ # Feed NEUTRAL shape skeletons (rev-templates/, zero content to leak) + the rule-
317
+ # partition authority + the project context (the feature map). NO adopted specs
318
+ # exist — the evidence is the OKF overview + aggregates/index + platform.
319
+ - id: ctx_pack
320
+ action: build_context
321
+ context:
322
+ - { path: "{{inventory_json}}" } # the COMPLETE deterministic scan substrate — read representative SOURCE from its file lists (the OKF map only SUMMARISES this)
323
+ - { path: .aw-spec/orchestrator/rev-templates/comandrulemap.skeleton.md, optional: true }
324
+ - { path: .aw-spec/orchestrator/rev-templates/domain-rule-file.skeleton.md, optional: true }
325
+ - { path: .aw-spec/orchestrator/rev-templates/domain-requirements.skeleton.md, optional: true }
326
+ - { path: .aw-spec/RULE-PARTITION.md } # the rule-partition authority (which command reads what)
327
+ context_from: project_context
328
+ - id: author_pack
329
+ action: agent_generate
330
+ tools: "Read,Write,Edit"
331
+ permission_mode: acceptEdits
332
+ task: |
333
+ Scaffold the PROJECT-level DOMAIN RULE-FILE PACK for **{{project_name}}** (domain
334
+ {{domain_slug}}) into docs/domainspecs/{{domain_slug}}/ (the dir exists).
335
+
336
+ EVIDENCE = THE CODE ITSELF (deep read), NOT the shallow map. The OKF FEATURE MAP in
337
+ context (architecture/overview.md, aggregates/index.md, architecture/platform.md)
338
+ only SUMMARISES the codebase. READ REPRESENTATIVE SOURCE to extract the real domain
339
+ rules: use {{inventory_json}} (in context) to locate the domain-carrying files —
340
+ entities, value objects, aggregates, domain events, invariant checks, validation —
341
+ across the aggregate_signals, and Read enough of them to state each rule from what
342
+ the code ACTUALLY enforces. Do NOT invent a rule the code does not evidence, and do
343
+ NOT rely on the map alone. There are NO adopted specs yet; this is the whole-repo
344
+ vantage — describe the domain / bounded context AS A WHOLE, so any feature later
345
+ slots in without a rewrite.
346
+
347
+ CONCERNS HINT: {{USER_INPUT}} may carry a "concerns: a, b, c" clause. Treat any listed
348
+ concern as a SEARCH HINT — go look for it in the code — but you still DECIDE presence
349
+ from evidence: include a concern's rule file ONLY if the code exhibits it, drop a
350
+ listed concern the code shows none of, and ADD an unlisted concern the code clearly
351
+ evidences. Ignore any non-concerns text (the domain name / scope hint).
352
+
353
+ PROVISIONAL BY CONSTRUCTION. Because no slice is adopted, you have the domain's
354
+ SHAPE (its features, ubiquitous language, bounded-context map, evident concerns)
355
+ but not yet its enumerated rule ids. Write each rule at the level the feature map
356
+ evidences and mark unresolved specifics `PROVISIONAL — reconciled at adopt`
357
+ (adopt fills the exact BR-/CN-/DC-/IC- ids when the feature is developed). NEVER
358
+ invent a rule the code/feature-map does not evidence.
359
+
360
+ SKELETONS ARE SHAPE ONLY. The *.skeleton.md files (rev-templates/) show HEADINGS,
361
+ frontmatter, the rule-partition and tone — and carry NO domain content. Copy the
362
+ SHAPE; never treat a bracketed [TOKEN] or example marker as a value to assert.
363
+
364
+ EVIDENCED-ONLY (lean): write a `<concern>.domain.md` ONLY for a concern the
365
+ feature map / platform note actually exhibits. Consider, include only if evidenced:
366
+ - domain-driven-design.domain.md — the ubiquitous language + bounded-context /
367
+ feature map (almost always evidenced; the modelling standard for /specify).
368
+ - data-classification.domain.md — only if the overview shows classified data.
369
+ - auditing.domain.md — only if the platform note shows audit/immutability.
370
+ - authorization.domain.md — only if an auth posture is evident.
371
+ - persistence.domain.md — only if retention/immutability/no-hard-delete is evident.
372
+ - cqrs.domain.md — only if the platform note shows a command/query split.
373
+ - eventing.domain.md — only if domain events are evident.
374
+ - api-versioning.domain.md — only if the API surface is versioned.
375
+ Plus, as needed:
376
+ - a domain reference file per distinct domain identifier/standard the overview names.
377
+ - domain-requirements.md — the PROJECT overview: open with a
378
+ `[DOMAIN: Bounded Contexts / Modules]` map (from the overview + aggregates
379
+ index), then per-subsection pointers, platform topology, governance overrides.
380
+ Stamp every file `origin: reverse-engineered`, `generated_by: aw-spec-onboard/1.0.0`,
381
+ and note the pack is a provisional scaffold reconciled per slice at adopt.
382
+
383
+ comandrulemap.md (MANDATORY — /specify's resolve-domain reads this exact filename).
384
+ Wire ONLY the files you generated, preserving the RULE PARTITION:
385
+ - `## /aw-spec-constitution` — the domain identity/regulatory/interop files → domain principles.
386
+ - `## /aw-spec-specify` — the FULL domain set (specify models the domain, lifts CN-/DC-/IC-).
387
+ - `## /aw-spec-design` — `_None — design loads no domain file. Domain reaches design only through the spec._`
388
+ - `## /aw-spec-implement` — `_None — implement loads no domain file. Domain reaches implement only through design.md._`
389
+ - `## /aw-spec-gate` — the conformance-checklist set (the *.domain.md files).
390
+ Each bullet is a workspace-relative path `- docs/domainspecs/{{domain_slug}}/<file>`.
391
+ Write ONLY inside docs/domainspecs/{{domain_slug}}/. Report the files written.
392
+ outputs:
393
+ - { name: pack_files, from: "$.files" }
394
+
395
+ - id: verify_pack
396
+ action: verify_context
397
+ require_non_empty: pack_files
398
+ on_empty: stop
399
+ on_empty_message: "No domain rule files were written to docs/domainspecs/{{domain_slug}}/. Ensure the feature map carries a modellable domain (a feature map + ubiquitous language) and re-run."
400
+ - id: require_comandrulemap
401
+ action: verify_context
402
+ required_files: ["{{comandrulemap}}"]
403
+
404
+ # ── DOMAIN CONSTITUTION SOURCE — docs/brf-<domain>-constitution.md ───────────
405
+ - id: ctx_domain_source
406
+ action: build_context
407
+ context:
408
+ - { path: "{{comandrulemap}}" }
409
+ - { path: .aw-spec/orchestrator/rev-templates/domain-constitution.skeleton.md, optional: true }
410
+ context_from: project_context
411
+ - id: author_domain_source
412
+ action: agent_author
413
+ include_standards: false
414
+ output_target: { type: file, path: "{{domain_constitution_source}}" }
415
+ task: |
416
+ Author the DOMAIN CONSTITUTION SOURCE (the output target) — the human-readable
417
+ charter for the WHOLE PROJECT **{{project_name}}** (domain {{domain_slug}}),
418
+ scaffolded from the OKF feature map (architecture/overview.md, aggregates/index.md
419
+ — in context) and the generated pack's comandrulemap.md. Follow the SHAPE of the
420
+ neutral skeleton domain-constitution.skeleton.md (in context) — its Project-Identity
421
+ + Domain-Principle structure — so the normal /aw-spec-orch constitution can
422
+ re-derive the domain half later. The skeleton carries NO content; every value
423
+ comes from the feature-map evidence.
424
+
425
+ PROJECT CHARTER, NOT AN AGGREGATE SPEC, and PROVISIONAL (no slice adopted yet).
426
+ Structure:
427
+ - Title `# {{project_name}} Domain Constitution (as-built, provisional)` and a
428
+ one-line origin note (`origin: reverse-engineered`, today's date).
429
+ - `## Project Identity` — project name = {{project_name}}; mission (from the
430
+ overview Purpose); bounded-context / feature map (from the overview feature map +
431
+ aggregates/index.md — list the features AND named external references as
432
+ contexts); architecture posture (from platform.md).
433
+ - `## Domain Principles` — principles the domain embodies, TITLED by DOMAIN CONCERN
434
+ (not by a feature name), each a declarative rule that would hold across features.
435
+ Number with a stable "D1, D2, …" convention (the composed constitution assigns
436
+ exact roman numerals after the technology base). Cite the feature-map evidence;
437
+ mark any principle whose exact rule ids are not yet enumerable `PROVISIONAL —
438
+ reconciled at adopt`.
439
+ - AS-BUILT: state the rule the code evidences; do NOT prescribe an ideal it does
440
+ not meet, and do NOT create a debt/backlog (migration is a later phase) — simply
441
+ omit an aspiration the code shows none of.
442
+ - Reference (do not restate) the technology base and the pack's rule files.
443
+ Return the charter markdown only.
444
+
445
+ # ── SPLIT CONSTITUTION — scaffold the two memory halves ──────────────────────
446
+ - id: setup_constitution
447
+ action: execute_script
448
+ script: { ref: actions }
449
+ subcommand: setup-constitution
450
+ outputs:
451
+ - { name: constitution_technical_file, from: "$.constitution_technical_file" }
452
+ - { name: constitution_domain_file, from: "$.constitution_domain_file" }
453
+
454
+ # TECHNICAL HALF — from the OKF overview + platform note (design_context), DOMAIN-FREE.
455
+ # The neutral technical shape skeleton is fed via CONTEXT (not the sticky standards
456
+ # set, which is empty), so nothing leaks into the Part-1 feature-map agent.
457
+ - id: ctx_technical
458
+ action: build_context
459
+ context:
460
+ - { path: "{{constitution_technical_file}}" }
461
+ - { path: .aw-spec/orchestrator/rev-templates/technical-constitution.skeleton.md, optional: true }
462
+ - { path: .aw-spec/orchestrator/rev-templates/ai-rules.reference.md, optional: true }
463
+ context_from: design_context
464
+ - id: author_technical
465
+ action: agent_author
466
+ include_standards: false
467
+ output_target: { type: file, path: "{{constitution_technical_file}}" }
468
+ task: |
469
+ Scaffold the TECHNICAL project constitution (the target file in context) —
470
+ AS-BUILT, from the OKF architecture overview + platform note (in context) that
471
+ describe this codebase's ACTUAL technology base. It is a TEMPLATE with [ALL_CAPS]
472
+ tokens; this is the domain-AGNOSTIC half. No slice is adopted, so the evidence is
473
+ the SCAN (overview stack + platform note), and principles are PROVISIONAL —
474
+ reconciled with real code coordinates when features are adopted.
475
+
476
+ EVIDENCE-FIRST — DISCOVER the principle set; do NOT inherit it. The skeleton
477
+ (technical-constitution.skeleton.md, in context) is a NEUTRAL SHAPE REFERENCE ONLY
478
+ — heading style, Sync-Impact-Report shape, evidence-line pattern — and carries NO
479
+ principle set. Author a principle ONLY for a technology trait the platform note /
480
+ overview actually evidences (the framework, persistence, eventing, concurrency,
481
+ hosting, testing, auth posture that ARE there). Cite the evidence on every
482
+ principle (e.g. "(evidence: platform.md persistence; overview stack)"); mark it
483
+ `PROVISIONAL — code coordinate reconciled at adopt` where the exact file/type is
484
+ not yet pinned.
485
+ - State PARTIAL / STUBBED / OPTIONAL traits AT THE LEVEL THE CODE REACHES, never a
486
+ template ideal (e.g. permissive-stub auth is not "Security by Default").
487
+ - OMIT pure-aspiration traits the platform note shows ZERO of. Do NOT create an
488
+ as-built-debt/backlog sink — migration is a separate later phase; an unmet ideal
489
+ is simply not asserted here.
490
+ - The project name is **{{project_name}}** — use it for the title / any
491
+ [PROJECT_NAME] token so this half, the domain half, and the charter name the
492
+ SAME project (never the outer tooling folder or a namespace).
493
+ - Do NOT add any domain-specific principle, identifier, terminology, regulatory or
494
+ interop rule — those belong to constitution.domain.md.
495
+ - NUMBER the discovered principles with sequential roman numerals from I, NO gaps,
496
+ NO padding. STATE the hand-off in the Sync Impact Report ("Technical principles:
497
+ I–<N>; domain half continues at <N+1>").
498
+ - Fill EVERY placeholder; leave no unexplained [BRACKET] (justify a genuine
499
+ deferral as TODO(<FIELD>): reason). Bump CONSTITUTION_VERSION by semver; ISO
500
+ YYYY-MM-DD dates (RATIFICATION_DATE = today). Preserve heading hierarchy.
501
+ - PREPEND a "Sync Impact Report" HTML comment: version old→new, the DISCOVERED
502
+ principle set, any trait DELIBERATELY OMITTED for lack of evidence (with why),
503
+ the technical count / domain hand-off numeral, and dependent artifacts (✅/⚠).
504
+ Return the complete updated technical constitution content only.
505
+
506
+ - id: technical_validation_loop
507
+ action: loop
508
+ while: "{{technical_ok}} != true"
509
+ max_iterations: 3
510
+ steps:
511
+ - id: tech_lint
512
+ action: execute_script
513
+ script: { ref: actions }
514
+ subcommand: constitution-verify
515
+ args: ["--file", "{{constitution_technical_file}}"]
516
+ outputs:
517
+ - { name: technical_ok, from: "$.ok" }
518
+ - { name: technical_issues, from: "$.issues" }
519
+ - id: tech_lint_break
520
+ action: break
521
+ condition: "{{technical_ok}} == true"
522
+ - id: patch_technical
523
+ action: agent_author
524
+ context: ["{{constitution_technical_file}}"]
525
+ include_standards: false
526
+ output_target: { type: file, path: "{{constitution_technical_file}}" }
527
+ task: |
528
+ Fix these mechanical defects in the technical constitution (target file in
529
+ context), changing NOTHING else — preserve every principle, the heading
530
+ hierarchy, and the Sync Impact Report. Fill any listed [ALL_CAPS] placeholder
531
+ with concrete text (or a justified TODO(<FIELD>): reason); make the body's
532
+ version line AGREE with the Sync Impact Report; ISO YYYY-MM-DD dates.
533
+ Defects: {{technical_issues}}
534
+ Return the complete updated technical constitution content only.
535
+
536
+ # DOMAIN HALF — from the pack + charter, principles continue the technical numbering.
537
+ - id: ctx_domain
538
+ action: build_context
539
+ context:
540
+ - { path: "{{constitution_domain_file}}" }
541
+ - { path: "{{constitution_technical_file}}" } # to CONTINUE its numbering (evidenced-only ⇒ not a fixed XV)
542
+ - { path: "{{domain_constitution_source}}" }
543
+ - { path: "{{comandrulemap}}" }
544
+ context_from: project_context
545
+ - id: author_domain
546
+ action: agent_author
547
+ include_standards: false
548
+ output_target: { type: file, path: "{{constitution_domain_file}}" }
549
+ task: |
550
+ Scaffold the DOMAIN ADDENDA constitution for the WHOLE PROJECT **{{project_name}}**
551
+ (domain {{domain_slug}}) — the target file in context — AS-BUILT and PROVISIONAL,
552
+ from the OKF project context (overview, aggregates/index — in context) + the
553
+ domain-constitution source + the generated pack (comandrulemap in context; READ
554
+ the pack's rule files under docs/domainspecs/{{domain_slug}}/). It is a TEMPLATE
555
+ with [ALL_CAPS] tokens; this half carries ONLY domain material.
556
+ - Name the SAME project as the technical half / charter: title / any [PROJECT_NAME]
557
+ token = {{project_name}}. This is a PROJECT constitution, not an aggregate spec —
558
+ govern the domain / bounded context as a whole.
559
+ - Fill EVERY placeholder; NO residual [BRACKET] may remain (it blocks composition).
560
+ - Author ONLY the domain layer: domain principles, domain folder additions,
561
+ regulatory/security posture, domain governance — from the pack + charter. NUMBER
562
+ them by CONTINUING the technical half's roman numerals: READ
563
+ constitution.technical.md (in context), find its LAST numeral N, start the first
564
+ domain principle at N+1 (do NOT assume it ends at XV). TITLE each by DOMAIN
565
+ CONCERN (not a feature name); state which technical principle (by its ACTUAL
566
+ numeral) it EXTENDS. Do NOT restate the technical principles — reference them.
567
+ Mark any principle whose exact rule ids are not yet enumerable `PROVISIONAL —
568
+ reconciled at adopt`.
569
+ - Include a short domain identity / bounded-context map (from the charter).
570
+ - AS-BUILT: the principle is what the code evidences; do NOT introduce a domain
571
+ rule the feature map does not evidence, and do NOT create a debt/backlog.
572
+ - Bump CONSTITUTION_VERSION by semver; ISO YYYY-MM-DD dates. Preserve heading
573
+ hierarchy. PREPEND a "Sync Impact Report" HTML comment (version old→new, domain
574
+ principles, dependent artifacts ✅/⚠ + TODOs).
575
+ Return the complete updated domain addenda content only.
576
+
577
+ - id: domain_validation_loop
578
+ action: loop
579
+ while: "{{domain_ok}} != true"
580
+ max_iterations: 3
581
+ steps:
582
+ - id: dom_lint
583
+ action: execute_script
584
+ script: { ref: actions }
585
+ subcommand: constitution-verify
586
+ args: ["--file", "{{constitution_domain_file}}"]
587
+ outputs:
588
+ - { name: domain_ok, from: "$.ok" }
589
+ - { name: domain_issues, from: "$.issues" }
590
+ - id: dom_lint_break
591
+ action: break
592
+ condition: "{{domain_ok}} == true"
593
+ - id: patch_domain
594
+ action: agent_author
595
+ context: ["{{constitution_domain_file}}"]
596
+ include_standards: false
597
+ output_target: { type: file, path: "{{constitution_domain_file}}" }
598
+ task: |
599
+ Fix these mechanical defects in the domain addenda constitution (target file
600
+ in context), changing NOTHING else — preserve every principle, the heading
601
+ hierarchy, and the Sync Impact Report. Fill any listed [ALL_CAPS] placeholder
602
+ (or a justified TODO(<FIELD>): reason); make the body version AGREE with the
603
+ Sync Impact Report; ISO YYYY-MM-DD dates.
604
+ Defects: {{domain_issues}}
605
+ Return the complete updated domain addenda content only.
606
+
607
+ # ── COMPOSE + ACTIVATE ───────────────────────────────────────────────────────
608
+ - id: compose_constitution
609
+ action: execute_script
610
+ script: { ref: actions }
611
+ subcommand: compose-constitution
612
+ outputs:
613
+ - { name: composed_file, from: "$.composed_file" }
614
+ - { name: domain_included, from: "$.domain_included" }
615
+
616
+ # Auto-activate: point .aw-spec/domain.json at the scaffolded pack so the forward CR
617
+ # loop governs development with it from the first change.
618
+ - id: activate_domain
619
+ action: execute_script
620
+ script: { ref: actions }
621
+ subcommand: set-domain
622
+ args: ["--domain", "{{domain_slug}}"]
623
+ outputs:
624
+ - { name: active_domain, from: "$.domain" }
625
+ - { name: map_exists, from: "$.map_exists" }
626
+
627
+ # ═══════════ TECHNICAL RULE-FILE PACK (code-derived) — the technical twin of the ═══
628
+ # domain pack above. This is what stops adopt AND the whole forward
629
+ # pipeline from falling back to greenfield technical rules.
630
+ #
631
+ # Runs AFTER the technical constitution is authored + validated (technical_validation_loop)
632
+ # so its ratified principles are on hand: each generated tech rule file is the DETAIL layer
633
+ # under a constitution.technical.md principle (thin ratified line ↑ / enforceable rule ↓).
634
+ # Evidence = the CODE (deep read via inventory_json's file lists) + the validated technical
635
+ # constitution + the shallow platform note (corroboration only). Writes:
636
+ # 1. docs/domainspecs/<domain>/tech/<concern>.md — evidenced-only code-derived tech rule
637
+ # files (the docs/architecture · docs/security · docs/governance ANALOG, but reverse-
638
+ # engineered from THIS code, never a greenfield file), INCLUDING the one file that
639
+ # feeds /specify: tech/domain-modelling.md, the as-built modelling METHODOLOGY (the
640
+ # analog of greenfield docs/domain/domain-driven-design.md). Without it brownfield
641
+ # specify has a model but no HOW-to-model standard, and models a NEW feature in a
642
+ # different idiom than the code it joins, and
643
+ # 2. docs/domainspecs/<domain>/commandtechrulemap.md — the TECHNICAL map (resolve-tech +
644
+ # tech-select read it by that exact name), wiring the generated files per-workflow.
645
+ # Because onboard already ACTIVATED brf-<domain>, the forward pipeline's + adopt's tech_select
646
+ # steps now resolve to THESE files — no greenfield docs/architecture fallback, ever. The pack
647
+ # lives inside pack_dir, so pack_guard (above) already protects it from clobber.
648
+ - id: ctx_tech_pack
649
+ action: build_context
650
+ context:
651
+ - { path: "{{inventory_json}}" } # PRIMARY: the COMPLETE deterministic substrate — read representative SOURCE from its file lists
652
+ - { path: "{{constitution_technical_file}}" } # PRIMARY: the VALIDATED as-built technology base — the ratified principles these files detail
653
+ - { path: .aw-spec/orchestrator/rev-templates/commandtechrulemap.skeleton.md, optional: true } # SHAPE ONLY: the technical map's headings + partition + table (zero real files)
654
+ - { path: .aw-spec/orchestrator/rev-templates/technical-rule-file.skeleton.md, optional: true } # SHAPE ONLY: one code-derived tech rule file's shape (zero real tech)
655
+ - { path: .aw-spec/RULE-PARTITION.md } # the rule-partition authority (which command reads what)
656
+ - { path: "{{bundle_dir}}/architecture/platform.md", optional: true } # SECONDARY (shallow): the OKF as-built platform note — corroborate, don't rely on alone
657
+ context_from: design_context
658
+ - id: author_tech_pack
659
+ action: agent_generate
660
+ tools: "Read,Write,Edit"
661
+ permission_mode: acceptEdits
662
+ task: |
663
+ Scaffold the PROJECT-level TECHNICAL RULE-FILE PACK for **{{project_name}}** (domain
664
+ {{domain_slug}}) — the CODE-DERIVED replacement for the greenfield technical rule set —
665
+ into docs/domainspecs/{{domain_slug}}/tech/ (create it), plus the technical map
666
+ docs/domainspecs/{{domain_slug}}/commandtechrulemap.md. This is the TECHNICAL twin of the
667
+ already-generated domain pack: it feeds the HOW phases (design/implement/build/…) plus
668
+ ONE modelling-methodology file for /specify (see domain-modelling below) — and nothing
669
+ else ever reaches /specify from this tier.
670
+
671
+ EVIDENCE = THE CODE ITSELF (deep read) + THE VALIDATED TECHNICAL CONSTITUTION. Authority,
672
+ in order:
673
+ 1. THE ACTUAL SOURCE CODE (ground truth). Use {{inventory_json}} (in context) to locate
674
+ representative files across top_level_dirs + a few aggregate_signals, and Read enough
675
+ to state each technical rule from what the code ACTUALLY does — the folder/tier/module
676
+ convention, the dependency direction, the persistence approach, concurrency handling,
677
+ testing convention, the auth/cross-cutting posture. Do NOT assert structure you have
678
+ not seen in the code.
679
+ 2. constitution.technical.md (in context) — the VALIDATED as-built technology base. Each
680
+ generated tech rule file is the DETAIL under one of ITS principles; cite the principle
681
+ numeral on the rules it details. Never contradict it; never restate it wholesale.
682
+ 3. The OKF platform.md (in context, if present) — SECONDARY, shallow corroboration only.
683
+ NEVER reference, read, copy, or list a greenfield rule file (docs/architecture/*,
684
+ docs/security/*, docs/governance/*, docs/interop/*, docs/VerticalSlice/*) — those are the
685
+ greenfield fixture, NOT this project's rules. Every path you write lives under
686
+ docs/domainspecs/{{domain_slug}}/tech/.
687
+
688
+ CONCERNS HINT: {{USER_INPUT}} may carry a "concerns: a, b, c" clause. Treat any listed
689
+ concern as a SEARCH HINT — look for it in the code — but DECIDE presence from evidence:
690
+ write a tech rule file for a concern ONLY if the code exhibits it, drop a listed concern
691
+ the code shows none of, and ADD an unlisted concern the code clearly evidences. Ignore any
692
+ non-concerns text.
693
+
694
+ EVIDENCED-ONLY (lean). Write a `tech/<concern>.md` ONLY for a technology concern the code
695
+ actually exhibits — e.g. as-built-architecture, persistence, concurrency, testing,
696
+ security-posture, api-surface, eventing, observability, hosting. Follow the SHAPE of
697
+ technical-rule-file.skeleton.md (in context): frontmatter (origin: reverse-engineered,
698
+ generated_by: aw-spec-onboard/1.3.0, concern), a one-line framing, rules each citing a CODE
699
+ COORDINATE (real file/folder path or named type) + the constitution principle numeral where
700
+ it maps. The skeleton carries NO real technology — copy the shape only. State stubs/partials
701
+ AS-BUILT (do not upgrade a stub into a greenfield ideal); omit a concern the code shows none
702
+ of (migration is a separate later phase — no debt/backlog sink here).
703
+
704
+ PLUS ONE SPECIAL FILE — `tech/domain-modelling.md` (concern: domain-modelling). This is the
705
+ ONE file in this pack that feeds /specify, and it is a MODELLING METHODOLOGY: HOW this
706
+ codebase expresses a domain model, not WHAT the model is (the model itself is the domain
707
+ pack's domain-driven-design.domain.md, already written — do NOT restate or duplicate it).
708
+ Read the code and state the AS-BUILT modelling conventions, each citing a code coordinate:
709
+ - what marks an aggregate root, and how a root is reached (base class / marker interface
710
+ / naming), plus the identity convention (typed id? primitive? value object?);
711
+ - entity vs value object — how the code distinguishes them, and where each lives;
712
+ - where invariants actually live (root method / domain service / validator / DB
713
+ constraint) — state what the code DOES, even if that is "enforced in the handler";
714
+ - the bounded-context / module boundary and what may cross it (ids only? DTOs? entities?);
715
+ - domain events, if the code has them: what raises one, and where it is dispatched;
716
+ - the naming/ubiquitous-language convention the code visibly follows.
717
+ Write it even when the conventions are partial or inconsistent — say so AS-BUILT and cite
718
+ the divergent coordinates; that is exactly what /specify needs in order to model a NEW
719
+ feature the way this codebase already models. Contains NO business vocabulary and NO
720
+ technology/architecture rules (those are the other files). Omit this file ONLY if the code
721
+ has no discernible domain model at all (e.g. a pure script/ETL repo).
722
+
723
+ commandtechrulemap.md (MANDATORY — resolve-tech + the tech-select module read this exact
724
+ filename). Follow the SHAPE of commandtechrulemap.skeleton.md (in context) and the rule
725
+ partition (.aw-spec/RULE-PARTITION.md, in context). Wire ONLY files you generated, under these headings, and
726
+ ONLY a heading you have a generated file for (an absent heading soft-continues → loads
727
+ nothing):
728
+ - `## /aw-spec-specify` — EXACTLY ONE bullet: `tech/domain-modelling.md`, the modelling methodology. NEVER an architecture / persistence / codegen / security file here — specify is the domain phase and any technology rule under this heading breaks its domain purity. Omit the heading only if you did not write domain-modelling.md.
729
+ - `## /aw-spec-design` — the as-built architecture / cross-cutting rules the design author mediates the spec against.
730
+ - `## /aw-spec-implement` — the code-generation / convention set the generator builds against (from design.md).
731
+ - `## /aw-spec-implement-delta` — the same code-generation set, scoped to a change's delta-design.
732
+ - `## /aw-spec-build` — the layering + convention rules the compile-fixer respects.
733
+ - `## /aw-spec-analyze-slice` — the conformance rules the design↔code gate validates against.
734
+ - `## /aw-spec-adopt` — the technical reference set the reversed design mediates against (a subset of design's).
735
+ - `## /aw-spec-run` — the runtime / execution conventions the app-run step honors (add ONLY if the code evidences a runtime/hosting concern file; NOT data-migration — migration is the deferred later phase).
736
+ Each bullet is a
737
+ workspace-relative path `- docs/domainspecs/{{domain_slug}}/tech/<file>`. Close with the
738
+ quick-reference table. Write ONLY inside docs/domainspecs/{{domain_slug}}/ (tech/ + the map);
739
+ modify no source. Report the files written + the concerns you found present (with the code
740
+ paths that evidence them).
741
+ outputs:
742
+ - { name: tech_pack_files, from: "$.files" }
743
+
744
+ - id: verify_tech_pack
745
+ action: verify_context
746
+ require_non_empty: tech_pack_files
747
+ on_empty: stop
748
+ on_empty_message: "No technical rule files were written to docs/domainspecs/{{domain_slug}}/tech/. Ensure the scan substrate (inventory_json) + the validated technical constitution carry an as-built technology base and re-run."
749
+ - id: require_commandtechrulemap
750
+ action: verify_context
751
+ required_files: ["{{pack_dir}}/commandtechrulemap.md"]
752
+
753
+ # ═══════════ CODE-DERIVED DESIGN TEMPLATES (reverse-engineered) ═══════════════
754
+ # Runs LAST in onboard — AFTER the governance tier is authored + validated + composed
755
+ # (compose_constitution above) — so the strongest reverse-engineered evidence is on hand:
756
+ # the ACTUAL SOURCE CODE + the deterministic scan substrate (inventory_json) + the
757
+ # VALIDATED technical constitution (the as-built technology base). Establish this repo's
758
+ # DESIGN CONVENTION by REVERSE-ENGINEERING its own technical structure into a project-
759
+ # specific design + delta-design template pair, written to the PROJECT-LEVEL override slot
760
+ # (.aw-spec/templates/overrides/{design,delta-design}-template.md — resolve_template
761
+ # Priority-1). The forward `design` phase's brownfield branch (design-scaffold reports
762
+ # override_active ⇒ design_mode == bootstrap_bf) then authors EVERY new feature against the
763
+ # as-built architecture, and a CHANGE authors its delta-design against the SAME code-derived
764
+ # sections (cr-setup scaffolds the delta from resolve_template("delta-design-template") ⇒
765
+ # the override) — no adopt required, consistent with the master design.md adopt emits.
766
+ #
767
+ # GROUNDED IN CODE + REVERSE-ENGINEERED FILES ONLY. The Part-1 OKF feature map is a SHALLOW
768
+ # discovery index (by design — NOT a deep reverse), so it is NOT the authority: the section
769
+ # skeleton is derived from the CODE itself + inventory_json (complete, deterministic) + the
770
+ # validated technical constitution, with the OKF map as secondary corroboration. The
771
+ # greenfield template supplies ONLY the NON-architectural bones (overview, the §1.2 domain/
772
+ # data-model anchor, the traceability spine, the Assumptions/Deviations ledgers, Change
773
+ # History) + the tech-agnostic authoring rules; its four greenfield layers MUST NOT leak —
774
+ # the ARCHITECTURAL sections come from the code only. The generated skeleton keeps the §0–§6
775
+ # shape the forward `design` bootstrap_bf branch expects, so no workflow change is needed to
776
+ # consume it. Re-onboard is gated upstream (bundle_guard / pack_guard) — remove the OKF
777
+ # bundle to regenerate.
778
+
779
+ # DESIGN template — feed the code-derived evidence (code + inventory + technical
780
+ # constitution) FIRST, the greenfield template for NEUTRAL bones only, then AUTHOR the override.
781
+ - id: ctx_design_template
782
+ action: build_context
783
+ context:
784
+ - { path: "{{inventory_json}}" } # PRIMARY: the COMPLETE deterministic substrate (top_level_dirs, aggregate_signals' per-layer file groupings) — the OKF markdown only SUMMARISES this
785
+ - { path: "{{constitution_technical_file}}" } # PRIMARY: the VALIDATED as-built technology base (framework/persistence/concurrency/hosting/testing/cross-cutting)
786
+ - { path: .aw-spec/templates/design-template.md } # SHAPE ONLY: the greenfield template — NEUTRAL bones to carry over + tech-agnostic authoring rules (its four layers must NOT leak)
787
+ - { path: "{{bundle_dir}}/architecture/platform.md", optional: true } # SECONDARY (shallow): the OKF as-built platform note — corroborate, don't rely on alone
788
+ - { path: "{{bundle_dir}}/architecture/overview.md", optional: true } # SECONDARY (shallow): the OKF feature map + stack
789
+ - { path: "{{bundle_dir}}/aggregates/index.md", optional: true } # SECONDARY (shallow): the bounded-context / feature map
790
+ - id: gen_design_template
791
+ action: agent_generate
792
+ tools: "Read,Write,Edit"
793
+ permission_mode: acceptEdits
794
+ task: |
795
+ REVERSE-ENGINEER this repo's design convention into a PROJECT-SPECIFIC design
796
+ TEMPLATE and Write it to .aw-spec/templates/overrides/design-template.md (create the
797
+ overrides/ dir if absent). It is a TEMPLATE — concrete project-derived section HEADERS
798
+ with [PLACEHOLDER] tokens + authoring HTML comments the forward `design` phase fills
799
+ per feature — NOT a filled design.
800
+
801
+ GROUND EVERYTHING IN THE CODE + THE REVERSE-ENGINEERED FILES — NOT the greenfield
802
+ template and NOT the shallow OKF map. Evidence authority, in order:
803
+ 1. THE ACTUAL SOURCE CODE (ground truth). Read REPRESENTATIVE source files across the
804
+ repo's top_level_dirs and a few aggregate_signals (from {{inventory_json}}) — enough
805
+ to CONFIRM from the code the recurring folder/tier/module convention + the dependency
806
+ direction it actually follows. Do NOT assert structure you have not seen in the code.
807
+ 2. {{inventory_json}} — the COMPLETE deterministic scan substrate (top_level_dirs, each
808
+ aggregate_signal's files grouped by layer, categories, tech stack). The OKF markdown
809
+ only SUMMARISES this, shallowly — prefer the substrate + the code over it.
810
+ 3. The TECHNICAL CONSTITUTION (constitution.technical.md, in context) — the VALIDATED
811
+ as-built technology base (framework, persistence, concurrency, hosting, testing,
812
+ cross-cutting posture). It is the authority for §1.1 As-Built Architecture + §3.
813
+ 4. The OKF platform.md / overview.md / aggregates/index.md (in context, if present) —
814
+ SECONDARY, shallow corroboration only (Part 1 is a discovery map, NOT a deep
815
+ reverse). Never rely on them alone.
816
+ The greenfield .aw-spec/templates/design-template.md is a SHAPE reference for the NEUTRAL
817
+ sections + the tech-agnostic authoring rules ONLY — its Domain/Application/API/
818
+ Infrastructure layering MUST NOT appear in the derived §1.1/§2.
819
+
820
+ Identify the RECURRING structural convention across features (the real layer/tier/module
821
+ folders + the dependency rule) from evidence 1–3 — this ONE template governs every
822
+ future feature.
823
+
824
+ Then AUTHOR the template with this §0–§6 skeleton (the shape the forward `design`
825
+ brownfield branch expects — keep these section numbers + headings):
826
+ - Keep the greenfield template's header block (Aggregate / Design home / Source spec /
827
+ Version / Status) and its TECHNOLOGY-AGNOSTIC authoring rules (behaviour as
828
+ signatures + pre/post/invariant/raises, contracts as field shapes, NO code; every
829
+ element traces to a spec id).
830
+ - §0 Design Overview + `### Ubiquitous Language (design delta)` — CARRY OVER (neutral).
831
+ - §1 Architecture Context & Domain Model:
832
+ §1.1 As-Built Architecture — describe THIS project's real structural convention you
833
+ discovered FROM THE CODE + the technical constitution (name the actual layer/tier/
834
+ module folders with representative code paths, the dependency direction, the tech
835
+ base). A new feature ALIGNS to this.
836
+ §1.2 Domain / Data Model — NEUTRAL ANCHOR: carry over the greenfield §1 domain-model
837
+ guidance (entities & value objects = spec Key Entities; invariants = spec BR-nnn;
838
+ aggregate boundary; lifecycle/states; cross-slice references-by-id).
839
+ - §2 Component & Behaviour Design — ONE `### 2.n` subsection PER RECURRING STRUCTURAL
840
+ AXIS the project actually uses, each TITLED after the project's OWN folder/tier name
841
+ (NOT a fixed Domain/Application/API/Infrastructure layering). In each, template the
842
+ components that live there + their behaviour in signature form + the ports/contracts.
843
+ Include exactly one subsection whose heading contains the word "Integration" (the
844
+ External Integrations table — one port/adapter row per IC-) as a pinned anchor.
845
+ - §3 Cross-Cutting Concerns — carry over the greenfield §5 table (security, data
846
+ protection, audit, observability, performance, retention, idempotency/concurrency;
847
+ Serves = a spec id or a §5 DA-n).
848
+ - §4 Traceability — CARRY OVER the greenfield §6 spine (every FR/BR/CN/DC/IC/US/SC has a
849
+ design home; the Layer column uses the project's OWN section refs).
850
+ - §5 Assumptions (DA-n) — carry over the greenfield §7 ledger, "None (as of vX.Y)".
851
+ - §6 Deviations / Deferred Decisions (WA-n) — carry over the greenfield §8 ledger, but
852
+ frame it AS-BUILT: it records genuine deviations, NOT "organised unlike a reference
853
+ architecture" (that is the as-built shape, §1.1).
854
+ - Change History — carry over.
855
+ Keep every [PLACEHOLDER] and authoring comment so `design` can fill it — and in those
856
+ comments DIRECT the downstream author (forward `design` / adopt) to GROUND each filled
857
+ section in the ACTUAL CODE + the reverse-engineered files (cite real file/folder paths and
858
+ the relevant technical-constitution principle), NEVER a greenfield assumption. Do NOT
859
+ invent project structure the code does not show; where the convention is unclear, template
860
+ a generic axis and flag it in a comment. Write ONLY the override file; modify no source.
861
+ Report the file written + the structural axes you derived (with the code paths that
862
+ evidence them).
863
+ outputs:
864
+ - { name: design_template_files, from: "$.files" }
865
+
866
+ - id: verify_design_template
867
+ action: verify_context
868
+ require_non_empty: design_template_files
869
+ on_empty: stop
870
+ on_empty_message: "No design template was written to .aw-spec/templates/overrides/design-template.md. Ensure the scan substrate (inventory_json) + the technical constitution are present and re-run."
871
+
872
+ # DELTA-DESIGN template — MIRROR the just-generated master template's OWN sections so a
873
+ # change classifies ADDED/MODIFIED/REMOVED against the code-derived structure, not the
874
+ # greenfield four layers. Aligns with the delta-design module (classifies "per the
875
+ # master's OWN section structure").
876
+ - id: ctx_delta_design_template
877
+ action: build_context
878
+ context:
879
+ - { path: .aw-spec/templates/overrides/design-template.md, optional: true } # PRIMARY: the JUST-generated code-derived master — mirror its ACTUAL sections
880
+ - { path: .aw-spec/templates/delta-design-template.md } # SHAPE ONLY: greenfield delta template — NEUTRAL bones to carry over
881
+ - { path: "{{constitution_technical_file}}" } # the validated as-built technology base (keep the delta consistent with the master)
882
+ - id: gen_delta_design_template
883
+ action: agent_generate
884
+ tools: "Read,Write,Edit"
885
+ permission_mode: acceptEdits
886
+ task: |
887
+ Author the matching PROJECT-SPECIFIC DELTA-design TEMPLATE and Write it to
888
+ .aw-spec/templates/overrides/delta-design-template.md. It is a TEMPLATE (placeholders
889
+ + authoring comments) for classifying a CHANGE to a feature as ADDED / MODIFIED /
890
+ REMOVED against the master design.md.
891
+
892
+ MIRROR the just-generated master template (.aw-spec/templates/overrides/design-template.md,
893
+ in context — Read it): its ADDED/MODIFIED/REMOVED tables must key off the master's OWN
894
+ code-derived sections (§1.1/§1.2, the §2.n axes it derived, §3), NOT the greenfield four
895
+ layers (Domain/Application/API/Infra). Use a "Section (§ in design.md)" column whose
896
+ example rows name the ACTUAL sections of the generated master template.
897
+ - CARRY OVER the greenfield delta template's neutral parts (in context): Change summary,
898
+ Cross-section impact, Regression targets, New assumptions/workarounds (DA-n / WA-n),
899
+ On close. Keep behaviour technology-agnostic (signatures + contracts, no code); a
900
+ shared element is MODIFIED in place, never duplicated; every changed element serves a
901
+ spec id.
902
+ - This aligns with the delta-design module, which classifies "per the master's OWN
903
+ section structure" — so the template MUST NOT hardcode a fixed layering.
904
+ Keep every [PLACEHOLDER] and authoring comment. Write ONLY the override file; modify no
905
+ source. Report the file written.
906
+ outputs:
907
+ - { name: delta_design_template_files, from: "$.files" }
908
+
909
+ - id: verify_delta_design_template
910
+ action: verify_context
911
+ require_non_empty: delta_design_template_files
912
+ on_empty: stop
913
+ on_empty_message: "No delta-design template was written to .aw-spec/templates/overrides/delta-design-template.md. Re-run onboard after confirming the design template override was generated."
914
+
915
+ # Post-execution hooks.
916
+ - id: resolve_post_hooks
917
+ action: execute_script
918
+ script: { ref: actions }
919
+ subcommand: resolve-hooks
920
+ args: ["--phase", "after_onboard"]
921
+ outputs:
922
+ - { name: after_hooks, from: "$.hooks" }
923
+ - id: dispatch_post_hooks
924
+ action: dispatch_hooks
925
+ hooks_from_variable: after_hooks
926
+
927
+ outputs:
928
+ bundle_dir: "{{bundle_dir}}"
929
+ aggregate_count: "{{aggregate_count}}"
930
+ concepts: "{{concepts}}"
931
+ warnings: "{{okf_warnings}}"
932
+ domain_slug: "{{domain_slug}}"
933
+ pack_dir: "{{pack_dir}}"
934
+ comandrulemap: "{{comandrulemap}}"
935
+ commandtechrulemap: "{{pack_dir}}/commandtechrulemap.md"
936
+ pack_files: "{{pack_files}}"
937
+ tech_pack_files: "{{tech_pack_files}}"
938
+ domain_constitution_source: "{{domain_constitution_source}}"
939
+ constitution_technical_file: "{{constitution_technical_file}}"
940
+ constitution_domain_file: "{{constitution_domain_file}}"
941
+ composed_file: "{{composed_file}}"
942
+ active_domain: "{{active_domain}}"
943
+ design_template_override: ".aw-spec/templates/overrides/design-template.md"
944
+ delta_design_template_override: ".aw-spec/templates/overrides/delta-design-template.md"
945
+ design_template_files: "{{design_template_files}}"
946
+ delta_design_template_files: "{{delta_design_template_files}}"
947
+ technical_validation_ok: "{{technical_ok}}"
948
+ domain_validation_ok: "{{domain_ok}}"
949
+ next: "Onboarded {{project_name}}: a high-level feature map at {{bundle_dir}} + a PROVISIONAL project governance scaffold (constitution.technical.md + constitution.domain.md), domain {{active_domain}} ACTIVATED, and — reverse-engineered from THIS code alone — BOTH rule tiers wired per-workflow: the DOMAIN pack (docs/domainspecs/{{domain_slug}}/*.domain.md + comandrulemap.md) AND the TECHNICAL pack (docs/domainspecs/{{domain_slug}}/tech/*.md + commandtechrulemap.md). Because the domain is activated, resolve-domain + resolve-tech now route the WHOLE forward pipeline AND adopt to these code-derived rules — no greenfield docs/architecture / docs/security fallback. Code-derived design + delta-design templates are installed as the project template overrides (.aw-spec/templates/overrides/) so a NEW feature is developed against the as-built architecture with NO adopt. Develop an EXISTING feature just-in-time: /aw-spec-orch adopt <Feature> reverse-engineers its spec.md + design.md and RECONCILES the governance with the slice's evidence. Develop a NEW feature straight through the forward pipeline (/aw-spec-orch specify → design → implement). Then drive every change through the CR delta loop (/aw-spec-orch specify → design → analyze-delta-design → implement-delta → build → finalize-delta → analyze-slice → close-delta). If a validation_ok is false, its constitution half needs a manual touch (see its Sync Impact Report)."