chore(memory): phase 1 redesigned as native context diet
This commit is contained in:
1 parent
d157032616
commit
2c9ed20782
2 files changed
+15
-8
No files matched your search
@@ -1499,4 +1499,5 @@ Branch feature/user-writing-web-rules, UNMERGED (human gate).
|
||||
- **Refs**: probe `scratchpad/ctxprobe` (session-local, not committed), plugin-authoring types 2.1.306 (`prompt.context`, `prompt.compose`, `prompt.section`, `prompt.attachment`, `prompt.submit`, `tool.call`). Supersedes [[BDR-031]]; links [[BLK-009]], [[LRN-175]], [[LRN-054]], [[LRN-091]], [[BDR-115]].
|
||||
- **Amendment (2026-10-24, user)**: phase 5 added: per-project virtual profiles, concurrent sessions (today `lib/profile.sh` global: one profile for all open sessions), auto-pick from fingerprint or pinned `/profile set`, per-skill advert of needed helpers; plugin project-scope `enabledPlugins` to verify. Advisor toast refused. Each phase deletes what it obsoletes (scripts, hooks, tests, doctrine). Full specs: TODO "Context mod queue". Probe bench kept at `.claude/tasks/plans/2026-10-24-context-mod-probe/`.
|
||||
- **Amendment 2 (2026-10-24, user: full memory redesign allowed)**: phase 4 = memory v2 (write + capture + read + feedback), measured on 434 entries: capture is the weak link (5/7 real errors of 2026-10-23 had no entry), not search; haiku rerank of lexical top-30 = 14/22 vs BM25 9/22 on real FR prompts; error 4-gram match exact (429 → BLK-030/031). Storage: augment in place + Meta line + generated Index + single writer `lib/memory.sh` + pre-commit validator (Edit-level guard rejected: real writes go through Bash/python). One-file-per-entry rejected for now (44 citers + 8 project migrations for concurrency/history gains a validator+backfill mostly match). Registry guard moved from phase 2 to 4a; 4a needs no mod.
|
||||
- **Amendment 3 (2026-10-24, challenge of phase 1)**: phase 1 = native context diet, no mod. Proven: `paths:` rules load on Read (not on Write of a new file), `autoMemoryEnabled: false` drops the auto-memory section, classic SessionStart/UserPromptSubmit hooks inject context, instruction files reload on compaction natively. Each section goes to the carrier matching its trigger (path rule, hook, skill body, setting, or compression once enforced by 4a/phase 2). Same ~4.4k gain, no mod code, works with mod off. Mod marker subtraction kept only as fallback if a native carrier fails a canary. Fingerprint moves to phase 3.
|
||||
|
||||
+14
-8
@@ -24,14 +24,20 @@ Shared rules for every phase:
|
||||
- One pass over the git repos in ~/Documents/ (this repo first, then by size: faunosteo, zenquality, game, robin_petier, config, integration_alphalink): one `chore/claude-md-split` branch per repo, per-project approval, never an automatic merge (user signal per repo), `/context` before/after per project recorded in that project's journal.
|
||||
- Proof: per project, canary that a moved section is ABSENT at start and PRESENT after a Read of a matching file; total always-on delta across the 7 projects.
|
||||
|
||||
- [ ] **Phase 1, mod `context`: marked-section subtraction + JIT injection + project fingerprint**
|
||||
- New mod `mods/context/` (+ `skills/context` link, census row in mods.test.sh), config `~/.claude/context-mod.json`.
|
||||
- Fingerprint at `session.start` (fs only, cached in `$.state`): stack (package.json deps astro/next/react/vue/svelte, Cargo.toml, go.mod, pyproject), web public vs app, `supabase/`, messaging deps (twilio, sendgrid, resend, mailgun), `functions/` or serverless config, `graphify-out/graph.json`, tracked code file count, code origin via `lib/code-origin.sh` (ours / foreign), gitflow repo, `.claude/memory/` present, empty dir.
|
||||
- Marked sections and triggers: Design work (UI file Read/Edit or UI prompt, same detector as `hooks/design-toolchain-reminder.sh`); graphify (graph.json exists → stays in context block); Public websites never SPA + Web APIs versioned + rules/default-language.md (empty dir, or skill.prompt of init-project / ship-feature / brainstorming / refactor); secure-by-default sections 4 Supabase / 5 SMS-email / 6 cloud functions (fingerprint); gitflow detail (keep 3 core lines; full text on first Bash git/gitflow call); Memory registries format (keep 2 lines; full text on Read/Edit/Write under `.claude/memory/`); "Our code" vs "Foreign code" variant (origin → inject only the applicable one, at first code Read).
|
||||
- Delivery: always-on part via `prompt.context` (drop/rewrite `claudeMd` instructionFiles); JIT via `tool.call` result `context` (Read comes before Edit, so guidance lands before the write) and `prompt.submit` `context`; skill-triggered via `skill.prompt` append.
|
||||
- Drop the unused auto-memory system section (`prompt.section` name `memory`, dir `~/.claude/projects/*/memory/` empty 2026-10-23) behind a config flag.
|
||||
- Proof: canary per section (ABSENT without trigger, PRESENT after it, once only, again after /clear and after a compaction); mod-off run loads everything; `claude plugin test` unit suite; `/context` delta (~4.4k est.).
|
||||
- Cleanup: `hooks/design-toolchain-reminder.sh` + its settings.json registration + `lib/tests/design-toolchain-reminder.test.sh` (the mod injects the section itself); the hook's "(already in context)" text; CLAUDE.global.md lines that only pointed at the moved text; BDR-031 citers.
|
||||
- [ ] **Phase 1, native context diet: no mod** (redesigned 2026-10-24 after challenge: the engine already does most of it)
|
||||
- Facts 2026-10-24 (scratchpad pathtest, memtest): a `paths:` rule loads on Read of a matching file, NOT on Write of a new file (S1 ABSENT, S2 after Write ABSENT, S3 after Read PRESENT); `"autoMemoryEnabled": false` removes the auto-memory system section (PRESENT → ABSENT); classic SessionStart / UserPromptSubmit hooks inject additionalContext (seen live in every session); instruction files reload on compaction natively (InstructionsLoaded `load_reason: compact` in the 2.1.306 types). So each section goes to the native carrier that matches its trigger, with no mod code, no fail-open risk, and it works with the mod off and in sub-agents.
|
||||
- Section → carrier:
|
||||
- auto-memory system section → `"autoMemoryEnabled": false` in settings.json (one line, proven).
|
||||
- Design work (1.5k chars) → user rule `rules/design-work.md` with the UI globs of rules/web-building.md (fires on UI file Read) + `hooks/design-toolchain-reminder.sh` injects the section text itself when it detects UI work in a prompt (covers new files created from a prompt); drop its "(already in context)" wording.
|
||||
- graphify (0.6k) → `hooks/session-start.sh` injects the section only when `graphify-out/graph.json` exists (it already computes graph presence for the banner).
|
||||
- Public websites never SPA + default language + web APIs versioned (2.3k) → into the skills that brainstorm (init-project, ship-feature STEP 1, brainstorming, refactor whole-project, onboard) + session-start injects them when the cwd has no tracked code file (new project); dedupe "Web APIs" against rules/rest-api.md.
|
||||
- secure-by-default domains 4 Supabase + 6 cloud functions → user path rules (`supabase/**`, `**/*.sql`; `functions/**`, `**/serverless.*`, `**/firebase.json`); keep "Every API", hosting, injection, exposure and SMS/email always-on (no reliable path for messaging, 325 chars).
|
||||
- Our code vs foreign code → session-start runs `lib/code-origin.sh` once and injects one line ("this repo: ours, strict limits" / "foreign, keep its style"); both short sections stay always-on.
|
||||
- Registry format → compressed in phase 4a (lib/memory.sh enforces it); gitflow detail → compressed in phase 2 cleanup (hooks + lib + merge gate enforce it). No JIT needed for either.
|
||||
- Project fingerprint (stack, supabase, messaging, functions, graph, origin) moves to phase 3, its first consumer (listing filter), reused by phase 5.
|
||||
- Proof: canary per moved section (ABSENT without trigger, PRESENT after it: UI Read, UI prompt, graph.json present, empty dir, skill load, supabase Read); a new-file-only UI turn still gets Design work through the prompt hook; `/context` delta (~4.4k est. across phases 1, 2, 4a); hook tests extended (design-toolchain-reminder, session-start).
|
||||
- Cleanup: CLAUDE.global.md loses the moved sections (one pointer line each where needed), citers patched (doctrine-citers census); BDR-031 citers.
|
||||
- The `context` mod is born in phase 2 or 3 (first need: guards or listing rewrite); challenge at phase 2 launch whether guards fit better as classic hooks (push-guard pattern, transcript_path gives the last user message) or as the mod.
|
||||
|
||||
- [ ] **Phase 2, guards in the context mod (deny with reason, deterministic)**
|
||||
- Registry format: moved to phase 4a (measured 2026-10-24: registry writes go through Bash/python, never Edit, since Edit needs a Read of a 357k-char file; a `tool.call` guard on Edit/Write would miss them; a pre-commit validator sees every write path).
|
||||
|
||||
Reference in new issue
Block a user