Skip to content

feat(dashboard): host an agent-written dashboard page and let it subscribe (#19060) - #19335

Merged
iamwhatever merged 1 commit into
mainfrom
feat/19060-page-host
Oct 13, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
feat/19060-page-host

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A crewmate's owner agent can write its own dashboard page, and a reader watching that page sees its numbers move as the work moves instead of a snapshot from whenever the tab opened.

A crewmate's Dashboard tab can only show a page that SHIPPED with the product. An owner agent wanting to draw something the shipped templates do not cover -- a dispatch tree, a chart, a scene -- has no way to put it on screen, and the shipped pages refresh by re-reading the whole record, which throws away whatever state the page had built (a scroll position, an animation, a 3D camera).

Why it matters

A crewmate's report is the one surface its owner reads to know what the crew is doing. Restricting it to shipped templates means every new thing worth reporting waits for a product release. And a report that silently stops being current is worse than one that costs a read: the reader cannot tell "nothing moved" from "nothing arrived".

Not a goal

  • BUILDING the stage / preview / approve / apply flow. This ships the RENDER half of the RFC's decision 3: it serves only a version a person applied, and nothing when none is. The save-side verbs are feat(dashboard): dashboard_save stages a composed page an agent builds #18851's.
  • Resolving a package slug from anywhere but the crewmate's own binding.
  • A host-level notice for the scripts-off state. The page author owns that message through <noscript>.

What changed (motivation -> approach -> change)

A kind=dashboard package can carry one view.html its owner wrote instead of the block list. The frame gains window.kirocrew.subscribe(name, cb), firing on load and on every push carrying that field, so a page redraws from the field that moved rather than re-reading everything -- which is what keeps its own state.

The model is the allowlist throughout: subscribed_fields reads it, the save gate refuses an undeclared binding, the controller resolves every value through it, and a frame carries only fields whose value changed. A write is refused unless the caller is the bound owner, on all three save paths; an APP caller is refused outright. A field NAME travels further than its value, so validation runs each through the same redaction shim. A preview resolves no binding, so it cannot serve the LIVE package page to someone deciding on a staged one. The stale-values Retry repeats the read that failed.

A dashboard package is never written against a snapshot that has moved on, and the store is what says so. One rule, stated on the record its own lock loaded: a record whose CURRENT kind is dashboard is never written without a matching snapshot token, and an ABSENT token is a refusal. The handler classifies nothing; it names the read it authorized against for every write it makes (snapshot_token) and update decides. Scoping this in the handler instead is what kept the hole open across three rounds -- an event type it did not count, then a content-less kind PATCH, then a read that found prose or nothing and so sent no token at all, which rewrote both the kind and the bytes of whatever the slug held by then. A time-of-check guard in the caller cannot close a time-of-use hole in the store. Scoped to writes that can take the page away -- its kind, its bytes, or any write naming a snapshot -- so publish_sync's snapshot bump and the deploy route's webapp_metadata write keep last-write-wins, and a metadata-only write on any other kind is never fenced, which the editor's autosave depends on.

That fence and the caller's own expected_token are two questions, asked independently. The fence asks whether the write names the record it is landing on, which a request-driven caller can always answer with its own fresh read. expected_token asks whether the record still holds what THAT client last saw. Answering the first and skipping the second would let an owner's stale tab overwrite a newer layout with no 409 -- an agent and an open tab editing one dashboard is the ordinary case here, not an extreme one -- so a content write carrying expected_token is compared on every kind, dashboards included.

The gallery page's own words, rewritten against the UX review's blind reader -- in the shipped page, not the chrome. The scripts-off notice ended in "open the dispatch tree from a crew whose network access is unrestricted", which names no person and uses the posture's own word; it now says to ask whoever administers the crew's network policy, and carries a rule and a tint instead of the footnote grey it shared with the empty line. on a cycle and unresolved became dispatched in a loop and whose parent is missing. A bare 9 items on a parent row read as covering the rows underneath, which their own counts contradicted, so each row says 9 own items. Three tests pin the new text and each reddens on the old page. Two states the review could not see are now attached: the page with no rows, and Try again faded while the whole read is in flight.

The person's layout lock outranks package selection, and every name an owner refusal quotes is redacted. Two things the rebase onto main's structure lock exposed. The lock is a ceiling over the crewmate, but the package branch returned before instance.read, the only reader of it -- so a crewmate writing its own kind="dashboard" artifact, ordinary agent work, moved the tab off the page the person pinned, and an unapplied package moved it to the empty state. The lock is now read first and the locked record is what is served. Separately, binding_refusal quoted the binding name, the caller's crew and a validation error's value into a sentence the named GET returns as its 403 body, and _BOUND_TO_RE accepts a GitLab-PAT or Slack-bot shape. The redaction went INTO that one function rather than onto the route: three readers of this string had the same defect and two were found one at a time, so the next caller gets the rule for free.

A tab showing no package drops that package's pushes rather than letting them through. The frame guard read mine && fromPackage !== mine, so an empty mine passed everything -- and the lock fix above makes that reachable: once locked, the gateway stops selecting a package and the body carries no dashboard, while the (crewmate, package) page stays armed. The template's bootstrap then could not place the pushed generation and asked for a whole read with nothing to name, which the route answers 400 missing_dashboard, so the stale band returned on every push. The guard now drops whenever fromPackage !== mine, and the whole-read ask returns early when no package is live.

The ambiguous-slug refusal landed on main while this branch was rebasing, so this change yields to it rather than answering the same question twice. api_artifact_update on main now validates a submitted binding's TARGET -- a crew member who exists, a slug two of them do not share (dashboard_slug_ambiguous), a live root session -- and answers 400. That is the narrower question and it has a definite answer, so it is asked FIRST; this change's owner gate, which asks the broader question of whether the caller owns the record and cannot always resolve a caller, now runs after it. Asking the broad one first replaced every one of those 400s with a single 403 and hid what the specific gate would have said. Nothing is weakened: the owner gate still refuses a worker rebinding another crewmate's page to a target that happens to be valid, and the snapshot read it depends on still refuses an unreadable or absent record before either gate decides. One narrowing came with it -- an app is identified by its id STRING, where any truthy value in that slot was read as one, which is a broad refusal standing in for an identification the gate never made.

This class of defect surfaced in four places -- resolve_bound_slug, the member lookup on artifacts.py, main's target validation, and the owner comparison in binding_refusal -- because the product resolves a crewmate slug in more than one place and they did not agree on ambiguity. The owner comparison is the last of them and asks the roster the count before it compares: a roster holding both Atlas and atlas derives one slug from two names, and comparing the caller's slug to the binding's then authorized EITHER of them for the other's package. More than one owner refuses as dashboard_slug_ambiguous and never picks, and the count comes from _member_names_for_slug, the roster's own answer the other three already ask, rather than a fourth spelling of the rule.

The script grant is POLICY AND the owner's active PROFILE, tested by archetype and resolved off the event loop. The grant read only the composed ceiling, so an open policy with a profile that restricts network.egress -- the ordinary shape, and the standalone default where no policy is configured at all -- handed the page allow-scripts, and a running page can navigate its own frame, carrying fold values, to a host the profile forbids. The profile is resolved for the surface the page belongs to (the crewmate's own slot; without a session key the scope resolves to unknown and no surface profile can match), and it is tested the same way the ceiling is -- is this scope RESTRICTED AT ALL -- because asking whether one host is permitted answers only about that host: a profile denying github.com permits every other name. The resolution runs through _run, since the profile store stats its directory and reloads what moved, which on the loop pauses every other session's chat and the heartbeat. An unresolvable profile withholds script, as an unreadable ceiling already did.

And four display defects where the page would show a reader the wrong thing. The applied version's bytes must come from the record the approval was read from (created_at), because a slug is reusable and a version number restarts at 1, so a delete-and-recreate between the two reads served the replacement's page under somebody else's approval. A page served with no script now has its bound cells filled server-side as escaped text, since the bootstrap is what normally fills them and an empty page with a hidden stale band reads as a current one. A field whose fold path stops resolving now sends a patch even though no value moved, so the stale band is raised instead of the last value standing as current. A refetch no longer spends a patch version, which was putting every other tab on the package one behind and making each of them refetch in turn. And the binding scanner reads an UNQUOTED attribute value, which a browser accepts and the validator was skipping.

This also carries the tree READ path beside its only caller, LivePage. That reader is why the worktree fold's binding joins manifest.FOLD_NAMES here -- the pairing #18777 deferred -- and the catalogue's advertised flag derives from that same set, so it turns over on regeneration rather than by hand.

The render path serves a version a person applied. This answers the First Principles block rather than asking for an exception, and each link was measured:

  1. _serve_package called get(package_slug) with no version -- the artifact's CURRENT content, so the page served was whatever the agent wrote last, with no approval step anywhere.
  2. "It has versions" is not an answer: the save route sets snapshot = is_mcp, so an agent writing over MCP cuts a version on every save with no person involved.
  3. The marker that works needs BOTH fields. Every version-cutting update appends an event carrying by=<actor>, derived from how the request authenticated (actor = "agent" if is_mcp else "user", keyed on the X-Internal-Secret header). by alone is not enough -- it is stamped on referenced (posted whenever a person OPENS the artifact) and comment too, both at the record's CURRENT version, so a glance would approve the agent's latest draft. The type alone is not enough either: event_type is body-settable, so an agent can spell its own save edited. So: the newest version whose event has by == "user" AND an approving type.
  4. The approving set is an ALLOWLIST (edited, reverted), never a denylist of annotations -- a type the store gains later is excluded until somebody decides, which is how referenced should have been treated. created is out because its actor comes from create's source, validated against ALLOWED_SOURCES, which has no user: the event can never carry the marker, so listing it would be a rule matching nothing that reads as "creating approves".
  5. The bytes come from THAT version (get(slug, version=N)), not the current content. No approval, or a version whose event was evicted or bytes pruned, renders nothing.

The one leak, and where it is closed. by == "user" is assigned to a request with no X-Internal-Secret, and an app backend is proxied with that header stripped. package_write_refusal identifies an app POSITIVELY from request["app"] and refuses before the person's exemption, so an app never falls through as "whoever sent no secret"; closing it in the middleware would change actor derivation for every app artifact write. An agent cannot reach a person's credentials either (httpOnly cookies, KIROCREW_INTERNAL_SECRET stripped by sandbox._AGENT_DENIED_ENV_KEYS, .local_secret denylisted, CLI minting refused). The marker DEPENDS on that refusal, so a test ties them.

Not claimed: the actor is unforgeable from the REQUEST, not against a writer already running as this OS user -- the same residual the stored-bytes read carries, bounded by the frame.

Backwards compatibility

Compatible: view.html is a new opt-in package shape behind the owner binding, and the route keeps the body shape the tab reads. A crewmate that adopted nothing, or adopted a template, is served what it was before. scripts absent means allowed.

One capability IS narrowed: package_write_refusal refuses an APP-token caller writing a kind="dashboard" package, which it could do through /api/artifacts before. An app has no crewmate identity to check a binding against and the page it writes runs script in a person's tab. Sweep on main: no shipped app writes this kind -- it is introduced by this line, and both writers (the dashboard skill's save path and the owner agent) are owner-token callers. Any other kind is untouched.

One assertion is RESTATED, not removed. test_every_manifest_fold_name_has_a_scope required every FOLD_NAMES entry to have a bus scope, and a tree fold has none by design. It becomes ..._is_keyed_or_read_as_a_tree: every accepted name is REACHABLE, by a scope or the tree read. The strictness moves rather than drops -- test_a_tree_fold_the_manifest_accepts_has_a_reader requires no scope AND a real reader, asserted as read_tree_projection existing and LivePage._read_trees calling it.

The binding lookup is DEDUPED and the shared function got STRICTER, so "deleted a duplicate" must not read as dropped protections. resolve_bound_slug now refuses ambiguity (new BindingAmbiguous, a subclass so no caller changes), refuses when an unreadable record follows a match, and skips live-backed records. Every test the copy carried moved onto it, including the two-claimant one.

One race closed, and the window is worth seeing without re-deriving it. This route authorizes a dashboard-package write against a snapshot it READ: handlers/artifacts.py reads the record at :2028, gates on it at :2081, and writes at :2111. It hands the store that read's content_token so a rebind landing in the gap becomes a conflict instead of a silent overwrite. But ArtifactStore.update's guarded condition required content is not None (artifacts.py:1257-1261), so a kind-only PATCH arrived with the token attached and ignored -- an agent de-authorized by a rebind inside that window could still flip the kind of the package the owner had just taken. No bytes were lost and later writes stayed owner-gated, but dashboard is not a user-selectable kind, so nothing put it back without a human.

guarded now also holds when the record's kind IS dashboard, so the comparison runs under the store's own lock -- the only place the record is loaded race-free; the handler's read is a moment earlier by definition. It is scoped by the kind the RECORD holds, never the submitted one: the dangerous PATCH submits markdown, so reading the submitted value would let exactly this write escape the guard it is meant to trip. Metadata-only writes on every other kind stay unguarded, which the editor's autosave and every tag edit depend on.

Ownership is read off the stored ENVELOPE, not off a validated package. The write gate authorizes against both bindings and the STORED one decides, because the submitted one is a claim the caller wrote. Reading the stored binding by parsing the package tied it to whether the layout still validates -- and this PR is what makes those diverge: it adds the credential-shaped field-name refusal, so a dashboard stored before it, whose model the old validator accepted, now fails parse_package and classified as "not a package". The gate then skipped the stored half entirely, and a worker submitting a package bound to itself could overwrite and rebind a crewmate's page. stored_package_binding now decodes the envelope and answers three cases: no dashboard record (nothing to protect), a readable binding (enforced), or a dashboard record whose binding cannot be read (refused, not skipped). Same rule resolve_bound_slug already follows, for the same reason: a layout the validator rejects is still somebody's.

An undeclared binding name is redacted before it is echoed. A field NAME travels further than its value, so a credential-shaped one is refused as a name and the refusal names it by its redacted spelling. That ran only on declared model.types names, while view.html's undeclared-binding refusal listed the names it found raw -- and the artifact route returns that string as the HTTP error body, so an agent binding a credential-shaped name it never declared got it echoed back unredacted. Both paths now redact; redaction is identity on an ordinary name, so the author still reads which field to fix.

The snapshot fence and the ownership gate classify the stored record the SAME way, off the envelope. Reading it one way to decide who owns the slug and another way to decide whether to forward the read's token is worse than either alone: a legacy package the current validator rejects was enforced by the gate and left unfenced by the token decision, so its former owner's kind-only PATCH passed with nothing guarding it. Both now use stored_package_binding, and a test asserts the two agree on every shape rather than checking one case.

A read answering state: empty drops the page it was holding. That state means the record HAS no page (its applied version pruned, or none approved), and returning early on "this body carries no page" left the held document mounted with the grant it loaded under -- so a reader saw a page the record no longer has, and under an egress ceiling restricted since, that document could still navigate its own frame. The empty state is now authoritative: the held page and any probationary candidate are dropped and the script decision is reset. A read that still carries a page is untouched.

Removes nothing else: no key, route or public function is withdrawn for an existing caller.

Tests

  • TestTheRenderPathServesAnAppliedVersion -- on a REAL ArtifactStore, so the events are the ones the product writes. Agent writes three times, nothing renders; a person's snapshot lands, that page renders; the agent writes again and the person's version still renders, which is the case separating this gate from one that serves the latest write once any approval exists.
  • TestAnAnnotationIsNotAnApproval -- a person opening or commenting on the package does not apply the agent's draft, and does not promote a newer draft over one already applied. Each asserts its own premise first.
  • TestTheGenericSnapshotButtonIsNotAnApproval -- a content-less snapshot: true cuts no version for this kind, so the generic Snapshot control cannot publish the agent's page; and a person who SUBMITS bytes does apply them.
  • TestTheApprovingTypeSetIsAnAllowlist -- every name in the set is a real event type, every type the store emits is in the set or excluded with its reason, ALLOWED_SOURCES still has no user, and the conjunction is asserted in all four combinations.
  • TestTheAppRefusalIsWhatKeepsTheMarkerHonest -- an app writes a package, the page renders nothing, and the app check provably precedes the person's exemption.
  • TestAStagedPageReachesOnlyItsOwnersPreview -- nine source-level tests enumerating every reader of staged bytes, every page producer, the gate before each, and the order keeping a preview on the staged page.
  • TestABoundPackageWithNothingToServe -- a binding whose package has no record renders the frame's empty state, not a 404 and not the default template.
  • CrewDynamicDashboard.revocation.test.tsx -- a withdrawn script grant REMOUNTS the frame. A sandbox attribute is computed at navigation, so rewriting it on a running document leaves that document with the grants it loaded under; the grant is now part of the frame's identity, and an unchanged grant does not remount.
  • TestAnUntokenedWriteCannotTakeADashboardOver -- the store's own invariant: a record whose CURRENT kind is dashboard is never written without a matching snapshot token, and an ABSENT token is a refusal. Covers the reported PATCH (kind and content together, which is what gets past the layout validator), a stale token refused the same way, the owner's matching token going through, a metadata-only write naming no snapshot still applying, an ordinary artifact keeping last-write-wins, and the fence not swallowing a caller's own stale expected_token. Five mutations of the store clause each redden it -- absent-is-a-refusal, the fence's scope, stored-vs-submitted kind, the handler's naming of its read, and collapsing the two questions back into one elif -- and a run with the clause restored is green.
  • TestWhatTheStaticPageSays -- the scripts-off notice ends in an action a reader can take, uses no posture vocabulary, names no object the UI does not label, and carries its own notice style rather than the muted grey it shared with the empty line.
  • Plus the package shape, owner gate, subscribe contract, field push, event scoping, gallery, scripts-ceiling, refetch and fold-catalogue suites.

Measured on this head: 1109 passed across the twenty dashboard suites, 1395 across every test_artifact* suite, and 1147 across the publish and deploy suites -- the three internal update callers that name no snapshot, which is what the invariant's scoping had to leave alone. Frontend: 884 passed across 34 member and dashboard specs with KIROCREW_ACT_STRICT=1; tsc --noEmit and eslint exit 0; black, isort, comment-history and take-away gates clean, and the test-determinism rules report no finding on any file this change touches.

Manual verification

Where a staged page can be seen, read off the source: the staged read has ONE call site, inside if request.query.get("preview") == "1"; _preview_record is the only caller of instance.staged_preview outside the store, where the other is apply_preview, which consumes it. Both page routes return on _owner_only before reaching _serve, so the staged page inherits the applied page's gate. Every non-preview read serves the applied record or the shipped default, both after the preview branch returns. The product emits a page in exactly three places, all in one file. preview_url is that same gated read, with no capability token.

Screenshots were captured in a real Chromium against the REAL component with only the gateway's reads stubbed: the page is the shipped gallery package composed by the production composer. Each state asserts its testid, palette and the frame's own sandbox attribute before the shot. The stale band is reached the way a reader reaches it -- a patch skipping a version, so the page asks for a whole read, which is refused.

On the UX review's "script withdrawal is silent": not for this page. With scripts: false the frame mounts with an empty sandbox and the page's own <noscript> is what renders (third shot). TestWhatTheStaticPageSays pins that text, pins that the two claims only a script could correct ship hidden, and pins that it does not promise the counts are current.

The gallery page's words, rewritten against the UX review's blind reader. Three things it could not act on, all in the shipped page rather than the chrome: the scripts-off notice ended in "open the dispatch tree from a crew whose network access is unrestricted", which names no person and uses the posture's own word, so it now says to ask whoever administers the crew's network policy, and carries a rule and a tint instead of footnote grey; on a cycle and unresolved became dispatched in a loop and whose parent is missing; and a bare 9 items on a parent row read as covering the rows underneath, which their own counts contradicted, so each row says 9 own items. Three tests pin the new text and each one reddens on the old page.

The disabled Retry was measured, not assumed. The first capture of the pending state photographed the button at full brightness: Btn fades to disabled:opacity-30 through transition-all, so shooting on the disabled flag alone catches it mid-transition. The shot now waits for the computed opacity to settle and asserts it, which is why that image shows an acknowledgement at all.

Screenshots / video

Committed under temp-screenshots/19335/ rather than attached: gh pr edit --attach and every other gh write on this machine return exit 0 and change nothing, so an attachment could not be produced for this revision. Committed media is the documented alternative and the review lanes read it the same way. All five are re-captured on this head, so the three that existed before now show the rewritten words rather than the ones the UX review quoted.

The dispatch-tree gallery page running in the Dashboard tab

The same page with nothing folded yet, so its own empty line is what a reader meets. Still a live read, which is what separates it from the record-level empty state:

The dispatch-tree page with no rows, showing its own empty line

The same page with scripts: false, the state an admin ceiling that denies the owner agent egress produces:

The same page static, showing its noscript notice

The stale-values notice after the whole read was refused; Try again repeats that read:

The stale-values notice above the hosted page

Try again pressed, with that read in flight. The notice stays up until the read arrives, so the faded button is the only thing on screen acknowledging the press:

The stale-values notice with Try again faded while the read is in flight

Related Issues

Part of #19060. Split out of #18777, which has merged, so this targets main directly.

Checklist

  • At most two commits, with a Conventional Commits title
  • 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

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ human override accepted

Human judgment by @chenmingwei23 overrides the GPT 6.1 finding for f4cde7b737f2e663bb17e3d9338b64b35629d054; the recorded reason is authoritative for this commit.

[GPT-OVERRIDE] f4cde7b

This comment is updated in place on each push.

The model was not re-run because an authorized human decision supersedes it.

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

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — 🟡 CONCERNS

UX-level review of f4cde7b737f2e663bb17e3d9338b64b35629d054 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: CONCERNS

The dispatch-tree gallery page uses words the blind reader didn't know, and the faded "Try again" looks the same whether it is retrying or turned off.

Watch

  • The gallery page's words aren't explained. The shipped page uses "root", "dispatched in a loop", "whose parent is missing", "own items" and "No board has dispatched another yet". The page never says what any of them mean. The blind reader said "I don't know what a 'board' is" and "no idea what an 'item' is", and listed all of these words under "Could not tell". This is moderate: every first visit to this template shows the summary line and the empty state, though the tree's layout still comes across.
  • "Try again" gives no sign that a retry is running. While the read is in flight, the only change is disabled={refetchPending}, with no spinner or new text. The reader of shot-05 said: "I can't tell whether it is busy or simply turned off." This is low to moderate: it only shows while recovering from a failed refresh, but the user can't tell that their press worked.

Suggestions

  • In CrewDynamicDashboard.tsx, spin the RotateCw icon (animate-spin) and show "Trying again…" while refetchPending is true.
  • In the gallery view.html, change "No board has dispatched another yet." to "No task has started another task yet." Also replace "own items" with a noun that names what the rows actually count.

[UX-REVIEWED] f4cde7b

Description read

[DESCRIPTION-READ] 7d9e8727e614441071281133f72872fd1a83c48d0eb08d7b7fa30381cc6eab19

That sha256 names everything this verdict read: the PR description, plus the 8 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 12, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — 🟡 CONCERNS

Design-level review of f4cde7b737f2e663bb17e3d9338b64b35629d054 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

The new store-level dashboard fence rejects publish_sync.pull_upstream's untokened content write, and that path silently reports "write-back failed".

Watch

  • Pull-from-upstream on a dashboard record now always fails. The change makes ArtifactStore.update refuse when the stored kind is dashboard, the write carries content, and no token is passed: authorized is None: raise ArtifactConflictError(...). publish_sync.py:pull_upstream calls store.update(slug, content=pulled_content, kind=pull_kind, actor=actor, snapshot=True) with no snapshot_token or expected_token. Its except Exception turns the conflict into {"pulled": False, "reason": "write-back failed"}. So a published dashboard package can no longer be pulled, and the person is never told the fence refused it. The description names publish_sync's snapshot bump as exempt but not its content pull. The ## Backwards compatibility section falls past the 8000-byte truncation, so this check is capped at CONCERNS.
    Clears when: pull_upstream either passes the content_token of the read it loaded art from, or refuses dashboard-kind records up front with a specific reason; a test covers pull_upstream on a kind="dashboard" record; and that reader is listed under Backwards compatibility.

[DESIGN-REVIEWED] f4cde7b

Description read

[DESCRIPTION-READ] 1953b4ddb09555931e2ff4bb203108e186d67cf781461a676f8e5cf8b66b461b

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 12, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🟡 CONCERNS

Premise-level review of f4cde7b737f2e663bb17e3d9338b64b35629d054 — 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/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

The fold name "agentic" already exists as DASHBOARD_FOLD_NAME; this PR adds two more copies of it and a test to keep the three in step.

Not justified as shipped

  • Item 9 — duplicate of src/kiro_crew/crew_log/entry_types.py:344: the diff adds AGENTIC_FOLD: Final[str] = "agentic" in both dashboard_feed.py:62 and member_dashboard_fields.py:68, with test_the_two_spellings_of_the_agentic_fold_agree to keep them equal. Grepping = "agentic" finds DASHBOARD_FOLD_NAME = "agentic" already on base, used at 8 sites. dashboard_feed.py already imports PANEL_FOLD_NAME from that same module. The comment's reason for the copy is a ban on importing dashboard_feed at module scope, which does not cover entry_types.
    Subtraction: delete both AGENTIC_FOLD constants and the agreement test, and import DASHBOARD_FOLD_NAME from crew_log.entry_types at both sites.
    Clears when: both new constants and the test are removed, or the description names an import cycle that entry_types itself would cause.

What this change ships

Inventory (10 items) — 9 justified

Intent: an owner agent writes its own crewmate dashboard page, and readers see it update live. ADDITION.

  1. The Dashboard tab can show a view.html page the owner agent wrote (applied versions only) — justified
  2. Pages get kirocrew.subscribe(name, cb) and redraw only the field that changed — justified
  3. Changed field values reach the owner's tab live over the socket, limited to the declared fields — justified
  4. Only the bound owner can save a dashboard package, and apps are refused — justified
  5. A dashboard package write is refused unless it names a current snapshot — justified
  6. The person's layout lock now takes precedence over the agent's package — justified
  7. A gallery dispatch-tree page ships, with reworded empty and scripts-off text — justified
  8. A "values stopped updating" band, with a Retry that does a full re-read — justified
  9. Tree folds become bindable by package pages; the catalogue marks them "package only" — duplicate of entry_types.DASHBOARD_FOLD_NAME
  10. Refusal text and field names pass through redaction — justified

[FIRST-PRINCIPLES-REVIEWED] f4cde7b

Description read

[DESCRIPTION-READ] 3309059fd69bef1a338cc81bf5d5419581395df4875f31bc27123d6cdbc40e5c

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 Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

The bound-package route returns a 409 error for any package that uses the older view.blocks layout instead of falling back.

FINDING — src/kiro_crew/dashboard/handlers/member_dashboard_fields.py:499 — a crewmate bound to a package with a blocks-only view (view.blocks, the only shape the validator accepted before this PR) that a person has edited at least once: GET /api/members/{slug}/dashboard → _bound_package_slug → _serve_package arms a page → render_package_page runs html = ((package.get("view") or {}).get("html")) or "" → validate_page("") raises page_empty. The tab then shows 409 dashboard_refused on every read and every poll instead of a page. Each read also arms and then disarms the page's subscriptions. → Fix: in _serve_package, check for a package with no view.html before arming. When the binding chose the package (asked_for=False), answer it with _nothing_to_serve.

[OPUS-REVIEWED] f4cde7b

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

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

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 12, 2026
@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 12, 2026
@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 12, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: a31c23c
  • What rule changed: security_posture.py's REGISTRY of redaction boundaries, not any redactor, allowlist or scrub behaviour. One entry is added to _REDACTION_SINKS (field values pushed to a crewmate's dashboard page, produced in dashboard/handlers/member_dashboard_fields.py) and one to NON_EGRESS_REDACTION_MODULES (artifact_store/dashboard_package.py, which calls a redactor to CLASSIFY a field name rather than to emit text).
  • Before -> after (what was allowed/blocked, now): before, neither module existed, so neither was known to the posture audit. After, the value path is declared an egress sink, which means the audit REQUIRES it to scrub every value it produces and fails if it stops; and the package validator is declared non-egress, which means the audit does not require its redactor call to produce outbound text. Nothing that was blocked became allowed: no value reaches a page unscrubbed either side of this change.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the non-egress classification is the one that could leak. If dashboard_package.py did emit redacted content rather than only classifying, declaring it non-egress would exempt a real output boundary from the audit and a field name that redaction rewrites could reach a page unscrubbed. It does not emit: the redactor output is compared against the input, the package is REFUSED when they differ, and the redacted spelling appears only inside the refusal message. The sink entry has no leak shape at all, since registering a sink only adds an obligation.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and ::test_allowlist_has_no_stale_entries both pass on this head, which is the audit reading the registry against every real call site rather than this description being believed. test_member_dashboard_field_push.py::test_every_value_crosses_the_redactor_on_both_paths proves the registered sink actually scrubs on the initial read AND on every later patch.
  • No regression:
    • Tools still work (which tools/commands were run, result): pytest test/test_security_posture.py test/test_member_dashboard_field_push.py test/test_dashboard_package_owner_gate.py -q -p no:randomly -n 2 on this head, 115 passed, 0 failed. The dashboard read and the package save are the two paths these entries describe and both are exercised there.
    • Backward compatible (old config / old data / old callers still work, how checked): yes. Both lists are append-only here, no existing entry is edited or removed, so every module already registered keeps the same classification. An existing package, an existing instance record and an older gateway are unaffected, which test_allowlist_has_no_stale_entries checks from the other direction by failing on an entry that no longer matches a call site.
    • Existing tests (which suites passed on this head): the three suites above, 115 passed. Frontend: CrewDynamicDashboard.refetch.test.tsx 5 passed under KIROCREW_ACT_STRICT=1, plus the dashboard component set 59 passed, with tsc --noEmit and eslint clean.
  • How to undo: delete the two added entries from _REDACTION_SINKS and NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py. They are pure registry rows with no runtime caller, so removing them restores the previous audit exactly; the audit then fails on the two unregistered call sites, which is the state before this PR added those modules.

Base automatically changed from feat/18642-tree-fold to main October 12, 2026 10:32
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: a05850c
  • What rule changed: security_posture.py's REGISTRY of redaction boundaries, not any redactor, allowlist or scrub behaviour. One entry is added to _REDACTION_SINKS (field values pushed to a crewmate's dashboard page, produced in dashboard/handlers/member_dashboard_fields.py) and one to NON_EGRESS_REDACTION_MODULES (artifact_store/dashboard_package.py, which calls a redactor to CLASSIFY a field name rather than to emit text).
  • Before -> after (what was allowed/blocked, now): before, neither module existed, so neither was known to the posture audit. After, the value path is declared an egress sink, which means the audit REQUIRES it to scrub every value it produces and fails if it stops; and the package validator is declared non-egress, which means the audit does not require its redactor call to produce outbound text. Nothing that was blocked became allowed: no value reaches a page unscrubbed either side of this change.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the non-egress classification is the one that could leak. If dashboard_package.py did emit redacted content rather than only classifying, declaring it non-egress would exempt a real output boundary from the audit and a field name that redaction rewrites could reach a page unscrubbed. It does not emit: the redactor output is compared against the input, the package is REFUSED when they differ, and the redacted spelling appears only inside the refusal message. The sink entry has no leak shape at all, since registering a sink only adds an obligation.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and ::test_allowlist_has_no_stale_entries both pass on this head, which is the audit reading the registry against every real call site rather than this description being believed. test_member_dashboard_field_push.py::test_every_value_crosses_the_redactor_on_both_paths proves the registered sink actually scrubs on the initial read AND on every later patch.
  • No regression:
    • Tools still work (which tools/commands were run, result): pytest test/test_security_posture.py test/test_member_dashboard_field_push.py test/test_dashboard_package_owner_gate.py -q -p no:randomly -n 2 on this head, 115 passed, 0 failed, and the wider twenty-suite dashboard set on the rebased head 1001 passed. The dashboard read and the package save are the two paths these entries describe and both are exercised there.
    • Backward compatible (old config / old data / old callers still work, how checked): yes. Both lists are append-only here, no existing entry is edited or removed, so every module already registered keeps the same classification. An existing package, an existing instance record and an older gateway are unaffected, which test_allowlist_has_no_stale_entries checks from the other direction by failing on an entry that no longer matches a call site.
    • Existing tests (which suites passed on this head): the three suites above plus seventeen more on the rebased head, 1001 passed. Frontend: CrewDynamicDashboard.refetch.test.tsx 5 passed under KIROCREW_ACT_STRICT=1, plus the dashboard component set 59 passed, with tsc --noEmit and eslint clean.
  • How to undo: delete the two added entries from _REDACTION_SINKS and NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py. They are pure registry rows with no runtime caller, so removing them restores the previous audit exactly; the audit then fails on the two unregistered call sites, which is the state before this PR added those modules.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 1ff28a3
  • What rule changed: security_posture.py's REGISTRY of redaction boundaries, not any redactor, allowlist or scrub behaviour. One entry is added to _REDACTION_SINKS (field values pushed to a crewmate's dashboard page, produced in dashboard/handlers/member_dashboard_fields.py) and one to NON_EGRESS_REDACTION_MODULES (artifact_store/dashboard_package.py, which calls a redactor to CLASSIFY a field name rather than to emit text).
  • Before -> after (what was allowed/blocked, now): before, neither module existed, so neither was known to the posture audit. After, the value path is declared an egress sink, which means the audit REQUIRES it to scrub every value it produces and fails if it stops; and the package validator is declared non-egress, which means the audit does not require its redactor call to produce outbound text. Nothing that was blocked became allowed: no value reaches a page unscrubbed either side of this change.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the non-egress classification is the one that could leak. If dashboard_package.py did emit redacted content rather than only classifying, declaring it non-egress would exempt a real output boundary from the audit and a field name that redaction rewrites could reach a page unscrubbed. It does not emit: the redactor output is compared against the input, the package is REFUSED when they differ, and the redacted spelling appears only inside the refusal message. The sink entry has no leak shape at all, since registering a sink only adds an obligation.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and ::test_allowlist_has_no_stale_entries both pass on this head, which is the audit reading the registry against every real call site rather than this description being believed. test_member_dashboard_field_push.py::test_every_value_crosses_the_redactor_on_both_paths proves the registered sink actually scrubs on the initial read AND on every later patch.
  • No regression:
    • Tools still work (which tools/commands were run, result): pytest test/test_security_posture.py test/test_member_dashboard_field_push.py test/test_dashboard_package_owner_gate.py -q -p no:randomly -n 2 on this head, 115 passed, 0 failed, and the wider twenty-suite dashboard set on the rebased head 1001 passed. The dashboard read and the package save are the two paths these entries describe and both are exercised there.
    • Backward compatible (old config / old data / old callers still work, how checked): yes. Both lists are append-only here, no existing entry is edited or removed, so every module already registered keeps the same classification. An existing package, an existing instance record and an older gateway are unaffected, which test_allowlist_has_no_stale_entries checks from the other direction by failing on an entry that no longer matches a call site.
    • Existing tests (which suites passed on this head): the three suites above plus seventeen more on the rebased head, 1001 passed. Frontend: CrewDynamicDashboard.refetch.test.tsx 5 passed under KIROCREW_ACT_STRICT=1, plus the dashboard component set 59 passed, with tsc --noEmit and eslint clean.
  • How to undo: delete the two added entries from _REDACTION_SINKS and NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py. They are pure registry rows with no runtime caller, so removing them restores the previous audit exactly; the audit then fails on the two unregistered call sites, which is the state before this PR added those modules.

@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 merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 12, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 502d37d
  • What rule changed: security_posture.py's REGISTRY of redaction boundaries, not any redactor, allowlist or scrub behaviour. One entry is added to _REDACTION_SINKS (field values pushed to a crewmate's dashboard page, produced in dashboard/handlers/member_dashboard_fields.py) and one to NON_EGRESS_REDACTION_MODULES (artifact_store/dashboard_package.py, which calls a redactor to CLASSIFY a field name rather than to emit text).
  • Before -> after (what was allowed/blocked, now): before, neither module existed, so neither was known to the posture audit. After, the value path is declared an egress sink, which means the audit REQUIRES it to scrub every value it produces and fails if it stops; and the package validator is declared non-egress, which means the audit does not require its redactor call to produce outbound text. Nothing that was blocked became allowed: no value reaches a page unscrubbed either side of this change.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the non-egress classification is the one that could leak. If dashboard_package.py did emit redacted content rather than only classifying, declaring it non-egress would exempt a real output boundary from the audit and a field name that redaction rewrites could reach a page unscrubbed. It does not emit: the redactor output is compared against the input, the package is REFUSED when they differ, and the redacted spelling appears only inside the refusal message. The sink entry has no leak shape at all, since registering a sink only adds an obligation.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and ::test_allowlist_has_no_stale_entries both pass on this head, which is the audit reading the registry against every real call site rather than this description being believed. test_member_dashboard_field_push.py::test_every_value_crosses_the_redactor_on_both_paths proves the registered sink actually scrubs on the initial read AND on every later patch.
  • No regression:
    • Tools still work (which tools/commands were run, result): pytest test/test_security_posture.py test/test_member_dashboard_field_push.py test/test_dashboard_package_owner_gate.py -q -p no:randomly -n 2 on this head, 128 passed, 0 failed; the dashboard and artifact-store suites 2267 passed across thirty-nine suites on this head, and the publish and deploy suites 1147 passed on its immediate parent. The dashboard read and the package save are the two paths these entries describe and both are exercised there.
    • Backward compatible (old config / old data / old callers still work, how checked): yes. Both lists are append-only here, no existing entry is edited or removed, so every module already registered keeps the same classification. An existing package, an existing instance record and an older gateway are unaffected, which test_allowlist_has_no_stale_entries checks from the other direction by failing on an entry that no longer matches a call site.
    • Existing tests (which suites passed on this head): the three suites above plus thirty-six more on this head, 2267 passed. Frontend: the members and dashboard component set 892 passed in 34 files under KIROCREW_ACT_STRICT=1, with tsc --noEmit and eslint clean.
  • How to undo: delete the two added entries from _REDACTION_SINKS and NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py. They are pure registry rows with no runtime caller, so removing them restores the previous audit exactly; the audit then fails on the two unregistered call sites, which is the state before this PR added those modules.
  • This revision also narrows a write path rather than widening one: ArtifactStore.update now refuses a kind or content write that lands on a record whose CURRENT kind is dashboard unless it carries the content_token of the read it was authorized against, and an ABSENT token is a refusal. Five separate mutations of that clause each redden test_dashboard_package_owner_gate.py::TestAnUntokenedWriteCannotTakeADashboardOver and a run with the clause restored is green. Scoped to writes that can move a page to another owner, so publish_sync's snapshot bump and the deploy route's webapp_metadata write keep last-write-wins, which the 1147 publish and deploy tests above exercise.
  • One correction carried into this revision from the review of its parent: the fence and the caller's own expected_token are asked INDEPENDENTLY. Satisfying the fence with the handler's fresh read and then skipping the caller's compare-and-set would have let an owner's stale tab overwrite a newer layout with no 409, which is a guard REMOVED rather than added, so a content write carrying expected_token is now compared on every kind including this one. Collapsing the two back into one branch reddens test_the_fence_does_not_swallow_the_callers_own_stale_token.
  • This revision adds one more redaction boundary rather than relaxing any: binding_refusal now redacts every name it quotes -- the binding, the caller's crew, and a validation error's own value -- because _BOUND_TO_RE accepts a GitLab-PAT or Slack-bot shape and the named dashboard GET returns that sentence as its HTTP 403 body. Done inside the one function that composes these messages, not at the three routes that return them. Making the redaction identity reddens four of the five tests in TestTheOwnerRefusalRedactsEveryNameItQuotes; the fifth is the limit, which proves an ordinary name is still named. Also: the person's layout lock is now read BEFORE package selection, so a crewmate cannot move the tab off a locked page by writing its own artifact; removing that condition reddens test_the_persons_lock_outranks_the_crewmates_package.
  • This revision closes a crash rather than opening a path: stored_package_binding caught (ValueError, TypeError) from json.loads but not RecursionError, which is a RuntimeError -- so a markdown document beginning with { and nesting deeper than the decoder's stack made every later PATCH of that slug answer 500, including the one replacing it with plain text. It now answers None (not unprovable): the write path's own decoder refuses that depth, so no stored dashboard record can be this deep, and calling it unprovable would refuse every write to an ordinary document. Removing the new arm reddens test_a_document_too_deep_to_decode_is_not_a_package_and_does_not_raise with the exact RecursionError.
  • One rule in this revision YIELDS rather than adds: main's own api_artifact_update now validates a submitted binding's target (crew member exists, slug not shared, session live) and answers 400, so this change's broader owner gate is asked AFTER it instead of replacing all of those refusals with a single 403. Nothing is weakened -- the owner gate still refuses a worker rebinding another crewmate's page to a valid target, and the snapshot read it depends on still refuses an unreadable or absent record before either gate decides. One narrowing came with it: an app is identified by its id STRING, where any truthy value in request['app'] was read as one.
  • Two rules tightened in this revision, neither relaxed. The page's script grant was derived from the composed ceiling alone; it is now POLICY AND the owner's active PROFILE, asked through governance_permits (the one place the two are intersected) about an arbitrary host, because a page that runs script can navigate its own frame anywhere. An unresolvable profile withholds script, as an unreadable ceiling already did, and a ceiling that does not govern egress is no longer an answer on its own -- that early return was the standalone default, every install with no policy configured. Dropping the profile half reddens 2 tests in TestTheProfileIsAskedTooNotJustThePolicy. Separately, the applied version's bytes are now required to come from the same RECORD the approval was read from (created_at), because a slug is reusable and a version number restarts at 1; dropping that comparison reddens TestAnApprovalDoesNotAuthorizeAReplacement::test_a_recreated_record_renders_nothing.
  • The script grant tightened twice more in this revision, never loosened. It is resolved for the SURFACE the page belongs to (the crewmate's own slot), because without a session key the scope resolves to unknown and no surface-bound profile can match -- the intersection then fell back to policy alone. And the profile is tested by ARCHETYPE, the same shape test the ceiling gets, rather than by probing one host: a profile denying github.com permits every other name, so a permitted probe proved nothing about the restriction. Mutating the profile half to return True reddens 3 tests in TestTheProfileIsAskedTooNotJustThePolicy. The resolution also moved off the event loop (_run), since the profile store stats its directory and reloads what moved.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 80af05e
  • What rule changed: security_posture.py's REGISTRY of redaction boundaries, not any redactor, allowlist or scrub behaviour. One entry is added to _REDACTION_SINKS (field values pushed to a crewmate's dashboard page, produced in dashboard/handlers/member_dashboard_fields.py) and one to NON_EGRESS_REDACTION_MODULES (artifact_store/dashboard_package.py, which calls a redactor to CLASSIFY a field name rather than to emit text).
  • Before -> after (what was allowed/blocked, now): before, neither module existed, so neither was known to the posture audit. After, the value path is declared an egress sink, which means the audit REQUIRES it to scrub every value it produces and fails if it stops; and the package validator is declared non-egress, which means the audit does not require its redactor call to produce outbound text. Nothing that was blocked became allowed: no value reaches a page unscrubbed either side of this change.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the non-egress classification is the one that could leak. If dashboard_package.py did emit redacted content rather than only classifying, declaring it non-egress would exempt a real output boundary from the audit and a field name that redaction rewrites could reach a page unscrubbed. It does not emit: the redactor output is compared against the input, the package is REFUSED when they differ, and the redacted spelling appears only inside the refusal message. The sink entry has no leak shape at all, since registering a sink only adds an obligation.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and ::test_allowlist_has_no_stale_entries both pass on this head, which is the audit reading the registry against every real call site rather than this description being believed. test_member_dashboard_field_push.py::test_every_value_crosses_the_redactor_on_both_paths proves the registered sink actually scrubs on the initial read AND on every later patch.
  • No regression:
    • Tools still work (which tools/commands were run, result): pytest test/test_security_posture.py test/test_member_dashboard_field_push.py test/test_dashboard_package_owner_gate.py -q -p no:randomly -n 2 on this head, 128 passed, 0 failed; the dashboard and artifact-store suites 2267 passed across thirty-nine suites on this head, and the publish and deploy suites 1147 passed on its immediate parent. The dashboard read and the package save are the two paths these entries describe and both are exercised there.
    • Backward compatible (old config / old data / old callers still work, how checked): yes. Both lists are append-only here, no existing entry is edited or removed, so every module already registered keeps the same classification. An existing package, an existing instance record and an older gateway are unaffected, which test_allowlist_has_no_stale_entries checks from the other direction by failing on an entry that no longer matches a call site.
    • Existing tests (which suites passed on this head): the three suites above plus thirty-six more on this head, 2267 passed. Frontend: the members and dashboard component set 892 passed in 34 files under KIROCREW_ACT_STRICT=1, with tsc --noEmit and eslint clean.
  • How to undo: delete the two added entries from _REDACTION_SINKS and NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py. They are pure registry rows with no runtime caller, so removing them restores the previous audit exactly; the audit then fails on the two unregistered call sites, which is the state before this PR added those modules.
  • This revision also narrows a write path rather than widening one: ArtifactStore.update now refuses a kind or content write that lands on a record whose CURRENT kind is dashboard unless it carries the content_token of the read it was authorized against, and an ABSENT token is a refusal. Five separate mutations of that clause each redden test_dashboard_package_owner_gate.py::TestAnUntokenedWriteCannotTakeADashboardOver and a run with the clause restored is green. Scoped to writes that can move a page to another owner, so publish_sync's snapshot bump and the deploy route's webapp_metadata write keep last-write-wins, which the 1147 publish and deploy tests above exercise.
  • One correction carried into this revision from the review of its parent: the fence and the caller's own expected_token are asked INDEPENDENTLY. Satisfying the fence with the handler's fresh read and then skipping the caller's compare-and-set would have let an owner's stale tab overwrite a newer layout with no 409, which is a guard REMOVED rather than added, so a content write carrying expected_token is now compared on every kind including this one. Collapsing the two back into one branch reddens test_the_fence_does_not_swallow_the_callers_own_stale_token.
  • This revision adds one more redaction boundary rather than relaxing any: binding_refusal now redacts every name it quotes -- the binding, the caller's crew, and a validation error's own value -- because _BOUND_TO_RE accepts a GitLab-PAT or Slack-bot shape and the named dashboard GET returns that sentence as its HTTP 403 body. Done inside the one function that composes these messages, not at the three routes that return them. Making the redaction identity reddens four of the five tests in TestTheOwnerRefusalRedactsEveryNameItQuotes; the fifth is the limit, which proves an ordinary name is still named. Also: the person's layout lock is now read BEFORE package selection, so a crewmate cannot move the tab off a locked page by writing its own artifact; removing that condition reddens test_the_persons_lock_outranks_the_crewmates_package.
  • This revision closes a crash rather than opening a path: stored_package_binding caught (ValueError, TypeError) from json.loads but not RecursionError, which is a RuntimeError -- so a markdown document beginning with { and nesting deeper than the decoder's stack made every later PATCH of that slug answer 500, including the one replacing it with plain text. It now answers None (not unprovable): the write path's own decoder refuses that depth, so no stored dashboard record can be this deep, and calling it unprovable would refuse every write to an ordinary document. Removing the new arm reddens test_a_document_too_deep_to_decode_is_not_a_package_and_does_not_raise with the exact RecursionError.
  • One rule in this revision YIELDS rather than adds: main's own api_artifact_update now validates a submitted binding's target (crew member exists, slug not shared, session live) and answers 400, so this change's broader owner gate is asked AFTER it instead of replacing all of those refusals with a single 403. Nothing is weakened -- the owner gate still refuses a worker rebinding another crewmate's page to a valid target, and the snapshot read it depends on still refuses an unreadable or absent record before either gate decides. One narrowing came with it: an app is identified by its id STRING, where any truthy value in request['app'] was read as one.
  • Two rules tightened in this revision, neither relaxed. The page's script grant was derived from the composed ceiling alone; it is now POLICY AND the owner's active PROFILE, asked through governance_permits (the one place the two are intersected) about an arbitrary host, because a page that runs script can navigate its own frame anywhere. An unresolvable profile withholds script, as an unreadable ceiling already did, and a ceiling that does not govern egress is no longer an answer on its own -- that early return was the standalone default, every install with no policy configured. Dropping the profile half reddens 2 tests in TestTheProfileIsAskedTooNotJustThePolicy. Separately, the applied version's bytes are now required to come from the same RECORD the approval was read from (created_at), because a slug is reusable and a version number restarts at 1; dropping that comparison reddens TestAnApprovalDoesNotAuthorizeAReplacement::test_a_recreated_record_renders_nothing.
  • The script grant tightened twice more in this revision, never loosened. It is resolved for the SURFACE the page belongs to (the crewmate's own slot), because without a session key the scope resolves to unknown and no surface-bound profile can match -- the intersection then fell back to policy alone. And the profile is tested by ARCHETYPE, the same shape test the ceiling gets, rather than by probing one host: a profile denying github.com permits every other name, so a permitted probe proved nothing about the restriction. Mutating the profile half to return True reddens 3 tests in TestTheProfileIsAskedTooNotJustThePolicy. The resolution also moved off the event loop (_run), since the profile store stats its directory and reloads what moved.
  • The script grant's key is now built by one named function, member_dashboard.governance_session_key(slot), rather than assembled at the call site. A profile is bound to a SURFACE and the surface is read off this key's prefix: a crewmate's slot is a bare member-* string, which the canonical classifier sends to its Slack fallback, so a key built from the slot alone skipped every dashboard-bound profile. The product has no shared builder for this prefix -- it is spelled inline at about a dozen call sites -- so this is the dashboard handler's single spelling, and the test asks the CLASSIFIER what the key resolves to instead of comparing it to a literal. A profile bound to either surface a member page can run on withholds the grant, parameterised so adding a surface cannot leave one ungoverned.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 3a5025b
  • What rule changed: security_posture.py's REGISTRY of redaction boundaries, not any redactor, allowlist or scrub behaviour. One entry is added to _REDACTION_SINKS (field values pushed to a crewmate's dashboard page, produced in dashboard/handlers/member_dashboard_fields.py) and one to NON_EGRESS_REDACTION_MODULES (artifact_store/dashboard_package.py, which calls a redactor to CLASSIFY a field name rather than to emit text).
  • Before -> after (what was allowed/blocked, now): before, neither module existed, so neither was known to the posture audit. After, the value path is declared an egress sink, which means the audit REQUIRES it to scrub every value it produces and fails if it stops; and the package validator is declared non-egress, which means the audit does not require its redactor call to produce outbound text. Nothing that was blocked became allowed: no value reaches a page unscrubbed either side of this change.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the non-egress classification is the one that could leak. If dashboard_package.py did emit redacted content rather than only classifying, declaring it non-egress would exempt a real output boundary from the audit and a field name that redaction rewrites could reach a page unscrubbed. It does not emit: the redactor output is compared against the input, the package is REFUSED when they differ, and the redacted spelling appears only inside the refusal message. The sink entry has no leak shape at all, since registering a sink only adds an obligation.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and ::test_allowlist_has_no_stale_entries both pass on this head, which is the audit reading the registry against every real call site rather than this description being believed. test_member_dashboard_field_push.py::test_every_value_crosses_the_redactor_on_both_paths proves the registered sink actually scrubs on the initial read AND on every later patch.
  • No regression:
    • Tools still work (which tools/commands were run, result): pytest test/test_security_posture.py test/test_member_dashboard_field_push.py test/test_dashboard_package_owner_gate.py -q -p no:randomly -n 2 on this head, 128 passed, 0 failed; the dashboard and artifact-store suites 2267 passed across thirty-nine suites on this head, and the publish and deploy suites 1147 passed on its immediate parent. The dashboard read and the package save are the two paths these entries describe and both are exercised there.
    • Backward compatible (old config / old data / old callers still work, how checked): yes. Both lists are append-only here, no existing entry is edited or removed, so every module already registered keeps the same classification. An existing package, an existing instance record and an older gateway are unaffected, which test_allowlist_has_no_stale_entries checks from the other direction by failing on an entry that no longer matches a call site.
    • Existing tests (which suites passed on this head): the three suites above plus thirty-six more on this head, 2267 passed. Frontend: the members and dashboard component set 892 passed in 34 files under KIROCREW_ACT_STRICT=1, with tsc --noEmit and eslint clean.
  • How to undo: delete the two added entries from _REDACTION_SINKS and NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py. They are pure registry rows with no runtime caller, so removing them restores the previous audit exactly; the audit then fails on the two unregistered call sites, which is the state before this PR added those modules.
  • This revision also narrows a write path rather than widening one: ArtifactStore.update now refuses a kind or content write that lands on a record whose CURRENT kind is dashboard unless it carries the content_token of the read it was authorized against, and an ABSENT token is a refusal. Five separate mutations of that clause each redden test_dashboard_package_owner_gate.py::TestAnUntokenedWriteCannotTakeADashboardOver and a run with the clause restored is green. Scoped to writes that can move a page to another owner, so publish_sync's snapshot bump and the deploy route's webapp_metadata write keep last-write-wins, which the 1147 publish and deploy tests above exercise.
  • One correction carried into this revision from the review of its parent: the fence and the caller's own expected_token are asked INDEPENDENTLY. Satisfying the fence with the handler's fresh read and then skipping the caller's compare-and-set would have let an owner's stale tab overwrite a newer layout with no 409, which is a guard REMOVED rather than added, so a content write carrying expected_token is now compared on every kind including this one. Collapsing the two back into one branch reddens test_the_fence_does_not_swallow_the_callers_own_stale_token.
  • This revision adds one more redaction boundary rather than relaxing any: binding_refusal now redacts every name it quotes -- the binding, the caller's crew, and a validation error's own value -- because _BOUND_TO_RE accepts a GitLab-PAT or Slack-bot shape and the named dashboard GET returns that sentence as its HTTP 403 body. Done inside the one function that composes these messages, not at the three routes that return them. Making the redaction identity reddens four of the five tests in TestTheOwnerRefusalRedactsEveryNameItQuotes; the fifth is the limit, which proves an ordinary name is still named. Also: the person's layout lock is now read BEFORE package selection, so a crewmate cannot move the tab off a locked page by writing its own artifact; removing that condition reddens test_the_persons_lock_outranks_the_crewmates_package.
  • This revision closes a crash rather than opening a path: stored_package_binding caught (ValueError, TypeError) from json.loads but not RecursionError, which is a RuntimeError -- so a markdown document beginning with { and nesting deeper than the decoder's stack made every later PATCH of that slug answer 500, including the one replacing it with plain text. It now answers None (not unprovable): the write path's own decoder refuses that depth, so no stored dashboard record can be this deep, and calling it unprovable would refuse every write to an ordinary document. Removing the new arm reddens test_a_document_too_deep_to_decode_is_not_a_package_and_does_not_raise with the exact RecursionError.
  • One rule in this revision YIELDS rather than adds: main's own api_artifact_update now validates a submitted binding's target (crew member exists, slug not shared, session live) and answers 400, so this change's broader owner gate is asked AFTER it instead of replacing all of those refusals with a single 403. Nothing is weakened -- the owner gate still refuses a worker rebinding another crewmate's page to a valid target, and the snapshot read it depends on still refuses an unreadable or absent record before either gate decides. One narrowing came with it: an app is identified by its id STRING, where any truthy value in request['app'] was read as one.
  • Two rules tightened in this revision, neither relaxed. The page's script grant was derived from the composed ceiling alone; it is now POLICY AND the owner's active PROFILE, asked through governance_permits (the one place the two are intersected) about an arbitrary host, because a page that runs script can navigate its own frame anywhere. An unresolvable profile withholds script, as an unreadable ceiling already did, and a ceiling that does not govern egress is no longer an answer on its own -- that early return was the standalone default, every install with no policy configured. Dropping the profile half reddens 2 tests in TestTheProfileIsAskedTooNotJustThePolicy. Separately, the applied version's bytes are now required to come from the same RECORD the approval was read from (created_at), because a slug is reusable and a version number restarts at 1; dropping that comparison reddens TestAnApprovalDoesNotAuthorizeAReplacement::test_a_recreated_record_renders_nothing.
  • The script grant tightened twice more in this revision, never loosened. It is resolved for the SURFACE the page belongs to (the crewmate's own slot), because without a session key the scope resolves to unknown and no surface-bound profile can match -- the intersection then fell back to policy alone. And the profile is tested by ARCHETYPE, the same shape test the ceiling gets, rather than by probing one host: a profile denying github.com permits every other name, so a permitted probe proved nothing about the restriction. Mutating the profile half to return True reddens 3 tests in TestTheProfileIsAskedTooNotJustThePolicy. The resolution also moved off the event loop (_run), since the profile store stats its directory and reloads what moved.
  • The script grant's key is now built by one named function, member_dashboard.governance_session_key(slot), rather than assembled at the call site. A profile is bound to a SURFACE and the surface is read off this key's prefix: a crewmate's slot is a bare member-* string, which the canonical classifier sends to its Slack fallback, so a key built from the slot alone skipped every dashboard-bound profile. The product has no shared builder for this prefix -- it is spelled inline at about a dozen call sites -- so this is the dashboard handler's single spelling, and the test asks the CLASSIFIER what the key resolves to instead of comparing it to a literal. A profile bound to either surface a member page can run on withholds the grant, parameterised so adding a surface cannot leave one ungoverned.
  • One more redaction boundary, swept across every site this change adds rather than the one that was reported: a validation or conflict exception's text now goes through redact_via_context before it becomes an HTTP body. Three sites -- the applied package's parse_package refusal, the frame-compose refusal, and the save path's ArtifactConflictError. The first two quote the value or binding the validator refused, and a stored snapshot's values are not re-validated by whoever wrote them; the third names the SLUG, which is [a-z0-9-] and so cannot be a ghp_ but can be an xoxb- or a glpat- -- the same shapes the named-package read already refuses for. Pre-existing sites outside this change are left alone.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 37129cc
  • What rule changed: security_posture.py's REGISTRY of redaction boundaries, not any redactor, allowlist or scrub behaviour. One entry is added to _REDACTION_SINKS (field values pushed to a crewmate's dashboard page, produced in dashboard/handlers/member_dashboard_fields.py) and one to NON_EGRESS_REDACTION_MODULES (artifact_store/dashboard_package.py, which calls a redactor to CLASSIFY a field name rather than to emit text).
  • Before -> after (what was allowed/blocked, now): before, neither module existed, so neither was known to the posture audit. After, the value path is declared an egress sink, which means the audit REQUIRES it to scrub every value it produces and fails if it stops; and the package validator is declared non-egress, which means the audit does not require its redactor call to produce outbound text. Nothing that was blocked became allowed: no value reaches a page unscrubbed either side of this change.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the non-egress classification is the one that could leak. If dashboard_package.py did emit redacted content rather than only classifying, declaring it non-egress would exempt a real output boundary from the audit and a field name that redaction rewrites could reach a page unscrubbed. It does not emit: the redactor output is compared against the input, the package is REFUSED when they differ, and the redacted spelling appears only inside the refusal message. The sink entry has no leak shape at all, since registering a sink only adds an obligation.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and ::test_allowlist_has_no_stale_entries both pass on this head, which is the audit reading the registry against every real call site rather than this description being believed. test_member_dashboard_field_push.py::test_every_value_crosses_the_redactor_on_both_paths proves the registered sink actually scrubs on the initial read AND on every later patch.
  • No regression:
    • Tools still work (which tools/commands were run, result): pytest test/test_security_posture.py test/test_member_dashboard_field_push.py test/test_dashboard_package_owner_gate.py -q -p no:randomly -n 2 on this head, 128 passed, 0 failed; the dashboard and artifact-store suites 2267 passed across thirty-nine suites on this head, and the publish and deploy suites 1147 passed on its immediate parent. The dashboard read and the package save are the two paths these entries describe and both are exercised there.
    • Backward compatible (old config / old data / old callers still work, how checked): yes. Both lists are append-only here, no existing entry is edited or removed, so every module already registered keeps the same classification. An existing package, an existing instance record and an older gateway are unaffected, which test_allowlist_has_no_stale_entries checks from the other direction by failing on an entry that no longer matches a call site.
    • Existing tests (which suites passed on this head): the three suites above plus thirty-six more on this head, 2267 passed. Frontend: the members and dashboard component set 892 passed in 34 files under KIROCREW_ACT_STRICT=1, with tsc --noEmit and eslint clean.
  • How to undo: delete the two added entries from _REDACTION_SINKS and NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py. They are pure registry rows with no runtime caller, so removing them restores the previous audit exactly; the audit then fails on the two unregistered call sites, which is the state before this PR added those modules.
  • This revision also narrows a write path rather than widening one: ArtifactStore.update now refuses a kind or content write that lands on a record whose CURRENT kind is dashboard unless it carries the content_token of the read it was authorized against, and an ABSENT token is a refusal. Five separate mutations of that clause each redden test_dashboard_package_owner_gate.py::TestAnUntokenedWriteCannotTakeADashboardOver and a run with the clause restored is green. Scoped to writes that can move a page to another owner, so publish_sync's snapshot bump and the deploy route's webapp_metadata write keep last-write-wins, which the 1147 publish and deploy tests above exercise.
  • One correction carried into this revision from the review of its parent: the fence and the caller's own expected_token are asked INDEPENDENTLY. Satisfying the fence with the handler's fresh read and then skipping the caller's compare-and-set would have let an owner's stale tab overwrite a newer layout with no 409, which is a guard REMOVED rather than added, so a content write carrying expected_token is now compared on every kind including this one. Collapsing the two back into one branch reddens test_the_fence_does_not_swallow_the_callers_own_stale_token.
  • This revision adds one more redaction boundary rather than relaxing any: binding_refusal now redacts every name it quotes -- the binding, the caller's crew, and a validation error's own value -- because _BOUND_TO_RE accepts a GitLab-PAT or Slack-bot shape and the named dashboard GET returns that sentence as its HTTP 403 body. Done inside the one function that composes these messages, not at the three routes that return them. Making the redaction identity reddens four of the five tests in TestTheOwnerRefusalRedactsEveryNameItQuotes; the fifth is the limit, which proves an ordinary name is still named. Also: the person's layout lock is now read BEFORE package selection, so a crewmate cannot move the tab off a locked page by writing its own artifact; removing that condition reddens test_the_persons_lock_outranks_the_crewmates_package.
  • This revision closes a crash rather than opening a path: stored_package_binding caught (ValueError, TypeError) from json.loads but not RecursionError, which is a RuntimeError -- so a markdown document beginning with { and nesting deeper than the decoder's stack made every later PATCH of that slug answer 500, including the one replacing it with plain text. It now answers None (not unprovable): the write path's own decoder refuses that depth, so no stored dashboard record can be this deep, and calling it unprovable would refuse every write to an ordinary document. Removing the new arm reddens test_a_document_too_deep_to_decode_is_not_a_package_and_does_not_raise with the exact RecursionError.
  • One rule in this revision YIELDS rather than adds: main's own api_artifact_update now validates a submitted binding's target (crew member exists, slug not shared, session live) and answers 400, so this change's broader owner gate is asked AFTER it instead of replacing all of those refusals with a single 403. Nothing is weakened -- the owner gate still refuses a worker rebinding another crewmate's page to a valid target, and the snapshot read it depends on still refuses an unreadable or absent record before either gate decides. One narrowing came with it: an app is identified by its id STRING, where any truthy value in request['app'] was read as one.
  • Two rules tightened in this revision, neither relaxed. The page's script grant was derived from the composed ceiling alone; it is now POLICY AND the owner's active PROFILE, asked through governance_permits (the one place the two are intersected) about an arbitrary host, because a page that runs script can navigate its own frame anywhere. An unresolvable profile withholds script, as an unreadable ceiling already did, and a ceiling that does not govern egress is no longer an answer on its own -- that early return was the standalone default, every install with no policy configured. Dropping the profile half reddens 2 tests in TestTheProfileIsAskedTooNotJustThePolicy. Separately, the applied version's bytes are now required to come from the same RECORD the approval was read from (created_at), because a slug is reusable and a version number restarts at 1; dropping that comparison reddens TestAnApprovalDoesNotAuthorizeAReplacement::test_a_recreated_record_renders_nothing.
  • The script grant tightened twice more in this revision, never loosened. It is resolved for the SURFACE the page belongs to (the crewmate's own slot), because without a session key the scope resolves to unknown and no surface-bound profile can match -- the intersection then fell back to policy alone. And the profile is tested by ARCHETYPE, the same shape test the ceiling gets, rather than by probing one host: a profile denying github.com permits every other name, so a permitted probe proved nothing about the restriction. Mutating the profile half to return True reddens 3 tests in TestTheProfileIsAskedTooNotJustThePolicy. The resolution also moved off the event loop (_run), since the profile store stats its directory and reloads what moved.
  • The script grant's key is now built by one named function, member_dashboard.governance_session_key(slot), rather than assembled at the call site. A profile is bound to a SURFACE and the surface is read off this key's prefix: a crewmate's slot is a bare member-* string, which the canonical classifier sends to its Slack fallback, so a key built from the slot alone skipped every dashboard-bound profile. The product has no shared builder for this prefix -- it is spelled inline at about a dozen call sites -- so this is the dashboard handler's single spelling, and the test asks the CLASSIFIER what the key resolves to instead of comparing it to a literal. A profile bound to either surface a member page can run on withholds the grant, parameterised so adding a surface cannot leave one ungoverned.
  • One more redaction boundary, swept across every site this change adds rather than the one that was reported: a validation or conflict exception's text now goes through redact_via_context before it becomes an HTTP body. Three sites -- the applied package's parse_package refusal, the frame-compose refusal, and the save path's ArtifactConflictError. The first two quote the value or binding the validator refused, and a stored snapshot's values are not re-validated by whoever wrote them; the third names the SLUG, which is [a-z0-9-] and so cannot be a ghp_ but can be an xoxb- or a glpat- -- the same shapes the named-package read already refuses for. Pre-existing sites outside this change are left alone.
  • This revision refuses a caller the gate previously authorized, and authorizes nobody new: binding_refusal asks the roster how many crewmates resolve to the binding's slug before comparing the caller against it. Slugification is lossy, so a hand-edited roster holding both Atlas and atlas derives one slug from two names, and comparing the caller's slug to the binding's then let EITHER of them write the other's package -- the page that runs script inside the owner's own fold values. More than one owner refuses as dashboard_slug_ambiguous and never picks; the remedy named in the sentence is a person renaming one of them, the same remedy the serve-time refusal already gives. The count comes from dashboard.handlers.members._member_names_for_slug, the roster's own answer that _crewmate_binding_refusal and member_dashboard._resolve already ask, so this is not a fourth spelling of the rule. Mutating len(owners) > 1 to a constant false reddens test_a_slug_two_crews_resolve_to_authorizes_neither for both callers; a roster with one owner still writes its own page, which test_an_unambiguous_owner_is_unaffected_by_the_count pins as the boundary. Evidence on this head: test_dashboard_package_owner_gate.py 78 passed, and the seventeen suites this PR touches 1210 passed. To undo, delete the owners count and its refusal branch from binding_refusal; the comparison below it is unchanged.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

/ai-review override gpt 37129cc: Not a new exposure. main already returns this exact unredacted message at artifacts.py:1272; this PR adds a second copy of it for the snapshot path. The slug in the 409 is the one the caller put in its own request URL, and the route is owner-gated (handlers/artifacts.py:2178), so the only reader is the owner who sent it. Adjudication flagged it as an edge case for the same reason. Redacting both copies, including main's, is a one-line follow-up PR.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@chenmingwei23 marked the gpt AI finding as false positive, not applicable, or explicitly accepted for 37129cc4594b968bd039fd21930b8d84202c6e54.

Not a new exposure. main already returns this exact unredacted message at artifacts.py:1272; this PR adds a second copy of it for the snapshot path. The slug in the 409 is the one the caller put in its own request URL, and the route is owner-gated (handlers/artifacts.py:2178), so the only reader is the owner who sent it. Adjudication flagged it as an edge case for the same reason. Redacting both copies, including main's, is a one-line follow-up PR.

This decision applies only to this commit. A new push requires a new judgment.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 37129cc
  • What rule changed: security_posture.py's REGISTRY of redaction boundaries, not any redactor, allowlist or scrub behaviour. One entry is added to _REDACTION_SINKS (field values pushed to a crewmate's dashboard page, produced in dashboard/handlers/member_dashboard_fields.py) and one to NON_EGRESS_REDACTION_MODULES (artifact_store/dashboard_package.py, which calls a redactor to CLASSIFY a field name rather than to emit text).
  • Before -> after (what was allowed/blocked, now): before, neither module existed, so neither was known to the posture audit. After, the value path is declared an egress sink, which means the audit REQUIRES it to scrub every value it produces and fails if it stops; and the package validator is declared non-egress, which means the audit does not require its redactor call to produce outbound text. Nothing that was blocked became allowed: no value reaches a page unscrubbed either side of this change.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the non-egress classification is the one that could leak. If dashboard_package.py did emit redacted content rather than only classifying, declaring it non-egress would exempt a real output boundary from the audit and a field name that redaction rewrites could reach a page unscrubbed. It does not emit: the redactor output is compared against the input, the package is REFUSED when they differ, and the redacted spelling appears only inside the refusal message. The sink entry has no leak shape at all, since registering a sink only adds an obligation.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and ::test_allowlist_has_no_stale_entries both pass on this head, which is the audit reading the registry against every real call site rather than this description being believed. test_member_dashboard_field_push.py::test_every_value_crosses_the_redactor_on_both_paths proves the registered sink actually scrubs on the initial read AND on every later patch.
  • No regression:
    • Tools still work (which tools/commands were run, result): every number below was measured on THIS head, not carried from a parent. pytest test/test_security_posture.py test/test_member_dashboard_field_push.py test/test_dashboard_package_owner_gate.py -q -p no:randomly -n 2: 152 passed, 0 failed. Every suite that names dashboard_package, binding_refusal, _member_names_for_slug, resolve_bound_slug or artifact_store, twenty-five of them: 1930 passed, 0 failed. The publish and deploy suites, fifty-nine of them: 1147 passed, 1 skipped, 0 failed. The dashboard read and the package save are the two paths these entries describe and both are exercised there.
    • Backward compatible (old config / old data / old callers still work, how checked): yes. Both lists are append-only here, no existing entry is edited or removed, so every module already registered keeps the same classification. An existing package, an existing instance record and an older gateway are unaffected, which test_allowlist_has_no_stale_entries checks from the other direction by failing on an entry that no longer matches a call site.
    • Existing tests (which suites passed on this head): the three suites above plus the twenty-five and the fifty-nine named there, all on this head. Frontend: the members and dashboard component set, 43 files, 874 passed and 1 failed under KIROCREW_ACT_STRICT=1, with tsc --noEmit and eslint src --max-warnings=0 both clean. That one failure is not this change's and not a lane red: it is two React act() warnings in website/src/test/CrewDynamicDashboard.test.tsx, a file this PR's diff against main does not touch at all and whose failing case main already carries. KIROCREW_ACT_STRICT=1 is an opt-in local strictness no workflow sets -- integration/setup.ts reports those warnings and does not fail the run without it -- so all four Frontend Tests shards, Frontend Lint & Type Check and Frontend Coverage Merge are green on this head. Reading the newest run per lane, the only non-success on this head is E2E Gateway Boot (ubuntu-latest), a repo-wide 60-second boot timeout hitting five other open PRs whose Windows siblings boot fine.
  • How to undo: delete the two added entries from _REDACTION_SINKS and NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py. They are pure registry rows with no runtime caller, so removing them restores the previous audit exactly; the audit then fails on the two unregistered call sites, which is the state before this PR added those modules.
  • This revision also narrows a write path rather than widening one: ArtifactStore.update now refuses a kind or content write that lands on a record whose CURRENT kind is dashboard unless it carries the content_token of the read it was authorized against, and an ABSENT token is a refusal. Five separate mutations of that clause each redden test_dashboard_package_owner_gate.py::TestAnUntokenedWriteCannotTakeADashboardOver and a run with the clause restored is green. Scoped to writes that can move a page to another owner, so publish_sync's snapshot bump and the deploy route's webapp_metadata write keep last-write-wins, which the 1147 publish and deploy tests above exercise.
  • One correction carried into this revision from the review of its parent: the fence and the caller's own expected_token are asked INDEPENDENTLY. Satisfying the fence with the handler's fresh read and then skipping the caller's compare-and-set would have let an owner's stale tab overwrite a newer layout with no 409, which is a guard REMOVED rather than added, so a content write carrying expected_token is now compared on every kind including this one. Collapsing the two back into one branch reddens test_the_fence_does_not_swallow_the_callers_own_stale_token.
  • This revision adds one more redaction boundary rather than relaxing any: binding_refusal now redacts every name it quotes -- the binding, the caller's crew, and a validation error's own value -- because _BOUND_TO_RE accepts a GitLab-PAT or Slack-bot shape and the named dashboard GET returns that sentence as its HTTP 403 body. Done inside the one function that composes these messages, not at the three routes that return them. Making the redaction identity reddens four of the five tests in TestTheOwnerRefusalRedactsEveryNameItQuotes; the fifth is the limit, which proves an ordinary name is still named. Also: the person's layout lock is now read BEFORE package selection, so a crewmate cannot move the tab off a locked page by writing its own artifact; removing that condition reddens test_the_persons_lock_outranks_the_crewmates_package.
  • This revision closes a crash rather than opening a path: stored_package_binding caught (ValueError, TypeError) from json.loads but not RecursionError, which is a RuntimeError -- so a markdown document beginning with { and nesting deeper than the decoder's stack made every later PATCH of that slug answer 500, including the one replacing it with plain text. It now answers None (not unprovable): the write path's own decoder refuses that depth, so no stored dashboard record can be this deep, and calling it unprovable would refuse every write to an ordinary document. Removing the new arm reddens test_a_document_too_deep_to_decode_is_not_a_package_and_does_not_raise with the exact RecursionError.
  • One rule in this revision YIELDS rather than adds: main's own api_artifact_update now validates a submitted binding's target (crew member exists, slug not shared, session live) and answers 400, so this change's broader owner gate is asked AFTER it instead of replacing all of those refusals with a single 403. Nothing is weakened -- the owner gate still refuses a worker rebinding another crewmate's page to a valid target, and the snapshot read it depends on still refuses an unreadable or absent record before either gate decides. One narrowing came with it: an app is identified by its id STRING, where any truthy value in request['app'] was read as one.
  • Two rules tightened in this revision, neither relaxed. The page's script grant was derived from the composed ceiling alone; it is now POLICY AND the owner's active PROFILE, asked through governance_permits (the one place the two are intersected) about an arbitrary host, because a page that runs script can navigate its own frame anywhere. An unresolvable profile withholds script, as an unreadable ceiling already did, and a ceiling that does not govern egress is no longer an answer on its own -- that early return was the standalone default, every install with no policy configured. Dropping the profile half reddens 2 tests in TestTheProfileIsAskedTooNotJustThePolicy. Separately, the applied version's bytes are now required to come from the same RECORD the approval was read from (created_at), because a slug is reusable and a version number restarts at 1; dropping that comparison reddens TestAnApprovalDoesNotAuthorizeAReplacement::test_a_recreated_record_renders_nothing.
  • The script grant tightened twice more in this revision, never loosened. It is resolved for the SURFACE the page belongs to (the crewmate's own slot), because without a session key the scope resolves to unknown and no surface-bound profile can match -- the intersection then fell back to policy alone. And the profile is tested by ARCHETYPE, the same shape test the ceiling gets, rather than by probing one host: a profile denying github.com permits every other name, so a permitted probe proved nothing about the restriction. Mutating the profile half to return True reddens 3 tests in TestTheProfileIsAskedTooNotJustThePolicy. The resolution also moved off the event loop (_run), since the profile store stats its directory and reloads what moved.
  • The script grant's key is now built by one named function, member_dashboard.governance_session_key(slot), rather than assembled at the call site. A profile is bound to a SURFACE and the surface is read off this key's prefix: a crewmate's slot is a bare member-* string, which the canonical classifier sends to its Slack fallback, so a key built from the slot alone skipped every dashboard-bound profile. The product has no shared builder for this prefix -- it is spelled inline at about a dozen call sites -- so this is the dashboard handler's single spelling, and the test asks the CLASSIFIER what the key resolves to instead of comparing it to a literal. A profile bound to either surface a member page can run on withholds the grant, parameterised so adding a surface cannot leave one ungoverned.
  • One more redaction boundary, swept across every site this change adds rather than the one that was reported: a validation or conflict exception's text now goes through redact_via_context before it becomes an HTTP body. Three sites -- the applied package's parse_package refusal, the frame-compose refusal, and the save path's ArtifactConflictError. The first two quote the value or binding the validator refused, and a stored snapshot's values are not re-validated by whoever wrote them; the third names the SLUG, which is [a-z0-9-] and so cannot be a ghp_ but can be an xoxb- or a glpat- -- the same shapes the named-package read already refuses for. Pre-existing sites outside this change are left alone.
  • This revision refuses a caller the gate previously authorized, and authorizes nobody new: binding_refusal asks the roster how many crewmates resolve to the binding's slug before comparing the caller against it. Slugification is lossy, so a hand-edited roster holding both Atlas and atlas derives one slug from two names, and comparing the caller's slug to the binding's then let EITHER of them write the other's package -- the page that runs script inside the owner's own fold values. More than one owner refuses as dashboard_slug_ambiguous and never picks; the remedy named in the sentence is a person renaming one of them, the same remedy the serve-time refusal already gives. The count comes from dashboard.handlers.members._member_names_for_slug, the roster's own answer that _crewmate_binding_refusal and member_dashboard._resolve already ask, so this is not a fourth spelling of the rule. Mutating len(owners) > 1 to a constant false reddens test_a_slug_two_crews_resolve_to_authorizes_neither for both callers; a roster with one owner still writes its own page, which test_an_unambiguous_owner_is_unaffected_by_the_count pins as the boundary. Evidence on this head: test_dashboard_package_owner_gate.py 78 passed, and the twenty-five suites that reach this module 1930 passed. To undo, delete the owners count and its refusal branch from binding_refusal; the comparison below it is unchanged.

iamwhatever
iamwhatever previously approved these changes Oct 13, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 725de10
  • What rule changed: security_posture.py's REGISTRY of redaction boundaries, not any redactor, allowlist or scrub behaviour. One entry is added to _REDACTION_SINKS (field values pushed to a crewmate's dashboard page, produced in dashboard/handlers/member_dashboard_fields.py) and one to NON_EGRESS_REDACTION_MODULES (artifact_store/dashboard_package.py, which calls a redactor to CLASSIFY a field name rather than to emit text).
  • Before -> after (what was allowed/blocked, now): before, neither module existed, so neither was known to the posture audit. After, the value path is declared an egress sink, which means the audit REQUIRES it to scrub every value it produces and fails if it stops; and the package validator is declared non-egress, which means the audit does not require its redactor call to produce outbound text. Nothing that was blocked became allowed: no value reaches a page unscrubbed either side of this change.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the non-egress classification is the one that could leak. If dashboard_package.py did emit redacted content rather than only classifying, declaring it non-egress would exempt a real output boundary from the audit and a field name that redaction rewrites could reach a page unscrubbed. It does not emit: the redactor output is compared against the input, the package is REFUSED when they differ, and the redacted spelling appears only inside the refusal message. The sink entry has no leak shape at all, since registering a sink only adds an obligation.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and ::test_allowlist_has_no_stale_entries both pass on this head, which is the audit reading the registry against every real call site rather than this description being believed. test_member_dashboard_field_push.py::test_every_value_crosses_the_redactor_on_both_paths proves the registered sink actually scrubs on the initial read AND on every later patch.
  • No regression:
    • Tools still work (which tools/commands were run, result): every number below was measured on THIS head, not carried from a parent. every suite that names dashboard_package, binding_refusal, _member_names_for_slug, resolve_bound_slug or artifact_store, twenty-six of them: 1954 passed, 1 failed. The seventeen suites this change touches: 1210 passed, 0 failed. The composition contract: 109 passed. The four integrated dashboard PRs' own suites, fifteen of them: 1003 passed, 1 failed. BOTH failures are the same single test, named in the rebase note at the end of this comment; nothing else in this change is red. The dashboard read and the package save are the two paths these entries describe and both are exercised there.
    • Backward compatible (old config / old data / old callers still work, how checked): yes. Both lists are append-only here, no existing entry is edited or removed, so every module already registered keeps the same classification. An existing package, an existing instance record and an older gateway are unaffected, which test_allowlist_has_no_stale_entries checks from the other direction by failing on an entry that no longer matches a call site.
    • Existing tests (which suites passed on this head): the twenty-six, the seventeen and the fifteen named above, all on this head. Frontend: the members, dashboard, websocket, api-client and preview-surface set, 369 files, 5844 passed and 0 failed, with tsc --noEmit and eslint src --max-warnings=0 both clean. That one failure is not this change's and not a lane red: it is two React act() warnings in website/src/test/CrewDynamicDashboard.test.tsx, a file this PR's diff against main does not touch at all and whose failing case main already carries. KIROCREW_ACT_STRICT=1 is an opt-in local strictness no workflow sets -- integration/setup.ts reports those warnings and does not fail the run without it -- so all four Frontend Tests shards, Frontend Lint & Type Check and Frontend Coverage Merge are green on this head. Reading the newest run per lane, the only non-success on this head is E2E Gateway Boot (ubuntu-latest), a repo-wide 60-second boot timeout hitting five other open PRs whose Windows siblings boot fine.
  • How to undo: delete the two added entries from _REDACTION_SINKS and NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py. They are pure registry rows with no runtime caller, so removing them restores the previous audit exactly; the audit then fails on the two unregistered call sites, which is the state before this PR added those modules.
  • This revision also narrows a write path rather than widening one: ArtifactStore.update now refuses a kind or content write that lands on a record whose CURRENT kind is dashboard unless it carries the content_token of the read it was authorized against, and an ABSENT token is a refusal. Five separate mutations of that clause each redden test_dashboard_package_owner_gate.py::TestAnUntokenedWriteCannotTakeADashboardOver and a run with the clause restored is green. Scoped to writes that can move a page to another owner, so publish_sync's snapshot bump and the deploy route's webapp_metadata write keep last-write-wins, which the 1147 publish and deploy tests above exercise.
  • One correction carried into this revision from the review of its parent: the fence and the caller's own expected_token are asked INDEPENDENTLY. Satisfying the fence with the handler's fresh read and then skipping the caller's compare-and-set would have let an owner's stale tab overwrite a newer layout with no 409, which is a guard REMOVED rather than added, so a content write carrying expected_token is now compared on every kind including this one. Collapsing the two back into one branch reddens test_the_fence_does_not_swallow_the_callers_own_stale_token.
  • This revision adds one more redaction boundary rather than relaxing any: binding_refusal now redacts every name it quotes -- the binding, the caller's crew, and a validation error's own value -- because _BOUND_TO_RE accepts a GitLab-PAT or Slack-bot shape and the named dashboard GET returns that sentence as its HTTP 403 body. Done inside the one function that composes these messages, not at the three routes that return them. Making the redaction identity reddens four of the five tests in TestTheOwnerRefusalRedactsEveryNameItQuotes; the fifth is the limit, which proves an ordinary name is still named. Also: the person's layout lock is now read BEFORE package selection, so a crewmate cannot move the tab off a locked page by writing its own artifact; removing that condition reddens test_the_persons_lock_outranks_the_crewmates_package.
  • This revision closes a crash rather than opening a path: stored_package_binding caught (ValueError, TypeError) from json.loads but not RecursionError, which is a RuntimeError -- so a markdown document beginning with { and nesting deeper than the decoder's stack made every later PATCH of that slug answer 500, including the one replacing it with plain text. It now answers None (not unprovable): the write path's own decoder refuses that depth, so no stored dashboard record can be this deep, and calling it unprovable would refuse every write to an ordinary document. Removing the new arm reddens test_a_document_too_deep_to_decode_is_not_a_package_and_does_not_raise with the exact RecursionError.
  • One rule in this revision YIELDS rather than adds: main's own api_artifact_update now validates a submitted binding's target (crew member exists, slug not shared, session live) and answers 400, so this change's broader owner gate is asked AFTER it instead of replacing all of those refusals with a single 403. Nothing is weakened -- the owner gate still refuses a worker rebinding another crewmate's page to a valid target, and the snapshot read it depends on still refuses an unreadable or absent record before either gate decides. One narrowing came with it: an app is identified by its id STRING, where any truthy value in request['app'] was read as one.
  • Two rules tightened in this revision, neither relaxed. The page's script grant was derived from the composed ceiling alone; it is now POLICY AND the owner's active PROFILE, asked through governance_permits (the one place the two are intersected) about an arbitrary host, because a page that runs script can navigate its own frame anywhere. An unresolvable profile withholds script, as an unreadable ceiling already did, and a ceiling that does not govern egress is no longer an answer on its own -- that early return was the standalone default, every install with no policy configured. Dropping the profile half reddens 2 tests in TestTheProfileIsAskedTooNotJustThePolicy. Separately, the applied version's bytes are now required to come from the same RECORD the approval was read from (created_at), because a slug is reusable and a version number restarts at 1; dropping that comparison reddens TestAnApprovalDoesNotAuthorizeAReplacement::test_a_recreated_record_renders_nothing.
  • The script grant tightened twice more in this revision, never loosened. It is resolved for the SURFACE the page belongs to (the crewmate's own slot), because without a session key the scope resolves to unknown and no surface-bound profile can match -- the intersection then fell back to policy alone. And the profile is tested by ARCHETYPE, the same shape test the ceiling gets, rather than by probing one host: a profile denying github.com permits every other name, so a permitted probe proved nothing about the restriction. Mutating the profile half to return True reddens 3 tests in TestTheProfileIsAskedTooNotJustThePolicy. The resolution also moved off the event loop (_run), since the profile store stats its directory and reloads what moved.
  • The script grant's key is now built by one named function, member_dashboard.governance_session_key(slot), rather than assembled at the call site. A profile is bound to a SURFACE and the surface is read off this key's prefix: a crewmate's slot is a bare member-* string, which the canonical classifier sends to its Slack fallback, so a key built from the slot alone skipped every dashboard-bound profile. The product has no shared builder for this prefix -- it is spelled inline at about a dozen call sites -- so this is the dashboard handler's single spelling, and the test asks the CLASSIFIER what the key resolves to instead of comparing it to a literal. A profile bound to either surface a member page can run on withholds the grant, parameterised so adding a surface cannot leave one ungoverned.
  • One more redaction boundary, swept across every site this change adds rather than the one that was reported: a validation or conflict exception's text now goes through redact_via_context before it becomes an HTTP body. Three sites -- the applied package's parse_package refusal, the frame-compose refusal, and the save path's ArtifactConflictError. The first two quote the value or binding the validator refused, and a stored snapshot's values are not re-validated by whoever wrote them; the third names the SLUG, which is [a-z0-9-] and so cannot be a ghp_ but can be an xoxb- or a glpat- -- the same shapes the named-package read already refuses for. Pre-existing sites outside this change are left alone.
  • This revision refuses a caller the gate previously authorized, and authorizes nobody new: binding_refusal asks the roster how many crewmates resolve to the binding's slug before comparing the caller against it. Slugification is lossy, so a hand-edited roster holding both Atlas and atlas derives one slug from two names, and comparing the caller's slug to the binding's then let EITHER of them write the other's package -- the page that runs script inside the owner's own fold values. More than one owner refuses as dashboard_slug_ambiguous and never picks; the remedy named in the sentence is a person renaming one of them, the same remedy the serve-time refusal already gives. The count comes from dashboard.handlers.members._member_names_for_slug, the roster's own answer that _crewmate_binding_refusal and member_dashboard._resolve already ask, so this is not a fourth spelling of the rule. Mutating len(owners) > 1 to a constant false reddens test_a_slug_two_crews_resolve_to_authorizes_neither for both callers; a roster with one owner still writes its own page, which test_an_unambiguous_owner_is_unaffected_by_the_count pins as the boundary. Evidence on this head: test_dashboard_package_owner_gate.py 78 passed, and the twenty-five suites that reach this module 1930 passed. To undo, delete the owners count and its refusal branch from binding_refusal; the comparison below it is unchanged.
  • This revision is a REBASE onto main, with no behaviour of its own added. Four dashboard changes landed on main under it: per-field upkeep text with helper scripts (dashboard_upkeep.py), operator pages served from the panel-templates folder, the default page showing what a crewmate published, and the removal of the Dynamic Dashboard preview flag. Main wins everywhere those four own the ground, and the check is mechanical rather than asserted: every non-blank line each of the four added is present in this tree, with four reported exceptions all accounted for -- two are the feature-map row and the ApiClient surface list, which are single long lines merged cell-by-cell and token-by-token into strict supersets of main's (no token of main's missing, verified), and two are lines a LATER main commit removed, so matching main means not carrying them. RENDERABLE_SOURCES keeps main's {builtin, user}; the spec page keeps main's two-root section and drops the six lines of mine that claimed one root; memberPanel is dropped from the client surface because main deleted that method; every PREVIEW_DASHBOARD reference and every "behind the feature preview" phrase is gone, and this surface is now just the Dashboard tab. The thirteen locale files each keep BOTH keys, main's dashboard_owner_only and this change's dashboard_values_stale, and each file still parses as JSON.
  • One test of main's is red on this head and it is not a defect this revision introduces: test_dashboard_operator_pages.py::test_the_served_page_is_framed_exactly_like_a_built_in_one requires every sandbox={...} in CrewDynamicDashboard.tsx to be the literal CREW_DASHBOARD_SANDBOX, and this change's script grant makes both mount sites crewDashboardSandbox(mayRunScript && shown.scripts) because a page whose owner the admin ceiling denies egress must be mounted with no script at all. No spelling satisfies both: the withheld case needs sandbox="", omitting the attribute is strictly more permissive, and two constant names still fail that test's == [name] * n form. The property it was written to pin DOES hold here -- its docstring says the frame never branches on where a page came from, and both mounts call one named helper that branches on the script grant, never on provenance. Nothing was changed in that test, because main wins where main's tests own the ground and widening its regex is not this worker's call to make; the finding is with the reviewer who owns it.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 824a1ce
  • What rule changed: security_posture.py's REGISTRY of redaction boundaries, not any redactor, allowlist or scrub behaviour. One entry is added to _REDACTION_SINKS (field values pushed to a crewmate's dashboard page, produced in dashboard/handlers/member_dashboard_fields.py) and one to NON_EGRESS_REDACTION_MODULES (artifact_store/dashboard_package.py, which calls a redactor to CLASSIFY a field name rather than to emit text).
  • Before -> after (what was allowed/blocked, now): before, neither module existed, so neither was known to the posture audit. After, the value path is declared an egress sink, which means the audit REQUIRES it to scrub every value it produces and fails if it stops; and the package validator is declared non-egress, which means the audit does not require its redactor call to produce outbound text. Nothing that was blocked became allowed: no value reaches a page unscrubbed either side of this change.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the non-egress classification is the one that could leak. If dashboard_package.py did emit redacted content rather than only classifying, declaring it non-egress would exempt a real output boundary from the audit and a field name that redaction rewrites could reach a page unscrubbed. It does not emit: the redactor output is compared against the input, the package is REFUSED when they differ, and the redacted spelling appears only inside the refusal message. The sink entry has no leak shape at all, since registering a sink only adds an obligation.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and ::test_allowlist_has_no_stale_entries both pass on this head, which is the audit reading the registry against every real call site rather than this description being believed. test_member_dashboard_field_push.py::test_every_value_crosses_the_redactor_on_both_paths proves the registered sink actually scrubs on the initial read AND on every later patch.
  • No regression:
    • Tools still work (which tools/commands were run, result): every number below was measured on THIS head, not carried from a parent. every suite that names dashboard_package, binding_refusal, _member_names_for_slug, resolve_bound_slug or artifact_store, twenty-six of them: 1955 passed, 0 failed. The seventeen suites this change touches: 1210 passed, 0 failed. The composition contract: 109 passed. The four integrated dashboard PRs' own suites, fifteen of them: 1004 passed, 0 failed. Nothing in this change is red. The dashboard read and the package save are the two paths these entries describe and both are exercised there.
    • Backward compatible (old config / old data / old callers still work, how checked): yes. Both lists are append-only here, no existing entry is edited or removed, so every module already registered keeps the same classification. An existing package, an existing instance record and an older gateway are unaffected, which test_allowlist_has_no_stale_entries checks from the other direction by failing on an entry that no longer matches a call site.
    • Existing tests (which suites passed on this head): the twenty-six, the seventeen and the fifteen named above, all on this head. Frontend: the members, dashboard, websocket, api-client and preview-surface set, 369 files, 5844 passed and 0 failed, with tsc --noEmit and eslint src --max-warnings=0 both clean. That one failure is not this change's and not a lane red: it is two React act() warnings in website/src/test/CrewDynamicDashboard.test.tsx, a file this PR's diff against main does not touch at all and whose failing case main already carries. KIROCREW_ACT_STRICT=1 is an opt-in local strictness no workflow sets -- integration/setup.ts reports those warnings and does not fail the run without it -- so all four Frontend Tests shards, Frontend Lint & Type Check and Frontend Coverage Merge are green on this head. Reading the newest run per lane, the only non-success on this head is E2E Gateway Boot (ubuntu-latest), a repo-wide 60-second boot timeout hitting five other open PRs whose Windows siblings boot fine.
  • How to undo: delete the two added entries from _REDACTION_SINKS and NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py. They are pure registry rows with no runtime caller, so removing them restores the previous audit exactly; the audit then fails on the two unregistered call sites, which is the state before this PR added those modules.
  • This revision also narrows a write path rather than widening one: ArtifactStore.update now refuses a kind or content write that lands on a record whose CURRENT kind is dashboard unless it carries the content_token of the read it was authorized against, and an ABSENT token is a refusal. Five separate mutations of that clause each redden test_dashboard_package_owner_gate.py::TestAnUntokenedWriteCannotTakeADashboardOver and a run with the clause restored is green. Scoped to writes that can move a page to another owner, so publish_sync's snapshot bump and the deploy route's webapp_metadata write keep last-write-wins, which the 1147 publish and deploy tests above exercise.
  • One correction carried into this revision from the review of its parent: the fence and the caller's own expected_token are asked INDEPENDENTLY. Satisfying the fence with the handler's fresh read and then skipping the caller's compare-and-set would have let an owner's stale tab overwrite a newer layout with no 409, which is a guard REMOVED rather than added, so a content write carrying expected_token is now compared on every kind including this one. Collapsing the two back into one branch reddens test_the_fence_does_not_swallow_the_callers_own_stale_token.
  • This revision adds one more redaction boundary rather than relaxing any: binding_refusal now redacts every name it quotes -- the binding, the caller's crew, and a validation error's own value -- because _BOUND_TO_RE accepts a GitLab-PAT or Slack-bot shape and the named dashboard GET returns that sentence as its HTTP 403 body. Done inside the one function that composes these messages, not at the three routes that return them. Making the redaction identity reddens four of the five tests in TestTheOwnerRefusalRedactsEveryNameItQuotes; the fifth is the limit, which proves an ordinary name is still named. Also: the person's layout lock is now read BEFORE package selection, so a crewmate cannot move the tab off a locked page by writing its own artifact; removing that condition reddens test_the_persons_lock_outranks_the_crewmates_package.
  • This revision closes a crash rather than opening a path: stored_package_binding caught (ValueError, TypeError) from json.loads but not RecursionError, which is a RuntimeError -- so a markdown document beginning with { and nesting deeper than the decoder's stack made every later PATCH of that slug answer 500, including the one replacing it with plain text. It now answers None (not unprovable): the write path's own decoder refuses that depth, so no stored dashboard record can be this deep, and calling it unprovable would refuse every write to an ordinary document. Removing the new arm reddens test_a_document_too_deep_to_decode_is_not_a_package_and_does_not_raise with the exact RecursionError.
  • One rule in this revision YIELDS rather than adds: main's own api_artifact_update now validates a submitted binding's target (crew member exists, slug not shared, session live) and answers 400, so this change's broader owner gate is asked AFTER it instead of replacing all of those refusals with a single 403. Nothing is weakened -- the owner gate still refuses a worker rebinding another crewmate's page to a valid target, and the snapshot read it depends on still refuses an unreadable or absent record before either gate decides. One narrowing came with it: an app is identified by its id STRING, where any truthy value in request['app'] was read as one.
  • Two rules tightened in this revision, neither relaxed. The page's script grant was derived from the composed ceiling alone; it is now POLICY AND the owner's active PROFILE, asked through governance_permits (the one place the two are intersected) about an arbitrary host, because a page that runs script can navigate its own frame anywhere. An unresolvable profile withholds script, as an unreadable ceiling already did, and a ceiling that does not govern egress is no longer an answer on its own -- that early return was the standalone default, every install with no policy configured. Dropping the profile half reddens 2 tests in TestTheProfileIsAskedTooNotJustThePolicy. Separately, the applied version's bytes are now required to come from the same RECORD the approval was read from (created_at), because a slug is reusable and a version number restarts at 1; dropping that comparison reddens TestAnApprovalDoesNotAuthorizeAReplacement::test_a_recreated_record_renders_nothing.
  • The script grant tightened twice more in this revision, never loosened. It is resolved for the SURFACE the page belongs to (the crewmate's own slot), because without a session key the scope resolves to unknown and no surface-bound profile can match -- the intersection then fell back to policy alone. And the profile is tested by ARCHETYPE, the same shape test the ceiling gets, rather than by probing one host: a profile denying github.com permits every other name, so a permitted probe proved nothing about the restriction. Mutating the profile half to return True reddens 3 tests in TestTheProfileIsAskedTooNotJustThePolicy. The resolution also moved off the event loop (_run), since the profile store stats its directory and reloads what moved.
  • The script grant's key is now built by one named function, member_dashboard.governance_session_key(slot), rather than assembled at the call site. A profile is bound to a SURFACE and the surface is read off this key's prefix: a crewmate's slot is a bare member-* string, which the canonical classifier sends to its Slack fallback, so a key built from the slot alone skipped every dashboard-bound profile. The product has no shared builder for this prefix -- it is spelled inline at about a dozen call sites -- so this is the dashboard handler's single spelling, and the test asks the CLASSIFIER what the key resolves to instead of comparing it to a literal. A profile bound to either surface a member page can run on withholds the grant, parameterised so adding a surface cannot leave one ungoverned.
  • One more redaction boundary, swept across every site this change adds rather than the one that was reported: a validation or conflict exception's text now goes through redact_via_context before it becomes an HTTP body. Three sites -- the applied package's parse_package refusal, the frame-compose refusal, and the save path's ArtifactConflictError. The first two quote the value or binding the validator refused, and a stored snapshot's values are not re-validated by whoever wrote them; the third names the SLUG, which is [a-z0-9-] and so cannot be a ghp_ but can be an xoxb- or a glpat- -- the same shapes the named-package read already refuses for. Pre-existing sites outside this change are left alone.
  • This revision refuses a caller the gate previously authorized, and authorizes nobody new: binding_refusal asks the roster how many crewmates resolve to the binding's slug before comparing the caller against it. Slugification is lossy, so a hand-edited roster holding both Atlas and atlas derives one slug from two names, and comparing the caller's slug to the binding's then let EITHER of them write the other's package -- the page that runs script inside the owner's own fold values. More than one owner refuses as dashboard_slug_ambiguous and never picks; the remedy named in the sentence is a person renaming one of them, the same remedy the serve-time refusal already gives. The count comes from dashboard.handlers.members._member_names_for_slug, the roster's own answer that _crewmate_binding_refusal and member_dashboard._resolve already ask, so this is not a fourth spelling of the rule. Mutating len(owners) > 1 to a constant false reddens test_a_slug_two_crews_resolve_to_authorizes_neither for both callers; a roster with one owner still writes its own page, which test_an_unambiguous_owner_is_unaffected_by_the_count pins as the boundary. Evidence on this head: test_dashboard_package_owner_gate.py 78 passed, and the twenty-five suites that reach this module 1930 passed. To undo, delete the owners count and its refusal branch from binding_refusal; the comparison below it is unchanged.
  • This revision is a REBASE onto main, with no behaviour of its own added. Four dashboard changes landed on main under it: per-field upkeep text with helper scripts (dashboard_upkeep.py), operator pages served from the panel-templates folder, the default page showing what a crewmate published, and the removal of the Dynamic Dashboard preview flag. Main wins everywhere those four own the ground, and the check is mechanical rather than asserted: every non-blank line each of the four added is present in this tree, with four reported exceptions all accounted for -- two are the feature-map row and the ApiClient surface list, which are single long lines merged cell-by-cell and token-by-token into strict supersets of main's (no token of main's missing, verified), and two are lines a LATER main commit removed, so matching main means not carrying them. RENDERABLE_SOURCES keeps main's {builtin, user}; the spec page keeps main's two-root section and drops the six lines of mine that claimed one root; memberPanel is dropped from the client surface because main deleted that method; every PREVIEW_DASHBOARD reference and every "behind the feature preview" phrase is gone, and this surface is now just the Dashboard tab. The thirteen locale files each keep BOTH keys, main's dashboard_owner_only and this change's dashboard_values_stale, and each file still parses as JSON.
  • One test of main's is RE-PINNED in this revision, and it ends up stricter rather than looser. test_dashboard_operator_pages.py::test_the_served_page_is_framed_exactly_like_a_built_in_one compared every sandbox={...} in CrewDynamicDashboard.tsx against the literal CREW_DASHBOARD_SANDBOX, which this change's script grant cannot satisfy: a page whose owner the admin ceiling denies egress must be mounted with no grant at all, so both mounts read crewDashboardSandbox(mayRunScript && ...). The product code is untouched. What the test now pins is the property its own docstring names -- one wrapping for an operator page and a built-in one -- as the FUNCTION and its argument instead of the string: every mount calls the single helper, that helper answers only with the two declared grant sets, and every mount hands it the server's own answer rather than a literal. Four mutations each redden it and the restored code is green: a mount wrapping itself in the raw constant, a mount passing true, the helper ignoring the scripts argument, and CREW_DASHBOARD_SANDBOX_STATIC gaining allow-same-origin. The last two are holes main's literal comparison did not cover, so the re-pin adds coverage. Its sibling assertion that the frame reads no page provenance is left exactly as it stands, and so are its CSP and byte-identity assertions.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 99f456c
  • What rule changed: security_posture.py's REGISTRY of redaction boundaries, not any redactor, allowlist or scrub behaviour. One entry is added to _REDACTION_SINKS (field values pushed to a crewmate's dashboard page, produced in dashboard/handlers/member_dashboard_fields.py) and one to NON_EGRESS_REDACTION_MODULES (artifact_store/dashboard_package.py, which calls a redactor to CLASSIFY a field name rather than to emit text).
  • Before -> after (what was allowed/blocked, now): before, neither module existed, so neither was known to the posture audit. After, the value path is declared an egress sink, which means the audit REQUIRES it to scrub every value it produces and fails if it stops; and the package validator is declared non-egress, which means the audit does not require its redactor call to produce outbound text. Nothing that was blocked became allowed: no value reaches a page unscrubbed either side of this change.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the non-egress classification is the one that could leak. If dashboard_package.py did emit redacted content rather than only classifying, declaring it non-egress would exempt a real output boundary from the audit and a field name that redaction rewrites could reach a page unscrubbed. It does not emit: the redactor output is compared against the input, the package is REFUSED when they differ, and the redacted spelling appears only inside the refusal message. The sink entry has no leak shape at all, since registering a sink only adds an obligation.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and ::test_allowlist_has_no_stale_entries both pass on this head, which is the audit reading the registry against every real call site rather than this description being believed. test_member_dashboard_field_push.py::test_every_value_crosses_the_redactor_on_both_paths proves the registered sink actually scrubs on the initial read AND on every later patch.
  • No regression:
    • Tools still work (which tools/commands were run, result): every number below was measured on THIS head, not carried from a parent. every suite that names dashboard_package, binding_refusal, _member_names_for_slug, resolve_bound_slug or artifact_store, twenty-six of them: 1955 passed, 0 failed. The seventeen suites this change touches: 1210 passed, 0 failed. The composition contract: 109 passed. The four integrated dashboard PRs' own suites, fifteen of them: 1004 passed, 0 failed. Nothing in this change is red. The dashboard read and the package save are the two paths these entries describe and both are exercised there.
    • Backward compatible (old config / old data / old callers still work, how checked): yes. Both lists are append-only here, no existing entry is edited or removed, so every module already registered keeps the same classification. An existing package, an existing instance record and an older gateway are unaffected, which test_allowlist_has_no_stale_entries checks from the other direction by failing on an entry that no longer matches a call site.
    • Existing tests (which suites passed on this head): the twenty-six, the seventeen and the fifteen named above, all on this head. Frontend: the members, dashboard, websocket, api-client and preview-surface set, 367 files, 5829 passed and 0 failed, with tsc --noEmit and eslint src --max-warnings=0 both clean.
  • How to undo: delete the two added entries from _REDACTION_SINKS and NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py. They are pure registry rows with no runtime caller, so removing them restores the previous audit exactly; the audit then fails on the two unregistered call sites, which is the state before this PR added those modules.
  • This revision also narrows a write path rather than widening one: ArtifactStore.update now refuses a kind or content write that lands on a record whose CURRENT kind is dashboard unless it carries the content_token of the read it was authorized against, and an ABSENT token is a refusal. Five separate mutations of that clause each redden test_dashboard_package_owner_gate.py::TestAnUntokenedWriteCannotTakeADashboardOver and a run with the clause restored is green. Scoped to writes that can move a page to another owner, so publish_sync's snapshot bump and the deploy route's webapp_metadata write keep last-write-wins, which the 1147 publish and deploy tests above exercise.
  • One correction carried into this revision from the review of its parent: the fence and the caller's own expected_token are asked INDEPENDENTLY. Satisfying the fence with the handler's fresh read and then skipping the caller's compare-and-set would have let an owner's stale tab overwrite a newer layout with no 409, which is a guard REMOVED rather than added, so a content write carrying expected_token is now compared on every kind including this one. Collapsing the two back into one branch reddens test_the_fence_does_not_swallow_the_callers_own_stale_token.
  • This revision adds one more redaction boundary rather than relaxing any: binding_refusal now redacts every name it quotes -- the binding, the caller's crew, and a validation error's own value -- because _BOUND_TO_RE accepts a GitLab-PAT or Slack-bot shape and the named dashboard GET returns that sentence as its HTTP 403 body. Done inside the one function that composes these messages, not at the three routes that return them. Making the redaction identity reddens four of the five tests in TestTheOwnerRefusalRedactsEveryNameItQuotes; the fifth is the limit, which proves an ordinary name is still named. Also: the person's layout lock is now read BEFORE package selection, so a crewmate cannot move the tab off a locked page by writing its own artifact; removing that condition reddens test_the_persons_lock_outranks_the_crewmates_package.
  • This revision closes a crash rather than opening a path: stored_package_binding caught (ValueError, TypeError) from json.loads but not RecursionError, which is a RuntimeError -- so a markdown document beginning with { and nesting deeper than the decoder's stack made every later PATCH of that slug answer 500, including the one replacing it with plain text. It now answers None (not unprovable): the write path's own decoder refuses that depth, so no stored dashboard record can be this deep, and calling it unprovable would refuse every write to an ordinary document. Removing the new arm reddens test_a_document_too_deep_to_decode_is_not_a_package_and_does_not_raise with the exact RecursionError.
  • One rule in this revision YIELDS rather than adds: main's own api_artifact_update now validates a submitted binding's target (crew member exists, slug not shared, session live) and answers 400, so this change's broader owner gate is asked AFTER it instead of replacing all of those refusals with a single 403. Nothing is weakened -- the owner gate still refuses a worker rebinding another crewmate's page to a valid target, and the snapshot read it depends on still refuses an unreadable or absent record before either gate decides. One narrowing came with it: an app is identified by its id STRING, where any truthy value in request['app'] was read as one.
  • Two rules tightened in this revision, neither relaxed. The page's script grant was derived from the composed ceiling alone; it is now POLICY AND the owner's active PROFILE, asked through governance_permits (the one place the two are intersected) about an arbitrary host, because a page that runs script can navigate its own frame anywhere. An unresolvable profile withholds script, as an unreadable ceiling already did, and a ceiling that does not govern egress is no longer an answer on its own -- that early return was the standalone default, every install with no policy configured. Dropping the profile half reddens 2 tests in TestTheProfileIsAskedTooNotJustThePolicy. Separately, the applied version's bytes are now required to come from the same RECORD the approval was read from (created_at), because a slug is reusable and a version number restarts at 1; dropping that comparison reddens TestAnApprovalDoesNotAuthorizeAReplacement::test_a_recreated_record_renders_nothing.
  • The script grant tightened twice more in this revision, never loosened. It is resolved for the SURFACE the page belongs to (the crewmate's own slot), because without a session key the scope resolves to unknown and no surface-bound profile can match -- the intersection then fell back to policy alone. And the profile is tested by ARCHETYPE, the same shape test the ceiling gets, rather than by probing one host: a profile denying github.com permits every other name, so a permitted probe proved nothing about the restriction. Mutating the profile half to return True reddens 3 tests in TestTheProfileIsAskedTooNotJustThePolicy. The resolution also moved off the event loop (_run), since the profile store stats its directory and reloads what moved.
  • The script grant's key is now built by one named function, member_dashboard.governance_session_key(slot), rather than assembled at the call site. A profile is bound to a SURFACE and the surface is read off this key's prefix: a crewmate's slot is a bare member-* string, which the canonical classifier sends to its Slack fallback, so a key built from the slot alone skipped every dashboard-bound profile. The product has no shared builder for this prefix -- it is spelled inline at about a dozen call sites -- so this is the dashboard handler's single spelling, and the test asks the CLASSIFIER what the key resolves to instead of comparing it to a literal. A profile bound to either surface a member page can run on withholds the grant, parameterised so adding a surface cannot leave one ungoverned.
  • One more redaction boundary, swept across every site this change adds rather than the one that was reported: a validation or conflict exception's text now goes through redact_via_context before it becomes an HTTP body. Three sites -- the applied package's parse_package refusal, the frame-compose refusal, and the save path's ArtifactConflictError. The first two quote the value or binding the validator refused, and a stored snapshot's values are not re-validated by whoever wrote them; the third names the SLUG, which is [a-z0-9-] and so cannot be a ghp_ but can be an xoxb- or a glpat- -- the same shapes the named-package read already refuses for. Pre-existing sites outside this change are left alone.
  • This revision refuses a caller the gate previously authorized, and authorizes nobody new: binding_refusal asks the roster how many crewmates resolve to the binding's slug before comparing the caller against it. Slugification is lossy, so a hand-edited roster holding both Atlas and atlas derives one slug from two names, and comparing the caller's slug to the binding's then let EITHER of them write the other's package -- the page that runs script inside the owner's own fold values. More than one owner refuses as dashboard_slug_ambiguous and never picks; the remedy named in the sentence is a person renaming one of them, the same remedy the serve-time refusal already gives. The count comes from dashboard.handlers.members._member_names_for_slug, the roster's own answer that _crewmate_binding_refusal and member_dashboard._resolve already ask, so this is not a fourth spelling of the rule. Mutating len(owners) > 1 to a constant false reddens test_a_slug_two_crews_resolve_to_authorizes_neither for both callers; a roster with one owner still writes its own page, which test_an_unambiguous_owner_is_unaffected_by_the_count pins as the boundary. Evidence on this head: test_dashboard_package_owner_gate.py 78 passed, and the twenty-five suites that reach this module 1930 passed. To undo, delete the owners count and its refusal branch from binding_refusal; the comparison below it is unchanged.
  • This revision is a REBASE onto main, with no behaviour of its own added. Four dashboard changes landed on main under it: per-field upkeep text with helper scripts (dashboard_upkeep.py), operator pages served from the panel-templates folder, the default page showing what a crewmate published, and the removal of the Dynamic Dashboard preview flag. Main wins everywhere those four own the ground, and the check is mechanical rather than asserted: every non-blank line each of the four added is present in this tree, with four reported exceptions all accounted for -- two are the feature-map row and the ApiClient surface list, which are single long lines merged cell-by-cell and token-by-token into strict supersets of main's (no token of main's missing, verified), and two are lines a LATER main commit removed, so matching main means not carrying them. RENDERABLE_SOURCES keeps main's {builtin, user}; the spec page keeps main's two-root section and drops the six lines of mine that claimed one root; memberPanel is dropped from the client surface because main deleted that method; every PREVIEW_DASHBOARD reference and every "behind the feature preview" phrase is gone, and this surface is now just the Dashboard tab. The thirteen locale files each keep BOTH keys, main's dashboard_owner_only and this change's dashboard_values_stale, and each file still parses as JSON.
  • One test of main's is RE-PINNED in this revision, and it ends up stricter rather than looser. test_dashboard_operator_pages.py::test_the_served_page_is_framed_exactly_like_a_built_in_one compared every sandbox={...} in CrewDynamicDashboard.tsx against the literal CREW_DASHBOARD_SANDBOX, which this change's script grant cannot satisfy: a page whose owner the admin ceiling denies egress must be mounted with no grant at all, so both mounts read crewDashboardSandbox(mayRunScript && ...). The product code is untouched. What the test now pins is the property its own docstring names -- one wrapping for an operator page and a built-in one -- as the FUNCTION and its argument instead of the string: every mount calls the single helper, that helper answers only with the two declared grant sets, and every mount hands it the server's own answer rather than a literal. Four mutations each redden it and the restored code is green: a mount wrapping itself in the raw constant, a mount passing true, the helper ignoring the scripts argument, and CREW_DASHBOARD_SANDBOX_STATIC gaining allow-same-origin. The last two are holes main's literal comparison did not cover, so the re-pin adds coverage. Its sibling assertion that the frame reads no page provenance is left exactly as it stands, and so are its CSP and byte-identity assertions.
  • This revision closes a privilege-retention hole in the frontend and grants nothing new. A read that gives the Dashboard tab NO page to be on used to return early on the missing page alone, which left the held document MOUNTED with the allow-scripts it loaded under, plus its candidate and its probation state, until something else made the tab reload. Keying that on the state: empty word alone left two other ways in: a record whose layout lock pins a template_id the catalog no longer holds, which resolves to no package slug and composes nothing, so the body carries neither rendered_html nor a scripts decision; and a read that moves the tab from a package to the crewmate's template instance, which DOES compose a page, so only the surface tells them apart -- an instance version is per record and the html can coincide, so the version-keyed comparison kept the held package page. Under either one a reader goes on looking at a page the record does not have, and if an admin ceiling has since restricted the owner agent's egress that document still holds the grant and can navigate its own frame to a host now forbidden.
  • The fix is one fail-closed guard in the one place a read is applied, with no case exempted for being merely stale: any read with no rendered_html clears the page, the candidate and the script decision; and the page's SURFACE (the package slug, '' for the template instance) is now carried on Loaded and compared ahead of the version in both promotion paths, so a page from another surface is dropped rather than reconciled. state: error stays the one read that leaves the held page alone, because it is a different answer -- the read succeeded and says the crewmate's NEWER stored copy does not parse, so the page on screen is still the record's last good one and stays under a band, which test_the_last_page_that_parsed and its siblings pin.
  • Evidence, by mutation rather than by assertion: restoring the early return on a missing composed page reddens 3 tests in CrewDynamicDashboard.revocation.test.tsx; removing the surface check from either promotion path, or from both, reddens tells the surfaces apart when the version and the html both coincide. That test is read in the UNDER-granting direction because that is the one a frame shows: a static package page, then the template instance at the same version with the same bytes, which may run script. Its two siblings pin the security direction -- a scripted package page held, then a read that composes nothing, and the same page then moved to a template answering scripts: false: no allow-scripts frame survives either. Two limits are pinned too, so the rule cannot be satisfied by blanking the tab: a read for the SAME package does not remount, and the template's page does reach the frame. One line is NOT independently observable and is not claimed as tested: resetting mayRunScript to false inside the clear changes nothing a frame can show, because the page is cleared in the same branch and no iframe mounts at all. It is there because an absent scripts field is the absence of a decision rather than the last decision, and the next read that establishes a page overwrites it from that page's own answer.
  • Counts on this head: the twenty-six backend suites reaching the changed module 1955 passed; the frontend members, dashboard, websocket, api-client and preview-surface set 5829 passed across 367 files, with tsc --noEmit and eslint src --max-warnings=0 clean; revocation.test.tsx itself 14 passed. To undo, restore the early return and drop the dashboard field from Loaded and from the two comparisons; the hole returns with it.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: a645e94
  • What rule changed: security_posture.py's REGISTRY of redaction boundaries, not any redactor, allowlist or scrub behaviour. One entry is added to _REDACTION_SINKS (field values pushed to a crewmate's dashboard page, produced in dashboard/handlers/member_dashboard_fields.py) and one to NON_EGRESS_REDACTION_MODULES (artifact_store/dashboard_package.py, which calls a redactor to CLASSIFY a field name rather than to emit text).
  • Before -> after (what was allowed/blocked, now): before, neither module existed, so neither was known to the posture audit. After, the value path is declared an egress sink, which means the audit REQUIRES it to scrub every value it produces and fails if it stops; and the package validator is declared non-egress, which means the audit does not require its redactor call to produce outbound text. Nothing that was blocked became allowed: no value reaches a page unscrubbed either side of this change.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the non-egress classification is the one that could leak. If dashboard_package.py did emit redacted content rather than only classifying, declaring it non-egress would exempt a real output boundary from the audit and a field name that redaction rewrites could reach a page unscrubbed. It does not emit: the redactor output is compared against the input, the package is REFUSED when they differ, and the redacted spelling appears only inside the refusal message. The sink entry has no leak shape at all, since registering a sink only adds an obligation.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and ::test_allowlist_has_no_stale_entries both pass on this head, which is the audit reading the registry against every real call site rather than this description being believed. test_member_dashboard_field_push.py::test_every_value_crosses_the_redactor_on_both_paths proves the registered sink actually scrubs on the initial read AND on every later patch.
  • No regression:
    • Tools still work (which tools/commands were run, result): every number below was measured on THIS head, not carried from a parent. every suite that names dashboard_package, binding_refusal, _member_names_for_slug, resolve_bound_slug or artifact_store, twenty-six of them: 1960 passed, 0 failed. The seventeen suites this change touches: 1235 passed, 0 failed. The composition contract: 109 passed. The four integrated dashboard PRs' own suites, fifteen of them: 1004 passed, 0 failed. Nothing in this change is red. The dashboard read and the package save are the two paths these entries describe and both are exercised there.
    • Backward compatible (old config / old data / old callers still work, how checked): yes. Both lists are append-only here, no existing entry is edited or removed, so every module already registered keeps the same classification. An existing package, an existing instance record and an older gateway are unaffected, which test_allowlist_has_no_stale_entries checks from the other direction by failing on an entry that no longer matches a call site.
    • Existing tests (which suites passed on this head): the twenty-six, the seventeen and the fifteen named above, all on this head. Frontend: the members, dashboard, websocket, api-client and preview-surface set, 367 files, 5829 passed and 0 failed, with tsc --noEmit and eslint src --max-warnings=0 both clean.
  • How to undo: delete the two added entries from _REDACTION_SINKS and NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py. They are pure registry rows with no runtime caller, so removing them restores the previous audit exactly; the audit then fails on the two unregistered call sites, which is the state before this PR added those modules.
  • This revision also narrows a write path rather than widening one: ArtifactStore.update now refuses a kind or content write that lands on a record whose CURRENT kind is dashboard unless it carries the content_token of the read it was authorized against, and an ABSENT token is a refusal. Five separate mutations of that clause each redden test_dashboard_package_owner_gate.py::TestAnUntokenedWriteCannotTakeADashboardOver and a run with the clause restored is green. Scoped to writes that can move a page to another owner, so publish_sync's snapshot bump and the deploy route's webapp_metadata write keep last-write-wins, which the 1147 publish and deploy tests above exercise.
  • One correction carried into this revision from the review of its parent: the fence and the caller's own expected_token are asked INDEPENDENTLY. Satisfying the fence with the handler's fresh read and then skipping the caller's compare-and-set would have let an owner's stale tab overwrite a newer layout with no 409, which is a guard REMOVED rather than added, so a content write carrying expected_token is now compared on every kind including this one. Collapsing the two back into one branch reddens test_the_fence_does_not_swallow_the_callers_own_stale_token.
  • This revision adds one more redaction boundary rather than relaxing any: binding_refusal now redacts every name it quotes -- the binding, the caller's crew, and a validation error's own value -- because _BOUND_TO_RE accepts a GitLab-PAT or Slack-bot shape and the named dashboard GET returns that sentence as its HTTP 403 body. Done inside the one function that composes these messages, not at the three routes that return them. Making the redaction identity reddens four of the five tests in TestTheOwnerRefusalRedactsEveryNameItQuotes; the fifth is the limit, which proves an ordinary name is still named. Also: the person's layout lock is now read BEFORE package selection, so a crewmate cannot move the tab off a locked page by writing its own artifact; removing that condition reddens test_the_persons_lock_outranks_the_crewmates_package.
  • This revision closes a crash rather than opening a path: stored_package_binding caught (ValueError, TypeError) from json.loads but not RecursionError, which is a RuntimeError -- so a markdown document beginning with { and nesting deeper than the decoder's stack made every later PATCH of that slug answer 500, including the one replacing it with plain text. It now answers None (not unprovable): the write path's own decoder refuses that depth, so no stored dashboard record can be this deep, and calling it unprovable would refuse every write to an ordinary document. Removing the new arm reddens test_a_document_too_deep_to_decode_is_not_a_package_and_does_not_raise with the exact RecursionError.
  • One rule in this revision YIELDS rather than adds: main's own api_artifact_update now validates a submitted binding's target (crew member exists, slug not shared, session live) and answers 400, so this change's broader owner gate is asked AFTER it instead of replacing all of those refusals with a single 403. Nothing is weakened -- the owner gate still refuses a worker rebinding another crewmate's page to a valid target, and the snapshot read it depends on still refuses an unreadable or absent record before either gate decides. One narrowing came with it: an app is identified by its id STRING, where any truthy value in request['app'] was read as one.
  • Two rules tightened in this revision, neither relaxed. The page's script grant was derived from the composed ceiling alone; it is now POLICY AND the owner's active PROFILE, asked through governance_permits (the one place the two are intersected) about an arbitrary host, because a page that runs script can navigate its own frame anywhere. An unresolvable profile withholds script, as an unreadable ceiling already did, and a ceiling that does not govern egress is no longer an answer on its own -- that early return was the standalone default, every install with no policy configured. Dropping the profile half reddens 2 tests in TestTheProfileIsAskedTooNotJustThePolicy. Separately, the applied version's bytes are now required to come from the same RECORD the approval was read from (created_at), because a slug is reusable and a version number restarts at 1; dropping that comparison reddens TestAnApprovalDoesNotAuthorizeAReplacement::test_a_recreated_record_renders_nothing.
  • The script grant tightened twice more in this revision, never loosened. It is resolved for the SURFACE the page belongs to (the crewmate's own slot), because without a session key the scope resolves to unknown and no surface-bound profile can match -- the intersection then fell back to policy alone. And the profile is tested by ARCHETYPE, the same shape test the ceiling gets, rather than by probing one host: a profile denying github.com permits every other name, so a permitted probe proved nothing about the restriction. Mutating the profile half to return True reddens 3 tests in TestTheProfileIsAskedTooNotJustThePolicy. The resolution also moved off the event loop (_run), since the profile store stats its directory and reloads what moved.
  • The script grant's key is now built by one named function, member_dashboard.governance_session_key(slot), rather than assembled at the call site. A profile is bound to a SURFACE and the surface is read off this key's prefix: a crewmate's slot is a bare member-* string, which the canonical classifier sends to its Slack fallback, so a key built from the slot alone skipped every dashboard-bound profile. The product has no shared builder for this prefix -- it is spelled inline at about a dozen call sites -- so this is the dashboard handler's single spelling, and the test asks the CLASSIFIER what the key resolves to instead of comparing it to a literal. A profile bound to either surface a member page can run on withholds the grant, parameterised so adding a surface cannot leave one ungoverned.
  • One more redaction boundary, swept across every site this change adds rather than the one that was reported: a validation or conflict exception's text now goes through redact_via_context before it becomes an HTTP body. Three sites -- the applied package's parse_package refusal, the frame-compose refusal, and the save path's ArtifactConflictError. The first two quote the value or binding the validator refused, and a stored snapshot's values are not re-validated by whoever wrote them; the third names the SLUG, which is [a-z0-9-] and so cannot be a ghp_ but can be an xoxb- or a glpat- -- the same shapes the named-package read already refuses for. Pre-existing sites outside this change are left alone.
  • This revision refuses a caller the gate previously authorized, and authorizes nobody new: binding_refusal asks the roster how many crewmates resolve to the binding's slug before comparing the caller against it. Slugification is lossy, so a hand-edited roster holding both Atlas and atlas derives one slug from two names, and comparing the caller's slug to the binding's then let EITHER of them write the other's package -- the page that runs script inside the owner's own fold values. More than one owner refuses as dashboard_slug_ambiguous and never picks; the remedy named in the sentence is a person renaming one of them, the same remedy the serve-time refusal already gives. The count comes from dashboard.handlers.members._member_names_for_slug, the roster's own answer that _crewmate_binding_refusal and member_dashboard._resolve already ask, so this is not a fourth spelling of the rule. Mutating len(owners) > 1 to a constant false reddens test_a_slug_two_crews_resolve_to_authorizes_neither for both callers; a roster with one owner still writes its own page, which test_an_unambiguous_owner_is_unaffected_by_the_count pins as the boundary. Evidence on this head: test_dashboard_package_owner_gate.py 78 passed, and the twenty-five suites that reach this module 1930 passed. To undo, delete the owners count and its refusal branch from binding_refusal; the comparison below it is unchanged.
  • This revision is a REBASE onto main, with no behaviour of its own added. Four dashboard changes landed on main under it: per-field upkeep text with helper scripts (dashboard_upkeep.py), operator pages served from the panel-templates folder, the default page showing what a crewmate published, and the removal of the Dynamic Dashboard preview flag. Main wins everywhere those four own the ground, and the check is mechanical rather than asserted: every non-blank line each of the four added is present in this tree, with four reported exceptions all accounted for -- two are the feature-map row and the ApiClient surface list, which are single long lines merged cell-by-cell and token-by-token into strict supersets of main's (no token of main's missing, verified), and two are lines a LATER main commit removed, so matching main means not carrying them. RENDERABLE_SOURCES keeps main's {builtin, user}; the spec page keeps main's two-root section and drops the six lines of mine that claimed one root; memberPanel is dropped from the client surface because main deleted that method; every PREVIEW_DASHBOARD reference and every "behind the feature preview" phrase is gone, and this surface is now just the Dashboard tab. The thirteen locale files each keep BOTH keys, main's dashboard_owner_only and this change's dashboard_values_stale, and each file still parses as JSON.
  • One test of main's is RE-PINNED in this revision, and it ends up stricter rather than looser. test_dashboard_operator_pages.py::test_the_served_page_is_framed_exactly_like_a_built_in_one compared every sandbox={...} in CrewDynamicDashboard.tsx against the literal CREW_DASHBOARD_SANDBOX, which this change's script grant cannot satisfy: a page whose owner the admin ceiling denies egress must be mounted with no grant at all, so both mounts read crewDashboardSandbox(mayRunScript && ...). The product code is untouched. What the test now pins is the property its own docstring names -- one wrapping for an operator page and a built-in one -- as the FUNCTION and its argument instead of the string: every mount calls the single helper, that helper answers only with the two declared grant sets, and every mount hands it the server's own answer rather than a literal. Four mutations each redden it and the restored code is green: a mount wrapping itself in the raw constant, a mount passing true, the helper ignoring the scripts argument, and CREW_DASHBOARD_SANDBOX_STATIC gaining allow-same-origin. The last two are holes main's literal comparison did not cover, so the re-pin adds coverage. Its sibling assertion that the frame reads no page provenance is left exactly as it stands, and so are its CSP and byte-identity assertions.
  • This revision closes a privilege-retention hole in the frontend and grants nothing new. A read that gives the Dashboard tab NO page to be on used to return early on the missing page alone, which left the held document MOUNTED with the allow-scripts it loaded under, plus its candidate and its probation state, until something else made the tab reload. Keying that on the state: empty word alone left two other ways in: a record whose layout lock pins a template_id the catalog no longer holds, which resolves to no package slug and composes nothing, so the body carries neither rendered_html nor a scripts decision; and a read that moves the tab from a package to the crewmate's template instance, which DOES compose a page, so only the surface tells them apart -- an instance version is per record and the html can coincide, so the version-keyed comparison kept the held package page. Under either one a reader goes on looking at a page the record does not have, and if an admin ceiling has since restricted the owner agent's egress that document still holds the grant and can navigate its own frame to a host now forbidden.
  • The fix is one fail-closed guard in the one place a read is applied, with no case exempted for being merely stale: any read with no rendered_html clears the page, the candidate and the script decision; and the page's SURFACE (the package slug, '' for the template instance) is now carried on Loaded and compared ahead of the version in both promotion paths, so a page from another surface is dropped rather than reconciled. state: error stays the one read that leaves the held page alone, because it is a different answer -- the read succeeded and says the crewmate's NEWER stored copy does not parse, so the page on screen is still the record's last good one and stays under a band, which test_the_last_page_that_parsed and its siblings pin.
  • Evidence, by mutation rather than by assertion: restoring the early return on a missing composed page reddens 3 tests in CrewDynamicDashboard.revocation.test.tsx; removing the surface check from either promotion path, or from both, reddens tells the surfaces apart when the version and the html both coincide. That test is read in the UNDER-granting direction because that is the one a frame shows: a static package page, then the template instance at the same version with the same bytes, which may run script. Its two siblings pin the security direction -- a scripted package page held, then a read that composes nothing, and the same page then moved to a template answering scripts: false: no allow-scripts frame survives either. Two limits are pinned too, so the rule cannot be satisfied by blanking the tab: a read for the SAME package does not remount, and the template's page does reach the frame. One line is NOT independently observable and is not claimed as tested: resetting mayRunScript to false inside the clear changes nothing a frame can show, because the page is cleared in the same branch and no iframe mounts at all. It is there because an absent scripts field is the absence of a decision rather than the last decision, and the next read that establishes a page overwrites it from that page's own answer.
  • Counts on this head: the twenty-six backend suites reaching the changed module 1960 passed; the frontend members, dashboard, websocket, api-client and preview-surface set 5829 passed across 367 files, with tsc --noEmit and eslint src --max-warnings=0 clean; revocation.test.tsx itself 14 passed. To undo, restore the early return and drop the dashboard field from Loaded and from the two comparisons; the hole returns with it.
  • This revision ADDS AN AUDIT RECORD and changes no decision. The script grant in _serve_package is an authorization decision -- it decides whether a page a crewmate wrote may run script against that crewmate's own fold values -- and it was reached and acted on without leaving a record, which this repository's backend security controls require of a decision of that kind. It now writes one through sel().log_governance_decision, the SAME shared helper agent_backend_governance._audit and every other permission check in the product use, rather than a second emitter: the outcome vocabulary is that helper's own allowed/denied, so a log query for allowed decisions does not miss these rows alone, and the redaction is the helper's own pass over operation, item and reason. The row carries the crewmate, the package slug and its applied version (item), the scope network.egress, the verdict, and the layer plus a reason token -- because a row saying only "denied" cannot be acted on, while ceiling_restricts_egress, profile_restricts_egress, ceiling_unreadable and profile_unresolvable have different remedies and only some are a misconfiguration. Producing the reason split owner_agent_egress_unrestricted into a thin boolean wrapper over _egress_decision, which returns the verdict with its layer; every existing caller and all 107 tests of that function still read the boolean unchanged.
  • DEDUPED ON (crewmate, package, version, decision), which is what keeps it an authorization log rather than a page-view log. The tab polls on a timer and refetches on two WS frames, so one open dashboard re-decides this with the same answer for as long as it stays open; a row per read would push the rows that matter out of any practical retention window. A row is written when any part of that tuple changes -- a newly applied version, or a profile edit that flips the verdict. The memory is a dict keyed by (crewmate, package) capped at 256 pairs, bounded for the reason the live-page registry is: the key is a pair an operator can create, so an unbounded map is a slow leak on a long-lived gateway, and evicting the oldest costs at most one repeated row and never a missed change.
  • BEST EFFORT, and the grant cannot move because of it. The call is made AFTER scripts is bound, so the value it records is already settled and this function cannot reach it; the whole body including the dedupe is inside one except Exception that logs at debug; and log_governance_decision without critical enqueues to the background writer, which swallows persistence failures by design. The decision is also remembered BEFORE the write is attempted, so a log that cannot be written costs one lost row rather than one failed write per poll for as long as a tab is open.
  • Evidence by mutation, five tests in test_member_dashboard_package_route.py::TestTheScriptGrantIsAudited driving the REAL route: removing the audit call reddens 4; removing the dedupe check reddens 2; keying the dedupe on the version alone, so a flipped verdict is hidden, reddens 1; letting the emit raise reddens 2; and remembering the decision after the write instead of before reddens 1. The restored code is green at 5. The four the ruling asked for are among them -- a first open writes one row, four identical reads write none, a profile edit that flips scripts from true to false writes a second row naming profile as the layer, and a sel() that raises still answers 200 with the same scripts and the package's own page. Counts on this head: 2037 passed across the twenty-six module suites plus the security-posture and ceiling suites, 1235 across the seventeen this change touches, and test_sel.py with test_security_posture.py green beside them. To undo, delete _audit_page_script_grant, its two module constants and the call in _serve_package, and collapse _egress_decision back into the boolean; nothing else reads them.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 5cda01b
  • What rule changed: security_posture.py's REGISTRY of redaction boundaries, not any redactor, allowlist or scrub behaviour. One entry is added to _REDACTION_SINKS (field values pushed to a crewmate's dashboard page, produced in dashboard/handlers/member_dashboard_fields.py) and one to NON_EGRESS_REDACTION_MODULES (artifact_store/dashboard_package.py, which calls a redactor to CLASSIFY a field name rather than to emit text).
  • Before -> after (what was allowed/blocked, now): before, neither module existed, so neither was known to the posture audit. After, the value path is declared an egress sink, which means the audit REQUIRES it to scrub every value it produces and fails if it stops; and the package validator is declared non-egress, which means the audit does not require its redactor call to produce outbound text. Nothing that was blocked became allowed: no value reaches a page unscrubbed either side of this change.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the non-egress classification is the one that could leak. If dashboard_package.py did emit redacted content rather than only classifying, declaring it non-egress would exempt a real output boundary from the audit and a field name that redaction rewrites could reach a page unscrubbed. It does not emit: the redactor output is compared against the input, the package is REFUSED when they differ, and the redacted spelling appears only inside the refusal message. The sink entry has no leak shape at all, since registering a sink only adds an obligation.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and ::test_allowlist_has_no_stale_entries both pass on this head, which is the audit reading the registry against every real call site rather than this description being believed. test_member_dashboard_field_push.py::test_every_value_crosses_the_redactor_on_both_paths proves the registered sink actually scrubs on the initial read AND on every later patch.
  • No regression:
    • Tools still work (which tools/commands were run, result): every number below was measured on THIS head, not carried from a parent. every suite that names dashboard_package, binding_refusal, _member_names_for_slug, resolve_bound_slug or artifact_store, twenty-six of them: 1960 passed, 0 failed. The seventeen suites this change touches: 1235 passed, 0 failed. The composition contract: 109 passed. The four integrated dashboard PRs' own suites, fifteen of them: 1004 passed, 0 failed. Nothing in this change is red. The dashboard read and the package save are the two paths these entries describe and both are exercised there.
    • Backward compatible (old config / old data / old callers still work, how checked): yes. Both lists are append-only here, no existing entry is edited or removed, so every module already registered keeps the same classification. An existing package, an existing instance record and an older gateway are unaffected, which test_allowlist_has_no_stale_entries checks from the other direction by failing on an entry that no longer matches a call site.
    • Existing tests (which suites passed on this head): the twenty-six, the seventeen and the fifteen named above, all on this head. Frontend: the members, dashboard, websocket, api-client and preview-surface set, 367 files, 5829 passed and 0 failed, with tsc --noEmit and eslint src --max-warnings=0 both clean.
  • How to undo: delete the two added entries from _REDACTION_SINKS and NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py. They are pure registry rows with no runtime caller, so removing them restores the previous audit exactly; the audit then fails on the two unregistered call sites, which is the state before this PR added those modules.
  • This revision also narrows a write path rather than widening one: ArtifactStore.update now refuses a kind or content write that lands on a record whose CURRENT kind is dashboard unless it carries the content_token of the read it was authorized against, and an ABSENT token is a refusal. Five separate mutations of that clause each redden test_dashboard_package_owner_gate.py::TestAnUntokenedWriteCannotTakeADashboardOver and a run with the clause restored is green. Scoped to writes that can move a page to another owner, so publish_sync's snapshot bump and the deploy route's webapp_metadata write keep last-write-wins, which the 1147 publish and deploy tests above exercise.
  • One correction carried into this revision from the review of its parent: the fence and the caller's own expected_token are asked INDEPENDENTLY. Satisfying the fence with the handler's fresh read and then skipping the caller's compare-and-set would have let an owner's stale tab overwrite a newer layout with no 409, which is a guard REMOVED rather than added, so a content write carrying expected_token is now compared on every kind including this one. Collapsing the two back into one branch reddens test_the_fence_does_not_swallow_the_callers_own_stale_token.
  • This revision adds one more redaction boundary rather than relaxing any: binding_refusal now redacts every name it quotes -- the binding, the caller's crew, and a validation error's own value -- because _BOUND_TO_RE accepts a GitLab-PAT or Slack-bot shape and the named dashboard GET returns that sentence as its HTTP 403 body. Done inside the one function that composes these messages, not at the three routes that return them. Making the redaction identity reddens four of the five tests in TestTheOwnerRefusalRedactsEveryNameItQuotes; the fifth is the limit, which proves an ordinary name is still named. Also: the person's layout lock is now read BEFORE package selection, so a crewmate cannot move the tab off a locked page by writing its own artifact; removing that condition reddens test_the_persons_lock_outranks_the_crewmates_package.
  • This revision closes a crash rather than opening a path: stored_package_binding caught (ValueError, TypeError) from json.loads but not RecursionError, which is a RuntimeError -- so a markdown document beginning with { and nesting deeper than the decoder's stack made every later PATCH of that slug answer 500, including the one replacing it with plain text. It now answers None (not unprovable): the write path's own decoder refuses that depth, so no stored dashboard record can be this deep, and calling it unprovable would refuse every write to an ordinary document. Removing the new arm reddens test_a_document_too_deep_to_decode_is_not_a_package_and_does_not_raise with the exact RecursionError.
  • One rule in this revision YIELDS rather than adds: main's own api_artifact_update now validates a submitted binding's target (crew member exists, slug not shared, session live) and answers 400, so this change's broader owner gate is asked AFTER it instead of replacing all of those refusals with a single 403. Nothing is weakened -- the owner gate still refuses a worker rebinding another crewmate's page to a valid target, and the snapshot read it depends on still refuses an unreadable or absent record before either gate decides. One narrowing came with it: an app is identified by its id STRING, where any truthy value in request['app'] was read as one.
  • Two rules tightened in this revision, neither relaxed. The page's script grant was derived from the composed ceiling alone; it is now POLICY AND the owner's active PROFILE, asked through governance_permits (the one place the two are intersected) about an arbitrary host, because a page that runs script can navigate its own frame anywhere. An unresolvable profile withholds script, as an unreadable ceiling already did, and a ceiling that does not govern egress is no longer an answer on its own -- that early return was the standalone default, every install with no policy configured. Dropping the profile half reddens 2 tests in TestTheProfileIsAskedTooNotJustThePolicy. Separately, the applied version's bytes are now required to come from the same RECORD the approval was read from (created_at), because a slug is reusable and a version number restarts at 1; dropping that comparison reddens TestAnApprovalDoesNotAuthorizeAReplacement::test_a_recreated_record_renders_nothing.
  • The script grant tightened twice more in this revision, never loosened. It is resolved for the SURFACE the page belongs to (the crewmate's own slot), because without a session key the scope resolves to unknown and no surface-bound profile can match -- the intersection then fell back to policy alone. And the profile is tested by ARCHETYPE, the same shape test the ceiling gets, rather than by probing one host: a profile denying github.com permits every other name, so a permitted probe proved nothing about the restriction. Mutating the profile half to return True reddens 3 tests in TestTheProfileIsAskedTooNotJustThePolicy. The resolution also moved off the event loop (_run), since the profile store stats its directory and reloads what moved.
  • The script grant's key is now built by one named function, member_dashboard.governance_session_key(slot), rather than assembled at the call site. A profile is bound to a SURFACE and the surface is read off this key's prefix: a crewmate's slot is a bare member-* string, which the canonical classifier sends to its Slack fallback, so a key built from the slot alone skipped every dashboard-bound profile. The product has no shared builder for this prefix -- it is spelled inline at about a dozen call sites -- so this is the dashboard handler's single spelling, and the test asks the CLASSIFIER what the key resolves to instead of comparing it to a literal. A profile bound to either surface a member page can run on withholds the grant, parameterised so adding a surface cannot leave one ungoverned.
  • One more redaction boundary, swept across every site this change adds rather than the one that was reported: a validation or conflict exception's text now goes through redact_via_context before it becomes an HTTP body. Three sites -- the applied package's parse_package refusal, the frame-compose refusal, and the save path's ArtifactConflictError. The first two quote the value or binding the validator refused, and a stored snapshot's values are not re-validated by whoever wrote them; the third names the SLUG, which is [a-z0-9-] and so cannot be a ghp_ but can be an xoxb- or a glpat- -- the same shapes the named-package read already refuses for. Pre-existing sites outside this change are left alone.
  • This revision refuses a caller the gate previously authorized, and authorizes nobody new: binding_refusal asks the roster how many crewmates resolve to the binding's slug before comparing the caller against it. Slugification is lossy, so a hand-edited roster holding both Atlas and atlas derives one slug from two names, and comparing the caller's slug to the binding's then let EITHER of them write the other's package -- the page that runs script inside the owner's own fold values. More than one owner refuses as dashboard_slug_ambiguous and never picks; the remedy named in the sentence is a person renaming one of them, the same remedy the serve-time refusal already gives. The count comes from dashboard.handlers.members._member_names_for_slug, the roster's own answer that _crewmate_binding_refusal and member_dashboard._resolve already ask, so this is not a fourth spelling of the rule. Mutating len(owners) > 1 to a constant false reddens test_a_slug_two_crews_resolve_to_authorizes_neither for both callers; a roster with one owner still writes its own page, which test_an_unambiguous_owner_is_unaffected_by_the_count pins as the boundary. Evidence on this head: test_dashboard_package_owner_gate.py 78 passed, and the twenty-five suites that reach this module 1930 passed. To undo, delete the owners count and its refusal branch from binding_refusal; the comparison below it is unchanged.
  • This revision is a REBASE onto main, with no behaviour of its own added. Four dashboard changes landed on main under it: per-field upkeep text with helper scripts (dashboard_upkeep.py), operator pages served from the panel-templates folder, the default page showing what a crewmate published, and the removal of the Dynamic Dashboard preview flag. Main wins everywhere those four own the ground, and the check is mechanical rather than asserted: every non-blank line each of the four added is present in this tree, with four reported exceptions all accounted for -- two are the feature-map row and the ApiClient surface list, which are single long lines merged cell-by-cell and token-by-token into strict supersets of main's (no token of main's missing, verified), and two are lines a LATER main commit removed, so matching main means not carrying them. RENDERABLE_SOURCES keeps main's {builtin, user}; the spec page keeps main's two-root section and drops the six lines of mine that claimed one root; memberPanel is dropped from the client surface because main deleted that method; every PREVIEW_DASHBOARD reference and every "behind the feature preview" phrase is gone, and this surface is now just the Dashboard tab. The thirteen locale files each keep BOTH keys, main's dashboard_owner_only and this change's dashboard_values_stale, and each file still parses as JSON.
  • One test of main's is RE-PINNED in this revision, and it ends up stricter rather than looser. test_dashboard_operator_pages.py::test_the_served_page_is_framed_exactly_like_a_built_in_one compared every sandbox={...} in CrewDynamicDashboard.tsx against the literal CREW_DASHBOARD_SANDBOX, which this change's script grant cannot satisfy: a page whose owner the admin ceiling denies egress must be mounted with no grant at all, so both mounts read crewDashboardSandbox(mayRunScript && ...). The product code is untouched. What the test now pins is the property its own docstring names -- one wrapping for an operator page and a built-in one -- as the FUNCTION and its argument instead of the string: every mount calls the single helper, that helper answers only with the two declared grant sets, and every mount hands it the server's own answer rather than a literal. Four mutations each redden it and the restored code is green: a mount wrapping itself in the raw constant, a mount passing true, the helper ignoring the scripts argument, and CREW_DASHBOARD_SANDBOX_STATIC gaining allow-same-origin. The last two are holes main's literal comparison did not cover, so the re-pin adds coverage. Its sibling assertion that the frame reads no page provenance is left exactly as it stands, and so are its CSP and byte-identity assertions.
  • This revision closes a privilege-retention hole in the frontend and grants nothing new. A read that gives the Dashboard tab NO page to be on used to return early on the missing page alone, which left the held document MOUNTED with the allow-scripts it loaded under, plus its candidate and its probation state, until something else made the tab reload. Keying that on the state: empty word alone left two other ways in: a record whose layout lock pins a template_id the catalog no longer holds, which resolves to no package slug and composes nothing, so the body carries neither rendered_html nor a scripts decision; and a read that moves the tab from a package to the crewmate's template instance, which DOES compose a page, so only the surface tells them apart -- an instance version is per record and the html can coincide, so the version-keyed comparison kept the held package page. Under either one a reader goes on looking at a page the record does not have, and if an admin ceiling has since restricted the owner agent's egress that document still holds the grant and can navigate its own frame to a host now forbidden.
  • The fix is one fail-closed guard in the one place a read is applied, with no case exempted for being merely stale: any read with no rendered_html clears the page, the candidate and the script decision; and the page's SURFACE (the package slug, '' for the template instance) is now carried on Loaded and compared ahead of the version in both promotion paths, so a page from another surface is dropped rather than reconciled. state: error stays the one read that leaves the held page alone, because it is a different answer -- the read succeeded and says the crewmate's NEWER stored copy does not parse, so the page on screen is still the record's last good one and stays under a band, which test_the_last_page_that_parsed and its siblings pin.
  • Evidence, by mutation rather than by assertion: restoring the early return on a missing composed page reddens 3 tests in CrewDynamicDashboard.revocation.test.tsx; removing the surface check from either promotion path, or from both, reddens tells the surfaces apart when the version and the html both coincide. That test is read in the UNDER-granting direction because that is the one a frame shows: a static package page, then the template instance at the same version with the same bytes, which may run script. Its two siblings pin the security direction -- a scripted package page held, then a read that composes nothing, and the same page then moved to a template answering scripts: false: no allow-scripts frame survives either. Two limits are pinned too, so the rule cannot be satisfied by blanking the tab: a read for the SAME package does not remount, and the template's page does reach the frame. One line is NOT independently observable and is not claimed as tested: resetting mayRunScript to false inside the clear changes nothing a frame can show, because the page is cleared in the same branch and no iframe mounts at all. It is there because an absent scripts field is the absence of a decision rather than the last decision, and the next read that establishes a page overwrites it from that page's own answer.
  • Counts on this head: the twenty-six backend suites reaching the changed module 1960 passed; the frontend members, dashboard, websocket, api-client and preview-surface set 5829 passed across 367 files, with tsc --noEmit and eslint src --max-warnings=0 clean; revocation.test.tsx itself 14 passed. To undo, restore the early return and drop the dashboard field from Loaded and from the two comparisons; the hole returns with it.
  • This revision ADDS AN AUDIT RECORD and changes no decision. The script grant in _serve_package is an authorization decision -- it decides whether a page a crewmate wrote may run script against that crewmate's own fold values -- and it was reached and acted on without leaving a record, which this repository's backend security controls require of a decision of that kind. It now writes one through sel().log_governance_decision, the SAME shared helper agent_backend_governance._audit and every other permission check in the product use, rather than a second emitter: the outcome vocabulary is that helper's own allowed/denied, so a log query for allowed decisions does not miss these rows alone, and the redaction is the helper's own pass over operation, item and reason. The row carries the crewmate, the package slug and its applied version (item), the scope network.egress, the verdict, and the layer plus a reason token -- because a row saying only "denied" cannot be acted on, while ceiling_restricts_egress, profile_restricts_egress, ceiling_unreadable and profile_unresolvable have different remedies and only some are a misconfiguration. Producing the reason split owner_agent_egress_unrestricted into a thin boolean wrapper over _egress_decision, which returns the verdict with its layer; every existing caller and all 107 tests of that function still read the boolean unchanged.
  • DEDUPED ON (crewmate, package, version, decision), which is what keeps it an authorization log rather than a page-view log. The tab polls on a timer and refetches on two WS frames, so one open dashboard re-decides this with the same answer for as long as it stays open; a row per read would push the rows that matter out of any practical retention window. A row is written when any part of that tuple changes -- a newly applied version, or a profile edit that flips the verdict. The memory is a dict keyed by (crewmate, package) capped at 256 pairs, bounded for the reason the live-page registry is: the key is a pair an operator can create, so an unbounded map is a slow leak on a long-lived gateway, and evicting the oldest costs at most one repeated row and never a missed change.
  • BEST EFFORT, and the grant cannot move because of it. The call is made AFTER scripts is bound, so the value it records is already settled and this function cannot reach it; the whole body including the dedupe is inside one except Exception that logs at debug; and log_governance_decision without critical enqueues to the background writer, which swallows persistence failures by design. The decision is also remembered BEFORE the write is attempted, so a log that cannot be written costs one lost row rather than one failed write per poll for as long as a tab is open.
  • Evidence by mutation, five tests in test_member_dashboard_package_route.py::TestTheScriptGrantIsAudited driving the REAL route: removing the audit call reddens 4; removing the dedupe check reddens 2; keying the dedupe on the version alone, so a flipped verdict is hidden, reddens 1; letting the emit raise reddens 2; and remembering the decision after the write instead of before reddens 1. The restored code is green at 5. The four the ruling asked for are among them -- a first open writes one row, four identical reads write none, a profile edit that flips scripts from true to false writes a second row naming profile as the layer, and a sel() that raises still answers 200 with the same scripts and the package's own page. Counts on this head: 2037 passed across the twenty-six module suites plus the security-posture and ceiling suites, 1235 across the seventeen this change touches, and test_sel.py with test_security_posture.py green beside them. To undo, delete _audit_page_script_grant, its two module constants and the call in _serve_package, and collapse _egress_decision back into the boolean; nothing else reads them.
  • This revision RESTORES a ratchet this PR had weakened, and narrows a save gate rather than widening one. dashboard_templates.manifest.FOLD_NAMES is the set of crew-log folds a manifest field may bind, and this PR had added the TREE family to it so a package could bind one. That set is shared: parse_manifest gates a TEMPLATE with it, and artifact_store.dashboard_package.fold_names() gates a PACKAGE with it. Only the package surface gained the reader. A tree-keyed fold has no bus scope by design -- it joins the logs of many slots, so no event could carry a key saying which one moved -- and it is READ instead, by member_dashboard_fields.LivePage, which draws a package's page. A template is rendered by member_dashboard._render, whose DashboardFeed reaches a fold only by its scope and has no tree read. So an operator writing a panel-templates page could bind worktree.boards, have parse_manifest accept it, and get a field missing on every read behind a permanent stale band -- exactly the block the gate's own comment exists to refuse.
  • The two sets are now separate: FOLD_NAMES is back to main's value, the two SCOPED families, and a new PACKAGE_FOLD_NAMES is that set plus the tree family, which fold_names() reads. A superset rather than a second list, because the two surfaces answer one question and differ only in what can reach a fold, so a name neither can reach is in neither. Nothing is admitted that was not admitted before this PR: the template gate is byte-identical to main's, and the package gate is the only thing that grew.
  • Three assertions move with it, and the universal one comes back. test_dynamic_dashboard.py had replaced assert dashboard_feed.scope_for(name), name with an allowlist whose entries this PR added, which is the weakening: the universal form is restored for FOLD_NAMES, the reachability form now runs over PACKAGE_FOLD_NAMES, and a third test pins the SPLIT itself -- every tree fold is absent from the template set, present in the package set, and FOLD_NAMES < PACKAGE_FOLD_NAMES -- because re-merging the sets would otherwise still satisfy the package loop, a superset passing a check written for the subset. Main's own test_the_fold_names_come_from_the_manifest_not_a_copy keeps its claim, that this gate reads the manifest module's set and never a copy, and now also asserts the subset relation.
  • Evidence by mutation: re-merging the tree family into FOLD_NAMES, which is the regression itself, reddens 3 tests; pointing fold_names() back at the template set, which makes a package's tree binding unreachable again, reddens 1. The restored code is green at 252 for those two suites and 2079 across the twenty-six module suites plus the dynamic-dashboard, ceiling, security-posture, field-schema and operator-pages suites. To undo, merge the two constants and the universal assertion weakens again with them.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 6f4d80e
  • What rule changed: security_posture.py's REGISTRY of redaction boundaries, not any redactor, allowlist or scrub behaviour. One entry is added to _REDACTION_SINKS (field values pushed to a crewmate's dashboard page, produced in dashboard/handlers/member_dashboard_fields.py) and one to NON_EGRESS_REDACTION_MODULES (artifact_store/dashboard_package.py, which calls a redactor to CLASSIFY a field name rather than to emit text).
  • Before -> after (what was allowed/blocked, now): before, neither module existed, so neither was known to the posture audit. After, the value path is declared an egress sink, which means the audit REQUIRES it to scrub every value it produces and fails if it stops; and the package validator is declared non-egress, which means the audit does not require its redactor call to produce outbound text. Nothing that was blocked became allowed: no value reaches a page unscrubbed either side of this change.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the non-egress classification is the one that could leak. If dashboard_package.py did emit redacted content rather than only classifying, declaring it non-egress would exempt a real output boundary from the audit and a field name that redaction rewrites could reach a page unscrubbed. It does not emit: the redactor output is compared against the input, the package is REFUSED when they differ, and the redacted spelling appears only inside the refusal message. The sink entry has no leak shape at all, since registering a sink only adds an obligation.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and ::test_allowlist_has_no_stale_entries both pass on this head, which is the audit reading the registry against every real call site rather than this description being believed. test_member_dashboard_field_push.py::test_every_value_crosses_the_redactor_on_both_paths proves the registered sink actually scrubs on the initial read AND on every later patch.
  • No regression:
    • Tools still work (which tools/commands were run, result): every number below was measured on THIS head, not carried from a parent. every suite that names dashboard_package, binding_refusal, _member_names_for_slug, resolve_bound_slug or artifact_store, twenty-six of them: 1960 passed, 0 failed. The seventeen suites this change touches: 1235 passed, 0 failed. The composition contract: 109 passed. The four integrated dashboard PRs' own suites, fifteen of them: 1004 passed, 0 failed. Nothing in this change is red. The dashboard read and the package save are the two paths these entries describe and both are exercised there.
    • Backward compatible (old config / old data / old callers still work, how checked): yes. Both lists are append-only here, no existing entry is edited or removed, so every module already registered keeps the same classification. An existing package, an existing instance record and an older gateway are unaffected, which test_allowlist_has_no_stale_entries checks from the other direction by failing on an entry that no longer matches a call site.
    • Existing tests (which suites passed on this head): the twenty-six, the seventeen and the fifteen named above, all on this head. Frontend: the members, dashboard, websocket, api-client and preview-surface set, 367 files, 5829 passed and 0 failed, with tsc --noEmit and eslint src --max-warnings=0 both clean.
  • How to undo: delete the two added entries from _REDACTION_SINKS and NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py. They are pure registry rows with no runtime caller, so removing them restores the previous audit exactly; the audit then fails on the two unregistered call sites, which is the state before this PR added those modules.
  • This revision also narrows a write path rather than widening one: ArtifactStore.update now refuses a kind or content write that lands on a record whose CURRENT kind is dashboard unless it carries the content_token of the read it was authorized against, and an ABSENT token is a refusal. Five separate mutations of that clause each redden test_dashboard_package_owner_gate.py::TestAnUntokenedWriteCannotTakeADashboardOver and a run with the clause restored is green. Scoped to writes that can move a page to another owner, so publish_sync's snapshot bump and the deploy route's webapp_metadata write keep last-write-wins, which the 1147 publish and deploy tests above exercise.
  • One correction carried into this revision from the review of its parent: the fence and the caller's own expected_token are asked INDEPENDENTLY. Satisfying the fence with the handler's fresh read and then skipping the caller's compare-and-set would have let an owner's stale tab overwrite a newer layout with no 409, which is a guard REMOVED rather than added, so a content write carrying expected_token is now compared on every kind including this one. Collapsing the two back into one branch reddens test_the_fence_does_not_swallow_the_callers_own_stale_token.
  • This revision adds one more redaction boundary rather than relaxing any: binding_refusal now redacts every name it quotes -- the binding, the caller's crew, and a validation error's own value -- because _BOUND_TO_RE accepts a GitLab-PAT or Slack-bot shape and the named dashboard GET returns that sentence as its HTTP 403 body. Done inside the one function that composes these messages, not at the three routes that return them. Making the redaction identity reddens four of the five tests in TestTheOwnerRefusalRedactsEveryNameItQuotes; the fifth is the limit, which proves an ordinary name is still named. Also: the person's layout lock is now read BEFORE package selection, so a crewmate cannot move the tab off a locked page by writing its own artifact; removing that condition reddens test_the_persons_lock_outranks_the_crewmates_package.
  • This revision closes a crash rather than opening a path: stored_package_binding caught (ValueError, TypeError) from json.loads but not RecursionError, which is a RuntimeError -- so a markdown document beginning with { and nesting deeper than the decoder's stack made every later PATCH of that slug answer 500, including the one replacing it with plain text. It now answers None (not unprovable): the write path's own decoder refuses that depth, so no stored dashboard record can be this deep, and calling it unprovable would refuse every write to an ordinary document. Removing the new arm reddens test_a_document_too_deep_to_decode_is_not_a_package_and_does_not_raise with the exact RecursionError.
  • One rule in this revision YIELDS rather than adds: main's own api_artifact_update now validates a submitted binding's target (crew member exists, slug not shared, session live) and answers 400, so this change's broader owner gate is asked AFTER it instead of replacing all of those refusals with a single 403. Nothing is weakened -- the owner gate still refuses a worker rebinding another crewmate's page to a valid target, and the snapshot read it depends on still refuses an unreadable or absent record before either gate decides. One narrowing came with it: an app is identified by its id STRING, where any truthy value in request['app'] was read as one.
  • Two rules tightened in this revision, neither relaxed. The page's script grant was derived from the composed ceiling alone; it is now POLICY AND the owner's active PROFILE, asked through governance_permits (the one place the two are intersected) about an arbitrary host, because a page that runs script can navigate its own frame anywhere. An unresolvable profile withholds script, as an unreadable ceiling already did, and a ceiling that does not govern egress is no longer an answer on its own -- that early return was the standalone default, every install with no policy configured. Dropping the profile half reddens 2 tests in TestTheProfileIsAskedTooNotJustThePolicy. Separately, the applied version's bytes are now required to come from the same RECORD the approval was read from (created_at), because a slug is reusable and a version number restarts at 1; dropping that comparison reddens TestAnApprovalDoesNotAuthorizeAReplacement::test_a_recreated_record_renders_nothing.
  • The script grant tightened twice more in this revision, never loosened. It is resolved for the SURFACE the page belongs to (the crewmate's own slot), because without a session key the scope resolves to unknown and no surface-bound profile can match -- the intersection then fell back to policy alone. And the profile is tested by ARCHETYPE, the same shape test the ceiling gets, rather than by probing one host: a profile denying github.com permits every other name, so a permitted probe proved nothing about the restriction. Mutating the profile half to return True reddens 3 tests in TestTheProfileIsAskedTooNotJustThePolicy. The resolution also moved off the event loop (_run), since the profile store stats its directory and reloads what moved.
  • The script grant's key is now built by one named function, member_dashboard.governance_session_key(slot), rather than assembled at the call site. A profile is bound to a SURFACE and the surface is read off this key's prefix: a crewmate's slot is a bare member-* string, which the canonical classifier sends to its Slack fallback, so a key built from the slot alone skipped every dashboard-bound profile. The product has no shared builder for this prefix -- it is spelled inline at about a dozen call sites -- so this is the dashboard handler's single spelling, and the test asks the CLASSIFIER what the key resolves to instead of comparing it to a literal. A profile bound to either surface a member page can run on withholds the grant, parameterised so adding a surface cannot leave one ungoverned.
  • One more redaction boundary, swept across every site this change adds rather than the one that was reported: a validation or conflict exception's text now goes through redact_via_context before it becomes an HTTP body. Three sites -- the applied package's parse_package refusal, the frame-compose refusal, and the save path's ArtifactConflictError. The first two quote the value or binding the validator refused, and a stored snapshot's values are not re-validated by whoever wrote them; the third names the SLUG, which is [a-z0-9-] and so cannot be a ghp_ but can be an xoxb- or a glpat- -- the same shapes the named-package read already refuses for. Pre-existing sites outside this change are left alone.
  • This revision refuses a caller the gate previously authorized, and authorizes nobody new: binding_refusal asks the roster how many crewmates resolve to the binding's slug before comparing the caller against it. Slugification is lossy, so a hand-edited roster holding both Atlas and atlas derives one slug from two names, and comparing the caller's slug to the binding's then let EITHER of them write the other's package -- the page that runs script inside the owner's own fold values. More than one owner refuses as dashboard_slug_ambiguous and never picks; the remedy named in the sentence is a person renaming one of them, the same remedy the serve-time refusal already gives. The count comes from dashboard.handlers.members._member_names_for_slug, the roster's own answer that _crewmate_binding_refusal and member_dashboard._resolve already ask, so this is not a fourth spelling of the rule. Mutating len(owners) > 1 to a constant false reddens test_a_slug_two_crews_resolve_to_authorizes_neither for both callers; a roster with one owner still writes its own page, which test_an_unambiguous_owner_is_unaffected_by_the_count pins as the boundary. Evidence on this head: test_dashboard_package_owner_gate.py 78 passed, and the twenty-five suites that reach this module 1930 passed. To undo, delete the owners count and its refusal branch from binding_refusal; the comparison below it is unchanged.
  • This revision is a REBASE onto main, with no behaviour of its own added. Four dashboard changes landed on main under it: per-field upkeep text with helper scripts (dashboard_upkeep.py), operator pages served from the panel-templates folder, the default page showing what a crewmate published, and the removal of the Dynamic Dashboard preview flag. Main wins everywhere those four own the ground, and the check is mechanical rather than asserted: every non-blank line each of the four added is present in this tree, with four reported exceptions all accounted for -- two are the feature-map row and the ApiClient surface list, which are single long lines merged cell-by-cell and token-by-token into strict supersets of main's (no token of main's missing, verified), and two are lines a LATER main commit removed, so matching main means not carrying them. RENDERABLE_SOURCES keeps main's {builtin, user}; the spec page keeps main's two-root section and drops the six lines of mine that claimed one root; memberPanel is dropped from the client surface because main deleted that method; every PREVIEW_DASHBOARD reference and every "behind the feature preview" phrase is gone, and this surface is now just the Dashboard tab. The thirteen locale files each keep BOTH keys, main's dashboard_owner_only and this change's dashboard_values_stale, and each file still parses as JSON.
  • One test of main's is RE-PINNED in this revision, and it ends up stricter rather than looser. test_dashboard_operator_pages.py::test_the_served_page_is_framed_exactly_like_a_built_in_one compared every sandbox={...} in CrewDynamicDashboard.tsx against the literal CREW_DASHBOARD_SANDBOX, which this change's script grant cannot satisfy: a page whose owner the admin ceiling denies egress must be mounted with no grant at all, so both mounts read crewDashboardSandbox(mayRunScript && ...). The product code is untouched. What the test now pins is the property its own docstring names -- one wrapping for an operator page and a built-in one -- as the FUNCTION and its argument instead of the string: every mount calls the single helper, that helper answers only with the two declared grant sets, and every mount hands it the server's own answer rather than a literal. Four mutations each redden it and the restored code is green: a mount wrapping itself in the raw constant, a mount passing true, the helper ignoring the scripts argument, and CREW_DASHBOARD_SANDBOX_STATIC gaining allow-same-origin. The last two are holes main's literal comparison did not cover, so the re-pin adds coverage. Its sibling assertion that the frame reads no page provenance is left exactly as it stands, and so are its CSP and byte-identity assertions.
  • This revision closes a privilege-retention hole in the frontend and grants nothing new. A read that gives the Dashboard tab NO page to be on used to return early on the missing page alone, which left the held document MOUNTED with the allow-scripts it loaded under, plus its candidate and its probation state, until something else made the tab reload. Keying that on the state: empty word alone left two other ways in: a record whose layout lock pins a template_id the catalog no longer holds, which resolves to no package slug and composes nothing, so the body carries neither rendered_html nor a scripts decision; and a read that moves the tab from a package to the crewmate's template instance, which DOES compose a page, so only the surface tells them apart -- an instance version is per record and the html can coincide, so the version-keyed comparison kept the held package page. Under either one a reader goes on looking at a page the record does not have, and if an admin ceiling has since restricted the owner agent's egress that document still holds the grant and can navigate its own frame to a host now forbidden.
  • The fix is one fail-closed guard in the one place a read is applied, with no case exempted for being merely stale: any read with no rendered_html clears the page, the candidate and the script decision; and the page's SURFACE (the package slug, '' for the template instance) is now carried on Loaded and compared ahead of the version in both promotion paths, so a page from another surface is dropped rather than reconciled. state: error stays the one read that leaves the held page alone, because it is a different answer -- the read succeeded and says the crewmate's NEWER stored copy does not parse, so the page on screen is still the record's last good one and stays under a band, which test_the_last_page_that_parsed and its siblings pin.
  • Evidence, by mutation rather than by assertion: restoring the early return on a missing composed page reddens 3 tests in CrewDynamicDashboard.revocation.test.tsx; removing the surface check from either promotion path, or from both, reddens tells the surfaces apart when the version and the html both coincide. That test is read in the UNDER-granting direction because that is the one a frame shows: a static package page, then the template instance at the same version with the same bytes, which may run script. Its two siblings pin the security direction -- a scripted package page held, then a read that composes nothing, and the same page then moved to a template answering scripts: false: no allow-scripts frame survives either. Two limits are pinned too, so the rule cannot be satisfied by blanking the tab: a read for the SAME package does not remount, and the template's page does reach the frame. One line is NOT independently observable and is not claimed as tested: resetting mayRunScript to false inside the clear changes nothing a frame can show, because the page is cleared in the same branch and no iframe mounts at all. It is there because an absent scripts field is the absence of a decision rather than the last decision, and the next read that establishes a page overwrites it from that page's own answer.
  • Counts on this head: the twenty-six backend suites reaching the changed module 1960 passed; the frontend members, dashboard, websocket, api-client and preview-surface set 5829 passed across 367 files, with tsc --noEmit and eslint src --max-warnings=0 clean; revocation.test.tsx itself 14 passed. To undo, restore the early return and drop the dashboard field from Loaded and from the two comparisons; the hole returns with it.
  • This revision ADDS AN AUDIT RECORD and changes no decision. The script grant in _serve_package is an authorization decision -- it decides whether a page a crewmate wrote may run script against that crewmate's own fold values -- and it was reached and acted on without leaving a record, which this repository's backend security controls require of a decision of that kind. It now writes one through sel().log_governance_decision, the SAME shared helper agent_backend_governance._audit and every other permission check in the product use, rather than a second emitter: the outcome vocabulary is that helper's own allowed/denied, so a log query for allowed decisions does not miss these rows alone, and the redaction is the helper's own pass over operation, item and reason. The row carries the crewmate, the package slug and its applied version (item), the scope network.egress, the verdict, and the layer plus a reason token -- because a row saying only "denied" cannot be acted on, while ceiling_restricts_egress, profile_restricts_egress, ceiling_unreadable and profile_unresolvable have different remedies and only some are a misconfiguration. Producing the reason split owner_agent_egress_unrestricted into a thin boolean wrapper over _egress_decision, which returns the verdict with its layer; every existing caller and all 107 tests of that function still read the boolean unchanged.
  • DEDUPED ON (crewmate, package, version, decision), which is what keeps it an authorization log rather than a page-view log. The tab polls on a timer and refetches on two WS frames, so one open dashboard re-decides this with the same answer for as long as it stays open; a row per read would push the rows that matter out of any practical retention window. A row is written when any part of that tuple changes -- a newly applied version, or a profile edit that flips the verdict. The memory is a dict keyed by (crewmate, package) capped at 256 pairs, bounded for the reason the live-page registry is: the key is a pair an operator can create, so an unbounded map is a slow leak on a long-lived gateway, and evicting the oldest costs at most one repeated row and never a missed change.
  • BEST EFFORT, and the grant cannot move because of it. The call is made AFTER scripts is bound, so the value it records is already settled and this function cannot reach it; the whole body including the dedupe is inside one except Exception that logs at debug; and log_governance_decision without critical enqueues to the background writer, which swallows persistence failures by design. The decision is also remembered BEFORE the write is attempted, so a log that cannot be written costs one lost row rather than one failed write per poll for as long as a tab is open.
  • Evidence by mutation, five tests in test_member_dashboard_package_route.py::TestTheScriptGrantIsAudited driving the REAL route: removing the audit call reddens 4; removing the dedupe check reddens 2; keying the dedupe on the version alone, so a flipped verdict is hidden, reddens 1; letting the emit raise reddens 2; and remembering the decision after the write instead of before reddens 1. The restored code is green at 5. The four the ruling asked for are among them -- a first open writes one row, four identical reads write none, a profile edit that flips scripts from true to false writes a second row naming profile as the layer, and a sel() that raises still answers 200 with the same scripts and the package's own page. Counts on this head: 2037 passed across the twenty-six module suites plus the security-posture and ceiling suites, 1235 across the seventeen this change touches, and test_sel.py with test_security_posture.py green beside them. To undo, delete _audit_page_script_grant, its two module constants and the call in _serve_package, and collapse _egress_decision back into the boolean; nothing else reads them.
  • This revision RESTORES a ratchet this PR had weakened, and narrows a save gate rather than widening one. dashboard_templates.manifest.FOLD_NAMES is the set of crew-log folds a manifest field may bind, and this PR had added the TREE family to it so a package could bind one. That set is shared: parse_manifest gates a TEMPLATE with it, and artifact_store.dashboard_package.fold_names() gates a PACKAGE with it. Only the package surface gained the reader. A tree-keyed fold has no bus scope by design -- it joins the logs of many slots, so no event could carry a key saying which one moved -- and it is READ instead, by member_dashboard_fields.LivePage, which draws a package's page. A template is rendered by member_dashboard._render, whose DashboardFeed reaches a fold only by its scope and has no tree read. So an operator writing a panel-templates page could bind worktree.boards, have parse_manifest accept it, and get a field missing on every read behind a permanent stale band -- exactly the block the gate's own comment exists to refuse.
  • The two sets are now separate: FOLD_NAMES is back to main's value, the two SCOPED families, and a new PACKAGE_FOLD_NAMES is that set plus the tree family, which fold_names() reads. A superset rather than a second list, because the two surfaces answer one question and differ only in what can reach a fold, so a name neither can reach is in neither. Nothing is admitted that was not admitted before this PR: the template gate is byte-identical to main's, and the package gate is the only thing that grew.
  • Three assertions move with it, and the universal one comes back. test_dynamic_dashboard.py had replaced assert dashboard_feed.scope_for(name), name with an allowlist whose entries this PR added, which is the weakening: the universal form is restored for FOLD_NAMES, the reachability form now runs over PACKAGE_FOLD_NAMES, and a third test pins the SPLIT itself -- every tree fold is absent from the template set, present in the package set, and FOLD_NAMES < PACKAGE_FOLD_NAMES -- because re-merging the sets would otherwise still satisfy the package loop, a superset passing a check written for the subset. Main's own test_the_fold_names_come_from_the_manifest_not_a_copy keeps its claim, that this gate reads the manifest module's set and never a copy, and now also asserts the subset relation.
  • Evidence by mutation: re-merging the tree family into FOLD_NAMES, which is the regression itself, reddens 3 tests; pointing fold_names() back at the template set, which makes a package's tree binding unreachable again, reddens 1. The restored code is green at 252 for those two suites and 2081 across the twenty-six module suites plus the dynamic-dashboard, ceiling, security-posture, field-schema and operator-pages suites. To undo, merge the two constants and the universal assertion weakens again with them.
  • The split is now pinned AT THE GATE as well as on the sets, which is the half that was missing. test_a_template_binding_a_tree_fold_is_refused_at_parse builds a template manifest binding each registered tree fold and asserts parse_manifest raises ManifestError naming that fold -- the refusal an operator writing a panel-templates page actually meets, rather than a set-membership assertion standing in for it, and named so the author is told which binding to change instead of being handed a manifest-wide "invalid". Its companion test_a_package_binding_the_same_tree_fold_is_accepted asks dashboard_package.fold_names() the same question, because a package never reaches parse_manifest and its page IS drawn by the reader that resolves a tree fold: together they say the two surfaces answer differently on purpose. Re-merging the two sets reddens 3 of the 6 tests in this group. No product behaviour for a package changes in this revision; it adds the two tests and nothing else.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 37ab2b2
  • What rule changed: security_posture.py's REGISTRY of redaction boundaries, not any redactor, allowlist or scrub behaviour. One entry is added to _REDACTION_SINKS (field values pushed to a crewmate's dashboard page, produced in dashboard/handlers/member_dashboard_fields.py) and one to NON_EGRESS_REDACTION_MODULES (artifact_store/dashboard_package.py, which calls a redactor to CLASSIFY a field name rather than to emit text).
  • Before -> after (what was allowed/blocked, now): before, neither module existed, so neither was known to the posture audit. After, the value path is declared an egress sink, which means the audit REQUIRES it to scrub every value it produces and fails if it stops; and the package validator is declared non-egress, which means the audit does not require its redactor call to produce outbound text. Nothing that was blocked became allowed: no value reaches a page unscrubbed either side of this change.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the non-egress classification is the one that could leak. If dashboard_package.py did emit redacted content rather than only classifying, declaring it non-egress would exempt a real output boundary from the audit and a field name that redaction rewrites could reach a page unscrubbed. It does not emit: the redactor output is compared against the input, the package is REFUSED when they differ, and the redacted spelling appears only inside the refusal message. The sink entry has no leak shape at all, since registering a sink only adds an obligation.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and ::test_allowlist_has_no_stale_entries both pass on this head, which is the audit reading the registry against every real call site rather than this description being believed. test_member_dashboard_field_push.py::test_every_value_crosses_the_redactor_on_both_paths proves the registered sink actually scrubs on the initial read AND on every later patch.
  • No regression:
    • Tools still work (which tools/commands were run, result): every number below was measured on THIS head, not carried from a parent. every suite that names dashboard_package, binding_refusal, _member_names_for_slug, resolve_bound_slug or artifact_store, twenty-six of them: 1960 passed, 0 failed. The seventeen suites this change touches: 1235 passed, 0 failed. The composition contract: 109 passed. The four integrated dashboard PRs' own suites, fifteen of them: 1004 passed, 0 failed. Nothing in this change is red. The dashboard read and the package save are the two paths these entries describe and both are exercised there.
    • Backward compatible (old config / old data / old callers still work, how checked): yes. Both lists are append-only here, no existing entry is edited or removed, so every module already registered keeps the same classification. An existing package, an existing instance record and an older gateway are unaffected, which test_allowlist_has_no_stale_entries checks from the other direction by failing on an entry that no longer matches a call site.
    • Existing tests (which suites passed on this head): the twenty-six, the seventeen and the fifteen named above, all on this head. Frontend: the members, dashboard, websocket, api-client and preview-surface set, 367 files, 5829 passed and 0 failed, with tsc --noEmit and eslint src --max-warnings=0 both clean.
  • How to undo: delete the two added entries from _REDACTION_SINKS and NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py. They are pure registry rows with no runtime caller, so removing them restores the previous audit exactly; the audit then fails on the two unregistered call sites, which is the state before this PR added those modules.
  • This revision also narrows a write path rather than widening one: ArtifactStore.update now refuses a kind or content write that lands on a record whose CURRENT kind is dashboard unless it carries the content_token of the read it was authorized against, and an ABSENT token is a refusal. Five separate mutations of that clause each redden test_dashboard_package_owner_gate.py::TestAnUntokenedWriteCannotTakeADashboardOver and a run with the clause restored is green. Scoped to writes that can move a page to another owner, so publish_sync's snapshot bump and the deploy route's webapp_metadata write keep last-write-wins, which the 1147 publish and deploy tests above exercise.
  • One correction carried into this revision from the review of its parent: the fence and the caller's own expected_token are asked INDEPENDENTLY. Satisfying the fence with the handler's fresh read and then skipping the caller's compare-and-set would have let an owner's stale tab overwrite a newer layout with no 409, which is a guard REMOVED rather than added, so a content write carrying expected_token is now compared on every kind including this one. Collapsing the two back into one branch reddens test_the_fence_does_not_swallow_the_callers_own_stale_token.
  • This revision adds one more redaction boundary rather than relaxing any: binding_refusal now redacts every name it quotes -- the binding, the caller's crew, and a validation error's own value -- because _BOUND_TO_RE accepts a GitLab-PAT or Slack-bot shape and the named dashboard GET returns that sentence as its HTTP 403 body. Done inside the one function that composes these messages, not at the three routes that return them. Making the redaction identity reddens four of the five tests in TestTheOwnerRefusalRedactsEveryNameItQuotes; the fifth is the limit, which proves an ordinary name is still named. Also: the person's layout lock is now read BEFORE package selection, so a crewmate cannot move the tab off a locked page by writing its own artifact; removing that condition reddens test_the_persons_lock_outranks_the_crewmates_package.
  • This revision closes a crash rather than opening a path: stored_package_binding caught (ValueError, TypeError) from json.loads but not RecursionError, which is a RuntimeError -- so a markdown document beginning with { and nesting deeper than the decoder's stack made every later PATCH of that slug answer 500, including the one replacing it with plain text. It now answers None (not unprovable): the write path's own decoder refuses that depth, so no stored dashboard record can be this deep, and calling it unprovable would refuse every write to an ordinary document. Removing the new arm reddens test_a_document_too_deep_to_decode_is_not_a_package_and_does_not_raise with the exact RecursionError.
  • One rule in this revision YIELDS rather than adds: main's own api_artifact_update now validates a submitted binding's target (crew member exists, slug not shared, session live) and answers 400, so this change's broader owner gate is asked AFTER it instead of replacing all of those refusals with a single 403. Nothing is weakened -- the owner gate still refuses a worker rebinding another crewmate's page to a valid target, and the snapshot read it depends on still refuses an unreadable or absent record before either gate decides. One narrowing came with it: an app is identified by its id STRING, where any truthy value in request['app'] was read as one.
  • Two rules tightened in this revision, neither relaxed. The page's script grant was derived from the composed ceiling alone; it is now POLICY AND the owner's active PROFILE, asked through governance_permits (the one place the two are intersected) about an arbitrary host, because a page that runs script can navigate its own frame anywhere. An unresolvable profile withholds script, as an unreadable ceiling already did, and a ceiling that does not govern egress is no longer an answer on its own -- that early return was the standalone default, every install with no policy configured. Dropping the profile half reddens 2 tests in TestTheProfileIsAskedTooNotJustThePolicy. Separately, the applied version's bytes are now required to come from the same RECORD the approval was read from (created_at), because a slug is reusable and a version number restarts at 1; dropping that comparison reddens TestAnApprovalDoesNotAuthorizeAReplacement::test_a_recreated_record_renders_nothing.
  • The script grant tightened twice more in this revision, never loosened. It is resolved for the SURFACE the page belongs to (the crewmate's own slot), because without a session key the scope resolves to unknown and no surface-bound profile can match -- the intersection then fell back to policy alone. And the profile is tested by ARCHETYPE, the same shape test the ceiling gets, rather than by probing one host: a profile denying github.com permits every other name, so a permitted probe proved nothing about the restriction. Mutating the profile half to return True reddens 3 tests in TestTheProfileIsAskedTooNotJustThePolicy. The resolution also moved off the event loop (_run), since the profile store stats its directory and reloads what moved.
  • The script grant's key is now built by one named function, member_dashboard.governance_session_key(slot), rather than assembled at the call site. A profile is bound to a SURFACE and the surface is read off this key's prefix: a crewmate's slot is a bare member-* string, which the canonical classifier sends to its Slack fallback, so a key built from the slot alone skipped every dashboard-bound profile. The product has no shared builder for this prefix -- it is spelled inline at about a dozen call sites -- so this is the dashboard handler's single spelling, and the test asks the CLASSIFIER what the key resolves to instead of comparing it to a literal. A profile bound to either surface a member page can run on withholds the grant, parameterised so adding a surface cannot leave one ungoverned.
  • One more redaction boundary, swept across every site this change adds rather than the one that was reported: a validation or conflict exception's text now goes through redact_via_context before it becomes an HTTP body. Three sites -- the applied package's parse_package refusal, the frame-compose refusal, and the save path's ArtifactConflictError. The first two quote the value or binding the validator refused, and a stored snapshot's values are not re-validated by whoever wrote them; the third names the SLUG, which is [a-z0-9-] and so cannot be a ghp_ but can be an xoxb- or a glpat- -- the same shapes the named-package read already refuses for. Pre-existing sites outside this change are left alone.
  • This revision refuses a caller the gate previously authorized, and authorizes nobody new: binding_refusal asks the roster how many crewmates resolve to the binding's slug before comparing the caller against it. Slugification is lossy, so a hand-edited roster holding both Atlas and atlas derives one slug from two names, and comparing the caller's slug to the binding's then let EITHER of them write the other's package -- the page that runs script inside the owner's own fold values. More than one owner refuses as dashboard_slug_ambiguous and never picks; the remedy named in the sentence is a person renaming one of them, the same remedy the serve-time refusal already gives. The count comes from dashboard.handlers.members._member_names_for_slug, the roster's own answer that _crewmate_binding_refusal and member_dashboard._resolve already ask, so this is not a fourth spelling of the rule. Mutating len(owners) > 1 to a constant false reddens test_a_slug_two_crews_resolve_to_authorizes_neither for both callers; a roster with one owner still writes its own page, which test_an_unambiguous_owner_is_unaffected_by_the_count pins as the boundary. Evidence on this head: test_dashboard_package_owner_gate.py 78 passed, and the twenty-five suites that reach this module 1930 passed. To undo, delete the owners count and its refusal branch from binding_refusal; the comparison below it is unchanged.
  • This revision is a REBASE onto main, with no behaviour of its own added. Four dashboard changes landed on main under it: per-field upkeep text with helper scripts (dashboard_upkeep.py), operator pages served from the panel-templates folder, the default page showing what a crewmate published, and the removal of the Dynamic Dashboard preview flag. Main wins everywhere those four own the ground, and the check is mechanical rather than asserted: every non-blank line each of the four added is present in this tree, with four reported exceptions all accounted for -- two are the feature-map row and the ApiClient surface list, which are single long lines merged cell-by-cell and token-by-token into strict supersets of main's (no token of main's missing, verified), and two are lines a LATER main commit removed, so matching main means not carrying them. RENDERABLE_SOURCES keeps main's {builtin, user}; the spec page keeps main's two-root section and drops the six lines of mine that claimed one root; memberPanel is dropped from the client surface because main deleted that method; every PREVIEW_DASHBOARD reference and every "behind the feature preview" phrase is gone, and this surface is now just the Dashboard tab. The thirteen locale files each keep BOTH keys, main's dashboard_owner_only and this change's dashboard_values_stale, and each file still parses as JSON.
  • One test of main's is RE-PINNED in this revision, and it ends up stricter rather than looser. test_dashboard_operator_pages.py::test_the_served_page_is_framed_exactly_like_a_built_in_one compared every sandbox={...} in CrewDynamicDashboard.tsx against the literal CREW_DASHBOARD_SANDBOX, which this change's script grant cannot satisfy: a page whose owner the admin ceiling denies egress must be mounted with no grant at all, so both mounts read crewDashboardSandbox(mayRunScript && ...). The product code is untouched. What the test now pins is the property its own docstring names -- one wrapping for an operator page and a built-in one -- as the FUNCTION and its argument instead of the string: every mount calls the single helper, that helper answers only with the two declared grant sets, and every mount hands it the server's own answer rather than a literal. Four mutations each redden it and the restored code is green: a mount wrapping itself in the raw constant, a mount passing true, the helper ignoring the scripts argument, and CREW_DASHBOARD_SANDBOX_STATIC gaining allow-same-origin. The last two are holes main's literal comparison did not cover, so the re-pin adds coverage. Its sibling assertion that the frame reads no page provenance is left exactly as it stands, and so are its CSP and byte-identity assertions.
  • This revision closes a privilege-retention hole in the frontend and grants nothing new. A read that gives the Dashboard tab NO page to be on used to return early on the missing page alone, which left the held document MOUNTED with the allow-scripts it loaded under, plus its candidate and its probation state, until something else made the tab reload. Keying that on the state: empty word alone left two other ways in: a record whose layout lock pins a template_id the catalog no longer holds, which resolves to no package slug and composes nothing, so the body carries neither rendered_html nor a scripts decision; and a read that moves the tab from a package to the crewmate's template instance, which DOES compose a page, so only the surface tells them apart -- an instance version is per record and the html can coincide, so the version-keyed comparison kept the held package page. Under either one a reader goes on looking at a page the record does not have, and if an admin ceiling has since restricted the owner agent's egress that document still holds the grant and can navigate its own frame to a host now forbidden.
  • The fix is one fail-closed guard in the one place a read is applied, with no case exempted for being merely stale: any read with no rendered_html clears the page, the candidate and the script decision; and the page's SURFACE (the package slug, '' for the template instance) is now carried on Loaded and compared ahead of the version in both promotion paths, so a page from another surface is dropped rather than reconciled. state: error stays the one read that leaves the held page alone, because it is a different answer -- the read succeeded and says the crewmate's NEWER stored copy does not parse, so the page on screen is still the record's last good one and stays under a band, which test_the_last_page_that_parsed and its siblings pin.
  • Evidence, by mutation rather than by assertion: restoring the early return on a missing composed page reddens 3 tests in CrewDynamicDashboard.revocation.test.tsx; removing the surface check from either promotion path, or from both, reddens tells the surfaces apart when the version and the html both coincide. That test is read in the UNDER-granting direction because that is the one a frame shows: a static package page, then the template instance at the same version with the same bytes, which may run script. Its two siblings pin the security direction -- a scripted package page held, then a read that composes nothing, and the same page then moved to a template answering scripts: false: no allow-scripts frame survives either. Two limits are pinned too, so the rule cannot be satisfied by blanking the tab: a read for the SAME package does not remount, and the template's page does reach the frame. One line is NOT independently observable and is not claimed as tested: resetting mayRunScript to false inside the clear changes nothing a frame can show, because the page is cleared in the same branch and no iframe mounts at all. It is there because an absent scripts field is the absence of a decision rather than the last decision, and the next read that establishes a page overwrites it from that page's own answer.
  • Counts on this head: the twenty-six backend suites reaching the changed module 1960 passed; the frontend members, dashboard, websocket, api-client and preview-surface set 5829 passed across 367 files, with tsc --noEmit and eslint src --max-warnings=0 clean; revocation.test.tsx itself 14 passed. To undo, restore the early return and drop the dashboard field from Loaded and from the two comparisons; the hole returns with it.
  • This revision ADDS AN AUDIT RECORD and changes no decision. The script grant in _serve_package is an authorization decision -- it decides whether a page a crewmate wrote may run script against that crewmate's own fold values -- and it was reached and acted on without leaving a record, which this repository's backend security controls require of a decision of that kind. It now writes one through sel().log_governance_decision, the SAME shared helper agent_backend_governance._audit and every other permission check in the product use, rather than a second emitter: the outcome vocabulary is that helper's own allowed/denied, so a log query for allowed decisions does not miss these rows alone, and the redaction is the helper's own pass over operation, item and reason. The row carries the crewmate, the package slug and its applied version (item), the scope network.egress, the verdict, and the layer plus a reason token -- because a row saying only "denied" cannot be acted on, while ceiling_restricts_egress, profile_restricts_egress, ceiling_unreadable and profile_unresolvable have different remedies and only some are a misconfiguration. Producing the reason split owner_agent_egress_unrestricted into a thin boolean wrapper over _egress_decision, which returns the verdict with its layer; every existing caller and all 107 tests of that function still read the boolean unchanged.
  • DEDUPED ON (crewmate, package, version, decision), which is what keeps it an authorization log rather than a page-view log. The tab polls on a timer and refetches on two WS frames, so one open dashboard re-decides this with the same answer for as long as it stays open; a row per read would push the rows that matter out of any practical retention window. A row is written when any part of that tuple changes -- a newly applied version, or a profile edit that flips the verdict. The memory is a dict keyed by (crewmate, package) capped at 256 pairs, bounded for the reason the live-page registry is: the key is a pair an operator can create, so an unbounded map is a slow leak on a long-lived gateway, and evicting the oldest costs at most one repeated row and never a missed change.
  • BEST EFFORT, and the grant cannot move because of it. The call is made AFTER scripts is bound, so the value it records is already settled and this function cannot reach it; the whole body including the dedupe is inside one except Exception that logs at debug; and log_governance_decision without critical enqueues to the background writer, which swallows persistence failures by design. The decision is also remembered BEFORE the write is attempted, so a log that cannot be written costs one lost row rather than one failed write per poll for as long as a tab is open.
  • Evidence by mutation, five tests in test_member_dashboard_package_route.py::TestTheScriptGrantIsAudited driving the REAL route: removing the audit call reddens 4; removing the dedupe check reddens 2; keying the dedupe on the version alone, so a flipped verdict is hidden, reddens 1; letting the emit raise reddens 2; and remembering the decision after the write instead of before reddens 1. The restored code is green at 5. The four the ruling asked for are among them -- a first open writes one row, four identical reads write none, a profile edit that flips scripts from true to false writes a second row naming profile as the layer, and a sel() that raises still answers 200 with the same scripts and the package's own page. Counts on this head: 2037 passed across the twenty-six module suites plus the security-posture and ceiling suites, 1235 across the seventeen this change touches, and test_sel.py with test_security_posture.py green beside them. To undo, delete _audit_page_script_grant, its two module constants and the call in _serve_package, and collapse _egress_decision back into the boolean; nothing else reads them.
  • This revision RESTORES a ratchet this PR had weakened, and narrows a save gate rather than widening one. dashboard_templates.manifest.FOLD_NAMES is the set of crew-log folds a manifest field may bind, and this PR had added the TREE family to it so a package could bind one. That set is shared: parse_manifest gates a TEMPLATE with it, and artifact_store.dashboard_package.fold_names() gates a PACKAGE with it. Only the package surface gained the reader. A tree-keyed fold has no bus scope by design -- it joins the logs of many slots, so no event could carry a key saying which one moved -- and it is READ instead, by member_dashboard_fields.LivePage, which draws a package's page. A template is rendered by member_dashboard._render, whose DashboardFeed reaches a fold only by its scope and has no tree read. So an operator writing a panel-templates page could bind worktree.boards, have parse_manifest accept it, and get a field missing on every read behind a permanent stale band -- exactly the block the gate's own comment exists to refuse.
  • The two sets are now separate: FOLD_NAMES is back to main's value, the two SCOPED families, and a new PACKAGE_FOLD_NAMES is that set plus the tree family, which fold_names() reads. A superset rather than a second list, because the two surfaces answer one question and differ only in what can reach a fold, so a name neither can reach is in neither. Nothing is admitted that was not admitted before this PR: the template gate is byte-identical to main's, and the package gate is the only thing that grew.
  • Three assertions move with it, and the universal one comes back. test_dynamic_dashboard.py had replaced assert dashboard_feed.scope_for(name), name with an allowlist whose entries this PR added, which is the weakening: the universal form is restored for FOLD_NAMES, the reachability form now runs over PACKAGE_FOLD_NAMES, and a third test pins the SPLIT itself -- every tree fold is absent from the template set, present in the package set, and FOLD_NAMES < PACKAGE_FOLD_NAMES -- because re-merging the sets would otherwise still satisfy the package loop, a superset passing a check written for the subset. Main's own test_the_fold_names_come_from_the_manifest_not_a_copy keeps its claim, that this gate reads the manifest module's set and never a copy, and now also asserts the subset relation.
  • Evidence by mutation: re-merging the tree family into FOLD_NAMES, which is the regression itself, reddens 3 tests; pointing fold_names() back at the template set, which makes a package's tree binding unreachable again, reddens 1. The restored code is green at 252 for those two suites and 2081 across the twenty-six module suites plus the dynamic-dashboard, ceiling, security-posture, field-schema and operator-pages suites. To undo, merge the two constants and the universal assertion weakens again with them.
  • The split is now pinned AT THE GATE as well as on the sets, which is the half that was missing. test_a_template_binding_a_tree_fold_is_refused_at_parse builds a template manifest binding each registered tree fold and asserts parse_manifest raises ManifestError naming that fold -- the refusal an operator writing a panel-templates page actually meets, rather than a set-membership assertion standing in for it, and named so the author is told which binding to change instead of being handed a manifest-wide "invalid". Its companion test_a_package_binding_the_same_tree_fold_is_accepted asks dashboard_package.fold_names() the same question, because a package never reaches parse_manifest and its page IS drawn by the reader that resolves a tree fold: together they say the two surfaces answer differently on purpose. Re-merging the two sets reddens 3 of the 6 tests in this group. No product behaviour for a package changes in this revision; it adds the two tests and nothing else.
  • The committed fold catalogue is regenerated to match the split, and it comes out BYTE-IDENTICAL TO MAIN'S. scripts/fold_catalogue.py derives each fold's advertised flag from manifest.FOLD_NAMES -- the set a template's save gate accepts a binding from -- so widening that set had quietly promised a template author it could bind worktree, the one registered tree fold, and the generator's own comment already said why that promise is wrong: "a name outside it is a binding that would be REFUSED". Restoring the template set restores the flag, so folds.json goes back to "advertised": false for worktree and FOLDS.md back to marking it, and git diff origin/main on both files is now empty. That is the clearest statement available that this split did not change what a template may bind: the artifact an authoring agent reads is main's, unmodified. test_fold_catalogue.py is 48 passed, and the full set on this head is 2129.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 8a9e4fc
  • What rule changed: security_posture.py's REGISTRY of redaction boundaries, not any redactor, allowlist or scrub behaviour. One entry is added to _REDACTION_SINKS (field values pushed to a crewmate's dashboard page, produced in dashboard/handlers/member_dashboard_fields.py) and one to NON_EGRESS_REDACTION_MODULES (artifact_store/dashboard_package.py, which calls a redactor to CLASSIFY a field name rather than to emit text).
  • Before -> after (what was allowed/blocked, now): before, neither module existed, so neither was known to the posture audit. After, the value path is declared an egress sink, which means the audit REQUIRES it to scrub every value it produces and fails if it stops; and the package validator is declared non-egress, which means the audit does not require its redactor call to produce outbound text. Nothing that was blocked became allowed: no value reaches a page unscrubbed either side of this change.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the non-egress classification is the one that could leak. If dashboard_package.py did emit redacted content rather than only classifying, declaring it non-egress would exempt a real output boundary from the audit and a field name that redaction rewrites could reach a page unscrubbed. It does not emit: the redactor output is compared against the input, the package is REFUSED when they differ, and the redacted spelling appears only inside the refusal message. The sink entry has no leak shape at all, since registering a sink only adds an obligation.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and ::test_allowlist_has_no_stale_entries both pass on this head, which is the audit reading the registry against every real call site rather than this description being believed. test_member_dashboard_field_push.py::test_every_value_crosses_the_redactor_on_both_paths proves the registered sink actually scrubs on the initial read AND on every later patch.
  • No regression:
    • Tools still work (which tools/commands were run, result): every number below was measured on THIS head, not carried from a parent. every suite that names dashboard_package, binding_refusal, _member_names_for_slug, resolve_bound_slug or artifact_store, twenty-six of them: 1960 passed, 0 failed. The seventeen suites this change touches: 1235 passed, 0 failed. The composition contract: 109 passed. The four integrated dashboard PRs' own suites, fifteen of them: 1004 passed, 0 failed. Nothing in this change is red. The dashboard read and the package save are the two paths these entries describe and both are exercised there.
    • Backward compatible (old config / old data / old callers still work, how checked): yes. Both lists are append-only here, no existing entry is edited or removed, so every module already registered keeps the same classification. An existing package, an existing instance record and an older gateway are unaffected, which test_allowlist_has_no_stale_entries checks from the other direction by failing on an entry that no longer matches a call site.
    • Existing tests (which suites passed on this head): the twenty-six, the seventeen and the fifteen named above, all on this head. Frontend: the members, dashboard, websocket, api-client and preview-surface set, 367 files, 5829 passed and 0 failed, with tsc --noEmit and eslint src --max-warnings=0 both clean.
  • How to undo: delete the two added entries from _REDACTION_SINKS and NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py. They are pure registry rows with no runtime caller, so removing them restores the previous audit exactly; the audit then fails on the two unregistered call sites, which is the state before this PR added those modules.
  • This revision also narrows a write path rather than widening one: ArtifactStore.update now refuses a kind or content write that lands on a record whose CURRENT kind is dashboard unless it carries the content_token of the read it was authorized against, and an ABSENT token is a refusal. Five separate mutations of that clause each redden test_dashboard_package_owner_gate.py::TestAnUntokenedWriteCannotTakeADashboardOver and a run with the clause restored is green. Scoped to writes that can move a page to another owner, so publish_sync's snapshot bump and the deploy route's webapp_metadata write keep last-write-wins, which the 1147 publish and deploy tests above exercise.
  • One correction carried into this revision from the review of its parent: the fence and the caller's own expected_token are asked INDEPENDENTLY. Satisfying the fence with the handler's fresh read and then skipping the caller's compare-and-set would have let an owner's stale tab overwrite a newer layout with no 409, which is a guard REMOVED rather than added, so a content write carrying expected_token is now compared on every kind including this one. Collapsing the two back into one branch reddens test_the_fence_does_not_swallow_the_callers_own_stale_token.
  • This revision adds one more redaction boundary rather than relaxing any: binding_refusal now redacts every name it quotes -- the binding, the caller's crew, and a validation error's own value -- because _BOUND_TO_RE accepts a GitLab-PAT or Slack-bot shape and the named dashboard GET returns that sentence as its HTTP 403 body. Done inside the one function that composes these messages, not at the three routes that return them. Making the redaction identity reddens four of the five tests in TestTheOwnerRefusalRedactsEveryNameItQuotes; the fifth is the limit, which proves an ordinary name is still named. Also: the person's layout lock is now read BEFORE package selection, so a crewmate cannot move the tab off a locked page by writing its own artifact; removing that condition reddens test_the_persons_lock_outranks_the_crewmates_package.
  • This revision closes a crash rather than opening a path: stored_package_binding caught (ValueError, TypeError) from json.loads but not RecursionError, which is a RuntimeError -- so a markdown document beginning with { and nesting deeper than the decoder's stack made every later PATCH of that slug answer 500, including the one replacing it with plain text. It now answers None (not unprovable): the write path's own decoder refuses that depth, so no stored dashboard record can be this deep, and calling it unprovable would refuse every write to an ordinary document. Removing the new arm reddens test_a_document_too_deep_to_decode_is_not_a_package_and_does_not_raise with the exact RecursionError.
  • One rule in this revision YIELDS rather than adds: main's own api_artifact_update now validates a submitted binding's target (crew member exists, slug not shared, session live) and answers 400, so this change's broader owner gate is asked AFTER it instead of replacing all of those refusals with a single 403. Nothing is weakened -- the owner gate still refuses a worker rebinding another crewmate's page to a valid target, and the snapshot read it depends on still refuses an unreadable or absent record before either gate decides. One narrowing came with it: an app is identified by its id STRING, where any truthy value in request['app'] was read as one.
  • Two rules tightened in this revision, neither relaxed. The page's script grant was derived from the composed ceiling alone; it is now POLICY AND the owner's active PROFILE, asked through governance_permits (the one place the two are intersected) about an arbitrary host, because a page that runs script can navigate its own frame anywhere. An unresolvable profile withholds script, as an unreadable ceiling already did, and a ceiling that does not govern egress is no longer an answer on its own -- that early return was the standalone default, every install with no policy configured. Dropping the profile half reddens 2 tests in TestTheProfileIsAskedTooNotJustThePolicy. Separately, the applied version's bytes are now required to come from the same RECORD the approval was read from (created_at), because a slug is reusable and a version number restarts at 1; dropping that comparison reddens TestAnApprovalDoesNotAuthorizeAReplacement::test_a_recreated_record_renders_nothing.
  • The script grant tightened twice more in this revision, never loosened. It is resolved for the SURFACE the page belongs to (the crewmate's own slot), because without a session key the scope resolves to unknown and no surface-bound profile can match -- the intersection then fell back to policy alone. And the profile is tested by ARCHETYPE, the same shape test the ceiling gets, rather than by probing one host: a profile denying github.com permits every other name, so a permitted probe proved nothing about the restriction. Mutating the profile half to return True reddens 3 tests in TestTheProfileIsAskedTooNotJustThePolicy. The resolution also moved off the event loop (_run), since the profile store stats its directory and reloads what moved.
  • The script grant's key is now built by one named function, member_dashboard.governance_session_key(slot), rather than assembled at the call site. A profile is bound to a SURFACE and the surface is read off this key's prefix: a crewmate's slot is a bare member-* string, which the canonical classifier sends to its Slack fallback, so a key built from the slot alone skipped every dashboard-bound profile. The product has no shared builder for this prefix -- it is spelled inline at about a dozen call sites -- so this is the dashboard handler's single spelling, and the test asks the CLASSIFIER what the key resolves to instead of comparing it to a literal. A profile bound to either surface a member page can run on withholds the grant, parameterised so adding a surface cannot leave one ungoverned.
  • One more redaction boundary, swept across every site this change adds rather than the one that was reported: a validation or conflict exception's text now goes through redact_via_context before it becomes an HTTP body. Three sites -- the applied package's parse_package refusal, the frame-compose refusal, and the save path's ArtifactConflictError. The first two quote the value or binding the validator refused, and a stored snapshot's values are not re-validated by whoever wrote them; the third names the SLUG, which is [a-z0-9-] and so cannot be a ghp_ but can be an xoxb- or a glpat- -- the same shapes the named-package read already refuses for. Pre-existing sites outside this change are left alone.
  • This revision refuses a caller the gate previously authorized, and authorizes nobody new: binding_refusal asks the roster how many crewmates resolve to the binding's slug before comparing the caller against it. Slugification is lossy, so a hand-edited roster holding both Atlas and atlas derives one slug from two names, and comparing the caller's slug to the binding's then let EITHER of them write the other's package -- the page that runs script inside the owner's own fold values. More than one owner refuses as dashboard_slug_ambiguous and never picks; the remedy named in the sentence is a person renaming one of them, the same remedy the serve-time refusal already gives. The count comes from dashboard.handlers.members._member_names_for_slug, the roster's own answer that _crewmate_binding_refusal and member_dashboard._resolve already ask, so this is not a fourth spelling of the rule. Mutating len(owners) > 1 to a constant false reddens test_a_slug_two_crews_resolve_to_authorizes_neither for both callers; a roster with one owner still writes its own page, which test_an_unambiguous_owner_is_unaffected_by_the_count pins as the boundary. Evidence on this head: test_dashboard_package_owner_gate.py 78 passed, and the twenty-five suites that reach this module 1930 passed. To undo, delete the owners count and its refusal branch from binding_refusal; the comparison below it is unchanged.
  • This revision is a REBASE onto main, with no behaviour of its own added. Four dashboard changes landed on main under it: per-field upkeep text with helper scripts (dashboard_upkeep.py), operator pages served from the panel-templates folder, the default page showing what a crewmate published, and the removal of the Dynamic Dashboard preview flag. Main wins everywhere those four own the ground, and the check is mechanical rather than asserted: every non-blank line each of the four added is present in this tree, with four reported exceptions all accounted for -- two are the feature-map row and the ApiClient surface list, which are single long lines merged cell-by-cell and token-by-token into strict supersets of main's (no token of main's missing, verified), and two are lines a LATER main commit removed, so matching main means not carrying them. RENDERABLE_SOURCES keeps main's {builtin, user}; the spec page keeps main's two-root section and drops the six lines of mine that claimed one root; memberPanel is dropped from the client surface because main deleted that method; every PREVIEW_DASHBOARD reference and every "behind the feature preview" phrase is gone, and this surface is now just the Dashboard tab. The thirteen locale files each keep BOTH keys, main's dashboard_owner_only and this change's dashboard_values_stale, and each file still parses as JSON.
  • One test of main's is RE-PINNED in this revision, and it ends up stricter rather than looser. test_dashboard_operator_pages.py::test_the_served_page_is_framed_exactly_like_a_built_in_one compared every sandbox={...} in CrewDynamicDashboard.tsx against the literal CREW_DASHBOARD_SANDBOX, which this change's script grant cannot satisfy: a page whose owner the admin ceiling denies egress must be mounted with no grant at all, so both mounts read crewDashboardSandbox(mayRunScript && ...). The product code is untouched. What the test now pins is the property its own docstring names -- one wrapping for an operator page and a built-in one -- as the FUNCTION and its argument instead of the string: every mount calls the single helper, that helper answers only with the two declared grant sets, and every mount hands it the server's own answer rather than a literal. Four mutations each redden it and the restored code is green: a mount wrapping itself in the raw constant, a mount passing true, the helper ignoring the scripts argument, and CREW_DASHBOARD_SANDBOX_STATIC gaining allow-same-origin. The last two are holes main's literal comparison did not cover, so the re-pin adds coverage. Its sibling assertion that the frame reads no page provenance is left exactly as it stands, and so are its CSP and byte-identity assertions.
  • This revision closes a privilege-retention hole in the frontend and grants nothing new. A read that gives the Dashboard tab NO page to be on used to return early on the missing page alone, which left the held document MOUNTED with the allow-scripts it loaded under, plus its candidate and its probation state, until something else made the tab reload. Keying that on the state: empty word alone left two other ways in: a record whose layout lock pins a template_id the catalog no longer holds, which resolves to no package slug and composes nothing, so the body carries neither rendered_html nor a scripts decision; and a read that moves the tab from a package to the crewmate's template instance, which DOES compose a page, so only the surface tells them apart -- an instance version is per record and the html can coincide, so the version-keyed comparison kept the held package page. Under either one a reader goes on looking at a page the record does not have, and if an admin ceiling has since restricted the owner agent's egress that document still holds the grant and can navigate its own frame to a host now forbidden.
  • The fix is one fail-closed guard in the one place a read is applied, with no case exempted for being merely stale: any read with no rendered_html clears the page, the candidate and the script decision; and the page's SURFACE (the package slug, '' for the template instance) is now carried on Loaded and compared ahead of the version in both promotion paths, so a page from another surface is dropped rather than reconciled. state: error stays the one read that leaves the held page alone, because it is a different answer -- the read succeeded and says the crewmate's NEWER stored copy does not parse, so the page on screen is still the record's last good one and stays under a band, which test_the_last_page_that_parsed and its siblings pin.
  • Evidence, by mutation rather than by assertion: restoring the early return on a missing composed page reddens 3 tests in CrewDynamicDashboard.revocation.test.tsx; removing the surface check from either promotion path, or from both, reddens tells the surfaces apart when the version and the html both coincide. That test is read in the UNDER-granting direction because that is the one a frame shows: a static package page, then the template instance at the same version with the same bytes, which may run script. Its two siblings pin the security direction -- a scripted package page held, then a read that composes nothing, and the same page then moved to a template answering scripts: false: no allow-scripts frame survives either. Two limits are pinned too, so the rule cannot be satisfied by blanking the tab: a read for the SAME package does not remount, and the template's page does reach the frame. One line is NOT independently observable and is not claimed as tested: resetting mayRunScript to false inside the clear changes nothing a frame can show, because the page is cleared in the same branch and no iframe mounts at all. It is there because an absent scripts field is the absence of a decision rather than the last decision, and the next read that establishes a page overwrites it from that page's own answer.
  • Counts on this head: the twenty-six backend suites reaching the changed module 1960 passed; the frontend members, dashboard, websocket, api-client and preview-surface set 5829 passed across 367 files, with tsc --noEmit and eslint src --max-warnings=0 clean; revocation.test.tsx itself 14 passed. To undo, restore the early return and drop the dashboard field from Loaded and from the two comparisons; the hole returns with it.
  • This revision ADDS AN AUDIT RECORD and changes no decision. The script grant in _serve_package is an authorization decision -- it decides whether a page a crewmate wrote may run script against that crewmate's own fold values -- and it was reached and acted on without leaving a record, which this repository's backend security controls require of a decision of that kind. It now writes one through sel().log_governance_decision, the SAME shared helper agent_backend_governance._audit and every other permission check in the product use, rather than a second emitter: the outcome vocabulary is that helper's own allowed/denied, so a log query for allowed decisions does not miss these rows alone, and the redaction is the helper's own pass over operation, item and reason. The row carries the crewmate, the package slug and its applied version (item), the scope network.egress, the verdict, and the layer plus a reason token -- because a row saying only "denied" cannot be acted on, while ceiling_restricts_egress, profile_restricts_egress, ceiling_unreadable and profile_unresolvable have different remedies and only some are a misconfiguration. Producing the reason split owner_agent_egress_unrestricted into a thin boolean wrapper over _egress_decision, which returns the verdict with its layer; every existing caller and all 107 tests of that function still read the boolean unchanged.
  • DEDUPED ON (crewmate, package, version, decision), which is what keeps it an authorization log rather than a page-view log. The tab polls on a timer and refetches on two WS frames, so one open dashboard re-decides this with the same answer for as long as it stays open; a row per read would push the rows that matter out of any practical retention window. A row is written when any part of that tuple changes -- a newly applied version, or a profile edit that flips the verdict. The memory is a dict keyed by (crewmate, package) capped at 256 pairs, bounded for the reason the live-page registry is: the key is a pair an operator can create, so an unbounded map is a slow leak on a long-lived gateway, and evicting the oldest costs at most one repeated row and never a missed change.
  • BEST EFFORT, and the grant cannot move because of it. The call is made AFTER scripts is bound, so the value it records is already settled and this function cannot reach it; the whole body including the dedupe is inside one except Exception that logs at debug; and log_governance_decision without critical enqueues to the background writer, which swallows persistence failures by design. The decision is also remembered BEFORE the write is attempted, so a log that cannot be written costs one lost row rather than one failed write per poll for as long as a tab is open.
  • Evidence by mutation, five tests in test_member_dashboard_package_route.py::TestTheScriptGrantIsAudited driving the REAL route: removing the audit call reddens 4; removing the dedupe check reddens 2; keying the dedupe on the version alone, so a flipped verdict is hidden, reddens 1; letting the emit raise reddens 2; and remembering the decision after the write instead of before reddens 1. The restored code is green at 5. The four the ruling asked for are among them -- a first open writes one row, four identical reads write none, a profile edit that flips scripts from true to false writes a second row naming profile as the layer, and a sel() that raises still answers 200 with the same scripts and the package's own page. Counts on this head: 2037 passed across the twenty-six module suites plus the security-posture and ceiling suites, 1235 across the seventeen this change touches, and test_sel.py with test_security_posture.py green beside them. To undo, delete _audit_page_script_grant, its two module constants and the call in _serve_package, and collapse _egress_decision back into the boolean; nothing else reads them.
  • This revision RESTORES a ratchet this PR had weakened, and narrows a save gate rather than widening one. dashboard_templates.manifest.FOLD_NAMES is the set of crew-log folds a manifest field may bind, and this PR had added the TREE family to it so a package could bind one. That set is shared: parse_manifest gates a TEMPLATE with it, and artifact_store.dashboard_package.fold_names() gates a PACKAGE with it. Only the package surface gained the reader. A tree-keyed fold has no bus scope by design -- it joins the logs of many slots, so no event could carry a key saying which one moved -- and it is READ instead, by member_dashboard_fields.LivePage, which draws a package's page. A template is rendered by member_dashboard._render, whose DashboardFeed reaches a fold only by its scope and has no tree read. So an operator writing a panel-templates page could bind worktree.boards, have parse_manifest accept it, and get a field missing on every read behind a permanent stale band -- exactly the block the gate's own comment exists to refuse.
  • The two sets are now separate: FOLD_NAMES is back to main's value, the two SCOPED families, and a new PACKAGE_FOLD_NAMES is that set plus the tree family, which fold_names() reads. A superset rather than a second list, because the two surfaces answer one question and differ only in what can reach a fold, so a name neither can reach is in neither. Nothing is admitted that was not admitted before this PR: the template gate is byte-identical to main's, and the package gate is the only thing that grew.
  • Three assertions move with it, and the universal one comes back. test_dynamic_dashboard.py had replaced assert dashboard_feed.scope_for(name), name with an allowlist whose entries this PR added, which is the weakening: the universal form is restored for FOLD_NAMES, the reachability form now runs over PACKAGE_FOLD_NAMES, and a third test pins the SPLIT itself -- every tree fold is absent from the template set, present in the package set, and FOLD_NAMES < PACKAGE_FOLD_NAMES -- because re-merging the sets would otherwise still satisfy the package loop, a superset passing a check written for the subset. Main's own test_the_fold_names_come_from_the_manifest_not_a_copy keeps its claim, that this gate reads the manifest module's set and never a copy, and now also asserts the subset relation.
  • Evidence by mutation: re-merging the tree family into FOLD_NAMES, which is the regression itself, reddens 3 tests; pointing fold_names() back at the template set, which makes a package's tree binding unreachable again, reddens 1. The restored code is green at 252 for those two suites and 2081 across the twenty-six module suites plus the dynamic-dashboard, ceiling, security-posture, field-schema and operator-pages suites. To undo, merge the two constants and the universal assertion weakens again with them.
  • The split is now pinned AT THE GATE as well as on the sets, which is the half that was missing. test_a_template_binding_a_tree_fold_is_refused_at_parse builds a template manifest binding each registered tree fold and asserts parse_manifest raises ManifestError naming that fold -- the refusal an operator writing a panel-templates page actually meets, rather than a set-membership assertion standing in for it, and named so the author is told which binding to change instead of being handed a manifest-wide "invalid". Its companion test_a_package_binding_the_same_tree_fold_is_accepted asks dashboard_package.fold_names() the same question, because a package never reaches parse_manifest and its page IS drawn by the reader that resolves a tree fold: together they say the two surfaces answer differently on purpose. Re-merging the two sets reddens 3 of the 6 tests in this group. No product behaviour for a package changes in this revision; it adds the two tests and nothing else.
  • The committed fold catalogue is regenerated to match the split, and it comes out BYTE-IDENTICAL TO MAIN'S. scripts/fold_catalogue.py derives each fold's advertised flag from manifest.FOLD_NAMES -- the set a template's save gate accepts a binding from -- so widening that set had quietly promised a template author it could bind worktree, the one registered tree fold, and the generator's own comment already said why that promise is wrong: "a name outside it is a binding that would be REFUSED". Restoring the template set restores the flag, so folds.json goes back to "advertised": false for worktree and FOLDS.md back to marking it, and git diff origin/main on both files is now empty. That is the clearest statement available that this split did not change what a template may bind: the artifact an authoring agent reads is main's, unmodified. test_fold_catalogue.py is 48 passed, and the full set on this head is 2129.
  • Four tests of this PR's own were asking the WRONG GATE, and the split exposed them rather than breaking them. test_crew_log_worktree_fold.py and test_crew_log_worktree_read.py built blocks that bind the tree fold and validated them through parse_manifest, which worked only while one set served both surfaces. One of them is even named test_a_v3_package_block_binding_the_tree_validates: a PACKAGE block, checked by the template loader. They now go through the gate a package actually passes -- dashboard_package.validate_package, the caller of fold_names(), then member_dashboard_fields.package_manifest, the translation the feed subscribes by -- and the end-to-end claim is unchanged and still end to end: the binding validates and the same bound path, walked over the value this fold folded from three logs, comes back with the rows. Their view.html became an inline body because the package validator refuses a document tag, which is the host's to supply.
  • The fourth, test_the_catalogue_advertises_the_fold_now_that_a_reader_exists, had its PREMISE inverted and is renamed test_the_template_catalogue_still_withholds_the_fold. That catalogue belongs to the dashboard-template skill, which scaffolds templates, so withheld is the honest answer and it is still withheld by the same derived expression rather than a hand edit. It now also asserts the fold IS in the package set, so the document and the two gates are pinned together in one place.
  • One process note, recorded because it is the reason these four reached CI at all: my local run this round was the module set plus a few named suites, not the full list of suites this PR touches, and these two files are in that list. The counts below are from the full list -- git diff --name-only origin/main...HEAD -- test/ plus the module set plus the catalogue, ceiling, security-posture, field-schema and operator-pages suites -- 2581 passed, 0 failed, and the fold-catalogue gate confirms the committed catalogue still matches the code.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: ccb012a
  • What rule changed: security_posture.py's REGISTRY of redaction boundaries, not any redactor, allowlist or scrub behaviour. One entry is added to _REDACTION_SINKS (field values pushed to a crewmate's dashboard page, produced in dashboard/handlers/member_dashboard_fields.py) and one to NON_EGRESS_REDACTION_MODULES (artifact_store/dashboard_package.py, which calls a redactor to CLASSIFY a field name rather than to emit text).
  • Before -> after (what was allowed/blocked, now): before, neither module existed, so neither was known to the posture audit. After, the value path is declared an egress sink, which means the audit REQUIRES it to scrub every value it produces and fails if it stops; and the package validator is declared non-egress, which means the audit does not require its redactor call to produce outbound text. Nothing that was blocked became allowed: no value reaches a page unscrubbed either side of this change.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the non-egress classification is the one that could leak. If dashboard_package.py did emit redacted content rather than only classifying, declaring it non-egress would exempt a real output boundary from the audit and a field name that redaction rewrites could reach a page unscrubbed. It does not emit: the redactor output is compared against the input, the package is REFUSED when they differ, and the redacted spelling appears only inside the refusal message. The sink entry has no leak shape at all, since registering a sink only adds an obligation.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and ::test_allowlist_has_no_stale_entries both pass on this head, which is the audit reading the registry against every real call site rather than this description being believed. test_member_dashboard_field_push.py::test_every_value_crosses_the_redactor_on_both_paths proves the registered sink actually scrubs on the initial read AND on every later patch.
  • No regression:
    • Tools still work (which tools/commands were run, result): every number below was measured on THIS head, not carried from a parent. every suite that names dashboard_package, binding_refusal, _member_names_for_slug, resolve_bound_slug or artifact_store, twenty-six of them: 1960 passed, 0 failed. The seventeen suites this change touches: 1235 passed, 0 failed. The composition contract: 109 passed. The four integrated dashboard PRs' own suites, fifteen of them: 1004 passed, 0 failed. Nothing in this change is red. The dashboard read and the package save are the two paths these entries describe and both are exercised there.
    • Backward compatible (old config / old data / old callers still work, how checked): yes. Both lists are append-only here, no existing entry is edited or removed, so every module already registered keeps the same classification. An existing package, an existing instance record and an older gateway are unaffected, which test_allowlist_has_no_stale_entries checks from the other direction by failing on an entry that no longer matches a call site.
    • Existing tests (which suites passed on this head): the twenty-six, the seventeen and the fifteen named above, all on this head. Frontend: the members, dashboard, websocket, api-client and preview-surface set, 367 files, 5829 passed and 0 failed, with tsc --noEmit and eslint src --max-warnings=0 both clean.
  • How to undo: delete the two added entries from _REDACTION_SINKS and NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py. They are pure registry rows with no runtime caller, so removing them restores the previous audit exactly; the audit then fails on the two unregistered call sites, which is the state before this PR added those modules.
  • This revision also narrows a write path rather than widening one: ArtifactStore.update now refuses a kind or content write that lands on a record whose CURRENT kind is dashboard unless it carries the content_token of the read it was authorized against, and an ABSENT token is a refusal. Five separate mutations of that clause each redden test_dashboard_package_owner_gate.py::TestAnUntokenedWriteCannotTakeADashboardOver and a run with the clause restored is green. Scoped to writes that can move a page to another owner, so publish_sync's snapshot bump and the deploy route's webapp_metadata write keep last-write-wins, which the 1147 publish and deploy tests above exercise.
  • One correction carried into this revision from the review of its parent: the fence and the caller's own expected_token are asked INDEPENDENTLY. Satisfying the fence with the handler's fresh read and then skipping the caller's compare-and-set would have let an owner's stale tab overwrite a newer layout with no 409, which is a guard REMOVED rather than added, so a content write carrying expected_token is now compared on every kind including this one. Collapsing the two back into one branch reddens test_the_fence_does_not_swallow_the_callers_own_stale_token.
  • This revision adds one more redaction boundary rather than relaxing any: binding_refusal now redacts every name it quotes -- the binding, the caller's crew, and a validation error's own value -- because _BOUND_TO_RE accepts a GitLab-PAT or Slack-bot shape and the named dashboard GET returns that sentence as its HTTP 403 body. Done inside the one function that composes these messages, not at the three routes that return them. Making the redaction identity reddens four of the five tests in TestTheOwnerRefusalRedactsEveryNameItQuotes; the fifth is the limit, which proves an ordinary name is still named. Also: the person's layout lock is now read BEFORE package selection, so a crewmate cannot move the tab off a locked page by writing its own artifact; removing that condition reddens test_the_persons_lock_outranks_the_crewmates_package.
  • This revision closes a crash rather than opening a path: stored_package_binding caught (ValueError, TypeError) from json.loads but not RecursionError, which is a RuntimeError -- so a markdown document beginning with { and nesting deeper than the decoder's stack made every later PATCH of that slug answer 500, including the one replacing it with plain text. It now answers None (not unprovable): the write path's own decoder refuses that depth, so no stored dashboard record can be this deep, and calling it unprovable would refuse every write to an ordinary document. Removing the new arm reddens test_a_document_too_deep_to_decode_is_not_a_package_and_does_not_raise with the exact RecursionError.
  • One rule in this revision YIELDS rather than adds: main's own api_artifact_update now validates a submitted binding's target (crew member exists, slug not shared, session live) and answers 400, so this change's broader owner gate is asked AFTER it instead of replacing all of those refusals with a single 403. Nothing is weakened -- the owner gate still refuses a worker rebinding another crewmate's page to a valid target, and the snapshot read it depends on still refuses an unreadable or absent record before either gate decides. One narrowing came with it: an app is identified by its id STRING, where any truthy value in request['app'] was read as one.
  • Two rules tightened in this revision, neither relaxed. The page's script grant was derived from the composed ceiling alone; it is now POLICY AND the owner's active PROFILE, asked through governance_permits (the one place the two are intersected) about an arbitrary host, because a page that runs script can navigate its own frame anywhere. An unresolvable profile withholds script, as an unreadable ceiling already did, and a ceiling that does not govern egress is no longer an answer on its own -- that early return was the standalone default, every install with no policy configured. Dropping the profile half reddens 2 tests in TestTheProfileIsAskedTooNotJustThePolicy. Separately, the applied version's bytes are now required to come from the same RECORD the approval was read from (created_at), because a slug is reusable and a version number restarts at 1; dropping that comparison reddens TestAnApprovalDoesNotAuthorizeAReplacement::test_a_recreated_record_renders_nothing.
  • The script grant tightened twice more in this revision, never loosened. It is resolved for the SURFACE the page belongs to (the crewmate's own slot), because without a session key the scope resolves to unknown and no surface-bound profile can match -- the intersection then fell back to policy alone. And the profile is tested by ARCHETYPE, the same shape test the ceiling gets, rather than by probing one host: a profile denying github.com permits every other name, so a permitted probe proved nothing about the restriction. Mutating the profile half to return True reddens 3 tests in TestTheProfileIsAskedTooNotJustThePolicy. The resolution also moved off the event loop (_run), since the profile store stats its directory and reloads what moved.
  • The script grant's key is now built by one named function, member_dashboard.governance_session_key(slot), rather than assembled at the call site. A profile is bound to a SURFACE and the surface is read off this key's prefix: a crewmate's slot is a bare member-* string, which the canonical classifier sends to its Slack fallback, so a key built from the slot alone skipped every dashboard-bound profile. The product has no shared builder for this prefix -- it is spelled inline at about a dozen call sites -- so this is the dashboard handler's single spelling, and the test asks the CLASSIFIER what the key resolves to instead of comparing it to a literal. A profile bound to either surface a member page can run on withholds the grant, parameterised so adding a surface cannot leave one ungoverned.
  • One more redaction boundary, swept across every site this change adds rather than the one that was reported: a validation or conflict exception's text now goes through redact_via_context before it becomes an HTTP body. Three sites -- the applied package's parse_package refusal, the frame-compose refusal, and the save path's ArtifactConflictError. The first two quote the value or binding the validator refused, and a stored snapshot's values are not re-validated by whoever wrote them; the third names the SLUG, which is [a-z0-9-] and so cannot be a ghp_ but can be an xoxb- or a glpat- -- the same shapes the named-package read already refuses for. Pre-existing sites outside this change are left alone.
  • This revision refuses a caller the gate previously authorized, and authorizes nobody new: binding_refusal asks the roster how many crewmates resolve to the binding's slug before comparing the caller against it. Slugification is lossy, so a hand-edited roster holding both Atlas and atlas derives one slug from two names, and comparing the caller's slug to the binding's then let EITHER of them write the other's package -- the page that runs script inside the owner's own fold values. More than one owner refuses as dashboard_slug_ambiguous and never picks; the remedy named in the sentence is a person renaming one of them, the same remedy the serve-time refusal already gives. The count comes from dashboard.handlers.members._member_names_for_slug, the roster's own answer that _crewmate_binding_refusal and member_dashboard._resolve already ask, so this is not a fourth spelling of the rule. Mutating len(owners) > 1 to a constant false reddens test_a_slug_two_crews_resolve_to_authorizes_neither for both callers; a roster with one owner still writes its own page, which test_an_unambiguous_owner_is_unaffected_by_the_count pins as the boundary. Evidence on this head: test_dashboard_package_owner_gate.py 78 passed, and the twenty-five suites that reach this module 1930 passed. To undo, delete the owners count and its refusal branch from binding_refusal; the comparison below it is unchanged.
  • This revision is a REBASE onto main, with no behaviour of its own added. Four dashboard changes landed on main under it: per-field upkeep text with helper scripts (dashboard_upkeep.py), operator pages served from the panel-templates folder, the default page showing what a crewmate published, and the removal of the Dynamic Dashboard preview flag. Main wins everywhere those four own the ground, and the check is mechanical rather than asserted: every non-blank line each of the four added is present in this tree, with four reported exceptions all accounted for -- two are the feature-map row and the ApiClient surface list, which are single long lines merged cell-by-cell and token-by-token into strict supersets of main's (no token of main's missing, verified), and two are lines a LATER main commit removed, so matching main means not carrying them. RENDERABLE_SOURCES keeps main's {builtin, user}; the spec page keeps main's two-root section and drops the six lines of mine that claimed one root; memberPanel is dropped from the client surface because main deleted that method; every PREVIEW_DASHBOARD reference and every "behind the feature preview" phrase is gone, and this surface is now just the Dashboard tab. The thirteen locale files each keep BOTH keys, main's dashboard_owner_only and this change's dashboard_values_stale, and each file still parses as JSON.
  • One test of main's is RE-PINNED in this revision, and it ends up stricter rather than looser. test_dashboard_operator_pages.py::test_the_served_page_is_framed_exactly_like_a_built_in_one compared every sandbox={...} in CrewDynamicDashboard.tsx against the literal CREW_DASHBOARD_SANDBOX, which this change's script grant cannot satisfy: a page whose owner the admin ceiling denies egress must be mounted with no grant at all, so both mounts read crewDashboardSandbox(mayRunScript && ...). The product code is untouched. What the test now pins is the property its own docstring names -- one wrapping for an operator page and a built-in one -- as the FUNCTION and its argument instead of the string: every mount calls the single helper, that helper answers only with the two declared grant sets, and every mount hands it the server's own answer rather than a literal. Four mutations each redden it and the restored code is green: a mount wrapping itself in the raw constant, a mount passing true, the helper ignoring the scripts argument, and CREW_DASHBOARD_SANDBOX_STATIC gaining allow-same-origin. The last two are holes main's literal comparison did not cover, so the re-pin adds coverage. Its sibling assertion that the frame reads no page provenance is left exactly as it stands, and so are its CSP and byte-identity assertions.
  • This revision closes a privilege-retention hole in the frontend and grants nothing new. A read that gives the Dashboard tab NO page to be on used to return early on the missing page alone, which left the held document MOUNTED with the allow-scripts it loaded under, plus its candidate and its probation state, until something else made the tab reload. Keying that on the state: empty word alone left two other ways in: a record whose layout lock pins a template_id the catalog no longer holds, which resolves to no package slug and composes nothing, so the body carries neither rendered_html nor a scripts decision; and a read that moves the tab from a package to the crewmate's template instance, which DOES compose a page, so only the surface tells them apart -- an instance version is per record and the html can coincide, so the version-keyed comparison kept the held package page. Under either one a reader goes on looking at a page the record does not have, and if an admin ceiling has since restricted the owner agent's egress that document still holds the grant and can navigate its own frame to a host now forbidden.
  • The fix is one fail-closed guard in the one place a read is applied, with no case exempted for being merely stale: any read with no rendered_html clears the page, the candidate and the script decision; and the page's SURFACE (the package slug, '' for the template instance) is now carried on Loaded and compared ahead of the version in both promotion paths, so a page from another surface is dropped rather than reconciled. state: error stays the one read that leaves the held page alone, because it is a different answer -- the read succeeded and says the crewmate's NEWER stored copy does not parse, so the page on screen is still the record's last good one and stays under a band, which test_the_last_page_that_parsed and its siblings pin.
  • Evidence, by mutation rather than by assertion: restoring the early return on a missing composed page reddens 3 tests in CrewDynamicDashboard.revocation.test.tsx; removing the surface check from either promotion path, or from both, reddens tells the surfaces apart when the version and the html both coincide. That test is read in the UNDER-granting direction because that is the one a frame shows: a static package page, then the template instance at the same version with the same bytes, which may run script. Its two siblings pin the security direction -- a scripted package page held, then a read that composes nothing, and the same page then moved to a template answering scripts: false: no allow-scripts frame survives either. Two limits are pinned too, so the rule cannot be satisfied by blanking the tab: a read for the SAME package does not remount, and the template's page does reach the frame. One line is NOT independently observable and is not claimed as tested: resetting mayRunScript to false inside the clear changes nothing a frame can show, because the page is cleared in the same branch and no iframe mounts at all. It is there because an absent scripts field is the absence of a decision rather than the last decision, and the next read that establishes a page overwrites it from that page's own answer.
  • Counts on this head: the twenty-six backend suites reaching the changed module 1960 passed; the frontend members, dashboard, websocket, api-client and preview-surface set 5829 passed across 367 files, with tsc --noEmit and eslint src --max-warnings=0 clean; revocation.test.tsx itself 14 passed. To undo, restore the early return and drop the dashboard field from Loaded and from the two comparisons; the hole returns with it.
  • This revision ADDS AN AUDIT RECORD and changes no decision. The script grant in _serve_package is an authorization decision -- it decides whether a page a crewmate wrote may run script against that crewmate's own fold values -- and it was reached and acted on without leaving a record, which this repository's backend security controls require of a decision of that kind. It now writes one through sel().log_governance_decision, the SAME shared helper agent_backend_governance._audit and every other permission check in the product use, rather than a second emitter: the outcome vocabulary is that helper's own allowed/denied, so a log query for allowed decisions does not miss these rows alone, and the redaction is the helper's own pass over operation, item and reason. The row carries the crewmate, the package slug and its applied version (item), the scope network.egress, the verdict, and the layer plus a reason token -- because a row saying only "denied" cannot be acted on, while ceiling_restricts_egress, profile_restricts_egress, ceiling_unreadable and profile_unresolvable have different remedies and only some are a misconfiguration. Producing the reason split owner_agent_egress_unrestricted into a thin boolean wrapper over _egress_decision, which returns the verdict with its layer; every existing caller and all 107 tests of that function still read the boolean unchanged.
  • DEDUPED ON (crewmate, package, version, decision), which is what keeps it an authorization log rather than a page-view log. The tab polls on a timer and refetches on two WS frames, so one open dashboard re-decides this with the same answer for as long as it stays open; a row per read would push the rows that matter out of any practical retention window. A row is written when any part of that tuple changes -- a newly applied version, or a profile edit that flips the verdict. The memory is a dict keyed by (crewmate, package) capped at 256 pairs, bounded for the reason the live-page registry is: the key is a pair an operator can create, so an unbounded map is a slow leak on a long-lived gateway, and evicting the oldest costs at most one repeated row and never a missed change.
  • BEST EFFORT, and the grant cannot move because of it. The call is made AFTER scripts is bound, so the value it records is already settled and this function cannot reach it; the whole body including the dedupe is inside one except Exception that logs at debug; and log_governance_decision without critical enqueues to the background writer, which swallows persistence failures by design. The decision is also remembered BEFORE the write is attempted, so a log that cannot be written costs one lost row rather than one failed write per poll for as long as a tab is open.
  • Evidence by mutation, five tests in test_member_dashboard_package_route.py::TestTheScriptGrantIsAudited driving the REAL route: removing the audit call reddens 4; removing the dedupe check reddens 2; keying the dedupe on the version alone, so a flipped verdict is hidden, reddens 1; letting the emit raise reddens 2; and remembering the decision after the write instead of before reddens 1. The restored code is green at 5. The four the ruling asked for are among them -- a first open writes one row, four identical reads write none, a profile edit that flips scripts from true to false writes a second row naming profile as the layer, and a sel() that raises still answers 200 with the same scripts and the package's own page. Counts on this head: 2037 passed across the twenty-six module suites plus the security-posture and ceiling suites, 1235 across the seventeen this change touches, and test_sel.py with test_security_posture.py green beside them. To undo, delete _audit_page_script_grant, its two module constants and the call in _serve_package, and collapse _egress_decision back into the boolean; nothing else reads them.
  • This revision RESTORES a ratchet this PR had weakened, and narrows a save gate rather than widening one. dashboard_templates.manifest.FOLD_NAMES is the set of crew-log folds a manifest field may bind, and this PR had added the TREE family to it so a package could bind one. That set is shared: parse_manifest gates a TEMPLATE with it, and artifact_store.dashboard_package.fold_names() gates a PACKAGE with it. Only the package surface gained the reader. A tree-keyed fold has no bus scope by design -- it joins the logs of many slots, so no event could carry a key saying which one moved -- and it is READ instead, by member_dashboard_fields.LivePage, which draws a package's page. A template is rendered by member_dashboard._render, whose DashboardFeed reaches a fold only by its scope and has no tree read. So an operator writing a panel-templates page could bind worktree.boards, have parse_manifest accept it, and get a field missing on every read behind a permanent stale band -- exactly the block the gate's own comment exists to refuse.
  • The two sets are now separate: FOLD_NAMES is back to main's value, the two SCOPED families, and a new PACKAGE_FOLD_NAMES is that set plus the tree family, which fold_names() reads. A superset rather than a second list, because the two surfaces answer one question and differ only in what can reach a fold, so a name neither can reach is in neither. Nothing is admitted that was not admitted before this PR: the template gate is byte-identical to main's, and the package gate is the only thing that grew.
  • Three assertions move with it, and the universal one comes back. test_dynamic_dashboard.py had replaced assert dashboard_feed.scope_for(name), name with an allowlist whose entries this PR added, which is the weakening: the universal form is restored for FOLD_NAMES, the reachability form now runs over PACKAGE_FOLD_NAMES, and a third test pins the SPLIT itself -- every tree fold is absent from the template set, present in the package set, and FOLD_NAMES < PACKAGE_FOLD_NAMES -- because re-merging the sets would otherwise still satisfy the package loop, a superset passing a check written for the subset. Main's own test_the_fold_names_come_from_the_manifest_not_a_copy keeps its claim, that this gate reads the manifest module's set and never a copy, and now also asserts the subset relation.
  • Evidence by mutation: re-merging the tree family into FOLD_NAMES, which is the regression itself, reddens 3 tests; pointing fold_names() back at the template set, which makes a package's tree binding unreachable again, reddens 1. The restored code is green at 252 for those two suites and 2081 across the twenty-six module suites plus the dynamic-dashboard, ceiling, security-posture, field-schema and operator-pages suites. To undo, merge the two constants and the universal assertion weakens again with them.
  • The split is now pinned AT THE GATE as well as on the sets, which is the half that was missing. test_a_template_binding_a_tree_fold_is_refused_at_parse builds a template manifest binding each registered tree fold and asserts parse_manifest raises ManifestError naming that fold -- the refusal an operator writing a panel-templates page actually meets, rather than a set-membership assertion standing in for it, and named so the author is told which binding to change instead of being handed a manifest-wide "invalid". Its companion test_a_package_binding_the_same_tree_fold_is_accepted asks dashboard_package.fold_names() the same question, because a package never reaches parse_manifest and its page IS drawn by the reader that resolves a tree fold: together they say the two surfaces answer differently on purpose. Re-merging the two sets reddens 3 of the 6 tests in this group. No product behaviour for a package changes in this revision; it adds the two tests and nothing else.
  • The committed fold catalogue is regenerated to match the split, and it comes out BYTE-IDENTICAL TO MAIN'S. scripts/fold_catalogue.py derives each fold's advertised flag from manifest.FOLD_NAMES -- the set a template's save gate accepts a binding from -- so widening that set had quietly promised a template author it could bind worktree, the one registered tree fold, and the generator's own comment already said why that promise is wrong: "a name outside it is a binding that would be REFUSED". Restoring the template set restores the flag, so folds.json goes back to "advertised": false for worktree and FOLDS.md back to marking it, and git diff origin/main on both files is now empty. That is the clearest statement available that this split did not change what a template may bind: the artifact an authoring agent reads is main's, unmodified. test_fold_catalogue.py is 48 passed, and the full set on this head is 2129.
  • Four tests of this PR's own were asking the WRONG GATE, and the split exposed them rather than breaking them. test_crew_log_worktree_fold.py and test_crew_log_worktree_read.py built blocks that bind the tree fold and validated them through parse_manifest, which worked only while one set served both surfaces. One of them is even named test_a_v3_package_block_binding_the_tree_validates: a PACKAGE block, checked by the template loader. They now go through the gate a package actually passes -- dashboard_package.validate_package, the caller of fold_names(), then member_dashboard_fields.package_manifest, the translation the feed subscribes by -- and the end-to-end claim is unchanged and still end to end: the binding validates and the same bound path, walked over the value this fold folded from three logs, comes back with the rows. Their view.html became an inline body because the package validator refuses a document tag, which is the host's to supply.
  • The fourth, test_the_catalogue_advertises_the_fold_now_that_a_reader_exists, had its PREMISE inverted and is renamed test_the_template_catalogue_still_withholds_the_fold. That catalogue belongs to the dashboard-template skill, which scaffolds templates, so withheld is the honest answer and it is still withheld by the same derived expression rather than a hand edit. It now also asserts the fold IS in the package set, so the document and the two gates are pinned together in one place.
  • One process note, recorded because it is the reason these four reached CI at all: my local run this round was the module set plus a few named suites, not the full list of suites this PR touches, and these two files are in that list. The counts below are from the full list -- git diff --name-only origin/main...HEAD -- test/ plus the module set plus the catalogue, ceiling, security-posture, field-schema and operator-pages suites -- 2581 passed, 0 failed, and the fold-catalogue gate confirms the committed catalogue still matches the code.
  • The catalogue now says WHICH SURFACE may bind a fold, instead of dropping the one only a package can reach. Letting worktree fall back to unadvertised made the two gates consistent but cost a package author the only place they could learn the fold exists: advertised: false reads as "not for you" to BOTH authors, and this document is the whole interface a composing agent has for what folds there are and what fields they carry. scripts/fold_catalogue.py gains a second derived flag, package_only -- true when a fold is bindable, not editorially withheld, outside the TEMPLATE set and inside the PACKAGE set -- and FOLDS.md marks such a fold *(package only)* with a legend paragraph saying why a template may not bind it. class and outline keep *(internal)*, because they are bindable on neither surface, so the two labels now mean different things rather than one standing in for both.
  • Both flags stay DERIVED from the two gate sets, which is what keeps the document from promising a binding either gate turns down; neither is hand-written, and the generator's own equality gate (test_fold_catalogue.py, 48 passed) is what proves the committed bytes match. Evidence by mutation: forcing package_only to False, which is the drop-it-entirely behaviour, reddens 1; computing advertised from the package set, which is the original regression that let a template bind a tree fold, reddens 1. The test that reads this is test_the_template_catalogue_still_withholds_the_fold, which now asserts BOTH halves -- withheld from templates and still offered to packages -- so the catalogue cannot satisfy it by hiding the fold from everyone.
  • The three suites named in the ruling pass locally on this head: test_crew_log_worktree_fold.py, test_fold_catalogue.py and test_dynamic_dashboard.py, 240 passed together. The full list this PR touches plus the module set, the ceiling, security-posture, field-schema, operator-pages and spawn-audit suites is 2597 passed, 0 failed, with black, isort, flake8, comment-history, feature-map, take-away and the fold-catalogue gate all green.

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

Verdict: REQUEST CHANGES — head ccb012a1cc

What it fixes

A crewmate's Dashboard tab can now render a kind="dashboard" package whose view.html the owner agent wrote. The page can also call window.kirocrew.subscribe(name, cb) and redraw from pushed field patches, without reloading. This is the render half of the RFC's decision 3. It serves only a version a person cut, and nothing when no such version exists.

What I verified

  • Sandbox: the frame gets allow-scripts alone, with no allow-same-origin (website/src/pages/members/CrewDynamicDashboard.tsx:41). It gets an empty sandbox when the server withholds scripts. The frame is keyed on the grant, so revoking scripts remounts it (:948).
  • CSP: connect-src 'none', frame-src, form-action and base-uri are all 'none' (src/kiro_crew/dashboard_frame.py:108-120).
  • postMessage: the parent drops any message whose event.source is not this frame's window (CrewDynamicDashboard.tsx:343), and the page's own listener requires event.source === parent (dashboard_frame.py:445).
  • Scope: field frames go to the owner only (ws_event_scope.py, dashboard_fields). Values come only from the model's manifest, rooted at the crewmate's own slot, and are redacted in one place (member_dashboard_fields.py:288-298). The refetch route is owner-gated.
  • Scripts are withheld unless both the policy and the active profile leave egress unrestricted. Any failure to read either withholds them (member_dashboard.py:993-1085).
  • The approval marker requires by == "user" together with an edited or reverted event (member_dashboard.py:1191,1262-1275). That actor exists only for snapshot writes (artifacts.py:1558-1586).
  • 581 Python and 36 frontend tests pass on this head. Each of three mutations turned a named test red:
    • dropping the by check reddened test_an_agent_cannot_spell_its_way_to_an_applied_version;
    • dropping the absent-token refusal reddened test_an_absent_token_cannot_flip_the_kind;
    • letting a restricting profile grant scripts reddened test_an_open_policy_with_a_restricting_profile_gets_NO_scripts.
  • Default users: a crewmate with no binding or with a template is served exactly what it got before. The RFC's second amendment removed the Feature Preview, so no flag is required.

Blocking

  1. The owning spec is stale. docs/system-specs/modules/artifacts.md § Dashboard packages still says "Two rules differ from every other kind". This PR adds three more, and none of them is documented:

    • every write to a record of this kind needs a snapshot token;
    • the bound-owner write gate, including the new refusal for APP tokens;
    • the view.html shape.

    Please document all three in that section.

  2. The RFC says only the save module's apply cuts a live version. This PR defines "applied" as "a version a person cut". That makes a person's save in the artifact editor an approval. It also means #18851's dashboard_apply will never render: it is an agent call over MCP, so its version is recorded as by=agent. Please add an amendment to the RFC that states the marker, and how apply is meant to produce it.

Non-blocking follow-ups

  • Merge order. The RFC allows the renderer to land first, and #18851 at d170224efd still refuses a package apply. #18851 has to adopt this PR's approval marker before it lifts that refusal.
  • publish_sync.pull_upstream now fails on a dashboard record with a generic "write-back failed" (the Design lane flagged this). That is fail-closed. A specific refusal would be clearer.
  • With scripts withheld, the validator does not refuse <meta http-equiv="refresh"> or a full-page link. Either one lets a page navigate somewhere off the egress ceiling. Consider refusing both in the validator.
  • The probe frame's ready listener does not check event.source. This predates the PR.
  • iamwhatever's CHANGES_REQUESTED on 37129cc459 had an empty body and no inline comments. The PR author dismissed it without a message. Please ask the reviewer to re-review rather than leaving it dismissed.

Not verified

  • No real browser run: the meta-refresh behaviour in a sandboxed frame and the CDN-script path were not exercised.
  • I ran no publish or deploy suites.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

@buluoray thanks for the thorough review and the mutation checks.

Blocker 1 (artifacts.md is stale): agreed. The next push documents all three rules in the Dashboard packages section (snapshot token on every write, the bound-owner write gate with the APP token refusal, and the view.html shape). That push is needed anyway, since this PR now conflicts with main.

Blocker 2 (the RFC amendment for the approval marker): I would like to move this to the change that actually lets an apply go live, for three reasons:

  1. No build can reach the mismatch today. feat(dashboard): dashboard_save stages a composed page an agent builds #18851 refuses every package apply with 409 package_display_pending (your own review of it confirms nothing gets bound), and main has no other path that applies a package. So there is no agent-applied package for this renderer to ignore.
  2. The marker here is the conservative side. by == "user" plus edited / reverted can only make fewer pages go live, never more. A person saving the page in the artifact editor counting as approval is intended: a person editing the page is consenting to it.
  3. What is still open is how apply should produce that marker: a person pressing an Apply button on the preview page, or something else. That is a product decision, and it should land in the same PR as the code that obeys it, so the amendment and the behaviour are reviewed together instead of the RFC promising something no code does yet.

So the plan is: this PR ships the renderer with the conservative marker, #18851 ships staging with apply still refused, and a third PR lifts the refusal, with the RFC amendment as its first commit. I will open the tracking issue for that third PR and link it here. Does that work for you?

…cribe (#19060)

A `kind=dashboard` package can carry one `view.html` its owner wrote instead of
the block list, and the frame gains `window.kirocrew.subscribe(name, cb)` so a
page redraws from the field that moved rather than re-reading everything and
losing its own state.

It also carries the tree READ path (`read_tree_projection`,
`fold_tree_checkpoint`, `tree_fold_units`), which moved here from #18777 so it
sits beside its only caller, `member_dashboard_fields.LivePage`.

That reader is why the worktree fold's binding is admitted here too. The tree
key kind joins `manifest.FOLD_NAMES` -- the set the save gate accepts a block's
`source.fold` from -- in the same change that brings something able to resolve
the value, which is the pairing #18777 deferred. The catalogue's `advertised`
flag is derived from that same gate set, so it turns over on regeneration
rather than being edited: the catalogue cannot offer a binding the gate would
refuse, or withhold one it would accept.
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

/ai-review override gpt f4cde7b: No new reach. A page script runs only when the owner agent's egress is unrestricted (member_dashboard.py:1531, fails closed). The field the older tab could receive is one the same agent declared in a version a person already applied, and refetch is owner-gated so it reaches only the owner's own browser (:1599). Adjudication flagged it for the same reason. Binding refetch to the displayed layout version is a follow-up.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: f4cde7b
  • What rule changed: security_posture.py's REGISTRY of redaction boundaries, not any redactor, allowlist or scrub behaviour. One entry is added to _REDACTION_SINKS (field values pushed to a crewmate's dashboard page, produced in dashboard/handlers/member_dashboard_fields.py) and one to NON_EGRESS_REDACTION_MODULES (artifact_store/dashboard_package.py, which calls a redactor to CLASSIFY a field name rather than to emit text).
  • Before -> after (what was allowed/blocked, now): before, neither module existed, so neither was known to the posture audit. After, the value path is declared an egress sink, which means the audit REQUIRES it to scrub every value it produces and fails if it stops; and the package validator is declared non-egress, which means the audit does not require its redactor call to produce outbound text. Nothing that was blocked became allowed: no value reaches a page unscrubbed either side of this change.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the non-egress classification is the one that could leak. If dashboard_package.py did emit redacted content rather than only classifying, declaring it non-egress would exempt a real output boundary from the audit and a field name that redaction rewrites could reach a page unscrubbed. It does not emit: the redactor output is compared against the input, the package is REFUSED when they differ, and the redacted spelling appears only inside the refusal message. The sink entry has no leak shape at all, since registering a sink only adds an obligation.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and ::test_allowlist_has_no_stale_entries both pass on this head, which is the audit reading the registry against every real call site rather than this description being believed. test_member_dashboard_field_push.py::test_every_value_crosses_the_redactor_on_both_paths proves the registered sink actually scrubs on the initial read AND on every later patch.
  • No regression:
    • Tools still work (which tools/commands were run, result): every number below was measured on THIS head, not carried from a parent. every suite that names dashboard_package, binding_refusal, _member_names_for_slug, resolve_bound_slug or artifact_store, twenty-six of them: 1960 passed, 0 failed. The seventeen suites this change touches: 1235 passed, 0 failed. The composition contract: 109 passed. The four integrated dashboard PRs' own suites, fifteen of them: 1004 passed, 0 failed. Nothing in this change is red. The dashboard read and the package save are the two paths these entries describe and both are exercised there.
    • Backward compatible (old config / old data / old callers still work, how checked): yes. Both lists are append-only here, no existing entry is edited or removed, so every module already registered keeps the same classification. An existing package, an existing instance record and an older gateway are unaffected, which test_allowlist_has_no_stale_entries checks from the other direction by failing on an entry that no longer matches a call site.
    • Existing tests (which suites passed on this head): the twenty-six, the seventeen and the fifteen named above, all on this head. Frontend: the members, dashboard, websocket, api-client and preview-surface set, 367 files, 5829 passed and 0 failed, with tsc --noEmit and eslint src --max-warnings=0 both clean.
  • How to undo: delete the two added entries from _REDACTION_SINKS and NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py. They are pure registry rows with no runtime caller, so removing them restores the previous audit exactly; the audit then fails on the two unregistered call sites, which is the state before this PR added those modules.
  • This revision also narrows a write path rather than widening one: ArtifactStore.update now refuses a kind or content write that lands on a record whose CURRENT kind is dashboard unless it carries the content_token of the read it was authorized against, and an ABSENT token is a refusal. Five separate mutations of that clause each redden test_dashboard_package_owner_gate.py::TestAnUntokenedWriteCannotTakeADashboardOver and a run with the clause restored is green. Scoped to writes that can move a page to another owner, so publish_sync's snapshot bump and the deploy route's webapp_metadata write keep last-write-wins, which the 1147 publish and deploy tests above exercise.
  • One correction carried into this revision from the review of its parent: the fence and the caller's own expected_token are asked INDEPENDENTLY. Satisfying the fence with the handler's fresh read and then skipping the caller's compare-and-set would have let an owner's stale tab overwrite a newer layout with no 409, which is a guard REMOVED rather than added, so a content write carrying expected_token is now compared on every kind including this one. Collapsing the two back into one branch reddens test_the_fence_does_not_swallow_the_callers_own_stale_token.
  • This revision adds one more redaction boundary rather than relaxing any: binding_refusal now redacts every name it quotes -- the binding, the caller's crew, and a validation error's own value -- because _BOUND_TO_RE accepts a GitLab-PAT or Slack-bot shape and the named dashboard GET returns that sentence as its HTTP 403 body. Done inside the one function that composes these messages, not at the three routes that return them. Making the redaction identity reddens four of the five tests in TestTheOwnerRefusalRedactsEveryNameItQuotes; the fifth is the limit, which proves an ordinary name is still named. Also: the person's layout lock is now read BEFORE package selection, so a crewmate cannot move the tab off a locked page by writing its own artifact; removing that condition reddens test_the_persons_lock_outranks_the_crewmates_package.
  • This revision closes a crash rather than opening a path: stored_package_binding caught (ValueError, TypeError) from json.loads but not RecursionError, which is a RuntimeError -- so a markdown document beginning with { and nesting deeper than the decoder's stack made every later PATCH of that slug answer 500, including the one replacing it with plain text. It now answers None (not unprovable): the write path's own decoder refuses that depth, so no stored dashboard record can be this deep, and calling it unprovable would refuse every write to an ordinary document. Removing the new arm reddens test_a_document_too_deep_to_decode_is_not_a_package_and_does_not_raise with the exact RecursionError.
  • One rule in this revision YIELDS rather than adds: main's own api_artifact_update now validates a submitted binding's target (crew member exists, slug not shared, session live) and answers 400, so this change's broader owner gate is asked AFTER it instead of replacing all of those refusals with a single 403. Nothing is weakened -- the owner gate still refuses a worker rebinding another crewmate's page to a valid target, and the snapshot read it depends on still refuses an unreadable or absent record before either gate decides. One narrowing came with it: an app is identified by its id STRING, where any truthy value in request['app'] was read as one.
  • Two rules tightened in this revision, neither relaxed. The page's script grant was derived from the composed ceiling alone; it is now POLICY AND the owner's active PROFILE, asked through governance_permits (the one place the two are intersected) about an arbitrary host, because a page that runs script can navigate its own frame anywhere. An unresolvable profile withholds script, as an unreadable ceiling already did, and a ceiling that does not govern egress is no longer an answer on its own -- that early return was the standalone default, every install with no policy configured. Dropping the profile half reddens 2 tests in TestTheProfileIsAskedTooNotJustThePolicy. Separately, the applied version's bytes are now required to come from the same RECORD the approval was read from (created_at), because a slug is reusable and a version number restarts at 1; dropping that comparison reddens TestAnApprovalDoesNotAuthorizeAReplacement::test_a_recreated_record_renders_nothing.
  • The script grant tightened twice more in this revision, never loosened. It is resolved for the SURFACE the page belongs to (the crewmate's own slot), because without a session key the scope resolves to unknown and no surface-bound profile can match -- the intersection then fell back to policy alone. And the profile is tested by ARCHETYPE, the same shape test the ceiling gets, rather than by probing one host: a profile denying github.com permits every other name, so a permitted probe proved nothing about the restriction. Mutating the profile half to return True reddens 3 tests in TestTheProfileIsAskedTooNotJustThePolicy. The resolution also moved off the event loop (_run), since the profile store stats its directory and reloads what moved.
  • The script grant's key is now built by one named function, member_dashboard.governance_session_key(slot), rather than assembled at the call site. A profile is bound to a SURFACE and the surface is read off this key's prefix: a crewmate's slot is a bare member-* string, which the canonical classifier sends to its Slack fallback, so a key built from the slot alone skipped every dashboard-bound profile. The product has no shared builder for this prefix -- it is spelled inline at about a dozen call sites -- so this is the dashboard handler's single spelling, and the test asks the CLASSIFIER what the key resolves to instead of comparing it to a literal. A profile bound to either surface a member page can run on withholds the grant, parameterised so adding a surface cannot leave one ungoverned.
  • One more redaction boundary, swept across every site this change adds rather than the one that was reported: a validation or conflict exception's text now goes through redact_via_context before it becomes an HTTP body. Three sites -- the applied package's parse_package refusal, the frame-compose refusal, and the save path's ArtifactConflictError. The first two quote the value or binding the validator refused, and a stored snapshot's values are not re-validated by whoever wrote them; the third names the SLUG, which is [a-z0-9-] and so cannot be a ghp_ but can be an xoxb- or a glpat- -- the same shapes the named-package read already refuses for. Pre-existing sites outside this change are left alone.
  • This revision refuses a caller the gate previously authorized, and authorizes nobody new: binding_refusal asks the roster how many crewmates resolve to the binding's slug before comparing the caller against it. Slugification is lossy, so a hand-edited roster holding both Atlas and atlas derives one slug from two names, and comparing the caller's slug to the binding's then let EITHER of them write the other's package -- the page that runs script inside the owner's own fold values. More than one owner refuses as dashboard_slug_ambiguous and never picks; the remedy named in the sentence is a person renaming one of them, the same remedy the serve-time refusal already gives. The count comes from dashboard.handlers.members._member_names_for_slug, the roster's own answer that _crewmate_binding_refusal and member_dashboard._resolve already ask, so this is not a fourth spelling of the rule. Mutating len(owners) > 1 to a constant false reddens test_a_slug_two_crews_resolve_to_authorizes_neither for both callers; a roster with one owner still writes its own page, which test_an_unambiguous_owner_is_unaffected_by_the_count pins as the boundary. Evidence on this head: test_dashboard_package_owner_gate.py 78 passed, and the twenty-five suites that reach this module 1930 passed. To undo, delete the owners count and its refusal branch from binding_refusal; the comparison below it is unchanged.
  • This revision is a REBASE onto main, with no behaviour of its own added. Four dashboard changes landed on main under it: per-field upkeep text with helper scripts (dashboard_upkeep.py), operator pages served from the panel-templates folder, the default page showing what a crewmate published, and the removal of the Dynamic Dashboard preview flag. Main wins everywhere those four own the ground, and the check is mechanical rather than asserted: every non-blank line each of the four added is present in this tree, with four reported exceptions all accounted for -- two are the feature-map row and the ApiClient surface list, which are single long lines merged cell-by-cell and token-by-token into strict supersets of main's (no token of main's missing, verified), and two are lines a LATER main commit removed, so matching main means not carrying them. RENDERABLE_SOURCES keeps main's {builtin, user}; the spec page keeps main's two-root section and drops the six lines of mine that claimed one root; memberPanel is dropped from the client surface because main deleted that method; every PREVIEW_DASHBOARD reference and every "behind the feature preview" phrase is gone, and this surface is now just the Dashboard tab. The thirteen locale files each keep BOTH keys, main's dashboard_owner_only and this change's dashboard_values_stale, and each file still parses as JSON.
  • One test of main's is RE-PINNED in this revision, and it ends up stricter rather than looser. test_dashboard_operator_pages.py::test_the_served_page_is_framed_exactly_like_a_built_in_one compared every sandbox={...} in CrewDynamicDashboard.tsx against the literal CREW_DASHBOARD_SANDBOX, which this change's script grant cannot satisfy: a page whose owner the admin ceiling denies egress must be mounted with no grant at all, so both mounts read crewDashboardSandbox(mayRunScript && ...). The product code is untouched. What the test now pins is the property its own docstring names -- one wrapping for an operator page and a built-in one -- as the FUNCTION and its argument instead of the string: every mount calls the single helper, that helper answers only with the two declared grant sets, and every mount hands it the server's own answer rather than a literal. Four mutations each redden it and the restored code is green: a mount wrapping itself in the raw constant, a mount passing true, the helper ignoring the scripts argument, and CREW_DASHBOARD_SANDBOX_STATIC gaining allow-same-origin. The last two are holes main's literal comparison did not cover, so the re-pin adds coverage. Its sibling assertion that the frame reads no page provenance is left exactly as it stands, and so are its CSP and byte-identity assertions.
  • This revision closes a privilege-retention hole in the frontend and grants nothing new. A read that gives the Dashboard tab NO page to be on used to return early on the missing page alone, which left the held document MOUNTED with the allow-scripts it loaded under, plus its candidate and its probation state, until something else made the tab reload. Keying that on the state: empty word alone left two other ways in: a record whose layout lock pins a template_id the catalog no longer holds, which resolves to no package slug and composes nothing, so the body carries neither rendered_html nor a scripts decision; and a read that moves the tab from a package to the crewmate's template instance, which DOES compose a page, so only the surface tells them apart -- an instance version is per record and the html can coincide, so the version-keyed comparison kept the held package page. Under either one a reader goes on looking at a page the record does not have, and if an admin ceiling has since restricted the owner agent's egress that document still holds the grant and can navigate its own frame to a host now forbidden.
  • The fix is one fail-closed guard in the one place a read is applied, with no case exempted for being merely stale: any read with no rendered_html clears the page, the candidate and the script decision; and the page's SURFACE (the package slug, '' for the template instance) is now carried on Loaded and compared ahead of the version in both promotion paths, so a page from another surface is dropped rather than reconciled. state: error stays the one read that leaves the held page alone, because it is a different answer -- the read succeeded and says the crewmate's NEWER stored copy does not parse, so the page on screen is still the record's last good one and stays under a band, which test_the_last_page_that_parsed and its siblings pin.
  • Evidence, by mutation rather than by assertion: restoring the early return on a missing composed page reddens 3 tests in CrewDynamicDashboard.revocation.test.tsx; removing the surface check from either promotion path, or from both, reddens tells the surfaces apart when the version and the html both coincide. That test is read in the UNDER-granting direction because that is the one a frame shows: a static package page, then the template instance at the same version with the same bytes, which may run script. Its two siblings pin the security direction -- a scripted package page held, then a read that composes nothing, and the same page then moved to a template answering scripts: false: no allow-scripts frame survives either. Two limits are pinned too, so the rule cannot be satisfied by blanking the tab: a read for the SAME package does not remount, and the template's page does reach the frame. One line is NOT independently observable and is not claimed as tested: resetting mayRunScript to false inside the clear changes nothing a frame can show, because the page is cleared in the same branch and no iframe mounts at all. It is there because an absent scripts field is the absence of a decision rather than the last decision, and the next read that establishes a page overwrites it from that page's own answer.
  • Counts on this head: the twenty-six backend suites reaching the changed module 1960 passed; the frontend members, dashboard, websocket, api-client and preview-surface set 5829 passed across 367 files, with tsc --noEmit and eslint src --max-warnings=0 clean; revocation.test.tsx itself 14 passed. To undo, restore the early return and drop the dashboard field from Loaded and from the two comparisons; the hole returns with it.
  • This revision ADDS AN AUDIT RECORD and changes no decision. The script grant in _serve_package is an authorization decision -- it decides whether a page a crewmate wrote may run script against that crewmate's own fold values -- and it was reached and acted on without leaving a record, which this repository's backend security controls require of a decision of that kind. It now writes one through sel().log_governance_decision, the SAME shared helper agent_backend_governance._audit and every other permission check in the product use, rather than a second emitter: the outcome vocabulary is that helper's own allowed/denied, so a log query for allowed decisions does not miss these rows alone, and the redaction is the helper's own pass over operation, item and reason. The row carries the crewmate, the package slug and its applied version (item), the scope network.egress, the verdict, and the layer plus a reason token -- because a row saying only "denied" cannot be acted on, while ceiling_restricts_egress, profile_restricts_egress, ceiling_unreadable and profile_unresolvable have different remedies and only some are a misconfiguration. Producing the reason split owner_agent_egress_unrestricted into a thin boolean wrapper over _egress_decision, which returns the verdict with its layer; every existing caller and all 107 tests of that function still read the boolean unchanged.
  • DEDUPED ON (crewmate, package, version, decision), which is what keeps it an authorization log rather than a page-view log. The tab polls on a timer and refetches on two WS frames, so one open dashboard re-decides this with the same answer for as long as it stays open; a row per read would push the rows that matter out of any practical retention window. A row is written when any part of that tuple changes -- a newly applied version, or a profile edit that flips the verdict. The memory is a dict keyed by (crewmate, package) capped at 256 pairs, bounded for the reason the live-page registry is: the key is a pair an operator can create, so an unbounded map is a slow leak on a long-lived gateway, and evicting the oldest costs at most one repeated row and never a missed change.
  • BEST EFFORT, and the grant cannot move because of it. The call is made AFTER scripts is bound, so the value it records is already settled and this function cannot reach it; the whole body including the dedupe is inside one except Exception that logs at debug; and log_governance_decision without critical enqueues to the background writer, which swallows persistence failures by design. The decision is also remembered BEFORE the write is attempted, so a log that cannot be written costs one lost row rather than one failed write per poll for as long as a tab is open.
  • Evidence by mutation, five tests in test_member_dashboard_package_route.py::TestTheScriptGrantIsAudited driving the REAL route: removing the audit call reddens 4; removing the dedupe check reddens 2; keying the dedupe on the version alone, so a flipped verdict is hidden, reddens 1; letting the emit raise reddens 2; and remembering the decision after the write instead of before reddens 1. The restored code is green at 5. The four the ruling asked for are among them -- a first open writes one row, four identical reads write none, a profile edit that flips scripts from true to false writes a second row naming profile as the layer, and a sel() that raises still answers 200 with the same scripts and the package's own page. Counts on this head: 2037 passed across the twenty-six module suites plus the security-posture and ceiling suites, 1235 across the seventeen this change touches, and test_sel.py with test_security_posture.py green beside them. To undo, delete _audit_page_script_grant, its two module constants and the call in _serve_package, and collapse _egress_decision back into the boolean; nothing else reads them.
  • This revision RESTORES a ratchet this PR had weakened, and narrows a save gate rather than widening one. dashboard_templates.manifest.FOLD_NAMES is the set of crew-log folds a manifest field may bind, and this PR had added the TREE family to it so a package could bind one. That set is shared: parse_manifest gates a TEMPLATE with it, and artifact_store.dashboard_package.fold_names() gates a PACKAGE with it. Only the package surface gained the reader. A tree-keyed fold has no bus scope by design -- it joins the logs of many slots, so no event could carry a key saying which one moved -- and it is READ instead, by member_dashboard_fields.LivePage, which draws a package's page. A template is rendered by member_dashboard._render, whose DashboardFeed reaches a fold only by its scope and has no tree read. So an operator writing a panel-templates page could bind worktree.boards, have parse_manifest accept it, and get a field missing on every read behind a permanent stale band -- exactly the block the gate's own comment exists to refuse.
  • The two sets are now separate: FOLD_NAMES is back to main's value, the two SCOPED families, and a new PACKAGE_FOLD_NAMES is that set plus the tree family, which fold_names() reads. A superset rather than a second list, because the two surfaces answer one question and differ only in what can reach a fold, so a name neither can reach is in neither. Nothing is admitted that was not admitted before this PR: the template gate is byte-identical to main's, and the package gate is the only thing that grew.
  • Three assertions move with it, and the universal one comes back. test_dynamic_dashboard.py had replaced assert dashboard_feed.scope_for(name), name with an allowlist whose entries this PR added, which is the weakening: the universal form is restored for FOLD_NAMES, the reachability form now runs over PACKAGE_FOLD_NAMES, and a third test pins the SPLIT itself -- every tree fold is absent from the template set, present in the package set, and FOLD_NAMES < PACKAGE_FOLD_NAMES -- because re-merging the sets would otherwise still satisfy the package loop, a superset passing a check written for the subset. Main's own test_the_fold_names_come_from_the_manifest_not_a_copy keeps its claim, that this gate reads the manifest module's set and never a copy, and now also asserts the subset relation.
  • Evidence by mutation: re-merging the tree family into FOLD_NAMES, which is the regression itself, reddens 3 tests; pointing fold_names() back at the template set, which makes a package's tree binding unreachable again, reddens 1. The restored code is green at 252 for those two suites and 2081 across the twenty-six module suites plus the dynamic-dashboard, ceiling, security-posture, field-schema and operator-pages suites. To undo, merge the two constants and the universal assertion weakens again with them.
  • The split is now pinned AT THE GATE as well as on the sets, which is the half that was missing. test_a_template_binding_a_tree_fold_is_refused_at_parse builds a template manifest binding each registered tree fold and asserts parse_manifest raises ManifestError naming that fold -- the refusal an operator writing a panel-templates page actually meets, rather than a set-membership assertion standing in for it, and named so the author is told which binding to change instead of being handed a manifest-wide "invalid". Its companion test_a_package_binding_the_same_tree_fold_is_accepted asks dashboard_package.fold_names() the same question, because a package never reaches parse_manifest and its page IS drawn by the reader that resolves a tree fold: together they say the two surfaces answer differently on purpose. Re-merging the two sets reddens 3 of the 6 tests in this group. No product behaviour for a package changes in this revision; it adds the two tests and nothing else.
  • The committed fold catalogue is regenerated to match the split, and it comes out BYTE-IDENTICAL TO MAIN'S. scripts/fold_catalogue.py derives each fold's advertised flag from manifest.FOLD_NAMES -- the set a template's save gate accepts a binding from -- so widening that set had quietly promised a template author it could bind worktree, the one registered tree fold, and the generator's own comment already said why that promise is wrong: "a name outside it is a binding that would be REFUSED". Restoring the template set restores the flag, so folds.json goes back to "advertised": false for worktree and FOLDS.md back to marking it, and git diff origin/main on both files is now empty. That is the clearest statement available that this split did not change what a template may bind: the artifact an authoring agent reads is main's, unmodified. test_fold_catalogue.py is 48 passed, and the full set on this head is 2129.
  • Four tests of this PR's own were asking the WRONG GATE, and the split exposed them rather than breaking them. test_crew_log_worktree_fold.py and test_crew_log_worktree_read.py built blocks that bind the tree fold and validated them through parse_manifest, which worked only while one set served both surfaces. One of them is even named test_a_v3_package_block_binding_the_tree_validates: a PACKAGE block, checked by the template loader. They now go through the gate a package actually passes -- dashboard_package.validate_package, the caller of fold_names(), then member_dashboard_fields.package_manifest, the translation the feed subscribes by -- and the end-to-end claim is unchanged and still end to end: the binding validates and the same bound path, walked over the value this fold folded from three logs, comes back with the rows. Their view.html became an inline body because the package validator refuses a document tag, which is the host's to supply.
  • The fourth, test_the_catalogue_advertises_the_fold_now_that_a_reader_exists, had its PREMISE inverted and is renamed test_the_template_catalogue_still_withholds_the_fold. That catalogue belongs to the dashboard-template skill, which scaffolds templates, so withheld is the honest answer and it is still withheld by the same derived expression rather than a hand edit. It now also asserts the fold IS in the package set, so the document and the two gates are pinned together in one place.
  • One process note, recorded because it is the reason these four reached CI at all: my local run this round was the module set plus a few named suites, not the full list of suites this PR touches, and these two files are in that list. The counts below are from the full list -- git diff --name-only origin/main...HEAD -- test/ plus the module set plus the catalogue, ceiling, security-posture, field-schema and operator-pages suites -- 2581 passed, 0 failed, and the fold-catalogue gate confirms the committed catalogue still matches the code.
  • The catalogue now says WHICH SURFACE may bind a fold, instead of dropping the one only a package can reach. Letting worktree fall back to unadvertised made the two gates consistent but cost a package author the only place they could learn the fold exists: advertised: false reads as "not for you" to BOTH authors, and this document is the whole interface a composing agent has for what folds there are and what fields they carry. scripts/fold_catalogue.py gains a second derived flag, package_only -- true when a fold is bindable, not editorially withheld, outside the TEMPLATE set and inside the PACKAGE set -- and FOLDS.md marks such a fold *(package only)* with a legend paragraph saying why a template may not bind it. class and outline keep *(internal)*, because they are bindable on neither surface, so the two labels now mean different things rather than one standing in for both.
  • Both flags stay DERIVED from the two gate sets, which is what keeps the document from promising a binding either gate turns down; neither is hand-written, and the generator's own equality gate (test_fold_catalogue.py, 48 passed) is what proves the committed bytes match. Evidence by mutation: forcing package_only to False, which is the drop-it-entirely behaviour, reddens 1; computing advertised from the package set, which is the original regression that let a template bind a tree fold, reddens 1. The test that reads this is test_the_template_catalogue_still_withholds_the_fold, which now asserts BOTH halves -- withheld from templates and still offered to packages -- so the catalogue cannot satisfy it by hiding the fold from everyone.
  • The three suites named in the ruling pass locally on this head: test_crew_log_worktree_fold.py, test_fold_catalogue.py and test_dynamic_dashboard.py, 240 passed together. The full list this PR touches plus the module set, the ceiling, security-posture, field-schema, operator-pages and spawn-audit suites is 2597 passed, 0 failed, with black, isort, flake8, comment-history, feature-map, take-away and the fold-catalogue gate all green.
  • This head is REBASED onto 3751ed36ad, 103 commits on, and main wins where it moved. The change that overlaps this one is the in-place refill of an open Dashboard page instead of a reload (the flicker fix): it touches CrewDynamicDashboard.tsx, the _BOOTSTRAP_JS refill listener in dashboard_frame.py and test_dashboard_frame.py, all three of which this PR also touches. Its page-keyed document (instance version, template id and version, theme -- never the values) and its kirocrew-dashboard:data post are kept as they are, and this PR's package subscribe/patch path sits BESIDE them rather than over them. Checked mechanically rather than asserted: every one of its added lines survives -- 39 in dashboard_frame.py, 114 in CrewDynamicDashboard.tsx, 19 in test_dashboard_frame.py. The one line this PR replaces in that bootstrap pre-dates the flicker fix and is replaced by this PR's own version/generation fencing on the same listener. The flicker cannot come back silently: its own suite plus the four dashboard suites are 67 passed across 5 files, and test_dashboard_frame.py is green in the 340-pass backend run. One stale assertion of this PR's own was fixed with it -- a test hardcoded two per-call nosemgrep suppressions in the tab and the flicker fix added a third postMessage, so the count is now taken from the postMessage( calls and cannot go stale when another is added.
  • One more branch of the privilege-retention hole is closed, and the fix moves the rule to its ROOT rather than adding a third guard. The surface check and its fail-closed reset now run as the FIRST thing in the read effect, ahead of every state branch. state: 'error' was the branch that still leaked: it returns early on purpose, because that read succeeded and says the crewmate's NEWER stored copy does not parse, so the last page that parsed stays under a band -- but that reasoning holds only for a page on THIS surface. A read that moved the tab from a package to the template instance AND answered error took the keep-it branch before the surface was ever compared, leaving the package document mounted with allow-scripts on a surface the tab had left. Since no branch may return while another surface's page is mounted, and each returns for its own good reason, the comparison belongs before all of them.
  • The held surface is read from a ref written at exactly the two moments it changes -- when a read establishes a page, and when any branch clears one -- so the effect does not depend on the page it promotes and the ref cannot lag what is mounted. The surface comparisons previously inside the two promotion setters are REMOVED: the root guard clears first, so they were unreachable, and an unreachable guard is one a later reader trusts to be doing the work. Evidence by mutation: restoring the error early return ahead of the guard reddens exactly the new test; deleting the guard reddens 2. Both new tests state the rule and its limit -- a scripted package page held, then a template read answering error, leaves no allow-scripts frame; and an error read on the SAME surface still keeps its page under the band, which is the behaviour main pins. The second waits on that band rather than on a timer, so the suite is 16 passed with no act() warning under KIROCREW_ACT_STRICT=1.
  • docs/system-specs/modules/artifacts.md now describes what this PR actually enforces. Its "Dashboard packages" section counted two rules differing from every other kind; there are five, and the three it omitted are the ones this change adds: the snapshot-token fence (a record whose current kind is dashboard is never written without a matching token, and an absent token is a refusal), the bound-owner write gate including the outright refusal of an app token, and the shape of view.html. The lead-in also said both rules live in kiro_crew.artifacts, which is no longer true of all of them, so it now names where each is enforced: the record-level rules in the store, the writer's identity at the HTTP layer, the page's shape in the canonicaliser. One claim was cut from the draft after checking the code rather than the prose: the declared-name check scans data-dashboard-field attributes only, not a name read through window.kirocrew.subscribe, and the page says so and says why.
  • No RFC amendment is in this PR, and no third PR is opened. The applied-marker question -- whether "applied" should mean a version a person cut (by == "user") when the RFC reserves live versions to the save module's own apply, which an agent's dashboard_apply cannot satisfy -- is deferred by decision and recorded on the pull request. Two improvements found during this round are held as follow-up notes rather than built here: binding the refetch to the layout version on screen so an older open tab reloads instead of taking fields from a newer applied layout, and the one-line redaction of the slug in the artifacts.py 409 that main already emits unredacted one call earlier.
  • Counts on this head: the full list of suites this PR touches plus every suite reaching the changed modules is 2602 passed, 0 failed; the frontend members, dashboard, websocket, api-client and preview-surface set is green with tsc --noEmit and eslint src --max-warnings=0 clean; and black, isort, flake8, comment-history, feature-map, take-away, docs-lint and the fold-catalogue gate all pass. Reading the newest run per lane, Opus 5.5 Review and Security scope candidates (Opus 5.5) are both green on this head.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@chenmingwei23 marked the gpt AI finding as false positive, not applicable, or explicitly accepted for f4cde7b737f2e663bb17e3d9338b64b35629d054.

No new reach. A page script runs only when the owner agent's egress is unrestricted (member_dashboard.py:1531, fails closed). The field the older tab could receive is one the same agent declared in a version a person already applied, and refetch is owner-gated so it reaches only the owner's own browser (:1599). Adjudication flagged it for the same reason. Binding refetch to the displayed layout version is a follow-up.

This decision applies only to this commit. A new push requires a new judgment.

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.

3 participants