@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.
- package/CHANGELOG.md +23 -0
- package/README.md +26 -33
- package/package.json +1 -2
- package/plugins/devos/agents/verifier.md +4 -30
- package/plugins/devos/pi/extension/devos.ts +16 -26
- package/plugins/devos/scripts/check-evidence-router.sh +7 -1
- package/plugins/devos/scripts/evidence-router.py +5 -3
- package/plugins/devos/scripts/gates/check-dod-core.sh +5 -3
- package/plugins/devos/scripts/gates/check-port-source.sh +1 -1
- package/plugins/devos/scripts/gates/check-scenario-coverage.sh +10 -8
- package/plugins/devos/scripts/gates/phase-gate.sh +6 -6
- package/plugins/devos/scripts/gates/plan-template-check.py +6 -12
- package/plugins/devos/scripts/gates/spec-contract.sh +19 -0
- package/plugins/devos/scripts/gates/spec-template-check.py +8 -21
- package/plugins/devos/scripts/gates/suite/01-dod.sh +485 -0
- package/plugins/devos/scripts/gates/suite/02-integrity.sh +310 -0
- package/plugins/devos/scripts/gates/suite/03-archetype.sh +255 -0
- package/plugins/devos/scripts/gates/suite/04-spec-validator.sh +183 -0
- package/plugins/devos/scripts/gates/suite/05-requires.sh +360 -0
- package/plugins/devos/scripts/gates/suite/06-clarify-adapters.sh +435 -0
- package/plugins/devos/scripts/gates/suite/07-lint-evals.sh +350 -0
- package/plugins/devos/scripts/gates/suite/08-converge.sh +591 -0
- package/plugins/devos/scripts/gates/suite/09-quality.sh +516 -0
- package/plugins/devos/scripts/gates/suite/10-eval-harness.sh +679 -0
- package/plugins/devos/scripts/gates/test-gates.sh +23 -4253
- package/plugins/devos/scripts/gates/test-integrity-rubric.sh +1 -1
- package/plugins/devos/scripts/gates/test-phase-gate.sh +5 -5
- package/plugins/devos/skills/build/SKILL.md +3 -3
- package/plugins/devos/skills/build/references/refactor.md +1 -1
- package/plugins/devos/skills/build/references/routes.md +4 -4
- package/plugins/devos/skills/frame/SKILL.md +22 -39
- package/plugins/devos/skills/frame/references/template.md +115 -0
- package/plugins/devos/skills/implement/SKILL.md +4 -4
- package/plugins/devos/skills/implement/references/dod.md +6 -1
- package/plugins/devos/skills/implement/references/implement.md +3 -1
- package/plugins/devos/skills/implement/references/plan.md +9 -27
- package/plugins/devos/skills/implement/references/resume.md +1 -1
- package/plugins/devos/skills/implement/references/verify-close.md +4 -3
- package/plugins/devos/skills/implement/scripts/ops-log.sh +2 -2
- package/plugins/devos/skills/implement/scripts/validate-spec.sh +17 -65
- package/plugins/devos/skills/init/references/context.md +1 -1
- package/plugins/devos/skills/review/SKILL.md +24 -47
- package/plugins/devos/skills/review/references/comments.md +13 -0
- package/plugins/devos/skills/review/references/reviewer.md +124 -0
- package/plugins/devos/skills/review/references/routing.md +35 -0
- package/plugins/devos/skills/review/scripts/__pycache__/prepare.cpython-313.pyc +0 -0
- package/plugins/devos/skills/review/scripts/prepare.py +763 -0
- package/plugins/devos/skills/spec/SKILL.md +5 -6
- package/plugins/devos/skills/spec/references/write-spec.md +36 -51
- package/plugins/devos/skills/spec/scripts/clarify.sh +4 -4
- package/plugins/devos/skills/status/SKILL.md +4 -4
- package/plugins/devos/skills/status/scripts/check-requires.py +4 -4
- package/plugins/devos/skills/status/scripts/convention-usage.sh +1 -1
- package/plugins/devos/skills/status/scripts/quality-correlation.sh +2 -25
- package/plugins/devos/scripts/gates/check-handoff.sh +0 -215
- package/plugins/devos/skills/design-taste/SKILL.md +0 -55
- package/plugins/devos/skills/design-taste/references/tells.md +0 -85
- package/plugins/devos/skills/design-taste/scripts/slop-scan.py +0 -305
- package/plugins/devos/skills/docs/SKILL.md +0 -22
- package/plugins/devos/skills/docs/references/backfill.md +0 -54
- package/plugins/devos/skills/docs/references/init.md +0 -43
- package/plugins/devos/skills/docs/references/status.md +0 -71
- package/plugins/devos/skills/docs/references/update.md +0 -80
- package/plugins/devos/skills/explain/SKILL.md +0 -45
- package/plugins/devos/skills/explain/references/quiz.md +0 -21
- package/plugins/devos/skills/frame/references/boundaries.md +0 -53
- package/plugins/devos/skills/frame/references/decompose.md +0 -96
- package/plugins/devos/skills/frame/references/impact.md +0 -43
- package/plugins/devos/skills/frame/references/interrogate.md +0 -68
- package/plugins/devos/skills/product/SKILL.md +0 -40
- package/plugins/devos/skills/product/references/planner.md +0 -54
- package/plugins/devos/skills/surgical-diff/SKILL.md +0 -23
- package/plugins/devos/skills/test-integrity/SKILL.md +0 -26
- package/plugins/devos/skills/verification-evidence/SKILL.md +0 -17
- package/plugins/devos/workflows/common/backlog-file-structure.md +0 -44
- package/plugins/devos/workflows/common/category-file-structure.md +0 -41
- package/plugins/devos/workflows/common/feature-line-format.md +0 -10
- package/plugins/devos/workflows/common/roadmap-file-structure.md +0 -51
- package/plugins/devos/workflows/common/suggest-categories.md +0 -76
- package/plugins/devos/workflows/common/suggest-milestones.md +0 -92
- package/plugins/devos/workflows/doc/doc-health.md +0 -137
- package/plugins/devos/workflows/doc/doc-writer.md +0 -44
- package/plugins/devos/workflows/doc/init-documentation.md +0 -196
- package/plugins/devos/workflows/doc/retro-documentation.md +0 -304
- package/plugins/devos/workflows/doc/templates/library.md +0 -58
- package/plugins/devos/workflows/doc/templates/service.md +0 -61
- package/plugins/devos/workflows/doc/update-documentation.md +0 -194
- package/plugins/devos/workflows/doc/write-documentation.md +0 -137
- package/plugins/devos/workflows/product/create-product-mission.md +0 -45
- package/plugins/devos/workflows/product/create-product-roadmap.md +0 -106
- package/plugins/devos/workflows/product/create-product-tech-stack.md +0 -19
- package/plugins/devos/workflows/product/gather-product-info.md +0 -25
- package/plugins/devos/workflows/product/resume-detection.md +0 -70
- package/plugins/devos/workflows/product/reverse-backlog.md +0 -118
- package/plugins/devos/workflows/product/reverse-domain-model.md +0 -86
- package/plugins/devos/workflows/product/reverse-product-plan.md +0 -81
- package/plugins/devos/workflows/product/reverse-tech-stack.md +0 -73
- package/plugins/devos/workflows/product/scan-deep.md +0 -113
- package/plugins/devos/workflows/product/scan-git.md +0 -122
- package/plugins/devos/workflows/product/scan-light.md +0 -154
|
@@ -0,0 +1,679 @@
|
|
|
1
|
+
# --- Scenario <-> criteria consistency -------------------------------------
|
|
2
|
+
# Every scenario must have a criteria file and vice versa. A scenario without
|
|
3
|
+
# criteria can never be scored; criteria without a scenario is dead config.
|
|
4
|
+
missing=0
|
|
5
|
+
for s in "$EVALS"/scenarios/*.md; do
|
|
6
|
+
name=$(basename "$s" .md)
|
|
7
|
+
[[ -f "$EVALS/criteria/${name}.json" ]] || { echo "FAIL scenario $name: no criteria.json" >&2; missing=1; }
|
|
8
|
+
done
|
|
9
|
+
for c in "$EVALS"/criteria/*.json; do
|
|
10
|
+
name=$(basename "$c" .json)
|
|
11
|
+
[[ "$name" == "_selftest-needs" || "$name" == "_selftest-flip" || "$name" == "_selftest-hold" ]] && continue
|
|
12
|
+
[[ -f "$EVALS/scenarios/${name}.md" ]] || { echo "FAIL criteria $name: no scenario.md" >&2; missing=1; }
|
|
13
|
+
done
|
|
14
|
+
check "every scenario has criteria and every criteria has a scenario" 0 "$missing"
|
|
15
|
+
|
|
16
|
+
# --- Concurrent template-cache invalidation ---------------------------------
|
|
17
|
+
# no-op-gate and oracle-gate start together under `just verify`. If both see
|
|
18
|
+
# a stale fingerprint before either takes the lock, the second process must
|
|
19
|
+
# re-check after acquisition. Otherwise it deletes templates the first process
|
|
20
|
+
# is already building. Hold the lock, advance the fingerprint, then call ensure.
|
|
21
|
+
(
|
|
22
|
+
export EVAL_DIR="$EVALS"
|
|
23
|
+
TEMPLATES="$tmp/template-cache"
|
|
24
|
+
source "$EVALS/build-templates.sh" || exit 1
|
|
25
|
+
mkdir -p "$TEMPLATES"
|
|
26
|
+
printf 'stale\n' >"$TEMPLATES/.fingerprint"
|
|
27
|
+
mkdir "$TEMPLATES.lock"
|
|
28
|
+
printf 'keep\n' >"$TEMPLATES/sentinel"
|
|
29
|
+
want=$(templates_fingerprint)
|
|
30
|
+
(
|
|
31
|
+
sleep 0.2
|
|
32
|
+
printf '%s\n' "$want" >"$TEMPLATES/.fingerprint"
|
|
33
|
+
rmdir "$TEMPLATES.lock"
|
|
34
|
+
) &
|
|
35
|
+
ensure_templates_fresh
|
|
36
|
+
wait
|
|
37
|
+
test -f "$TEMPLATES/sentinel"
|
|
38
|
+
)
|
|
39
|
+
check "concurrent cache invalidation preserves templates built by the lock holder" 0 "$?"
|
|
40
|
+
|
|
41
|
+
# --- Every scenario has a template build case --------------------------------
|
|
42
|
+
# A scenario with no build_template case in run.sh silently runs against an
|
|
43
|
+
# empty repo, producing garbage scores. EVAL_TEMPLATES_ONLY=1 reports EMPTY,
|
|
44
|
+
# but `just evals` doesn't set it. Catch the gap in `just verify` by dry-running
|
|
45
|
+
# the same template build and flagging any EMPTY result.
|
|
46
|
+
tmpl_out=$(EVAL_TEMPLATES_ONLY=1 bash "$EVALS/run.sh" 2>&1)
|
|
47
|
+
empty_count=$(grep -c 'EMPTY' <<<"$tmpl_out" || true)
|
|
48
|
+
check "no scenario has an empty template build" 0 "$empty_count"
|
|
49
|
+
|
|
50
|
+
# --- Criteria must discriminate (at least one non-transcript criterion fails) ---
|
|
51
|
+
# A criterion that passes against the pre-fix template is dead weight: it adds
|
|
52
|
+
# to the total but can never catch a regression. For each scenario, at least
|
|
53
|
+
# one filesystem-checkable criterion MUST fail against the untouched template.
|
|
54
|
+
# Pure-analysis scenarios (all criteria need a transcript) are validated by the
|
|
55
|
+
# transcript-dependency check instead — they need at least one non-transcript
|
|
56
|
+
# pre-condition criterion to be scored at all.
|
|
57
|
+
disc_fail=0
|
|
58
|
+
for s in "$EVALS"/scenarios/*.md; do
|
|
59
|
+
name=$(basename "$s" .md)
|
|
60
|
+
[[ "$name" == "_selftest-needs" || "$name" == "_selftest-flip" || "$name" == "_selftest-hold" ]] && continue
|
|
61
|
+
crit="$EVALS/criteria/${name}.json"
|
|
62
|
+
[[ -f "$crit" ]] || continue
|
|
63
|
+
tmpl="$EVALS/templates/$name"
|
|
64
|
+
if [[ ! -d "$tmpl" ]]; then
|
|
65
|
+
( cd "$EVALS" && EVAL_TEMPLATES_ONLY=1 bash run.sh >/dev/null 2>&1 )
|
|
66
|
+
fi
|
|
67
|
+
[[ -d "$tmpl" ]] || continue
|
|
68
|
+
# Count filesystem vs transcript criteria.
|
|
69
|
+
total=$(python3 -c "import json;print(len(json.load(open('$crit'))))")
|
|
70
|
+
total_fs=$(python3 -c "import json;print(sum(1 for x in json.load(open('$crit')) if not x.get('needs')))")
|
|
71
|
+
total_tx=$((total - total_fs))
|
|
72
|
+
# Pure-analysis (all need transcript): validated by transcript-dependency check.
|
|
73
|
+
[[ "$total_fs" -eq 0 ]] && continue
|
|
74
|
+
# If there are transcript criteria AND filesystem criteria are pre-conditions
|
|
75
|
+
# (pass against template), that's OK — the transcript criteria do the real testing.
|
|
76
|
+
# Only flag if there are NO transcript criteria AND all filesystem criteria pass.
|
|
77
|
+
if [[ "$total_tx" -gt 0 ]]; then
|
|
78
|
+
# Has transcript criteria: filesystem criteria are pre-conditions. Skip discrimination check.
|
|
79
|
+
continue
|
|
80
|
+
fi
|
|
81
|
+
# Run each filesystem criterion against the template and count failures.
|
|
82
|
+
# Each check is designed to run with cwd=PROJ, so cd there first.
|
|
83
|
+
# The Python script prints the count of failing criteria to stdout.
|
|
84
|
+
fails=$(python3 - "$crit" "$tmpl" "$EVAL_DIR" <<'PYEOF'
|
|
85
|
+
import json, os, subprocess, sys
|
|
86
|
+
crit, proj, eval_dir = sys.argv[1], sys.argv[2], sys.argv[3]
|
|
87
|
+
with open(crit) as f:
|
|
88
|
+
criteria = json.load(f)
|
|
89
|
+
fs = [c for c in criteria if not c.get('needs')]
|
|
90
|
+
env = {**os.environ, 'PROJ': proj, 'EVAL_DIR': eval_dir, 'TRANSCRIPT': proj + '/transcript.jsonl'}
|
|
91
|
+
fails = 0
|
|
92
|
+
for c in fs:
|
|
93
|
+
try:
|
|
94
|
+
cmd = 'cd "$PROJ" && ' + c['check'] if not c['check'].strip().startswith('cd ') and 'cd "$PROJ"' not in c['check'] else c['check']
|
|
95
|
+
r = subprocess.run(['bash', '-c', cmd], capture_output=True, text=True, timeout=10, env=env)
|
|
96
|
+
if r.returncode != 0:
|
|
97
|
+
fails += 1
|
|
98
|
+
except Exception:
|
|
99
|
+
fails += 1
|
|
100
|
+
print(fails)
|
|
101
|
+
PYEOF
|
|
102
|
+
)
|
|
103
|
+
# fails is the count of failing criteria (captured from stdout).
|
|
104
|
+
if [[ "$fails" -eq 0 ]]; then
|
|
105
|
+
echo "FAIL $name: all $total_fs filesystem criteria pass against pre-fix template (none discriminate)" >&2
|
|
106
|
+
disc_fail=1
|
|
107
|
+
fi
|
|
108
|
+
done
|
|
109
|
+
check "every scenario has at least one discriminating filesystem criterion" 0 "$disc_fail"
|
|
110
|
+
|
|
111
|
+
# --- No scenario is entirely transcript-dependent --------------------------------
|
|
112
|
+
# If every criterion in a scenario needs a transcript, the scenario can never be
|
|
113
|
+
# scored without one — it's a manual-read item in disguise, not an eval. Flag it.
|
|
114
|
+
all_transcript=0
|
|
115
|
+
for c in "$EVALS"/criteria/*.json; do
|
|
116
|
+
name=$(basename "$c" .json)
|
|
117
|
+
[[ "$name" == "_selftest-needs" || "$name" == "_selftest-flip" || "$name" == "_selftest-hold" ]] && continue
|
|
118
|
+
total=$(python3 -c "import json;print(len(json.load(open('$c'))))")
|
|
119
|
+
needs_tx=$(python3 -c "import json;print(sum(1 for x in json.load(open('$c')) if x.get('needs')))")
|
|
120
|
+
if [[ "$total" -gt 0 && "$needs_tx" -eq "$total" ]]; then
|
|
121
|
+
echo "FAIL $name: all $total criteria need a transcript (scores 0 without one)" >&2
|
|
122
|
+
all_transcript=1
|
|
123
|
+
fi
|
|
124
|
+
done
|
|
125
|
+
check "no scenario is entirely transcript-dependent" 0 "$all_transcript"
|
|
126
|
+
|
|
127
|
+
# --- gate-check.mjs ---------------------------------------------------------
|
|
128
|
+
GC="$(dirname "$DOD")/gate-check.mjs"
|
|
129
|
+
g="$tmp/gates.md"
|
|
130
|
+
cat > "$g" <<'EOF'
|
|
131
|
+
# Gates: demo
|
|
132
|
+
|
|
133
|
+
- [ ] G1: passes via exit code
|
|
134
|
+
CHECK: echo ok
|
|
135
|
+
EVIDENCE: pending
|
|
136
|
+
|
|
137
|
+
- [ ] G2: passes via EXPECT regex
|
|
138
|
+
CHECK: echo "count: 42"
|
|
139
|
+
EXPECT: /count: 42/
|
|
140
|
+
EVIDENCE: pending
|
|
141
|
+
|
|
142
|
+
- [ ] G3: failing check stays unchecked
|
|
143
|
+
CHECK: false
|
|
144
|
+
EVIDENCE: pending
|
|
145
|
+
|
|
146
|
+
- [x] G4: checked box with pending evidence counts UNMET
|
|
147
|
+
EVIDENCE: pending
|
|
148
|
+
|
|
149
|
+
- [ ] G5: honestly abandoned
|
|
150
|
+
EVIDENCE: pending
|
|
151
|
+
ABANDON: G5 needs prod access this machine lacks
|
|
152
|
+
EOF
|
|
153
|
+
node "$GC" "$g" >/dev/null; check "gate-check: unmet gates exit 1" 1 $?
|
|
154
|
+
grep -q '^- \[x\] G1' "$g"; check "gate-check: passing gate flipped" 0 $?
|
|
155
|
+
grep -q '^- \[ \] G3' "$g"; check "gate-check: failing gate stays unchecked" 0 $?
|
|
156
|
+
grep -qE '^ EVIDENCE: ok' "$g"; check "gate-check: evidence recorded from output" 0 $?
|
|
157
|
+
grep -qE '^ EVIDENCE: count: 42' "$g"; check "gate-check: regex EXPECT recorded evidence" 0 $?
|
|
158
|
+
node "$GC" --status "$g" >/dev/null; check "gate-check: --status reports remaining unmet as exit 1" 1 $?
|
|
159
|
+
|
|
160
|
+
# A gate file may omit the EVIDENCE placeholder. The pass path used to flip the
|
|
161
|
+
# box and report ALL MET while writing nothing, so the next --status run on the
|
|
162
|
+
# same bytes read the checked box as an unproven claim and exited 1: one run's
|
|
163
|
+
# result contradicted the next on an unchanged file.
|
|
164
|
+
gnoev="$tmp/gates-no-evidence.md"
|
|
165
|
+
printf -- '- [ ] G1: no evidence line\n CHECK: echo ok\n EXPECT: ok\n- [ ] G2: second gate\n CHECK: echo world\n EXPECT: world\n' > "$gnoev"
|
|
166
|
+
node "$GC" "$gnoev" >/dev/null; check "gate-check: gates without an EVIDENCE line can pass" 0 $?
|
|
167
|
+
grep -qE '^ EVIDENCE: ok$' "$gnoev"; check "gate-check: a missing EVIDENCE line is written, not skipped" 0 $?
|
|
168
|
+
grep -qE '^ EVIDENCE: world$' "$gnoev"; check "gate-check: each gate keeps its own evidence after a line insert" 0 $?
|
|
169
|
+
[[ "$(grep -cE '^ EVIDENCE: ' "$gnoev")" == 2 ]]; check "gate-check: exactly one evidence line per gate" 0 $?
|
|
170
|
+
node "$GC" --status "$gnoev" >/dev/null; check "gate-check: the recorded evidence satisfies a later --status run" 0 $?
|
|
171
|
+
|
|
172
|
+
gok="$tmp/gates-ok.md"
|
|
173
|
+
printf -- '- [x] G1: done\n EVIDENCE: 3 rows rendered\n' > "$gok"
|
|
174
|
+
node "$GC" "$gok" >/dev/null; check "gate-check: all met exits 0" 0 $?
|
|
175
|
+
|
|
176
|
+
gdupe="$tmp/gates-duplicate.md"
|
|
177
|
+
cat > "$gdupe" <<'EOF'
|
|
178
|
+
- [ ] G1: first outcome
|
|
179
|
+
CHECK: false
|
|
180
|
+
EVIDENCE: pending
|
|
181
|
+
- [ ] G1: second outcome
|
|
182
|
+
CHECK: false
|
|
183
|
+
EVIDENCE: pending
|
|
184
|
+
ABANDON: G1 only one outcome was abandoned
|
|
185
|
+
EOF
|
|
186
|
+
out=$(node "$GC" --status "$gdupe" 2>&1); rc=$?
|
|
187
|
+
check "gate-check: duplicate identifiers are a parse error" 2 $rc
|
|
188
|
+
printf '%s\n' "$out" | grep -Fq 'duplicate gate identifier G1'; check "gate-check: duplicate diagnostic names the identifier" 0 $?
|
|
189
|
+
|
|
190
|
+
# The gates.md format is enforced by gate-check.mjs alone. check-dod-core.sh
|
|
191
|
+
# deliberately does not parse it, so there is no DoD
|
|
192
|
+
# blocking case to test here until a real spec uses gates and earns enforcement.
|
|
193
|
+
|
|
194
|
+
# --- evals/run.sh isolation and timeout -------------------------------------
|
|
195
|
+
# A machine-local pi extension can fail before an eval starts. Both DevOS and
|
|
196
|
+
# baseline runs must disable those extensions. A child that ignores TERM must
|
|
197
|
+
# also not leave the eval harness waiting forever.
|
|
198
|
+
run_sh=$(cat "$EVALS/run.sh")
|
|
199
|
+
if grep -q 'local ext_args=(-ne)' <<<"$run_sh" && grep -q 'pi -p "$prompt" ${PROVIDER:+--provider "$PROVIDER"}' <<<"$run_sh"; then isolation_ok=0; else isolation_ok=1; fi
|
|
200
|
+
check "eval pi invocations disable machine-local extensions" 0 "$isolation_ok"
|
|
201
|
+
|
|
202
|
+
timeout_fn=$(awk '/^run_with_timeout\(\)/,/^}/' "$EVALS/run.sh")
|
|
203
|
+
timeout_rc=0
|
|
204
|
+
timeout_start=$(date +%s)
|
|
205
|
+
(eval "$timeout_fn"; run_with_timeout 1 bash -c 'trap "" TERM; sleep 5') >/dev/null 2>&1 || timeout_rc=$?
|
|
206
|
+
timeout_elapsed=$(( $(date +%s) - timeout_start ))
|
|
207
|
+
if [[ "$timeout_rc" -ne 0 && "$timeout_elapsed" -le 3 ]]; then timeout_ok=0; else timeout_ok=1; fi
|
|
208
|
+
check "run timeout kills a TERM-ignoring child" 0 "$timeout_ok"
|
|
209
|
+
(eval "$timeout_fn"; run_with_timeout 5 bash -c 'exit 0') >/dev/null 2>&1
|
|
210
|
+
check "run timeout preserves a successful child" 0 "$?"
|
|
211
|
+
|
|
212
|
+
# --- build/scripts/ledger.sh (H route) --------------------------------------
|
|
213
|
+
# The H route's two evidence-backed decisions live in the script, so they get a
|
|
214
|
+
# real test instead of a prose promise: `next` must flag a reissued task, and
|
|
215
|
+
# `notes` must replace and cap instead of growing. Every action runs against a
|
|
216
|
+
# throwaway run dir, the same way the route runs it.
|
|
217
|
+
LEDGER="$REPO_ROOT/plugins/devos/skills/build/scripts/ledger.sh"
|
|
218
|
+
|
|
219
|
+
lr="$tmp/hard-run"
|
|
220
|
+
bash "$LEDGER" init --dir "$lr" --task "make the widget pass" --check "true" >/dev/null
|
|
221
|
+
check "ledger: init creates the run" 0 $?
|
|
222
|
+
grep -q 'make the widget pass' "$lr/task.md"; check "ledger: init writes task.md" 0 $?
|
|
223
|
+
|
|
224
|
+
lpa="$tmp/ledger-path-artifact"
|
|
225
|
+
out=$(bash "$LEDGER" init --dir "$lpa" --task "make a path artifact" --artifact ../escaped.txt 2>&1); rc=$?
|
|
226
|
+
check "ledger: rejects a path artifact" 2 "$rc"
|
|
227
|
+
grep -Fq 'artifact must be a file name' <<<"$out"; check "ledger: names the artifact path contract" 0 $?
|
|
228
|
+
[[ ! -e "$tmp/escaped.txt" ]]; check "ledger: does not create an escaped artifact" 0 $?
|
|
229
|
+
|
|
230
|
+
out=$(bash "$LEDGER" read --dir "$lr")
|
|
231
|
+
printf '%s' "$out" | grep -q 'round: 0/10'; check "ledger: read shows the round budget" 0 $?
|
|
232
|
+
printf '%s' "$out" | grep -q 'artifact: solution.py (empty)'; check "ledger: read reports an empty artifact" 0 $?
|
|
233
|
+
|
|
234
|
+
# Plan is capped, not trusted whole.
|
|
235
|
+
out=$(head -c 5000 /dev/zero | tr '\0' 'p' | bash "$LEDGER" plan --dir "$lr")
|
|
236
|
+
[ "$(wc -c < "$lr/plan.md" | tr -d ' ')" -le 4000 ]; check "ledger: plan capped at 4000" 0 $?
|
|
237
|
+
# Capping without saying so reads as a plan that landed whole, and the worker
|
|
238
|
+
# is handed the cut half.
|
|
239
|
+
printf '%s' "$out" | grep -q 'TRUNCATED'; check "ledger: an over-cap plan says it was cut" 0 $?
|
|
240
|
+
printf 'short plan\n' | bash "$LEDGER" plan --dir "$lr" | grep -q 'TRUNCATED'
|
|
241
|
+
[[ $? -ne 0 ]]; check "ledger: a plan that fits is not reported as cut" 0 $?
|
|
242
|
+
|
|
243
|
+
printf -- '- [todo] first\n- [todo] second\n' | bash "$LEDGER" tasks --dir "$lr" >/dev/null
|
|
244
|
+
[ "$(grep -c '^- \[' "$lr/tasks.md" || true)" = "2" ]; check "ledger: tasks keeps only list lines" 0 $?
|
|
245
|
+
|
|
246
|
+
# The guard: the same task twice is the no-progress signal the paper relies on.
|
|
247
|
+
bash "$LEDGER" next --dir "$lr" --task "patch the parser" >/dev/null
|
|
248
|
+
out=$(bash "$LEDGER" next --dir "$lr" --task "Patch the parser")
|
|
249
|
+
printf '%s' "$out" | grep -q 'GUARD:'; check "ledger: reissued task raises the guard" 0 $?
|
|
250
|
+
printf '%s' "$out" | grep -q 'round 2/10'; check "ledger: next increments the round" 0 $?
|
|
251
|
+
|
|
252
|
+
# The round budget is a guard, not display text. Exhaustion must stop before
|
|
253
|
+
# the task or round mutates, or the manager can run forever past its cap.
|
|
254
|
+
lbr="$tmp/hard-run-budget"
|
|
255
|
+
bash "$LEDGER" init --dir "$lbr" --task "initial task" --check "true" --max-iters 1 >/dev/null
|
|
256
|
+
bash "$LEDGER" next --dir "$lbr" --task "allowed task" >/dev/null
|
|
257
|
+
out=$(bash "$LEDGER" next --dir "$lbr" --task "over-budget task" 2>&1); rc=$?
|
|
258
|
+
check "ledger: exhausted round budget refuses another task" 1 "$rc"
|
|
259
|
+
printf '%s' "$out" | grep -q 'STOP: iteration budget exhausted (1/1)'; check "ledger: exhausted budget names the limit" 0 $?
|
|
260
|
+
[[ "$(awk -F= '$1=="round" {print $2}' "$lbr/meta")" == "1" ]]; check "ledger: refused task does not increment the round" 0 $?
|
|
261
|
+
[[ "$(awk -F= '$1=="last_task" {sub(/^[^=]*=/, ""); print}' "$lbr/meta")" == "allowed task" ]]; check "ledger: refused task does not replace the last task" 0 $?
|
|
262
|
+
|
|
263
|
+
# Budget validation must happen before init creates any run state. A valid
|
|
264
|
+
# positive integer remains a usable control for the same command.
|
|
265
|
+
for invalid_budget in nope 0 -1; do
|
|
266
|
+
invalid_dir="$tmp/invalid-budget-$invalid_budget"
|
|
267
|
+
out=$(bash "$LEDGER" init --dir "$invalid_dir" --task "invalid budget" --check true --max-iters "$invalid_budget" 2>&1); rc=$?
|
|
268
|
+
check "ledger: rejects invalid budget $invalid_budget" 2 "$rc"
|
|
269
|
+
grep -Fq 'max-iters must be a positive integer' <<<"$out"; check "ledger: names invalid budget $invalid_budget" 0 $?
|
|
270
|
+
[[ ! -e "$invalid_dir" ]]; check "ledger: does not create state for invalid budget $invalid_budget" 0 $?
|
|
271
|
+
done
|
|
272
|
+
valid_budget_dir="$tmp/valid-budget"
|
|
273
|
+
bash "$LEDGER" init --dir "$valid_budget_dir" --task "valid budget" --check true --max-iters 2 >/dev/null
|
|
274
|
+
check "ledger: accepts a positive budget" 0 $?
|
|
275
|
+
grep -q '^max_iters=2$' "$valid_budget_dir/meta"; check "ledger: stores the validated positive budget" 0 $?
|
|
276
|
+
|
|
277
|
+
# Notes replace by default and cap; --append adds without unbounded growth.
|
|
278
|
+
printf 'first finding\n' | bash "$LEDGER" notes --dir "$lr" >/dev/null
|
|
279
|
+
printf 'second finding\n' | bash "$LEDGER" notes --dir "$lr" >/dev/null
|
|
280
|
+
[ "$(cat "$lr/notes.md")" = "second finding" ]; check "ledger: notes replace, old content gone" 0 $?
|
|
281
|
+
head -c 9000 /dev/zero | tr '\0' 'n' | bash "$LEDGER" notes --dir "$lr" --append >/dev/null
|
|
282
|
+
[ "$(wc -c < "$lr/notes.md" | tr -d ' ')" -le 8000 ]; check "ledger: notes capped at 8000" 0 $?
|
|
283
|
+
out=$(head -c 9000 /dev/zero | tr '\0' 'n' | bash "$LEDGER" notes --dir "$lr")
|
|
284
|
+
printf '%s' "$out" | grep -q 'TRUNCATED'; check "ledger: over-cap notes say they were cut" 0 $?
|
|
285
|
+
|
|
286
|
+
# Artifact write and read.
|
|
287
|
+
printf 'print("ok")\n' | bash "$LEDGER" artifact --dir "$lr" >/dev/null
|
|
288
|
+
bash "$LEDGER" artifact --dir "$lr" --read | grep -q 'print("ok")'; check "ledger: artifact round-trips" 0 $?
|
|
289
|
+
|
|
290
|
+
# Check is ground truth: exit code and recorded verdict.
|
|
291
|
+
bash "$LEDGER" check --dir "$lr" --cmd "grep -q ok solution.py" >/dev/null; check "ledger: check passes on the artifact" 0 $?
|
|
292
|
+
grep -q '^verdict=pass' "$lr/meta"; check "ledger: a pass is recorded" 0 $?
|
|
293
|
+
bash "$LEDGER" check --dir "$lr" --cmd "grep -q missing solution.py" >/dev/null 2>&1; check "ledger: a failing check exits non-zero" 1 $?
|
|
294
|
+
grep -q '^verdict=fail' "$lr/meta"; check "ledger: a fail overrides the recorded pass" 0 $?
|
|
295
|
+
|
|
296
|
+
# Refuses to clobber an initialized run, and errors on an uninitialized dir.
|
|
297
|
+
bash "$LEDGER" init --dir "$lr" --task x >/dev/null 2>&1; check "ledger: init will not clobber a run" 2 $?
|
|
298
|
+
bash "$LEDGER" read --dir "$tmp/no-such-run" >/dev/null 2>&1; check "ledger: read on an uninitialized dir errors" 2 $?
|
|
299
|
+
|
|
300
|
+
# --- init/scripts/reverse-engineer.sh: a non-repo is not an empty history ---
|
|
301
|
+
# The git log ran with stderr sent to /dev/null, so a directory that is not a
|
|
302
|
+
# repository produced no output, fell into the same empty branch as a repo
|
|
303
|
+
# whose last 6 months hold nothing, and printed "no clusters found in the last
|
|
304
|
+
# 6 months". The reference tells the operator a greenfield repo is the case to
|
|
305
|
+
# skip, so a directory with no history to read was green-lit on a claim about
|
|
306
|
+
# history that was never read.
|
|
307
|
+
REVENG="$REPO_ROOT/plugins/devos/skills/init/scripts/reverse-engineer.sh"
|
|
308
|
+
reveng_notgit="$tmp/reveng-not-git"
|
|
309
|
+
mkdir -p "$reveng_notgit"
|
|
310
|
+
out=$(cd "$reveng_notgit" && bash "$REVENG" 2>&1); rc=$?
|
|
311
|
+
[[ $rc -ne 0 ]] || { echo "FAIL reveng: a non-repo must not exit 0"; fail=1; }
|
|
312
|
+
[[ "$out" == *"not a git repository"* ]] || { echo "FAIL reveng: a non-repo must name the cause: $out"; fail=1; }
|
|
313
|
+
[[ "$out" != *"no clusters found"* ]] || { echo "FAIL reveng: a non-repo must not claim an empty history: $out"; fail=1; }
|
|
314
|
+
|
|
315
|
+
# Control: a real repository with no commits is the genuine zero-cluster case
|
|
316
|
+
# and keeps the documented line and exit 0. Without it, "always exit non-zero"
|
|
317
|
+
# would pass the checks above.
|
|
318
|
+
reveng_empty="$tmp/reveng-empty"
|
|
319
|
+
mkdir -p "$reveng_empty"
|
|
320
|
+
git -C "$reveng_empty" init -q -b main
|
|
321
|
+
out=$(cd "$reveng_empty" && bash "$REVENG" 2>&1); rc=$?
|
|
322
|
+
check "reveng: an empty repository still reports no clusters" 0 "$rc"
|
|
323
|
+
[[ "$out" == *"no clusters found in the last 6 months"* ]] || { echo "FAIL reveng: an empty repo lost its line: $out"; fail=1; }
|
|
324
|
+
|
|
325
|
+
# A missing directory is still its own error, not the repository one.
|
|
326
|
+
out=$(cd "$reveng_empty" && bash "$REVENG" "$tmp/reveng-absent" 2>&1); rc=$?
|
|
327
|
+
[[ $rc -ne 0 ]] || { echo "FAIL reveng: a missing directory must exit non-zero"; fail=1; }
|
|
328
|
+
[[ "$out" == *"no such directory"* ]] || { echo "FAIL reveng: a missing directory must name itself: $out"; fail=1; }
|
|
329
|
+
|
|
330
|
+
# Control: a real repo with one cluster commit still writes its stub, so the
|
|
331
|
+
# repository check cannot pass by refusing all work.
|
|
332
|
+
reveng_real="$tmp/reveng-real"
|
|
333
|
+
mkdir -p "$reveng_real/plugins/demo/skills/thing"
|
|
334
|
+
git -C "$reveng_real" init -q -b main
|
|
335
|
+
git -C "$reveng_real" config user.email t@t && git -C "$reveng_real" config user.name t
|
|
336
|
+
echo x > "$reveng_real/plugins/demo/skills/thing/run.sh"
|
|
337
|
+
git -C "$reveng_real" add -A && git -C "$reveng_real" commit -qm 'feat: thing'
|
|
338
|
+
out=$(cd "$reveng_real" && bash "$REVENG" 2>&1); rc=$?
|
|
339
|
+
check "reveng: a repository with history writes stubs" 0 "$rc"
|
|
340
|
+
ls "$reveng_real/devos/specs/archive/"*-plugins-demo-skills-thing.spec.md >/dev/null 2>&1; check "reveng: the cluster stub lands on disk" 0 $?
|
|
341
|
+
|
|
342
|
+
# --------------------------------------------------------------------------
|
|
343
|
+
# The smallest spec folder an M change is told to write, end to end.
|
|
344
|
+
#
|
|
345
|
+
# The router sends an M change through the same spec folder and the same plan
|
|
346
|
+
# capsule as an L feature, so what a small change costs is set by what the
|
|
347
|
+
# templates demand. write-spec.md names a one-page shape for M and a 300-line
|
|
348
|
+
# ceiling for the capsule, and the claim that the short one works is only true
|
|
349
|
+
# if every gate accepts it. It does not stop at validate-spec: the capsule is
|
|
350
|
+
# archived and a verdict claimed, because a spec that validates but cannot
|
|
351
|
+
# close the pipeline is not a shape the framework supports.
|
|
352
|
+
mspec=$(mktemp -d)
|
|
353
|
+
mspec_name=2026-01-01-invoice-pdf
|
|
354
|
+
mkdir -p "$mspec/devos/specs/$mspec_name/verifications"
|
|
355
|
+
cat > "$mspec/devos/specs/$mspec_name/spec.md" <<'EOF'
|
|
356
|
+
---
|
|
357
|
+
devos-contract: 1
|
|
358
|
+
---
|
|
359
|
+
# Export invoices
|
|
360
|
+
|
|
361
|
+
## Goal
|
|
362
|
+
|
|
363
|
+
A user can download a PDF of their invoices without asking support.
|
|
364
|
+
|
|
365
|
+
## Scenarios
|
|
366
|
+
|
|
367
|
+
- Scenario SC-1: plain export / WHEN an account has 3 invoices / THEN a PDF with all 3 is downloaded
|
|
368
|
+
- Scenario SC-2: empty account / WHEN an account has no invoices / THEN the export is refused with one line naming why
|
|
369
|
+
|
|
370
|
+
## Out of scope
|
|
371
|
+
|
|
372
|
+
- Scheduled or recurring exports
|
|
373
|
+
- Choosing a paper size or locale
|
|
374
|
+
|
|
375
|
+
EOF
|
|
376
|
+
cat >> "$mspec/devos/specs/$mspec_name/spec.md" <<'EOF'
|
|
377
|
+
## Local Craft
|
|
378
|
+
|
|
379
|
+
None
|
|
380
|
+
|
|
381
|
+
## Design Convergence
|
|
382
|
+
- **Direct MVP**: the existing invoice list route renders a print view
|
|
383
|
+
- **Failed Items**: None
|
|
384
|
+
- **Adopted Additions**: None
|
|
385
|
+
- **Rejected Additions**: None
|
|
386
|
+
|
|
387
|
+
## Boundaries
|
|
388
|
+
- **Always** (in scope): the export route and its test
|
|
389
|
+
- **Ask First** (none)
|
|
390
|
+
|
|
391
|
+
## Code Map
|
|
392
|
+
|
|
393
|
+
- `src/invoices/pdf.ts`: the renderer
|
|
394
|
+
|
|
395
|
+
## Implementation Plan
|
|
396
|
+
|
|
397
|
+
### Overview
|
|
398
|
+
Total: 1 task group.
|
|
399
|
+
|
|
400
|
+
### Task Group 1: Export route
|
|
401
|
+
**Files:** `src/invoices/pdf.ts`
|
|
402
|
+
- Render and test
|
|
403
|
+
**Scenarios covered:** SC-1, SC-2
|
|
404
|
+
**Acceptance Criteria:** None
|
|
405
|
+
EOF
|
|
406
|
+
printf 'Completeness: CLEAN\nQuality: PASS\nNo pre-existing failures.\n\nSC-1 pass: export test, 3 invoices.\nSC-2 pass: export test, empty account refused.\n' \
|
|
407
|
+
> "$mspec/devos/specs/$mspec_name/verifications/verification.md"
|
|
408
|
+
mkdir -p "$mspec/src/invoices"
|
|
409
|
+
printf 'export const render = (invoices) => invoices.join(",");\n' \
|
|
410
|
+
> "$mspec/src/invoices/pdf.ts"
|
|
411
|
+
out=$(bash "$VSPEC" "$mspec/devos/specs/$mspec_name" 2>&1); rc=$?
|
|
412
|
+
check "m-spec: the one-page functional spec validates" 0 "$rc"
|
|
413
|
+
# The negative control, because a guard that has only ever passed is not a
|
|
414
|
+
# guard. Deleting the one delivered source file has to fail the DoD gate, or
|
|
415
|
+
# this block is asserting nothing.
|
|
416
|
+
git -C "$mspec" init -q -b "$mspec_name"
|
|
417
|
+
mv "$mspec/devos/specs/$mspec_name" "$mspec/devos/specs/archive/$mspec_name" 2>/dev/null \
|
|
418
|
+
|| { mkdir -p "$mspec/devos/specs/archive" && mv "$mspec/devos/specs/$mspec_name" "$mspec/devos/specs/archive/$mspec_name"; }
|
|
419
|
+
printf 'Implemented the export route.\nVerdict: DONE: devos/specs/archive/%s\n' "$mspec_name" \
|
|
420
|
+
> "$mspec/transcript.txt"
|
|
421
|
+
out=$(cd "$mspec" && bash "$DOD" transcript.txt 2>&1); rc=$?
|
|
422
|
+
check "m-spec: the one-page folder closes the pipeline" 0 "$rc"
|
|
423
|
+
rm "$mspec/src/invoices/pdf.ts"
|
|
424
|
+
out=$(cd "$mspec" && bash "$DOD" transcript.txt 2>&1); rc=$?
|
|
425
|
+
check "m-spec: the same folder fails once the delivered file is gone" 2 "$rc"
|
|
426
|
+
|
|
427
|
+
# The quality row the close path writes. verify-close.md 4.3 specifies six
|
|
428
|
+
# columns, after dropping the three that no row in this repo has ever filled.
|
|
429
|
+
# The contract that matters is not the column count but that the parser counts
|
|
430
|
+
# the row: an instruction and a status script that disagree is how a metric
|
|
431
|
+
# silently starts reporting on nothing. A legacy nine-column row has to keep
|
|
432
|
+
# parsing too, because the archive is full of them.
|
|
433
|
+
qrow=$(mktemp -d)
|
|
434
|
+
mkdir -p "$qrow/devos/specs/archive"
|
|
435
|
+
# Five rows minimum: quality-correlation.sh refuses to report below that, and a
|
|
436
|
+
# refusal would mask the thing this check is about.
|
|
437
|
+
for n in a b c d; do
|
|
438
|
+
printf '%s\tL\tyes\t0\tnone\tyes\n' "$n" > "$qrow/devos/specs/archive/$n.quality.md"
|
|
439
|
+
done
|
|
440
|
+
printf 'legacy\tL\tyes\t2\twarning\tyes\t3\t1/4\tdebt\n' > "$qrow/devos/specs/archive/legacy.quality.md"
|
|
441
|
+
out=$(bash "$QC" "$qrow" 2>&1); rc=$?
|
|
442
|
+
check "quality-row: a six-column corpus does not error" 0 "$rc"
|
|
443
|
+
# The real contract: both row shapes are counted, so the metric does not
|
|
444
|
+
# silently start reporting on nothing once old rows age out.
|
|
445
|
+
if grep -q 'Quality files: 5' <<<"$out" && grep -q 'Specs analyzed: 5' <<<"$out"; then
|
|
446
|
+
pass=$((pass + 1))
|
|
447
|
+
else
|
|
448
|
+
echo "FAIL quality-row: six-column and legacy rows not both counted" >&2
|
|
449
|
+
printf '%s\n' "$out" >&2
|
|
450
|
+
fail=$((fail + 1))
|
|
451
|
+
fi
|
|
452
|
+
|
|
453
|
+
# --------------------------------------------------------------------------
|
|
454
|
+
# knowledge.py: the absorbed-source manifest. Its contract is that it needs no
|
|
455
|
+
# network and no model, so drift is a diff between two files on disk, and that
|
|
456
|
+
# a re-read never loses the date a collection was last distilled.
|
|
457
|
+
KNOW="$REPO_ROOT/plugins/devos/skills/absorb/scripts/knowledge.py"
|
|
458
|
+
kdir="$tmp/knowledge/devos/product/knowledge"
|
|
459
|
+
know() { python3 -I "$KNOW" --dir "$kdir" "$@" 2>&1; }
|
|
460
|
+
cat >"$tmp/sitemap.xml" <<'XML'
|
|
461
|
+
<urlset><url><loc>https://help.example.com/fr/articles/111-statuses</loc><lastmod>2026-01-02T00:00:00Z</lastmod></url>
|
|
462
|
+
<url><loc>https://help.example.com/fr/articles/222-quotes</loc><lastmod>2026-01-03T00:00:00Z</lastmod></url></urlset>
|
|
463
|
+
XML
|
|
464
|
+
cat >"$tmp/collection.md" <<'MD'
|
|
465
|
+
- [Invoice statuses](https://help.example.com/fr/articles/111-statuses)
|
|
466
|
+
- [Quotes](https://help.example.com/fr/articles/222-quotes)
|
|
467
|
+
MD
|
|
468
|
+
know init >/dev/null
|
|
469
|
+
grep -q 'cache/' "$kdir/.gitignore" 2>/dev/null
|
|
470
|
+
check "knowledge: init ignores the fetch cache" 0 $?
|
|
471
|
+
out=$(know import --collection sales --listing "$tmp/collection.md" --lastmod "$tmp/sitemap.xml")
|
|
472
|
+
check "knowledge: import counts the rows" "import sales: 2 new, 0 updated, 2 rows total" "$out"
|
|
473
|
+
grep -q $'111\thttps://help.example.com/fr/articles/111-statuses\tInvoice statuses\tsales\tin\t2026-01-02' "$kdir/sources.tsv"
|
|
474
|
+
check "knowledge: a row carries url, title, collection, scope and source date" 0 $?
|
|
475
|
+
out=$(know check --lastmod "$tmp/sitemap.xml" | tail -1)
|
|
476
|
+
check "knowledge: unread rows are reported before any read date" "check: 0 changed, 0 new, 0 gone, 2 unread" "$out"
|
|
477
|
+
know read --collection sales --date 2026-02-01 >/dev/null
|
|
478
|
+
out=$(know check --lastmod "$tmp/sitemap.xml" | tail -1)
|
|
479
|
+
check "knowledge: no drift once read after the source date" "check: no drift, 2 in-scope articles current" "$out"
|
|
480
|
+
cat >"$tmp/sitemap.xml" <<'XML'
|
|
481
|
+
<urlset><url><loc>https://help.example.com/fr/articles/111-statuses</loc><lastmod>2026-03-09T00:00:00Z</lastmod></url>
|
|
482
|
+
<url><loc>https://help.example.com/fr/articles/333-dunning</loc><lastmod>2026-03-01T00:00:00Z</lastmod></url></urlset>
|
|
483
|
+
XML
|
|
484
|
+
out=$(know check --lastmod "$tmp/sitemap.xml")
|
|
485
|
+
grep -q '^changed sales/111 read 2026-02-01, source 2026-03-09' <<<"$out"; check "knowledge: a moved source is changed" 0 $?
|
|
486
|
+
grep -q '^new 333' <<<"$out"; check "knowledge: an unlisted article is new" 0 $?
|
|
487
|
+
grep -q '^gone sales/222' <<<"$out"; check "knowledge: a withdrawn article is gone" 0 $?
|
|
488
|
+
know scope --collection purchases --reason "owned by the purchases service" >/dev/null
|
|
489
|
+
grep -q $'collection:purchases\t\tcollection purchases\tpurchases\tout\t\t\t\towned by the purchases service' "$kdir/sources.tsv"
|
|
490
|
+
check "knowledge: an out-of-scope collection keeps its reason" 0 $?
|
|
491
|
+
out=$(know check --lastmod "$tmp/sitemap.xml" | tail -1)
|
|
492
|
+
grep -qv 'purchases' <<<"$out"; check "knowledge: out-of-scope rows never drift" 0 $?
|
|
493
|
+
before=$(cat "$kdir/sources.tsv")
|
|
494
|
+
know check --lastmod "$tmp/sitemap.xml" >/dev/null
|
|
495
|
+
check "knowledge: check writes nothing" "$before" "$(cat "$kdir/sources.tsv")"
|
|
496
|
+
know import --collection sales --listing "$tmp/collection.md" --lastmod "$tmp/sitemap.xml" >/dev/null
|
|
497
|
+
grep -q $'111\t.*\t2026-02-01' "$kdir/sources.tsv"; check "knowledge: re-import keeps the read date" 0 $?
|
|
498
|
+
# A sitemap fetched through a markdown converter keeps the dates and loses the tags.
|
|
499
|
+
cat >"$tmp/sitemap.md" <<'MD'
|
|
500
|
+
[https://help.example.com/fr/articles/111-statuses](https://help.example.com/fr/articles/111-statuses)
|
|
501
|
+
2026-04-04T00:00:00Z
|
|
502
|
+
MD
|
|
503
|
+
out=$(know check --lastmod "$tmp/sitemap.md")
|
|
504
|
+
grep -q '^changed sales/111 read 2026-02-01, source 2026-04-04' <<<"$out"
|
|
505
|
+
check "knowledge: a markdown-rendered sitemap still carries dates" 0 $?
|
|
506
|
+
|
|
507
|
+
# --------------------------------------------------------------------------
|
|
508
|
+
# frame survey: where the project already touches a vocabulary
|
|
509
|
+
SV="$SKILLS/frame/scripts/survey.sh"
|
|
510
|
+
sv="$tmp/survey"
|
|
511
|
+
mkdir -p "$sv/src/api/handlers" "$sv/src/jobs"
|
|
512
|
+
printf 'void a payment\n' >"$sv/src/api/handlers/void.js"
|
|
513
|
+
printf 'void a payment in a job\n' >"$sv/src/jobs/void.job.js"
|
|
514
|
+
out=$(cd "$sv" && bash "$SV" void)
|
|
515
|
+
grep -q 'code: 2 files' <<<"$out"
|
|
516
|
+
check "survey: counts the files that touch a term" 0 $?
|
|
517
|
+
grep -q 'src/api/handlers' <<<"$out"
|
|
518
|
+
check "survey: groups matches by area" 0 $?
|
|
519
|
+
out=$(cd "$sv" && bash "$SV" nothing-here)
|
|
520
|
+
grep -q 'code: none under src' <<<"$out"
|
|
521
|
+
check "survey: a term with no code says so" 0 $?
|
|
522
|
+
out=$(cd "$sv" && bash "$SV")
|
|
523
|
+
check "survey: no term is a usage error" 2 $?
|
|
524
|
+
|
|
525
|
+
CR="$SKILLS/absorb/scripts/check-refs.sh"
|
|
526
|
+
cr="$tmp/checkrefs"
|
|
527
|
+
mkdir -p "$cr/docs" "$cr/src/app" "$cr/src/db"
|
|
528
|
+
printf 'model X {\n id String\n}\n' >/dev/null
|
|
529
|
+
printf 'enum InvoiceStatus {\n PAID\n}\n' >"$cr/src/db/schema.prisma"
|
|
530
|
+
printf 'export const kinds = [\x27DELETE\x27] as const\n' >"$cr/src/app/kinds.ts"
|
|
531
|
+
printf 'page names `src/app/kinds.ts` and `InvoiceStatus.PAID` and `kinds.DELETE`\n' >"$cr/docs/ok.md"
|
|
532
|
+
out=$(bash "$CR" --docs "$cr/docs" --src "$cr/src" 2>&1)
|
|
533
|
+
check "check-refs: a page that resolves passes" 0 $?
|
|
534
|
+
grep -q 'missing refs: 0' <<<"$out"
|
|
535
|
+
check "check-refs: reports zero missing" 0 $?
|
|
536
|
+
printf 'page names `src/app/gone.ts` and `InvoiceStatus.TERMINATED`\n' >"$cr/docs/bad.md"
|
|
537
|
+
out=$(bash "$CR" --docs "$cr/docs" --src "$cr/src" 2>&1) && rc=0 || rc=$?
|
|
538
|
+
check "check-refs: a missing path fails" 1 $rc
|
|
539
|
+
grep -q 'MISSING src/app/gone.ts' <<<"$out"
|
|
540
|
+
check "check-refs: names the missing path" 0 $?
|
|
541
|
+
grep -q 'InvoiceStatus.TERMINATED' <<<"$out"
|
|
542
|
+
check "check-refs: names the unknown member" 0 $?
|
|
543
|
+
rm "$cr/docs/bad.md"
|
|
544
|
+
out=$(bash "$CR" --docs "$cr/docs" 2>&1) && rc=0 || rc=$?
|
|
545
|
+
check "check-refs: no source root is a usage error" 2 $rc
|
|
546
|
+
|
|
547
|
+
# --------------------------------------------------------------------------
|
|
548
|
+
# review packet: the brief a fresh reviewer reads
|
|
549
|
+
PREPARE="$SKILLS/review/scripts/prepare.py"
|
|
550
|
+
pr="$tmp/prepare"
|
|
551
|
+
pr2="$tmp/prepare-rules"
|
|
552
|
+
mkdir -p "$pr/devos/standards" "$pr/src"
|
|
553
|
+
printf '# Conventions\n\n## Logging\n\nUse the logger, never console.log.\n' >"$pr/devos/standards/conventions.md"
|
|
554
|
+
printf 'export function notify() {}\n' >"$pr/src/notify.js"
|
|
555
|
+
printf 'test("a", () => {})\n' >"$pr/src/notify.test.js"
|
|
556
|
+
(
|
|
557
|
+
cd "$pr" &&
|
|
558
|
+
git init -q . &&
|
|
559
|
+
git add -A &&
|
|
560
|
+
git -c user.email=test@example.com -c user.name=test commit -qm init
|
|
561
|
+
) >/dev/null 2>&1
|
|
562
|
+
check "prepare: the fixture repository is a repository" 0 $?
|
|
563
|
+
|
|
564
|
+
printf 'export function notify(msg) {\n // TODO: use the logger\n console.log(msg);\n}\n' >"$pr/src/notify.js"
|
|
565
|
+
printf 'test.only("a", () => {})\n' >"$pr/src/notify.test.js"
|
|
566
|
+
out=$(cd "$pr" && python3 "$PREPARE" --target worktree --task "add notification logging" --out "$pr/packet.md" 2>&1)
|
|
567
|
+
check "prepare: a working tree change builds a packet" 0 $?
|
|
568
|
+
grep -q 'src/notify.js' "$pr/packet.md"
|
|
569
|
+
check "prepare: the packet names the changed file" 0 $?
|
|
570
|
+
grep -q 'never console.log' "$pr/packet.md"
|
|
571
|
+
check "prepare: the packet quotes the convention the change bears on" 0 $?
|
|
572
|
+
test -s "$pr/rubric.md"
|
|
573
|
+
check "prepare: the rubric rides beside the packet" 0 $?
|
|
574
|
+
grep -q 'src/notify.js:2.*fixme' "$pr/packet.md"
|
|
575
|
+
check "prepare: the packet lists the TODO the change adds" 0 $?
|
|
576
|
+
grep -q 'src/notify.js:3.*debug' "$pr/packet.md"
|
|
577
|
+
check "prepare: the packet lists the debug statement the change adds" 0 $?
|
|
578
|
+
grep -q 'src/notify.test.js:1.*focused-test' "$pr/packet.md"
|
|
579
|
+
check "prepare: the packet lists the focused test the change adds" 0 $?
|
|
580
|
+
|
|
581
|
+
printf '[review-2026-01-01] warning defer: the old logger call (src/notify.js:3)\n' >"$pr/devos/deferred.md"
|
|
582
|
+
(cd "$pr" && python3 "$PREPARE" --target worktree --out "$pr/packet.md" >/dev/null 2>&1)
|
|
583
|
+
grep -q 'the old logger call' "$pr/packet.md"
|
|
584
|
+
check "prepare: the packet carries the findings an earlier review ruled on" 0 $?
|
|
585
|
+
grep -q 'goes in .fixed.' "$pr/packet.md"
|
|
586
|
+
check "prepare: the settled list asks which entries the code no longer shows" 0 $?
|
|
587
|
+
printf '[2026-01-01-notify] warning patch: the logger swap: src/notify.js:3\n' >>"$pr/devos/deferred.md"
|
|
588
|
+
printf '[2026-01-01-notify] warning patch: another file: src/other.js:1\n' >>"$pr/devos/deferred.md"
|
|
589
|
+
(cd "$pr" && python3 "$PREPARE" --target worktree --out "$pr/packet.md" >/dev/null 2>&1)
|
|
590
|
+
grep -q 'the logger swap' "$pr/packet.md"
|
|
591
|
+
check "prepare: the packet carries the implement ledger's entries" 0 $?
|
|
592
|
+
grep -q 'another file' "$pr/packet.md"
|
|
593
|
+
check "prepare: the packet skips the entries for other files" 1 $?
|
|
594
|
+
rm "$pr/devos/deferred.md"
|
|
595
|
+
|
|
596
|
+
printf 'export const extra = 1;\n' >"$pr/src/extra.js"
|
|
597
|
+
(cd "$pr" && python3 "$PREPARE" --target worktree --out "$pr/packet.md" >/dev/null 2>&1)
|
|
598
|
+
grep -q 'src/extra.js' "$pr/packet.md"
|
|
599
|
+
check "prepare: the packet lists the untracked file git cannot diff" 0 $?
|
|
600
|
+
rm "$pr/src/extra.js"
|
|
601
|
+
|
|
602
|
+
out=$(cd "$pr" && python3 "$PREPARE" --target worktree --lean --out "$pr/lean-packet.md" 2>&1)
|
|
603
|
+
grep -q 'Lean pass' "$pr/lean-packet.md"
|
|
604
|
+
check "prepare: the lean lens rides in the packet" 0 $?
|
|
605
|
+
|
|
606
|
+
(cd "$pr" && git checkout -q -- .)
|
|
607
|
+
out=$(cd "$pr" && python3 "$PREPARE" --target worktree --out "$pr/clean-packet.md" 2>&1) && rc=0 || rc=$?
|
|
608
|
+
check "prepare: a clean working tree falls back to the last change" 0 $rc
|
|
609
|
+
grep -q 'fallback:' <<<"$out"
|
|
610
|
+
check "prepare: the fallback says what it covered instead" 0 $?
|
|
611
|
+
grep -q 'the last change' "$pr/clean-packet.md"
|
|
612
|
+
check "prepare: the packet names the change it covers" 0 $?
|
|
613
|
+
|
|
614
|
+
branch=$(cd "$pr" && git rev-parse --abbrev-ref HEAD)
|
|
615
|
+
out=$(cd "$pr" && python3 "$PREPARE" --target "$branch" 2>&1) && rc=0 || rc=$?
|
|
616
|
+
check "prepare: a base naming the checked-out branch falls back too" 0 $rc
|
|
617
|
+
grep -q 'checked-out branch' <<<"$out"
|
|
618
|
+
check "prepare: the fallback says why there was nothing since it" 0 $?
|
|
619
|
+
|
|
620
|
+
out=$(cd "$pr" && python3 "$PREPARE" --target no-such-target 2>&1) && rc=0 || rc=$?
|
|
621
|
+
check "prepare: a target that is nothing at all is a usage error" 2 $rc
|
|
622
|
+
grep -q 'neither a branch' <<<"$out"
|
|
623
|
+
check "prepare: the unresolvable target says what it tried" 0 $?
|
|
624
|
+
|
|
625
|
+
# The rule a change breaks has to reach the reviewer even when the user's
|
|
626
|
+
# sentence shares no word with it: the rule says console.log, the task says
|
|
627
|
+
# "add the notification sender", and only the diff names console.log.
|
|
628
|
+
mkdir -p "$pr2/devos/standards" "$pr2/src"
|
|
629
|
+
printf -- '---\ndevos-contract: 1\n---\n# Conventions\n\n## Rules\n\n- No console.log in production code\n\n## Unrelated\n\n- Prefer tabs\n' >"$pr2/devos/standards/conventions.md"
|
|
630
|
+
printf 'export function send(msg) {}\n' >"$pr2/src/send.js"
|
|
631
|
+
(
|
|
632
|
+
cd "$pr2" &&
|
|
633
|
+
git init -q . &&
|
|
634
|
+
git add -A &&
|
|
635
|
+
git -c user.email=test@example.com -c user.name=test commit -qm init
|
|
636
|
+
) >/dev/null 2>&1
|
|
637
|
+
printf 'export function send(msg) {\n console.log(msg);\n}\n' >"$pr2/src/send.js"
|
|
638
|
+
out=$(cd "$pr2" && python3 "$PREPARE" --target worktree --task "add the notification sender" --out "$pr2/packet.md" 2>&1)
|
|
639
|
+
check "prepare: a change whose rule the task does not name builds a packet" 0 $?
|
|
640
|
+
grep -q 'No console.log in production code' "$pr2/packet.md"
|
|
641
|
+
check "prepare: the packet quotes the rule the diff breaks, not only the task's words" 0 $?
|
|
642
|
+
|
|
643
|
+
mkdir -p "$pr/devos/specs/2026-01-01-notify"
|
|
644
|
+
printf '# notify\n\n**Files:** `src/notify.js`\n' >"$pr/devos/specs/2026-01-01-notify/spec.md"
|
|
645
|
+
out=$(cd "$pr" && python3 "$PREPARE" --target 2026-01-01-notify --out "$pr/spec-packet.md" 2>&1)
|
|
646
|
+
check "prepare: a spec target builds a packet" 0 $?
|
|
647
|
+
grep -q 'src/notify.js' "$pr/spec-packet.md"
|
|
648
|
+
check "prepare: the spec target names the files the plan claims" 0 $?
|
|
649
|
+
grep -q 'Spec in scope' "$pr/spec-packet.md"
|
|
650
|
+
check "prepare: the packet names the spec in scope" 0 $?
|
|
651
|
+
|
|
652
|
+
mkdir -p "$pr/devos/specs/2026-01-02-other"
|
|
653
|
+
printf '# other\n\n**Files:** `src/notify.js`\n' >"$pr/devos/specs/2026-01-02-other/spec.md"
|
|
654
|
+
printf 'export function notify(msg) {}\n' >"$pr/src/notify.js"
|
|
655
|
+
out=$(cd "$pr" && python3 "$PREPARE" --target worktree --out "$pr/two-packet.md" 2>&1)
|
|
656
|
+
grep -q '2 specs claim these files' "$pr/two-packet.md"
|
|
657
|
+
check "prepare: two specs claiming the files say so" 0 $?
|
|
658
|
+
rm -rf "$pr/devos/specs/2026-01-02-other"
|
|
659
|
+
|
|
660
|
+
(cd "$pr" && git checkout -q -- .)
|
|
661
|
+
base=$(cd "$pr" && git rev-parse --abbrev-ref HEAD)
|
|
662
|
+
(cd "$pr" && git checkout -q -b feature)
|
|
663
|
+
printf 'export function notify(msg) {}\n' >"$pr/src/notify.js"
|
|
664
|
+
(cd "$pr" && git add -A && git -c user.email=test@example.com -c user.name=test commit -qm "feat: notify takes a message")
|
|
665
|
+
out=$(cd "$pr" && python3 "$PREPARE" --target "--base $base" --out "$pr/branch-packet.md" 2>&1) && rc=0 || rc=$?
|
|
666
|
+
check "prepare: a branch target builds a packet" 0 $?
|
|
667
|
+
grep -q 'notify takes a message' "$pr/branch-packet.md"
|
|
668
|
+
check "prepare: the packet lists the commits of the change" 0 $?
|
|
669
|
+
grep -q 'Task: notify takes a message' "$pr/branch-packet.md"
|
|
670
|
+
check "prepare: the task comes from the commit subjects" 0 $?
|
|
671
|
+
(cd "$pr" && git checkout -q "$base")
|
|
672
|
+
out=$(cd "$pr" && python3 "$PREPARE" --target "--base feature" --out "$pr/ahead-packet.md" 2>&1) && rc=0 || rc=$?
|
|
673
|
+
check "prepare: a base the work is already in falls back to the last change" 0 $rc
|
|
674
|
+
grep -q 'nothing changed on feature since merge-base' <<<"$out"
|
|
675
|
+
check "prepare: the fallback names the base that held no change" 0 $?
|
|
676
|
+
grep -q 'notify takes a message' "$pr/ahead-packet.md"
|
|
677
|
+
check "prepare: the fallback reviews the change that is there" 0 $?
|
|
678
|
+
(cd "$pr" && git checkout -q -B feature)
|
|
679
|
+
|