From 44dc0b3015ea5ed78efa1f660e0234997bad0a13 Mon Sep 17 00:00:00 2001 From: bchanot Date: Wed, 18 Nov 2026 00:32:38 +0100 Subject: [PATCH] chore(memory): gates hotfix journal, TODO 88-89 done, residuals logged --- .claude/memory/journal.md | 3 + .claude/tasks/TODO.md | 7 +- .../2026-11-17-gates-label-timeout-2342.md | 41 +++++ .../2026-11-17-gates-label-timeout-2342.md | 173 ++++++++++++++++++ 4 files changed, 222 insertions(+), 2 deletions(-) create mode 100644 .claude/tasks/contracts/2026-11-17-gates-label-timeout-2342.md create mode 100644 .claude/tasks/plans/2026-11-17-gates-label-timeout-2342.md diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index fe0a7e9..4ed2b0a 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -777,3 +777,6 @@ rules: - Advisor call points run A (6ef3069): transcript count showed main loop 2 calls on Opus (409k/680k uncached) vs 18/20 opus sub-agents on Fable (~70k); doctrine now names main-loop points (plan, first gate loop failing twice, merge) + judgment agents once, advice add-only; 2 challenge rounds, gates found block E double count, fixed r5. Runs B, C next. - Advisor run B1 (58a5273): plan point moved into lib/challenge-plan.md (once per skill run, Advisor: row), stuck lines inline in verify-secure-loop (main-loop calls only), analyzer joins, trigger for doctrine/architecture/public-interface recommendations. 2 challenge rounds (2 BLOCKERs were my own oracle markers), scratch simulation then MET first run; gates sequential, CONFORME + PASS. - Advisor run B2 (/ship-feature, f48343e 24354d9 6022b9d): stuck line in 6 gate skills, end-of-run call at each flow's end step (9 flows, capitalize-commit untouched), 3 judgment agents dispatch-scoped, auditor raise upward only; plan r3 after 3 lenses + confirm; STEP 6 review fix restated fix path in skills (LRN-297); gates green first pass and after fix. Merge waits for user go. + +## 2026-11-18 +- gates.sh hotfix c25a7ea (bugfix/gates-label-timeout): digit label not `N. text` = parse error; 2nd CHECK/EXPECT/EVIDENCE on one criterion = error (indented/bullet/bold labels gave same false MET, advisor caught it); no-criteria die names first parse error; default timeout 120 -> 600. GATE 0 MET 5/5 incl full make test at default, security PASS, 3 challengers SOLID. ABANDON-id aliasing + verify-secure-loop cause list -> TODO. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index ee6f397..cb6c9f8 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -85,8 +85,11 @@ Open children of the shipped phases (History 2026-11-12), text verbatim. - [ ] feature (G2 split, user 2026-11-10): measured passive-cost API, one source for doctor / /status / plugin-advisor (probe COSTS field). Spec input = the two challenge rounds in the G2 plan: unit = pack or ON plugin (skills + agents + commands descriptions; pr-review-toolkit ~1550t, example-skills ~2350t), doctor counts OFF packs (higgsfield, extras), `detect_plugin_dev` globs the wrong cache level and ignores enabled state, `?` for not-installed or empty units, rc-0 sentinels (`costs-unavailable`/`unknown`) for doctor's `set -euo pipefail`, profile.sh failure → unknown, `python3 -I` (probe runs in the user's project), installPath from installed_plugins.json. Doctor keeps its measured ui-ux 670 until then. - [x] D3 add-ons (done 9b12b12) from G2 (plugin-advisor.md): plan-budget WARN :317 (unreachable: plugin-gate never sends PLAN, detect_plan gone), :42 "absolute COST ESTIMATE still reported", :105 `(budget: ~t | n/a)`, :222 "passive cost estimate = highest-cost package profile", "0t passive" claims for impeccable / design-motion-principles (:226 :227 :268 :269); USAGE.md :248 "Budget Pro (~11k tokens/5h)", :494 `(~400t)`, :923 `(~200t)`; session-banner.test.sh SB10 `gone()` passes on a missing file (add an existence check) - [x] D6 project rule (done c69ce9c; lead paragraph fixed too, follow-ups in BUGS-FOUND): .claude/rules/graphify-vendored.md says `graphify install --platform claude` "touches nothing else", but graphifyy 0.9.67 appends a `# graphify` block to ~/.claude/CLAUDE.md (= CLAUDE.global.md); `graphify claude install` writes into the caller's cwd, so the install-plugins.sh trap protects $REPO only when run from $REPO -- [ ] gates.sh: warn or reject a criterion row labelled `^[0-9]+[a-z]\.` (LRN-284: `1b.` absorbed into criterion 1, its CHECK/EXPECT overwritten, false MET) -- [ ] gates.sh default `GATES_TIMEOUT=120` < full `make test` (~135 s on 2026-11-16): a "Full make test green" criterion goes NOT-MET on timeout alone (A6 run, re-run with GATES_TIMEOUT=400). Raise the default or have contract-interview write the timeout for full-suite criteria. +- [x] DONE c25a7ea (bugfix/gates-label-timeout, user 2026-11-17 "reject"; also rejects a 2nd CHECK/EXPECT/EVIDENCE on one criterion: indented ` 2.`, `- `, `**2.**` gave the same false MET) gates.sh: warn or reject a criterion row labelled `^[0-9]+[a-z]\.` (LRN-284: `1b.` absorbed into criterion 1, its CHECK/EXPECT overwritten, false MET) +- [x] DONE c25a7ea (user 2026-11-17: default 600 s, env override kept) gates.sh default `GATES_TIMEOUT=120` < full `make test` (~135 s on 2026-11-16): a "Full make test green" criterion goes NOT-MET on timeout alone (A6 run, re-run with GATES_TIMEOUT=400). Raise the default or have contract-interview write the timeout for full-suite criteria. +- [ ] gates.sh:93 ABANDON regex `([0-9]+)?` reads `ABANDON: 1b …` / `1.1` as id 1: after a renumber (LRN-284) criterion 1 is masked ABANDONED (rc 3) instead of "unknown criterion" ERROR. Anchor the id `([0-9]+)([[:space:]]|$)` + test (robustness challenger, gates hotfix 2026-11-17) +- [ ] gates.sh residual: a stray oracle (indented ` 2.`, `- `, `**2.**` label) after a MANUAL criterion still attaches to it, row MANUAL → MET/NOT-MET on an unrelated oracle (no red oracle overwritten; accepted 2026-11-17) +- [ ] lib/verify-secure-loop.md:46-47 ERROR(n) cause list is examples, incomplete: missing "no numbered criteria", "ABANDON names unknown criterion", malformed label, second attribute (c25a7ea) - [ ] lib/design-tool-gate.sh:70 `perl -e 'alarm shift; exec @ARGV' 15 21st whoami` kills one process only (same limit as the old session-start runner, fixed 490ad83): reuse the group-kill runner when this file is next touched. - [ ] parked (code-clean 2026-11-09): hooks/rtk-rewrite.sh:84 no-op `[ "$CMD" = "$REWRITTEN" ] && REWRITTEN="$CMD"`: remove with the next real rtk-hook edit, re-pin `hooks/.rtk-hook.sha256` + rtk-rewrite.test.sh T13 in the same step - [ ] deferred (BDR-123): remap inline-writing best-tier skills (design Build stack, writing-skills, deprecation-and-migration, /tour single-project, /audit-delta 3d, /harden STEP 3); stale citers skills/feat/SKILL.md:6, skills/code-clean/SKILL.md:36; + impeccable row in routing.json (design Build stack has none; frontend-design has `reflect`; census test pins the table) diff --git a/.claude/tasks/contracts/2026-11-17-gates-label-timeout-2342.md b/.claude/tasks/contracts/2026-11-17-gates-label-timeout-2342.md new file mode 100644 index 0000000..aec0f23 --- /dev/null +++ b/.claude/tasks/contracts/2026-11-17-gates-label-timeout-2342.md @@ -0,0 +1,41 @@ +# CONTRACT — gates-label-timeout +- date: 2026-11-17 | flow: hotfix | branch: bugfix/gates-label-timeout +- status: active + +## REQUEST (verbatim — IMMUTABLE) +corrige les deux bugs mis dans le todos puis passe a C + +Bug description (TODO:88-89): (1) gates.sh: warn or reject a criterion row labelled `^[0-9]+[a-z]\.` (LRN-284: `1b.` absorbed into criterion 1, its CHECK/EXPECT overwritten, false MET). (2) gates.sh default `GATES_TIMEOUT=120` < full `make test` (~135 s on 2026-11-16): a "Full make test green" criterion goes NOT-MET on timeout alone (A6 run, re-run with GATES_TIMEOUT=400). Raise the default or have contract-interview write the timeout for full-suite criteria. + +## CLARIFICATIONS +Q: the two bugs? / A: inferred, not asked: TODO:88-89, the two gates.sh items (TODO:90 design-tool-gate is deferred to its next touch by its own text); the user's answers to the two questions below approve both fixes +Deviation 2026-11-17 (advisor, reported to the user): the same false MET reproduces with an indented ` 2. sub`, `- sub` or `**2.** sub` label, so `_set_attr` also rejects a second CHECK/EXPECT/EVIDENCE on one criterion (no past contract has one; every past verdict unchanged) +Q: bad label handling? / A: reject: an unindented ACCEPTANCE CRITERIA line starting with a digit that is not `N. text` (`1b.`, `1.1`, `2)`) is a parse error naming the line, its attributes belong to no criterion, verdict ERROR [gated 2026-11-17] +Q: timeout fix? / A: default 600 s, the GATES_TIMEOUT env override kept [gated 2026-11-17] + +## ACCEPTANCE CRITERIA +1. A `1b.` label after a failing criterion makes `gates.sh run` return ERROR rc 2 naming line 6 (before the fix this fixture is a false MET). + CHECK: cd /home/bchanot/Documents/claude && f=$(mktemp) && printf '## ACCEPTANCE CRITERIA\n1. real\n CHECK: exit 1\n EXPECT: x\n EVIDENCE: pending\n1b. sub\n CHECK: echo y\n EXPECT: y\n EVIDENCE: pending\n' > "$f"; out=$(bash lib/gates.sh run "$f" 2>&1); rc=$?; rm -f "$f"; [ "$rc" -eq 2 ] && printf '%s' "$out" | grep -q 'malformed criterion label at line 6' && printf '%s' "$out" | grep -q 'VERDICT: ERROR' && echo LABEL-REJECTED + EXPECT: LABEL-REJECTED + EVIDENCE: MET exit=0 marker-found :: LABEL-REJECTED +2. With GATES_TIMEOUT unset, gates.sh reports a 600 s timeout; with GATES_TIMEOUT=7 it reports 7 s. + CHECK: cd /home/bchanot/Documents/claude && f=$(mktemp) && printf '## ACCEPTANCE CRITERIA\n1. manual\n' > "$f"; a=$(env -u GATES_TIMEOUT bash lib/gates.sh status "$f" 2>&1); b=$(GATES_TIMEOUT=7 bash lib/gates.sh status "$f" 2>&1); rm -f "$f"; printf '%s' "$a" | grep -q 'timeout 600s' && printf '%s' "$b" | grep -q 'timeout 7s' && echo DEFAULT-600 + EXPECT: DEFAULT-600 + EVIDENCE: MET exit=0 marker-found :: DEFAULT-600 +3. lib/tests/gates.test.sh carries the regression cases and is green; shellcheck clean on both files. + CHECK: cd /home/bchanot/Documents/claude && grep -q '1b\. sub' lib/tests/gates.test.sh && grep -q '1\.1 dotted' lib/tests/gates.test.sh && grep -q 'timeout 600s' lib/tests/gates.test.sh && shellcheck -S warning lib/gates.sh lib/tests/gates.test.sh && bash lib/tests/gates.test.sh 2>&1 | tail -1 | grep -q ', 0 fail' && echo SUITE-GREEN + EXPECT: SUITE-GREEN + EVIDENCE: MET exit=0 marker-found :: SUITE-GREEN +4. An indented ` 2. sub` label with a passing oracle after a failing criterion 1 makes `gates.sh run` return ERROR naming the second CHECK (before the fix: false MET). + CHECK: cd /home/bchanot/Documents/claude && f=$(mktemp) && printf '## ACCEPTANCE CRITERIA\n1. real\n CHECK: exit 1\n EXPECT: x\n EVIDENCE: pending\n 2. sub\n CHECK: echo y\n EXPECT: y\n EVIDENCE: pending\n' > "$f"; out=$(bash lib/gates.sh run "$f" 2>&1); rc=$?; rm -f "$f"; [ "$rc" -eq 2 ] && printf '%s' "$out" | grep -q 'second CHECK: at line 7' && printf '%s' "$out" | grep -q 'VERDICT: ERROR' && echo STRAY-REJECTED + EXPECT: STRAY-REJECTED + EVIDENCE: MET exit=0 marker-found :: STRAY-REJECTED +5. Full make test green, run by gates.sh with no GATES_TIMEOUT set (proves the new default covers the suite). + CHECK: cd /home/bchanot/Documents/claude && PATH=$HOME/.bun/bin:$PATH make test &1 | tail -1 + EXPECT: all suites green + EVIDENCE: MET exit=0 marker-found :: all suites green + +## FILE SCOPE +lib/gates.sh +lib/tests/gates.test.sh +(bookkeeping: .claude/tasks/TODO.md, .claude/memory via memory.sh, this contract, the challenge plan .claude/tasks/plans/2026-11-17-gates-label-timeout-2342.md) diff --git a/.claude/tasks/plans/2026-11-17-gates-label-timeout-2342.md b/.claude/tasks/plans/2026-11-17-gates-label-timeout-2342.md new file mode 100644 index 0000000..8552a0f --- /dev/null +++ b/.claude/tasks/plans/2026-11-17-gates-label-timeout-2342.md @@ -0,0 +1,173 @@ +# Fix plan — gates.sh stray oracle + default timeout (hotfix) + +Contract: .claude/tasks/contracts/2026-11-17-gates-label-timeout-2342.md +Branch: bugfix/gates-label-timeout. Files: lib/gates.sh, lib/tests/gates.test.sh. + +## Root causes +1. `_absorb` (lib/gates.sh:86-98) opens a criterion only on + `^([0-9]+)\.[[:space:]]+(.*)$`. Any other label (`1b. sub`, `1.1 dotted`, + `2) paren`, an indented ` 2. sub`, `- sub`, `**2.** sub`) matches no + branch and is dropped as prose, but `_CUR` still points at the previous + criterion, so `_set_attr` lets the CHECK/EXPECT/EVIDENCE under it + overwrite that criterion's oracle. Criterion 1 with `CHECK: exit 1` + followed by a stray passing oracle yields VERDICT: MET (LRN-284; all six + shapes reproduced on a scratch copy). +2. `TIMEOUT="${GATES_TIMEOUT:-120}"` (lib/gates.sh:32) is per CHECK; the full + `make test` takes ~135 s, so a "full suite green" criterion goes NOT-MET + on timeout unless the caller exports GATES_TIMEOUT (contracts used + 400/600/1200). + +## Edit — lib/gates.sh (exact) +A. Line 32: `TIMEOUT="${GATES_TIMEOUT:-600}"`, with three comment lines + right above it: + ```bash + # TIMEOUT is per CHECK and a run lasts their sum: the caller's own limit (a + # foreground tool call stops at 600 s) must cover it, else run it in the + # background. A killed run writes nothing back; the floor stays PENDING. + ``` + +B. `_set_attr`: a comment line above the function, then a guard between the + `_CUR -lt 0` block and the assigning `case`: + ```bash + # A second attribute on one criterion is an error, never an overwrite: it + # is what an oracle under a label the parser missed looks like (LRN-284). + _set_attr() { # _set_attr + if [ "$_CUR" -lt 0 ]; then + _err "$1 at line $3 belongs to no criterion" + return 0 + fi + local seen="" + case "$1" in + CHECK) seen="${_CHECK[_CUR]}" ;; + EXPECT) seen="${_EXPECT[_CUR]}" ;; + EVIDENCE) [ "${_EVLINE[_CUR]}" = 0 ] || seen=yes ;; + esac + if [ -n "$seen" ]; then + _err "second $1: at line $3 in criterion ${_ID[_CUR]}" + return 0 + fi + case "$1" in + ``` +C. `_absorb`: new branch right after the criterion branch, before ABANDON: + ```bash + elif [[ "$1" =~ ^[0-9] ]]; then + _err "malformed criterion label at line $2 (want \`N. text\`)" + _CUR=-1 + ``` + It covers the case B cannot: a digit label after a MANUAL criterion + (no attribute yet) would otherwise lend it the stray oracle. The comment + above `_absorb` gains: "A digit-led line that is not `N. text` (`1b.`, + `1.1`, `2)`) is rejected and orphans what follows, like a duplicate id." + +D. `main`: when no criterion parsed, the die message carries the first + parse error, so an all-malformed block (`1) a`, `2) b`) still names its + line: + `main`'s locals become `local mode="$1" file="$2" first`, and the + two-line `[ "${#_ID[@]}" -gt 0 ] || _die "no numbered criteria …"` + becomes: + ```bash + if [ "${#_ID[@]}" -eq 0 ]; then + first="${_ERRORS[0]:+; ${_ERRORS[0]}}" + _die "no numbered criteria under ## ACCEPTANCE CRITERIA$first" + fi + ``` + +Any `_ERRORS` entry already makes the verdict ERROR rc 2 and executes +nothing (existing "malformed ledger executes nothing" case). + +Scans done on all 90+ .claude/tasks/contracts/*.md: no unindented digit-led +non-criterion line and no criterion with a repeated attribute; `gates.sh +status` verdicts identical before/after on every contract (scratch copy). + +## Edit — lib/tests/gates.test.sh (exact) +1. Section "fail-closed execution", right after + `has "timeout recorded" "NOT-MET timeout=1s"`: + ```bash + # The default must outlast the full suite (~135 s on 2026-11-16): at 120 s + # a "full make test green" criterion went NOT-MET on the timeout alone. + LAST="$WORK/default-timeout.md" + printf '## ACCEPTANCE CRITERIA\n1. manual\n' > "$LAST" + out="$(env -u GATES_TIMEOUT bash "$GATES" status "$LAST" 2>&1)" + if [[ "$out" == *"timeout 600s"* ]]; then + ok "default timeout 600s" + else + bad "default timeout 600s" "status did not print timeout 600s" + fi + ``` +2. Section "parse strictness", right after the "duplicate orphans what + follows" case (its closing `EOF`): + ```bash + # An oracle under a label the parser does not read as `N. text` must never + # overwrite the previous criterion's: criterion 1 fails, the stray oracle + # passes, a false MET (LRN-284). A digit-led label is rejected by name; + # any other shape trips the second-attribute guard when the previous + # criterion already has that attribute (after a manual one it does not). + gate "1b. label rejected" run "malformed criterion label at line 6" 2 <<'EOF' + ## ACCEPTANCE CRITERIA + 1. real + CHECK: exit 1 + EXPECT: x + EVIDENCE: pending + 1b. sub + CHECK: echo y + EXPECT: y + EVIDENCE: pending + EOF + + gate "1.1 label rejected" run "malformed criterion label at line 3" 2 <<'EOF' + ## ACCEPTANCE CRITERIA + 1. first + 1.1 dotted + EVIDENCE: pending + EOF + + gate "no valid label" run "malformed criterion label at line 2" 2 <<'EOF' + ## ACCEPTANCE CRITERIA + 2) paren + EOF + + gate "indented label: second CHECK" run "second CHECK: at line 7" 2 <<'EOF' + ## ACCEPTANCE CRITERIA + 1. real + CHECK: exit 1 + EXPECT: x + EVIDENCE: pending + 2. sub + CHECK: echo y + EXPECT: y + EVIDENCE: pending + EOF + + gate "bullet label: second EVIDENCE" run "second EVIDENCE: at line 9" 2 <<'EOF' + ## ACCEPTANCE CRITERIA + 1. real + CHECK: exit 1 + EXPECT: x + EVIDENCE: pending + - sub + CHECK: echo y + EXPECT: y + EVIDENCE: pending + EOF + ``` + (Plan text is indented 3 for the list; in the file every heredoc body + line starts at column 0 exactly as in the existing cases, the oracle + attributes indented 3 spaces.) + +## Residual (accepted) +- Any label branch C misses (indented ` 2.`, `- `, `**2.**`) after a MANUAL + criterion still lends it the stray oracle: that row turns MANUAL into + MET/NOT-MET on an unrelated oracle. No failing oracle is overwritten. +- `ABANDON: 1b …` parses as id 1 (gates.sh:90 regex): pre-existing, same + class, logged to TODO, not fixed here. +- lib/verify-secure-loop.md:46-47 lists ERROR causes as examples; it already + omits "no numbered criteria" and "ABANDON names unknown criterion", so the + two new causes do not make it newly stale. Logged to TODO (complete the + list), not a third file here. +- ~/.claude/lib is a symlink to this repo's lib: an in-flight contract in + another repo with a repeated attribute or a digit-led prose line now goes + ERROR (fail-closed, names the line). + +## Out of scope +lib/design-tool-gate.sh:70 (TODO:90, deferred by its own text). The test +helper's own `${GATES_TIMEOUT:-120}` stays (fast fixtures only).