diff --git a/.claude/memory/decisions.md b/.claude/memory/decisions.md index 8f0a9a7..01cd954 100644 --- a/.claude/memory/decisions.md +++ b/.claude/memory/decisions.md @@ -1502,4 +1502,5 @@ Branch feature/user-writing-web-rules, UNMERGED (human gate). - **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. - **Amendment 5 (2026-10-25, routing verification + user picks)**: routing probe bench (`.claude/tasks/plans/2026-10-25-routing-probe/`): fresh sessions route explicit intents right (init-project, close, bugfix, reconcile, commit-change, cso), but a small feature ask was coded inline and history shows 11/21 code-writing bug/feature turns inline. User: always through a skill → phase 2 routing guard (main-loop code write outside a skill run denied; docs, `.claude/**`, sub-agents, in-skill writes free; ceiling bullet rewritten model-agnostic). Interviewer: by design inline in /init-project (C1 routed right), unused only because no new project in the window. Listing: 46/124 skills name-only; `SLASH_COMMAND_TOOL_CHAR_BUDGET=60000` → 0 name-only (+~17k chars); raise after packs (user). Order: 0 → 4a → 1 → 5 → 2 → 3 → 4b-4d (user). +- **Amendment 6 (2026-10-25, shell deny probe)**: bench `.claude/tasks/plans/2026-10-25-bash-deny-probe/`. Native Bash deny matcher sees through compound ops, subshell, `env`/`command`/`timeout`/`nohup`/`xargs`, quoted command word, simple assignments: no per-rule shell duplication. Misses `sh -c`, bare shell + heredoc, `$(…)` command, absolute path, interpreters, quoted literal arg. Under `defaultMode: auto` classifier approved every miss. rtk-rewrite hook runs before permission eval, deny evaluated on rewritten cmd: `git push origin :feature` → `rtk git push …` bypasses `git push * :**` (ac23cc6) and ask `git push *`; `cat */*.pem` likewise. Redirects into Edit-denied path denied. `ask` beats `allow`. User: stay auto, fixes go in phase 2 (rtk rc=3 passthrough + rtk read twins, targeted ask/deny rules, limits written down, routing guard covers Bash writes). Interim risk accepted with the phase order. diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 29054e0..7168a9b 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -648,3 +648,4 @@ rules: ## 2026-10-25 - Context-mod plan hardened: phase 2 challenged (3 lenses FATAL) → $.ui.ask merge gate, commit-msg git hook, added-lines 80-col hook, G2 out; phase 5 = native packs, per-project settings.local + per-conversation --settings proven concurrent; routing probe: explicit intents route right, small feature coded inline, 11/21 history code turns inline → routing guard (user: always via skill); 46/124 skills name-only, budget env fixes it (after packs). Order 0 → 4a → 1 → 5 → 2 → 3 → 4b-4d. Side: faunosteo TODO has stale follow-ups (ZodError msg gone since R4.7, SVG sanitiser done since R5.5): run /reconcile there. +- Shell deny probe (user: facts): 27 variants vs `Bash(echo SECRET*)`; matcher sees through compound/wrappers/assignments, misses `sh -c`, heredoc shell, `$(…)`, abs path, interpreters, quoted literal arg; auto mode classifier approved all misses. rtk-rewrite hook bypasses deny on rewritten cmds (`git push origin :feature`, `cat */*.pem`): ac23cc6 fix inert in real use. Fixes queued in phase 2 (BDR-125 amendment 6), order kept, mode stays auto. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 0cd2915..4222dd2 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -42,10 +42,16 @@ Shared rules for every phase: - [ ] **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. - - Routing guard (user pick 2026-10-25: "always through a skill"). Measured: "j'aimerais que doctor.sh affiche la version de rtk" was coded inline with no skill (routing probe L3); history 2026-09-23 → 10-24: 10 code-writing bug/feature turns went through a skill, 11 coded inline (long pasted faunosteo briefs). Mod `tool.call` on Edit/Write/NotebookEdit of a code file by the MAIN loop (no `agentId`) while no skill run is active (model-router run slot or a `skill.prompt` seen this turn for feat/bugfix/hotfix/ship-feature/refactor/code-clean/tour…) → deny with reason "route through /hotfix (≤2 files, obvious), /feat, /bugfix or /ship-feature". Free: docs (.md), `.claude/**`, sub-agents (executors), any write inside a skill run. Doctrine follows in the same change: the ceiling bullet becomes "the main loop writes no code outside a skill run, whatever the model". Proof: routing bench `.claude/tasks/plans/2026-10-25-routing-probe/` cases (L3 must now enter a skill), long-brief replay in a clone, false-deny fixtures (doc edits, executor edits, in-skill edits). + - Routing guard (user pick 2026-10-25: "always through a skill"). Measured: "j'aimerais que doctor.sh affiche la version de rtk" was coded inline with no skill (routing probe L3); history 2026-09-23 → 10-24: 10 code-writing bug/feature turns went through a skill, 11 coded inline (long pasted faunosteo briefs). Mod `tool.call` on Edit/Write/NotebookEdit of a code file by the MAIN loop (no `agentId`) while no skill run is active (model-router run slot or a `skill.prompt` seen this turn for feat/bugfix/hotfix/ship-feature/refactor/code-clean/tour…) → deny with reason "route through /hotfix (≤2 files, obvious), /feat, /bugfix or /ship-feature". Free: docs (.md), `.claude/**`, sub-agents (executors), any write inside a skill run. Bash write forms to a code file by the main loop (`>`/`>>` redirect, `tee`, `sed -i`, `cat < f`, `python3 -c 'open(…,"w")'`) → same deny, cheap regex prefilter, unparseable → allow (never deny every Bash). Doctrine follows in the same change: the ceiling bullet becomes "the main loop writes no code outside a skill run, whatever the model". Proof: routing bench `.claude/tasks/plans/2026-10-25-routing-probe/` cases (L3 must now enter a skill), long-brief replay in a clone, false-deny fixtures (doc edits, executor edits, in-skill edits, Bash writes inside a run). + - Shell deny hygiene (measured 2026-10-25, bench `.claude/tasks/plans/2026-10-25-bash-deny-probe/`; user pick: stay in `defaultMode: auto`). Facts: the native matcher already sees through `&&` `;` `||` `|` newline `( )` `env` `command` `\cmd` `timeout` `nohup` `xargs` quoted command word and simple assignments (no per-rule duplication needed); it misses `sh -c`, bare `bash`/`sh` + heredoc, `$(…)` in command position, absolute paths, interpreters (`python3 -c`, `awk system()`, `node -e`) and a quoted literal argument (`git push origin ":feature"` escapes `:**`); under auto every miss was approved by the classifier, not prompted; the rtk-rewrite PreToolUse hook runs BEFORE permission evaluation and the deny is evaluated on the REWRITTEN command (`cat SECRET.txt` under deny `cat SECRET*`: DENIED hooks off, RAN hooks on; `git push origin :feature` → rc=3 → `rtk git push origin :feature`, so deny `git push * :**` (hotfix ac23cc6) and ask `git push *` are bypassed in real use; rc=2 forms `--delete` `+ref` `--force*` `.env` `id_rsa` `.aws` `find -delete|-exec` `git branch -D` are left unchanged and hold; rc=0 misses `cat */*.pem`, `cat */secrets/*`); Bash redirects into an Edit-denied path ARE denied; `ask` beats `allow` (an `ask Bash(bash *)` prompts every lib script: never). + - rtk hook: rc=3 → pass through unchanged (no `updatedInput`), native deny/ask see the original; re-pin `hooks/.rtk-hook.sha256`; hook test with the `cat SECRET*` analogue hooks-on. rc=0 reads: census test that every `Bash(cat|head|tail )` deny has its `Bash(rtk read )` twin, twins added. + - settings.json `ask` += `Bash(sh -c *)`, `Bash(bash)`, `Bash(sh)`, `Bash(bash -s*)`, `Bash(bash <(*)`, `Bash(/*)`, `Bash(python3 -c *)`, `Bash(python -c *)`, `Bash(node -e *)`; `deny` += `Bash(awk *system*)` (`awk *` stays allowed; proven: plain awk RAN, system() DENIED). Each pattern proven in the bench (r3) before landing. P41 (templates: "ask inert under auto") is contradicted by measurement (`bash -c` prompted under auto in -p): re-check and fix the item, not the config. + - Limits written down, one place: settings.json soft_deny note + README permissions: `$(…)` in command position and a quoted literal argument have no matchable rule and rest on the classifier; mode stays auto. + - Folds TODO Actionable "docker host-root mount spellings" (prove with the same bench, same change) and the T42 dead-entry drop list (`git push * :*` etc.) if the release lands first. + - Interim (accepted with the order 0 → 4a → 1 → 5 → 2): until this lands, a `git push origin :ref` deletion rests on the classifier and rtk's registry, not on settings.json. - 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). + - Proof: an evasion matrix per rule (the bash-deny-probe bench: quoting, cd and -C, bash -c, sh -c, heredoc, $(…), absolute path, interpreters, rtk rewrite hooks-on, 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** (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.)