diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a630c5..45ceec2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/) and this project - **model-router prompt classifier**: a plain prompt typed in the composer (12 characters or more, not a slash command, not mid-turn, never under `-p` or in a sub-agent) that no keyword rule, skill, run slot, `/route` or floor covers is labelled by one call to the engine's small model (`design`, `analysis`, `coding`, `bookkeeping`, `chat`), bounded to 3 s. The label maps to plan, reflect, implement or apply and the turn takes that phase's route: its effort, and its model under the switch and the downgrade cap, never above the session model (an `ultrathink` floor raises the effort only, the guess's model holds); no dialog, no file write, gone at the end of the turn, replaced by any route call or typed skill, and dropped for that turn by a `/effort` typed between turns. Three failures in a row pause it for `cooldownMinutes` (one toast, `classifier: paused` in the status line). `"classify": false` in `~/.claude/model-router.json` and `/route classify on|off` turn it off; `/route show` prints `classify:`. The status line reads `route: classifier ` and `/route verbose on` adds `(: classifier)`. - **model-router cold-read caps**: both main-loop caps measure the cold read a switch costs, from a per-model record of main's last step, warm within the engine's prompt-cache TTL (`cache_ttl` 5m or 1h from main's model-switch events, 1 h before the first, kept across `/clear`; records cleared by `/clear` and `/route reload`), plus the submitted prompt the engine's usage may not count yet (code points / 3 of its text, context entries and a typed skill's body, added at the turn's first main step unless usage already grew by half of it; a `document` attachment blocks the switch for that step); `downgradeMaxTokens` (default 120000) joins `upgradeMaxTokens` (200000). A model-loaded helper skill inside a best-tier run moves effort only; main routed onto a model whose window the context outgrew returns to the session model. `/route show` prints `switch: on (downgrade, cap 120000 tokens cold, ttl 60 min)`, the status line shows ` · switch off` only when the switch is off, the skip line is logged once per cap crossing and the change toast names a cap hold. A built-in `general-purpose` agent that main spawns with no model while main sits below the session model starts on the session model instead of inheriting the lower one. +- **Phase 2 guards (BDR-125)**: the deterministic half of the gitflow and routing doctrine. Merge gate: `ask` rules on `git merge *`, `bash *gitflow.sh finish*` (it also asks on the quoted `bash "$HOME/.claude/lib/gitflow.sh" finish` every skill types) and `sh *gitflow.sh finish*`: every finish raises one permission prompt, `/close` and `/capitalize` 5C included; a declined prompt stops the flow with "nothing merged, branch kept". Shell forms: `ask` on `sh -c` and its flag forms (`sh -ec`, `bash -lc`, `dash -c`), a bare `bash`/`sh` fed by a heredoc, `bash <(…)`, `/bin/sh`, `/bin/bash`, `/usr/bin/sh`, `/usr/bin/bash`, `/usr/bin/env sh|bash`; `deny` on `awk *system(*`, the flag forms `head|tail|cat * .env*` and `* */.env*` (the plain deny missed `head -5 .env`), and an `rtk read` twin (relative and absolute) for every `cat|head|tail` deny, locked by a census (push-guard T62, T63). Each rule was proven in a saved headless bench in auto mode (`.claude/tasks/plans/2026-11-02-phase2-bench/`); `ask` raising a prompt in an interactive auto-mode session was checked by hand. Not covered, written down as `autoMode.soft_deny` "Static rule blind spots": `$(…)` in command position, a quoted literal argument, inline interpreters, `… | bash -s`, a sourced `gitflow_finish`, and `git -C merge`. Routing guard in model-router: a main-loop Edit, Write or NotebookEdit of a code file (config included; `.md`, `.txt`, the project's `.claude/` outside `worktrees/` and `docs/` are free) is redirected ("code is written inside a skill run. Enter /hotfix, /feat, /bugfix or /ship-feature, or re-enter the skill you were running") until a skill ran on the main loop in the session, a phase was declared this turn, or a typed `/route` holds; sub-agents write freely; `/route clear`, `/route off` and `/clear` re-arm it; a `/model` hand pick does not open it; a register.ts reload resets it. A new `autoMode.hard_deny` entry says a redirect is followed, never routed around, and `permissions.ask` is never edited to pass a gate. code-limits hook (PostToolUse, `Edit|Write`): the lines a file gained over 80 columns, in our code only (`lib/code-origin.sh`), once per file per session, as context, never a block; silent in a repo the origin check calls foreign, this one included unless `git config claude.origin ours`. - **model-router ask before Fable**: before a route lifts the main loop, or a rowed agent, onto Fable from another model, the mod asks once per span with the origin (skill, agent, `route` tool, `/route`), the phase and its `about` line, the model and the effort: `Fable`, `Opus instead (big tier)` (the span resolves through the `big` tier at the phase's effort, offered only while Opus is up) or `Stop asking this session` (paused until `/clear`). A best-tier skill the model loads counts as a skill row; a spawn keeps one answer per agent type per session. Never headless (`-p`) or inside a sub-agent; a dismissed dialog runs Fable; no answer is written to `routing.json` (`confirmed` included). `routing.json` gains `askTier` (`best`, or `false` to turn it off; the machine config wins), set by `/route ask-tier on|off`; `/route show` prints `ask-tier:`. Known limit: when a Fable breaker hold or a cold-read cap lapses later, main upgrades without asking. Tests: `mods/model-router/hooks/register.test.ts` (TIER). - **/explain-diff skill**: turns a change (commit, range, branch, merge, PR, staged or uncommitted work) into one self-contained HTML page saved outside the repo, under `~/Documents/explanations//YYYY-MM-DD-.html`. The page has a background, an intuition built on toy data with HTML diagrams, a code walkthrough grouped by concern and a 5-question interactive quiz. Adapted from Geoffrey Litt's explain-diff gist. A bundled template (light and dark, works offline) and a checker (`scripts/check_explanation.py`: file name, location, sections, quiz, code escaping, no ASCII art, no em-dash) hold every page to the same floor. Routing row `reflect`; profiles full, max and dev. - **Project path rules (CLAUDE.md split)**: `lib/project-rules.sh` (`check`, `matches`, `sections`, `extract`, `emit`, optional `-C `) is the glob oracle for `.claude/rules/.md` rules, one-line `paths:` frontmatter, loaded on Read of a matching file; suite `lib/tests/project-rules.test.sh`. `/onboard split` classifies an existing project CLAUDE.md section by section behind a gate and moves the path-bound ones into rules on a `chore/claude-md-split` branch. `extract` also moves a `###` subsection (heading passed as `'### '`; a bare heading stays `##`), which ends at the next heading of level 3 or less outside a fence, and `sections --depth 3` lists each `##` section's subsections with their sizes, so `/onboard split` can move a path-bound subsection out of an always-on parent (one `### <title>` row; a row's parent is never itself a move row). `extract` refuses an absolute `<out>`, one with a `..` part, or one that already exists (a dangling symlink included), with rc 2 and the reason on stderr, and leaves the source CLAUDE.md untouched when the rule directory or file cannot be written. `/onboard` and `/init-project` emit `docker`, `testing` and `ci` rules from `templates/project-rules/` when their globs match. This repo's CLAUDE.md now keeps its header, Health Stack and a pointer; four sections load as path rules. @@ -29,6 +30,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/) and this project - The design gate, the plugin gate and advisor, the statusline, the session banner and `doctor.sh` read `profile.sh current --plain`. `doctor.sh` gains Packs and Profiles sections and checks that `cc.sh` is sourced. ### Changed +- **rtk hook passes rtk-ask commands through**: a command rtk's registry asks about (rc 3) now reaches Claude Code unrewritten, so the native `ask` and `deny` rules judge it as typed (a `rtk git push origin :ref` rewrite escaped both). Visible effect: `git push`, `git stash pop` and the install forms raise their native permission prompt. `/release-candidate` runs `gitflow.sh finish` and the tag in the main loop, the release-executor keeps the prep span only (a sub-agent cannot put the finish prompt to you, BLK-018). The ceiling doctrine is model-agnostic: the main loop writes no code outside a skill run. - **model-router bare `/model` dialog**: a bare `/model` opens the router's dialog (model, variant, scope), so the scope question also comes when the pick is the current model (fable, opus, sonnet; a current haiku goes through `/model haiku`). Step 1 asks fable, opus, sonnet or `Other model (native picker)` (the native picker, run with the slot free so a pick inside it asks its scope); step 2 asks Standard or `[1m]`; step 3 is the existing scope question. Esc or free text changes nothing. Tests: `mods/model-router/hooks/register.test.ts`. - Registries are written only through `lib/memory.sh`, never by Edit (`CLAUDE.global.md`, Memory registries); every CAPITALIZE step (`/feat`, `/bugfix`, `/hotfix`, `/ship-feature`, `/capitalize`, `/init-project`, `/onboard`, `commit-changer`) and the gated capitalize offers of `/tour`, `/deploy` and `/audit-delta` write through `lib/capitalize-commit.md` § WRITE. - `lib/memory-commit.sh commit` runs `memory.sh check --staged` first: a staged v2 registry that removes or rewrites a line inside an entry, gains a duplicate ID, a bad heading or an open fence, or is deleted or downgraded is unstaged and refused with rc 6; a HEAD or staged blob git cannot read is refused too, and stderr names each memory path whose separate partial stage the refusal dropped, with its blob id and `git update-index --cacheinfo` restore command; v1 registries are skipped.