its-magic 0.1.2-29 → 0.1.2-32

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.
@@ -61,13 +61,231 @@ Strict-proof reason codes:
61
61
  - `RUNTIME_PROOF_STALE`
62
62
  - `RUNTIME_PROOF_AMBIGUOUS_LINK`
63
63
 
64
+ ## Strict phase role enforcement (US-0069 / DEC-0051)
65
+
66
+ `/auto` must enforce a deterministic **phase→role contract** with **preflight
67
+ admission** before each phase spawn, **fail-closed checkpoint validation** after
68
+ each phase completes, and **aligned strict-proof `role`** values. Post-hoc
69
+ isolation markers alone are insufficient.
70
+
71
+ ### Canonical phase→role matrix (fixed defaults)
72
+
73
+ | phase_id | Allowed roles | Default when no valid alternate policy |
74
+ |----------|-----------------|----------------------------------------|
75
+ | `intake` | `po` | `po` |
76
+ | `discovery` | `po` | `po` |
77
+ | `research` | `po`, `tech-lead` | `tech-lead` |
78
+ | `architecture` | `tech-lead` | `tech-lead` |
79
+ | `sprint-plan` | `tech-lead` | `tech-lead` |
80
+ | `plan-verify` | `qa`, `tech-lead` | `qa` |
81
+ | `execute` | `dev` (override path only) | `dev` |
82
+ | `qa` | `qa` | `qa` |
83
+ | `verify-work` | `qa` | `qa` |
84
+ | `release` | `release` | `release` |
85
+ | `refresh-context` | `curator`, `po` | `curator` |
86
+
87
+ ### Alternate-role scratchpad policy (single-valued resolution)
88
+
89
+ Resolve **exactly one** expected role for phases with alternates using merged
90
+ scratchpad (active + `.cursor/scratchpad.local.md`; template parity on install):
91
+
92
+ - `AUTO_ROLE_RESEARCH`: `po` \| `tech-lead` — when **unset or empty**, default
93
+ `tech-lead`; when set to any other value, fail closed with diagnostics (no
94
+ unrelated-role fallback).
95
+ - `AUTO_ROLE_PLAN_VERIFY`: `qa` \| `tech-lead` — when **unset or empty**,
96
+ default `qa`; otherwise only `qa` or `tech-lead` allowed (else fail closed).
97
+ - `AUTO_ROLE_REFRESH_CONTEXT`: `curator` \| `po` — when **unset or empty**,
98
+ default `curator`; otherwise only `curator` or `po` allowed (else fail closed).
99
+
100
+ ### Preflight capability gate (before spawn)
101
+
102
+ Before spawning phase work, `/auto` must:
103
+
104
+ 1. Resolve `phase_id` → expected canonical `role` (matrix + policy keys above).
105
+ 2. For `execute`, apply **default deny**: expected role is `dev` unless **both**
106
+ `AUTO_EXECUTE_ROLE_OVERRIDE=allowed_non_dev_execute` **and**
107
+ `EXECUTE_OVERRIDE_GOVERNANCE_REF` point to a **parseable** approved exception
108
+ record (for example `DEC-xxxx` or a documented anchor in
109
+ `docs/engineering/state.md`).
110
+ 3. Evaluate **role capability availability** for that boundary (subagent/tooling
111
+ can satisfy the resolved role).
112
+ 4. On missing capability: stop with `PHASE_ROLE_CAPABILITY_MISSING` including
113
+ `phase_id`, expected role, observed capability result, and remediation. **Do
114
+ not** spawn under a substitute unrelated role.
115
+
116
+ ### Post-completion boundary validation
117
+
118
+ When a phase completes, before advancing:
119
+
120
+ - Isolation evidence `role` must equal the **same** preflight-resolved expected
121
+ role for that `phase_id`. Else stop with `PHASE_ROLE_MISMATCH`.
122
+ - Strict-proof tuple `role` must equal isolation `role` and the expected role.
123
+ - `proof_hash` must be SHA-256 over canonical sorted-key JSON of
124
+ `orchestrator_run_id`, `runtime_proof_id`, `phase_id`, `role`,
125
+ `proof_issued_at`, `proof_ttl_seconds` (`DEC-0038` / architecture US-0069).
126
+
127
+ ### Resume / `start-from` parity
128
+
129
+ Every `/auto` invocation (explicit `start-from`, `resume_brief`, or conservative
130
+ `state.md` fallback) must **recompute** policy resolution and preflight from
131
+ scratch; stale continuation artifacts must not bypass the gate.
132
+
133
+ ### Role-enforcement reason codes (deterministic)
134
+
135
+ - `PHASE_ROLE_CAPABILITY_MISSING`
136
+ - `PHASE_ROLE_MISMATCH`
137
+
138
+ ## Configurable phase selection policy (US-0070 / DEC-0052)
139
+
140
+ `/auto` must treat the **resolved phase plan** as a first-class, fail-closed
141
+ schedule: a single ordered subset of canonical phases computed from merged
142
+ scratchpad (active + `.cursor/scratchpad.local.md`; template parity on install),
143
+ **before** resume/`start-from` intersection and **before** any phase spawn.
144
+
145
+ ### Canonical lifecycle order (baseline `full` plan)
146
+
147
+ Unless narrowed by policy, the canonical ordered phase list is:
148
+
149
+ `intake` → `discovery` → `research` → `architecture` → `sprint-plan` →
150
+ `plan-verify` → `execute` → `qa` → `verify-work` → `release` →
151
+ `refresh-context`
152
+
153
+ When `SECURITY_REVIEW=1`, insert `/security-review` in **design** mode
154
+ immediately after `architecture` and before `sprint-plan`, and in **code** mode
155
+ immediately after `execute` and before `qa`, as documented in **Steps** below.
156
+ Record these inserts in `resolved_phase_plan` breadcrumbs using the same
157
+ deterministic labels the orchestrator already uses for security boundaries.
158
+
159
+ ### Scratchpad selectors (exactly one active policy mode)
160
+
161
+ At most one of the following may be materially active after merge. If two or
162
+ more non-default selectors conflict, fail closed with `PHASE_POLICY_CONFLICT`
163
+ and **do not** materialize a plan:
164
+
165
+ - `AUTO_PHASE_PLAN=full` — full canonical lifecycle (including security-review
166
+ inserts when enabled). Default when unset and no other selector is set.
167
+ - `AUTO_PHASE_EXCLUDE=<csv>` — start from `full`, remove listed phase IDs
168
+ (validate each token; unknown id → `PHASE_PLAN_UNKNOWN_PHASE`).
169
+ - `AUTO_PHASE_INCLUDE=<csv>` — schedule **only** listed ids, then **re-sort**
170
+ into canonical lifecycle order. Unknown id → `PHASE_PLAN_UNKNOWN_PHASE`.
171
+ Empty result after parsing → `PHASE_PLAN_EMPTY_INCLUDE`.
172
+ - `AUTO_PHASE_PROFILE=<name>` — expand a **named profile** from the registry
173
+ below. Unknown profile → `PHASE_PLAN_UNKNOWN_PROFILE`.
174
+
175
+ **Conflict rule**: `AUTO_PHASE_PLAN` is default-only when it is unset, empty, or
176
+ exactly `full`. Any explicit non-`full` `AUTO_PHASE_PLAN` value is invalid
177
+ (fail closed with `PHASE_PLAN_INVALID_AUTO_PHASE_PLAN`) — use `INCLUDE` /
178
+ `EXCLUDE` / `PROFILE` instead.
179
+
180
+ ### Profile registry (baseline)
181
+
182
+ - `default` — equivalent to `full` (optional explicit alias; same behavior as
183
+ unset policy).
184
+
185
+ **High-risk profile sketch** (illustrative; `R-0049`): `profile_high_risk_dev_fast`
186
+ may only be selected when **both** hold: `AUTO_PHASE_PROFILE=profile_high_risk_dev_fast`
187
+ and `AUTO_PHASE_HIGH_RISK_ACK=<operator_token>` matches the profile spec
188
+ version documented in `decisions/DEC-0052.md` / research `R-0049`. Missing ack →
189
+ `PHASE_PLAN_HIGH_RISK_ACK_REQUIRED`. High-risk profiles may define **narrower**
190
+ reinstatement rules **only** as documented for that profile; default profile
191
+ behavior applies otherwise.
192
+
193
+ ### Plan materialization pipeline (evaluation order)
194
+
195
+ On every `/auto` entry (including resume, backlog-drain, bulk execute, and
196
+ team-mode runs), **recompute** from merged scratchpad:
197
+
198
+ 1. Parse merged scratchpad policy inputs for phase selection + `SECURITY_REVIEW`.
199
+ 2. Detect active policy mode; on conflict → `PHASE_POLICY_CONFLICT` (no plan).
200
+ 3. Expand mode to a **candidate** ordered phase list in canonical order.
201
+ 4. Apply **non-skippable reinstatement** for the **default profile** (and for
202
+ any profile that does not explicitly document a narrower exception with ack):
203
+ - **Safety gates**: always reinstate if removed: `qa`, `verify-work`,
204
+ `release`.
205
+ - **Evidence-chain closure**: if the candidate retains any phase from
206
+ `execute` onward (`execute`, optional `security-review-code`, `qa`,
207
+ `verify-work`, `release`, `refresh-context`), reinstate (if removed) the
208
+ contiguous canonical prefix from `intake` through `plan-verify` so later
209
+ gates retain valid upstream isolation + strict-proof chain semantics.
210
+ - When `SECURITY_REVIEW=1`, reinstate the corresponding `security-review-*`
211
+ insert when the adjacent retained phases would otherwise violate the
212
+ documented security boundary contract.
213
+ Record each reinstatement in breadcrumbs with reason `non_skippable_gate`
214
+ (or a more specific documented code).
215
+ 5. Record **operator-visible plan breadcrumbs** to `docs/engineering/state.md`
216
+ **before** first spawn (append-bottom per `DEC-0040`):
217
+ - `phase_policy_mode` (`full|exclude|include|profile`)
218
+ - `resolved_phase_plan` (ordered `phase_id` list)
219
+ - `skipped_phases` (id + reason: `policy_exclude`, `non_skippable_gate`,
220
+ `default_full_plan`, etc.)
221
+ - `orchestrator_run_id` (when known for this run)
222
+ 6. **Do not** silently revive phases omitted by policy on continuation: every
223
+ entry re-reads scratchpad bytes and recomputes the plan class.
224
+
225
+ ### `start-from` and resume intersection with the resolved plan
226
+
227
+ After computing the **resolved phase plan**, resolve the **nominal** start
228
+ phase using **Deterministic resume-source precedence** (explicit `start-from`
229
+ → `resume_brief` → `state` fallback → fail-fast).
230
+
231
+ Then **intersect**:
232
+
233
+ - Keep phases that appear in the resolved plan **in plan order**, starting at
234
+ the first plan phase whose canonical position is **at or after** the nominal
235
+ anchor phase (canonical order matches the baseline list above, including
236
+ security inserts when enabled).
237
+ - If the intersection is empty, fail closed with
238
+ `START_FROM_PHASE_PLAN_EMPTY_INTERSECTION` and diagnostics listing
239
+ `resolved_phase_plan` vs `requested_start_phase` / resume inference.
240
+
241
+ ### Compatibility with `US-0069` / `DEC-0051`
242
+
243
+ - Role resolution and preflight apply **only** to phases present in the
244
+ intersected schedule. Skipping `research` does **not** change the expected
245
+ role for `architecture` or any other retained phase.
246
+ - Skipped phases produce **no** spawn and **no** alternate-role substitution
247
+ for a different phase.
248
+
249
+ ### Phase-plan reason codes (deterministic)
250
+
251
+ Add to operator diagnostics and breadcrumb records:
252
+
253
+ - `PHASE_POLICY_CONFLICT`
254
+ - `PHASE_PLAN_UNKNOWN_PHASE`
255
+ - `PHASE_PLAN_EMPTY_INCLUDE`
256
+ - `PHASE_PLAN_UNKNOWN_PROFILE`
257
+ - `PHASE_PLAN_INVALID_AUTO_PHASE_PLAN`
258
+ - `PHASE_PLAN_HIGH_RISK_ACK_REQUIRED`
259
+ - `START_FROM_PHASE_PLAN_EMPTY_INTERSECTION`
260
+
261
+ ### Phase boundary operator visibility (AC-10)
262
+
263
+ At each phase boundary (after completing a scheduled phase), record a compact
264
+ **phase boundary status** entry (for example in `docs/engineering/state.md`
265
+ continuation breadcrumbs) including:
266
+
267
+ - `resolved_phase_plan` snapshot (or stable hash pointer to the run’s plan record)
268
+ - `skipped_phases` summary (id + reason code)
269
+ - `phase_boundary` (completed `phase_id`)
270
+ - `next_scheduled_phase` (or `none` when complete/stopped)
271
+
64
272
  ## Inputs
65
- - `AUTO_FLOW_MODE` and `PHASE_MODE` from `.cursor/scratchpad.md`
66
- - `AUTO_IMPLEMENTATION_LOOP`, `AUTO_LOOP_MAX_CYCLES` from `.cursor/scratchpad.md`
67
- - `AUTO_PAUSE_REQUEST`, `AUTO_PAUSE_POLICY` from `.cursor/scratchpad.md`
68
- - `SECURITY_REVIEW`, `COMPLIANCE_PROFILES` from `.cursor/scratchpad.md`
273
+ - Merged scratchpad policy (`US-0073` / `DEC-0055`): resolve flags from **local >
274
+ materialized `.cursor/scratchpad.md` > `.cursor/scratchpad.local.example.md`**
275
+ (installers materialize baseline when missing; missing required keys after merge
276
+ must fail closed with `[SCRATCHPAD_MERGE_ERROR]` diagnostics, not silent defaults).
277
+ - `AUTO_FLOW_MODE` and `PHASE_MODE` from merged scratchpad
278
+ - `AUTO_IMPLEMENTATION_LOOP`, `AUTO_LOOP_MAX_CYCLES` from merged scratchpad
279
+ - `AUTO_PAUSE_REQUEST`, `AUTO_PAUSE_POLICY` from merged scratchpad
280
+ - `SECURITY_REVIEW`, `COMPLIANCE_PROFILES` from merged scratchpad
69
281
  - `AUTO_EXECUTE_BULK`, `AUTO_EXECUTE_MAX_ITEMS`, `AUTO_EXECUTE_ON_BLOCK`,
70
- `AUTO_EXECUTE_SELECTION`, `AUTO_TEAM_SCOPE_ENFORCE` from `.cursor/scratchpad.md`
282
+ `AUTO_EXECUTE_SELECTION`, `AUTO_TEAM_SCOPE_ENFORCE` from merged scratchpad
283
+ - `AUTO_ROLE_RESEARCH`, `AUTO_ROLE_PLAN_VERIFY`, `AUTO_ROLE_REFRESH_CONTEXT`,
284
+ `AUTO_EXECUTE_ROLE_OVERRIDE`, `EXECUTE_OVERRIDE_GOVERNANCE_REF` from merged
285
+ scratchpad (US-0069 / DEC-0051)
286
+ - `AUTO_PHASE_PLAN`, `AUTO_PHASE_EXCLUDE`, `AUTO_PHASE_INCLUDE`,
287
+ `AUTO_PHASE_PROFILE`, `AUTO_PHASE_HIGH_RISK_ACK` from merged scratchpad
288
+ (US-0070 / DEC-0052)
71
289
  - `TEAM_MODE`, `TEAM_MEMBER`, `ACTIVE_TASK_IDS` from merged scratchpad context
72
290
  - Current product and engineering docs
73
291
  - Optional explicit argument: `start-from=<phase>`
@@ -225,6 +443,15 @@ Reason-code baseline:
225
443
  - `RUNTIME_PROOF_REUSED`
226
444
  - `RUNTIME_PROOF_STALE`
227
445
  - `RUNTIME_PROOF_AMBIGUOUS_LINK`
446
+ - `PHASE_ROLE_CAPABILITY_MISSING`
447
+ - `PHASE_ROLE_MISMATCH`
448
+ - `PHASE_POLICY_CONFLICT`
449
+ - `PHASE_PLAN_UNKNOWN_PHASE`
450
+ - `PHASE_PLAN_EMPTY_INCLUDE`
451
+ - `PHASE_PLAN_UNKNOWN_PROFILE`
452
+ - `PHASE_PLAN_INVALID_AUTO_PHASE_PLAN`
453
+ - `PHASE_PLAN_HIGH_RISK_ACK_REQUIRED`
454
+ - `START_FROM_PHASE_PLAN_EMPTY_INTERSECTION`
228
455
 
229
456
  ## Canonical `start-from` contract
230
457
 
@@ -284,21 +511,35 @@ Required codes:
284
511
  - `STATE_PHASE_UNRECOVERABLE`
285
512
 
286
513
  ## Steps
287
- 1. Read automation flags from scratchpad.
514
+ 1. Read automation flags from merged scratchpad and **materialize the resolved
515
+ phase plan** per **Configurable phase selection policy (US-0070 / DEC-0052)**:
516
+ detect exactly-one policy mode, expand, apply non-skippable reinstatement,
517
+ validate tokens/profile/ack requirements, and append plan breadcrumbs
518
+ (`phase_policy_mode`, `resolved_phase_plan`, `skipped_phases` + reasons) to
519
+ `docs/engineering/state.md` **before** any phase spawn. On failure, emit
520
+ deterministic phase-plan reason codes and stop (no partial schedule).
288
521
  2. Parse optional `start-from=<phase>` and validate canonical phase ID rules.
289
522
  Parse optional `--execute-bulk` and treat it as explicit one-run override.
290
- 3. Resolve start phase using deterministic precedence:
523
+ 3. Resolve **nominal** start phase using deterministic precedence:
291
524
  - explicit argument -> resume brief -> state fallback -> fail-fast.
292
525
  - Emit `[AUTO_RESUME_ERROR] ...` message on resolver failure.
526
+ 3a. **Intersect** the nominal start anchor with the resolved phase plan (plan
527
+ order preserved; drop scheduled phases strictly before the anchor in canonical
528
+ order). **Empty intersection** → fail fast with
529
+ `START_FROM_PHASE_PLAN_EMPTY_INTERSECTION` and diagnostics listing
530
+ `resolved_phase_plan` vs `requested_start_phase` / inferred resume anchor.
531
+ Set the executable schedule to this intersection.
293
532
  4. Record continuation breadcrumb metadata in `docs/engineering/state.md`:
294
533
  - `invocation_mode=auto`
295
534
  - `requested_start_from`
296
- - `resolved_start_phase`
535
+ - `resolved_start_phase` (first phase of the intersected schedule)
297
536
  - `resolution_source` (`argument|resume_brief|state_fallback`)
298
537
  - `resolution_status` (`resolved|fail-fast`)
299
538
  - `timestamp`
300
- 5. Spawn a fresh subagent for each remaining phase in canonical order, starting
301
- at the resolved phase:
539
+ 5. Spawn a fresh subagent for each remaining phase in **the intersected
540
+ resolved schedule order** (not the full canonical list when phases are
541
+ omitted), starting at `resolved_start_phase`:
542
+ default full path:
302
543
  intake -> discovery -> research -> architecture -> sprint plan ->
303
544
  plan verify -> execute -> QA -> verify work -> release -> refresh context.
304
545
  If `SECURITY_REVIEW=1`, run `/security-review` in a fresh security subagent:
@@ -307,13 +548,25 @@ Required codes:
307
548
  If `SECURITY_REVIEW=0` (default), skip both checks with zero overhead.
308
549
  - If `AUTO_BACKLOG_DRAIN=1`, repeat story lifecycle for next eligible OPEN
309
550
  story using deterministic selection policy until bounded stop criteria.
551
+ **Reload merged scratchpad phase-selection inputs and recompute the phase
552
+ plan at each story boundary** (same policy class as single-segment runs).
310
553
  - If bulk execute mode is active (`--execute-bulk` or
311
554
  `AUTO_EXECUTE_BULK=1`), iterate eligible planned items using
312
555
  `AUTO_EXECUTE_SELECTION` with bounded item count
313
556
  (`AUTO_EXECUTE_MAX_ITEMS`) and deterministic block/skip semantics.
557
+ **Reload merged scratchpad phase-selection inputs and recompute the phase
558
+ plan at each item boundary** (no silent revival of omitted phases).
314
559
  - In team mode with enforcement enabled, run pre-mutation scope checks against
315
560
  `TEAM_MEMBER` and `ACTIVE_TASK_IDS`; out-of-scope tasks produce deterministic
316
561
  reason codes and no writes.
562
+ - **US-0069 / DEC-0051**: Before each phase spawn, resolve the single-valued
563
+ expected role (matrix + `AUTO_ROLE_RESEARCH`, `AUTO_ROLE_PLAN_VERIFY`,
564
+ `AUTO_ROLE_REFRESH_CONTEXT`), enforce execute default deny / override
565
+ contract, and run the preflight capability gate; on failure stop with
566
+ `PHASE_ROLE_CAPABILITY_MISSING` (no unrelated-role spawn).
567
+ - **US-0069 / DEC-0051**: After each phase completes, validate isolation
568
+ `role` and strict-proof `role` against the preflight-resolved expected
569
+ role; on conflict stop with `PHASE_ROLE_MISMATCH`.
317
570
  6. Pass only the phase input files and current objective to each spawned
318
571
  subagent. Do not pass prior conversational reasoning as phase context.
319
572
  7. If `AUTO_IMPLEMENTATION_LOOP=1`, alternate fresh subagents for execute and QA
@@ -338,7 +591,9 @@ Required codes:
338
591
  phase in `docs/engineering/state.md` and includes all required fields. If
339
592
  missing/invalid/stale, stop with the appropriate reason code and remediation
340
593
  guidance (run the phase again in a fresh subagent context and write new
341
- evidence).
594
+ evidence). Append **phase boundary status** per **Configurable phase
595
+ selection policy (US-0070 / DEC-0052)** (selected/skipped summary + next
596
+ scheduled phase).
342
597
  11b. At each phase boundary, verify strict runtime attestation tuple exists and
343
598
  is valid for the completed phase (`orchestrator_run_id`,
344
599
  `runtime_proof_id`, `phase_id`, `role`, `proof_issued_at`,
@@ -29,4 +29,15 @@ description: "its-magic discovery: collect design/UX inspiration and scope updat
29
29
  1. Capture references and UX notes in vision.
30
30
  2. Add new stories or updates to backlog.
31
31
  3. Refresh the PO -> TL handoff.
32
+ 4. Triad hot-surface gate (DEC-0054) when `handoffs/po_to_tl.md` is mutated:
33
+ - run `python scripts/enforce-triad-hot-surface.py --rollover` then `--check`
34
+ from repository root,
35
+ - on failure stop with `STATE_ARCHIVE_REQUIRED` or
36
+ `ARTIFACT_HOT_SURFACE_OVERSIZE`,
37
+ - record verification tuple fields when rollover occurred (see runbook).
38
+
39
+ 5. Default minimal-read posture: start at `docs/engineering/phase-context.md`,
40
+ then vision/backlog/tail of `handoffs/po_to_tl.md` per runbook table; escalate
41
+ only to a named archive `pack_ref` when unresolved (`CONTEXT_BUDGET_EXCEEDED`
42
+ on unbounded reads).
32
43
 
@@ -182,4 +182,27 @@ Release gate semantics (US-0039): mandatory gates (check-in test, QA, UAT) and n
182
182
  - Runtime boundary:
183
183
  - static generated-test PASS is necessary but not sufficient for QA PASS;
184
184
  runtime startup/connectivity/log verdict remains governed by `US-0065`.
185
+ 20. User-visible internal metadata guard (US-0071 / DEC-0053):
186
+ - Before completing `/execute`, run `python scripts/check-user-visible-metadata.py`
187
+ from the repository root (or `python scripts/check-user-visible-metadata.py --repo <root>`).
188
+ - On failure, stop with `USER_VISIBLE_INTERNAL_METADATA_DETECTED` and use the
189
+ remediation contract in `docs/engineering/runbook.md` (evidence ref, token
190
+ class, neutral operator copy). Do not ship planning tokens in scanned
191
+ operator-visible strings.
192
+ - If you add a new operator-facing script or binary path, update inclusive
193
+ scan roots in `scripts/check-user-visible-metadata.py` **and** this runbook
194
+ section together or fail closed with `METADATA_SANITIZATION_SCOPE_AMBIGUOUS`
195
+ semantics at QA/release.
196
+ 21. Triad hot-surface enforcement (DEC-0054):
197
+ - Before completing `/execute`, run
198
+ `python scripts/enforce-triad-hot-surface.py --check` from repository root
199
+ (or `--repo <root>`).
200
+ - If the check fails, run `python scripts/enforce-triad-hot-surface.py --rollover`
201
+ then `--check` again; if still failing, stop with `STATE_ARCHIVE_REQUIRED` or
202
+ `ARTIFACT_HOT_SURFACE_OVERSIZE` (no successful execute completion on oversize
203
+ triad hot files).
204
+ - When your edits touched any triad path (`docs/engineering/state.md`,
205
+ `handoffs/po_to_tl.md`, `docs/engineering/architecture.md`), ensure rollover
206
+ evidence (`boundary`, `moved`, `retained`, `pack_ref`) is recorded in the
207
+ execute checkpoint when packs were written.
185
208
 
@@ -183,6 +183,14 @@ description: "its-magic intake: clarify idea and capture story + acceptance."
183
183
  - If `USER_GUIDE_MODE=0`, add no required user-guide steps or blocking checks (zero overhead).
184
184
  - If `USER_GUIDE_MODE=1`, ensure handoff references canonical user-guide path
185
185
  `docs/user-guides/US-xxxx.md` for the new story when applicable; see runbook.
186
+ 14. Triad hot-surface gate (DEC-0054) when `handoffs/po_to_tl.md` is mutated:
187
+ - run `python scripts/enforce-triad-hot-surface.py --rollover` then `--check`
188
+ from repository root,
189
+ - on failure stop with `STATE_ARCHIVE_REQUIRED` or
190
+ `ARTIFACT_HOT_SURFACE_OVERSIZE` (no successful intake completion with an
191
+ oversize handoff hot file),
192
+ - record the verification tuple (`boundary`, `moved`, `retained`,
193
+ `pack_ref`) in intake outputs when rollover occurred.
186
194
 
187
195
  ## Deterministic artifact ordering contract (US-0058 / DEC-0040)
188
196
 
@@ -57,6 +57,12 @@ verify no unresolved blockers.
57
57
  - `TEST_COMMAND` is mandatory baseline evidence for push eligibility.
58
58
  - Optional checks run only when configured and should be reported as
59
59
  `pass|fail|skipped` deterministically.
60
+ - **User-visible metadata guard (US-0071 / DEC-0053):** run
61
+ `python scripts/check-user-visible-metadata.py` (see runbook). On failure,
62
+ record blocking findings with reason `USER_VISIBLE_INTERNAL_METADATA_DETECTED`,
63
+ cite `path:line:column` evidence, token class, and remediation per runbook.
64
+ If the checker entrypoint is missing, fail closed with
65
+ `METADATA_SANITIZATION_POLICY_MISSING`.
60
66
  2. Record findings and severity.
61
67
  - Explicitly classify blockers that must prevent auto-push:
62
68
  unresolved blocking QA findings and unresolved critical issues.
@@ -27,14 +27,24 @@ description: "its-magic refresh context: compact state and decisions."
27
27
  1. Compact state and decisions into a short context pack.
28
28
  2. Update sprint summary with current status.
29
29
  3. Ensure handoffs and state are consistent.
30
- 4. Enforce state hot-surface rollover when configured thresholds are exceeded:
31
- - evaluate `STATE_HOT_MAX_LINES` and `STATE_HOT_MAX_CHECKPOINTS` from
32
- `.cursor/scratchpad.md`,
33
- - archive oldest low-frequency checkpoints into deterministic pack files under
34
- `docs/engineering/state-archive/`,
35
- - preserve only bounded recent checkpoints in `docs/engineering/state.md`,
36
- - write deterministic verification evidence (archive boundary, moved entries,
37
- retained hot-surface markers); fail closed on verification mismatch.
30
+ 4. Enforce **triad** hot-surface rollover when merged scratchpad thresholds are
31
+ exceeded (DEC-0054):
32
+ - read caps from `.cursor/scratchpad.md` + `.cursor/scratchpad.local.md`,
33
+ including `STATE_HOT_MAX_LINES`, `STATE_HOT_MAX_CHECKPOINTS`,
34
+ `PO_TO_TL_HOT_MAX_LINES`, `PO_TO_TL_HOT_MAX_SECTIONS`, `ARCH_HOT_MAX_LINES`,
35
+ and `ARCH_HOT_MAX_STORY_SECTIONS` (see runbook defaults),
36
+ - run `python scripts/enforce-triad-hot-surface.py --rollover` from repo root
37
+ (or `--repo <root>`) so `state.md`, `handoffs/po_to_tl.md`, and
38
+ `docs/engineering/architecture.md` archive oldest contiguous units into
39
+ deterministic packs under `docs/engineering/state-archive/`,
40
+ `handoffs/archive/`, and `docs/engineering/architecture-archive/`,
41
+ - immediately rerun `python scripts/enforce-triad-hot-surface.py --check`;
42
+ on failure stop with `STATE_ARCHIVE_REQUIRED` or
43
+ `ARTIFACT_HOT_SURFACE_OVERSIZE` (no successful phase completion on oversize
44
+ hot files),
45
+ - record verification tuple fields (`boundary`, `moved`, `retained`,
46
+ `pack_ref`) in the new `state.md` checkpoint when any rollover occurred;
47
+ idempotent reruns must not duplicate archived content.
38
48
 
39
49
  ## Deterministic artifact ordering contract (US-0058 / DEC-0040)
40
50
 
@@ -85,7 +85,7 @@ Strict mutation semantics:
85
85
 
86
86
  Mandatory gate order (strict, deterministic). No step may be skipped or reordered:
87
87
 
88
- 1. **Check-in test gate** — Verify latest `TEST_COMMAND` result is passing; block on missing, stale, or failing evidence.
88
+ 1. **Check-in test gate** — Verify latest `TEST_COMMAND` result is passing; block on missing, stale, or failing evidence. When `TEST_COMMAND` runs the consolidated repo runner (`tests/run-tests.*`), passing results must include **US-0071** user-visible metadata guard coverage (positive, leak detection, idempotence); otherwise treat as incomplete release evidence for this repository (`METADATA_SANITIZATION_POLICY_MISSING` / missing regression row).
89
89
  2. **QA completion gate** — Require no unresolved blocking findings in current sprint context before proceeding.
90
90
  3. **UAT completion gate** — Require UAT artifacts populated and verified; block on placeholder, incomplete, or unresolved-fail state.
91
91
  4. **Isolation compliance gate** — Require valid per-phase isolation evidence (US-0048 / DEC-0029); block on missing/invalid/stale evidence or violation.
@@ -255,6 +255,9 @@ Guardrails:
255
255
  - Stale/reused evidence: block with `ISOLATION_EVIDENCE_STALE`
256
256
  - Orchestrator/phase executed without fresh subagent: block with
257
257
  `PHASE_CONTEXT_ISOLATION_VIOLATION`
258
+ - **Phase role alignment (US-0069 / DEC-0051)**: each entry's `role` must
259
+ match the canonical expected role for its `phase_id` (matrix + scratchpad
260
+ alternates as documented in `/auto`). Mismatch → `PHASE_ROLE_MISMATCH`.
258
261
  - Remediation: re-run the affected phase(s) in fresh subagent contexts,
259
262
  write new isolation evidence, then rerun `/release`.
260
263
  4b. Strict runtime proof gate (US-0056 / DEC-0038): verify strict runtime-proof
@@ -266,6 +269,11 @@ Guardrails:
266
269
  - Expired/stale proof: block with `RUNTIME_PROOF_STALE`
267
270
  - Ambiguous proof-to-checkpoint linkage: block with
268
271
  `RUNTIME_PROOF_AMBIGUOUS_LINK`
272
+ - **Strict-proof role alignment (US-0069 / DEC-0051)**: tuple `role` must
273
+ equal the sibling isolation evidence `role` and the expected phase contract
274
+ role; `proof_hash` must be consistent with sorted-key JSON of the tuple
275
+ fields per `DEC-0038`. Violation → `RUNTIME_PROOF_INVALID` or
276
+ `PHASE_ROLE_MISMATCH` as applicable.
269
277
  - Remediation: rerun affected phase(s), write fresh runtime proof tuples,
270
278
  then rerun `/release`.
271
279
  5. Ensure target queue row exists; set status to `unreleased` before finalization.
@@ -39,4 +39,11 @@ globs: ["**/*"]
39
39
  `RUNTIME_STACK_PROFILE_UNRESOLVED`.
40
40
  Include startup command/profile, runtime mode, health result, retry ledger,
41
41
  and log summary in QA artifacts.
42
+ - User-visible internal metadata (US-0071 / DEC-0053): do not introduce
43
+ planning-shaped tokens (`US-[0-9]{4}`, `DEC-[0-9]{4}`, `R-[0-9]{4}`) into
44
+ operator-visible strings under inclusive scan roots (`bin/`, root installers,
45
+ `packaging/**`, `scripts/validate-and-push.*`). Use
46
+ `python scripts/check-user-visible-metadata.py` before handoff; on leakage use
47
+ `USER_VISIBLE_INTERNAL_METADATA_DETECTED` with path evidence and remediation
48
+ per `docs/engineering/runbook.md`.
42
49
 
@@ -1,7 +1,8 @@
1
- # its-magic scratchpad (local overrides example)
1
+ # its-magic scratchpad (framework default catalog — Model B / DEC-0055)
2
2
  #
3
- # Copy this file to `.cursor/scratchpad.local.md` and set personal overrides.
4
- # Local values override `.cursor/scratchpad.md` and should stay gitignored.
3
+ # Copy this file to `.cursor/scratchpad.local.md` for personal overrides (gitignored).
4
+ # Merge precedence: local > materialized `.cursor/scratchpad.md` > this example
5
+ # (installers materialize the baseline from template when missing).
5
6
  #
6
7
  # Core behavior
7
8
  # - MAGIC_CONTEXT_STRICT: 0|1 (require context refresh after code changes)
@@ -55,6 +56,31 @@ AUTO_EXECUTE_ON_BLOCK=stop
55
56
  AUTO_EXECUTE_SELECTION=planned_then_priority
56
57
  AUTO_TEAM_SCOPE_ENFORCE=1
57
58
  #
59
+ # `/auto` phase role policy (US-0069 / DEC-0051)
60
+ # - AUTO_ROLE_RESEARCH: po|tech-lead (empty -> default tech-lead)
61
+ # - AUTO_ROLE_PLAN_VERIFY: qa|tech-lead (empty -> default qa)
62
+ # - AUTO_ROLE_REFRESH_CONTEXT: curator|po (empty -> default curator)
63
+ # - AUTO_EXECUTE_ROLE_OVERRIDE: empty or allowed_non_dev_execute (execute default is dev)
64
+ # - EXECUTE_OVERRIDE_GOVERNANCE_REF: parseable waiver pointer (DEC-xxxx / state anchor) when override set
65
+ AUTO_ROLE_RESEARCH=
66
+ AUTO_ROLE_PLAN_VERIFY=
67
+ AUTO_ROLE_REFRESH_CONTEXT=
68
+ AUTO_EXECUTE_ROLE_OVERRIDE=
69
+ EXECUTE_OVERRIDE_GOVERNANCE_REF=
70
+ #
71
+ # `/auto` phase selection policy (US-0070 / DEC-0052)
72
+ # Exactly one active mode after merge; conflict -> PHASE_POLICY_CONFLICT (no plan).
73
+ # - AUTO_PHASE_PLAN: unset or full (default full canonical lifecycle)
74
+ # - AUTO_PHASE_EXCLUDE: csv of canonical phase ids (exclude from full)
75
+ # - AUTO_PHASE_INCLUDE: csv of canonical phase ids (re-sorted to canonical order)
76
+ # - AUTO_PHASE_PROFILE: named profile (see /auto + DEC-0052; unknown -> fail closed)
77
+ # - AUTO_PHASE_HIGH_RISK_ACK: required token when a high-risk profile demands it
78
+ AUTO_PHASE_PLAN=
79
+ AUTO_PHASE_EXCLUDE=
80
+ AUTO_PHASE_INCLUDE=
81
+ AUTO_PHASE_PROFILE=
82
+ AUTO_PHASE_HIGH_RISK_ACK=
83
+ #
58
84
  # Team mode
59
85
  # - TEAM_MODE: 0|1 (enable task/member scoped team workflow)
60
86
  # - TEAM_MEMBER: short id for current developer
@@ -93,7 +119,7 @@ SYNC_CUSTOM_PHASES=
93
119
  ALLOW_AUTO_PUSH=0
94
120
  AUTO_PUSH_BRANCH_ALLOWLIST=
95
121
  #
96
- # Knowledge curation / intake
122
+ # Knowledge curation
97
123
  # - EARLY_RESEARCH: 0|1 (PO/TL search web during intake/architecture)
98
124
  # - INTAKE_GUIDED_MODE: 0|1 (guided intake follow-up/options/research behavior)
99
125
  # - INTAKE_SUBAGENT_FALLBACK: deny|allow (deny by default; when deny, missing
@@ -107,6 +133,10 @@ AUTO_PUSH_BRANCH_ALLOWLIST=
107
133
  # archival rollover checks)
108
134
  # - STATE_HOT_MAX_CHECKPOINTS: integer >= 10 (max recent checkpoints to retain
109
135
  # in `state.md` after rollover)
136
+ # - PO_TO_TL_HOT_MAX_LINES: integer >= 200 (handoff hot-surface line cap)
137
+ # - PO_TO_TL_HOT_MAX_SECTIONS: integer >= 10 (max top-level ## sections retained)
138
+ # - ARCH_HOT_MAX_LINES: integer >= 500 (architecture hot-surface line cap)
139
+ # - ARCH_HOT_MAX_STORY_SECTIONS: integer >= 20 (max # US-xxxx story sections retained)
110
140
  # - Manual-override precedence: explicit flag values in this file remain authoritative
111
141
  # for that flag and override profile defaults.
112
142
  EARLY_RESEARCH=1
@@ -116,8 +146,12 @@ ID_NAMESPACE_BOOTSTRAP=0
116
146
  TOKEN_PROFILE=balanced
117
147
  STATE_HOT_MAX_LINES=1200
118
148
  STATE_HOT_MAX_CHECKPOINTS=80
119
- #
120
- # Publish targets
149
+ PO_TO_TL_HOT_MAX_LINES=800
150
+ PO_TO_TL_HOT_MAX_SECTIONS=60
151
+ ARCH_HOT_MAX_LINES=3500
152
+ ARCH_HOT_MAX_STORY_SECTIONS=120
153
+
154
+ # Publish targets (US-0054)
121
155
  # - RELEASE_PUBLISH_MODE: disabled|confirm|auto
122
156
  # - disabled: skip post-release publish target execution
123
157
  # - confirm: require explicit operator confirmation before publish (default)
@@ -127,6 +161,7 @@ STATE_HOT_MAX_CHECKPOINTS=80
127
161
  RELEASE_PUBLISH_MODE=confirm
128
162
  RELEASE_TARGETS_FILE=docs/engineering/release-targets.json
129
163
  RELEASE_TARGETS_DEFAULT=
164
+
130
165
  #
131
166
  # Security review
132
167
  # - SECURITY_REVIEW: 0|1 (enable optional security/compliance review; default off)
@@ -135,8 +170,8 @@ RELEASE_TARGETS_DEFAULT=
135
170
  # When SECURITY_REVIEW=0, the workflow adds zero security-review overhead.
136
171
  SECURITY_REVIEW=0
137
172
  COMPLIANCE_PROFILES=GDPR
138
- #
139
- # Compatibility observability
173
+
174
+ # Cross-repo compatibility observability
140
175
  # - CROSS_REPO_OBSERVABILITY: 0|1 (enable compatibility visibility and checks)
141
176
  # - COMPATIBILITY_GATE_ON_CRITICAL: 0|1 (when enabled, critical unresolved
142
177
  # compatibility findings trigger decision gate before release)
@@ -145,17 +180,19 @@ COMPLIANCE_PROFILES=GDPR
145
180
  CROSS_REPO_OBSERVABILITY=0
146
181
  COMPATIBILITY_GATE_ON_CRITICAL=1
147
182
  COMPATIBILITY_SOURCES=
148
- #
149
- # Component scope
183
+
184
+ # Component-scoped execution mode
150
185
  # - COMPONENT_SCOPE_MODE: 0|1 (enable scoped planning/execution guardrails)
151
186
  # - TARGET_COMPONENTS: comma-separated component IDs intended in scope
152
187
  COMPONENT_SCOPE_MODE=0
153
188
  TARGET_COMPONENTS=
154
- #
155
- # Optional docs packs
189
+
190
+ # Optional spec-pack documentation (US-0031)
156
191
  # - SPEC_PACK_MODE: 0|1 (enable Design Concept, CRS, Technical Spec generation/validation; default 0)
157
192
  # When 0, intake/architecture/release add no required spec-pack steps.
193
+ SPEC_PACK_MODE=0
194
+
195
+ # Optional user-guide documentation (US-0032)
158
196
  # - USER_GUIDE_MODE: 0|1 (enable per-feature user guides at docs/user-guides/US-xxxx.md; default 0)
159
197
  # When 0, intake/architecture/sprint-plan/execute/qa/release add no required user-guide steps or blocking checks.
160
- SPEC_PACK_MODE=0
161
198
  USER_GUIDE_MODE=0