From 55f4b6ab6ee7ec5c7011c3c239420b8a515c33c6 Mon Sep 17 00:00:00 2001 From: bchanot Date: Tue, 3 Nov 2026 14:55:14 +0100 Subject: [PATCH] chore(contract): phase 4b brainstorm answers [gated] --- .../tasks/contracts/2026-11-03-memory-capture-0100.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.claude/tasks/contracts/2026-11-03-memory-capture-0100.md b/.claude/tasks/contracts/2026-11-03-memory-capture-0100.md index 393e563..d103972 100644 --- a/.claude/tasks/contracts/2026-11-03-memory-capture-0100.md +++ b/.claude/tasks/contracts/2026-11-03-memory-capture-0100.md @@ -14,6 +14,16 @@ Pass A (gaps found by the STEP 0d read-before, put to the user at the STEP 1 bra - Engine facts that reshape the seed (types 2.1.277 on disk, CLI 2.1.317): a non-zero Bash exit is an `isError` result whose text starts `Exit code N` (no exit-code field; the typed record with stdout/stderr/gitOperation exists on success only); `$.store` is per plugin, machine-wide, cross-project, 4 MiB total (not per session); there is no `$.state`; a registered tool exists from the prompt after `session.start`; sub-agents with a `tools:` allowlist cannot call an MCP tool (commit-changer); gitleaks rules are compiled into the binary (no data to port as-is); `session.id` changes on /clear and resume. - Spike 2026-11-03 (probe mod, headless, CLI 2.1.317; `.claude/tasks/plans/2026-11-03-memory-capture-spike/REPORT.md`): a non-zero exit, a deny rule and an unapproved ask all come back from `next(e)` as `isError: true` with the reason only in `text` (`Exit code N\n`, `Permission to use Bash with command … has been denied.`, `Claude requested permissions to use Bash, but you haven't granted it yet.`), never a `deny` field; `classic.PermissionDenied` never fired; `classic.PostToolUseFailure` fires on non-zero exits (`error` = text); success results carry `{stdout, stderr, interrupted}` and NO `gitOperation`, even on real commits (direct and in a script); stdout reaches the hook in clear (`TOKEN=abc123`), so redaction is needed. +Brainstorm answers `[gated 2026-11-03]` (user: "oui" to recommendations 1-8): +1. Host: a new mod `mods/memory/` (it will also host 4c), tool `memory_pending` → `mcp__memory__memory_pending`. +2. Failure = a Bash `isError` result whose text starts `Exit code N`, main loop and sub-agents; excluded: permission refusals (`Permission to use …`, `… haven't granted it yet`), guard redirects (`model-router: …`), `tool_use_error`, and a failure with no error line after `Exit code N`; distinctive line = the last non-empty line after `Exit code N`; deduplicated per session by normalized line. +3. Store: keyed by project root; ≤ 50 failures per session, ≤ 2 KiB per entry, the 3 most recent sessions per project kept (survives /clear), global cap 1 MiB of the 4 MiB `$.store`. +4. Match: index built at call time from backticked spans of BLK and LRN bodies (superseded excluded); known = shares ≥ 1 normalized word 4-gram (digits, paths, hex → placeholders); known entries carry the ID, the rest are "new". +5. Milestones: a successful `git commit` whose message starts `feat` or `fix` (read from the command text), a successful `gitflow.sh finish` except `finish chore`, the same `make test …` command going red then green; one-line note at the next prompt, once per milestone. +6. Redaction: TS pattern set = `KEY=value` for TOKEN|API_KEY|SECRET|PASSWORD|PASSWD, the 7 /guardrails SECRET_PATTERNS, `Bearer` tokens, URLs with `user:pass@`; 40-hex SHAs kept; no gitleaks call. +7. Consumers: /capitalize, /close and CAPITALIZE steps call it first; /commit-change calls it before dispatching commit-changer and passes the result; /hotfix stays silent unless the tool returns a new failure. +8. The tool stays deferred like `route`; skills load it with `ToolSearch` once per session. + ## ACCEPTANCE CRITERIA (seed, enriched at STEP 3 `[gated]`) 1. A mod captures failures (scope decided at the brainstorm) as entries {normalized line, verbatim excerpt, command, tool, time}, redacted BEFORE storage, in a bounded store layout decided at the brainstorm (entries per session, bytes per entry, eviction of stale sessions, total under the 4 MiB `$.store` cap). 2. Each captured failure is matched against an error index built from the project's `.claude/memory/` registries (rule decided at the brainstorm); matched ones carry the entry ID, unmatched ones are "new failure modes".