@tduyng/pi-devos 0.0.0-stage → 0.14.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 (109) hide show
  1. package/CHANGELOG.md +1421 -0
  2. package/LICENSE +201 -0
  3. package/README.md +206 -2
  4. package/package.json +44 -4
  5. package/plugins/devos/agents/reader.md +27 -0
  6. package/plugins/devos/agents/verifier.md +155 -0
  7. package/plugins/devos/pi/extension/devos.ts +605 -0
  8. package/plugins/devos/scripts/check-evidence-router.sh +140 -0
  9. package/plugins/devos/scripts/evidence-router.py +254 -0
  10. package/plugins/devos/scripts/gates/check-dod-core.sh +285 -0
  11. package/plugins/devos/scripts/gates/check-dod.sh +38 -0
  12. package/plugins/devos/scripts/gates/check-implementation-boundary.sh +99 -0
  13. package/plugins/devos/scripts/gates/check-port-source.sh +134 -0
  14. package/plugins/devos/scripts/gates/check-report-locations.sh +148 -0
  15. package/plugins/devos/scripts/gates/check-scenario-coverage.sh +104 -0
  16. package/plugins/devos/scripts/gates/gate-check.mjs +204 -0
  17. package/plugins/devos/scripts/gates/phase-gate.sh +208 -0
  18. package/plugins/devos/scripts/gates/plan-template-check.py +141 -0
  19. package/plugins/devos/scripts/gates/run-gate.sh +148 -0
  20. package/plugins/devos/scripts/gates/spec-contract.sh +19 -0
  21. package/plugins/devos/scripts/gates/spec-template-check.py +152 -0
  22. package/plugins/devos/scripts/gates/suite/01-dod.sh +485 -0
  23. package/plugins/devos/scripts/gates/suite/02-integrity.sh +310 -0
  24. package/plugins/devos/scripts/gates/suite/03-archetype.sh +255 -0
  25. package/plugins/devos/scripts/gates/suite/04-spec-validator.sh +183 -0
  26. package/plugins/devos/scripts/gates/suite/05-requires.sh +360 -0
  27. package/plugins/devos/scripts/gates/suite/06-clarify-adapters.sh +435 -0
  28. package/plugins/devos/scripts/gates/suite/07-lint-evals.sh +350 -0
  29. package/plugins/devos/scripts/gates/suite/08-converge.sh +591 -0
  30. package/plugins/devos/scripts/gates/suite/09-quality.sh +516 -0
  31. package/plugins/devos/scripts/gates/suite/10-eval-harness.sh +679 -0
  32. package/plugins/devos/scripts/gates/test-gates.sh +76 -0
  33. package/plugins/devos/scripts/gates/test-integrity-rubric.sh +152 -0
  34. package/plugins/devos/scripts/gates/test-phase-gate.sh +116 -0
  35. package/plugins/devos/skills/absorb/SKILL.md +75 -0
  36. package/plugins/devos/skills/absorb/references/distill.md +67 -0
  37. package/plugins/devos/skills/absorb/scripts/check-refs.sh +108 -0
  38. package/plugins/devos/skills/absorb/scripts/knowledge.py +258 -0
  39. package/plugins/devos/skills/build/SKILL.md +71 -0
  40. package/plugins/devos/skills/build/references/advanced-routing.md +19 -0
  41. package/plugins/devos/skills/build/references/defect.md +17 -0
  42. package/plugins/devos/skills/build/references/exposure.md +28 -0
  43. package/plugins/devos/skills/build/references/hard.md +39 -0
  44. package/plugins/devos/skills/build/references/refactor.md +66 -0
  45. package/plugins/devos/skills/build/references/routes.md +56 -0
  46. package/plugins/devos/skills/build/references/scale.md +84 -0
  47. package/plugins/devos/skills/build/references/spike.md +19 -0
  48. package/plugins/devos/skills/build/scripts/construct-census.py +204 -0
  49. package/plugins/devos/skills/build/scripts/dep-order.py +297 -0
  50. package/plugins/devos/skills/build/scripts/ledger.sh +228 -0
  51. package/plugins/devos/skills/build/scripts/route.sh +5 -0
  52. package/plugins/devos/skills/build/scripts/secret-scan.sh +121 -0
  53. package/plugins/devos/skills/build/scripts/toolchain-preflight.py +302 -0
  54. package/plugins/devos/skills/frame/SKILL.md +54 -0
  55. package/plugins/devos/skills/frame/references/template.md +115 -0
  56. package/plugins/devos/skills/frame/scripts/survey.sh +44 -0
  57. package/plugins/devos/skills/implement/SKILL.md +36 -0
  58. package/plugins/devos/skills/implement/references/conditional-plan.md +17 -0
  59. package/plugins/devos/skills/implement/references/debug-loop.md +7 -0
  60. package/plugins/devos/skills/implement/references/dod.md +37 -0
  61. package/plugins/devos/skills/implement/references/implement.md +54 -0
  62. package/plugins/devos/skills/implement/references/manual-gates.md +16 -0
  63. package/plugins/devos/skills/implement/references/plan.md +142 -0
  64. package/plugins/devos/skills/implement/references/resume.md +9 -0
  65. package/plugins/devos/skills/implement/references/scale.md +86 -0
  66. package/plugins/devos/skills/implement/references/verify-close.md +62 -0
  67. package/plugins/devos/skills/implement/references/visual-verification.md +7 -0
  68. package/plugins/devos/skills/implement/scripts/check-converge.sh +147 -0
  69. package/plugins/devos/skills/implement/scripts/equivalence-check.sh +140 -0
  70. package/plugins/devos/skills/implement/scripts/manifest-queue.sh +185 -0
  71. package/plugins/devos/skills/implement/scripts/ops-log.sh +58 -0
  72. package/plugins/devos/skills/implement/scripts/pilot-consistency.py +173 -0
  73. package/plugins/devos/skills/implement/scripts/validate-spec.sh +220 -0
  74. package/plugins/devos/skills/init/SKILL.md +100 -0
  75. package/plugins/devos/skills/init/references/archetype-sections.md +15 -0
  76. package/plugins/devos/skills/init/references/context.md +42 -0
  77. package/plugins/devos/skills/init/references/conventions-template.md +153 -0
  78. package/plugins/devos/skills/init/references/reverse-engineer.md +3 -0
  79. package/plugins/devos/skills/init/references/rule-format.md +58 -0
  80. package/plugins/devos/skills/init/references/shape-model.md +29 -0
  81. package/plugins/devos/skills/init/scripts/detect-archetype.py +461 -0
  82. package/plugins/devos/skills/init/scripts/render-rule.py +114 -0
  83. package/plugins/devos/skills/init/scripts/reverse-engineer.sh +162 -0
  84. package/plugins/devos/skills/learn/SKILL.md +29 -0
  85. package/plugins/devos/skills/learn/references/destinations.md +43 -0
  86. package/plugins/devos/skills/learn/references/scoring.md +26 -0
  87. package/plugins/devos/skills/review/SKILL.md +54 -0
  88. package/plugins/devos/skills/review/references/comments.md +13 -0
  89. package/plugins/devos/skills/review/references/gaps.md +26 -0
  90. package/plugins/devos/skills/review/references/reviewer.md +124 -0
  91. package/plugins/devos/skills/review/references/routing.md +35 -0
  92. package/plugins/devos/skills/review/scripts/__pycache__/prepare.cpython-313.pyc +0 -0
  93. package/plugins/devos/skills/review/scripts/prepare.py +763 -0
  94. package/plugins/devos/skills/spec/SKILL.md +57 -0
  95. package/plugins/devos/skills/spec/references/prototype.md +21 -0
  96. package/plugins/devos/skills/spec/references/question-craft.md +47 -0
  97. package/plugins/devos/skills/spec/references/roadmap-link.md +5 -0
  98. package/plugins/devos/skills/spec/references/write-spec.md +128 -0
  99. package/plugins/devos/skills/spec/scripts/clarify.sh +173 -0
  100. package/plugins/devos/skills/status/SKILL.md +67 -0
  101. package/plugins/devos/skills/status/references/cost.md +38 -0
  102. package/plugins/devos/skills/status/scripts/artifact-budgets.sh +88 -0
  103. package/plugins/devos/skills/status/scripts/check-requires.py +556 -0
  104. package/plugins/devos/skills/status/scripts/context-cost.sh +89 -0
  105. package/plugins/devos/skills/status/scripts/convention-usage.sh +184 -0
  106. package/plugins/devos/skills/status/scripts/findings-summary.sh +112 -0
  107. package/plugins/devos/skills/status/scripts/quality-correlation.sh +259 -0
  108. package/plugins/devos/skills/status/scripts/sizing-calibration.sh +71 -0
  109. package/plugins/devos/skills/status/scripts/spec-diff.sh +137 -0
@@ -0,0 +1,485 @@
1
+ # --- check-dod-core.sh ---------------------------------------------------
2
+ spec="devos/specs/2026-01-01-demo"
3
+ mkdir -p "$spec/verifications"
4
+
5
+ t="$tmp/transcript.txt"
6
+
7
+ echo "working on it, no verdict yet" > "$t"
8
+ bash "$DOD" "$t"; check "dod: no DONE claim allows" 0 $?
9
+
10
+ echo "Verdict: DONE" > "$t"
11
+ bash "$DOD" "$t" 2>/dev/null; check "dod: DONE without spec name blocks" 2 $?
12
+
13
+ echo "Verdict: DONE: $spec" > "$t"
14
+ bash "$DOD" "$t" 2>/dev/null; check "dod: DONE with missing report blocks" 2 $?
15
+
16
+ printf '# Verification\n> 2026-01-01 | Completeness: **CLEAN** | Quality: **PASS**\n' > "$spec/verifications/verification.md"
17
+ bash "$DOD" "$t"; check "dod: CLEAN+PASS report allows" 0 $?
18
+
19
+ # This gate's own message names the format as `Verdict: DONE: devos/specs/[name]`.
20
+ # A model that echoes the reminder after the real verdict used to have the echo
21
+ # read as the verdict and get blocked for repeating the gate's words; the last
22
+ # matching line is not necessarily the one that names a spec.
23
+ printf 'Verdict: DONE: %s\n\nFormat reminder: `Verdict: DONE: devos/specs/[name]`\n' "$spec" > "$t"
24
+ bash "$DOD" "$t"; check "dod: format reminder after a valid verdict allows" 0 $?
25
+
26
+ echo "Verdict: DONE" > "$t"
27
+ bash "$DOD" "$t" 2>/dev/null; check "dod: no line names a spec still blocks" 2 $?
28
+
29
+ # Restore the naming verdict for the report-state tests below, which read the
30
+ # report, not the transcript.
31
+ echo "Verdict: DONE: $spec" > "$t"
32
+
33
+ printf '# Verification\n> 2026-01-01 | Completeness: **CLEAN** | Quality: **FAIL**\n' > "$spec/verifications/verification.md"
34
+ bash "$DOD" "$t" 2>/dev/null; check "dod: FAIL report blocks" 2 $?
35
+
36
+ printf '# Verification\n> 2026-01-01 | Completeness: **HAS ISSUES** | Quality: **PASS**\n' > "$spec/verifications/verification.md"
37
+ bash "$DOD" "$t" 2>/dev/null; check "dod: HAS ISSUES report blocks" 2 $?
38
+
39
+ printf '# Verification\n> 2026-01-01 | Completeness: NOT CLEAN | Quality: NOT PASS\n' > "$spec/verifications/verification.md"
40
+ bash "$DOD" "$t" 2>/dev/null; check "dod: negated CLEAN and PASS report blocks" 2 $?
41
+
42
+ printf 'looks great, ship it\n' > "$spec/verifications/verification.md"
43
+ bash "$DOD" "$t" 2>/dev/null; check "dod: malformed report (no verdict line) blocks" 2 $?
44
+
45
+ bash "$DOD" "$tmp/nonexistent.txt"; check "dod: missing transcript allows" 0 $?
46
+
47
+ arch="devos/specs/archive/2026-01-01-demo"
48
+ mkdir -p "$arch/verifications"
49
+ printf '# Verification\n> 2026-01-01 | Completeness: **CLEAN** | Quality: **PASS**\n' > "$arch/verifications/verification.md"
50
+ echo "Verdict: DONE: $arch" > "$t"
51
+ bash "$DOD" "$t"; check "dod: archived spec path allows" 0 $?
52
+
53
+ echo "Verdict: DONE: devos/specs/archive/absent-spec" > "$t"
54
+ bash "$DOD" "$t" 2>/dev/null; check "dod: archived path without report blocks" 2 $?
55
+
56
+ echo "Verdict: DONE: devos/specs/archive/..." > "$t"
57
+ bash "$DOD" "$t" 2>/dev/null; check "dod: ellipsis placeholder is the missing-spec case, not a report check" 2 $?
58
+ echo "Verdict: DONE: devos/specs/archive/verifications/verification.md" > "$t"
59
+ bash "$DOD" "$t" 2>/dev/null; check "dod: report path pasted as spec blocks as missing-spec (no verifications/verifications)" 2 $?
60
+ [[ "$(bash "$DOD" "$t" 2>&1 >/dev/null)" != *"verifications/verifications"* ]]
61
+ check "dod: report-path-as-spec message never doubles the verifications dir" 0 $?
62
+
63
+ # --- check-dod-core.sh: a pre-existing failure has to be shown --------------
64
+ # The DoD's rationalization table answers "the 2 failures are unrelated" with
65
+ # "then prove it". Until Phase B recorded a baseline there was nothing to point
66
+ # at, so the claim was accepted on the implementer's word.
67
+ pe="$tmp/preexisting"
68
+ mkdir -p "$pe/$spec/verifications"
69
+ (cd "$pe" && git init -q . && git config user.email t@t && git config user.name t)
70
+ pet="$pe/transcript.txt"
71
+ echo "Verdict: DONE: $spec" >"$pet"
72
+ clean_report='# Verification\n> 2026-01-01 | Completeness: **CLEAN** | Quality: **PASS**\n'
73
+
74
+ printf "$clean_report" >"$pe/$spec/verifications/verification.md"
75
+ (cd "$pe" && bash "$DOD" "$pet"); check "dod: a report making no such claim needs no baseline" 0 $?
76
+
77
+ printf "${clean_report}No pre-existing failures.\n" >"$pe/$spec/verifications/verification.md"
78
+ (cd "$pe" && bash "$DOD" "$pet"); check "dod: a negated pre-existing claim needs no baseline" 0 $?
79
+
80
+ printf "${clean_report}No pre-existing failures. 2 failures are pre-existing.\n" >"$pe/$spec/verifications/verification.md"
81
+ (cd "$pe" && bash "$DOD" "$pet" 2>/dev/null); check "dod: mixed negated and affirmative claims block" 2 $?
82
+
83
+ printf "${clean_report}2 failures are pre-existing on this branch.\n" >"$pe/$spec/verifications/verification.md"
84
+ (cd "$pe" && bash "$DOD" "$pet" 2>/dev/null); check "dod: 'pre-existing' with no baseline.md blocks" 2 $?
85
+
86
+ printf 'node test.js -> exit 1 (2 failed)\n' >"$pe/$spec/verifications/baseline.md"
87
+ (cd "$pe" && bash "$DOD" "$pet"); check "dod: the same claim with a baseline allows" 0 $?
88
+
89
+ rm -f "$pe/$spec/verifications/baseline.md"
90
+ printf "${clean_report}The suite was already failing before this work.\n" >"$pe/$spec/verifications/verification.md"
91
+ (cd "$pe" && bash "$DOD" "$pet" 2>/dev/null); check "dod: 'already failing' is the same claim in other words" 2 $?
92
+
93
+ # --- check-dod-core.sh: a verdict is about the code it judged ----------------
94
+ # The report records the commit it read. Nothing re-runs the verifier when a
95
+ # later edit lands, so without that field a CLEAN report outlives the code it
96
+ # was true of, and every green report reads the same whether it still holds.
97
+ #
98
+ # Scoped to the plan's file list on purpose: the close protocol writes the
99
+ # behavior files, the archive, the changelog and the roadmap after the verifier
100
+ # ran, so a whole-tree rule would block every spec that ships its paperwork.
101
+ vc="$tmp/verdict-commit"
102
+ mkdir -p "$vc/$spec/verifications" "$vc/docs"
103
+ (cd "$vc" && git init -q . && git config user.email t@t && git config user.name t)
104
+ vct="$vc/transcript.txt"
105
+ echo "Verdict: DONE: $spec" >"$vct"
106
+ printf 'module.exports = 1\n' >"$vc/shipping.js"
107
+ printf '# Demo\n\n## Implementation Plan\n\n### Task Group 1: fee\n**Files:** `shipping.js`\n' >"$vc/$spec/spec.md"
108
+ printf '# Changelog\n' >"$vc/CHANGELOG.md"
109
+ printf '# Roadmap\n' >"$vc/docs/roadmap.md"
110
+ printf 'module.exports = 0\n' >"$vc/unrelated.js"
111
+ (cd "$vc" && git add -A && git commit -qm init)
112
+ vsha=$(cd "$vc" && git rev-parse --short HEAD)
113
+ printf '# Verification\n> 2026-01-01 | commit: %s | Completeness: **CLEAN** | Quality: **PASS**\n' "$vsha" >"$vc/$spec/verifications/verification.md"
114
+ (cd "$vc" && bash "$DOD" "$vct"); check "dod: a report bound to the tree it read allows" 0 $?
115
+
116
+ printf 'module.exports = 2\n' >"$vc/shipping.js"
117
+ (cd "$vc" && bash "$DOD" "$vct" 2>/dev/null); check "dod: a delivered file changed after the judged commit blocks" 2 $?
118
+
119
+ (cd "$vc" && git checkout -q -- shipping.js)
120
+ printf '# Changelog\n- shipped the fee\n' >"$vc/CHANGELOG.md"
121
+ printf '# Roadmap\n- fee: done\n' >"$vc/docs/roadmap.md"
122
+ printf 'module.exports = 0\n' >"$vc/unrelated.js"
123
+ (cd "$vc" && bash "$DOD" "$vct"); check "dod: the close protocol's paperwork after the verdict allows" 0 $?
124
+
125
+ printf '# Verification\n> 2026-01-01 | commit: 0000000 | Completeness: **CLEAN** | Quality: **PASS**\n' >"$vc/$spec/verifications/verification.md"
126
+ (cd "$vc" && bash "$DOD" "$vct" 2>/dev/null); check "dod: a marker naming no commit blocks" 2 $?
127
+
128
+ printf '# Verification\n> 2026-01-01 | Completeness: **CLEAN** | Quality: **PASS**\n' >"$vc/$spec/verifications/verification.md"
129
+ (cd "$vc" && bash "$DOD" "$vct"); check "dod: a report with no marker is the pre-marker format, allowed" 0 $?
130
+
131
+ printf 'module.exports = 3\n' >"$vc/shipping.js"
132
+ printf '# Verification\n> 2026-01-01 | Completeness: **CLEAN** | Quality: **PASS**\n\nSee commit: %s for the history.\n' "$vsha" >"$vc/$spec/verifications/verification.md"
133
+ (cd "$vc" && bash "$DOD" "$vct"); check "dod: a commit mentioned in the body is not the header's marker" 0 $?
134
+ (cd "$vc" && git checkout -q -- shipping.js)
135
+
136
+ printf '# Demo\n\n## Implementation Plan\n\nAn inline spec naming no files.\n' >"$vc/$spec/spec.md"
137
+ printf '# Verification\n> 2026-01-01 | commit: 0000000 | Completeness: **CLEAN** | Quality: **PASS**\n' >"$vc/$spec/verifications/verification.md"
138
+ (cd "$vc" && bash "$DOD" "$vct" 2>/dev/null); check "dod: a plan naming no files skips only the diff, not the marker" 2 $?
139
+
140
+ # Paths are passed one by one, so a name git would split is still one file, and
141
+ # a name git cannot resolve is the gate's limitation rather than a stale verdict.
142
+ printf '# Demo\n\n## Implementation Plan\n**Files:** `sp ace.js`\n' >"$vc/$spec/spec.md"
143
+ printf 'module.exports = 1\n' >"$vc/sp ace.js"
144
+ (cd "$vc" && git add -A && git commit -qm spacey)
145
+ ssha=$(cd "$vc" && git rev-parse --short HEAD)
146
+ printf '# Verification\n> 2026-01-01 | commit: %s | Completeness: **CLEAN** | Quality: **PASS**\n' "$ssha" >"$vc/$spec/verifications/verification.md"
147
+ (cd "$vc" && bash "$DOD" "$vct"); check "dod: a planned path with a space allows while unchanged" 0 $?
148
+ printf 'module.exports = 2\n' >"$vc/sp ace.js"
149
+ (cd "$vc" && bash "$DOD" "$vct" 2>/dev/null); check "dod: a changed planned path with a space still blocks" 2 $?
150
+ (cd "$vc" && git checkout -q -- 'sp ace.js')
151
+
152
+ : >"$tmp/outside.js"
153
+ printf '# Demo\n\n## Implementation Plan\n**Files:** `../outside.js`\n' >"$vc/$spec/spec.md"
154
+ printf '# Verification\n> 2026-01-01 | commit: %s | Completeness: **CLEAN** | Quality: **PASS**\n' "$ssha" >"$vc/$spec/verifications/verification.md"
155
+ (cd "$vc" && bash "$DOD" "$vct"); check "dod: a planned path git cannot resolve fails open" 0 $?
156
+
157
+ # --- check-dod-core.sh: an empty delivery is not done -----------------------
158
+ # The verifier scopes to the diff, so an implementation that wrote nothing has
159
+ # no placeholders in it and verifies CLEAN. The plan's own **Files:** lines say
160
+ # what was meant to exist.
161
+ printf "$clean_report" >"$pe/$spec/verifications/verification.md"
162
+ printf '# Demo\n\n## Implementation Plan\n\n### Task Group 1: thing\n**Files:** `src/thing.js`, `src/thing.test.js`\n' >"$pe/$spec/spec.md"
163
+ (cd "$pe" && bash "$DOD" "$pet" 2>/dev/null); check "dod: no planned file exists, nothing was delivered, blocks" 2 $?
164
+
165
+ mkdir -p "$pe/src" && : >"$pe/src/thing.js"
166
+ (cd "$pe" && bash "$DOD" "$pet"); check "dod: one planned file delivered allows (an amended list is normal)" 0 $?
167
+
168
+ printf '# Demo\n\n## Implementation Plan\n\n### Task Group 1: source\n**Files:** `src/auth.ts`\n' >"$pe/$spec/spec.md"
169
+ printf '// Implemented by DevOS\n' >"$pe/src/auth.ts"
170
+ (cd "$pe" && bash "$DOD" "$pet" 2>/dev/null); check "dod: process metadata in a planned source file blocks" 2 $?
171
+ printf 'export const status = 401\n' >"$pe/src/auth.ts"
172
+ (cd "$pe" && bash "$DOD" "$pet"); check "dod: clean planned source allows" 0 $?
173
+
174
+ rm -rf "$pe/src"
175
+ printf '# Demo\n\n## Implementation Plan\n\nNo file list, an inline mini-spec.\n' >"$pe/$spec/spec.md"
176
+ (cd "$pe" && bash "$DOD" "$pet"); check "dod: a plan naming no files is silent, not blocking" 0 $?
177
+
178
+ # A spec whose whole job is to write a standards file delivered what it planned.
179
+ # Blocking it would be the false positive; the check is "nothing exists", not
180
+ # "nothing outside devos/ exists".
181
+ printf '# Demo\n\n### Task Group 1: standards\n**Files:** `devos/standards/conventions.md`\n' >"$pe/$spec/spec.md"
182
+ (cd "$pe" && bash "$DOD" "$pet" 2>/dev/null); check "dod: a devos-only plan with nothing written still blocks" 2 $?
183
+ mkdir -p "$pe/devos/standards" && : >"$pe/devos/standards/conventions.md"
184
+ (cd "$pe" && bash "$DOD" "$pet"); check "dod: a devos-only plan that wrote its file allows" 0 $?
185
+
186
+ # --- check-port-source.sh: the tree a port reads is not the tree it writes ---
187
+ # A port writes a new tree and leaves the old one alone, and the old one may
188
+ # be running in production. The manifest names the sources, and the check
189
+ # compares them against the branch, so an edit to a source is a finding.
190
+ ps="$tmp/port-source"
191
+ mkdir -p "$ps/legacy/pkg" "$ps/modernized/pkg" "$ps/devos/specs/2026-10-20-port"
192
+ (cd "$ps" && git init -q && git config user.email t@t && git config user.name t)
193
+ printf 'x\n' >"$ps/legacy/pkg/a.py"
194
+ printf 'y\n' >"$ps/modernized/pkg/a.py"
195
+ printf 'source\ttarget\nlegacy/pkg/a.py\tmodernized/pkg/a.py\n' >"$ps/devos/specs/2026-10-20-port/manifest.tsv"
196
+ printf '# spec\n' >"$ps/devos/specs/2026-10-20-port/spec.md"
197
+ (cd "$ps" && git add -A && git commit -qm base)
198
+
199
+ bash "$PSRC" --spec-dir "$ps/devos/specs/2026-10-20-port" --root "$ps" >/dev/null 2>&1
200
+ check "port-source: a port that leaves the tree it reads alone allows" 0 $?
201
+
202
+ printf 'z\n' >>"$ps/legacy/pkg/a.py"
203
+ out=$(bash "$PSRC" --spec-dir "$ps/devos/specs/2026-10-20-port" --root "$ps" 2>&1); rc=$?
204
+ [ "$rc" -eq 1 ] && echo "$out" | grep -q "the tree it reads is not the tree it writes"
205
+ check "port-source: a port that edits the tree it reads blocks" 0 $?
206
+
207
+ out=$(bash "$PSRC" --spec-dir "$ps/devos/specs/2026-10-20-port" --root "$ps" 2>&1); rc=$?
208
+ [ "$rc" -eq 1 ] && echo "$out" | grep -q "fix: revert that change"
209
+ check "port-source: the finding says what to do" 0 $?
210
+
211
+ printf 'w\n' >>"$ps/modernized/pkg/a.py"
212
+ (cd "$ps" && git checkout -q -- legacy)
213
+ bash "$PSRC" --spec-dir "$ps/devos/specs/2026-10-20-port" --root "$ps" >/dev/null 2>&1
214
+ check "port-source: a port that writes the tree it builds allows" 0 $?
215
+
216
+ rm "$ps/devos/specs/2026-10-20-port/manifest.tsv"
217
+ bash "$PSRC" --spec-dir "$ps/devos/specs/2026-10-20-port" --root "$ps" >/dev/null 2>&1
218
+ check "port-source: a spec with no manifest is not a port, and is silent" 0 $?
219
+
220
+ # --- check-dod-core.sh: a port that edits the tree it reads is not done -----
221
+ # The port's manifest names the sources, and a DONE claim on a port spec is
222
+ # checked against them: the tree the port reads keeps running while the port
223
+ # lands.
224
+ port="$tmp/portrepo"
225
+ mkdir -p "$port/legacy/pkg" "$port/devos/specs/2026-10-20-port/verifications"
226
+ (cd "$port" && git init -q && git config user.email t@t && git config user.name t)
227
+ printf 'x\n' >"$port/legacy/pkg/a.py"
228
+ printf 'source\ttarget\nlegacy/pkg/a.py\tmodernized/pkg/a.py\n' >"$port/devos/specs/2026-10-20-port/manifest.tsv"
229
+ printf '# Verification\n> 2026-10-20 | Completeness: **CLEAN** | Quality: **PASS**\n' >"$port/devos/specs/2026-10-20-port/verifications/verification.md"
230
+ (cd "$port" && git add -A && git commit -qm base)
231
+ echo "Verdict: DONE: devos/specs/2026-10-20-port" > "$tmp/port.txt"
232
+ (cd "$port" && bash "$DOD" "$tmp/port.txt"); check "dod: a port that left its source tree alone allows" 0 $?
233
+ printf 'y\n' >>"$port/legacy/pkg/a.py"
234
+ (cd "$port" && bash "$DOD" "$tmp/port.txt") 2>/dev/null; check "dod: a port that edited its source tree blocks" 2 $?
235
+
236
+ # --- check-dod-core.sh: behavior-merge check --------
237
+ # Against the real corpus this repo ships: all three archived specs must
238
+ # pass unchanged, run from the actual repo (a regression test that only
239
+ # ever sees synthetic input has never seen a true negative).
240
+ for real in \
241
+ 2026-07-27-pressure-fixture-time-pressure \
242
+ 2026-07-27-reverse-engineer-spec-stubs \
243
+ 2026-07-27-run-sh-results-suffix; do
244
+ rt="$tmp/real-transcript-$real.txt"
245
+ echo "Verdict: DONE: devos/specs/archive/$real" > "$rt"
246
+ (cd "$REPO_ROOT" && bash "$DOD" "$rt") >/dev/null 2>&1
247
+ check "dod: real archived spec '$real' behavior delta passes unchanged" 0 $?
248
+ done
249
+
250
+ # Planted miss: delta names a capability with no behavior file at all.
251
+ ghost="$tmp/devos/specs/2026-01-01-ghost-capability"
252
+ mkdir -p "$ghost/verifications"
253
+ cat > "$ghost/spec.md" <<'MD'
254
+ # Ghost Capability
255
+ ## Goal
256
+ x
257
+ ## Behavior delta
258
+
259
+ **Added** (capability: `ghost-capability`):
260
+ - Something new that never got merged.
261
+ ## Out of Scope
262
+ - y
263
+ MD
264
+ printf '# Verification\n> 2026-01-01 | Completeness: **CLEAN** | Quality: **PASS**\n' > "$ghost/verifications/verification.md"
265
+ echo "Verdict: DONE: devos/specs/2026-01-01-ghost-capability" > "$t"
266
+ bash "$DOD" "$t" 2>/dev/null; check "dod: delta names capability with no behavior file blocks" 2 $?
267
+
268
+ # Fixed: behavior file exists with a matching last-spec header.
269
+ mkdir -p "$tmp/devos/product/behaviors"
270
+ printf '# Ghost Capability\n\n> updated: 2026-01-01 | last spec: 2026-01-01-ghost-capability\n\nSomething new that never got merged.\n' \
271
+ > "$tmp/devos/product/behaviors/ghost-capability.md"
272
+ bash "$DOD" "$t"; check "dod: matching behavior file with last-spec header allows" 0 $?
273
+
274
+ # Removed entry: needs a History tombstone naming this spec, not a fresh header.
275
+ removed="$tmp/devos/specs/2026-01-02-drop-capability"
276
+ mkdir -p "$removed/verifications"
277
+ cat > "$removed/spec.md" <<'MD'
278
+ # Drop Capability
279
+ ## Goal
280
+ x
281
+ ## Behavior delta
282
+
283
+ **Removed** (capability: `ghost-capability`):
284
+ - Dropped on purpose, replaced by nothing.
285
+ ## Out of Scope
286
+ - y
287
+ MD
288
+ printf '# Verification\n> 2026-01-02 | Completeness: **CLEAN** | Quality: **PASS**\n' > "$removed/verifications/verification.md"
289
+ rt2="$tmp/removed-transcript.txt"
290
+ echo "Verdict: DONE: devos/specs/2026-01-02-drop-capability" > "$rt2"
291
+ bash "$DOD" "$rt2" 2>/dev/null; check "dod: removed capability with no History tombstone blocks" 2 $?
292
+
293
+ printf '# Ghost Capability\n\n> updated: 2026-01-01 | last spec: 2026-01-01-ghost-capability\n\n## History\n- removed ghost-capability: dropped on purpose, per 2026-01-02-drop-capability\n' \
294
+ > "$tmp/devos/product/behaviors/ghost-capability.md"
295
+ bash "$DOD" "$rt2"; check "dod: removed capability with a matching History tombstone allows" 0 $?
296
+
297
+ # No Behavior delta section at all: silent, same posture as validate-spec.sh.
298
+ nodelta="$tmp/devos/specs/2026-01-03-no-delta"
299
+ mkdir -p "$nodelta/verifications"
300
+ printf '# No Delta\n## Goal\nx\n## Out of Scope\n- y\n' > "$nodelta/spec.md"
301
+ printf '# Verification\n> 2026-01-03 | Completeness: **CLEAN** | Quality: **PASS**\n' > "$nodelta/verifications/verification.md"
302
+ echo "Verdict: DONE: devos/specs/2026-01-03-no-delta" > "$t"
303
+ bash "$DOD" "$t"; check "dod: spec with no Behavior delta section is silent" 0 $?
304
+
305
+ # --- check-dod-core.sh: leftover debug instrumentation ----------------------
306
+ # The tag is assembled with printf, never written literally, so this very file
307
+ # stays clean: it is tracked, and the real-corpus assertions above run the gate
308
+ # from REPO_ROOT, where a literal tag here would block every one of them.
309
+ dbg="$tmp/debugtag"
310
+ mkdir -p "$dbg/devos/specs/2026-01-04-dbg/verifications"
311
+ (cd "$dbg" && git init -q .) 2>/dev/null
312
+ printf '# Verification\n> 2026-01-04 | Completeness: **CLEAN** | Quality: **PASS**\n' \
313
+ > "$dbg/devos/specs/2026-01-04-dbg/verifications/verification.md"
314
+ dt="$tmp/dbg-transcript.txt"
315
+ echo "Verdict: DONE: devos/specs/2026-01-04-dbg" > "$dt"
316
+
317
+ printf 'console.log("[DEBUG-%s] here")\n' a4f2 > "$dbg/src.js"
318
+ (cd "$dbg" && git add -A) 2>/dev/null
319
+ (cd "$dbg" && bash "$DOD" "$dt") 2>/dev/null
320
+ check "dod: leftover [DEBUG-hex] tag in a tracked file blocks" 2 $?
321
+
322
+ # The placeholder form the docs use is not the tag: it must not match itself.
323
+ printf 'tag every probe [DEBUG-xxxx] so cleanup is one grep\n' > "$dbg/src.js"
324
+ (cd "$dbg" && git add -A) 2>/dev/null
325
+ (cd "$dbg" && bash "$DOD" "$dt")
326
+ check "dod: [DEBUG-xxxx] placeholder in prose allows" 0 $?
327
+
328
+ # Untracked scratch file was never shipped: not the gate's business.
329
+ printf 'console.log("[DEBUG-%s]")\n' 9bee > "$dbg/scratch.js"
330
+ (cd "$dbg" && bash "$DOD" "$dt")
331
+ check "dod: untracked file with a tag allows" 0 $?
332
+
333
+ rm -f "$dbg/src.js" "$dbg/scratch.js"
334
+ (cd "$dbg" && git add -A) 2>/dev/null
335
+ (cd "$dbg" && bash "$DOD" "$dt")
336
+ check "dod: clean tree allows" 0 $?
337
+
338
+ # --- check-report-locations.sh: the verdict's citations are re-derived ------
339
+ # A `file:line` in the report is the part a candidate gets right in prose and
340
+ # wrong in fact. Before this pass nothing read it back, so a citation past the
341
+ # end of its file blocked nothing and read like every other line.
342
+ LOC="$(dirname "$DOD")/check-report-locations.sh"
343
+ loc="$tmp/loc"
344
+ mkdir -p "$loc/devos/specs/2026-01-05-loc/verifications"
345
+ printf 'one\ntwo\nthree\n' > "$loc/src.js"
346
+ LR="$loc/devos/specs/2026-01-05-loc/verifications/verification.md"
347
+ lt="$tmp/loc-transcript.txt"
348
+ echo "Verdict: DONE: devos/specs/2026-01-05-loc" > "$lt"
349
+
350
+ printf '# Verification\n> 2026-01-05 | Completeness: **CLEAN** | Quality: **PASS**\n| `src.js:2` | code | problem |\n' > "$LR"
351
+ (cd "$loc" && bash "$DOD" "$lt") 2>/dev/null
352
+ check "dod: a resolvable citation allows" 0 $?
353
+
354
+ printf '# Verification\n> 2026-01-05 | Completeness: **CLEAN** | Quality: **PASS**\n| `src.js:99` | code | problem |\n' > "$LR"
355
+ (cd "$loc" && bash "$DOD" "$lt") 2>/dev/null
356
+ check "dod: a citation past the end of its file blocks" 2 $?
357
+
358
+ printf '# Verification\n> 2026-01-05 | Completeness: **CLEAN** | Quality: **PASS**\n| `src/gone.js:3` | code | problem |\n' > "$LR"
359
+ (cd "$loc" && bash "$DOD" "$lt") 2>/dev/null
360
+ check "dod: a citation to a nonexistent file blocks" 2 $?
361
+
362
+ # A URL carries a colon-number too; it is not a citation.
363
+ printf '# Verification\n> 2026-01-05 | Completeness: **CLEAN** | Quality: **PASS**\nsee https://example.com:8080/a.js:9\n' > "$LR"
364
+ (cd "$loc" && bash "$DOD" "$lt")
365
+ check "dod: a URL colon-number is not a citation" 0 $?
366
+
367
+ # The reflection pass on its own, out of the hook: same exit contract.
368
+ bash "$LOC" "$loc/devos/specs/2026-01-05-loc" >/dev/null 2>&1
369
+ check "report-locations: a clean report exits 0" 0 $?
370
+ printf '# V\n| `src.js:99` | code |\n' > "$LR"
371
+ bash "$LOC" "$loc/devos/specs/2026-01-05-loc" >/dev/null 2>&1
372
+ check "report-locations: a drifted citation exits 1" 1 $?
373
+ printf '# V\n| `src.js:3-2` | reversed |\n' > "$LR"
374
+ report_out=$(bash "$LOC" "$loc/devos/specs/2026-01-05-loc" 2>&1); report_rc=$?
375
+ check "report-locations: a reversed range exits 1" 1 $report_rc
376
+ printf '%s\n' "$report_out" | grep -Fq 'range end 2 is before start 3'; check "report-locations: reversed range names the bounds" 0 $?
377
+ printf '# V\n| `src.js:0` | zero |\n' > "$LR"
378
+ report_out=$(bash "$LOC" "$loc/devos/specs/2026-01-05-loc" 2>&1); report_rc=$?
379
+ check "report-locations: line zero exits 1" 1 $report_rc
380
+ printf '%s\n' "$report_out" | grep -Fq 'source line numbers start at 1'; check "report-locations: line zero names the one-based rule" 0 $?
381
+ printf 'KEY=value\n' > "$loc/.env"
382
+ printf '# V\n| `.env:99` | drifted |\n' > "$LR"
383
+ report_out=$(bash "$LOC" "$loc/devos/specs/2026-01-05-loc" 2>&1); report_rc=$?
384
+ check "report-locations: dotfile citation exits 1" 1 $report_rc
385
+ printf '%s\n' "$report_out" | grep -Fq '.env:99'; check "report-locations: dotfile citation is named" 0 $?
386
+ printf 'outside\n' > "$tmp/report-outside.txt"
387
+ printf '# V\n| `../report-outside.txt:1` | escaped |\n' > "$LR"
388
+ report_out=$(bash "$LOC" "$loc/devos/specs/2026-01-05-loc" 2>&1); report_rc=$?
389
+ check "report-locations: a citation outside the project root exits 1" 1 $report_rc
390
+ printf '%s\n' "$report_out" | grep -Fq 'outside the project root'; check "report-locations: path escape names the boundary" 0 $?
391
+ ln -s "$tmp/report-outside.txt" "$loc/escape.txt"
392
+ printf '# V\n| `escape.txt:1` | symlink escape |\n' > "$LR"
393
+ report_out=$(bash "$LOC" "$loc/devos/specs/2026-01-05-loc" 2>&1); report_rc=$?
394
+ check "report-locations: a symlink outside the project root exits 1" 1 $report_rc
395
+ printf '%s\n' "$report_out" | grep -Fq 'outside the project root'; check "report-locations: symlink escape names the boundary" 0 $?
396
+ printf 'spec-local\n' > "$loc/devos/specs/2026-01-05-loc/notes.md"
397
+ printf '# V\n| `notes.md:1` | spec-relative |\n' > "$LR"
398
+ bash "$LOC" "$loc/devos/specs/2026-01-05-loc" --root "$loc" >/dev/null 2>&1
399
+ check "report-locations: a spec-relative in-root citation allows" 0 $?
400
+ bash "$LOC" >/dev/null 2>&1
401
+ check "report-locations: no argument is a usage error" 2 $?
402
+
403
+ # --- check-scenario-coverage.sh: a scenario recorded nowhere was not verified --
404
+ # The verifier is told to record every SC-n from spec.md in its
405
+ # report, and nothing checked it did. A missing row is the one failure a
406
+ # clean-looking report cannot show: every row it carries resolves, the verdict
407
+ # reads CLEAN + PASS, and the scenario nobody ran leaves no trace.
408
+ COV="$(dirname "$DOD")/check-scenario-coverage.sh"
409
+ cov="$tmp/cov"
410
+ COVS="$cov/devos/specs/2026-01-06-cov"
411
+ mkdir -p "$COVS/verifications"
412
+ CR="$COVS/verifications/verification.md"
413
+ covspec="$COVS/spec.md"
414
+ ct="$tmp/cov-transcript.txt"
415
+ printf 'x\nx\nx\nx\nx\nx\nx\nx\nx\nx\n' > "$cov/one.test.js"
416
+ echo "Verdict: DONE: devos/specs/2026-01-06-cov" > "$ct"
417
+ printf '# Demo\n\n## 3. Functionality\n\n**Scenarios:**\n- Scenario SC-1: one / WHEN a / THEN b\n- Scenario SC-2: two / WHEN c / THEN d\n' > "$covspec"
418
+
419
+ printf '# Verification\n> 2026-01-06 | Completeness: **CLEAN** | Quality: **PASS**\n| SC-1 | pass | `one.test.js:3` |\n| SC-2 | pass | `one.test.js:9` |\n' > "$CR"
420
+ (cd "$cov" && bash "$DOD" "$ct"); check "coverage: DONE with every scenario recorded allows" 0 $?
421
+
422
+ printf '# Verification\n> 2026-01-06 | Completeness: **CLEAN** | Quality: **PASS**\n| SC-1 | pass | `one.test.js:3` |\n' > "$CR"
423
+ cov_out=$(cd "$cov" && bash "$DOD" "$ct" 2>&1); cov_rc=$?
424
+ check "coverage: a scenario the report never records blocks DONE" 2 $cov_rc
425
+ printf '%s\n' "$cov_out" | grep -Fq 'SC-2'; check "coverage: the missing ID is named" 0 $?
426
+
427
+ # Presence, not format: prose that records each ID is as valid as a table row.
428
+ printf '# V\nSC-1 pass (`one.test.js:3`), SC-2 AWAITING HUMAN.\n' > "$CR"
429
+ bash "$COV" "$COVS" >/dev/null 2>&1; check "coverage: a mapping line records the scenarios" 0 $?
430
+
431
+ # A scenario the spec dropped during revision leaves the report's old row stale.
432
+ printf '# V\nSC-1 pass, SC-2 pass, SC-3 pass\n' > "$CR"
433
+ cov_out=$(bash "$COV" "$COVS" 2>&1); cov_rc=$?
434
+ check "coverage: a report citing an undeclared ID exits 1" 1 $cov_rc
435
+ printf '%s\n' "$cov_out" | grep -Fq 'SC-3'; check "coverage: the undeclared ID is named" 0 $?
436
+
437
+ # SC-10 is a different ID from SC-1, so a prefix match would let an omitted
438
+ # scenario pass on its neighbour's row.
439
+ printf '## Scenarios\n- Scenario SC-1: one / WHEN a / THEN b\n- Scenario SC-10: ten / WHEN c / THEN d\n' > "$covspec"
440
+ printf '# V\nSC-10 pass\n' > "$CR"
441
+ cov_out=$(bash "$COV" "$COVS" 2>&1); cov_rc=$?
442
+ check "coverage: SC-1 missing while SC-10 is recorded exits 1" 1 $cov_rc
443
+ printf '%s\n' "$cov_out" | grep -Fq 'SC-10'; check "coverage: a recorded SC-10 does not satisfy SC-1" 1 $?
444
+
445
+ # Exemptions: a C-route spec declares no scenarios by design, and a pre-SC spec
446
+ # has no IDs to trace. Both are silence, never a block.
447
+ printf '# Demo\n\n## Invariant\n- npm test exits 0 with the same count\n' > "$covspec"
448
+ bash "$COV" "$COVS" >/dev/null 2>&1; check "coverage: an invariant spec exits 0" 0 $?
449
+ printf '# Demo\n\n- Scenario: one / WHEN a / THEN b\n' > "$covspec"
450
+ bash "$COV" "$COVS" >/dev/null 2>&1; check "coverage: an unnumbered legacy spec exits 0" 0 $?
451
+ rm -f "$covspec"
452
+ bash "$COV" "$COVS" >/dev/null 2>&1; check "coverage: a spec with no functional doc exits 0" 0 $?
453
+ # The report path is accepted directly, since a caller holding one should not
454
+ # have to reconstruct the spec folder.
455
+ printf '## Scenarios\n- Scenario SC-1: one / WHEN a / THEN b\n' > "$covspec"
456
+ printf '# V\nSC-1 pass\n' > "$CR"
457
+ bash "$COV" "$CR" >/dev/null 2>&1; check "coverage: a report path records the scenarios" 0 $?
458
+ printf '# V\nnothing\n' > "$CR"
459
+ bash "$COV" "$CR" >/dev/null 2>&1; check "coverage: a report path with a missing ID exits 1" 1 $?
460
+ bash "$COV" >/dev/null 2>&1; check "coverage: no argument is a usage error" 2 $?
461
+
462
+ # --- check-dod-core.sh: the branch resolves the spec --------------
463
+ # The pipeline creates a `[spec-name]` branch before the first edit, so the gate
464
+ # derives the spec instead of trusting a path the model typed. A placeholder
465
+ # like `devos/specs/x` must not bounce the run into a retry loop when the
466
+ # branch's own report is there.
467
+ br="$tmp/branch"
468
+ mkdir -p "$br/devos/specs/2026-01-02-real/verifications"
469
+ (cd "$br" && git init -q . && git checkout -q -b 2026-01-02-real) 2>/dev/null
470
+ printf '# Verification\n> 2026-01-02 | Completeness: **CLEAN** | Quality: **PASS**\n' \
471
+ > "$br/devos/specs/2026-01-02-real/verifications/verification.md"
472
+ bt="$tmp/branch-transcript.txt"
473
+
474
+ echo "Verdict: DONE: devos/specs/x" > "$bt"
475
+ (cd "$br" && bash "$DOD" "$bt"); check "dod: a placeholder spec resolves to the branch's spec" 0 $?
476
+
477
+ echo "Verdict: DONE" > "$bt"
478
+ (cd "$br" && bash "$DOD" "$bt"); check "dod: a bare verdict resolves on a spec branch" 0 $?
479
+
480
+ # The fallback is not a bypass: with no report on the branch's spec, naming is
481
+ # still required and a placeholder still blocks.
482
+ rm -rf "$br/devos/specs/2026-01-02-real/verifications"
483
+ echo "Verdict: DONE: devos/specs/x" > "$bt"
484
+ (cd "$br" && bash "$DOD" "$bt" 2>/dev/null); check "dod: branch fallback needs a real report" 2 $?
485
+