feat: file-read decision gate — block reads when observation history exists

Add a PreToolUse gate that blocks file reads on first attempt when rich
observation history exists, presenting the timeline as feedback. Claude
then decides: use get_observations() (skip read, save tokens) or re-read
(allowed on second attempt).

- FileReadGate: in-memory session-scoped gate with 4h TTL
- POST /api/file-context/gate endpoint in worker
- stderrMessage plumbing in hook-command for exit code 2
- file-context handler uses gate to block/allow reads

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alex Newman
2026-03-19 12:11:02 -07:00
parent 47d6d51030
commit c80763390b
6 changed files with 914 additions and 68137 deletions
+1
View File
@@ -23,6 +23,7 @@ export interface HookResult {
};
systemMessage?: string;
exitCode?: number;
stderrMessage?: string; // Written to stderr before exit (for exit code 2 blocking feedback)
}
export interface PlatformAdapter {