Repository navigation
Description
Part of #83.
Problem
PR #67 stops credentials from being written from now on, but nothing deals with credentials that are already in the store, and memory_export will hand them to anyone holding the file.
Verified on main and on the #67 branch:
- Rows written before the change keep their secrets verbatim; they are injected into future sessions' system prompts exactly as before (and PR fix(inject): refresh the frozen memory block when its rows change #65 makes the removal take effect on the next request only once the row is edited or blocked).
memory_exportwrites active rows as-is, including any stored secret, to a caller-chosen path (fileis unrestricted today — see memory_export/memory_import accept arbitrary paths outside the memory root #24).- Snapshots in
<memory-root>/snapshots/keep every historical copy of a day file, so a redacted secret typically still exists in at least one snapshot, andmemory_undocan bring it back (withforce=trueby design, per fix(undo): restore only store snapshots and keep deleted rows deleted #63). memory_evidence/ blocked-write records: worth confirming the redaction happens before anyrecord*call on every path so the evidence log does not become another copy at rest.
What to decide and build
- Detection: reuse
src/secrets.tsas a scanner and report where matches live (day file, snapshot, evidence) without echoing the secret — offsets/line numbers and the matched family only. - Scrub tool: an explicit, snapshot-first, audited operation (mirroring
prune: reason + snapshot +deletions-style audit) that replaces matches with[redacted]across day files. Snapshots should be handled too, or the scrub is cosmetic whilememory_undostill restores the secret. - Policy statement in the README: redaction is forward-only; scrubbing an existing store is an explicit operation; export may contain secrets that predate it.
- ts stability interaction: rewriting a row's content in place must keep its
ts(row identity) — check that this still invalidates an epoch under PR fix(inject): refresh the frozen memory block when its rows change #65's content-hashedstoreVersion(it does) and that the blocklist/blocklist-free rows behave as expected.
Context
Split out of the #67 review, where the maintainer ruled to keep the best-effort scrub and document it rather than expanding it into a migration in that PR.
Slice 1 acceptance criteria: redact at export
Added 2026-11-02 at the maintainer's direction so this is executable. This slice closes the export face of the problem only. Items 2, 3 and 4 above (scrub tool, snapshots, README policy) stay open as follow-ups.
Verified on main today, so the claims below are current:
src/portable/export.ts:152serialisescontent: m.contentwith no redaction step.- The write side already redacts:
src/store/files/append.ts:109,supersede.ts:83,deletions.ts:28. - The helper exists and is exported:
redactSecretsatsrc/store/secrets.ts:27,REDACTED_SECRETat:5. - Correction to this ticket: the claim above that
fileis unrestricted is stale.resolveExportPathnow routes every destination throughresolveContained(..., exportsDir(), ...)(memory_export has no repo-visibility filter — any session can export every repository's rows #143), so export is confined to<memory-root>/exports/unless the operator escape hatch is set. memory_export/memory_import accept arbitrary paths outside the memory root #24 is not part of this slice.
- A new test file under
test/fails at the merge-base and passes on the branch. Report both pass/fail counts. - A row whose
contentholds ask--prefixed token exports JSONL that contains[redacted]and does not contain the token. - Same guarantee for the
issuefield, which is free text. - A row with no credential-shaped text serialises byte-identically to today's output. No reformatting, no key reordering, no whitespace change.
- The header line and the returned
countare unchanged. - Export stays a read path: after exporting, re-read the store and assert the original row content is untouched. Redaction happens on the value being written, never on the row.
bun run typecheck,bun run lintandbun run testall pass.git diff --name-onlyagainst the base listssrc/portable/export.ts, the one new test file, andtest/write-caps.test.ts— nothing else. The change totest/write-caps.test.tsis confined to the two lines that assert a stored credential survives export (currently 165-166). They must still assert the row is present viascope, and must now assert the credential is replaced by[redacted]. No other assertion in that file may change.
Out of scope: rewriting day files or snapshots, memory_undo, memory_import, writeExport's flags or mode, EXPORT_HEADER, EXPORT_VERSION, and any pattern change in src/store/secrets.ts.
If a criterion cannot be met without touching an out-of-scope file, stop and label this fix:blocked rather than widening the diff.
Activity
fix(capture): redact at appendMemory, reject credential metadata, doc…
chore(release): 0.8.8 [skip ci]
fix(security): scrub credentials at the evidence write boundary (abog…
chore(release): 0.14.12 [skip ci]
fix(security): make every update exit claim the truth (review of abog…
abogartz commentedon Oct 30, 2026
Severity triage 2026-10-30 —
severity:highReviewed against
main@525ed89. Still unbuilt: no scrub operation exists anywhere —grep -rn '"scrub\|scrub:' src/index.ts→ zero hits. What ships today is forward-only redaction (src/secrets.ts, used on capture egress) plus a scrub at the evidence write boundary (src/evidence.ts:50scrubFields).Marked high, not critical, because it requires a secret to already be in the store — it is a latent-condition ticket, not a live leak. But it stays above the mediums because when it does bite, the exposure is compounding and every existing mitigation stops at the write:
memory_exportwrites them out verbatim (and memory_export has no repo-visibility filter — any session can export every repository's rows #143's reader filter now correctly exports them to their own repo's session — the filter is not a redaction);<memory-root>/snapshots/keeps every historical copy, somemory_undo --forcerestores a secret you thought you removed.Your own framing in the body is the right bar: "must not be cosmetic while
memory_undo --forcecan restore a redacted secret from a snapshot." That is the acceptance test that matters — a scrub of day files alone leaves the secret one undo away, so snapshots must be in scope or the ticket isn't done.Sequence note: this was written as "sharpest after #24" — #24 (path containment) is now CLOSED, so nothing blocks it. The
ts-stability interaction you flagged (rewriting content in place must preserve row identity while still invalidating a content-hashed epoch) is still a real constraint to pin in the same PR.WhollyMindless commentedon Nov 1, 2026
Before proposing an implementation, could we settle the recovery policy for this? Your requirement that snapshots must not let force-undo restore a scrubbed secret is clear. The remaining tension is with the issue's "snapshot-first" direction: an ordinary pre-scrub snapshot would preserve exactly the values being removed.
My proposed default is an explicit dry-run/apply operation that sanitizes existing snapshots as well as live rows, preserves row timestamps, and creates only sanitized recovery copies. It would retain no unsanitized backup in the normal restore namespace. That makes false-positive redaction deliberately irreversible through ordinary undo, which deserves an explicit operator warning and your agreement.
The regression bar would include force-undo of every retained snapshot after a successful scrub, plus interrupted-operation recovery, with scan/audit output never echoing matched secrets. Happy to narrow or defer this; this comment asks for design direction and does not claim implementation.
abogartz commentedon Nov 2, 2026
Scope ruling, 2026-11-02: slice 1 is export-only, per the acceptance criteria added above. Snapshots, the scrub tool and the README policy statement stay open in this ticket.
@WhollyMindless your recovery-policy question is the right question and slice 1 does not answer it. It gates the scrub-tool slice, which rewrites durable data, so it needs its own decision about whether an unsanitized pre-scrub snapshot may exist at all. I have filed that as a separate ticket so it has somewhere to be argued that is not blocking this one.
Slice 1 restores nothing and rewrites nothing: redaction happens on the value being serialised into the export file, never on the stored row.
Two claims in the original body are now stale and I corrected them inline: export destination is confined to
<memory-root>/exports/viaresolveContainedsince #143, so #24 is not part of this; and the evidence log is already scrubbed at its write boundary (src/evidence/record.ts:52scrubFields, called at:116), so that "worth confirming" item is settled. What remains genuinely unbuilt is the scrub operation itself —git grepfor a scrub entry point on main returns nothing.ocsi-fixer commentedon Nov 2, 2026
Blocked: criterion 2 contradicts an existing in-scope-forbidden test. Reproduced the defect on
main@bf7f6d2(src/portable/export.tsserialisescontent/issuewith no redaction), implemented the slice (redact on the serialised value viaredactSecrets, store untouched), and addedtest/export-redaction.test.ts: 3 pass / 2 fail at the merge-base, 5 pass / 0 fail on the branch. Buttest/write-caps.test.ts:166assertsreadFileSync(exportFile, "utf8")).toContain(legacySecret)— it pins thatmemory_exportwrites a storedghp_secret verbatim (the behavior this ticket calls the defect). Criterion 2 forbids a stored token in the export, criterion 7 requiresbun run testgreen, and criterion 8 limits the diff tosrc/portable/export.tsplus the one new test file, so the pin cannot be updated inside scope; measured:bun run typecheckandbun run lintpass,bun run testis 864 pass / 14 skip / 1 fail (write-caps.test.ts:166), and write-caps alone is 10 pass / 0 fail at the merge-base and fails only under the fix. Needs a maintainer ruling: either amend the file scope to allow updatingtest/write-caps.test.ts:165-166to the redacted expectation, or restate criterion 2 — no implementation satisfies both as written.abogartz commentedon Nov 2, 2026
Ruling: criterion 8 amended,
fix:blockedcleared. Proceed.test/write-caps.test.tsis now in scope, limited to the two lines that assert a credential survives export.That test exists to prove an export is a confined copy of the store (#24). It used a credential-shaped string as convenient payload. Its purpose is not "a secret survives export" — that is the defect this ticket reports. Keep the purpose, change the expectation: assert the row is still present via
scope, assert the credential is replaced by[redacted].No other assertion in that file may change. Everything else you measured stands, including the 3 fail → 5 pass differential and leaving the stored row untouched.
Merge pull request #257 from abogartz/fix-issue-74-20261102T200500
chore(release): 0.15.9 [skip ci]
abogartz-opencode-self-improvement commentedon Nov 2, 2026
🎉 This issue has been resolved in version 0.15.9 🎉
The release is available on:
Your semantic-release bot 📦🚀
chore(release): 0.22.1 [skip ci]