Repository navigation
feat(storage)!: the session log stores the redacted form - #634
Merged
Merged
Conversation
Owner decision 2026-11-11 (#596, design secrets-integrations §5, §8.1); reverses E11's "the durable log keeps the original". JsonlStorage::commit redacts every entry payload with the process SecretSet before the line is encoded: structurally, every string and key, in every form the set knows (as is, JSON-escaped, base64, percent-encoded; a secret that is a bare number becomes the marker string). The pinned system prompt is redacted the same way. An entry that hid a secret carries "redacted": ["NAME"] on the wire, names only, absent otherwise. The committed in-memory entry is that same redacted form and the provider is fed from it, so the log stores what the provider saw and a replay rebuilds the same request. The set is the process set (secrets::set_process_secrets), built once; the CLI installs everything a provider request is redacted with, both providers' keys and URL passwords included (provider_chain::log_secrets). Without one, the environment's set, built once and cached. Old raw logs load unchanged and are never rewritten; only new lines are redacted.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This was referenced Nov 13, 2026
Closed
ajianaz
added a commit
that referenced
this pull request
Nov 13, 2026
…ssion log is redacted since #634 (#673) The rule that told the reviewer the durable log keeps the original text and not to flag missing redaction on durable log writes was wrong since #596 and #634 (the session log stores the redacted form): it is replaced by a rule that says so and asks the reviewer to flag any durable write (session log, ledger, usage record) that can carry a secret without going through the redaction. The subprocess rule's stale file name uteke_search.rs is now uteke.rs. The api_key rule (OpenAiConfig.api_key is filled from the environment) and the loop-guard rule (LOOP_TRIP_AFTER = 3) were re-verified against the code and are unchanged. Closes #668
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
#596. The session JSONL stores the redacted form. Every entry payload, and the pinned system prompt, is redacted with the process
SecretSetbefore its line is written. An entry that hid a secret names it, as"redacted": ["NAME"](names only). A replay from the log reproduces the provider's view exactly. Old raw logs load unchanged.Why
Owner decision 2026-11-11 (
docs/secrets-integrations-design.md§5, §8.1). Logs get exported, summarized into memory and shared, so a secret read once persisted in them. This reverses E11's "the durable log keeps the original".Changes
tole-core/src/storage.rs, at theStorageseam:JsonlStorage::commitredacts eachNewEntrypayload withSecretSet::redact_valuebefore encoding the line. That redacts every string and object key, in every form the set knows: as is, JSON-escaped, base64 and percent-encoded. A secret that is a bare JSON number becomes the marker string.Entryis the same redacted form, so memory equals disk.Record::Entry.redacted, with#[serde(default, skip_serializing_if = "Vec::is_empty")]. They are kept per entry id, socompact()writes them back.create_*redacts the pinned system prompt in the header.JsonlStorage::set_secretssets a per-storage redaction set, for tests and embedders.tole-core/src/secrets.rs:set_process_secrets/process_secrets.SecretSet::from_env()is built once, cached in aOnceLock, and shared as anArcclone.--no-default-features.tole-cli/src/provider_chain.rs:buildinstallslog_secrets: the process set plus each provider's key and base-URL password (primary and reserve), i.e. everything a provider request is redacted with.openai::provider_secretsis now public for this./exportparagraph;/export, memory loop, residuals).Replay exactness: verified, no divergent path found.
compaction::view(s.entries()), which is the in-memory, redacted entries.log_secrets), so nothing logged redacted was sent raw, and nothing sent redacted is logged raw.Streaming: text deltas only feed the live display. The log gets the assembled assistant message as one entry, so a value split across two chunks is whole there and gets redacted. No partial assistant text is ever committed.
Testing
All run locally on 8dd59e2 (develop e76d90e), with
CARGO_TARGET_DIRset andCARGO_INCREMENTAL=0.cargo test --workspace --no-fail-fastpasses: 1571 passed, 0 failed (85 suites), on the final head./tmpdirs left by a previous run whose pid was reused ("File exists", another test'suser.toml), not from this change.cargo test -p tole-clithen passed (700) and the final full run is clean.cargo test -p tole-core --no-default-featurespasses: 551 passed;cargo check -p tole-core --no-default-features --testspasses.cargo test -p tole-cli --no-default-featurespasses: 464 passed. With--features shell-toolsadded: 627 passed.cargo fmt --all -- --checkpasses.cargo clippy -D warningspasses for--workspace --all-targets,-p tole-core --no-default-features --all-targets,-p tole-cli --no-default-featuresand-p tole-cli --no-default-features --features shell-tools.cora review --no-llm --staged: "No issues found".New tests in
crates/tole-core/tests/redacted_log.rs. The secrets3cr3t/v"al+0596makes every encoded form differ.no_form_of_a_secret_reaches_the_log_and_each_entry_names_what_it_hid:redacted: ["TOLE_T596_TOKEN"], and a clean entry has no field.replay_from_the_log_reproduces_the_provider_view_exactly:an_old_raw_log_loads_unchanged_and_only_new_lines_are_redacted:a_secret_split_across_streamed_chunks_is_redacted_in_the_committed_message.a_whole_turn_logs_only_redacted_text_and_feeds_the_provider_the_same: throughrun_turn, the tool ran with the model's raw arguments, while the log and every transcript the provider was handed hold no form of the secret.the_pinned_system_prompt_is_stored_redacted.provider_chain::tests::the_log_redacts_every_secret_the_providers_are_shown_redacted: both providers' keys and URL passwords are in the log set.Red/green: each rule was broken on purpose, the named test failed, and it passed again once restored. All 7 breaks were caught:
redactedfield writtenDecisions to check
Resume::ReExecute) reads its arguments from the log, so it re-runs with the redacted form. The model only ever saw redacted text, so raw values in arguments should be rare.compact()keeps old raw lines raw. It rewrites entries verbatim (the audit log is never altered). For an old raw session, its raw lines stay raw after compaction. A fork of an old session is redacted, because it re-commits.set_process_secretsis called.tole exportdoes not exist. The TUI/exportrenders the in-memory entries, so a new session exports redacted, and an old session's raw lines export as they are.Size: 501 changed lines (489 added, 12 removed) across 8 files.
Related Issues
Closes #596 (secrets epic #594; follows #595, #631 and #632).
Checklist
feat/redacted-session-log)develop