mirror of
https://github.com/multica-ai/multica.git
synced 2026-08-03 11:10:23 +02:00
Addresses review on #6158. The adapter sized and truncated the normalized changes, and redaction only ran later — in the daemon before sending, then again in the server on ingest. That order loses secrets that straddle the budget. The PEM rule needs both markers to match: -----BEGIN[A-Z\s]*PRIVATE KEY-----.*?-----END[A-Z\s]*PRIVATE KEY----- So a 70 KB private key whose BEGIN sits inside the first 64 KiB and whose END falls past the cut stops matching once truncated. Neither later pass can recognise what truncation already broke, so the marker and 64 KiB of key material reach the database and the WebSocket broadcast. Measured on the previous code: stored bytes 65536 | BEGIN marker present | key body present | placeholder absent Redaction now runs first, and the budget measures the redacted bodies — which is also the honest measurement, since those are what actually gets stored and redaction usually shrinks them (that key collapses to 23 bytes, so no trimming is needed at all). `original_bytes` still reports the pre-redaction size so the reader sees how large the real patch was. The daemon and server passes stay as defence in depth; redaction is idempotent, so running three times is safe and that is now asserted. Note for callers: codexPatchInput no longer trims its argument in place, because redaction copies first. Two existing tests were asserting on the caller's original slice and had silently become vacuous; they now read the returned payload, and one pins the no-mutation contract. The delete fixture in the diff-vs-content routing test was also a credential-shaped string, which now redacts — it is plain text so that test keeps testing routing. Verified: the new boundary test fails on the previous order, reporting the surviving BEGIN marker and key material, and passes now. go test ./pkg/agent ./pkg/redact ./internal/daemon green; execenv ByteIdentical green; go vet and gofmt clean. Co-authored-by: multica-agent <github@multica.ai>