its-magic 0.1.2-40 → 0.1.2-43

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.
package/README.md CHANGED
@@ -44,6 +44,10 @@ Pick one method:
44
44
  | Chocolatey | `choco install its-magic` (Admin shell) |
45
45
  | Homebrew | `brew tap USER/tap && brew install its-magic` |
46
46
 
47
+ ### Global Linux install: empty `install_include_paths` (CRLF manifest)
48
+
49
+ If **`its-magic --target <repo> --mode missing`** fails with **`[INSTALL_MANIFEST_ERROR] install_include_paths section is empty`** on Debian/Linux while the packaged manifest still lists paths, the global install likely has **CRLF** line endings in **`installer-owned-paths.manifest`** (visible as **`^M$`** with **`cat -A`**). **Fix in-tree** from **`0.1.2-41`**: **`installer.sh`** strips trailing carriage returns before section matching; **`.gitattributes`** keeps **`*.manifest`** LF; **`prepublishOnly`** runs **`guard_installer_publish`**. **Upgrade**: install a build **≥ `0.1.2-41`** (or reinstall from a fresh **`npm pack`** tarball after pull). Older tarballs such as **`its-magic@0.1.2-40`** may remain broken until republished — see **`docs/engineering/architecture.md`** **`# BUG-0008`**.
50
+
47
51
  ### 2) Apply to a repo
48
52
 
49
53
  New repo:
package/installer.ps1 CHANGED
@@ -28,7 +28,7 @@ function Get-ManifestSection($ManifestPath, $SectionName) {
28
28
  $inSection = $false
29
29
  $items = New-Object System.Collections.Generic.List[string]
30
30
  foreach ($raw in $lines) {
31
- $line = $raw.Trim()
31
+ $line = $raw.TrimEnd("`r").Trim()
32
32
  if ([string]::IsNullOrWhiteSpace($line)) { continue }
33
33
  if ($line.StartsWith("#")) { continue }
34
34
  if ($line.StartsWith("[") -and $line.EndsWith("]")) {
package/installer.sh CHANGED
@@ -92,8 +92,13 @@ list_source_files() {
92
92
 
93
93
  get_manifest_paths() {
94
94
  section="$1"
95
+ # BUG-0008: strip trailing CR so CRLF manifests (Windows-published npm tarballs)
96
+ # still match [section] headers under POSIX awk on Linux.
95
97
  awk -v s="$section" '
96
98
  BEGIN { in_section=0 }
99
+ {
100
+ sub(/\r$/, "")
101
+ }
97
102
  /^[[:space:]]*#/ { next }
98
103
  /^[[:space:]]*$/ { next }
99
104
  /^\[/ {
@@ -205,6 +210,7 @@ write_installed_version() {
205
210
  printf "%s" "$2" > "$vf"
206
211
  legacy="$1/.its-magic-version"
207
212
  [ -f "$legacy" ] && rm -f "$legacy"
213
+ return 0
208
214
  }
209
215
 
210
216
  sync_root_readme_to_its_magic() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "its-magic",
3
- "version": "0.1.2-40",
3
+ "version": "0.1.2-43",
4
4
  "description": "its-magic - AI dev team workflow for Cursor.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -1,5 +1,11 @@
1
1
  #!/usr/bin/env python3
2
- """Verify active vs template/scripts/ bytes match for DEC-0063 intake gate modules (BUG-0001)."""
2
+ """Verify active vs template/scripts/ bytes match for DEC-0063 intake gate modules (BUG-0001).
3
+
4
+ Scoped modes (DEC-0073 §10 / US-0090):
5
+ --scope=intake (default) DEC-0063 intake pair table.
6
+ --scope=caveman-compress DEC-0073 caveman input-compression pair table.
7
+ --scope=all union of both tables.
8
+ """
3
9
 
4
10
  from __future__ import annotations
5
11
 
@@ -7,7 +13,6 @@ import argparse
7
13
  import sys
8
14
  from pathlib import Path
9
15
 
10
- # Normative pairs: repo scripts/ (canonical dev) → template/scripts/ (packaged ship path).
11
16
  INTAKE_TEMPLATE_PAIRS: tuple[tuple[str, str], ...] = (
12
17
  ("scripts/intake_evidence_validate.py", "template/scripts/intake_evidence_validate.py"),
13
18
  ("scripts/intake_evidence_lib.py", "template/scripts/intake_evidence_lib.py"),
@@ -16,6 +21,24 @@ INTAKE_TEMPLATE_PAIRS: tuple[tuple[str, str], ...] = (
16
21
  ("scripts/check_intake_template_parity.py", "template/scripts/check_intake_template_parity.py"),
17
22
  )
18
23
 
24
+ # DEC-0073 §10 / US-0090 — Caveman input-compression surface pairs. Contents
25
+ # must be byte-identical between active and template paths; installer delivers
26
+ # template copies (BUG-0003 / DEC-0066).
27
+ CAVEMAN_COMPRESS_PAIRS: tuple[tuple[str, str], ...] = (
28
+ ("scripts/caveman_compress_input.py", "template/scripts/caveman_compress_input.py"),
29
+ ("docs/engineering/context/installer-owned-paths.manifest",
30
+ "template/docs/engineering/context/installer-owned-paths.manifest"),
31
+ ("docs/engineering/runbook.md", "template/docs/engineering/runbook.md"),
32
+ ("docs/engineering/auto-orchestration-reference.md",
33
+ "template/docs/engineering/auto-orchestration-reference.md"),
34
+ )
35
+
36
+ SCOPES: dict[str, tuple[tuple[str, str], ...]] = {
37
+ "intake": INTAKE_TEMPLATE_PAIRS,
38
+ "caveman-compress": CAVEMAN_COMPRESS_PAIRS,
39
+ "all": INTAKE_TEMPLATE_PAIRS + CAVEMAN_COMPRESS_PAIRS,
40
+ }
41
+
19
42
 
20
43
  def main() -> int:
21
44
  p = argparse.ArgumentParser(description=__doc__)
@@ -25,10 +48,17 @@ def main() -> int:
25
48
  default=Path(__file__).resolve().parent.parent,
26
49
  help="Repository root",
27
50
  )
51
+ p.add_argument(
52
+ "--scope",
53
+ choices=sorted(SCOPES.keys()),
54
+ default="intake",
55
+ help="Parity pair table to verify.",
56
+ )
28
57
  args = p.parse_args()
29
58
  root: Path = args.repo
59
+ pairs = SCOPES[args.scope]
30
60
  failed = False
31
- for rel_active, rel_tpl in INTAKE_TEMPLATE_PAIRS:
61
+ for rel_active, rel_tpl in pairs:
32
62
  a = root / rel_active
33
63
  t = root / rel_tpl
34
64
  if not a.is_file() or not t.is_file():
@@ -45,7 +75,7 @@ def main() -> int:
45
75
  failed = True
46
76
  if failed:
47
77
  return 2
48
- print("[INTAKE_TEMPLATE_PARITY_OK]")
78
+ print(f"[INTAKE_TEMPLATE_PARITY_OK] scope={args.scope}")
49
79
  return 0
50
80
 
51
81
 
@@ -19,6 +19,11 @@ description: "its-magic auto: deterministic continuation orchestrator."
19
19
  - Phase context transfer happens only through artifacts and handoff files.
20
20
  - Scope is process/workflow orchestration only. Do not claim runtime product
21
21
  orchestration changes.
22
+ - **Bug-queue mode** (**`US-0087`**) uses the same **spawn-only** contract: the
23
+ orchestrator schedules materialization and spawns phase-role subagents per
24
+ bug segment—it **must not** run **`execute`**, **`qa`**, or other lifecycle
25
+ phases in the orchestrator turn. Violations → **`AUTO_ORCHESTRATOR_PHASE_EXECUTION`**
26
+ (**`BUG-0006`**, **`US-0069`**, **`DEC-0051`**).
22
27
 
23
28
  ## Spawn-boundary integrity (BUG-0006)
24
29
 
@@ -33,6 +38,39 @@ description: "its-magic auto: deterministic continuation orchestrator."
33
38
  (wrong writer / isolation break) and **`RUNTIME_PROOF_*`** / **`PHASE_ROLE_*`**
34
39
  families—do not overload those codes for a missing-spawn violation.
35
40
 
41
+ ## Continuous multi-phase execution (US-0088)
42
+
43
+ A single `/auto` orchestrated run advances through **all phases** in the
44
+ **intersected resolved schedule** (reference **Step 5**) until a
45
+ **deterministic stop condition** fires. The orchestrator does **not** stop after
46
+ spawning one phase unless the stop matrix requires it.
47
+
48
+ **Outer-driver equivalence (AC-1, Option B)**: When a single Cursor `/auto`
49
+ invocation cannot schedule multiple fresh subagent turns (product/runtime
50
+ constraint), a **documented outer driver** (operator script or manual
51
+ re-invocation with `start-from` / refreshed `resume_brief`) is
52
+ **deterministically equivalent** provided: same intersected phase order, same
53
+ isolation + strict-proof attestation per phase (**DEC-0038**), same stop
54
+ reasons, and same `resume_brief` + `state.md` refresh at every boundary.
55
+ Operators must follow the runbook recipe
56
+ (**`docs/engineering/runbook.md`** § Continuous `/auto` + backlog drain).
57
+
58
+ **Deterministic stop matrix** (see also architecture `# US-0088`):
59
+
60
+ | Condition | Behavior |
61
+ |-----------|----------|
62
+ | Next phase exists, no hard stop | **Continue** — preflight US-0069, spawn next phase |
63
+ | `decision_gate` | **Stop** (non-suppressible) |
64
+ | `error` / missing critical input | **Stop** (non-suppressible) |
65
+ | `AUTO_PAUSE_REQUEST` / `pause` | **Stop** at safe boundary (non-suppressible) |
66
+ | `AUTO_LOOP_MAX_CYCLES` / `loop_max` | **Stop** (non-suppressible) |
67
+ | `blocked` (sync/scope gate) | **Stop** (non-suppressible) |
68
+ | US lifecycle DONE / sprint segment complete | **Stop** segment; `AUTO_BACKLOG_DRAIN=1` may advance to next OPEN story (recompute phase plan — **reference Step 5**) |
69
+ | `BACKLOG_MAX_STORIES_REACHED` | **Stop** (non-suppressible) |
70
+
71
+ `stop_reason` vocabulary: `completed`, `decision_gate`, `missing_input`,
72
+ `pause_request`, `loop_max`, `error`, `blocked`.
73
+
36
74
  ## Full specification (US-0080 / DEC-0062)
37
75
 
38
76
  Long prose, expanded mode semantics, and **Steps 1–13** detail live in
@@ -101,16 +139,37 @@ Selectors and reinstatement: see reference. Phase-plan reason codes include
101
139
  `PHASE_POLICY_CONFLICT`, `PHASE_PLAN_UNKNOWN_PHASE`, `START_FROM_PHASE_PLAN_EMPTY_INTERSECTION`.
102
140
 
103
141
  Phase boundary visibility (**AC-10**): record `resolved_phase_plan` snapshot,
104
- `skipped_phases`, `phase_boundary`, `next_scheduled_phase` on `state.md`.
142
+ `skipped_phases`, `phase_boundary`, `next_scheduled_phase` on `state.md`. For
143
+ bug-queue segments, also record **`segment_work_item_kind`**, **`active_bug_id`**,
144
+ **`bug_queue_position`**, **`bug_queue_remaining`**, **`backlog_drain_active`**,
145
+ **`bug_queue_active`** per **`docs/engineering/architecture.md`** **`# US-0087`**
146
+ and **`docs/engineering/auto-orchestration-reference.md`**.
105
147
 
106
148
  ## Inputs
107
149
 
108
150
  Merged scratchpad (**US-0073** / **DEC-0055**), automation flags (`AUTO_*`, `SECURITY_REVIEW`,
109
151
  `TEAM_*`), phase-plan keys `AUTO_PHASE_PLAN`, `AUTO_PHASE_EXCLUDE`, `AUTO_PHASE_INCLUDE`,
110
152
  `AUTO_PHASE_PROFILE`, `AUTO_PHASE_HIGH_RISK_ACK`, product/engineering docs,
111
- optional `start-from=<phase>`, optional `--execute-bulk`, `handoffs/resume_brief.md`,
153
+ optional `start-from=<phase>`, optional **`bug-target=BUG-####`** or
154
+ **`bug-target=all-open`**, optional `--execute-bulk`, `handoffs/resume_brief.md`,
112
155
  `docs/engineering/state.md`.
113
156
 
157
+ ## Automation remote routing contract (US-0086)
158
+
159
+ - Automation-only gate: `AUTO_REMOTE_AUTOMATION_PROFILE=deterministic_v1` enables
160
+ target routing; `off` keeps manual/local behavior unchanged.
161
+ - Explicit intent literal is constrained to: `start container <target_id>`.
162
+ - Deterministic precedence when profile is enabled:
163
+ 1. explicit intent target id resolution,
164
+ 2. canonical target validation (`targets[].id` exists and is enabled),
165
+ 3. documented heuristic fallback,
166
+ 4. local default when no remote target is selected.
167
+ - Fail-closed reason codes (do not overload):
168
+ `REMOTE_AUTOMATION_MODE_OFF`, `REMOTE_TARGET_UNKNOWN`,
169
+ `REMOTE_TARGET_DISABLED`, `REMOTE_TARGET_UNROUTABLE`.
170
+ - Mode-off guardrail: never silently reroute `TEST_COMMAND` to remote when
171
+ automation profile is disabled.
172
+
114
173
  ## Canonical status contract (US-0045)
115
174
 
116
175
  Story status authority: `docs/product/backlog.md` only; do not infer readiness from
@@ -124,14 +183,43 @@ QA loop handoffs when applicable, continuation breadcrumbs including `resolution
124
183
 
125
184
  ## Stop conditions
126
185
 
127
- Decision gate, missing critical input, `AUTO_PAUSE_REQUEST` at safe boundary,
128
- `AUTO_LOOP_MAX_CYCLES` with unresolved defects.
186
+ Deterministic stop reasons (see **Stop matrix** in `## Continuous multi-phase
187
+ execution (US-0088)` above): `completed`, `decision_gate`, `missing_input`,
188
+ `pause_request`, `loop_max`, `error`, `blocked`.
129
189
 
130
190
  ## Optional backlog-drain mode (US-0044 / DEC-0022)
131
191
 
132
192
  Canonical controls: `AUTO_BACKLOG_DRAIN`, `AUTO_BACKLOG_MAX_STORIES`, `AUTO_BACKLOG_ON_BLOCK`,
133
- `AUTO_STORY_SELECTION`. Reason codes include `BACKLOG_MAX_STORIES_REACHED`. Full semantics:
134
- reference.
193
+ `AUTO_STORY_SELECTION`. When `AUTO_BACKLOG_DRAIN=1`, each story advances through
194
+ **multiple phases** until its terminal boundary (**reference Step 5**); the
195
+ orchestrator **recomputes** the materialized phase plan at each **story boundary**
196
+ and selects the **next eligible OPEN story** per `AUTO_STORY_SELECTION`.
197
+ Reason codes include `BACKLOG_MAX_STORIES_REACHED`. Full semantics: reference.
198
+
199
+ ## Optional bug-queue mode (US-0087)
200
+
201
+ Canonical **argv** literals (exact strings; **no aliases** in v1):
202
+ - **`bug-target=BUG-####`** (example: **`bug-target=BUG-0007`**) — single defect from
203
+ **`docs/product/backlog.md`** **`## Bug issues (canonical)`** with status **OPEN**.
204
+ - **`bug-target=all-open`** — deterministic **OPEN**-only queue, ascending **numeric**
205
+ **`BUG-####`** sort, optional cap **`AUTO_BUG_MAX_ITEMS`** (see reference).
206
+
207
+ Scratchpad keys (**default-off**): **`AUTO_BUG_QUEUE`**, **`AUTO_BUG_TARGET`**,
208
+ **`AUTO_BUG_MAX_ITEMS`**, **`AUTO_BUG_ON_BLOCK`** — full semantics: reference +
209
+ **`architecture.md`** **`# US-0087`**.
210
+
211
+ **Scheduler mutex**: if merged scratchpad has **`AUTO_BACKLOG_DRAIN=1`** **and**
212
+ **`AUTO_BUG_QUEUE=1`** **and** this invocation has **no** explicit **`bug-target=`**
213
+ argv token → fail closed with **`AUTO_SCHEDULER_CONFLICT`** (use
214
+ **`[AUTO_RESUME_ERROR] AUTO_SCHEDULER_CONFLICT: ...`** form per reference). When
215
+ **`bug-target=`** argv is present, it **selects** the bug scheduler for this run;
216
+ **`AUTO_BACKLOG_DRAIN`** must **not** also drive story selection for that same
217
+ materialized run.
218
+
219
+ Fail-closed codes (orthogonal to existing resume/phase codes; do **not** overload):
220
+ - **`AUTO_BUG_QUEUE_EMPTY`** — **`all-open`** (or equivalent) and zero **OPEN** bugs.
221
+ - **`AUTO_BUG_TARGET_UNKNOWN`** — malformed id, wrong pattern, or id missing from canonical bug section.
222
+ - **`AUTO_BUG_TARGET_NOT_OPEN`** — known id exists but status is not **OPEN** (e.g. **DONE**).
135
223
 
136
224
  ## Optional bulk execute mode (US-0047 / DEC-0024)
137
225
 
@@ -152,12 +240,19 @@ Phase-completion boundary evaluation only. **Guarded auto-push eligibility chain
152
240
 
153
241
  ## Deterministic resume-source precedence
154
242
 
155
- Resolve start phase in strict order:
243
+ Resolve nominal start phase and scheduler inputs in strict order (**`US-0087`**
244
+ extends scratchpad vs **`resume_brief`** ordering — full matrix: reference):
156
245
 
157
246
  1. Explicit `/auto start-from=<phase>`
158
- 2. `handoffs/resume_brief.md`
159
- 3. Conservative `docs/engineering/state.md` fallback
160
- 4. Fail fast on ambiguity/conflict/unrecoverable inputs
247
+ 2. Explicit **`bug-target=`** argv token when present (parsed **before** merged
248
+ scratchpad scheduler keys; selects bug scheduler for this run).
249
+ 3. Merged scratchpad (**`US-0073`** / **`DEC-0055`**) — including **`AUTO_BACKLOG_DRAIN`**,
250
+ **`AUTO_BUG_QUEUE`**, **`AUTO_BUG_TARGET`**, etc.
251
+ 4. `handoffs/resume_brief.md`
252
+ 5. Conservative `docs/engineering/state.md` fallback
253
+ 6. Fail fast on ambiguity/conflict/unrecoverable inputs (including
254
+ **`AUTO_SCHEDULER_CONFLICT`** when both schedulers are enabled in scratchpad
255
+ without **`bug-target=`** argv resolution).
161
256
 
162
257
  If `resume_brief.md` is present but stale or unparseable, fail fast instead
163
258
  of silently falling back.
@@ -177,22 +272,42 @@ Required codes:
177
272
  - `STATE_PHASE_AMBIGUOUS`
178
273
  - `STATE_PHASE_UNRECOVERABLE`
179
274
 
275
+ Bug-queue extensions (**`US-0087`**; same **`[AUTO_RESUME_ERROR]`** envelope when
276
+ used for resume/materialization failures):
277
+
278
+ - `AUTO_SCHEDULER_CONFLICT`
279
+ - `AUTO_BUG_QUEUE_EMPTY`
280
+ - `AUTO_BUG_TARGET_UNKNOWN`
281
+ - `AUTO_BUG_TARGET_NOT_OPEN`
282
+
180
283
  ## Steps (compact; full detail in reference)
181
284
 
182
285
  1. Read automation flags from merged scratchpad and **materialize the resolved
183
286
  phase plan** per **Configurable phase selection policy (US-0070 / DEC-0052)**; append
184
287
  plan breadcrumbs to `docs/engineering/state.md` **before** first spawn.
185
- 2. Parse `start-from` / `--execute-bulk`; resolve nominal start phase; intersect with plan.
288
+ 2. Parse `start-from` / **`bug-target=`** / `--execute-bulk`; resolve scheduler
289
+ mutex (**`AUTO_SCHEDULER_CONFLICT`** when applicable); resolve nominal start phase;
290
+ intersect with plan.
186
291
  3. Record continuation metadata (`invocation_mode=auto`, `requested_start_from`,
187
292
  `resolved_start_phase`, `resolution_source`, `resolution_status`, `timestamp`).
188
293
  4. Spawn fresh subagents per intersected schedule; enforce **US-0069** preflight/post checks.
189
- 5. Implementation loop, pause, stop breadcrumbs (`stop_reason` such as `completed|decision_gate|missing_input|pause_request|loop_max`, `stop_phase`, `timestamp`), `resume_brief` updates — reference.
190
- 6. 11a. Isolation evidence verification at each boundary.
191
- 7. 11b. At each phase boundary, verify strict runtime attestation tuple exists
294
+ 5. **Multi-phase continuation** (normative detail: **reference Step 5** in
295
+ **`docs/engineering/auto-orchestration-reference.md`** `## Steps` item 5):
296
+ advance through **all remaining phases** in the intersected resolved schedule
297
+ order until a **deterministic stop condition** fires (see **Stop matrix** in
298
+ `## Continuous multi-phase execution (US-0088)` above). When
299
+ `AUTO_BACKLOG_DRAIN=1`, repeat the story lifecycle for the next eligible OPEN
300
+ story, **reloading** scratchpad and **recomputing** the materialized phase
301
+ plan at each story boundary. Outer-driver equivalence applies when a single
302
+ invocation cannot schedule multiple subagent turns (**AC-1 Option B**).
303
+ `stop_reason`: `completed|decision_gate|missing_input|pause_request|loop_max|error|blocked`.
304
+ 6. Isolation evidence verification at each boundary (**reference** step 11a).
305
+ 7. At each phase boundary, verify strict runtime attestation tuple exists
192
306
  and is valid for the completed phase (`orchestrator_run_id`, `runtime_proof_id`,
193
- `phase_id`, `role`, `proof_issued_at`, `proof_ttl_seconds`, `proof_hash`).
194
- 8. Sync verdict recording when eligible — reference.
195
- 9. Backlog-drain / bulk per-item summaries when enabled — reference.
307
+ `phase_id`, `role`, `proof_issued_at`, `proof_ttl_seconds`, `proof_hash`)
308
+ (**reference** step 11b).
309
+ 8. Sync verdict recording when eligible — reference step 12.
310
+ 9. Backlog-drain / bulk per-item summaries when enabled — reference step 13.
196
311
 
197
312
  ## Backward compatibility
198
313
 
@@ -0,0 +1,141 @@
1
+ ---
2
+ description: "Caveman mode (US-0089) — optional response-side terse voice, default off"
3
+ globs: ["**/*"]
4
+ ---
5
+
6
+ # Caveman mode (US-0089)
7
+
8
+ This rule composes an optional **response-side** terse / imperative assistant
9
+ voice. It is **default off**. When `CAVEMAN_MODE` is unset or `0`, this rule
10
+ adds **zero** behavioral change and the assistant responds exactly as it did
11
+ pre-US-0089.
12
+
13
+ Inspired by JuliusBrussee/caveman (MIT). External reference only; not vendored.
14
+
15
+ ## Scratchpad gate (authoritative across subagent spawns)
16
+
17
+ Read the merged scratchpad (`.cursor/scratchpad.md`, then optional
18
+ `.cursor/scratchpad.local.md` overrides per **DEC-0055**) for these keys:
19
+
20
+ - `CAVEMAN_MODE=0|1` — default `0`. Absence is equivalent to `0`.
21
+ - `CAVEMAN_LEVEL=lite|full|ultra` — default empty.
22
+ - With `CAVEMAN_MODE=0`: inert regardless of value.
23
+ - With `CAVEMAN_MODE=1` and `CAVEMAN_LEVEL` empty: treat as `full`
24
+ (mid-tier default, matching upstream reference).
25
+ - With `CAVEMAN_MODE=1` and a listed level: apply that level.
26
+ - With `CAVEMAN_MODE=1` and any other non-empty value: fail closed with
27
+ deterministic reason code `CAVEMAN_LEVEL_UNKNOWN` and fall back to
28
+ pre-US-0089 voice (no terseness applied) while continuing the turn.
29
+ - `CAVEMAN_COMPRESS_INPUT=0|1` — **reserved for US-0090**; inert in US-0089;
30
+ no behavior until the compression story ships.
31
+ - `CAVEMAN_FILE_SCOPE=` — **reserved for US-0090**; inert in US-0089; no
32
+ behavior until the compression story ships.
33
+
34
+ Scratchpad values are **authoritative across subagent spawns**. Session
35
+ toggle phrases (see below) are overlays for the current conversation only
36
+ and do NOT persist across a fresh subagent context.
37
+
38
+ ## Literal-region invariant (9-zone hard MUST)
39
+
40
+ When `CAVEMAN_MODE=1`, the following output regions remain **byte-literal**
41
+ (no abbreviation, no rewording, no casing change). This rule is phrased as
42
+ **MUST**, not SHOULD:
43
+
44
+ 1. **Fenced code blocks** — both plain triple-backtick blocks and CODE
45
+ REFERENCE blocks of the form `startLine:endLine:filepath`. Content, line
46
+ numbers, filepath, language tags, and whitespace preserved.
47
+ 2. **File / path strings** — anything matching
48
+ `` `[\w./-]+\.(md|py|ps1|sh|json|mdc|ts|tsx|js|jsx|yml|yaml|toml|ini|env|example|manifest)` ``
49
+ or enclosed in backticks that points to a repo path. Preserve extension
50
+ and case.
51
+ 3. **AC checklist items** — bullets of form `- [ ]` or `- [x]` and their
52
+ entire text (AC-1..AC-N).
53
+ 4. **Reason codes** — `ALL_CAPS_WITH_UNDERSCORES` tokens such as
54
+ `PHASE_CONTEXT_ISOLATION_VIOLATION`, `RUNTIME_PROOF_MISSING`,
55
+ `AUTO_RESUME_ERROR`, `AUTO_SCHEDULER_CONFLICT`, `REMOTE_TARGET_UNKNOWN`,
56
+ `CAVEMAN_LEVEL_UNKNOWN`, `INTAKE_PERSISTENCE_BLOCKED`.
57
+ 5. **IDs** — `US-xxxx`, `DEC-xxxx`, `R-xxxx`, `BUG-####`, `S0xxx`, `T-xxx`.
58
+ 6. **Contract markers** — `[BUG_VALIDATION_OK]`,
59
+ `[INTAKE_EVIDENCE_VALIDATION_OK]`, `[SCRATCHPAD_PAIR_OK]`,
60
+ `[ARTIFACT_ORDERING_ANCHOR_AMBIGUOUS]`, `[CODEBASE_MAP_OK]`, and siblings.
61
+ 7. **Strict-proof tuple fields** — `orchestrator_run_id`, `runtime_proof_id`,
62
+ `proof_hash`, `proof_issued_at`, `proof_ttl_seconds`, `phase_id`, `role`
63
+ (DEC-0038).
64
+ 8. **Isolation evidence fields** — `fresh_context_marker`, `evidence_ref`,
65
+ `timestamp` (DEC-0029).
66
+ 9. **Commit / git refs** — quoted `git commit` messages, branch names, SHAs,
67
+ `HEAD`, tag names.
68
+
69
+ Forbidden "garbling" examples (never permitted even under `ultra`): dropping
70
+ the `US-` prefix from an ID, lowercasing a reason code, collapsing a fenced
71
+ code block into a bullet, truncating a path mid-filename, abbreviating a
72
+ proof hash.
73
+
74
+ ## Non-suppressible gate vocabulary (inherited from US-0088)
75
+
76
+ Caveman voice MUST NOT remove or abbreviate the following gate tokens — they
77
+ render byte-literal even under `CAVEMAN_LEVEL=ultra`:
78
+
79
+ - `decision_gate`
80
+ - `error`
81
+ - `pause`
82
+ - `loop_max`
83
+ - `blocked`
84
+ - `missing input`
85
+ - `[BUG_VALIDATION_OK]`
86
+ - `[INTAKE_EVIDENCE_VALIDATION_OK]`
87
+ - `[SCRATCHPAD_PAIR_OK]`
88
+
89
+ ## Operator toggle phrases (canonical set)
90
+
91
+ | Phrase | Effect |
92
+ |--------|--------|
93
+ | `caveman on` | Enable Caveman voice for the session (overlay). Effective from the next assistant turn. |
94
+ | `caveman off` | Disable Caveman voice for the session (overlay). Effective from the next assistant turn. |
95
+ | `stop caveman` | Alias for `caveman off`. |
96
+ | `normal mode` | Alias for `caveman off`. |
97
+ | `caveman: lite|full|ultra` | Set level for the session (implies `caveman on`). Effective from the next assistant turn. Accepts the three literal tokens `caveman: lite`, `caveman: full`, `caveman: ultra`. |
98
+
99
+ Determinism rules:
100
+
101
+ - Scratchpad `CAVEMAN_MODE` / `CAVEMAN_LEVEL` are **authoritative across
102
+ subagent spawns**; session toggles are overlays for the current
103
+ conversation only and do NOT persist across a fresh subagent context.
104
+ - Within a session, the **last explicit toggle wins**.
105
+ - A mid-turn toggle applies **from the next turn onward**; current-turn
106
+ machine-verifiable artifacts (gate messages, reason codes, strict-proof
107
+ tuples, isolation-evidence fields) remain literal regardless of the
108
+ toggle.
109
+ - Ambiguous phrases (`be caveman-lite`, `quiet caveman`, `cave man off`,
110
+ etc.) are **not recognized** — only the exact literal matches above fire.
111
+
112
+ ## Composition (non-substitution) with TOKEN_PROFILE
113
+
114
+ `TOKEN_PROFILE` controls context breadth. `CAVEMAN_MODE` controls reply
115
+ voice. Neither substitutes for the other; setting one does not change the
116
+ other. Combine freely.
117
+
118
+ ## Default-off invariant
119
+
120
+ With `CAVEMAN_MODE=0` or absent, this rule adds zero behavioral change:
121
+ existing command strings, gate ordering, spawn-only phrasing (BUG-0006),
122
+ contract-test token lists, `AUTO_QUIET` non-suppressible vocabulary
123
+ (US-0088), user-visible ID metadata (US-0071), strict-proof tuples
124
+ (DEC-0038), and isolation evidence fields (DEC-0029) all remain unchanged.
125
+
126
+ ## Non-goals (US-0089)
127
+
128
+ - No input-side file compression. `CAVEMAN_COMPRESS_INPUT` and
129
+ `CAVEMAN_FILE_SCOPE` are documented no-ops here; US-0090 owns that
130
+ vertical.
131
+ - No change to `TOKEN_PROFILE` (DEC-0035 / US-0080), context packs, archive
132
+ policy, or phase-context slimming.
133
+ - No rewrite of canonical artifacts (`docs/product/backlog.md`,
134
+ `docs/product/acceptance.md`, `docs/engineering/state.md` schema,
135
+ `docs/engineering/decisions.md`, DEC files).
136
+ - No new npm / Python dependencies. No `package.json` edit.
137
+ - No vendor plugin install. No package-manager install recipe is surfaced;
138
+ the JuliusBrussee/caveman reference is documentation-only.
139
+ - No change to spawn-only orchestration (US-0048 / DEC-0029 / BUG-0006),
140
+ strict runtime proof (DEC-0038), `AUTO_QUIET` non-suppressible list
141
+ (US-0088), or US-0071 visible-metadata rules.
@@ -26,6 +26,13 @@ globs: ["**/*"]
26
26
  - Remote config security (DEC-0016): never commit secret literals (tokens,
27
27
  passwords, private keys) in `.cursor/remote.json`; use environment-variable
28
28
  references only (for example `tokenEnv`, `passwordEnv`, `privateKeyPathEnv`).
29
+ - `.env` exclusion (DEC-0071 / US-0085): do not open, attach, read, search
30
+ inside, or index `.env` or `.env.*` files. Use environment variable names
31
+ in prose only. Operators source `.env` outside agent context.
32
+ - Automation remote routing (US-0086): when `AUTO_REMOTE_AUTOMATION_PROFILE=off`,
33
+ keep local behavior and never silently reroute `TEST_COMMAND` to remote.
34
+ Explicit NL routing is limited to `start container <target_id>` and unknown or
35
+ disabled targets must fail closed with documented reason codes.
29
36
  - Performance by default: avoid obvious N+1 loops, repeated expensive work, and
30
37
  unnecessary I/O in hot paths.
31
38
  - Documentation by default: update relevant docs when behavior, setup, or usage