Repository navigation
fix(apps): restart an app's backend when enabling it mints the owner-enable marker - #39252
chenmingwei23 wants to merge 4 commits into
Conversation
…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.
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS This fixes the cause: the gateway origin is read only when the backend spawns, so a restart gated on the marker the enable just minted is the smallest fix. Notes
What this change shipsInventory (3 items) — 2 justifiedIntent: an owner who re-enables an app that predates its owner-enable marker should get a backend that can reach the gateway without a manual restart. This is a FIX (#39160, plus a test that fails on base).
[FIRST-PRINCIPLES-REVIEWED] 21e926c Description read[DESCRIPTION-READ] 33d5e1a019d526818d58906449592ef29d3df79577ce3d8550d65fc00df9a9e5 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: a successful enable always leaves the marker in place ( Notes
[DESIGN-REVIEWED] 21e926c Description read[DESCRIPTION-READ] 9a8e3d1d2aaee67a1051fdf149796a924cb1e06e5328ef13f78dca57dbb1e618 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 |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
d1aa2f6 to
5b59d52
Compare
b399a28 to
045e1ed
Compare
Fixes #39160.
Stacked on #38807 (base
mkt-app/sel-gateway-client); rebase on main and retarget to main once #38807 merges.An app enabled before its owner-enable marker existed spawns its backend without
KIROCREW_GATEWAY_ORIGIN. Re-enabling it as the owner mints the marker, but the enable route reused the running backend, so the app kept no origin until a restart.The enable route now records whether the marker stood before the enable. When the enable minted it, the route stops the app's backend before starting it, so the new spawn gets the origin. A re-enable with the marker already present does not restart.
Tests (
test/test_enable_restarts_backend_on_new_marker.py): enable, drop the marker, re-enable -> stop then start with the marker in place; re-enable with the marker present -> start only.Spec: none (repair)
Ticket: none (repair batch)