Repository navigation
feat(apps): add an opt-in to never adopt a backend listener this run did not start - #35334
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The switch is off by default and adds no product shape. Two parts are worth trimming: the recovery-path gate only matters if the setting is turned on mid-run, and that path also writes a new audit row when the setting is off. Notes
What this change shipsInventory (8 items) — 6 justifiedIntent: an operator can stop the gateway from adopting an app backend listener it did not start in this run. This is an ADDITION.
[FIRST-PRINCIPLES-REVIEWED] fa318c7 Description read[DESCRIPTION-READ] 5f3a5d6d2941802a697c8baff0235f3c764b1bd2f93404c59c06d601dde391d2 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: the switch is off by default, read where it is used, and turning it off undoes it. Notes
[DESIGN-REVIEWED] fa318c7 Description read[DESCRIPTION-READ] d3abc85f746341f5c3e2aabee3a467907ab2fcfc04a54f869188086863d54dc1 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: |
efe536d to
7c06420
Compare
7c06420 to
549f585
Compare
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 25% chance that this change introduces a defect, above the 12% limit for approving on its own. The PR adds an opt-in setting, off by default, that refuses a healthy listener on an app's port at start and refuses the recovery re-bind of an adopted backend. The ceiling-revocation retry is exempt, so a revoked backend can still be re-bound and stopped. The refusal path releases the placeholder and port claim the same way main's unhealthy-port branch does. Both places that create or re-bind adopted records are gated, the setting is read live like its neighbouring settings, and the new tests cover both settings, the refusal audit rows and the fallback cases. Remaining issues, none blocking: on the default path every adopted recovery now writes an audit row and loads the config, which the description doesn't mention; a failed config load still adopts, which is declared; repeated refusals log every sweep; and the restart behaviour isn't documented. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
549f585 to
9dabf97
Compare
|
Re the Opus 5.5 finding on _rebind_adopted_owners: fixed in 9dabf97. The spawn-record check is now one helper, _spawn_is_recorded (backend_runtime/pidfile.py), called from both the adoption branch in _start_app_backend_body and _rebind_adopted_owners. The rebind returns False, so nothing is promoted, when the recorded leader pid is not among the captured owners with a matching start time. New test: test_an_unrecorded_listener_taking_the_port_is_not_rebound. No other path sets adopted_pids. |
|
Maintainer decision (Mingwei): accept Removal 1 of rfc-app-backend-adoption-provenance.md for this PR. The gateway adopts only backends whose spawn it recorded; a pid alone cannot prove the gateway owns a process. A backend an operator runs under their own supervisor is no longer re-adopted on start and should be started through the gateway. The spec is updated in this PR. |
|
Re KiroCrewCaptain's 03:45Z review, item by item, now at head dd9951f:
Not changed: the per-sweep warning and SEL row on a refused re-bind, left as an optional follow-up. |
dd9951f to
b65e358
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Thanks for the careful rework. The default path now matches main, and the start path refuses before it captures owners. One thing still blocks merge on this head.
src/kiro_crew/apps/backend_runtime/ports.py:159-160: say an operator setsagent.apps_never_adopt_backend_listener: truein a readableconfig.json, andconfig.local.jsonholds invalid JSON. The loader keeps the base value, so the setting loads astrue. The_base_unreadable or _overlay_unreadablecheck then raises, and_adoption_allowedreturns True.backend.py:609adopts the healthy survivor on the app's port, andsupervision.py:173re-binds it, even though the operator turned the refusal on. This is the security-class BLOCK on this head. Smallest fix: delete those two lines and decide from the loaded value, keeping theexceptfallback. An unreadable file adds only the defaultfalse, so with the setting off every case still adopts, as on main. With the setting on, atrueread from a readable file is honored. Then drop theoverlay_unreadableandbase_unreadablecases from the parametrize intest_an_unreadable_config_adopts_as_main_doesand keepraises. Finally, narrow "a config file that cannot be read still adopts" to "a config that fails to load still adopts" in the docstring,sections_agent.py,config-baseline.json,config.mdandapp-kit-platform.md.
My review on b38c649 read the earlier maintainer request as covering the setting-on case, and that note led to the current wording. I misread it. That request was about the default, off. Its suggested code (... is True inside a try/except) honors a readable true and has no unreadable-flag check. bolichen97, please confirm which reading you meant.
Earlier items from my review on b38c649:
_agent_unreadablenever changes the decision: fixed. The field, the kwarg, the clause and the test case are gone, and the loader files left the PR.- Key, label, SEL outcome and title described a spawn-record check: fixed.
- Docs did not name the unreadable-config exception: addressed, but item 1 above narrows that clause.
- Start-path SEL row not pinned, and moved after the owner capture: fixed.
test_the_start_path_writes_one_sel_row_with_the_decisionpins both settings, and the row is back where main writes it. - Refused re-bind writes a WARNING and a SEL row every 15 s sweep: deferred by the author. Still optional.
Optional:
- A refused start is retried by the 300 s backstop and writes a WARNING plus two SEL rows each time while a foreign listener holds the port. A follow-up issue for this and the re-bind noise would keep the deferral tracked.
- The warning at
ports.py:164says "adopting as main does". Operators do not know what "main" refers to. "adopting, as when the setting is off" reads better. The single commit is still titled "fix(apps): adopt a backend only when the gateway recorded its spawn". Please reword it to match the PR title. require_attribution(supervision.py:143) and the test helper_require_recorded_spawn, which is defined in two test files, still name the removed spawn-record check.
|
Parked for the maintainer under the stop rule: this is a new blocker after the declared final push, so there is no code change here until Mingwei rules. KiroCrewCaptain review 5887996179 (08:13Z, head b65e358): src/kiro_crew/apps/backend_runtime/ports.py:159-160. With agent.apps_never_adopt_backend_listener: true in a readable config.json and invalid JSON in config.local.json, the _base_unreadable / _overlay_unreadable check makes _adoption_allowed return True, so backend.py:609 adopts and supervision.py:173 re-binds a listener the operator asked to refuse. Captain suggests deciding from the loaded value instead and asks @bolichen97 to confirm which reading of the earlier request was meant. |
b65e358 to
47ba560
Compare
|
Re the 08:13Z review, point by point, now at head 47ba560 ("feat(apps): add an opt-in to never adopt a backend listener this run did not start"):
Deferred as accepted: the re-bind and refused-start log noise, and the @bolichen97, could you confirm that your earlier request about the unreadable-config case meant the default (setting off) case? With the setting off, every config state adopts as before. With the setting on, a |
|
Parked as a draft for a maintainer decision after the declared final push 47ba560. Nothing further is pushed from this PR until a maintainer rules. State: the points in KiroCrewCaptain's 08:13Z review are addressed in 47ba560 (see the reply above). Open blocker: GPT 6.1 flagged supervision.py:173 on this head. With the setting off, a recovery re-bind (require_attribution=True) allows adoption without writing an audit event, and only the refusal branch is audited. Its suggested fix is to audit both the allowed and the refused decision when require_attribution=True. The question to @bolichen97 in the previous comment still stands: does the earlier request about the unreadable-config case mean the default (setting off) case? |
|
Thanks for the careful rework. This head addresses what I asked for on b65e358, and I found no new blocking defect. I cannot approve yet, because two things need a maintainer. Earlier items from my review on b65e358:
What waits for a maintainer:
The base of this head does not include #37171, which fixes the tracing test on main. A rebase should bring that fix in. Optional:
|
Withdrawn: every item in this review is fixed or answered on the current head (see the follow-up comment). Other holds on this PR are listed there.
…did not start With agent.apps_never_adopt_backend_listener on, the gateway neither adopts nor re-binds a healthy listener it did not start in this run. Off (the default) keeps adopting any healthy listener, and so does a config that fails to load. Refs #13403
47ba560 to
fa318c7
Compare
|
Pushed fa318c7 (rebased onto current main, still one commit). It addresses the GPT 6.1 finding at supervision.py:173: a recovery re-bind with require_attribution now writes exactly one app_backend_adopt row either way, outcome adopted or refused_not_spawned_this_run, before the branch. The ceiling-revocation retry is unchanged and writes no row. New test test_a_recovery_rebind_audits_one_row_whichever_way_it_decides covers the setting on and off, and was red with the setting off on the previous head. @bolichen97: yes, the unreadable-config case is the default case with the setting off. A config that fails to load adopts as main does, with one warning. |
|
Thanks for the rework. I found no blocking defect on this head. I cannot approve yet, because bolichen97's change request on f1e6367 is still open and only that maintainer can clear it. This head answers that request. With the setting off, What this review checked on fa318c7:
Earlier items from my review on b65e358 and my comment on 47ba560:
Optional:
|
bolichen97
left a comment
There was a problem hiding this comment.
Thanks, my point from f1e6367 is fixed, and I read the whole diff at fa318c7.
- Unreadable config adopts, as on main.
_adoption_allowedinports.pynow refuses only whenKiroCrewConfig.load()returnsapps_never_adopt_backend_listener is True. If the load raises, it logs one warning and returns True.test_a_config_that_fails_to_load_adopts_as_when_the_setting_is_offpins that. - Default is main. The setting is
Falseinsections_agent.py,config.mdandconfig-baseline.json(a new key only, defaulting off). With it off, the start path inbackend.pyand the recovery re-bind insupervision.pyadopt exactly as before; the only addition there is one SEL row with the decision. - Opt-in is honored. A
trueread from a readableconfig.jsonsurvives an invalidconfig.local.json, and a repairedagentsection still reads the setting. The ceiling-revocation retry keepsrequire_attributionoff, so a revoked backend can always be re-bound and stopped. - No regex added. 101 checks pass, 0 red.
Problem / Motivation
Goal: An operator can tell the gateway to never adopt or re-bind an app backend listener it did not start in this run.
When the declared port answers its health path, the gateway adopts whatever holds the port. A backend that survived an uninstall (or any other process on that port) is then treated as the app's backend: addressed, health-reported and signalled as that app. There is no way to ask the gateway not to do that.
Why it matters
Anyone with an app that declares a fixed port plus a detached child outliving uninstall gets the next install of that name bound to a process the install never started. Operators who want that closed need a switch; operators who run externally managed backends need the current behaviour to stay.
Not a goal
What changed (motivation -> approach -> change)
A new opt-in setting,
agent.apps_never_adopt_backend_listener(default false), is read by one helper,_adoption_allowedinbackend_runtime/ports.py._start_app_backend_bodyand the recovery re-bind in_rebind_adopted_ownersare refused. A listener found at start was not started by this run, and a recovered adopted record is not a child of this run either, so in practice every such listener is refused. The refusal logs a warning and writes an audit row with outcomerefused_not_spawned_this_run.The setting is registered in
sections_agent.pyandloader_builders.py,config-baseline.jsonis regenerated, andconfig.mdandapp-kit-platform.mddescribe it. The default wording inapp-kit-platform.mdis unchanged. Stopping an adopted backend is untouched.Backwards compatibility
None for existing installs: the setting defaults to off and the default behaviour is unchanged.
Tests
test_the_start_path_writes_one_sel_row_with_the_decisionpins the start-path audit row for both settings;test_a_listener_this_run_did_not_start_is_not_adopted_when_requiredandtest_a_listener_this_run_did_not_start_is_not_rebound_when_requiredrun with the setting on; the second also asserts the audit row.test_a_listener_is_adopted_by_default,test_the_setting_alone_decides_whether_a_listener_may_be_adopted, the unreadable-config cases andtest_the_ceiling_retry_rebinds_a_listener_this_run_did_not_start_so_it_can_be_stoppedcover the default, fallback and revocation paths.test_protected_app_state.pyandtest_app_staged_grants.py, which fail identically without this change in this environment. flake8, isort, mypy on the source files, the comment-history gate, docs_lint and check_file_line_cap are clean.Manual verification
N/A - covered by the unit tests.
Related Issues
Refs #13403
Pattern harvest
Not generalizable: the defect is that adoption trusted a health answer with no way to opt out, which is specific to this one adoption branch.