Skip to content

fix: critical gateway-only audit writers raise; pin origin consumers - #39243

Draft
chenmingwei23 wants to merge 4 commits into
mkt-app/sel-gateway-clientfrom
mkt-app/sel-lows-1
Draft

chenmingwei23 wants to merge 4 commits into
mkt-app/sel-gateway-clientfrom
mkt-app/sel-lows-1

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #38807 (base: mkt-app/sel-gateway-client).

Problem / Motivation

Goal: A critical audit call to a gateway-only writer in an app backend refuses the action instead of passing silently.

In SelClient, a call such as log_sel_rotation(..., critical=True) only logged a warning and returned. The module says critical=True means the caller refuses the action it could not audit, so the action went ahead with no audit row.

Why it matters

An app backend that asks for a critical row from a writer the route does not take lost the row and still proceeded. This is a LOW finding from the #38807 review.

Not a goal

  • No change to non-critical calls: they still warn once and return.
  • No change to which writers the _sel route accepts.
  • No change to what the spawn passes to a backend with no owner-enable marker.

What changed (motivation -> approach -> change)

  • apps/sel_client.py: the gateway-only writer stub raises SelClientError when critical=True, and the docstring says so.
  • apps/backend.py: a comment on the no-marker spawn. The spawn drops KIROCREW_GATEWAY_ORIGIN there. Every reader of that variable (the SEL client and the Dev Fleet pointer broker) trades the app secret at POST /api/apps/<app>/token, and validate_app_secret refuses that without the marker, so no consumer is lost. Comment only, no behaviour change.
  • test/test_sel_backend_no_origin.py: a pin test that lists the origin readers and the token exchange they use, and checks validate_app_secret refuses without the marker.

Backwards compatibility

Compatible: only a critical=True call to a gateway-only writer changes, from a warning to SelClientError; non-critical calls and every accepted writer behave as before.

Removes nothing: no path, row, key or function is hidden, renamed or deleted.

Tests

  • test_a_critical_call_to_a_gateway_only_writer_raises: raises on critical=True, still one warning for non-critical calls.
  • test_every_origin_consumer_needs_the_app_token_a_no_marker_app_cannot_mint: pins the origin readers and the marker requirement.

Proof: not provable -- other: no Python test environment on the authoring crew, CI runs the tests

Manual verification

N/A -- unit coverage sufficient; the change is one branch in a client stub.

Real-machine verification

N/A -- the diff runs only in unit tests; no service or real machine path changes.

Screenshots / video

N/A -- no user-visible UI change.

Related Issues

Follow-up to #38807.

Sibling sweep

Swept: grep -n "gateway-only" src/kiro_crew/apps/sel_client.py
Siblings: none -- the stub in getattr is the only place a gateway-only writer is handled

Pattern harvest

Not generalizable: a one-off stub that ignored the critical flag its sibling writers honour.

Checklist

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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

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

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: critical=True now makes the gateway-only stub refuse the action, as the module contract requires, and non-critical calls still only warn.

Notes

[DESIGN-REVIEWED] 8c6c4f4

Description read

[DESCRIPTION-READ] 9e4280a79a86a846192ca93bde996deaa9f213d84e6a917c0d5567a6215fe58b

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 Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

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

First-Principles-Verdict: PASS

Nothing blocks: the fix is one branch at the mechanism that ignored critical. The origin-consumer pin is a rider that the fix doesn't need.

Notes

  • Item 3 — rides along: the fix is complete without it. It hard-codes "apps/builtins/dev_fleet/server.py" and pointer_broker.py, a built-in that Move every built-in app out to KiroCrewApps and forbid built-in apps #26967 is moving out of core. When that app leaves, this test has to be rewritten. Subtraction: delete _ORIGIN_CONSUMERS and the file-scan half of test_every_origin_consumer_needs_the_app_token_a_no_marker_app_cannot_mint, and keep only the validate_app_secret marker assertions.

What this change ships

Inventory (3 items) — 2 justified

Intent: when an app backend asks for a critical audit row and the gateway can't take it, the action is refused instead of going ahead unaudited. FIX.

  1. A critical=True call to a gateway-only log_* writer in an app backend now raises SelClientError instead of warning and returning — justified
  2. A comment on the spawn that drops the origin when there is no marker says no origin reader works without the marker — justified
  3. A new test scans the source tree for KIROCREW_GATEWAY_ORIGIN readers, pins the two in-tree ones (including Dev Fleet's), and checks the marker requirement — rides along, couples a core test to the built-in Dev Fleet app that is leaving core

[FIRST-PRINCIPLES-REVIEWED] 8c6c4f4

Description read

[DESCRIPTION-READ] 359f8d011fac4216f39146436a9962a75f86b0c0dbc0225a47f674abb913cf4d

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 Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 8c6c4f4

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 8c6c4f4e6a5723ef593f0981ac96be9f24c14488 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 8c6c4f4e6a5723ef593f0981ac96be9f24c14488 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 8c6c4f4

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 8c6c4f4e6a5723ef593f0981ac96be9f24c14488 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Nov 18, 2026
@chenmingwei23
chenmingwei23 force-pushed the mkt-app/sel-gateway-client branch from d1aa2f6 to 5b59d52 Compare November 18, 2026 21:06
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 18, 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 merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 18, 2026
…rmalized operation

Spawned app backends hold no SEL key, so their audit rows reach the log through the
gateway's _sel route and a client that only holds the per-app secret. These tests pin:

- the route and the client write the row as app:<name> with the operation kept under
  the app's namespace;
- the operation is normalized and the row is kept: 'Publish Doc' is stored as
  'Publish_Doc', a newline or control character becomes '_', a 300-character operation
  is clipped to 64 and an empty one is stored as 'unnamed';
- a backend has no SEL key, and the builtin backends' own operation names are stored as
  written;
- a critical write the gateway did not take refuses the action.
…nnot read the SEL key

A spawned app backend now holds only its per-app secret. Its audit rows go to the
gateway's POST /api/apps/{name}/_sel route through apps/sel_client.py, and the gateway
signs and appends them as app:<name>. The backend's sel() is that client, the SEL key
is masked from the backend, and the built-in security callers log through sel().

The operation is normalized by one function, sel_client.normalize_operation, that the
client and the route both call: every character outside [A-Za-z0-9_.-] becomes '_',
the result is clipped to 64 characters, and an empty one is stored as 'unnamed'. The row
is kept, so no newline or control character reaches a text view of the log. Credentials
are redacted before the operation is normalized, including a tool name.

The client posts the row as UTF-8 rather than ASCII escapes, so three 500-character
fields of astral characters stay under the route's 16 KiB body cap, and a lone surrogate
in a field is replaced instead of raising.

A critical write waits (bounded, as the exit drain does) for the rows queued before it, so
it cannot land ahead of an earlier row.

The docs describe the route, the client and the normalized operation.
@chenmingwei23
chenmingwei23 force-pushed the mkt-app/sel-gateway-client branch from 5b59d52 to 186ec81 Compare November 18, 2026 22:58
@github-actions github-actions Bot added merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 18, 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 merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 18, 2026
@chenmingwei23
chenmingwei23 force-pushed the mkt-app/sel-gateway-client branch from 186ec81 to f856349 Compare November 19, 2026 10:34
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 19, 2026
@chenmingwei23
chenmingwei23 force-pushed the mkt-app/sel-gateway-client branch 4 times, most recently from 8bf494a to 894d554 Compare November 19, 2026 12:26
@chenmingwei23
chenmingwei23 force-pushed the mkt-app/sel-gateway-client branch 2 times, most recently from b399a28 to 045e1ed Compare November 19, 2026 13:31

This branch has not been deployed

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

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant