Add deterministic context control layer that intercepts prompt
construction without modifying existing architecture:
- context_engine.py: single choke point (build_context) that assembles
structured prompts from ledger + sigil + live window, with token
budget enforcement and automatic window shrinking
- ledger.py: bounded per-stream JSON state (orientation, blockers,
open questions, delta) with hard field/list limits
- sigil.py: FIFO shorthand memory (max 15 entries) with deterministic
rule-based generation from message patterns
- token_gate.py: fast token estimation (~4 chars/token) and hard cap
enforcement with configurable MAX_TOKENS/LIVE_WINDOW
- redact.py: secret pattern detection (Discord, OpenAI, Anthropic,
AWS, Slack, GitHub, Telegram, Bearer, generic key=value) replaced
with [REDACTED_SECRET] before any output path
All 64 tests passing. No modifications to existing agent spawning,
model routing, tool system, or Discord relay architecture.
https://claude.ai/code/session_01K7BWJY2gUoJi6dq91Yc7nx