Skip to content

fix(chat): key the display-redaction cache on the host set the battery judged under - #16544

Merged
NicholasRBowers merged 1 commit into
mainfrom
fix/display-redaction-host-snapshot-13482
Oct 22, 2026
Merged

NicholasRBowers merged 1 commit into
mainfrom
fix/display-redaction-host-snapshot-13482

Conversation

@NicholasRBowers

@NicholasRBowers NicholasRBowers commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A chat render never shows a link as [REDACTED], or in plaintext, because the display cache stored output judged under a different exempt-host set than the one its key names.

_redact_for_display (src/kiro_crew/dashboard/chat_utils_display.py) memoizes the display battery keyed on the text and the exempt-host set, but it reads that set twice: once in _display_redaction_cache_key (_exempt_exact_hosts() | current_scoped_exempt_hosts()) and again inside the battery (display_battery -> redact_exfiltration_urls -> _exfil_exempt_hosts()). The platform read can move between the two (a companion loads, a policy tightens) and degrades every failure to the empty set. A transient failure on the battery read alone stores maximally-redacted output under the full set key, and every later hit, including the persistent verdict store, serves [REDACTED] for an exempt host. The reverse order serves a plaintext link after the set empties.

Confirmed on main 17404da26: both regression tests below fail there.

Why it matters

The display cache fronts every chat render and now also feeds the persistent verdict store. One transient failure on one read poisons a hot entry, and the symptom (an exempted tenant link shown as [REDACTED]) reads as a policy bug. It is a cache-correctness race on a security-area path.

Not a goal

  • The pass-4 token-parameter prefix set (_token_param_exempt_prefixes) is also read by the key and again inside redact_credentials. Same class, different input; left for a follow-up so this diff stays on the host set named in chat: display-redaction cache reads the exempt-host set twice #13482.
  • _redacted_preview keeps its own key reads; it already re-checks the digest before filing an entry.
  • Any change to which hosts are exempt or which rules an exemption relaxes.

What changed (motivation → approach → change)

Root cause: two independent reads of a set that can move between them, feeding a key and a battery that must agree. Change: ONE snapshot feeds both.

  • _redact_for_display reads _exempt_exact_hosts() | current_scoped_exempt_hosts() once (the exact expression the key digested before, so every key and stored verdict tag is byte-identical to main) and hands it to _display_redaction_cache_key(text, base, hosts) and to display_battery(text, exempt_hosts=hosts).
  • _display_redaction_cache_key gains an optional third positional exempt_hosts; None reads the set as before (used by wire_render._context_digest and _redacted_preview).
  • display_battery, redact_exfiltration_urls and redact_exfiltration_urls_with_records gain an optional keyword exempt_hosts. When supplied it replaces the live platform read and the scoped override; hosts are lowercased either way (RFC 4343); extra_exempt_hosts joins either way. None, the default for every other caller, is the live read.

No redaction rule is widened or narrowed: the set the battery judges under is the same set it would read itself, read once instead of twice. display_battery.py and exfil.py are rule sources, so the rules version moves once and stored verdicts are recomputed once.

This is a port of the original change onto the chat_utils_display / display_battery owner modules that landed after this PR was opened.

Backwards compatibility

Compatible: only optional parameters with defaults that keep the live read. Nothing is removed or renamed. Keys are byte-identical to main for the same host set.

Tests

New test/test_display_redaction_host_snapshot.py (9 tests):

  • test_an_entry_is_keyed_on_the_set_the_battery_judged_under: first read ALLOWED, later reads empty, then settles at ALLOWED; the warm render must equal the battery output under ALLOWED. RED on main, green here.
  • test_a_tightened_set_mid_call_never_serves_plaintext: the reverse order; RED on main (served plaintext), green here.
  • test_the_host_set_is_read_exactly_once_per_call: 1 read cold, 1 read warm (red on main).
  • test_the_key_digests_the_snapshot_it_is_handed: key takes no live read when handed a snapshot, and equals the default-read key for the same set.
  • test_the_snapshot_carries_the_scoped_override, test_the_battery_takes_the_snapshot_and_performs_no_live_read, test_the_snapshot_is_lowercased_like_the_live_set, test_extra_exempt_hosts_still_joins_a_snapshot, test_the_default_path_still_reads_live.

Adjusted: wrappers in test_chat_utils.py, test_display_verdicts.py and test/perf/slot_render_bench.py forward the new argument. test_display_redaction_source_guard.py counts reads through both bindings and pins exactly one per call. test_security_gate_liveness.py re-pins _PACKAGE_LINE_BUDGET 31,509 -> 31,523 with the reason beside it.

Determinism: the new file passed 5 repeats, a shuffled order (seed 7) and -n 4.

Runs: the 10 directly related files 171 passed. scripts/run_scoped_tests.py --surface backend: 8585 passed, 12 failed; the same 12 (test_cli.py::TestDoctor*, one test_auto_improvement_members, one test_sel_chain_hardening) fail identically on main in this sandbox (environment: scratch path under ~/.kiro/crew, no gateway). black, isort, flake8, mypy (3 source files), check_comment_history.py, check_file_line_cap.py clean.

Manual verification

N/A — unit coverage sufficient: backend-only change with no user-visible dashboard state; the race is pinned by the unit tests above.

Screenshots / video

N/A — no user-visible frontend surface is touched.

Related Issues

Closes #13482

Pattern harvest

Rule candidate: review-prompt
Pattern: a memo keyed on mutable state read by the key function AND re-read by the memoized function; the two reads can disagree, so pass the key snapshot into the function.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

N/A — placeholder pending OSPO wording.

@NicholasRBowers
NicholasRBowers requested a review from a team as a code owner October 3, 2026 16:04
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 3, 2026
@NicholasRBowers
NicholasRBowers enabled auto-merge (squash) October 3, 2026 16:04
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 51adf3bc1322a3ff5dacf318b5465dc385bef54a — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the key and the battery now judge under a single read of the host set, so a cached entry always matches the set its key names.

Notes

  • A snapshot now lowercases the scoped-override hosts too, which the old battery read did not. If an override ever holds a mixed-case host, that host now gets exempted. It is a small rule change that the description's "No redaction rule is widened" does not mention.

[DESIGN-REVIEWED] 51adf3b

Description read

[DESCRIPTION-READ] 9cb89829787978e541ac9eef49c69a081235926bf2297d1f6525301d9ce392f9

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 51adf3bc1322a3ff5dacf318b5465dc385bef54a — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The fix reads the host set once and passes that one copy to both the cache key and the battery. That removes the gap between two reads, which is what let the cache store output under the wrong key.

Inventory (6 items) — 6 justified

Intent: stop chat renders from showing an exempt link as [REDACTED], or a non-exempt link in plaintext, because the cache stored output judged under a different host set than its key names. FIX (#13482; two tests fail on base).

  1. A chat render reads the exempt-host set once per call; that copy feeds both the cache key and the battery — justified
  2. _display_redaction_cache_key takes an optional host set (exempt_hosts) instead of reading it itself; 1 consumer, other callers keep the live read — justified
  3. display_battery gains an optional exempt_hosts keyword (1 consumer: chat_utils_display.py:512) — justified
  4. redact_exfiltration_urls and ..._with_records take the host-set copy in place of the live read and the scoped override (consumer chain display_battery.py:65 → exfil.py:894) — justified
  5. The rules version moves once, so stored display verdicts are recomputed once (declared) — justified
  6. _PACKAGE_LINE_BUDGET raised by 14 lines, with the reason written beside it — justified

[FIRST-PRINCIPLES-REVIEWED] 51adf3b

Description read

[DESCRIPTION-READ] b93ead29a71776bf4ba93e38131bc5dce9a3f194cb0ec2e83b1d4761f0fb9bb9

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 51adf3bc1322a3ff5dacf318b5465dc385bef54a — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 51adf3b

Verdict parsed from the review's SHA-scoped output markers for commit 51adf3bc1322a3ff5dacf318b5465dc385bef54a.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 51adf3bc1322a3ff5dacf318b5465dc385bef54a: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- ✅ PASS

Which legitimate operations does 51adf3bc1322a3ff5dacf318b5465dc385bef54a newly refuse? Updated in place on each push. A script-confirmed regression blocks; the model proposes candidates and never decides a refusal.

Verdict basis: adjudicated, zero confirmed regressions.

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 7 classified, 0 newly refused, 7 still allowed.
  • ubuntu-latest (platform posix): 7 classified, 0 newly refused, 7 still allowed.
  • windows-latest (platform windows): 6 classified, 0 newly refused, 6 still allowed.

No candidate flipped from allowed to refused.

Scope-Verdict: PASS

Reason: Nothing in this change makes a refusal stricter. It is a consistency fix in the dashboard's display-redaction cache: the exempt-host set is now read once, and that one copy is used both for the cache key and by the redaction pass that produces the cached output. The live-read default path in redact_exfiltration_urls_with_records gives the same set as before. The only new caller passing exempt_hosts is the display path, so the shell deny tiers have no new matching surface. The display-side guard cannot be classified and is named under UNADJUDICATED.

TIGHTENING: the display redaction pass's exempt-host input (exfil.redact_exfiltration_urls_with_records, reached through display_battery and _redact_for_display) -- the threat is a host set that changes between two reads and stores output computed under one set under another set's cache key. That can serve [REDACTED] for an exempt host, or plaintext after the set has tightened: "+ hosts = _exempt_exact_hosts() | current_scoped_exempt_hosts() / + key, input_bytes = _display_redaction_cache_key(text, base, hosts) … + redacted = display_battery(text, exempt_hosts=hosts)", and in exfil.py "+ if exempt_hosts is None: / + exempt_hosts = _exfil_exempt_hosts() | _SCOPED_EXEMPT_HOSTS.get() / + else: / + exempt_hosts = frozenset(h.lower() for h in exempt_hosts)". The copy passed in is lowercased just as the live read is, so exempt-host matching ignores case either way.

ADJUDICATED: 10 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE: The diff assumes nothing new about paths, separators, interpreters, executable names or environment variables. It only adds a keyword argument and a lowercasing step to a set of hostnames. I still wrote rows in three spellings to cover the exfil tier near the edited function:

  • posix: curl with single-quoted URLs, the .venv/bin/python / env -u pytest form.
  • windows: curl.exe with double-quoted URLs, .venv\Scripts\python.exe with \ test paths.
  • any: kirocrew manifest --url, gh api, git grep.

No platform assumption in the diff is left without a candidate.

UNADJUDICATED: The guard is the display redaction pass's exempt-host decision, not the shell deny composite. The call path: dashboard render → chat_utils_display._redact_for_display(text) → one read of _exempt_exact_hosts() | current_scoped_exempt_hosts() → _display_redaction_cache_key(text, base, hosts) and display_battery(text, exempt_hosts=hosts) → redact_exfiltration_urls(text, exempt_hosts=hosts) → redact_exfiltration_urls_with_records, which replaces both the live platform read and the _SCOPED_EXEMPT_HOSTS override with the passed-in set. The classifier cannot check display text. The inputs I would have submitted, all expected to stay unredacted:

  • A mixed-case exempt tenant link such as https://Contoso.SharePoint.com/sites/x/doc.docx?id=<250 chars>, rendered with the companion exempting contoso.sharepoint.com.
  • The same link rendered inside a scoped_exempt_hosts({...}) block, which tests whether the scoped override still reaches the pass when it comes in through the single read.
  • A link on a host allowed per workspace through security.redaction_allow (extra_exempt_hosts), which still joins the passed-in set.
  • The kirocrew manifest --url Slack deep link in a chat turn.

Reading the code, I found no path where a legitimate link is newly redacted. The values that previously came from two separate reads now come from one. But this is reasoning, not a verdict.

[SCOPE-REVIEWED] 51adf3b

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 51adf3bc1322a3ff5dacf318b5465dc385bef54a and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 51adf3b

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 51adf3bc1322a3ff5dacf318b5465dc385bef54a: <one-sentence reason>

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 3, 2026
@NicholasRBowers

NicholasRBowers commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Review dispositions (updated in place)

Security Scope Review — CONCERNS (advisory, exit 0) on 53a5478240e31f0b5675d2e6c9e41258df92ec75. The classifier found no newly-refused candidate (10/10/9 still allowed) and listed four display-side inputs it cannot express as a shell line. Each is pinned by a test already in this diff or on main, so the disposition is "covered, no change":

  1. Mixed-case companion host (Contoso.SharePoint.com) with a long ?id= query, no scope → stays plaintext. test_the_snapshot_is_lowercased_like_the_live_set (a mixed-case snapshot member matches the lowercase URL host). On the KEY: main digests _exempt_exact_hosts() (verbatim case) | current_scoped_exempt_hosts(); this head digests _exfil_exempt_hosts() (lowercased). The battery judged on the lowercased set in both versions, so two companion lists differing only in case produced identical output under different keys before and share one key now — one cold cache on upgrade, no changed verdict per host.
  2. Same link inside a workspace whose reader allow-list exempts the host → stays plaintext; the snapshot already includes current_scoped_exempt_hosts(). test_the_snapshot_carries_the_scoped_override (kept inside the scope, redacted outside, entries == 2) and test_redaction_allow.py::test_prepare_messages_relaxes_the_slot_workspace_hosts on the _prepare_messages path.
  3. One row holding an exempted tenant link and a non-exempt long-query link → only the second redacted. The per-URL verdict is _exfil_url_warning(domain, ..., exempt_hosts) evaluated per _URL_RE match — untouched by this diff; the snapshot only changes which read supplies exempt_hosts. Mixed-host rows are pinned on main by test_redaction_blocked_links.py::TestCollectorRecordsMatchRedaction::test_one_record_per_redacted_url_in_order; the exempt-vs-not split per host by test_redaction_allow.py::test_an_allowed_host_is_neither_redacted_nor_reported.
  4. The Slack app-create manifest deep link → still displays. Its carve-out (_kirocrew_slack_app_link_alias) runs inside _exfil_url_warning and reads no host set; this diff does not touch that function.

Also covered from the previous head's list: default-path callers passing no snapshot (test_the_default_path_still_reads_live: live read plus scope; extra_exempt_hosts joins either way).

No redaction rule moved; the diff changes which READ feeds the battery, not what the battery does with it.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running labels Oct 3, 2026
@iamwhatever
iamwhatever force-pushed the fix/display-redaction-host-snapshot-13482 branch from 53a5478 to c1a8564 Compare October 20, 2026 02:51
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 20, 2026
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security/exfil.py

  • @KiroCrewCaptain: missing the ## Sensitive change review heading

How to clear this check:

  1. The PR author posts the template below as a PR comment, with
    every field filled (N/A needs a reason). Keep the
    Head commit line: it must name the current head SHA.
  2. The check turns green within a minute, with no push.
  3. A new push resets this check: post it again for the new head.

Only the author's comment counts this way. A reviewer can instead
paste the filled template into an "Approve" review on this head.
Merging still needs a reviewer's approval.

## Sensitive change review
- Head commit: 51adf3bc1322a3ff5dacf318b5465dc385bef54a
- What rule changed:
- Before -> after (what was allowed/blocked, now):
- Worst case if wrong (breaks commands / leaks secret / locks user out):
- Evidence checked (which sandbox result proves it):
- No regression:
  - Tools still work (which tools/commands were run, result):
  - Backward compatible (old config / old data / old callers still work, how checked):
  - Existing tests (which suites passed on this head):
- How to undo:

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 51adf3bc1322a3ff5dacf318b5465dc385bef54a touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@iamwhatever

Copy link
Copy Markdown
Contributor

Sensitive change review

  • Head commit: e997be3
  • What rule changed: no redaction rule changed. redact_exfiltration_urls and redact_exfiltration_urls_with_records gain an optional exempt_hosts snapshot that replaces the live platform read and the scoped override for one call. Only the display cache (_redact_for_display) passes it.
  • Before -> after (what was allowed/blocked, now): before, the display cache read the exempt-host set for its key and the battery read it again; if the two reads differed, the cache stored one set output under the other set key (exempt link shown [REDACTED], or a now-redacted link shown in plaintext until eviction). After, one read feeds both, so a cached entry always matches the set its key names. Every other caller keeps the live read (None default).
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a display render judged under a stale host set, i.e. the defect this fixes. No shell, file or network gate reads this code.
  • Evidence checked (which sandbox result proves it): Security Scope Review on c1a8564 (same tree): 0 newly refused on macOS, Ubuntu and Windows. test/test_display_redaction_host_snapshot.py: two regression tests red on main 17404da26, green here.
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool path calls the snapshot keyword; test_display_redaction_source_guard.py, test_exfil_facade.py, test_security_gate_liveness.py pass.
    • Backward compatible (old config / old data / old callers still work, how checked): optional keyword with a live-read default; cache keys are byte-identical to main (test_the_key_digests_the_snapshot_it_is_handed); test_the_default_path_still_reads_live.
    • Existing tests (which suites passed on this head): CI Backend Tests (3.12 and Windows) on c1a8564, same tree; locally run_scoped_tests.py --surface backend 8585 passed, 12 env failures that also fail on main.
  • How to undo: revert the single commit; no data or config migration.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 20, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Review dispositions for e997be3

  • target=first-principles head=e997be3c59b58b3e92a3214451016eb0a2c02994: token-parameter prefix double read — accepted-and-deferred

Same race class on a different input (_token_param_exempt_prefixes, read at chat_utils_display.py:346 and redaction.py:1158). Kept out so this diff stays on the host set named in #13482.
Follow-up: #22388, with a fix shape and an acceptance test.

  • target=design head=e997be3c59b58b3e92a3214451016eb0a2c02994: PASS, nothing to check — no action.
  • target=scope head=e997be3c59b58b3e92a3214451016eb0a2c02994: CONCERNS (advisory) — rebutted, covered

0 newly refused on macOS, Ubuntu and Windows. No shell, file or network tier reads redact_exfiltration_urls* or the exempt-host set; only _redact_for_display passes the snapshot.
Mixed-case tenant host: test_the_snapshot_is_lowercased_like_the_live_set. Scoped allow-list: test_the_snapshot_carries_the_scoped_override. Default callers: test_the_default_path_still_reads_live.

@github-actions github-actions Bot added the readiness: passed Eligible automated validation passed for the current revision label Oct 20, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD on e997be3. Two things stand: this touches the redaction path, which is reserved for human review, and one check is red.

The fix looks correct. _redact_for_display reads the exempt-host set once (L482) and hands the same snapshot to the key and to the battery (L512). In exfil.py the snapshot lowercases to exactly the set the live read produced, because scoped hosts are already stored lowercase, so no host becomes newly exempt. The deferred token-prefix race is covered by #22388.

To clear the hold:

  • Sensitive Change Review is red. The template on this head was posted by another account, and the check counts only the author's comment or a reviewer's Approve review carrying it. The author can repost it, or the human reviewer can include it in their approval.
  • Human review: a maintainer should review the exfil.py / display-battery change.
  • Please also link chat: display-redaction cache reads the token-parameter prefix set twice #22388 in the PR description, and give it an assignee.

— crew-pr-reviewer (r114)

@dodgeblaster dodgeblaster left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Steward review for #13482 (T1/T2 sweep). Verified the fix against current origin/main and read every changed file.

The bug is still live on main. _display_redaction_cache_key reads _exempt_exact_hosts() | current_scoped_exempt_hosts() for the key, and redact_exfiltration_urls_with_records re-reads _exfil_exempt_hosts() | _SCOPED_EXEMPT_HOSTS.get() independently — two reads of a set that can move (or degrade a failure to frozenset()) between them, so output computed under one set can be stored under another set's key.

The fix is correct and does not widen what is exempted.

  • _redact_for_display now takes ONE snapshot hosts = _exempt_exact_hosts() | current_scoped_exempt_hosts() and hands the SAME object to both _display_redaction_cache_key(text, base, hosts) and display_battery(text, exempt_hosts=hosts). Key and battery provably judge under the same set.
  • The new exempt_hosts keyword on redact_exfiltration_urls / _with_records replaces the live read rather than adding to it, and lowercases the snapshot (frozenset(h.lower() ...)) exactly as _exfil_exempt_hosts() does — so the snapshot path reproduces the live path's set element-for-element. extra_exempt_hosts still joins on top either way.
  • The default (exempt_hosts=None) branch is byte-identical to main: every other caller is untouched. Confirmed no redaction rule, threshold, or host carve-out is relaxed; the only change is that the two reads become one.
  • test/test_display_redaction_host_snapshot.py pins the contract both directions (a transient failure after the key read never serves [REDACTED] for an exempt host under the stable set; a tightened set after the key read never serves plaintext), asserts one read per call, and asserts a supplied snapshot suppresses the battery's live read.

CI: every required check is green on head e997be3c except Sensitive Change Review, which is red only because the sensitive-path reasoning template has not been posted for this head — not a code defect.

To merge, two things remain, both outside what a steward can do:

  1. @NicholasRBowers (author): post the filled ## Sensitive change review template as a PR comment naming head e997be3c59b58b3e92a3214451016eb0a2c02994 (or a reviewer folds it into an Approve review on this head). That clears the gate within ~a minute, no push needed.
  2. A human approving review (reviewDecision is REVIEW_REQUIRED).

I'm not approving or merging: the final approval and the security-gate template are the author's/maintainer's to supply, and this is a same-repo PR I did not author. Once (1) and (2) land with all checks green and no admin bypass, it's ready to squash-merge.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 21, 2026
@iamwhatever
iamwhatever force-pushed the fix/display-redaction-host-snapshot-13482 branch from e997be3 to 81b721a Compare October 22, 2026 01:20
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 22, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

@NicholasRBowers I rebased this onto latest main (it had conflicts) and force-pushed. The new head is 81b721aa1bae20daed9253e1ed933d49e8a7a09b. The only code change in the rebase: the security package line budget in test/test_security_gate_liveness.py is now 32,097 -> 32,111 (main raised it meanwhile; this PR still adds the same 14 lines). The bench conflict in test/perf/slot_render_bench.py took main's rewritten bench, which no longer patches _display_redaction_cache_key.

Sensitive Change Review counts only the author's comment or a reviewer's Approve review. Could you repost the filled form below as your own comment? Or a maintainer can paste it into an Approve review on this head. I am not posting it as an approval myself.

## Sensitive change review
- Head commit: 81b721aa1bae20daed9253e1ed933d49e8a7a09b
- What rule changed: no redaction rule changed. `redact_exfiltration_urls` and `redact_exfiltration_urls_with_records` gain an optional `exempt_hosts` snapshot that replaces the live platform read and the scoped override for one call. Only the display cache (`_redact_for_display`) passes it.
- Before -> after (what was allowed/blocked, now): before, the display cache read the exempt-host set for its key and the battery read it again; if the two reads differed, the cache stored one set output under the other set key (exempt link shown `[REDACTED]`, or a now-redacted link shown in plaintext until eviction). After, one read feeds both, so a cached entry always matches the set its key names. Every other caller keeps the live read (`None` default).
- Worst case if wrong (breaks commands / leaks secret / locks user out): a display render judged under a stale host set, i.e. the defect this fixes. No shell, file or network gate reads this code.
- Evidence checked (which sandbox result proves it): Security Scope Review on 81b721aa1: PASS, 0 newly refused on macOS, Ubuntu and Windows. `test/test_display_redaction_host_snapshot.py`: two regression tests red on main, green here.
- No regression:
  - Tools still work (which tools/commands were run, result): no tool path calls the snapshot keyword; `test_display_redaction_source_guard.py`, `test_display_verdicts.py`, `test_chat_utils.py`, `test_security_gate_liveness.py` pass on 81b721aa1 (locally, 102 passed).
  - Backward compatible (old config / old data / old callers still work, how checked): optional keyword with a live-read default; cache keys are byte-identical to main (`test_the_key_digests_the_snapshot_it_is_handed`); `test_the_default_path_still_reads_live`.
  - Existing tests (which suites passed on this head): Backend Lint & Type Check (3.12) and Security Scope Review pass on 81b721aa1; Backend Tests running in CI.
- How to undo: revert the single commit; no data or config migration.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running labels Oct 22, 2026
…y judged under

`_redact_for_display` read the exempt-host set twice: once in
`_display_redaction_cache_key` and again inside the battery
(`display_battery` -> `redact_exfiltration_urls` -> `_exfil_exempt_hosts`).
The platform read can move between the two (a companion loads, a policy
tightens) and degrades every failure to the empty set, so a transient failure
on the battery's read alone stored maximally-redacted output under the full
set's key, and every later hit served `[REDACTED]` for an exempt host. The
reverse order served a plaintext link after the set emptied.

One snapshot now feeds both: `_redact_for_display` reads
`_exempt_exact_hosts() | current_scoped_exempt_hosts()` once (the same
expression the key digested before, so every key is byte-identical), hands it
to `_display_redaction_cache_key(text, base, hosts)` and to
`display_battery(text, exempt_hosts=hosts)`. `redact_exfiltration_urls` and
`redact_exfiltration_urls_with_records` gain an optional `exempt_hosts`
keyword that replaces the live platform read and the scoped override;
`None`, the default for every other caller, is the live read.

Tests: regressions in both directions (red on main, green here), one read
per call, scoped-override composition, key and battery taking no live read
when handed a snapshot, lowercase matching, the additive set, and the
default path. Security package line budget re-pinned 32,097 -> 32,111.

Closes #13482

Co-authored-by: iamwhatever <iamwhatever@users.noreply.github.com>
@iamwhatever
iamwhatever force-pushed the fix/display-redaction-host-snapshot-13482 branch from 81b721a to 51adf3b Compare October 22, 2026 09:37
@iamwhatever

Copy link
Copy Markdown
Contributor

@NicholasRBowers I rebased this onto latest main again (one conflict) and force-pushed. New head: 51adf3bc1322a3ff5dacf318b5465dc385bef54a. The only change in the rebase: main raised the security package line budget to 32,111 meanwhile, so this PR now sets it to 32,125 (the same +14 lines as before) in test/test_security_gate_liveness.py.

Sensitive Change Review counts only the author's comment or a reviewer's Approve review. Could you repost the filled form below as your own comment? Or a maintainer can paste it into an Approve review on this head. I am not posting it as an approval myself.

## Sensitive change review
- Head commit: 51adf3bc1322a3ff5dacf318b5465dc385bef54a
- What rule changed: no redaction rule changed. `redact_exfiltration_urls` and `redact_exfiltration_urls_with_records` gain an optional `exempt_hosts` snapshot that replaces the live platform read and the scoped override for one call. Only the display cache (`_redact_for_display`) passes it.
- Before -> after (what was allowed/blocked, now): before, the display cache read the exempt-host set for its key and the battery read it again; if the two reads differed, the cache stored one set output under the other set key (exempt link shown `[REDACTED]`, or a now-redacted link shown in plaintext until eviction). After, one read feeds both, so a cached entry always matches the set its key names. Every other caller keeps the live read (`None` default).
- Worst case if wrong (breaks commands / leaks secret / locks user out): a display render judged under a stale host set, i.e. the defect this fixes. No shell, file or network gate reads this code.
- Evidence checked (which sandbox result proves it): Security Scope Review on 51adf3bc1 (see checks). `test/test_display_redaction_host_snapshot.py`: two regression tests red on main, green here.
- No regression:
  - Tools still work (which tools/commands were run, result): no tool path calls the snapshot keyword; `test_display_redaction_host_snapshot.py`, `test_display_redaction_source_guard.py`, `test_display_verdicts.py`, `test_chat_utils.py`, `test_security_gate_liveness.py`, `test_backend_cards_advertised.py` pass on 51adf3bc1 (locally, 110 passed).
  - Backward compatible (old config / old data / old callers still work, how checked): optional keyword with a live-read default; cache keys are byte-identical to main (`test_the_key_digests_the_snapshot_it_is_handed`); `test_the_default_path_still_reads_live`.
  - Existing tests (which suites passed on this head): see the CI checks on 51adf3bc1.
- How to undo: revert the single commit; no data or config migration.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Oct 22, 2026
@iamwhatever iamwhatever self-assigned this Oct 22, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review lanes PASS; the hold was advisory (a downgraded GPT 6.1 finding, a security-checklist item, or a missing reasoning template). The watch holder read the hold and approved explicitly.

@NicholasRBowers
NicholasRBowers merged commit 5994fd1 into main Oct 22, 2026
110 of 112 checks passed
@NicholasRBowers
NicholasRBowers deleted the fix/display-redaction-host-snapshot-13482 branch October 22, 2026 15:39
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chat: display-redaction cache reads the exempt-host set twice

5 participants