diff --git a/.claude/memory/decisions.md b/.claude/memory/decisions.md index ec42bc8..1f05e5b 100644 --- a/.claude/memory/decisions.md +++ b/.claude/memory/decisions.md @@ -1500,4 +1500,5 @@ Branch feature/user-writing-web-rules, UNMERGED (human gate). - **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. +- **Amendment 4 (2026-10-25, challenge of phase 2 + profile facts + user answers)**: phase 2: phrase-list merge gate rejected (3 lenses FATAL: false allows/denies, breaks BDR-068 ritual + release sub-agent) → `$.ui.ask` confirmation dialog per branch (user pick), named exceptions, prefilter before `.catch`, hard_deny extended; commit limit → `commit-msg` git hook (CLAUDECODE-gated); code limits → classic PostToolUse on added lines, 80 cols only; G2 removed (BLK-022). Phase 5 = native packs: per-project `.claude/settings.local.json` `enabledPlugins` and per-conversation `claude --settings` proven concurrent (same and different projects); skills-dir plugins obey; plugin skills keep short names; plugin agents need prefix → agents stay global (user); global profile mode deleted (user); 11 profiles kept as pack compositions (user); detection proposes once (user); off pack mid-skill → propose + `/reload-plugins` (spike). User-scope MCP not switchable per project → MCP into packs. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 730c88d..b711710 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -39,16 +39,15 @@ Shared rules for every phase: - 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). - - Merge gate: Bash running `gitflow.sh finish` refused unless the last user message (recorded at `prompt.submit` origin composer) carries an explicit signal (merge it / merge le / merger / fusionne / feature OK / ship it, FR+EN list, tested on this session's real phrasings) or an AskUserQuestion answer approving the merge in the same turn. - - Commit message: `git commit -m/-F` over 50 words refused unless a project convention file exists (lib/commit-message.md lookup order). - - Code limits on OUR code only (origin from phase 1): after Edit/Write, report lines > 80 cols and functions > 25 logic lines as result `context`, never deny (language support: sh, ts/js, py, rs first; others skipped). - - Destructive guard: re-attempt G2 (BLK-022) as a `tool.call` guard in TS against `lib/tests/guard-bash.test.sh` 214 cases; if the safety classifier withholds it again, record and stop. - - Proof: one fixture per refusal + one benign twin per rule (no false positive), `.catch` fail-closed test, live canary run. - - Cleanup: doctrine prose that only restated an enforced rule shrinks to one line + pointer (gitflow "finish only on explicit human signal", commit-message limit, registry format); `lib/commit-message.md` keeps the convention lookup only if still cited. +- [ ] **Phase 2, guards** (redesigned 2026-10-25 after a 3-lens challenge: correctness FATAL(10), robustness FATAL(13), simplicity FATAL(6); plan `.claude/tasks/plans/2026-10-24-context-mod-phase2.md`) + - Killed by the challenge: the phrase-list merge gate (false allows: "don't merge it yet", "should we merge it?", pasted text, skill bodies in the transcript; false denies: a plain "oui"; it blocked the BDR-068 /close auto-finish and the release-executor sub-agent finish; "ship it" contradicts the doctrine); G2 destructive guard (BLK-022: the content is withheld, not the language; stays a user-driven task with its two listed options); whole-file code-limit reports (measured 1498 lines > 80 cols across 92 files, lib/gitflow.sh 81: over-fires, LRN-091); parsing commit text from Bash (heredoc `-m "$(cat <<'EOF' …)"`, `-F`, `-C`); registry format (in 4a). + - Merge gate (user pick 2026-10-25: confirmation dialog). Mod `tool.call` on Bash|Monitor matching `gitflow.sh finish`, `gitflow_finish`, or `git merge` while develop/main is checked out → `$.ui.ask("Merge → ?")`, one per branch, single use; dismissed, rejected, `-p`, or no surface → deny with reason "confirm at the terminal, then re-run". Named exceptions: BDR-068 ritual (this turn's prompt.submit command is capitalize or close, `gitflow.sh start chore ` seen this session, diff touches only `.claude/**`); release path in a decision table (verify that `$.ui.ask` works for a sub-agent's tool.call; else /release-candidate runs finish inline, BLK-018 option b). Cheap synchronous prefilter before the `.catch` deny, so a guard bug never denies every Bash call. Banner or doctor line when the guard is not live. settings.json hard_deny names mod refusals and the mod disarm paths (`mods//` sources, `~/.claude/.json` `"enabled": false`, `enabledPlugins` `@skills-dir`, dev-copy shadow). The finish prose stays until canaries pass across sessions. This is the first piece of the context mod. + - Commit message: `commit-msg` git hook emitted by the gitflow hook generator (global core.hooksPath, T10 drift test), active only when `CLAUDECODE=1`, words counted with trailers excluded, limit read from lib/commit-message.md (one place), exemption only on deterministic convention files (commit template, .gitmessage, commitlint config). A failure is a git error to fix by shortening, not a permission refusal. + - Code limits: classic PostToolUse hook, added lines only (Edit new_string, Write content), our code only (`lib/code-origin.sh` on the edited file's repo), 80 columns only, at most 5 reports, once per file per turn, `additionalContext`, never a deny. Function length deferred (or the project's own linter rule). + - Proof: an evasion matrix per rule (quoting, cd and -C, bash -c, heredoc, Monitor, sub-agent, non-composer turn); false-allow fixtures for the gate (negation, question, paste); the /close ritual still finishes; the release decision table is tested; destructive commands are never run live (plugin test with stubs only). + - Cleanup: compress the gitflow section only for the forms now enforced; the commit-message line already points at the lib. -- [ ] **Phase 3, listings: skills filtered + routing hint + agent descriptions** +- [ ] **Phase 3, listings** (scope note 2026-10-25: this is NOT the plugin advisor; per-project profiles are phase 5. Once phase 5 packs exist, the skill listing shrinks natively, so the mod listing filter shrinks to restoring truncated descriptions of kept skills; the routing hint, agent description trim and MCP names stay here; the fingerprint built here also feeds phase 5 profile detection.) - Skill listing: `prompt.attachment` type `skill_listing` (30,031 chars measured) rewritten from the fingerprint: categories per skill live in routing.json (new `contexts` field beside the phase row); a skill with no category stays SHOWN (new skills always appear); census test in make test fails on an uncategorised skill; kept skills get their full description back from SKILL.md frontmatter (LRN-175 truncation). Handle the listing delta sent mid-session. - To verify first (canary): a skill hidden from the listing still runs when typed (`/name`) and through the Skill tool. - Routing hint: classifier (reuse model-router's small-model call) maps a typed prompt to one skill; inject one line via `prompt.submit` `context` only above a confidence threshold, never on slash prompts, mid-turn or inside a run; names hidden skills too. Replaces the CLAUDE.global.md "Skill routing" table (2.1k chars). @@ -71,13 +70,16 @@ Shared rules for every phase: - Proof: validator zero false positive on the 8 projects; writer round-trip; backfill coverage; recall precision on ≥20 real prompts and ≥10 real errors (journal + transcripts), target ≥ the 14/22 baseline; digest canary after a compaction; haiku rerank latency inside the mod measured; `/context` delta; captured-failure demo: an error from session N recalled by match in session N+1. - Cleanup: hand-maintained Index steps in skills, "add one row to the Index" instructions, ad hoc append snippets, the false doctrine premise, reconcile legacy-only status parsing once backfill lands. -- [ ] **Phase 5, per-project profiles, native and concurrent (user ask 2026-10-24)** - - Today `lib/profile.sh` is global (symlinks skills/ ↔ skills-disabled/, `claude plugin enable|disable` user scope): every open session shares one profile. Target: each session gets its own profile, so web in one project, full in another, backend in a third, at the same time. - - Virtual profile in the context mod: all skills stay installed; the session's profile filters the skill listing, agent descriptions and MCP names (phase 3 mechanism). Profile pick: pinned per project (mod slash command `/profile set `, stored in `$.store` keyed by origin remote `host/path`), else auto from the fingerprint (astro/next site → web, Cargo.toml/go.mod without frontend → backend, else full). - - Per-skill activation: when a skill loads (`skill.prompt`), the skills/agents it needs (declared in routing.json, e.g. ship-feature → impeccable stack on a UI project) are advertised in its prompt even if the profile hides them. - - Plugins (hooks/MCP of real plugins): to verify whether project-scope `enabledPlugins` in `.claude/settings.local.json` is honoured; if yes, the mod writes nothing itself (never writes settings: BDR-116 spirit) and `/profile set` prints the line for the user; mid-session plugin toggling is not native, say so. - - Proof: two concurrent sessions in two repos with different profiles, canaries prove different listings; typed `/profile set` persists across restarts; per-skill advert canary. - - Cleanup: `lib/profile.sh set|apply|reset` symlink toggling + `skills-disabled/` (24 entries), Makefile `profile*` targets, `/profile` skill, plugin-gate prose tied to global toggling (`lib/plugin-gate.md`, plugin-probe/plugin-advisor briefs), banner hint "/plugin-check before starting a new project", doctor profile checks, profile tests; keep `lib/profiles/*.profile` as the profile definitions the mod reads. +- [ ] **Phase 5, per-project and per-conversation profiles, native packs** (redesigned 2026-10-25, facts + user answers) + - Facts 2026-10-24/25 (scratch projects, fresh headless sessions, canaries, run concurrently, one shared ~/.claude): `.claude/settings.local.json` `enabledPlugins` per project works both ways and concurrently (ui-ux-pro-max off in A while on in B; pr-review-toolkit on in A only); `claude --settings ''` gives two SIMULTANEOUS conversations in the SAME project different plugin sets; a skills-dir plugin (`~/.claude/skills/` + `.claude-plugin/plugin.json`, like model-router) obeys both; plugin skills keep their short name (Skill tool `ui-styling` and typed `/ui-styling` resolve); plugin agents need the `plugin:` prefix (`silent-failure-hunter` → not found); `permissions.deny Skill(x)` does not hide a skill; a user-scope MCP cannot be switched off per project by settings (`disabledMcpjsonServers` and `disabledMcpServers` had no effect): project-specific MCP belongs in a pack plugin or at local scope; claude.ai connectors do not load under `-p` (untestable headless). + - User answers 2026-10-25: profile can change per project and per conversation, never one profile for all conversations; tracked `.claude/settings.json` keeps deny/allow only, profiles go local; a project without a profile gets a detected proposal once, written on accept; the global mode (skills/ ↔ skills-disabled/ symlinks + user-scope plugin toggling) is DELETED; core = everything except the heavy packs (design, seo/geo, web-validate, scroll/3d, higgsfield, gstack); agents stay global (no packs, short names kept); a skill needing an off pack proposes to enable it then `/reload-plugins` (spike first; fallback: stop and name the pack); all 11 profiles kept, rewritten as pack compositions. + - Packs: each heavy group becomes a skills-dir plugin `skills/pack-/` (`.claude-plugin/plugin.json` + `skills//SKILL.md`, + `.mcp.json` for higgsfield, + hooks if a pack has any). Spike first: nested skills inside a skills-dir plugin load as plugin skills and not twice as user skills; gstack (external installer, symlinks) as a pack. + - Profile = `lib/profiles/.profile` → generated `~/.claude/profiles/.json` (`{"enabledPlugins": {...}}`). Per project: `profile.sh set ` writes `enabledPlugins` into the cwd project's `.claude/settings.local.json` (never user scope; gitignore line checked). Per conversation: launcher `claude --settings ~/.claude/profiles/.json` (shell function or `make` helper, named with the user), wins over the project default for that conversation only. + - Detection: session-start hook reads the fingerprint (stack, web public vs app, supabase, messaging, graph; from phase 3, or a minimal shell version here) when the project has no profile and proposes one in one line; writing it needs the user's yes. + - Pack needed mid-skill: orchestrators' existing gates (lib/design-gate.md + design-tool-gate.sh, lib/plugin-gate.md) check the required packs; off → propose enabling for this conversation/project + `/reload-plugins`; spike that a settings change + `/reload-plugins` loads the pack mid-session. + - Spikes listed: nested skills in a pack, `/reload-plugins` after a settings change, claude.ai connectors per project (interactive session only), user-scope MCP moved into packs (higgsfield first). + - Proof: two concurrent conversations in one project and two projects, canaries prove different listings, MCP and hooks per pack; `/context` per profile; old global toggling gone and nothing references `skills-disabled/`. + - Cleanup: `lib/profile.sh` symlink toggling + `skills-disabled/` (24 entries), user-scope plugin toggling in `set|apply|reset`, Makefile `profile*` targets rewired, `/profile` skill rewritten for packs, plugin-gate prose tied to global toggling, banner hint "/plugin-check before starting a new project", doctor profile checks, profile tests rewritten; `lib/profiles/*.profile` stay as the definitions. ### Actionable - [ ] 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)