diff --git a/.claude/tasks/contracts/2026-10-28-context-diet-1944.md b/.claude/tasks/contracts/2026-10-28-context-diet-1944.md new file mode 100644 index 0000000..e834bd9 --- /dev/null +++ b/.claude/tasks/contracts/2026-10-28-context-diet-1944.md @@ -0,0 +1,73 @@ +# CONTRACT — context-diet (phase 1) +- date: 2026-10-28 | flow: ship-feature | branch: feature/context-diet (off develop 017a28b) +- status: active + +## REQUEST (verbatim — IMMUTABLE) +continue avec la phase suivante + +(user, 2026-10-28, after the phase 4a merge 017a28b. Queue order in `.claude/tasks/TODO.md` (BDR-125): 0 → 4a → 1 → 5 → 2 → 3 → 4b-4d, so "la phase suivante" = the TODO bullet "**Phase 1, native context diet: no mod**", its spec read verbatim from that bullet plus the "Shared rules for every phase" block above it.) + +## CLARIFICATIONS +Q: Architecture defaults (Rust default, public site never SPA, API /api/v1) leave always-on context for lib/architecture-defaults.md; BDR-118/BDR-120 rejected such moves because brainstorm happens in plain chat. What stays always-on? / A: one always-on line in CLAUDE.global.md naming the three defaults and pointing to the lib; rules/default-language.md moves into the lib (file deleted); /refactor not edited (it has no whole-project mode, the line covers it). [gated 2026-10-28, pass A] +Q: Which of the 5 auto memories migrate before `autoMemoryEnabled: false`? / A: one entry into robin_petier's registry (LAN dev server: never restart unprompted, ask before killing one found running) via memory.sh on a chore/* branch, text reviewed by the user before the write; the other 4 dropped (onecmd = robin_petier BLK-017, restore = BLK-016/LRN-066/067, faunosteo docker = its resolved BLK, jeux-deploy `:branch` refspec contradicts the gitflow delete doctrine and its project is gone). The user removes the ~/.claude/projects/*/memory dirs by hand afterwards; doctor warns while one is non-empty. [gated 2026-10-28, pass A] +Q: Supabase and cloud-functions bodies to path rules: names and globs? / A: rules/supabase.md on `**/supabase/**`, `**/*supabase*.*`; rules/cloud-functions.md on `**/functions/**`, `**/serverless.*`, `**/firebase.json`; one always-on line stays under each heading of rules/secure-by-default.md (Supabase: RLS everywhere + no service_role key client-side; cloud functions: instance cap + no self-trigger). No `**/*.sql` nor `**/migrations/**`. [gated 2026-10-28, pass A] +Q: Neighbouring defects in scope? / A: all three in: (a) design-toolchain test F1-F10 run with a temp HOME (1,770 of 2,779 logged fires are suite prompts); (b) lib/project-rules.sh:22-23 comment corrected (engine matching is gitignore-style, observed in the InstructionsLoaded log) and the static proof accounts for it; (c) the design hook stops firing on harness-generated `/dev/null && echo AUTOMEM-OFF + EXPECT: AUTOMEM-OFF + EVIDENCE: pending +2. robin_petier's registry holds exactly one new entry for the LAN dev server rule, written by `lib/memory.sh -C ~/Documents/robin_petier add`, on a `chore/*` branch of that repo, with the text the user approved; no other project's `.claude/memory/` changes. +3. doctor warns when any `~/.claude/projects/*/memory/` dir holds a file, names how many dirs, and stays silent when all are empty (flip-tested in a suite with a temp HOME). + [gated 2026-10-29] amended: doctor prints a warn line naming the count when a dir holds a file, a pass line otherwise; the proof is the function-level suite (lib/tests/doctor-automem.test.sh) including a call through a temp HOME; doctor also checks the `~/.claude/rules` symlink and that settings.json `autoMemoryEnabled` is false. +4. CLAUDE.global.md has no `## Design work` heading; rules/web-building.md ends with the section `## Design work — full toolchain (tiered by scope)`, body identical to the CLAUDE.global.md section at develop 017a28b (internal pointers excepted, listed in the plan); web-building.md `paths:` unchanged. + CHECK: bash .claude/tasks/contracts/c1-design-moved.sh + EXPECT: DESIGN-MOVED + EVIDENCE: pending +5. hooks/design-toolchain-reminder.sh prints a one-liner that names `~/.claude/rules/web-building.md` and the heading fragment `full toolchain`, and no longer says "already in context"; its suite asserts the exact new line. +6. The design hook stays quiet on a prompt starting with `/dev/null 2>&1 || exit 1; b=$(wc -l < "$L"); [ "$a" = "$b" ] && echo LOG-UNTOUCHED + EXPECT: LOG-UNTOUCHED + EVIDENCE: pending +8. [gated 2026-10-29] amended: `## graphify` keeps the threshold rule plus ONE reminder clause (`graphify query` before raw grep, `graphify update .` after code edits; sub-agents never see the banner); the full usage body moves as below. Original: CLAUDE.global.md `## graphify` keeps only the threshold rule; the usage body (query/path/explain, wiki/GRAPH_REPORT, `graphify update .`) is printed by hooks/session-start.sh only when the repo root holds `graphify-out/graph.json`; a suite proves present-with-graph and absent-without (flip). +9. lib/architecture-defaults.md exists and holds the "Public websites — never SPA" text and the "Default language — Rust" text (wording identical to their sources at 017a28b, pointers excepted) plus the Web APIs rule or a pointer to rules/rest-api.md § Versioning; CLAUDE.global.md has no `## Public websites` and no `## Web APIs` heading and holds one always-on line naming Rust default, never SPA, `/api/v1` and the lib path; rules/default-language.md no longer exists. + CHECK: bash .claude/tasks/contracts/c1-arch-moved.sh + EXPECT: ARCH-MOVED + EVIDENCE: pending +10. Readers name the lib: skills/init-project/SKILL.md, skills/ship-feature/SKILL.md (STEP 1), skills/onboard/SKILL.md, agents/interviewer.md, agents/scaffolder.md, skills/audit-delta/SKILL.md; no tracked file under skills/ agents/ lib/ hooks/ rules/ templates/ nor CLAUDE.global.md cites `default-language.md`. + CHECK: bash .claude/tasks/contracts/c1-readers.sh + EXPECT: READERS-OK + EVIDENCE: pending +11. rules/rest-api.md `## Versioning` carries the full versioning rule (text of CLAUDE.global.md § Web APIs at 017a28b), no "Not repeated here"; lib/project-archetypes/rest-api-node.md cites rules/rest-api.md instead of CLAUDE.md "Web APIs — always versioned". +12. rules/supabase.md and rules/cloud-functions.md exist with the clarified one-line JSON `paths:` and the bullets of secure-by-default.md §4 / §6 at 017a28b, wording identical; secure-by-default.md keeps the `## 4. Supabase` and `## 6. Cloud functions` headings with one line each naming the critical rule and the path rule. + CHECK: bash .claude/tasks/contracts/c1-supabase-functions.sh + EXPECT: SB-CF-MOVED + EVIDENCE: pending +13. A make-test suite parses every rules/*.md frontmatter (one-line JSON `paths:` or none) and locks the always-on set to exactly writing-style.md + secure-by-default.md; positive control: a multi-line `paths:` fixture and an extra always-on fixture both fail it. +14. lib/project-rules.sh header comment states the observed engine matching (trailing `/**` dropped, a pattern matches at any depth, hidden dirs included, evidence: InstructionsLoaded `globs: ["rules"]` on `.claude/rules/*.md`) instead of "the engine's matcher skips" dotfiles; code behaviour unchanged. +15. Load proof (controller, journaled): one fresh headless session per moved path rule, each prompt naming the Read tool on a real file, logs `path_glob_match` for rules/supabase.md (faunosteo), rules/cloud-functions.md (game, supabase/functions), rules/web-building.md (a UI file); and `bash lib/project-rules.sh -C matches ''` per new glob in the project that holds it (a glob that matches nowhere is named in the journal). +16. Every tracked agents/*.md `description:` (the 4 vendored impeccable-* excepted) is ≤ the length settled at the plan gate; agent names, files and `model:` lines unchanged. + CHECK: bash .claude/tasks/contracts/c1-agent-desc.sh + EXPECT: AGENT-DESC-OK + EVIDENCE: pending +17. Citers patched in the same branch: CLAUDE.global.md Skill routing (Design / UI line, Higgsfield line), lib/design-gate.md, agents/seo-analyzer.md, .claude/rules/rules-maintenance.md (always-on exception list and the "always-on doctrine stays in CLAUDE.global.md" sentence), hooks/session-start.sh comments citing BDR-031 / the moved sections; doctrine-citers census green. +18. CLAUDE.global.md is ≤ 320 lines (the session banner density warning goes away). + CHECK: n=$(wc -l < CLAUDE.global.md); [ "$n" -le 320 ] && echo GLOBAL-UNDER-320 + EXPECT: GLOBAL-UNDER-320 + EVIDENCE: pending +19. `/context` after (controller, `claude -p "/context"` at repo root, journaled with the baseline 2026-10-28: total 30.5k, Memory files 9.6k with user CLAUDE.md 7.4k / default-language 409 / secure-by-default 1.2k, Custom agents 2.6k, System prompt 4.4k): Memory files and Custom agents both lower, rules/default-language.md absent from the Memory files table. +20. make test all green and shellcheck clean. + CHECK: make test 2>&1 | tail -1 + EXPECT: all suites green + EVIDENCE: pending +21. shellcheck clean on the health stack. + CHECK: shellcheck *.sh hooks/*.sh lib/*.sh && echo SHELLCHECK-CLEAN + EXPECT: SHELLCHECK-CLEAN + EVIDENCE: pending + +## FILE SCOPE +CLAUDE.global.md, settings.json, rules/web-building.md, rules/rest-api.md, rules/secure-by-default.md, rules/default-language.md (deleted), rules/supabase.md (new), rules/cloud-functions.md (new), lib/architecture-defaults.md (new), hooks/design-toolchain-reminder.sh, lib/tests/design-toolchain-reminder.test.sh, hooks/session-start.sh, lib/graphify-gate.sh (only if the graph-present branch needs it), a session-start graphify suite (new), doctor.sh + one lib/doctor-*.sh + its suite (new), lib/tests/ user-rules suite (new) + fixtures, lib/tests/graphify-gate.test.sh (the session-start graphify checks live there) [gated 2026-10-29], lib/tests/effort-routing.test.sh (one lock retargeted) [gated 2026-10-29], lib/tests/doctrine-citers.test.sh (census extension) [gated 2026-10-29], skills/guardrails/SKILL.md (citer) [gated 2026-10-29], .claude/tasks/contracts/2026-10-28-context-diet-1944.md + c1-*.sh [gated 2026-10-29], .claude/tasks/TODO.md [gated 2026-10-29], lib/project-rules.sh (comment only), agents/*.md (23 tracked, `description:` only), skills/init-project/SKILL.md, skills/ship-feature/SKILL.md, skills/onboard/SKILL.md, skills/audit-delta/SKILL.md, agents/interviewer.md, agents/scaffolder.md, agents/seo-analyzer.md, lib/design-gate.md, lib/project-archetypes/rest-api-node.md, .claude/rules/rules-maintenance.md, .claude/tasks/contracts/c1-*.sh (oracles), robin_petier `.claude/memory/` (one entry, its own chore/* branch), docs at STEP 8. diff --git a/.claude/tasks/contracts/c1-agent-desc.sh b/.claude/tasks/contracts/c1-agent-desc.sh new file mode 100644 index 0000000..2231334 --- /dev/null +++ b/.claude/tasks/contracts/c1-agent-desc.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# GATE 0 oracle, contract context-diet c16: every tracked agent description +# ≤ 200 chars as written; file list and every other frontmatter key unchanged. +set -u +python3 -I - <<'PY' +import subprocess, sys, yaml +def ls(rev=None): + cmd = ['git', 'ls-tree', '-r', '--name-only', rev, 'agents'] if rev else ['git', 'ls-files', 'agents'] + out = subprocess.run(cmd, capture_output=True, text=True, check=True).stdout.split() + return sorted(f for f in out if f.endswith('.md') and not f.startswith('agents/resources/')) +def fm(text): + if not text.startswith('---\n'): return None, None + head = text.split('\n---\n', 1)[0][4:] + raw = next((l for l in head.splitlines() if l.startswith('description:')), '') + return yaml.safe_load(head), raw[len('description: '):] +now, old = ls(), ls('017a28b') +if now != old: print('agent file list changed'); sys.exit(1) +bad = [] +for f in now: + meta, raw = fm(open(f, encoding='utf-8').read()) + prev, _ = fm(subprocess.run(['git', 'show', '017a28b:' + f], capture_output=True, text=True).stdout) + if not isinstance(meta.get('description'), str) or len(raw) > 200: bad.append(f'{f}: {len(raw)} chars') + if {k: v for k, v in meta.items() if k != 'description'} != {k: v for k, v in prev.items() if k != 'description'}: + bad.append(f'{f}: other keys changed') +if bad: print('\n'.join(bad)); sys.exit(1) +print(f'AGENT-DESC-OK ({len(now)} agents)') +PY diff --git a/.claude/tasks/contracts/c1-arch-moved.sh b/.claude/tasks/contracts/c1-arch-moved.sh new file mode 100644 index 0000000..e4deadc --- /dev/null +++ b/.claude/tasks/contracts/c1-arch-moved.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# GATE 0 oracle, contract context-diet c9: architecture defaults in the lib, +# verbatim; one always-on line in CLAUDE.global.md; default-language.md gone. +set -u +fail() { echo "$1"; exit 1; } +L=lib/architecture-defaults.md +body() { awk -v h="$1" 'index($0, h) == 1 { f = 1; print; next } f && /^#/ { exit } f'; } +[ -f "$L" ] || fail "no $L" +[ -e rules/default-language.md ] && fail "rules/default-language.md still exists" +grep -q '^## Public websites' CLAUDE.global.md && fail "Public websites in CLAUDE.global.md" +grep -q '^## Web APIs' CLAUDE.global.md && fail "Web APIs in CLAUDE.global.md" +a=$(git show 017a28b:CLAUDE.global.md | body '## Public websites — never SPA') +b=$(body '## Public websites — never SPA' < "$L") +[ -n "$a" ] && [ "$a" = "$b" ] || fail "SPA section differs" +a=$(git show 017a28b:rules/default-language.md | sed '1s/^# /## /') +b=$(body '## Default language — Rust' < "$L") +[ -n "$a" ] && [ "$a" = "$b" ] || fail "language section differs" +grep -q 'rules/rest-api.md' "$L" || fail "no rest-api.md pointer in the lib" +line=$(awk '/^# Architecture decisions/ { f = 1; next } f && /^#/ { exit } f' CLAUDE.global.md \ + | tr '\n' ' ') +for w in 'Rust by default' 'never a SPA' '/api/v1/' '~/.claude/lib/architecture-defaults.md'; do + case "$line" in *"$w"*) ;; *) fail "architecture line lacks: $w" ;; esac +done +echo ARCH-MOVED diff --git a/.claude/tasks/contracts/c1-design-moved.sh b/.claude/tasks/contracts/c1-design-moved.sh new file mode 100644 index 0000000..75de76b --- /dev/null +++ b/.claude/tasks/contracts/c1-design-moved.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# GATE 0 oracle, contract context-diet c4: Design work moved verbatim to +# rules/web-building.md (last section), gone from CLAUDE.global.md, paths kept. +set -u +fail() { echo "$1"; exit 1; } +sec() { awk '/^## Design work — full toolchain/ { f = 1; print; next } + f && /^#/ { exit } f'; } +old=$(git show 017a28b:CLAUDE.global.md | sec) +[ -n "$old" ] || fail "no source section at 017a28b" +grep -q '^## Design work' CLAUDE.global.md && fail "still in CLAUDE.global.md" +new=$(sec < rules/web-building.md) +[ "$old" = "$new" ] || { diff <(printf '%s\n' "$old") <(printf '%s\n' "$new"); fail "body differs"; } +tail_=$(awk '/^## Design work — full toolchain/ { f = 1 } f' rules/web-building.md) +[ "$tail_" = "$new" ] || fail "not the last section" +[ "$(git show 017a28b:rules/web-building.md | sed -n 2p)" = "$(sed -n 2p rules/web-building.md)" ] \ + || fail "paths changed" +echo DESIGN-MOVED diff --git a/.claude/tasks/contracts/c1-readers.sh b/.claude/tasks/contracts/c1-readers.sh new file mode 100644 index 0000000..6fbf297 --- /dev/null +++ b/.claude/tasks/contracts/c1-readers.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# GATE 0 oracle, contract context-diet c10: the readers name the lib; no +# tracked doctrine file still cites rules/default-language.md. +set -u +for f in skills/init-project/SKILL.md skills/ship-feature/SKILL.md \ + skills/onboard/SKILL.md agents/interviewer.md agents/scaffolder.md \ + skills/audit-delta/SKILL.md agents/seo-analyzer.md; do + grep -q 'lib/architecture-defaults.md' "$f" || { echo "no lib in $f"; exit 1; } +done +if git grep -n 'default-language\.md' -- skills agents lib hooks rules templates \ + .claude/rules CLAUDE.global.md ':!lib/tests'; then + echo "stale default-language.md citer"; exit 1 +fi +echo READERS-OK diff --git a/.claude/tasks/contracts/c1-supabase-functions.sh b/.claude/tasks/contracts/c1-supabase-functions.sh new file mode 100644 index 0000000..8a5f5d4 --- /dev/null +++ b/.claude/tasks/contracts/c1-supabase-functions.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# GATE 0 oracle, contract context-diet c12: Supabase / cloud-functions bodies +# moved verbatim to path rules; secure-by-default keeps one bullet each and +# every other section byte-identical to 017a28b. +set -u +fail() { echo "$1"; exit 1; } +S=rules/secure-by-default.md +sect() { awk -v h="$1" '$0 == h { f = 1; next } f && /^## / { exit } f && NF'; } +bullets() { awk '/^- / { f = 1 } f && NF' "$1"; } +for r in supabase cloud-functions; do [ -f "rules/$r.md" ] || fail "no rules/$r.md"; done +[ "$(sed -n 2p rules/supabase.md)" = 'paths: ["**/supabase/**", "**/*supabase*.*"]' ] \ + || fail "supabase.md paths" +[ "$(sed -n 2p rules/cloud-functions.md)" = 'paths: ["**/functions/**", "**/serverless.*", "**/firebase.json"]' ] \ + || fail "cloud-functions.md paths" +[ "$(git show "017a28b:$S" | sect '## 4. Supabase')" = "$(bullets rules/supabase.md)" ] \ + || fail "supabase bullets differ" +[ "$(git show "017a28b:$S" | sect '## 6. Cloud functions')" = "$(bullets rules/cloud-functions.md)" ] \ + || fail "cloud-functions bullets differ" +one() { # one … → the section holds one bullet carrying every word + local t; t=$(sect "$1" < "$S"); shift + [ "$(printf '%s\n' "$t" | grep -c '^- ')" = 1 ] || return 1 + t=$(printf '%s' "$t" | tr '\n' ' ') + for w in "$@"; do case "$t" in *"$w"*) ;; *) return 1 ;; esac; done +} +one '## 4. Supabase' RLS service_role rules/supabase.md || fail "§4 line" +one '## 6. Cloud functions' 'Max instances' self-trigger rules/cloud-functions.md || fail "§6 line" +strip() { awk '/^## / { skip = ($0 == "## 4. Supabase" || $0 == "## 6. Cloud functions"); print; next } !skip'; } +[ "$(git show "017a28b:$S" | strip)" = "$(strip < "$S")" ] || fail "other sections changed" +echo SB-CF-MOVED diff --git a/docs/superpowers/plans/2026-10-29-context-diet.md b/docs/superpowers/plans/2026-10-29-context-diet.md index 35ca9f7..7aae6a6 100644 --- a/docs/superpowers/plans/2026-10-29-context-diet.md +++ b/docs/superpowers/plans/2026-10-29-context-diet.md @@ -19,7 +19,7 @@ - Foreign-style repo: match the neighbouring code (inline shell, `check()` test idiom, `PASS=%s FAIL=%s` footer, comments only for the why). Doctrine lines ≤ 80 chars; do not add a line over 80 chars to CLAUDE.global.md (3 exist today). - Tests run only through `make test suite=` or the full `make test`. shellcheck: `shellcheck *.sh hooks/*.sh lib/*.sh` (+ any new `lib/tests/*.sh` you create). - Bash pitfalls: no `head` reading a producer under pipefail (SIGPIPE rc 141); a sourced lib never changes the caller's shell options. -- `settings.json` has two hunks the USER wrote (`"model"` and `"theme"`, from `/model`): never stage or revert them (Task 7 gives the exact recipe). +- `settings.json` carries one uncommitted UI line (`"theme": "dark"`): never stage or revert it (Task 7 gives the exact recipe). - No destructive commands, no file outside this repo (the robin_petier write is a controller step, not yours). ## Review Focus @@ -979,7 +979,7 @@ Run: `make test suite=lib/tests/doctor-automem.test.sh` → `all suites green`; - [ ] **Step 6: settings.json, one line, staged alone** -The working tree holds the user's own uncommitted hunks (three today: `"model"` changed at @@359, `"theme"` + `"switchModelsOnFlag"` added at @@489, the trailing `"switchModelsOnFlag"` removed at @@542): leave them. Stage only the new key, built from HEAD's version: +The working tree holds one uncommitted line written by the Claude Code UI, `"theme": "dark",` right after `"effortLevel": "high",` (gate 2026-10-29: UI writes are stashed, never committed): leave it. Stage only the new key, built from HEAD's version: ```bash tmp=$(mktemp) @@ -993,7 +993,7 @@ jq -e '.autoMemoryEnabled == false' settings.json >/dev/null || { echo "worktree git diff --cached settings.json ``` -Expected: the cached diff is exactly one added line `+ "autoMemoryEnabled": false,`; `git diff settings.json` still shows the user's three hunks and nothing about autoMemoryEnabled; `jq -e '.autoMemoryEnabled == false' settings.json` → true. +Expected: the cached diff is exactly one added line `+ "autoMemoryEnabled": false,`; `git diff settings.json` still shows only the `"theme"` line and nothing about autoMemoryEnabled; `jq -e '.autoMemoryEnabled == false' settings.json` → true. - [ ] **Step 7: Commit** @@ -1004,7 +1004,7 @@ git show --stat HEAD | cat git diff --stat settings.json | cat ``` -Expected: the commit lists settings.json with `1 +`; the user's hunks remain unstaged. +Expected: the commit lists settings.json with `1 +`; the `"theme"` line remains unstaged. ---