@rasensio/aidlc-content 2.26.0 → 2.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/templates.d.ts +7 -0
  6. package/dist/templates.d.ts.map +1 -1
  7. package/dist/templates.js +9 -0
  8. package/dist/templates.js.map +1 -1
  9. package/docs/cost-tracking.md +25 -3
  10. package/docs/hygiene-and-compliance.md +48 -5
  11. package/docs/index.yaml +6 -0
  12. package/docs/knowledge-graph.md +2 -2
  13. package/docs/lifecycle.md +22 -0
  14. package/docs/reviews-and-guidance.md +4 -2
  15. package/docs/roadmap.md +61 -15
  16. package/docs/skills-and-platforms.md +29 -11
  17. package/guidance/index.yaml +5 -0
  18. package/guidance/mermaid-diagrams.md +219 -0
  19. package/howto/make-a-custom-template.md +78 -0
  20. package/package.json +1 -1
  21. package/packs/aspice/controls.yaml +561 -0
  22. package/packs/aspice/guidance/aspice-constraints.md +109 -0
  23. package/packs/aspice/pack.yaml +30 -0
  24. package/packs/gdpr/controls.yaml +287 -0
  25. package/packs/gdpr/guidance/gdpr-constraints.md +141 -0
  26. package/packs/gdpr/pack.yaml +24 -0
  27. package/packs/gxp/controls.yaml +479 -0
  28. package/packs/gxp/guidance/gxp-constraints.md +159 -0
  29. package/packs/gxp/pack.yaml +35 -0
  30. package/packs/sox/controls.yaml +229 -0
  31. package/packs/sox/guidance/sox-constraints.md +100 -0
  32. package/packs/sox/pack.yaml +30 -0
  33. package/resources/rules/decision-register.md +3 -3
  34. package/resources/rules/departures.md +3 -1
  35. package/resources/rules/fresh-main.md +25 -0
  36. package/resources/rules/unattended.md +1 -1
  37. package/skills/00-overview.md +3 -4
  38. package/skills/03-entry-point.md +1 -0
  39. package/skills/20-requirements.md +4 -2
  40. package/skills/30-design.md +16 -3
  41. package/skills/50-testing.md +15 -0
  42. package/skills/60-deployment.md +38 -4
  43. package/skills/81-continue.md +2 -1
  44. package/skills/84-autopilot.md +1 -1
  45. package/skills/90-retrospective.md +1 -1
  46. package/templates/quick-feature.yaml +3 -0
  47. package/templates/system.md +39 -0
@@ -0,0 +1,229 @@
1
+ # SOX IT general controls — change management only.
2
+ #
3
+ # Sarbanes-Oxley defines no control list and no numbering. External auditors test
4
+ # IT general controls in four areas against a control matrix the audited company
5
+ # writes. The ids below are this pack's own, one prefix per area:
6
+ #
7
+ # PC program changes
8
+ # PD program development
9
+ # APD access to programs and data
10
+ # CO computer operations
11
+ #
12
+ # A user maps them to the matrix their company and auditor agreed. The prefixes
13
+ # keep every id distinct from the SOC 2 pack's CC ids and the ISO 27001 pack's
14
+ # A<n>.<n> ids, which matters because `aidlc compliance check` keys agent outcomes
15
+ # by control id across all installed packs (sox-itgc-pack/AC-4, sox-itgc-pack/AC-13).
16
+ #
17
+ # The text below states each control's intent in this pack's own words. It quotes
18
+ # no COBIT or PCAOB text.
19
+ #
20
+ # `kind` says what the AIDLC artifact trail can establish:
21
+ #
22
+ # evidenced the trail genuinely demonstrates the control
23
+ # checked-only the control operates over a running system, so no document
24
+ # evidences it; the pack supplies a fail condition an agent
25
+ # applies, and the trail records only that the check happened
26
+ #
27
+ # Every control is `check_kind: agent`. Each fail condition needs a reading of the
28
+ # instance's records, and none of them is visible as a pattern over added lines.
29
+ #
30
+ # Five controls are `evidenced`. One is `checked-only`. Eleven IT general controls
31
+ # are not covered at all, each listed below with its reason.
32
+
33
+ controls:
34
+ # -------------------------------------------------------------------------
35
+ # Evidenced: the lifecycle is a change process, so its trail is the record an
36
+ # auditor tests for these.
37
+ # -------------------------------------------------------------------------
38
+ - id: PC1
39
+ kind: evidenced
40
+ check_kind: agent
41
+ severity: major
42
+ phases:
43
+ - requirements
44
+ requires: >-
45
+ Every change starts from a documented request that says what is to change and
46
+ why, so the change can be traced back to the need it answers.
47
+ look_at: >-
48
+ requirements.md for the problem statement and the numbered acceptance
49
+ criteria, and the roadmap item the instance was started from.
50
+ fails_when: >-
51
+ The change has no requirements.md, or requirements.md carries no numbered
52
+ acceptance criterion, or the change does work that no criterion asks for.
53
+ evidence_artifact: requirements.md
54
+
55
+ - id: PC2
56
+ kind: evidenced
57
+ check_kind: agent
58
+ severity: critical
59
+ phases:
60
+ - requirements
61
+ - design
62
+ requires: >-
63
+ The change request is authorized before work on it starts, and a request
64
+ changed after it was authorized is authorized again.
65
+ look_at: >-
66
+ transitions.log for the requirements-to-design transition and its `by`;
67
+ phase-requirements.yaml for `completed_by`; the review findings recorded for
68
+ requirements.md; any amendment sections appended to requirements.md.
69
+ fails_when: >-
70
+ Design or implementation started with no recorded completion of the
71
+ requirements phase, or requirements.md was changed after that completion
72
+ without an amendment.
73
+ evidence_artifact: transitions.log
74
+
75
+ - id: PC3
76
+ kind: evidenced
77
+ check_kind: agent
78
+ severity: critical
79
+ phases:
80
+ - testing
81
+ requires: >-
82
+ The change is tested against its request before it is released, and the
83
+ result of that testing is recorded.
84
+ look_at: >-
85
+ test-results.md, the tests that reference each acceptance criterion, and the
86
+ testing phase's transition in transitions.log.
87
+ fails_when: >-
88
+ test-results.md is absent, or records a failing test, or leaves an active
89
+ acceptance criterion with no referencing test.
90
+ evidence_artifact: test-results.md
91
+
92
+ - id: PC4
93
+ kind: evidenced
94
+ check_kind: agent
95
+ severity: critical
96
+ phases:
97
+ - deployment
98
+ requires: >-
99
+ A person approves the change for production before it is released, and the
100
+ approval is recorded with who gave it and when.
101
+ look_at: >-
102
+ deployment-record.md for the release plan and the approval it records,
103
+ transitions.log for the deployment transition, and the release tag or merge
104
+ time of the change.
105
+ fails_when: >-
106
+ The deployment record names no person approving the release, or records that
107
+ approval after the release.
108
+ evidence_artifact: deployment-record.md
109
+
110
+ - id: PC5
111
+ kind: evidenced
112
+ check_kind: agent
113
+ severity: critical
114
+ phases:
115
+ - implementation
116
+ - deployment
117
+ requires: >-
118
+ Segregation of duties: the person or agent who wrote a change is not the one
119
+ who approved it for production.
120
+ look_at: >-
121
+ `aidlc cost <instance>` and the instance's sessions.ndjson under
122
+ <git-common-dir>/aidlc/records/ for the sessions that claimed it; transitions.log
123
+ for the `by` on each transition; the `completed_by` field of each phase file;
124
+ the autopilot approval record; and refusals.ndjson in the git common
125
+ directory, which logs every person-only command an agent was refused.
126
+ fails_when: >-
127
+ The approval for production was recorded by an identity also recorded as
128
+ writing the change, or by an agent session.
129
+ evidence_artifact: transitions.log
130
+
131
+ # -------------------------------------------------------------------------
132
+ # Checked only: operates over the environments a change runs in, so no
133
+ # document evidences it. The trail records that the check was applied.
134
+ # -------------------------------------------------------------------------
135
+ - id: PC6
136
+ kind: checked-only
137
+ check_kind: agent
138
+ severity: major
139
+ phases:
140
+ - implementation
141
+ - deployment
142
+ requires: >-
143
+ Development, test and production environments are kept apart, so a change
144
+ reaches production only through its release.
145
+ look_at: >-
146
+ Environment configuration, test setup and fixtures in the change: which
147
+ endpoints, databases and credentials each environment's code and configuration
148
+ points at.
149
+ fails_when: >-
150
+ Development or test code or configuration points at a production endpoint,
151
+ database or credential, or a production configuration enables a feature meant
152
+ only for development.
153
+ references: secure-defaults#secrets-management
154
+
155
+ # ---------------------------------------------------------------------------
156
+ # Not covered. Eleven IT general controls.
157
+ #
158
+ # organizational the control runs over live systems or the business's own
159
+ # governance, which the lifecycle trail does not record
160
+ # not-yet-built a code lifecycle could check something here; this pack
161
+ # does not yet, and says so rather than claiming it
162
+ #
163
+ # Every exclusion carries a note, because `organizational` alone misdescribes a
164
+ # control that runs over live systems (sox-itgc-pack/AC-11).
165
+ # ---------------------------------------------------------------------------
166
+ excluded:
167
+ # Program changes.
168
+ - id: PC7
169
+ reason: not-yet-built
170
+ note: >-
171
+ Emergency changes have a lifecycle angle: a fix released before its review
172
+ could be required to carry a retrospective approval. This pack does not check
173
+ for one and does not claim the control.
174
+ - id: PC8
175
+ reason: not-yet-built
176
+ note: >-
177
+ Reconciling production against approved changes has a lifecycle angle: the
178
+ commits deployed could be compared with the deployment records. This pack does
179
+ not do that, and a change made outside the lifecycle is invisible to it.
180
+ # Program development.
181
+ - id: PD1
182
+ reason: not-yet-built
183
+ note: >-
184
+ Data conversion has a lifecycle angle: a migration's record could carry a
185
+ reconciliation of the data before and after. This pack does not check one and
186
+ does not claim the control.
187
+ - id: PD2
188
+ reason: organizational
189
+ note: >-
190
+ Acquiring or developing a new system is chosen and signed off through the
191
+ business's own project governance, not recorded in a change's trail.
192
+ # Access to programs and data.
193
+ - id: APD1
194
+ reason: organizational
195
+ note: >-
196
+ Provisioning user access is done in live identity systems, which the
197
+ lifecycle trail does not record.
198
+ - id: APD2
199
+ reason: organizational
200
+ note: >-
201
+ Removing access for leavers and movers is done in live identity systems,
202
+ which the lifecycle trail does not record.
203
+ - id: APD3
204
+ reason: organizational
205
+ note: >-
206
+ Periodic access review is a review of live accounts and their rights, which
207
+ the lifecycle trail does not record.
208
+ - id: APD4
209
+ reason: organizational
210
+ note: >-
211
+ Who holds production and database administrator rights is live configuration,
212
+ which the lifecycle trail does not record.
213
+ # Computer operations.
214
+ - id: CO1
215
+ reason: organizational
216
+ note: >-
217
+ Job scheduling and monitoring concern batch jobs running in production, which
218
+ the lifecycle trail does not record.
219
+ - id: CO2
220
+ reason: organizational
221
+ note: >-
222
+ Backup and recovery run over live data, and a restore test happens in
223
+ operations, not in a change's trail.
224
+ - id: CO3
225
+ reason: organizational
226
+ note: >-
227
+ Problem and incident management is an operations process. A fix for an
228
+ incident leaves a trail when it goes through the lifecycle, but the incident
229
+ process itself does not.
@@ -0,0 +1,100 @@
1
+ ---
2
+ name: sox-constraints
3
+ description: SOX IT general controls for change management that apply while code is being written
4
+ ---
5
+ # SOX ITGC Constraints
6
+
7
+ **This pack's control text has not been reviewed by a compliance practitioner.**
8
+ It was written by an engineer. Treat it as a working draft: useful for applying
9
+ controls while you write code, not as an opinion on whether your controls are
10
+ adequate. Nothing here makes a project SOX compliant, certified, attested, or
11
+ audit-ready.
12
+
13
+ The control text states each control's intent in this pack's own words. It quotes no
14
+ COBIT or PCAOB text.
15
+
16
+ ## What SOX asks and what this pack covers
17
+
18
+ SOX defines no control list or numbering. External auditors test IT general controls
19
+ against a control matrix the audited company writes. The ids `PC`, `PD`, `APD` and
20
+ `CO` — program changes, program development, access to programs and data, computer
21
+ operations — are this pack's own. Map them to the control matrix your company and
22
+ auditor agreed.
23
+
24
+ This pack covers the change-management ITGCs only. Access to programs and data and
25
+ computer operations run over live systems the lifecycle trail does not record, so
26
+ those controls are listed in the pack's `controls.yaml` under `excluded:` with a
27
+ reason: `organizational` where they run over live systems or the business's own
28
+ governance, `not-yet-built` where a code lifecycle could say something and this pack
29
+ does not yet.
30
+
31
+ ## Which controls apply, and when
32
+
33
+ | Phase | Controls to have in mind |
34
+ |---|---|
35
+ | Requirements | PC1, PC2 |
36
+ | Design | PC2 |
37
+ | Implementation | PC5, PC6 |
38
+ | Testing | PC3 |
39
+ | Deployment | PC4, PC5, PC6 |
40
+
41
+ Run `aidlc compliance check` for each control's exact fail condition. Apply the fail
42
+ condition as written rather than your reading of the control — that is what makes two
43
+ reviews of the same change agree.
44
+
45
+ ## Five controls are evidenced. One is only checked.
46
+
47
+ **PC1, PC2, PC3, PC4 and PC5 are evidenced.** They are controls over how a change is
48
+ requested, authorized, tested, approved and kept apart from its author, and this
49
+ lifecycle *is* a change process, so the artifact trail demonstrates them.
50
+
51
+ **PC6 is checked only.** Keeping environments apart is a property of the systems a
52
+ change runs in. No document establishes it — so the pack gives you a fail condition to
53
+ apply, and the trail records that you applied it. A report will say which is which.
54
+ Never present a checked-only control as evidence.
55
+
56
+ ## What the evidenced controls ask of you while you build
57
+
58
+ Make sure each of these leaves a record, because the record is the evidence:
59
+
60
+ - **PC1, change request.** `requirements.md` says what is to change and why, in
61
+ numbered acceptance criteria.
62
+ - **PC2, change authorization.** The requirements phase is completed before design
63
+ starts, and `transitions.log` shows who completed it. A requirement changed later goes
64
+ through `aidlc amend`.
65
+ - **PC3, change testing.** `test-results.md` records the outcome, and every active
66
+ criterion has a referencing test.
67
+ - **PC4, approval before production.** `deployment-record.md` names the person who
68
+ approved the release, and the approval is recorded before the release.
69
+ - **PC5, segregation of duties.** The person or agent who wrote the change is not the
70
+ one who approved it for production.
71
+
72
+ ## What PC5 does not evidence
73
+
74
+ PC5 is judged from the instance's `sessions.ndjson` (under `<git-common-dir>/aidlc/records/`,
75
+ read through `aidlc cost <instance>`), `transitions.log`, each phase file's
76
+ `completed_by`, the autopilot approval record and `refusals.ndjson`. The identities in
77
+ the trail are as recorded, not authenticated: a session id and a git user name say who
78
+ the tool was told it was, not who it was. And one person who both directs the agent
79
+ and approves the release fails PC5 — the agent wrote the change on that person's
80
+ instruction, so the approval is not independent of the author.
81
+
82
+ ## What the trail cannot show
83
+
84
+ A change made outside the lifecycle leaves no trail. A hotfix pushed straight to
85
+ production, a configuration edited on a server, a migration run by hand — none of them
86
+ appears here, so the pack cannot show that every production change went through it.
87
+ That is the gap PC8 names, and why PC8 is excluded rather than covered.
88
+
89
+ ## SOC 1
90
+
91
+ A SOX audit of a service your company relies on often arrives as a request for a SOC 1
92
+ report. The SOC 2 pack's SOC 1 note, in `docs/hygiene-and-compliance.md`, says what
93
+ its trail shows a SOC 1 auditor and what it does not. This pack names the
94
+ change-management controls directly instead.
95
+
96
+ ## Security rules live in one place, not here
97
+
98
+ This pack does not restate the project's security rules. Read
99
+ `.aidlc/guidance/secure-defaults.md` and apply it. PC6 references its secrets
100
+ management section, so there is exactly one place to change when a rule changes.
@@ -0,0 +1,30 @@
1
+ id: sox
2
+ # SOX names the statute; the pack covers the IT general controls an auditor tests
3
+ # under it, and the change-management ones only. The report prints this string as
4
+ # its section heading (sox-itgc-pack/AC-2, sox-itgc-pack/AC-25).
5
+ regime: SOX ITGC
6
+ version: 0.1.0
7
+
8
+ # The first pack scoped to an industry. Sarbanes-Oxley applies to companies that
9
+ # file with the SEC, and the teams that ask for its IT general controls work at
10
+ # public companies, banks and fintechs. Naming an industry other than `any` is what
11
+ # makes the init wizard ask which industry a project serves, and offer this pack
12
+ # only under `financial-services` (sox-itgc-pack/AC-27).
13
+ industries:
14
+ - financial-services
15
+
16
+ entitlement: unrestricted
17
+
18
+ # Null on purpose. The control text in this pack was written by an engineer, not
19
+ # a compliance practitioner. Nulling this field obliges the constraint layer to
20
+ # say so, obliges every report to say so, and makes a doctor check watch for
21
+ # someone editing the statement out.
22
+ reviewed_by: null
23
+
24
+ layers:
25
+ - name: sox-constraints
26
+ file: sox-constraints.md
27
+ # Pack layers are delivered as a read-instruction whatever their size. A small
28
+ # layer that got inlined would put pack text inside an emitted skill, which is
29
+ # forbidden outright.
30
+ always_pointer: true
@@ -1,6 +1,6 @@
1
1
  # The decision-register rule
2
2
 
3
- Most design decisions are knowledge-graph entries. The few that bind the whole project go to one readable file, `docs/adr/decision-register.md`, where a person can see what was rejected, approve the choice, and know what would reopen it.
3
+ Most design decisions are knowledge-graph entries. The few that bind the whole project go to one readable file, `.aidlc/decisions/decision-register.md`, where a person can see what was rejected, approve the choice, and know what would reopen it.
4
4
 
5
5
  ## Which decisions go to the register
6
6
 
@@ -15,10 +15,10 @@ Everything else is recorded as a `decision` entity exactly as before. When unsur
15
15
 
16
16
  ## Writing an entry
17
17
 
18
- 1. If `docs/adr/decision-register.md` does not exist, create it by copying `.aidlc/resources/templates/decision-register.md`, leaving out its `aidlc:generated` line: the register belongs to the project, and `aidlc update` never touches it. Only a project-wide decision creates the file.
18
+ 1. If `.aidlc/decisions/decision-register.md` does not exist, create it and its folder by copying `.aidlc/resources/templates/decision-register.md`, leaving out its `aidlc:generated` line: the register belongs to the project, and `aidlc update` never touches it. Only a project-wide decision creates the file.
19
19
  2. Add the entry from the skeleton, numbered one past the highest in the file, with every option considered and "What would reopen it" filled in. Add its row to the status table in the same edit. If another branch merged the same number first, take the next free number before merging; a number is fixed once its entry is on the main branch.
20
20
  3. Write it with status **Proposed**. Ask the person whether to accept it, through the **Question Protocol** (`.aidlc/resources/rules/question-protocol.md`) in `design-questions.md`. Their answer is the only thing that makes it **Accepted**; no gate or transition does. Record the answer by changing the entry's status-table row — to Accepted, or to Rejected with the design following their choice. The status table is the only place the current status lives.
21
- 4. Record a pointer in the knowledge graph, never a copy: `aidlc knowledge add --type decision --id adr-<nnnn>-<slug> --name "ADR-<nnnn>: <title>" --description "ADR-<nnnn> in docs/adr/decision-register.md: <title>" --source docs/adr/decision-register.md`. The options, reason and reopen line live in the register only.
21
+ 4. Record a pointer in the knowledge graph, never a copy: `aidlc knowledge add --type decision --id adr-<nnnn>-<slug> --name "ADR-<nnnn>: <title>" --description "ADR-<nnnn> in .aidlc/decisions/decision-register.md: <title>" --source .aidlc/decisions/decision-register.md`. The options, reason and reopen line live in the register only.
22
22
 
23
23
  ## Superseding
24
24
 
@@ -12,13 +12,15 @@ A change that narrows, widens or replaces what one of three sources says:
12
12
 
13
13
  A choice those sources leave open is not a departure: internal names, file layout, the order of work, how something is tested. Decide it and record it as usual; do not ask.
14
14
 
15
+ Before a decision is recorded, read it against the SHALL text of each criterion it touches — what that criterion says must happen: a decision that does what that text rules out is a departure, and one that only chooses within it is not.
16
+
15
17
  Example: the user picked the Cockpit layout, and building the one-column Stream instead, because Cockpit is harder, is a departure. Calling the module `cockpit.ts` or `dashboard.ts` is not.
16
18
 
17
19
  ## What to do
18
20
 
19
21
  Stop before the change is written — in design, before it reaches `design.md`; in implementation, before the code. Ask through the **Question Protocol** (`.aidlc/resources/rules/question-protocol.md`) in that phase's question file. Quote the source and what it says, and make keeping what was agreed one of the options.
20
22
 
21
- A change the person accepts that alters a completed `requirements.md` goes through an amendment (**Amending a Completed Phase**, in the requirements skill), never a silent edit.
23
+ A change the person accepts that alters a completed `requirements.md` goes through an amendment (**Amending a Completed Phase**, in the requirements skill), never a silent edit. A criterion changed to answer a review finding goes through an amendment too, never rewritten in place.
22
24
 
23
25
  ## Unattended
24
26
 
@@ -0,0 +1,25 @@
1
+ # The fresh-main rule
2
+
3
+ A session that reads state from a stale `main` shows work as open that a merge already finished. So before the entry skill or `aidlc-continue` reads any state, bring the primary checkout's `main` up to date when that is safe.
4
+
5
+ ## The step
6
+
7
+ Run these exactly, in order, from wherever the session is, in one shell. Each one either passes or ends the step:
8
+
9
+ ```sh
10
+ common="$(git rev-parse --path-format=absolute --git-common-dir)" # fails outside git
11
+ primary="$(dirname "$common")"
12
+ git -C "$primary" symbolic-ref --short HEAD # must print main
13
+ git -C "$primary" fetch --quiet origin main # must succeed
14
+ git -C "$primary" status --porcelain --untracked-files=no # must print nothing
15
+ git -C "$primary" rev-list --count main..main@{upstream} # 0 means up to date: stop here
16
+ git -C "$primary" merge --ff-only --quiet main@{upstream} # must succeed
17
+ ```
18
+
19
+ - Outside a git repository the first command fails: skip the step and say nothing.
20
+ - Any other check that fails, a failed fetch, or a refused fast-forward ends the step with one line naming which, for example `main not updated: the primary checkout has uncommitted changes`. Then read the local state as it is.
21
+ - A fast-forward that went through is one line too: `main fast-forwarded by <n> commit(s)`.
22
+
23
+ Untracked files do not block the step: `merge --ff-only` itself refuses when one would be overwritten, so it is never unsafe.
24
+
25
+ The step uses git only, so it needs no CLI. It never commits, stashes, resets, rebases or pushes, and it never switches the primary checkout's branch. Unattended, a failed check is the same one line and nothing more: it is information, not a stop.
@@ -69,7 +69,7 @@ Each bullet begins with its one outcome; a condition after it is part of the rul
69
69
  - `open-question` — **default and log**: the recommended option, marked `(unattended default)`; if it is a hard-stop class, hard stop — never another option.
70
70
  - `requirements-confirmation` — **hard stop** when the requirements exceed the roadmap item; inside it, nothing is confirmed or logged.
71
71
  - `design-confirmation` — **hard stop** when the design exceeds the roadmap item; inside it, nothing is confirmed or logged.
72
- - `phase-end-turn` — **default and log**: continue into the next phase, unless `AIDLC_PAUSE_AFTER` names the phase just completed, which is a review boundary.
72
+ - `phase-end-turn` — **default and log**: continue into the next phase, unless `AIDLC_PAUSE_AFTER` names the phase just completed, which is a review boundary, or the launch prompt names one phase: end when it completes, at the release boundary for testing and deployment.
73
73
  - `review-boundary` — **review boundary**: `AIDLC_PAUSE_AFTER` names the phase just completed.
74
74
  - `fresh-session` — **default and log**: continue; the runner decides where sessions start.
75
75
  - `own-change-revert` — **default and log**: reverting this session's own change, after keeping a copy.
@@ -29,7 +29,7 @@ Seven ordered phases. Not all apply to every task:
29
29
 
30
30
  1. **Ideation** — Problem exploration, goals, constraints
31
31
  2. **Requirements** — Acceptance criteria, user stories, scope
32
- 3. **Design** — Architecture, interfaces, data flow; register: `.aidlc/resources/rules/decision-register.md`
32
+ 3. **Design** — Architecture, interfaces, data flow; register: `.aidlc/resources/rules/decision-register.md`, kept in `.aidlc/decisions/decision-register.md`
33
33
  4. **Implementation** — Code following the design; agent per task: `.aidlc/resources/rules/task-agents.md`
34
34
  5. **Testing** — Verification against requirements
35
35
  6. **Deployment** — Release preparation and execution
@@ -60,7 +60,7 @@ All state lives in `.aidlc/state/<instance-name>/`. Read and write state as foll
60
60
  ### Writing State
61
61
 
62
62
  1. **Before mutating state**, check whether another session already holds a claim on the instance. Claims live in `<git-common-dir>/aidlc/claims/<instance>.yaml` (resolve via `git rev-parse --git-common-dir`) so every worktree of the repo sees the same claims; outside a git repo (or on instances not yet migrated) the claim is the `claim:` field in `instance.yaml`. If another session holds a non-stale claim, warn and request override confirmation.
63
- 2. Claim with `aidlc claim <instance>` (release with `aidlc release <instance>`) — it writes the claim file and appends the claim event to `sessions.ndjson` in one step. Without the CLI, do both writes yourself: write the claim file (fields: `session`, `claimed_at`, `id_source`, optional `renewed_at`/`worktree_path`), then append `{"event":"claim|release","session_id":"...","id_source":"agent","agent":"<platform>","timestamp":"<ISO 8601 UTC>"}` to `.aidlc/state/<instance>/sessions.ndjson`. Never rewrite that file — append only. If the CLI warns your claim is near timeout, run `aidlc claim --renew <instance>`. Renew at every phase transition and before long-running operations — a claim older than `claim_timeout_minutes` counts as stale.
63
+ 2. Claim with `aidlc claim <instance>` (release with `aidlc release <instance>`) — it writes the claim file and appends the claim event in one step. Without the CLI, do both: write the claim file (fields: `session`, `claimed_at`, `id_source`, optional `renewed_at`/`worktree_path`), then append `{"event":"claim|release","session_id":"...","id_source":"agent","agent":"<platform>","timestamp":"<ISO 8601 UTC>"}` to `<git-common-dir>/aidlc/records/<key>/state/<instance>/sessions.ndjson` (`<key>`: `@root`, or the project's URL-encoded path; outside git, `.aidlc/state/<instance>/`). Append only. Renew with `aidlc claim --renew <instance>` at every phase transition and before long operations; a claim older than `claim_timeout_minutes` is stale.
64
64
  3. Update phase state files as you produce artifacts.
65
65
  4. Append a transition record to `transitions.log` only on successful phase transitions. When completing a phase, set `metrics.elapsed_seconds` in its `phase-<name>.yaml` from `entered_at` → `completed_at` — cost and time reports read it.
66
66
  5. After a successful phase transition, fire lifecycle actions: `on-phase-exit` for the phase you left, then `on-phase-enter` for the phase you entered (see **Lifecycle Actions**).
@@ -112,8 +112,7 @@ Safe for the instance is not the same as free for the person, so two rules bind
112
112
  A completed phase's artifact is changed **only through an amendment**, never edited in
113
113
  place. The gates check that artifacts exist, not that they still agree with each other, so a
114
114
  direct edit leaves the phase `complete`, the downstream artifacts describing the old
115
- requirement, and every gate passing. That silent disagreement is the failure mode
116
- amendments exist to prevent.
115
+ requirement, and every gate passing.
117
116
 
118
117
  The protocol: retire the criterion in place (`- AC-<n> (retired YYYY-MM-DD, superseded by
119
118
  AC-<m>): ...`), issue its replacement with a fresh ID, append an
@@ -26,6 +26,7 @@ If `.aidlc/context/` does not exist or contains no `.md` files, defer to the **a
26
26
  > {{glossary:claim}}
27
27
  > {{glossary:template}}
28
28
 
29
+ 0. Before reading any state, run the step in **The fresh-main rule** (`.aidlc/resources/rules/fresh-main.md`).
29
30
  1. List the directories under `.aidlc/state/`. Each directory is a lifecycle instance.
30
31
  2. For each instance, read `instance.yaml` (current phase, template, scope, claim) and the `phase-<name>.yaml` files to compute completion (complete artifacts ÷ total required artifacts).
31
32
  3. Read `.aidlc/config.yaml` for project defaults (scope, template) if present.
@@ -48,7 +48,7 @@ See **The context rule** (`.aidlc/resources/rules/context.md`).
48
48
  - Specific and unambiguous
49
49
  - Testable (an observable outcome)
50
50
  - Independent (not relying on unstated assumptions)
51
- - **Identified**: write every criterion as a list item `- AC-<n>: <text>` (bold variants `- **AC-<n>**: ...` and `- **AC-<n>:** ...` are also valid). Assign `AC-1`, `AC-2`, ... sequentially. IDs are never renumbered or reused — an amended criterion keeps its meaning or is retired: mark it `- AC-<n> (retired YYYY-MM-DD, superseded by AC-<m>): <text>` and issue a new ID. The testing-phase gate parses these IDs and fails on any active criterion without a referencing test.
51
+ - **Identified**: write every criterion as a list item `- AC-<n>: <text>` (bold variants `- **AC-<n>**: ...` and `- **AC-<n>:** ...` are also valid). Assign `AC-1`, `AC-2`, ... sequentially. Number them across the whole document, never per section: a sub-numbered id such as `AC-6.1` is not supported. IDs are never renumbered or reused — an amended criterion keeps its meaning or is retired: mark it `- AC-<n> (retired YYYY-MM-DD, superseded by AC-<m>): <text>` and issue a new ID. The testing-phase gate parses these IDs and fails on any active criterion without a referencing test.
52
52
  - **Shaped**, when the criterion is a behaviour. Write the text after the colon in one of four shapes, each naming its own test — the condition to set up and the response to check:
53
53
  - Event — `- AC-1: WHEN the user presses Save, THE SYSTEM SHALL write the draft to disk`
54
54
  - State — `- AC-2: WHILE the draft is unsaved, THE SYSTEM SHALL show a dot in the tab`
@@ -83,6 +83,7 @@ When the instance uses the `bugfix` template, this phase produces `reproduction.
83
83
  - `requirements.md` exists with at least one user story and corresponding acceptance criteria
84
84
  - Each acceptance criterion is testable (has an observable pass/fail condition)
85
85
  - The phase ends by naming each open decision — asked through the **Question Protocol** (`.aidlc/resources/rules/question-protocol.md`) in `.aidlc/state/<instance>/requirements-questions.md` — or by saying "Nothing open", written into `requirements.md` as a line of its own: autopilot reads that line to skip a pause with nothing to decide. Do not ask the user to confirm the whole document. Unattended (`AIDLC_UNATTENDED=1`): nothing is confirmed or logged; hard-stop when the requirements reach beyond the roadmap item, per `.aidlc/resources/rules/unattended.md`.
86
+ - A risk or note in `requirements.md` whose check is a person's review is an open decision: the phase does not write "Nothing open" and asks that check through the Question Protocol in `.aidlc/state/<instance>/requirements-questions.md`. A risk whose mitigation is a test, a gate or code is not asked for that reason. Unattended (`AIDLC_UNATTENDED=1`), the check takes the recommended option marked `(unattended default)`, is logged in `.aidlc/state/<instance>/unattended-stops.md` with **Type:** `open-question`, not `default`, and the build carries on, so the pull request waits for a person (`.aidlc/resources/rules/unattended.md`, The log).
86
87
 
87
88
  ## Guidance
88
89
 
@@ -128,7 +129,8 @@ To change a criterion after its phase closed:
128
129
 
129
130
  Field bullets accept `Retires:`, `**Retires**:` and `**Retires:**` alike. AC lists take
130
131
  whole `AC-<n>` tokens only — `AC-4..AC-6` is not a range and contributes nothing. A
131
- wrapped bullet is still one bullet.
132
+ sub-numbered id such as `AC-6.1` is refused: `aidlc amend` exits without recording
133
+ anything. A wrapped bullet is still one bullet.
132
134
  3. Run `aidlc amend <instance> --impact` to see which tasks, tests and artifacts still cite
133
135
  the retired criteria. It ends with one line naming the smallest `Reopens:` the write
134
136
  will accept: `none`, or the earliest completed phase that still cites a retired criterion.
@@ -32,8 +32,10 @@ Read only:
32
32
  - the spec corpus files in `.aidlc/specs/` named by `requirements.md`'s `## Spec delta` section —
33
33
  the current spec, which is what the design is built against. Not a past instance's
34
34
  `requirements.md`: it describes a change, and later instances may have changed it again.
35
- - `docs/adr/decision-register.md`, when it exists — head first: its status table, then only the
35
+ - `.aidlc/decisions/decision-register.md`, when it exists — head first: its status table, then only the
36
36
  entries the work touches. Never the whole file.
37
+ - `.aidlc/architecture/system.md`, when it exists — head first: its section headings, then only the
38
+ diagrams the work touches. Never the whole file.
37
39
 
38
40
  The seams the requirements touch are then read from the *source*, as step 3 of the
39
41
  instructions says — a handful of files, not a survey, and not the previous phase's
@@ -43,6 +45,16 @@ transcript. See **The context rule** (`.aidlc/resources/rules/context.md`).
43
45
 
44
46
  - `design.md` — Architecture overview, component design, interfaces, data flow, and design decisions with rationale
45
47
 
48
+ ### The change diagram
49
+
50
+ `architecture-diagram.md` is optional. Draw it only when the change adds or removes a service or a
51
+ store, adds a data flow between components, or moves a boundary (account, network, tenant or
52
+ trust). Otherwise, or when unsure, draw none.
53
+
54
+ Before drawing or changing one, read `.aidlc/guidance/mermaid-diagrams.md`; no other step reads it.
55
+ Draw against the current diagrams in `.aidlc/architecture/system.md` where that file exists. The
56
+ deployment phase carries what was built into that file, in this instance's own branch.
57
+
46
58
  ## Instructions
47
59
 
48
60
  > {{glossary:gate}}
@@ -50,10 +62,10 @@ transcript. See **The context rule** (`.aidlc/resources/rules/context.md`).
50
62
  1. **Review requirements.** Read `requirements.md` (or its summary if one exists). Identify the key technical challenges. When requirements carry `AC-n` IDs, note in each design section which criteria it addresses — that linkage is what reviewers and the testing phase trace against.
51
63
  2. **Consult the knowledge graph, then check it against the source.** If the project has a knowledge graph (`.aidlc/knowledge/` exists), run `aidlc knowledge context --scope phase --phase design` for existing architecture, decisions, and conventions. The graph is an index into the code, not an authority over it: an entry naming a component, table, column, function, or registry is a pointer to open, and an entry written by an earlier instance may name something a later one renamed or deleted. Confirm a named symbol exists in the source before designing against it — `aidlc knowledge verify <id>` records that you did, and `aidlc knowledge update <id>` corrects an entry that no longer matches. A design built on a symbol that is not there produces code against an API nobody has, and nothing downstream catches it until implementation. Also read the always-read guidance layers from `.aidlc/guidance/index.yaml` — see **The always-read rule** (`.aidlc/resources/rules/always-read.md`) for which layers those are and when to reach for the full `lessons.md`. Read `.aidlc/context/constitution.md` when it exists and apply the constitution rule in `.aidlc/resources/rules/constitution.md`.
52
64
  3. **Find the seams before proposing structure.** A project is brownfield from its second instance onwards, so start from the assumption that something in the codebase already does part of what the requirements ask for. For each capability in `requirements.md`, locate and read the existing code that carries any of it — the scheduler that already fires, the settings shape that already persists, the registry that already dispatches — and name those files in `design.md` before describing a single new component. Keep it narrow: the seams the requirements actually touch, a handful of files, not a survey. When nothing exists, write that down — "no existing seam" is a finding, and stating it is what separates a genuinely new component from one designed alongside the code that should have absorbed it.
53
- 4. **Define architecture.** Describe the high-level structure: components, their responsibilities, and how they communicate. Say for each one whether it extends a seam found in step 3 or is new.
65
+ 4. **Define architecture.** Describe the high-level structure: components, their responsibilities, and how they communicate. Say for each one whether it extends a seam found in step 3 or is new. When the change alters the system's shape, draw `architecture-diagram.md` as **The change diagram** says.
54
66
  5. **Specify interfaces.** For each component boundary, define the contract (function signatures, API shapes, data types).
55
67
  6. **Data flow.** Document how data moves through the system — inputs, transformations, storage, outputs.
56
- 7. **Design decisions.** Record each significant decision with rationale and alternatives considered. A project-wide decision — a one-way door, a new runtime or dev dependency, a new service, or a change to a stated constraint — goes to the decision register, and work that touches a register entry is checked against it first: both as **The decision-register rule** (`.aidlc/resources/rules/decision-register.md`) says. Persist every other accepted decision as a `decision` entity: `aidlc knowledge add --type decision --id <slug> --name "<title>" --description "<rationale>"`. A decision that would build other than what was agreed — in `requirements.md`, the roadmap item or a person's answer — is asked before it is recorded, as **The departure rule** (`.aidlc/resources/rules/departures.md`) says. A design question the roadmap item's `## Decisions` section answers is not asked: write the answer into `design.md`, citing `roadmap-item.md` `## Decisions`.
68
+ 7. **Design decisions.** Record each significant decision with rationale and alternatives considered. A project-wide decision — a one-way door, a new runtime or dev dependency, a new service, or a change to a stated constraint — goes to the decision register, and work that touches a register entry is checked against it first: both as **The decision-register rule** (`.aidlc/resources/rules/decision-register.md`) says. Persist every other accepted decision as a `decision` entity: `aidlc knowledge add --type decision --id <slug> --name "<title>" --description "<rationale>"`. A decision that would build other than what was agreed — in `requirements.md`, the roadmap item or a person's answer — is asked before it is recorded, as **The departure rule** (`.aidlc/resources/rules/departures.md`) says. Before writing "Nothing open", read each decision against the criteria it touches, as that rule's **What a departure is** says. A design question the roadmap item's `## Decisions` section answers is not asked: write the answer into `design.md`, citing `roadmap-item.md` `## Decisions`.
57
69
  8. **Address non-functional concerns.** Map performance, security, and accessibility requirements to design choices.
58
70
  9. **Identify risks.** Note technical risks and mitigation strategies.
59
71
  10. **Produce the task breakdown.** For templates that require it (full-feature, quick-feature), write `tasks.md` in the instance state directory as the final design step — the design is not done until it is actionable. Decompose the design into commit-sized tasks: each one reviewable in one sitting and independently verifiable. One task per line, in this exact grammar:
@@ -78,6 +90,7 @@ transcript. See **The context rule** (`.aidlc/resources/rules/context.md`).
78
90
  - The design addresses all acceptance criteria from `requirements.md`
79
91
  - For templates requiring it: `tasks.md` exists and every active acceptance criterion is claimed by at least one task, or the gap is deliberate
80
92
  - The phase ends by naming each open design decision — asked through the **Question Protocol** (`.aidlc/resources/rules/question-protocol.md`) in `.aidlc/state/<instance>/design-questions.md` — or by saying "Nothing open", written into `design.md` as a line of its own: autopilot reads that line to skip a pause with nothing to decide. Do not ask the user to confirm the design as a whole. Unattended (`AIDLC_UNATTENDED=1`): nothing is confirmed or logged; hard-stop when the design reaches beyond the roadmap item, per `.aidlc/resources/rules/unattended.md`.
93
+ - A risk or note in `design.md` whose check is a person's review is an open decision: the phase does not write "Nothing open" and asks that check through the Question Protocol in `.aidlc/state/<instance>/design-questions.md`. A risk whose mitigation is a test, a gate or code is not asked for that reason. Unattended (`AIDLC_UNATTENDED=1`), the check takes the recommended option marked `(unattended default)`, is logged in `.aidlc/state/<instance>/unattended-stops.md` with **Type:** `open-question`, not `default`, and the build carries on, so the pull request waits for a person (`.aidlc/resources/rules/unattended.md`, The log).
81
94
 
82
95
  ## Guidance
83
96
 
@@ -63,6 +63,21 @@ See **The context rule** (`.aidlc/resources/rules/context.md`).
63
63
  AC-7: verified manually — see results table above
64
64
  ```
65
65
  5. **Address failures.** If tests reveal bugs, fix the implementation. Do not skip or weaken tests to force a pass.
66
+ 6. **Update the living system diagram when there is no deployment phase.** When the instance's
67
+ template has a deployment phase, skip this step: deployment does it. Otherwise this is the last
68
+ phase before merge, so do it here, and only when this instance drew `architecture-diagram.md`:
69
+ - In this instance's own branch, make `.aidlc/architecture/system.md` match what was built, not
70
+ what design planned.
71
+ - When the file does not exist, create it and its folder by copying
72
+ `.aidlc/resources/templates/system.md`, leaving out the `<!-- aidlc:generated … -->` comment under its title. When
73
+ `.aidlc/context/architecture.md` exists and has no line naming `.aidlc/architecture/system.md`,
74
+ add a `## System Diagram` section with the line "The system as it stands is drawn in
75
+ `.aidlc/architecture/system.md`. Read its section headings first, then only the diagrams the
76
+ work touches." — never a diagram.
77
+ - Edit only the diagrams the work touched and leave the rest as written. Never regenerate the
78
+ whole file.
79
+ - Read `.aidlc/guidance/mermaid-diagrams.md` before editing.
80
+ - Name the diagrams changed in the testing artifact, or say none applied. No gate checks it.
66
81
 
67
82
  ## Exit Criteria
68
83