Files
claude_mac/.claude/tasks/contracts/2026-10-28-context-diet-1944.md
T

15 KiB
Raw Blame History

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 <agent-message turns (857 of 2,779 logged fires). [gated 2026-10-28, pass A]

Q: STEP 3 gate (plan r3, 0441e56)? / A: plan approved; robin_petier entry text approved as shown (robin_petier = finished project, serves as the test case of the auto-memory → registry migration; faunosteo and game (orbistep) are the critical ones: the proof states explicitly that nothing of theirs is lost); settings.json: never commit a /model write, the tracked default stays "model": "opus", "switchModelsOnFlag": true stays; UI-written changes ("theme") are stashed, never committed, re-pushed only for a major change; Skill-routing lines → skill descriptions (TODO phase 3 bullet) DEFERRED to a TODO line; contract amendments below accepted. [gated 2026-10-29]

Q: autoMemoryEnabled: false also drops the analyzer's memory: project section (proved 2026-10-29 with a control run --settings '{"autoMemoryEnabled": true}': YES vs NO); the 4 .claude/agent-memory/analyzer/ dirs are empty. Keep false? / A: keep false + record a BDR; removing the dead memory: project field from agents/analyzer.md = TODO line. [gated 2026-10-29]

Q: GATE 1 ECARTS(5), human-only points: (1) robin_petier BDR-075 = the text approved at the STEP 3 gate? (2) docs/superpowers/specs/2026-10-29-context-diet-design.md and docs/superpowers/plans/2026-10-29-context-diet.md in FILE SCOPE? (3) authorize two # shellcheck disable=SC2016 # literal backticks in the fixture (lib/tests/doctrine-citers.test.sh fixture printf, same waiver as the file's existing line; and the plan doc that quotes it)? / A: yes to all three: BDR-075 is the approved text (byte-identical to the gate text); the two transient pipeline docs join FILE SCOPE (purged by gitflow finish, BDR-065); both SC2016 waivers authorized. [gated 2026-10-29]

ACCEPTANCE CRITERIA

  1. settings.json carries "autoMemoryEnabled": false. CHECK: jq -e '.autoMemoryEnabled == false' settings.json >/dev/null && echo AUTOMEM-OFF EXPECT: AUTOMEM-OFF EVIDENCE: MET exit=0 marker-found :: AUTOMEM-OFF
  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: MET exit=0 marker-found :: DESIGN-MOVED
  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 <agent-message even when it carries UI tokens (new D-test), and still fires on F1-F10.
  7. lib/tests/design-toolchain-reminder.test.sh runs every hook call under a temp HOME: a suite run leaves ~/.claude/logs/design-toolchain-fires.log unchanged. CHECK: L="$HOME/.claude/logs/design-toolchain-fires.log"; a=$(wc -l < "$L"); bash lib/tests/design-toolchain-reminder.test.sh >/dev/null 2>&1 || exit 1; b=$(wc -l < "$L"); [ "$a" = "$b" ] && echo LOG-UNTOUCHED EXPECT: LOG-UNTOUCHED EVIDENCE: MET exit=0 marker-found :: LOG-UNTOUCHED
  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: MET exit=0 marker-found :: ARCH-MOVED
  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: MET exit=0 marker-found :: READERS-OK
  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: MET exit=0 marker-found :: SB-CF-MOVED
  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 <project> matches '<glob>' 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: MET exit=0 marker-found :: AGENT-DESC-OK (23 agents)
  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: MET exit=0 marker-found :: GLOBAL-UNDER-320
  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: MET exit=0 marker-found :: all suites green
  21. shellcheck clean on the health stack. CHECK: shellcheck .sh hooks/.sh lib/*.sh && echo SHELLCHECK-CLEAN EXPECT: SHELLCHECK-CLEAN EVIDENCE: MET exit=0 marker-found :: SHELLCHECK-CLEAN

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], docs/superpowers/specs/2026-10-29-context-diet-design.md + docs/superpowers/plans/2026-10-29-context-diet.md (transient, purged at finish) [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.

PROOF — controller, 2026-10-29

  • c2 (robin_petier): chore/memory-lan-server started by gitflow.sh start, memory.sh -C ~/Documents/robin_petier add decision --status accepted → BDR-075 (v1 registry, stderr note), memory commit d16cd6e via memory-commit.sh rc 0, pushed; git -C ~/Documents/{faunosteo,game} status --short empty. Critical projects: faunosteo's only auto memory (dev-host-no-docker-access) already lives in its blockers.md (docker.sock BLK, resolved 2026-10-08); game's auto-memory dir is empty; jeux-deploy's (remote-git-ops) dropped by the pass-A answer (contradicts the gitflow delete doctrine). Nothing of faunosteo/game is lost.
  • c15 static: project-rules.sh -C <proj> matches: faunosteo **/supabase/** → packages/supabase, **/*supabase*.* → apps/app/src/lib/supabase.ts; game **/supabase/** → supabase, **/*supabase*.* → apps/web/src/progress/supabase.ts, **/functions/** → supabase/functions; robin_petier and zenquality: all five globs match nothing (no Supabase text loads there); **/serverless.* and **/firebase.json match nowhere in the four projects.
  • c15 load (~/.claude/logs/instructions-loaded.jsonl, headless claude -p naming the Read tool): 2026-10-29T12:14:26Z faunosteo supabase.md User path_glob_match on packages/supabase/package.json (globs logged **/supabase,**/*supabase*.*), web-building.md User on apps/app/e2e/harness/dialog.tsx; 12:14:36Z game cloud-functions.md + supabase.md User on supabase/functions/_shared/core.mjs (globs **/functions,…). Both repos clean after.
  • c19 /context after (repo root, headless): total 30.5k → 26.2k; Memory files 9.6k → 8.0k (user CLAUDE.md 7.4k → 6.3k, secure-by-default 1.2k → 985, default-language row gone); System prompt 4.4k → 3.7k (auto-memory section); Custom agents 2.6k → 2.1k. MCP server instructions 2.4k → 945 is NOT this branch (claude.ai connector set changed between the runs): own gain ≈ −2.8k.
  • analyzer memory: project: dropped by autoMemoryEnabled: false (control --settings '{"autoMemoryEnabled": true}' → section present); dirs empty; user kept false [gated 2026-10-29].