Skip to content

feat(autonudge): scrub loop text on every egress so a credential cannot reach a reader - #10967

Closed
rnoack1 wants to merge 1 commit into
kirodotdev:mainfrom
rnoack1:split/autonudge-egress-scrub
Closed

rnoack1 wants to merge 1 commit into
kirodotdev:mainfrom
rnoack1:split/autonudge-egress-scrub

Conversation

@rnoack1

@rnoack1 rnoack1 commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A credential typed into an auto-nudge loop's goal is no longer served back to the people reading that loop in the dashboard.

A loop's own message and banner were serialized verbatim to every dashboard client. A credential typed into a goal was therefore served back in full to every reader of that loop, on every read, for as long as the loop existed.

Why it matters

The goal field is exactly where a credential is most likely to be typed, because a goal often describes an operation against a real system. The serializer is the single point every reader passes through, so a gap there is a gap for all of them at once, not for one surface.

Not a goal

  • Refusing a credential-shaped id or slot_key at the load boundary. That refusal is what keeps the addressing exemption below safe, and it is already on this base in autonudge_service/store_loader.py — this diff has no hunks in that package and adds nothing to it.
  • The fingerprint gate's echo-projection coverage. The comparison itself (message_is_echoed_projection) is already on this base, and no test in the repository exercises it yet. That unit follows separately.
  • Any operator-facing surface for rows the loader holds back. The only in-product signal remains a startup warning naming the field, never the value.
  • Changing what the WebSocket frame or the reduced REST row contains. This changes how the existing fields are scrubbed, not which fields are served. Every frame main broadcasts is still broadcast. If the policy cannot compose, the frame's text fields carry the fixed placeholder [redaction unavailable] instead of raw text.
  • Any new refusal. No route, authorizer or admission check gains a 503 or an early refusal. The two 503s the save authorizer already had stay as they are; this diff does not touch autonudge_authz.py.

What changed (motivation → approach → change)

The symptom is one field reaching readers unscrubbed, but the root cause is that each reader of a loop assembled its own payload, so there was no single place a scrub could cover all of them. Three arms project a loop: the full REST serializer, the reducing arm for legacy readers, and the gateway's autonudge_state broadcast.

So the change is one per-field projection rule that all three call, rather than a scrub repeated at each caller — a second independent assembly would serve raw whatever the rule scrubs.

  • A loop's text fields, message and stopped_reason among them, are credential-scrubbed on the REST list, the per-loop detail, and the echoed POST/PATCH replies.
  • The ungated autonudge_state WebSocket broadcast applies that same rule rather than a second copy of it, so a field cannot end up scrubbed on one surface only.
  • The in-session monitor reading scrubs stopped_reason, which is agent-supplied free text on a route with no owner gate.
  • The fields a client uses to address a loop are exempt. A client keys on them, so a rewritten key would no longer match the row it names — the exemption is required for correctness, not a weakening of the scrub. goal_token is exempt for the same reason: it is random hex the popover sends back as expect_fingerprint, so a scrubbed token would refuse every save as a stale baseline. Today's tokens match no detector; the exemption keeps a future detector change from breaking saves silently. monitor is exempt too, because its nested state is already walked in place by the caller.
  • Editing part of a goal that holds a credential saves the redaction marker in place of the credential. The popover shows the scrubbed text, and only an unchanged echo of it is recognized and dropped (message_is_echoed_projection), so an edited one is stored as typed. The write path already redacts incoming text the same way on base (authorize_and_update_nudge), so this is the existing inbound behaviour, not a new loss.
  • Values are scrubbed shape-preservingly: numbers and booleans keep their types instead of being coerced to text, and dicts and lists are walked rather than flattened, so the typed judge readings keep the shape the popover parses.
  • The scrub goes through the existing redaction shim. On a host whose declared credential policy cannot compose, that shim raises. Every REST reader then serves [redaction unavailable] for each field it could not scrub (_project_field), so a list, slot read or a save that already committed answers 200, never 500, and serves no raw text. A policy broken at startup makes the loader refuse to arm any loop (store_loader.py), so this only bites a policy that breaks later. No route adds a probe or a 503 for it.
  • On that same host, the broadcast's scrub raises inside the gateway observer, ahead of the per-member event-log append that follows it. That append — not the live loop — is what the Crew Members drawer reads for a patrol's stop reason across a restart, so letting the error propagate would skip it and reconcile_members_at_startup would close the log as interrupted, replacing a real reason permanently. The scrub is therefore guarded there. The frame is still broadcast, so a policy failure costs no event and no conductor-board refresh, but every field the scrub could not reach is replaced with [redaction unavailable] first (_withhold_serialized_field). The exempt fields, numbers, booleans and null pass unchanged, so the frame still addresses its row.
  • The handler's existing "AutoNudge monitor responses" redaction sink in the security posture is widened to cover the loop's text fields, the four exemptions and the broadcast, rather than adding a second row for the same module.

Backwards compatibility

Compatible: no field is removed, renamed or newly rejected. Addressing fields still round-trip verbatim, numeric and container shapes are preserved, and ordinary text is unchanged because the redaction is shape-based and idempotent. No status code changes on a host whose credential policy composes.

Removes nothing: the diff adds a scrub and no refusal; no field, key, route or public function is hidden, deleted, tightened or migrated.

Tests

25 tests in test/test_autonudge_egress.py and two in test/test_slack_gateway_coverage_nudge_routing.py, all passing, grouped by what each locks in:

  • The REST projection scrubs loop text — a credential in message and in stopped_reason does not reach the client; the addressing fields survive verbatim; ordinary text round-trips unchanged. Includes a positive control that the redactor really rewrites the value used, so a passing assertion cannot be vacuous.
  • goal_token survives verbatim — a token shaped like a credential is served unchanged, while the same value in message is redacted as the control.
  • The scrub preserves shape — numeric fields are not rendered as text, judge and judge_last_verdict keep their object shape, and a credential nested inside judge is still scrubbed.
  • The other two surfaces use the same rule — the in-session reading scrubs stopped_reason, and a nested key that merely shares an addressing field's name is not exempted.
  • The scrub adds no refusal — on a host that cannot compose its policy, the list and slot routes answer 200 both empty and with a loop, a committed save answers 200, every reader serves the placeholder and no secret, an arm is not refused, a stop and a pause still run, and the save authorizer's existing 503 still answers.
  • An unscrubbable host still records the patrol transition — the broadcast's scrub is guarded, the guard catches the error a host that cannot compose its policy raises, it does not hand that error onward, and it sits ahead of the append it protects. Pinned on the source, as the repository's existing append-ordering tests pin the same invariant.
  • The broadcast frame is scrubbed — driving the real observer, a credential in message and stopped_reason does not reach the frame, while a credential-shaped id and slot_key pass verbatim. With redaction raising, the frame is still sent, message and stopped_reason carry the placeholder, no raw secret appears, and id, slot_key and a number pass unchanged.
  • The surfaces are registered in the posture — the handler is a declared sink, and its text names the broadcast it also covers.

Each bound was mutation-tested: removing the _serialize scrub or the goal_token exemption, re-adding a policy probe to the list route, the slot route or the arm path reddens a test. So does making the REST fallback re-raise, using the bare scrub in _serialize, the reduced row or the in-session reading, or letting the placeholder pass raw text (5/5 caught). Restoring the pre-fix raw send, letting the placeholder replace id/slot_key or a number, dropping the frame, or discarding the scrub result reddens the observer tests (5/5 caught).

The 8,272-test autonudge / nudge-wiring / nudge-routing / security-posture / monitor / event-log / patrol / composition / app-decoupling selection passes with 0 failures. black, isort and flake8 clean on every file touched; Semgrep with CI's rule packs reports no findings.

Manual verification

N/A — the surfaces under change are HTTP responses and one WebSocket frame, and the tests assert on the served payloads directly, including the shape the dashboard popover parses.

Related Issues

One unit of a split of #7996.

Scope

One unit of a split of #7996, which is 9.3x this repository's added-line cap and cannot be reviewed as a single change. This unit is the egress scrub alone, with no new refusal, and can merge on its own. The load-boundary refusal that keeps the addressing exemption safe is already on this base; the fingerprint gate that builds on this scrub follows separately, as does any operator-facing surface for held-back rows.

@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Sep 15, 2026
@dwu96

dwu96 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@rnoack1
rnoack1 marked this pull request as ready for review September 15, 2026 05:00
@rnoack1
rnoack1 requested review from a team and pepmach September 15, 2026 05:00
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 15, 2026
@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 89ddaf93281a52b763bb40c463f2635801af0848 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: one shared per-field rule covers all three ways a loop is served, takes nothing away, and fails closed with a placeholder instead of a 500 or a skipped event-log append.

Notes

  • The broadcast in nudge_wiring.py repeats _project_field's try/except inline, only to add a log line. Giving _project_field an optional warn hook would leave one fallback path to keep in sync.

[DESIGN-REVIEWED] 89ddaf9

Description read

[DESCRIPTION-READ] ef3f7df15fbfe45f0cd5cabc6bb29d05a836451a634fe7687e832e99c227e12f

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 Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 89ddaf93281a52b763bb40c463f2635801af0848 via the fork AI-review pipeline — 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

The fix aims at the cause: three readers now share one per-field rule, which the base already expected. The two notes below are second spellings that can be deleted.

Notes

  • Item 5 — duplicate of _project_field (added in this same diff): the broadcast's own try: … _scrub_serialized_field … except PlatformCompositionError: … _withhold_serialized_field repeats that function's try/except a second time. Subtraction: call _project_field(_key, _value) per field in nudge_wiring.py, and drop the _scrub_serialized_field/_withhold_serialized_field re-exports from slack/gateway.py and the TYPE_CHECKING block.
  • Item 4 — second spelling of LOG_WITHHELD_PLACEHOLDER (platform/context.py:1268, "<withheld: redaction unavailable>"): REDACTION_UNAVAILABLE_PLACEHOLDER = "[redaction unavailable]" is a new constant for the same withheld-text marker. Subtraction: reuse the existing constant and delete the new one.

What this change ships

Inventory (6 items) — 4 justified

Intent: stop a credential typed into an auto-nudge goal from being served back to dashboard readers. This is a FIX.

  1. Loop text (message, stopped_reason, banner, judge) is scrubbed on the REST list, the detail view and the save replies — justified
  2. The reduced legacy row and the in-session reading scrub stopped_reason — justified
  3. id, slot_key, goal_token and monitor pass through unscrubbed — justified
  4. When the policy cannot compose, REST fields serve [redaction unavailable] — duplicate of platform/context.py LOG_WITHHELD_PLACEHOLDER
  5. The autonudge_state broadcast is scrubbed; on failure its text is withheld, with a warning logged — duplicate of _project_field's try/except
  6. The posture sink description is widened to name these surfaces — justified

[FIRST-PRINCIPLES-REVIEWED] 89ddaf9

Description read

[DESCRIPTION-READ] 4a4ab62091c388d8beb5819923dbb8dfeb37d2918d140e4816821a3ada514e58

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 commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 89ddaf93281a52b763bb40c463f2635801af0848 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 89ddaf9

@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 89ddaf93281a52b763bb40c463f2635801af0848 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 89ddaf9

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 18, 2026
@rnoack1
rnoack1 force-pushed the split/autonudge-egress-scrub branch from 74cac05 to fcaad72 Compare September 18, 2026 12:01
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 18, 2026
@rnoack1
rnoack1 force-pushed the split/autonudge-egress-scrub branch from fcaad72 to fd4eaad Compare September 18, 2026 13:16
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 18, 2026
@rnoack1
rnoack1 force-pushed the split/autonudge-egress-scrub branch from fd4eaad to 54fa678 Compare September 18, 2026 14:01
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 18, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running 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 Sep 19, 2026
@NicholasRBowers NicholasRBowers added needs-pr-triage PR scanner: awaiting automated triage needs-author-decision PR blocked on author input and removed needs-pr-triage PR scanner: awaiting automated triage labels Sep 23, 2026
@NicholasRBowers

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew [operator: NicholasRBowers#a942f9ca]: This PR has been inactive for 7+ days. I reviewed the blockers but they require your input:

Your own later split PRs landed most of this on main first, in a different shape — so the first decision is close-as-superseded vs narrow-to-a-delta.

What is still genuinely unique, if you narrow: the REST-egress denylist scrub. main's dashboard/handlers/autonudge.py::_serialize scrubs only the monitor sub-object via _redact_monitor_value; this PR's version scrubs every field except ADDRESSING_FIELDS, so a free-text field added to NudgeLoop later is covered without its own scrub. I verified that on main today — nothing has superseded it.

Decision 1 — where do refused rows live? This is a policy choice I cannot make, because the two sides contradict each other. main (#11154) holds a refused row in a separate quarantine sidecar and pins the reason in a comment: "The sidecar is the SINGLE durable location. Held-aside rows are deliberately not embedded in the store too -- two copies of one state can disagree." This PR does the opposite: it keeps them in memory as self._refused_rows and writes them back into the main store on every persist ("loops": [...] + self._refused_rows). Resolving the conflict means ruling which one ships — either dropping this half, or reversing a decision already merged.

Decision 2 — the one blocking review finding sits on exactly that superseded half. GPT 5.6 is 🔴 blocking on the current head d96dda2af at src/kiro_crew/autonudge.py:1369 (self._refused_rows.append(raw)): a large agent-written field is retained for the process lifetime, so its fix hint is "bound row count and every retained value before appending". Note its adjudication stage failed to run, so no proportionality review took place and the verdict stands unreviewed. If you narrow to the REST scrub, this finding disappears with the code; if you keep the store half, it needs the bound and an argument against main's sidecar. Which way you go changes what the diff should contain, so I have deliberately not resolved anything.

Mechanical once you have ruled — none of this is a reason to hold:

  • The conflict is one file, src/kiro_crew/autonudge.py, 4 hunks (verified by trial merge against current main; security_posture.py and slack/gateway.py auto-merge clean). Two are trivial: an import-block union (keep main's redact_log_via_context alongside redact_via_context) and _store_payload, where main refactored to self._serialized_loops() while this PR appends + self._refused_rows. The other two are the constants block and the _load reset block, which is where the two designs actually disagree.
  • Opus 4.8 Review reads 🔴 only because it failed closed — its check output is "review incomplete" and its comment still stamps the older head 6923f979c. Design Review CONCERNS and First Principles PASS are also stamped on that older head. A new head restamps all three; there is nothing to fix for them.
  • Every other check passes (89 total, 3 failing: GPT, Opus, PR Readiness).
  • 0 unresolved review threads.
  • PR Readiness also notes the body references an issue with no closing keyword — add Fixes #<n> or state no linked issue: <why>. Advisory only.
  • The branch is 669 commits behind main.

When you've addressed these, the pipeline will re-assess on its next cycle.

Copy link
Copy Markdown
Contributor

PR triage (2026-10-05): PARTIALLY_COVERED by main. Needs a rebase and a narrower scope. Keep open; do not close.

I checked head d96dda2a against origin/main cc7e7989. The branch is 2,532 commits behind main. git merge-tree reports conflicts in 4 files: autonudge.py, dashboard/handlers/autonudge.py, security_posture.py and slack/gateway.py.

Already on main. Drop these from the diff:

Still missing on main. This is the delta worth keeping:

  • REST egress scrub. dashboard/handlers/autonudge.py::_serialize on main only redacts monitor. message, banner and stopped_reason are served exactly as stored. Both _serialize_for_legacy_reader and _autonudge_loop_reading ("stopped_reason": loop.stopped_reason, line 348) return raw values.
  • WebSocket egress. The autonudge_state broadcast in slack/gateway.py:7728/7742 sends loop.message and loop.stopped_reason unscrubbed.
  • The expect_fingerprint pass-through in api_autonudge_update. main's PATCH handler (around line 1082) still does not forward it.
  • The 503-instead-of-500 handling when the scrub policy cannot compose.

Note: the comment above main's ADDRESSING_FIELDS already says "the REST scrub exempts them", but that REST scrub does not exist on main yet.

Rebase hazard (the API would break if this is missed): since this PR's base, main has added the dict/list fields judge, judge_last_verdict and judge_recent_verdicts to NudgeLoop. _serialize pops judge_recent_verdicts, but judge and judge_last_verdict still reach the client. The denylist scrub exempts only ADDRESSING_FIELDS, monitor and the numeric fields, and scrub_loop_text turns any other non-string into str(value). So after a straight rebase, judge and judge_last_verdict would reach clients as strings. website/src/components/autoNudgeLoop.ts:202-205 (loop?.judge?.wake_when, loop?.judge_last_verdict) and SessionAutomationPopover.tsx:138-140 read them as objects, so the goal popover's judge reading would quietly stop working. When rebasing, scrub dict and list values recursively, the way _redact_monitor_value already does, instead of converting them to text. Also add a test that judge and judge_last_verdict keep their object shape.

Related open PR: #11027 (popover redaction UI) is complementary, not a duplicate. Its redaction notice works from the served text, and this PR's egress scrub is the server half that would supply it. The two should be sequenced together.

Recommendation: rebase onto main, narrow the PR to the REST + WS egress scrub plus the expect_fingerprint pass-through, drop _refused_rows/_refuse_if_reserved in favour of #11154's sidecar, and fix the dict-field coercion described above.

@rnoack1
rnoack1 force-pushed the split/autonudge-egress-scrub branch from d96dda2 to eb6c5a8 Compare October 19, 2026 16:08
@rnoack1
rnoack1 requested review from a team and KiroCrewCaptain as code owners October 19, 2026 16:08
@rnoack1
rnoack1 requested a review from buluoray October 19, 2026 16:08
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 19, 2026
@rnoack1

rnoack1 commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

Requesting a maintainer carry-forward, which is what the Sensitive Change Review gate itself prescribes. The narrowing you both asked for is done and pushed; the remaining blocker is structural and I cannot clear it from a fork.

The narrowing is complete

Head eb6c5a844d, now MERGEABLE (it was CONFLICTING). 497 added lines, down from 1500, across 6 files.

Following bolichen97's triage and NicholasRBowers' earlier note, I rebuilt this on current main rather than resolving the old conflict, because the conflicting code was my own work that had already landed:

The dict-coercion hazard bolichen97 flagged is fixed and pinned. judge and judge_last_verdict are walked recursively rather than coerced with str(), so the popover's judge reading keeps the object shape it parses. Each guard was mutation-tested separately (7 mutations, 7 caught, 0 survived); that run is also what found an uncovered branch, where a save touching only a cadence field reached neither existing 503 arm.

Why I am asking rather than pushing again

Sensitive Change Review fails on exactly one file, src/kiro_crew/security_posture.py, matched by exact name in SENSITIVE_GLOBS. Its output says a fork PR cannot pass, and prescribes a maintainer taking it over on a branch of this repository with Co-authored-by: and Supersedes #<n>.

I confirmed that is not a soft refusal: sensitive-change-review-comment.yml gives the author a way to clear the gate by comment, and it returns early for forks with "Fork PR: Sensitive Change Review refuses forks, so a comment cannot clear it." So there is no action available to me here.

That one file is 19 lines of additive sink documentation, and dashboard/handlers/autonudge.py is already a declared sink, so dropping it would make the gate inapplicable and every omission test still passes. I deliberately did not do that. This change alters what reaches every dashboard client, so the gate is right to treat it as sensitive, and removing only the file that declares the change while keeping the code would be evading a correct judgement.

Three failures are not from this PR

Harness Parity Gate fails with:

x-capture gate: a non-standard capability set must cite, above the set, a live capture
under test/fixtures/acp_frames/<backend>/ that a test replays.
  ACP_BACKENDS_MEMBER_CAPABILITIES [claude]: allowlisted but now proven; delete the entry

Running your own scripts/check_harness_parity.py reproduces this identically on unmodified main, both at my branch point afed43d2c0 and at the current tip 88914fd0d1. This PR touches no ACP, capability or fixture file. The fix appears to be deleting that now-proven allowlist entry.

It also cascades, so it is worth fixing for everyone: Harness Parity Gate runs inside the Fast Gate run, Await Fast Gate then fails closed after 726s saying "This is not a verdict on the code", every test job in the dependent run reads skipped, and Coverage Gate fails closed on frontend-test=skipped. No test and no AI review ran on this head at all — the fork review lanes fire on Fast Gate's workflow_run.

Two failures I can fix on request

Fork PR Description and PR Hygiene both fail because the PR template gained ## Not a goal and a **Goal:** line between this PR's original base and current main. The description was template-compliant before the rebase and is now also factually stale, since it still describes the dropped _refused_rows mechanism.

I have a corrected description ready that passes .github/scripts/pr-description-check.sh locally. I have not applied it, because code-review.yml fires on edited with cancel-in-progress: true and I did not want to cancel in-flight runs or spend review capacity without being asked. Say the word and I will save it, or fold it into the carry-forward branch.

Happy to split the security_posture.py documentation into a separate same-repo change if that is easier than carrying the whole thing.

@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision c6b11ec535b769981b761e4f9c089ea1cad3caa5 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

HOLD (policy: human review required) at 5206072.

This PR changes what is redacted on every auto-nudge egress through one shared rule (handlers/autonudge.py#L134) and declares a new redaction sink (security_posture_sinks_gateway.py#L514). Credential-redaction changes are reserved for a human reviewer, and Sensitive Change Review fails on this fork head, so a maintainer has to carry it forward as the author asks. I found no defect in the scrub itself: addressing fields stay verbatim, dicts and lists are walked, and writes that echo the loop refuse before mutating.

Unanswered on this head, please reply to each:

  • Design: a partial edit of a goal holding a credential stores the redaction marker. Inbound redaction already does this on write (autonudge_authz.py#L891), so a one-line note in the description would settle it.
  • Design: goal_token goes through the scrub; exempt it or say why not.
  • First Principles: the echoes_loop flag has one True caller per authorizer; reply or move the preflight into those handlers.
  • First Principles: the read 503 guards cover a policy that breaks after boot; the description does not name that case.

To clear: a maintainer takes the change onto a same-repo branch and approves it, and the four notes are answered.

— crew-pr-reviewer (r129)

@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD (policy: human review required) at 0be2c30.

This PR changes what is credential-redacted on every auto-nudge egress through one shared rule (handlers/autonudge.py#L135) and declares a new redaction sink (security_posture_sinks_gateway.py#L513). Redaction changes are reserved for a human reviewer, and Sensitive Change Review fails on this fork head, so a maintainer has to carry it to a same-repo branch.

I found no defect in the scrub. Addressing fields and goal_token stay verbatim, dicts and lists are walked, the three rendering write routes refuse before mutating, and halts that send no loop back are not blocked. The four notes from my r129 comment are now answered in the description and code.

One observation, not a blocker: the broadcast guard in nudge_wiring.py#L282 protects the event-log append only for loops without a monitor. monitor_kind (L263) and the structured record (L296) still redact outside it, unchanged from base.

To clear: a maintainer takes the change onto a same-repo branch, reviews the redaction change and approves it.

— crew-pr-reviewer (r133)

@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD (policy: human review required) at e308bfe.

This PR changes what is credential-redacted on every auto-nudge egress through one shared rule (

def _scrub_serialized_field(key: str, value: Any) -> Any:
"""The ONE per-field projection rule, shared by every reader of a loop.
Three arms project a loop: ``_serialize``, the reducing arm of
``_serialize_for_legacy_reader``, and the gateway's ``autonudge_state``
broadcast. All call HERE rather than assembling a payload of their own,
because a second independent assembly serves raw whatever this rule scrubs --
and ``stopped_reason`` is the field that exposes: agent-supplied free text,
neither withheld nor mapped out of the reduced row, on a route with no owner
gate.
``_redact_monitor_value`` carries the walk, and two of its properties are
load-bearing here rather than incidental: a dict or list is WALKED instead of
scrubbed as a unit, so ``judge`` and ``judge_last_verdict`` reach the popover
as the objects it reads; and nested keys are walked WITHOUT the exemption
below, because a nested key sharing one of those names addresses nothing.
``ADDRESSING_FIELDS`` is the loader's own set rather than a local copy,
because two copies could drift the hole open, and a scrubbed id addresses
nothing. ``goal_token`` is random hex the popover sends back as
``expect_fingerprint``, so a scrubbed token would refuse every save as a
stale baseline. ``monitor`` is settled by the caller from the typed record
through the same walk.
"""
if key in ADDRESSING_FIELDS or key in ("goal_token", "monitor"):
return value
return _redact_monitor_value(value)
), applies it to the autonudge_state broadcast (
_scrubbed = True
try:
for _key, _value in tuple(loop_payload.items()):
loop_payload[_key] = _scrub_serialized_field(_key, _value)
except PlatformCompositionError:
_scrubbed = False
logger.warning(
"AutoNudge: redaction policy would not compose; "
"autonudge_state withheld for %s",
loop.slot_key,
exc_info=True,
)
if is_structured_monitor_loop(loop):
assert loop.monitor is not None
loop_payload["monitor"] = _redact_monitor_value(
monitor_state_public_dict(loop.monitor)
)
broadcast = (
self.dashboard_state.broadcast_ws_owners
if is_structured_monitor_loop(loop)
else self.dashboard_state.broadcast_ws
)
_frame = {
"event": event,
"slot": loop.slot_key,
"loop": loop_payload,
}
def _publish(frame: dict = _frame) -> None:
if not _scrubbed:
return
broadcast("autonudge_state", frame)
) and declares a new redaction sink (
"Auto-nudge loop inventory",
). Redaction changes are reserved for a human reviewer. Sensitive Change Review fails on this fork head, and the author has asked a maintainer to carry it to a same-repo branch.

This head is the r133 commit rebased onto main with no logic change. I found no defect in the scrub: addressing fields and goal_token stay verbatim, dicts and lists are walked, the rendering write routes refuse before mutating, and halts that send no loop back are not blocked. All other checks are green. GPT and Opus report no findings, Design and First Principles PASS, UX skipped.

AI findings judged non-blocking:

  • First Principles: the pre-mutation guard is oversized, drop it from api_monitor_stop. The stop reply serializes the loop, and the description explains why the refusal sits there (
    if await _refuse_unscrubbable_write("monitor_stop", loop.slot_key, loop.id):
    return _monitor_error(
    "safety checks are temporarily unavailable — monitor not stopped",
    "monitor_stop_denied",
    status=503,
    )
    )
  • Design: with a denylist, a future client-keyed field must join ADDRESSING_FIELDS. A caution for future changes; no current field is affected (
    if key in ADDRESSING_FIELDS or key in ("goal_token", "monitor"):
    return value
    return _redact_monitor_value(value)
    )

To clear: a maintainer takes the change onto a same-repo branch, reviews the redaction change and approves it. No PR code was run locally.

— crew-pr-reviewer (r141)

@bolichen97

Copy link
Copy Markdown
Contributor

Holding this PR at e308bfe. Sensitive Change Review is red on this head, and the log gives a real reason, not a flaky run: this is a fork PR that changes a sensitive path (the gateway security posture sinks), and there is no reasoning template for this head. A fork PR cannot pass that gate.

It needs a maintainer security review before it can move. The gate's own path for this is for a maintainer to take it over on a branch of this repository, keeping the author with Co-authored-by: and writing Supersedes #10967, then run the real sandbox and drive that PR green. I am not approving it until that happens.

@bolichen97 bolichen97 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.

Maintainer decision (security sign-off): we are not increasing security strictness, so the new refusals in this PR cannot land. The scrub itself can.

At e308bfe I split it like this:

  • Keep: running every served loop field through the one _scrub_serialized_field rule, so the REST payloads, the legacy reader and the autonudge_state broadcast all redact the same way. This uses the existing redaction shim and refuses nothing.
  • Drop: the new refusals. scrub_policy_unavailable() is now checked in _dashboard_admission and before writes (_refuse_unscrubbable_write), and _read_scrub_unavailable turns the list and read routes into a 503. Each of those refuses a request that main serves today. The two existing 503s in the authorizers, which only move to the shared constant, are fine to keep.

Requesting changes for that. The branch also conflicts with main, so please rebase it when you push. Sensitive Change Review is red on this head and needs its reasoning template filled for the security path.

@bolichen97

Copy link
Copy Markdown
Contributor

Re-reviewed at d695147: the change I asked for is done, thank you.

  • The new refusals are gone. No more scrub_policy_unavailable() in _dashboard_admission, no _refuse_unscrubbable_write, and no read-route 503.
  • The only 503s left are the two the authorizers already returned on main, now using the shared SCRUB_UNAVAILABLE_SAVE_ERROR text.
  • The new TestTheScrubAddsNoRefusal tests pin that the list, slot, arm, stop and pause paths are still served when the policy cannot compose.
  • Every served loop field still goes through the one _scrub_serialized_field rule.
  • No regex is added.

So the security direction is now neutral, and the code side looks good to me.

What still blocks a merge is not something you can fix from here. Sensitive Change Review cannot pass on a fork PR that changes a sensitive path; its log says a maintainer has to re-open it from a branch of this repository and drive that branch green. I am flagging that to the maintainers. E2E, Integration and the redaction gate are still running on this head.

@bolichen97

Copy link
Copy Markdown
Contributor

Re-read at 3763d51. My earlier points are addressed, thank you: the new request refusals are gone, every served loop field goes through the one scrub rule, and no regex is added.

One new thing on this head. In nudge_wiring.py, when the redaction policy cannot compose, the observer now drops the autonudge_state frame instead of publishing it (the _scrubbed flag, with the warning log). On main that frame is still published in that case. We do not take added strictness, even when the author adds it, so please drop that path and let the frame behave as it does on main when the policy cannot compose. The scrub itself can stay.

@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD at 3763d51: @bolichen97's change request is still active, and this redaction change is reserved for a human.

The new request refusals are gone, as @bolichen97 confirmed, and every served loop field still goes through the one _scrub_serialized_field rule. One point remains open from @bolichen97's latest comment. When the redaction policy cannot compose, the observer withholds the autonudge_state frame (nudge_wiring.py#L282-L312), while main publishes it. The maintainers do not take added strictness, so please drop that path and keep the event-log append ahead of the publish.

AI findings judged non-blocking:

  • Design note 1: the posture sink text names only id and slot_key as exemptions, but goal_token and monitor are exempt too (security_posture_sinks_gateway.py#L516-L534). Worth fixing in the same push.
  • Design note 2: a monitor loop's _redact_monitor_value calls still sit outside the guard. That is unchanged from main and outside this PR's scope.

Also blocking: Sensitive Change Review is red on this fork head, so a maintainer has to carry the change to a branch of this repository.

To clear: the author drops the frame-withhold path, @bolichen97 lifts the change request, and a maintainer takes the change over and approves it. I read the source and CI; I did not run any PR code.

— crew-pr-reviewer (r146)

@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.

Thanks for narrowing this. One change is still needed at this head before it can merge.

  1. src/kiro_crew/slack/gateway_runtime/nudge_wiring.py:282-312. The frame-withhold path adds a refusal that main does not have. Trigger: a host whose credential policy stops composing after startup, so redact_via_context raises PlatformCompositionError, and then a plain loop (no monitor) is added, updated or removed. Outcome: _scrubbed is set to False, so _publish returns early. The autonudge_state frame that main broadcasts is not sent. The crew_work.worker_loop_moved(slot) refresh after it is skipped too, so conductor boards that name this worker keep a stale worker_looping reading. That refresh carries only a slot key and no loop text. This conflicts with the body's "Removes nothing" and with "Any new refusal" under Not a goal. It is also the path a maintainer asked to drop on 2026-11-05. Smallest fix: delete _scrubbed = True (L282), _scrubbed = False (L287) and the if not _scrubbed: return in _publish (L311-312). Keep the try/except, so the event-log append still runs before the publish. Reword the warning (L289-290) and the comment (L273-281) so they no longer say the frame is withheld. Remove test_an_unscrubbed_frame_is_never_broadcast in test/test_autonudge_egress.py and keep the other guard tests. On a host whose policy composes, every frame field still goes through _scrub_serialized_field, so the Goal still holds.

Optional:

  • The broadcast scrub only has AST pins. If the observer discards the result of _scrub_serialized_field, the related tests still pass. The existing TestAutonudgeRouterAndObserver._wire harness in test/test_slack_gateway_coverage_nudge_routing.py already drives this observer with mocks. A short test there could arm a plain loop whose message carries a secret, then assert the secret is not in the broadcast frame and that id and slot_key come through verbatim. That would pin the behaviour, and the docstring's "needs the whole gateway" claim could then be corrected.
  • security_posture_sinks_gateway.py:527 names only id and slot_key as exemptions. _scrub_serialized_field also exempts goal_token and monitor. Naming all four, each with its reason, would keep the sink text accurate.
  • The "adds no refusal" route tests use an empty store. Rendering one plain loop on a host whose policy cannot compose makes the list and slot routes raise where main answers 200. Narrowing the two docstrings (test/test_autonudge_egress.py L12-14 and L204) to what the tests show would keep the claims honest. Whether REST should fail closed there is a maintainer decision, and it does not need new code in this PR.

…ot reach a reader

Every reader-facing projection now goes through one per-field scrub rule instead
of a bare asdict, and both authorizers probe the credential policy before mutating.
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Thanks for the rework. The review found no blocking defect at this head. It still needs a maintainer before it can merge.

Follow-up on my earlier review (at 3763d51):

  • Frame-withhold refusal in nudge_wiring.py: fixed. The _scrubbed early return is gone. The frame is always published, the try/except stays, and the event-log append still runs first.
  • Optional, behaviour test for the broadcast scrub: fixed. The observer is now driven with a secret and a broken policy, and the frame is checked for placeholders and intact id and slot_key.
  • Optional, sink text naming all four exemptions: fixed in security_posture_sinks_gateway.py.
  • Optional, "adds no refusal" claims: addressed. REST readers now serve [redaction unavailable] through _project_field for a plain loop.

What still needs a maintainer:

  • Sensitive Change Review is red on this fork head. As noted on 2026-11-04, a fork PR cannot pass that check. A maintainer has to carry this head to a branch of this repository with Supersedes #10967, keeping you as co-author.
  • The earlier maintainer change request at e308bfe is still open. Its asks look met at this head (no new refusals, branch rebased), but it has to be re-reviewed or dismissed by that maintainer.
  • PR Readiness is still pending on UX Review.

What the review checked at this head: the REST serializer, the legacy reader, the in-session reading and the autonudge_state frame all use one per-field rule. The exemptions come from the loader's own ADDRESSING_FIELDS. Mutating the production hunks one at a time turned the tests red in 10 of 11 cases, and the one survivor is a no-op change. Backend Tests and both New-test stability jobs are green. Done well: the denylist over asdict(loop) means a free-text field added to the loop later is scrubbed with no extra code.

Optional:

  • The composition-failure fallback covers only loops without a monitor. monitor_kind (nudge_wiring.py:264-266) and the structured monitor redaction (:297, and _serialize in handlers/autonudge.py:224) still raise outside the guard. Main already behaves this way. Either bring those calls into the same fallback, or narrow the comment and the body's "200, never 500" to loops without a monitor.
  • The broadcast repeats _project_field's try/except. Calling _project_field per key would remove that copy and two re-exports from gateway.py.
  • The body says 25 tests in test_autonudge_egress.py. The file at this head defines 30.

@bolichen97

Copy link
Copy Markdown
Contributor

Continuing this in #32954; thanks for the start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) needs-author-decision PR blocked on author input

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants