@tduyng/pi-devos 0.13.6 → 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 (100) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +26 -33
  3. package/package.json +1 -2
  4. package/plugins/devos/agents/verifier.md +4 -30
  5. package/plugins/devos/pi/extension/devos.ts +16 -26
  6. package/plugins/devos/scripts/check-evidence-router.sh +7 -1
  7. package/plugins/devos/scripts/evidence-router.py +5 -3
  8. package/plugins/devos/scripts/gates/check-dod-core.sh +5 -3
  9. package/plugins/devos/scripts/gates/check-port-source.sh +1 -1
  10. package/plugins/devos/scripts/gates/check-scenario-coverage.sh +10 -8
  11. package/plugins/devos/scripts/gates/phase-gate.sh +6 -6
  12. package/plugins/devos/scripts/gates/plan-template-check.py +6 -12
  13. package/plugins/devos/scripts/gates/spec-contract.sh +19 -0
  14. package/plugins/devos/scripts/gates/spec-template-check.py +8 -21
  15. package/plugins/devos/scripts/gates/suite/01-dod.sh +485 -0
  16. package/plugins/devos/scripts/gates/suite/02-integrity.sh +310 -0
  17. package/plugins/devos/scripts/gates/suite/03-archetype.sh +255 -0
  18. package/plugins/devos/scripts/gates/suite/04-spec-validator.sh +183 -0
  19. package/plugins/devos/scripts/gates/suite/05-requires.sh +360 -0
  20. package/plugins/devos/scripts/gates/suite/06-clarify-adapters.sh +435 -0
  21. package/plugins/devos/scripts/gates/suite/07-lint-evals.sh +350 -0
  22. package/plugins/devos/scripts/gates/suite/08-converge.sh +591 -0
  23. package/plugins/devos/scripts/gates/suite/09-quality.sh +516 -0
  24. package/plugins/devos/scripts/gates/suite/10-eval-harness.sh +679 -0
  25. package/plugins/devos/scripts/gates/test-gates.sh +23 -4253
  26. package/plugins/devos/scripts/gates/test-integrity-rubric.sh +1 -1
  27. package/plugins/devos/scripts/gates/test-phase-gate.sh +5 -5
  28. package/plugins/devos/skills/build/SKILL.md +3 -3
  29. package/plugins/devos/skills/build/references/refactor.md +1 -1
  30. package/plugins/devos/skills/build/references/routes.md +4 -4
  31. package/plugins/devos/skills/frame/SKILL.md +22 -39
  32. package/plugins/devos/skills/frame/references/template.md +115 -0
  33. package/plugins/devos/skills/implement/SKILL.md +4 -4
  34. package/plugins/devos/skills/implement/references/dod.md +6 -1
  35. package/plugins/devos/skills/implement/references/implement.md +3 -1
  36. package/plugins/devos/skills/implement/references/plan.md +9 -27
  37. package/plugins/devos/skills/implement/references/resume.md +1 -1
  38. package/plugins/devos/skills/implement/references/verify-close.md +4 -3
  39. package/plugins/devos/skills/implement/scripts/ops-log.sh +2 -2
  40. package/plugins/devos/skills/implement/scripts/validate-spec.sh +17 -65
  41. package/plugins/devos/skills/init/references/context.md +1 -1
  42. package/plugins/devos/skills/review/SKILL.md +24 -47
  43. package/plugins/devos/skills/review/references/comments.md +13 -0
  44. package/plugins/devos/skills/review/references/reviewer.md +124 -0
  45. package/plugins/devos/skills/review/references/routing.md +35 -0
  46. package/plugins/devos/skills/review/scripts/__pycache__/prepare.cpython-313.pyc +0 -0
  47. package/plugins/devos/skills/review/scripts/prepare.py +763 -0
  48. package/plugins/devos/skills/spec/SKILL.md +5 -6
  49. package/plugins/devos/skills/spec/references/write-spec.md +36 -51
  50. package/plugins/devos/skills/spec/scripts/clarify.sh +4 -4
  51. package/plugins/devos/skills/status/SKILL.md +4 -4
  52. package/plugins/devos/skills/status/scripts/check-requires.py +4 -4
  53. package/plugins/devos/skills/status/scripts/convention-usage.sh +1 -1
  54. package/plugins/devos/skills/status/scripts/quality-correlation.sh +2 -25
  55. package/plugins/devos/scripts/gates/check-handoff.sh +0 -215
  56. package/plugins/devos/skills/design-taste/SKILL.md +0 -55
  57. package/plugins/devos/skills/design-taste/references/tells.md +0 -85
  58. package/plugins/devos/skills/design-taste/scripts/slop-scan.py +0 -305
  59. package/plugins/devos/skills/docs/SKILL.md +0 -22
  60. package/plugins/devos/skills/docs/references/backfill.md +0 -54
  61. package/plugins/devos/skills/docs/references/init.md +0 -43
  62. package/plugins/devos/skills/docs/references/status.md +0 -71
  63. package/plugins/devos/skills/docs/references/update.md +0 -80
  64. package/plugins/devos/skills/explain/SKILL.md +0 -45
  65. package/plugins/devos/skills/explain/references/quiz.md +0 -21
  66. package/plugins/devos/skills/frame/references/boundaries.md +0 -53
  67. package/plugins/devos/skills/frame/references/decompose.md +0 -96
  68. package/plugins/devos/skills/frame/references/impact.md +0 -43
  69. package/plugins/devos/skills/frame/references/interrogate.md +0 -68
  70. package/plugins/devos/skills/product/SKILL.md +0 -40
  71. package/plugins/devos/skills/product/references/planner.md +0 -54
  72. package/plugins/devos/skills/surgical-diff/SKILL.md +0 -23
  73. package/plugins/devos/skills/test-integrity/SKILL.md +0 -26
  74. package/plugins/devos/skills/verification-evidence/SKILL.md +0 -17
  75. package/plugins/devos/workflows/common/backlog-file-structure.md +0 -44
  76. package/plugins/devos/workflows/common/category-file-structure.md +0 -41
  77. package/plugins/devos/workflows/common/feature-line-format.md +0 -10
  78. package/plugins/devos/workflows/common/roadmap-file-structure.md +0 -51
  79. package/plugins/devos/workflows/common/suggest-categories.md +0 -76
  80. package/plugins/devos/workflows/common/suggest-milestones.md +0 -92
  81. package/plugins/devos/workflows/doc/doc-health.md +0 -137
  82. package/plugins/devos/workflows/doc/doc-writer.md +0 -44
  83. package/plugins/devos/workflows/doc/init-documentation.md +0 -196
  84. package/plugins/devos/workflows/doc/retro-documentation.md +0 -304
  85. package/plugins/devos/workflows/doc/templates/library.md +0 -58
  86. package/plugins/devos/workflows/doc/templates/service.md +0 -61
  87. package/plugins/devos/workflows/doc/update-documentation.md +0 -194
  88. package/plugins/devos/workflows/doc/write-documentation.md +0 -137
  89. package/plugins/devos/workflows/product/create-product-mission.md +0 -45
  90. package/plugins/devos/workflows/product/create-product-roadmap.md +0 -106
  91. package/plugins/devos/workflows/product/create-product-tech-stack.md +0 -19
  92. package/plugins/devos/workflows/product/gather-product-info.md +0 -25
  93. package/plugins/devos/workflows/product/resume-detection.md +0 -70
  94. package/plugins/devos/workflows/product/reverse-backlog.md +0 -118
  95. package/plugins/devos/workflows/product/reverse-domain-model.md +0 -86
  96. package/plugins/devos/workflows/product/reverse-product-plan.md +0 -81
  97. package/plugins/devos/workflows/product/reverse-tech-stack.md +0 -73
  98. package/plugins/devos/workflows/product/scan-deep.md +0 -113
  99. package/plugins/devos/workflows/product/scan-git.md +0 -122
  100. package/plugins/devos/workflows/product/scan-light.md +0 -154
@@ -0,0 +1,516 @@
1
+ # --- .quality.md: C route and the two derived columns ------
2
+ qdir="$tmp/qual/devos/specs/archive"
3
+ mkdir -p "$qdir"
4
+ printf 'a\tL\tyes\t1\tsuggestion\tyes\t2\t2/5\n' >"$qdir/a.quality.md"
5
+ printf 'b\tM\tyes\t0\tnone\tyes\t1\t-/0\n' >"$qdir/b.quality.md"
6
+ printf 'c\tC\tyes\t0\tnone\tyes\t1\t0/2\n' >"$qdir/c.quality.md"
7
+ printf 'd\tC\tno\t3\tcritical\tno\t4\t3/3\n' >"$qdir/d.quality.md"
8
+ printf 'e\tL\tyes\t0\tnone\tyes\t?\t?/4\n' >"$qdir/e.quality.md"
9
+ printf 'f\tL\tyes\t2\twarning\tyes\n' >"$qdir/f.quality.md"
10
+ qout=$(bash "$QC" "$tmp/qual" 2>&1)
11
+
12
+ check "quality: the C route is counted, not folded into ?" 1 \
13
+ "$(grep -cE '^C +2 +3 +1\.5$' <<<"$qout")"
14
+ check "quality: a 6-field row still counts toward findings" 1 \
15
+ "$(grep -cE '^TOTAL +6 +6 +1\.0$' <<<"$qout")"
16
+ check "quality: an unknown triage count is excluded from the average" 1 \
17
+ "$(grep -cE '^L +1 +2\.0' <<<"$qout")"
18
+ check "quality: the audit hit rate ignores unrecorded hits" 1 \
19
+ "$(grep -c '5 of 10 audit findings confirmed downstream (50%), across 4 spec(s)' <<<"$qout")"
20
+ check "quality: an excluded row is reported, not silently dropped" 1 \
21
+ "$(grep -c '1 spec(s) excluded: audit findings recorded, hits never were' <<<"$qout")"
22
+
23
+ qbad="$tmp/qual-bad/devos/specs/archive"
24
+ mkdir -p "$qbad"
25
+ for name in a b c d e; do
26
+ printf '%s\tL\tyes\t0\tnone\tyes\t1\t-/0\t-\n' "$name" > "$qbad/$name.quality.md"
27
+ done
28
+ printf 'malformed row\n' > "$qbad/f.quality.md"
29
+ qbadout=$(bash "$QC" "$tmp/qual-bad" 2>&1)
30
+ check "quality: malformed rows do not inflate analyzed specs" 1 \
31
+ "$(grep -c '^Specs analyzed: 5$' <<<"$qbadout")"
32
+ check "quality: malformed rows are surfaced" 1 \
33
+ "$(grep -c '^Skipped quality rows: 1 (fewer than 6 tab-separated fields)$' <<<"$qbadout")"
34
+
35
+ qblank="$tmp/qual-blank-audit/devos/specs/archive"
36
+ mkdir -p "$qblank"
37
+ for name in a b c d e; do
38
+ printf '%s\tS\tyes\t0\tnone\tyes\t1\t-/0\t-\n' "$name" > "$qblank/$name.quality.md"
39
+ done
40
+ printf 'blank-audit\tS\tyes\t0\tnone\tyes\t1\t\t-\n' > "$qblank/blank-audit.quality.md"
41
+ qblankout=$(bash "$QC" "$tmp/qual-blank-audit" 2>&1)
42
+ check "quality: a present blank audit field is surfaced" 1 \
43
+ "$(grep -c '^Invalid audit-hits values: 1 ' <<<"$qblankout")"
44
+ check "quality: a blank audit field is excluded only from audit metrics" 1 \
45
+ "$(grep -c 'no audit findings to confirm across 5 spec(s)' <<<"$qblankout")"
46
+ check "quality: a blank audit row remains in general aggregates" 1 \
47
+ "$(grep -cE '^TOTAL +6 +0 +0\.0$' <<<"$qblankout")"
48
+
49
+ qabsent="$tmp/qual-absent-audit/devos/specs/archive"
50
+ mkdir -p "$qabsent"
51
+ for name in a b c d e; do
52
+ printf '%s\tS\tyes\t0\tnone\tyes\t1\t-/0\t-\n' "$name" > "$qabsent/$name.quality.md"
53
+ done
54
+ printf 'absent-audit\tS\tyes\t0\tnone\tyes\t1\t-\n' > "$qabsent/absent-audit.quality.md"
55
+ qabsentout=$(bash "$QC" "$tmp/qual-absent-audit" 2>&1)
56
+ check "quality: an absent audit column is not invalid" 1 \
57
+ "$(grep -c '^Invalid audit-hits values:' <<<"$qabsentout" || true)"
58
+ check "quality: an absent audit column remains analyzable" 1 \
59
+ "$(grep -cE '^TOTAL +6 +0 +0\.0$' <<<"$qabsentout")"
60
+
61
+ qmeta="$tmp/qual-audit-metadata/devos/specs/archive"
62
+ mkdir -p "$qmeta"
63
+ for name in a b c d e; do
64
+ printf '%s\tS\tyes\t0\tnone\tyes\t1\t-/0\t-\n' "$name" > "$qmeta/$name.quality.md"
65
+ done
66
+ printf 'bad-denominator\tS\tyes\t0\tnone\tyes\t1\t-/x\t-\n' > "$qmeta/bad-denominator.quality.md"
67
+ printf 'bad-components\tS\tyes\t0\tnone\tyes\t1\t2/5/9\t-\n' > "$qmeta/bad-components.quality.md"
68
+ qmetaout=$(bash "$QC" "$tmp/qual-audit-metadata" 2>&1)
69
+ check "quality: nonnumeric audit denominators are surfaced" 1 \
70
+ "$(grep -c '^Invalid audit-hits values: 2 ' <<<"$qmetaout")"
71
+ check "quality: extra audit components are not accepted" 1 \
72
+ "$(grep -cE '^TOTAL +7 +0 +0\.0$' <<<"$qmetaout")"
73
+
74
+ # Every per-route table walked the route map with a bare for-in, so the rows
75
+ # came out in awk hash order: C, L, M, S on this awk, and no guarantee at all
76
+ # on another, which is the opposite of the S, M, L, C the script declares in its
77
+ # own route list. A reader comparing routes by size needs a stable order.
78
+ qorder="$tmp/qual-route-order/devos/specs/archive"
79
+ mkdir -p "$qorder"
80
+ i=0
81
+ for route in L S M C; do
82
+ for n in 1 2; do
83
+ i=$((i + 1))
84
+ printf 'spec%s\t%s\tyes\t2\twarning\tyes\t1\t-/0\t-\n' "$i" "$route" \
85
+ > "$qorder/spec$i.quality.md"
86
+ done
87
+ done
88
+ qorderout=$(bash "$QC" "$tmp/qual-route-order" 2>&1)
89
+ # Control: each route's own numbers are right, so a report that printed no
90
+ # per-route table could not satisfy the ordering checks.
91
+ check "quality: every route reports its own specs and findings" 4 \
92
+ "$(grep -cE '^(S|M|L|C) +2 +4 +2\.0$' <<<"$qorderout")"
93
+ qtable=$(sed -n '/^## Findings per Route/,/^## Routing/p' <<<"$qorderout" |
94
+ grep -oE '^[SMLC]([[:space:]]|$)' | tr -d '[:space:]' | tr -d '\n')
95
+ check "quality: the per-route tables read in declared S/M/L/C order" 0 \
96
+ "$([[ "$qtable" == 'SMLC' ]] && echo 0 || echo 1)"
97
+ # All four tables walk the same map, so all four must be ordered.
98
+ qmatrix=$(sed -n '/^## Routing Confusion Matrix/,/^## Triage/p' <<<"$qorderout" |
99
+ grep -oE '^[SMLC]([[:space:]]|$)' | tr -d '[:space:]' | tr -d '\n')
100
+ check "quality: the confusion matrix reads in the same declared order" 0 \
101
+ "$([[ "$qmatrix" == 'SMLC' ]] && echo 0 || echo 1)"
102
+ qloops=$(sed -n '/^## Triage Loops per Route/,/^## Spec Audit/p' <<<"$qorderout" |
103
+ grep -oE '^[SMLC]([[:space:]]|$)' | tr -d '[:space:]' | tr -d '\n')
104
+ check "quality: the triage table reads in the same declared order" 0 \
105
+ "$([[ "$qloops" == 'SMLC' ]] && echo 0 || echo 1)"
106
+ # The unrecognized-route bucket belongs after the recognized ones, not wherever
107
+ # the hash put it.
108
+ qbucket="$tmp/qual-route-bucket/devos/specs/archive"
109
+ mkdir -p "$qbucket"
110
+ i=0
111
+ for route in C L S M banana banana; do
112
+ i=$((i + 1))
113
+ printf 'spec%s\t%s\tyes\t2\twarning\tyes\t1\t-/0\t-\n' "$i" "$route" \
114
+ > "$qbucket/spec$i.quality.md"
115
+ done
116
+ qbucketout=$(bash "$QC" "$tmp/qual-route-bucket" 2>&1)
117
+ qbucketfirst=$(sed -n '/^## Findings per Route/,/^## Routing/p' <<<"$qbucketout" |
118
+ grep -oE '^[SMLC?]' | tr -d '\n')
119
+ check "quality: an unrecognized route is bucketed after the real routes" 0 \
120
+ "$([[ "$qbucketfirst" == 'SMLC?' ]] && echo 0 || echo 1)"
121
+ check "quality: the ? bucket still counts its specs" 1 \
122
+ "$(grep -cE '^\? +2 +4 +2\.0$' <<<"$qbucketout")"
123
+ rm -rf "$tmp/qual-route-order" "$tmp/qual-route-bucket"
124
+
125
+ qvalidate="$tmp/qual-validate/devos/specs/archive"
126
+ mkdir -p "$qvalidate"
127
+ for name in a b c d e; do
128
+ printf '%s\tS\tyes\t2\tnone\tyes\t1\t-/0\t-\n' "$name" > "$qvalidate/$name.quality.md"
129
+ done
130
+ printf 'bad-validate\tS\tmaybe\t2\tnone\tyes\t1\t-/0\t-\n' > "$qvalidate/bad-validate.quality.md"
131
+ qvalidateout=$(bash "$QC" "$tmp/qual-validate" 2>&1)
132
+ check "quality: invalid validate-pass values are excluded" 1 \
133
+ "$(grep -c '^Specs analyzed: 5$' <<<"$qvalidateout")"
134
+ check "quality: invalid validate-pass values are surfaced" 1 \
135
+ "$(grep -c '^Invalid validate-pass values: 1 ' <<<"$qvalidateout")"
136
+ check "quality: invalid validate-pass rows do not dilute totals" 1 \
137
+ "$(grep -cE '^TOTAL +5 +10 +2\.0$' <<<"$qvalidateout")"
138
+
139
+ qtriage="$tmp/qual-triage/devos/specs/archive"
140
+ mkdir -p "$qtriage"
141
+ for name in a b c d e; do
142
+ printf '%s\tS\tyes\t2\tnone\tyes\t1\t-/0\t-\n' "$name" > "$qtriage/$name.quality.md"
143
+ done
144
+ printf 'bad-triage\tS\tyes\t2\tnone\tyes\tmany\t-/0\t-\n' > "$qtriage/bad-triage.quality.md"
145
+ qtriageout=$(bash "$QC" "$tmp/qual-triage" 2>&1)
146
+ check "quality: malformed triage-loop values stay out of the average" 1 \
147
+ "$(grep -c '^Invalid triage-loop values: 1 ' <<<"$qtriageout")"
148
+ check "quality: malformed triage-loop rows remain available for other metrics" 1 \
149
+ "$(grep -cE '^TOTAL +6 +12 +2\.0$' <<<"$qtriageout")"
150
+ printf 'unknown-triage\tS\tyes\t2\tnone\tyes\t?\t-/0\t-\n' > "$qtriage/unknown-triage.quality.md"
151
+ qtriageout=$(bash "$QC" "$tmp/qual-triage" 2>&1)
152
+ check "quality: unknown triage-loop remains valid but does not enter the average" 1 \
153
+ "$(grep -cE '^S +5 +1\.0$' <<<"$qtriageout")"
154
+
155
+ qdod="$tmp/qual-dod/devos/specs/archive"
156
+ mkdir -p "$qdod"
157
+ for name in a b c d e; do
158
+ printf '%s\tS\tyes\t2\tnone\tyes\t1\t-/0\t-\n' "$name" > "$qdod/$name.quality.md"
159
+ done
160
+ printf 'bad-dod\tS\tyes\t2\tnone\tmaybe\t1\t-/0\t-\n' > "$qdod/bad-dod.quality.md"
161
+ qdodout=$(bash "$QC" "$tmp/qual-dod" 2>&1)
162
+ check "quality: invalid dod-pass values are excluded" 1 \
163
+ "$(grep -c '^Specs analyzed: 5$' <<<"$qdodout")"
164
+ check "quality: invalid dod-pass values are surfaced" 1 \
165
+ "$(grep -c '^Invalid dod-pass values: 1 ' <<<"$qdodout")"
166
+ check "quality: invalid dod-pass rows do not dilute totals" 1 \
167
+ "$(grep -cE '^TOTAL +5 +10 +2\.0$' <<<"$qdodout")"
168
+
169
+ qseverity="$tmp/qual-severity/devos/specs/archive"
170
+ mkdir -p "$qseverity"
171
+ for name in a b c d e; do
172
+ printf '%s\tS\tyes\t2\tnone\tyes\t1\t-/0\t-\n' "$name" > "$qseverity/$name.quality.md"
173
+ done
174
+ printf 'bad-severity\tS\tyes\t2\tbanana\tyes\t1\t-/0\t-\n' > "$qseverity/bad-severity.quality.md"
175
+ qseverityout=$(bash "$QC" "$tmp/qual-severity" 2>&1)
176
+ check "quality: invalid severity values are excluded" 1 \
177
+ "$(grep -c '^Specs analyzed: 5$' <<<"$qseverityout")"
178
+ check "quality: invalid severity values are surfaced" 1 \
179
+ "$(grep -c '^Invalid severity values: 1 ' <<<"$qseverityout")"
180
+ check "quality: invalid severity rows do not dilute totals" 1 \
181
+ "$(grep -cE '^TOTAL +5 +10 +2\.0$' <<<"$qseverityout")"
182
+
183
+ qunderstanding="$tmp/qual-understanding/devos/specs/archive"
184
+ mkdir -p "$qunderstanding"
185
+ for name in a b c d e; do
186
+ printf '%s\tS\tyes\t2\tnone\tyes\t1\t-/0\t-\n' "$name" > "$qunderstanding/$name.quality.md"
187
+ done
188
+ printf 'bad-understanding\tS\tyes\t2\tnone\tyes\t1\t-/0\tbanana\n' > "$qunderstanding/bad-understanding.quality.md"
189
+ qunderstandingout=$(bash "$QC" "$tmp/qual-understanding" 2>&1)
190
+ check "quality: invalid understanding values are excluded" 1 \
191
+ "$(grep -c '^Specs analyzed: 5$' <<<"$qunderstandingout")"
192
+ check "quality: invalid understanding values are surfaced" 1 \
193
+ "$(grep -c '^Invalid understanding values: 1 ' <<<"$qunderstandingout")"
194
+ check "quality: invalid understanding rows do not dilute totals" 1 \
195
+ "$(grep -cE '^TOTAL +5 +10 +2\.0$' <<<"$qunderstandingout")"
196
+
197
+ qdiag="$tmp/qual-diagnostic/devos/specs/archive"
198
+ mkdir -p "$qdiag"
199
+ for name in a b c d e; do
200
+ printf '%s\tS\tyes\t2\tnone\tyes\t1\t-/0\t-\n' "$name" > "$qdiag/$name.quality.md"
201
+ done
202
+ printf 'bad-count\tS\tyes\tbogus\tnone\tyes\t1\t-/0\t-\n' > "$qdiag/bad-count.quality.md"
203
+ printf 'short row\n' > "$qdiag/short.quality.md"
204
+ qdiagout=$(bash "$QC" "$tmp/qual-diagnostic" 2>&1)
205
+ check "quality: short rows and invalid counts have separate diagnostics" 1 \
206
+ "$(grep -c '^Specs analyzed: 5$' <<<"$qdiagout")"
207
+ check "quality: only the short row is reported as skipped" 1 \
208
+ "$(grep -c '^Skipped quality rows: 1 (fewer than 6 tab-separated fields)$' <<<"$qdiagout")"
209
+ check "quality: invalid finding counts are not mislabeled as short rows" 1 \
210
+ "$(grep -c '^Invalid finding-count values: 1 ' <<<"$qdiagout")"
211
+
212
+ qfindings="$tmp/qual-findings/devos/specs/archive"
213
+ mkdir -p "$qfindings"
214
+ for name in a b c d e; do
215
+ printf '%s\tS\tyes\t2\tnone\tyes\t1\t-/0\t-\n' "$name" > "$qfindings/$name.quality.md"
216
+ done
217
+ printf 'bad\tS\tyes\tbogus\tnone\tyes\t1\t-/0\t-\n' > "$qfindings/bad.quality.md"
218
+ qfindingsout=$(bash "$QC" "$tmp/qual-findings" 2>&1)
219
+ check "quality: non-integer finding counts are excluded" 1 \
220
+ "$(grep -c '^Specs analyzed: 5$' <<<"$qfindingsout")"
221
+ check "quality: non-integer finding counts are surfaced" 1 \
222
+ "$(grep -c '^Invalid finding-count values: 1 ' <<<"$qfindingsout")"
223
+ check "quality: invalid finding counts do not dilute averages" 1 \
224
+ "$(grep -cE '^TOTAL +5 +10 +2\.0$' <<<"$qfindingsout")"
225
+
226
+ qaudit="$tmp/qual-audit/devos/specs/archive"
227
+ mkdir -p "$qaudit"
228
+ for name in a b c d; do
229
+ printf '%s\tL\tyes\t0\tnone\tyes\t1\t-/0\t-\n' "$name" > "$qaudit/$name.quality.md"
230
+ done
231
+ printf 'e\tL\tyes\t0\tnone\tyes\t1\t-/5\t-\n' > "$qaudit/e.quality.md"
232
+ qaout=$(bash "$QC" "$tmp/qual-audit" 2>&1)
233
+ check "quality: malformed audit metadata is not clean" 1 \
234
+ "$(grep -c 'no audit findings to confirm across 4 spec(s)' <<<"$qaout")"
235
+ check "quality: malformed audit metadata is surfaced" 1 \
236
+ "$(grep -c '^Invalid audit-hits values: 1 ' <<<"$qaout")"
237
+
238
+ qratio="$tmp/qual-audit-ratio/devos/specs/archive"
239
+ mkdir -p "$qratio"
240
+ for name in a b c d; do
241
+ printf '%s\tL\tyes\t0\tnone\tyes\t1\t-/0\t-\n' "$name" > "$qratio/$name.quality.md"
242
+ done
243
+ printf 'e\tL\tyes\t0\tnone\tyes\t1\t3/2\t-\n' > "$qratio/e.quality.md"
244
+ qrout=$(bash "$QC" "$tmp/qual-audit-ratio" 2>&1)
245
+ check "quality: an impossible audit ratio is not included" 1 \
246
+ "$(grep -c 'no audit findings to confirm across 4 spec(s)' <<<"$qrout")"
247
+ check "quality: an impossible audit ratio is surfaced" 1 \
248
+ "$(grep -c '^Invalid audit-hits values: 1 ' <<<"$qrout")"
249
+
250
+ qsentinel="$tmp/qual-audit-sentinel/devos/specs/archive"
251
+ mkdir -p "$qsentinel"
252
+ for name in a b c d; do
253
+ printf '%s\tL\tyes\t0\tnone\tyes\t1\t-/0\t-\n' "$name" > "$qsentinel/$name.quality.md"
254
+ done
255
+ printf 'e\tL\tyes\t0\tnone\tyes\t1\t0/0\t-\n' > "$qsentinel/e.quality.md"
256
+ qsout=$(bash "$QC" "$tmp/qual-audit-sentinel" 2>&1)
257
+ check "quality: numeric 0/0 is not counted as clean" 1 \
258
+ "$(grep -c 'no audit findings to confirm across 4 spec(s)' <<<"$qsout")"
259
+ check "quality: numeric 0/0 is surfaced as invalid" 1 \
260
+ "$(grep -c '^Invalid audit-hits values: 1 ' <<<"$qsout")"
261
+
262
+ # --- artifact-budgets.sh: the three bands ----------------------------------
263
+ AB="$SKILLS/status/scripts/artifact-budgets.sh"
264
+ bdir="$tmp/budget"
265
+
266
+ mkdir -p "$bdir"
267
+ check "budget: no onboarded artifacts is not a failure" 0 \
268
+ "$(bash "$AB" "$bdir" >/dev/null 2>&1; echo $?)"
269
+ check "budget: no artifacts says so rather than printing an empty table" 1 \
270
+ "$(bash "$AB" "$bdir" 2>&1 | grep -c 'No budgeted artifacts found')"
271
+
272
+ mkdir -p "$bdir/devos/product"
273
+ # Cap 60: 53 lines is OK (below the 54-line 90% mark), 54 is NEAR, 61 is OVER.
274
+ seq 1 53 >"$bdir/devos/product/domain-model.md"
275
+ check "budget: below 90% of cap is OK" 1 \
276
+ "$(bash "$AB" "$bdir" 2>&1 | grep -c '^| OK | devos/product/domain-model.md | 53 | 60 |')"
277
+ check "budget: an OK-only run exits 0" 0 \
278
+ "$(bash "$AB" "$bdir" >/dev/null 2>&1; echo $?)"
279
+
280
+ seq 1 54 >"$bdir/devos/product/domain-model.md"
281
+ check "budget: 90% of cap is NEAR" 1 \
282
+ "$(bash "$AB" "$bdir" 2>&1 | grep -c '^| NEAR | devos/product/domain-model.md | 54 | 60 |')"
283
+ check "budget: NEAR is reported but never fatal" 0 \
284
+ "$(bash "$AB" "$bdir" >/dev/null 2>&1; echo $?)"
285
+
286
+ seq 1 60 >"$bdir/devos/product/domain-model.md"
287
+ check "budget: exactly at cap is NEAR, not OVER" 1 \
288
+ "$(bash "$AB" "$bdir" 2>&1 | grep -c '^| NEAR | devos/product/domain-model.md | 60 | 60 |')"
289
+
290
+ seq 1 61 >"$bdir/devos/product/domain-model.md"
291
+ check "budget: one line past cap is OVER" 1 \
292
+ "$(bash "$AB" "$bdir" 2>&1 | grep -c '^| OVER | devos/product/domain-model.md | 61 | 60 |')"
293
+ check "budget: an OVER artifact exits 1" 1 \
294
+ "$(bash "$AB" "$bdir" >/dev/null 2>&1; echo $?)"
295
+
296
+ { seq 1 60; printf '61'; } >"$bdir/devos/product/domain-model.md"
297
+ check "budget: an unterminated final line is counted" 1 \
298
+ "$(bash "$AB" "$bdir" 2>&1 | grep -c '^| OVER | devos/product/domain-model.md | 61 | 60 |')"
299
+ check "budget: an unterminated final OVER line exits 1" 1 \
300
+ "$(bash "$AB" "$bdir" >/dev/null 2>&1; echo $?)"
301
+
302
+ # Row order, not just row content. Lexical order over the band names is
303
+ # NEAR, OK, OVER, which puts the only actionable row last in a long table.
304
+ mkdir -p "$bdir/devos/product/behaviors"
305
+ seq 1 54 >"$bdir/devos/product/behaviors/near.md"
306
+ seq 1 10 >"$bdir/devos/product/behaviors/fine.md"
307
+ bandorder=$(bash "$AB" "$bdir" 2>&1 | awk -F'|' '/^\| (OK|NEAR|OVER) \|/ { gsub(/ /, "", $2); printf "%s ", $2 }')
308
+ check "budget: OVER leads, then NEAR, then OK" "OVER NEAR OK " "$bandorder"
309
+ rm -f "$bdir/devos/product/behaviors/near.md" "$bdir/devos/product/behaviors/fine.md"
310
+
311
+ # Each artifact class carries its own cap: 121 lines is OVER for the map (120)
312
+ # but well inside a capsule's 300.
313
+ mkdir -p "$bdir/devos/specs/archive/demo"
314
+ seq 1 121 >"$bdir/devos/product/codebase-map.md"
315
+ seq 1 121 >"$bdir/devos/specs/archive/demo/spec.md"
316
+ bout=$(bash "$AB" "$bdir" 2>&1)
317
+ check "budget: the map's cap is 120, not the capsule's 300" 1 \
318
+ "$(grep -c '^| OVER | devos/product/codebase-map.md | 121 | 120 |' <<<"$bout")"
319
+ check "budget: the same line count is OK inside a capsule's larger cap" 1 \
320
+ "$(grep -c '^| OK | devos/specs/archive/demo/spec.md | 121 | 300 |' <<<"$bout")"
321
+ check "budget: OVER rows lead the table so the actionable ones are read first" "OVER" \
322
+ "$(grep '^| ' <<<"$bout" | sed -n '3p' | awk -F'|' '{gsub(/ /,"",$2); print $2}')"
323
+ check "budget: every OVER artifact is counted in the failure line" 1 \
324
+ "$(grep -c '^2 artifact(s) OVER budget' <<<"$bout")"
325
+
326
+ # A behaviors file shares the domain model's 60-line page budget.
327
+ mkdir -p "$bdir/devos/product/behaviors"
328
+ seq 1 61 >"$bdir/devos/product/behaviors/thing.md"
329
+ check "budget: a behaviors capability page shares the 60-line cap" 1 \
330
+ "$(bash "$AB" "$bdir" 2>&1 | grep -c '^| OVER | devos/product/behaviors/thing.md | 61 | 60 |')"
331
+
332
+ check "budget: a missing repo directory fails loudly" 1 \
333
+ "$(bash "$AB" "$tmp/no-such-dir" >/dev/null 2>&1; echo $?)"
334
+
335
+ # --- convention-usage.sh: which conventions capsules actually exercised -----
336
+ CU="$SKILLS/status/scripts/convention-usage.sh"
337
+ cdir="$tmp/convuse"
338
+ cbdir="$tmp/convuse-bullets"
339
+
340
+ mkdir -p "$cdir"
341
+ check "convuse: no conventions.md is not a failure" 0 \
342
+ "$(bash "$CU" "$cdir" >/dev/null 2>&1; echo $?)"
343
+ check "convuse: no conventions.md says so" 1 \
344
+ "$(bash "$CU" "$cdir" 2>&1 | grep -c 'nothing onboarded')"
345
+
346
+ mkdir -p "$cdir/devos/standards" "$cdir/devos/specs/archive"
347
+ {
348
+ echo "# Project Conventions"
349
+ echo ""
350
+ echo "## Testing"
351
+ echo ""
352
+ echo "- Asserts live in \`plugins/devos/scripts/gates/test-gates.sh\`, no framework."
353
+ echo "- Fixtures under \`evals/fixtures/\` are copied to a temp dir first."
354
+ echo "- One logical change per commit."
355
+ echo "- Never invoke \`legacy/old-runner.sh\`; it was replaced."
356
+ echo "- Each spec writes a \`devos/specs/<name>/spec.md\` capsule."
357
+ } >"$cdir/devos/standards/conventions.md"
358
+
359
+ # Below the floor the ratio is meaningless, so it must refuse rather than guess.
360
+ for n in a b c; do
361
+ mkdir -p "$cdir/devos/specs/archive/spec-$n"
362
+ echo "ran test-gates.sh over evals/fixtures/thing" >"$cdir/devos/specs/archive/spec-$n/spec.md"
363
+ done
364
+ check "convuse: below 5 capsules reports INSUFFICIENT DATA" 1 \
365
+ "$(bash "$CU" "$cdir" 2>&1 | grep -c 'INSUFFICIENT DATA: only 3 archived capsule')"
366
+ check "convuse: INSUFFICIENT DATA still exits 0 (a report, not a gate)" 0 \
367
+ "$(bash "$CU" "$cdir" >/dev/null 2>&1; echo $?)"
368
+
369
+ for n in d e; do
370
+ mkdir -p "$cdir/devos/specs/archive/spec-$n"
371
+ echo "ran test-gates.sh over evals/fixtures/thing" >"$cdir/devos/specs/archive/spec-$n/spec.md"
372
+ done
373
+ cout=$(bash "$CU" "$cdir" 2>&1)
374
+
375
+ check "convuse: at the floor it reports instead of refusing" 1 \
376
+ "$(grep -c '^Source: 5 archived capsule' <<<"$cout")"
377
+ check "convuse: an exact path match counts as CITED" 1 \
378
+ "$(grep -c '^| CITED | 2 |' <<<"$cout")"
379
+ check "convuse: a full-path convention is CITED when the capsule names just the file" 1 \
380
+ "$(grep -c '| test-gates.sh |' <<<"$cout")"
381
+ check "convuse: a basename-only match is flagged for a second look" 1 \
382
+ "$(grep -c '^## CITED by filename only' <<<"$cout")"
383
+ check "convuse: an unambiguous full-path match is not listed as needing one" 0 \
384
+ "$(sed -n '/^## CITED by filename only/,/^$/p' <<<"$cout" | grep -c 'evals/fixtures')"
385
+ check "convuse: an identifier no capsule mentions is UNCITED" 1 \
386
+ "$(grep -c 'Never invoke legacy/old-runner.sh' <<<"$cout")"
387
+ check "convuse: a prose-only entry is UNMEASURABLE, never UNCITED" 1 \
388
+ "$(grep -c '^| UNMEASURABLE | 1 |' <<<"$cout")"
389
+ check "convuse: a generic basename never produces a false CITED" 1 \
390
+ "$(grep -c 'devos/specs/<name>/spec.md' <<<"$cout")"
391
+ check "convuse: every entry lands in exactly one class" "5" \
392
+ "$(awk -F'|' '/^\| (CITED|UNCITED|UNMEASURABLE) \|/ {s+=$3} END{print s}' <<<"$cout")"
393
+ mkdir -p "$cdir/devos/specs/archive/spec-f"
394
+ printf '%s\n' "ran test-gates.sh over evals/fixtures/thing" > "$cdir/devos/specs/archive/spec-f/spec.md"
395
+ printf '%s' '- Never invoke `legacy/final-runner.sh`; it was replaced.' > "$cdir/devos/standards/conventions.md"
396
+ cfinal=$(bash "$CU" "$cdir" 2>&1)
397
+ check "convuse: a final unterminated bullet is counted" 1 \
398
+ "$(grep -c '^| UNCITED | 1 |$' <<<"$cfinal")"
399
+ check "convuse: uncited entries never change the exit code" 0 \
400
+ "$(bash "$CU" "$cdir" >/dev/null 2>&1; echo $?)"
401
+ check "convuse: a missing repo directory fails loudly" 1 \
402
+ "$(bash "$CU" "$tmp/no-such-dir" >/dev/null 2>&1; echo $?)"
403
+
404
+ # Both markdown bullet markers make an entry. Only the dash form was
405
+ # recognized, so a convention written `* foo` was dropped from every class and
406
+ # from the total: a file with two entries reported one.
407
+ mkdir -p "$cbdir/devos/specs/archive" "$cbdir/devos/standards"
408
+ for n in one two three four five; do
409
+ mkdir -p "$cbdir/devos/specs/archive/spec-$n"
410
+ echo "uses src/index.js" >"$cbdir/devos/specs/archive/spec-$n/spec.md"
411
+ done
412
+ {
413
+ echo "# Project Conventions"
414
+ echo ""
415
+ echo "## Testing"
416
+ echo ""
417
+ echo "- \`src/index.js\`: keep the entry point thin."
418
+ echo "* \`lib/unused.ts\`: written with a star bullet."
419
+ } >"$cbdir/devos/standards/conventions.md"
420
+ cbout=$(bash "$CU" "$cbdir" 2>&1)
421
+ check "convuse: a star-bulleted entry is counted" 1 \
422
+ "$(grep -c '^| Total entries | 2 |' <<<"$cbout")"
423
+ check "convuse: an uncited star-bulleted entry is reported, not dropped" 1 \
424
+ "$(grep -c 'lib/unused.ts' <<<"$cbout")"
425
+ check "convuse: both bullet forms land in exactly one class" "2" \
426
+ "$(awk -F'|' '/^\| (CITED|UNCITED|UNMEASURABLE) \|/ {s+=$3} END{print s}' <<<"$cbout")"
427
+ printf 'uses lib/unused.ts\n' >>"$cbdir/devos/specs/archive/spec-one/spec.md"
428
+ cbcited=$(bash "$CU" "$cbdir" 2>&1)
429
+ check "convuse: a cited star-bulleted entry is CITED" 1 \
430
+ "$(grep -c '^| CITED | 2 |' <<<"$cbcited")"
431
+ check "convuse: a cited star-bulleted entry is not left in UNCITED" 1 \
432
+ "$(grep -c '^| UNCITED | 0 |' <<<"$cbcited")"
433
+ # A star-bulleted prose-only entry is still unmeasurable, not cited by accident.
434
+ {
435
+ echo "# Project Conventions"
436
+ echo ""
437
+ echo "- one logical change per commit."
438
+ echo "* \`legacy/old-runner.sh\` was replaced."
439
+ } >"$cbdir/devos/standards/conventions.md"
440
+ cbprose=$(bash "$CU" "$cbdir" 2>&1)
441
+ check "convuse: an uncited star-bulleted entry is UNCITED by identifier" 1 \
442
+ "$(grep -c '^| UNCITED | 1 |' <<<"$cbprose")"
443
+ check "convuse: a prose-only star-bulleted entry is UNMEASURABLE" 1 \
444
+ "$(grep -c '^| UNMEASURABLE | 1 |' <<<"$cbprose")"
445
+
446
+ # A spec directory name is a free-form slug, so it can contain a space. The
447
+ # haystack was built with cat over an unquoted expansion, so such a path split
448
+ # into two arguments that both failed to open, stderr was discarded, and the
449
+ # capsule vanished from the search. Every entry only that capsule mentioned was
450
+ # then listed UNCITED, which is the list a reader is told to consider deleting.
451
+ csdir="$tmp/convuse-spaced"
452
+ mkdir -p "$csdir/devos/standards" "$csdir/devos/specs/archive/alpha feature"
453
+ printf 'uses lib/spaced.ts\n' > "$csdir/devos/specs/archive/alpha feature/spec.md"
454
+ for n in beta gamma delta epsilon; do
455
+ mkdir -p "$csdir/devos/specs/archive/spec-$n"
456
+ echo "ran test-gates.sh over evals/fixtures/thing" >"$csdir/devos/specs/archive/spec-$n/spec.md"
457
+ done
458
+ {
459
+ echo "# Project Conventions"
460
+ echo ""
461
+ echo "- \`lib/spaced.ts\`: keep the archive loader in sync."
462
+ echo "- \`lib/absent.ts\`: delete once it is dead."
463
+ } >"$csdir/devos/standards/conventions.md"
464
+ csout=$(bash "$CU" "$csdir" 2>&1)
465
+ # Control: the identifier no capsule mentions must still be UNCITED, so a
466
+ # script that classified nothing at all cannot satisfy the next check.
467
+ check "convuse: an identifier no capsule mentions is still UNCITED" 1 \
468
+ "$(grep -c 'lib/absent.ts' <<<"$csout")"
469
+ check "convuse: a capsule under a spaced directory is searched" 1 \
470
+ "$(grep -c '^| CITED | 1 |' <<<"$csout")"
471
+ check "convuse: a spaced-capsule entry is not put on the delete list" 0 \
472
+ "$(grep -c 'lib/spaced.ts' <<<"$csout")"
473
+ check "convuse: a spaced spec directory still counts toward the capsule floor" 1 \
474
+ "$(grep -c '^Source: 5 archived capsule' <<<"$csout")"
475
+
476
+ # --- Sizing calibration ------------------------------------------------------
477
+ # The router's size letter lands in the started event's detail; the capsule's
478
+ # task groups are reality. M with many groups is under-sized, L with one is
479
+ # over-sized, and a started detail without an S/M/L (resume notes) is skipped.
480
+ SC="$SKILLS/status/scripts/sizing-calibration.sh"
481
+ sz="$tmp/sizing/devos/specs"
482
+ mkdir -p "$sz/a" "$sz/b" "$sz/archive/c" "$sz/archive/d" "$sz/archive/e"
483
+ printf '{"at":"t","event":"started","detail":"M"}\n' > "$sz/a/ops.jsonl"
484
+ for i in 1 2 3 4 5 6; do printf '### Task Group %d: g\n' "$i"; done > "$sz/a/spec.md"
485
+ printf '{"at":"t","event":"started","detail":"L"}\n' > "$sz/b/ops.jsonl"
486
+ printf '### Task Group 1: only\n' > "$sz/b/spec.md"
487
+ printf '{"at":"t","event":"started","detail":"resuming at Phase C"}\n' > "$sz/archive/c/ops.jsonl"
488
+ printf '### Task Group 1: g\n' > "$sz/archive/c/spec.md"
489
+ # A capital in a path is not a sizing decision. d names a file and nothing
490
+ # else, so the router never sized it and there is nothing to calibrate; e
491
+ # names the same file and then carries the real size call, which must still
492
+ # be read.
493
+ printf '{"at":"t","event":"started","detail":"resuming: rewrite src/L.ts parser"}\n' > "$sz/archive/d/ops.jsonl"
494
+ printf '### Task Group 1: g\n' > "$sz/archive/d/spec.md"
495
+ printf '{"at":"t","event":"started","detail":"resuming: rewrite src/L.ts parser, routed L"}\n' > "$sz/archive/e/ops.jsonl"
496
+ printf '### Task Group 1: g\n' > "$sz/archive/e/spec.md"
497
+ out=$(bash "$SC" "$tmp/sizing" 2>&1)
498
+ grep -q "UNDERSIZED a: sized M, capsule has 6 task groups" <<<"$out" \
499
+ && check "sizing: M with 6 groups reported under-sized" 0 $? \
500
+ || { echo "FAIL sizing: under-sized M not flagged"; echo "$out"; fail=1; }
501
+ grep -q "OVERSIZED b: sized L, capsule has 1 task group" <<<"$out" \
502
+ && check "sizing: L with 1 group reported over-sized" 0 $? \
503
+ || { echo "FAIL sizing: over-sized L not flagged"; fail=1; }
504
+ grep -q "UNDERSIZED c\|OVERSIZED c" <<<"$out" \
505
+ && { echo "FAIL sizing: resume detail without size letter was scored"; fail=1; } || true
506
+ grep -q "UNDERSIZED d\|OVERSIZED d" <<<"$out" \
507
+ && { echo "FAIL sizing: a detail naming a file was read as a size call"; echo "$out"; fail=1; } || true
508
+ grep -q "OVERSIZED e: sized L, capsule has 1 task group" <<<"$out" \
509
+ && check "sizing: a size call after a file name is still read" 0 $? \
510
+ || { echo "FAIL sizing: size call after a file name was lost"; echo "$out"; fail=1; }
511
+ grep -q "calibrated: 0 ok, 1 under-sized M, 2 over-sized L" <<<"$out" \
512
+ && check "sizing: summary counts mismatches and skips resume details" 0 $? \
513
+ || { echo "FAIL sizing: wrong summary counts"; echo "$out"; fail=1; }
514
+ out=$(bash "$SC" "$tmp/no-such-project" 2>&1); rc=$?
515
+ [[ $rc -eq 0 && -n "$out" ]] || { echo "FAIL sizing: missing specs dir must advise, got rc=$rc"; fail=1; }
516
+