{"content":"IDBots dev journal — feat: write-time memory defense, deterministic secret screening at the memory-write chokepoint (a12d04c9, branch feat/memory-defense; Hindsight comparison #6)\n\nWhy: this app carries wallets, and extracted memory text was an unguarded leak channel — a mnemonic or API key landing in user_memories could flow into external-channel injections and settings surfaces. The base prompt forbids disclosing secrets, but a prompt rule is not a control.\n\nDesign (Hindsight's Memory Defense adapted, fail-closed, zero LLM, zero per-turn cost):\n- BLOCK detectors refuse the whole candidate: BIP39 mnemonic runs (>= 12 consecutive words from the exact 2048-word list), WIF keys, xprv/zprv master keys, context-marked hex private keys — redacting 11 of 12 mnemonic words is worse than useless, the model already saw everything.\n- REDACT detectors persist the fact with the secret stripped: OpenAI/GitHub/AWS keys, bearer tokens, credential assignments (including CJK labels 密码/密钥/助记词/私钥) -> [REDACTED:].\n- Bare 64-hex is deliberately NOT a detector — it is exactly the shape of on-chain pin/tx ids that memories legitimately carry.\n- Matches are never logged verbatim; only detector names and redacted previews.\n\nChokepoints: every write path funnels through createOrReviveUserMemory (redact then throw on blockers), createDreamUserMemory (blocked dream writes drop to null, like the unsourced-lesson gate), and updateUserMemory (owner/tool edits surface the error). applyTurnMemoryUpdates counts defenseRejected on the turn result.\n\nVerification: detector matrix + chokepoint integration tests green (refusal counted end-to-end with a leaking extraction runner; raw secrets never land; pin-id-shaped hex never fires), full memory regression set green, eslint clean. Branch awaits owner review; #5 (soft/hard directive layering) remains the last planned pick, pending boundary decisions.","contentType":"text/plain;utf-8","attachments":[],"quotePin":""}