Repository navigation
fix(cli): print signing key repair steps when restart fails - #19829
iamwhatever merged 1 commit into
Conversation
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change adds output only, reuses the existing remedy and doctor's guard, and leaves exit codes and audit records unchanged. Notes
[DESIGN-REVIEWED] ec9453b Description read[DESCRIPTION-READ] 4b2b6e01a4f74c625da7404b13a8884728fd1836a8d8e9010263cda737644664 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 (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
|
note (non-blocking): For the account that installed it, the system unit reads the same key file the restart checks. |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The service-unit branch removes a real gap: the refusal only reaches the journal. The detached branch adds little now that #20055 relays Notes
What this change shipsInventory (5 items) — 4 justifiedIntent: when a restart fails because the gateway refused a truncated signing key, show the operator the repair steps in the restart terminal. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] ec9453b Description read[DESCRIPTION-READ] c5d1e3a701c898f504d27deba7e55009c8c38b9682f979c6698bc052943e03c0 That sha256 names the PR description this verdict read. Recompute it with |
0fec99e to
303fd45
Compare
|
issue (non-blocking): Upheld, the restart's short branch should not skip doctor's |
|
iamwhatever
left a comment
There was a problem hiding this comment.
This PR prints the token_signing.key repair steps in the kirocrew restart terminal when the replacement gateway dies right away or a service unit is not up and the key is under 32 bytes, so the operator no longer has to open gateway.log or the journal to find them. The code is correct: _signing_key_refusal_lines (src/kiro_crew/cli_server.py:1494) uses the same signing_key_health look with sandbox evidence and the same open_is_denied guard kirocrew doctor uses, returns nothing on any other state or any exception, and only fires on the RESTART_NOT_UP and "died immediately" branches, not on RESTART_REFUSED. I tried to get it to hand the file-deleting steps to a healthy key: a sandbox mode-0 mask is caught by open_is_denied, a different-account sudo -H restart checks a path that is normally absent and prints nothing, and a probe error is swallowed; the tests cover each of these and would fail on main for the two positive cases. The one thing left is a follow-up item, so per our rule this is not an approve yet: your First Principles disposition agrees the fix is symptom-level and promises a later PR that relays the dead gateway's last gateway.log lines on the "died immediately" branch (cli_server.py:1887), which would also cover the 3 sibling refusals in slack/gateway.py (persistence preflight, signing-key preflight timeout, no worker thread). Please open a GitHub issue for that relay work and link it in the PR description; the description's "Pattern harvest: Not generalizable" line should also be updated, since the disposition now says the pattern does generalize. I will approve on the next round once the issue is linked. — crew-pr-reviewer (deep re-check)
|
@iamwhatever note (non-blocking): Both description changes are in. The relay follow-up is tracked as #20054 and implemented in #20055, which prints the last 20 lines the replacement added to |
303fd45 to
ab29c51
Compare
|
note (non-blocking): Rebased on main after #20055 merged, no behaviour change. Both PRs edit the died-immediately branch of the restart and the tests beside it; the resolution keeps both, so the relayed gateway.log lines print first and the signing-key repair steps follow on a truncated key. 58 targeted tests in test/test_cli.py pass, flake8 and the black gate are clean. New head ab29c51. |
|
note (non-blocking): Backend Tests (3.12, 2) on fa0e198 hit the #22007 flake a third time. test_facade_mirror_guards.py::test_every_name_the_test_trees_patch_through_a_facade_reaches_its_readers ran past the 120 s pytest timeout, with no assertion failure. This PR doesn't touch that test or the facade mirror. A maintainer re-run of job 118558096855 should clear it. I won't push again for this. |
fa0e198 to
f496c99
Compare
|
note (non-blocking): Rebased on main 0b89e0c to pick up #22320, no behaviour change. New head f496c99. #22320 raises the per-test timeout for the whole-tree facade mirror guard scan, which is the #22007 timeout that failed Backend Tests (3.12, 2) on the last three heads. The diff is still 235 added lines across the same four files. All 108 tests in test/test_cli_restart.py and test/test_cli_restart_readiness.py pass, test/test_cli_server_facade.py passes, and flake8 is clean. |
|
note (non-blocking): Coverage Gate on f496c99 failed with "frontend-test=skipped -- failing closed", not on a test. This is the main regression in #22697: since #22425 a backend-only diff skips Frontend Lint, and that skip makes every test shard skip too, backend and frontend, which the gate rejects. So no tests ran on this head, and the earlier (3.12, 2) timeout question is still open. Other backend-only PRs show the same result today. I'll rebase once the #22697 fix lands on main; no code change is needed here. |
f496c99 to
7699956
Compare
|
note (non-blocking): Rebased on main 788f021, no behaviour change. New head 7699956. This picks up #22717, which fixed #22697: on f496c99 every test shard was skipped because the PR is backend-only, so Coverage Gate failed closed with no tests run. It also includes #22320, which raised the timeout behind the earlier Backend Tests (3.12, 2) failures. None of this PR's four files changed on main. The diff is still 235 added lines. 142 tests in test/test_cli_restart.py, test/test_cli_restart_readiness.py and test/test_cli_server_facade.py pass, and flake8 is clean. |
7699956 to
9fee0a7
Compare
issue (blocking): Fixed in
|
thought (non-blocking): Agreed that relaying
thought (non-blocking): Keeping it. The fallback is six lines and runs only when |
…ails A gateway that refuses to boot on a token_signing.key under 32 bytes prints its repair steps to its own stderr. Under kirocrew restart that stderr is gateway.log (detached) or the journal (service), so the terminal that ran the restart only saw 'died immediately' or 'not up' and a pointer to the logs. When the replacement dies, or a restarted unit does not stay up, restart now takes the same read-only look doctor does and, on a short key this process can open, prints the steps from signing_key_remedy with the service-aware restart command. A short key that refuses the open may be the sandbox mask over a healthy key, so like doctor it gets no file-removing steps. A refused restart verb never ran the gateway and gets no steps. Follow-up to kirodotdev#14457.
9fee0a7 to
ec9453b
Compare
|
note (non-blocking): Rebased on main 6512997, no behaviour change. New head ec9453b. #25366 added |
iamwhatever
left a comment
There was a problem hiding this comment.
Approve at ec9453b.
When a restart fails on a truncated token_signing.key, the restart terminal now shows the repair steps. The probe is read-only. It uses doctor's sandbox bits, and doctor's open_is_denied guard keeps the file-removing steps away from a masked healthy key. Any error prints nothing (cli_server_restart.py#L679-L716). The steps appear only on a RESTART_NOT_UP service report and on a died replacement whose gateway.log relay was empty. Our earlier request is met: #20054 is linked (done by #20055), and the Pattern harvest line is updated. All checks are green.
AI findings judged non-blocking:
- Design: this is the third copy of the
confined/require_denied_openderivation (also doctor_checks/access.py#L70-L74). The copies match today, so this is a refactor suggestion, andopen_is_deniedstill guards a drift.
I read the diff and CI. I did not run tests.
— crew-pr-reviewer (r134)
Problem / Motivation
Goal: When
kirocrew restartfails because the gateway refused to boot on a truncatedtoken_signing.key, the terminal that ran the restart shows the repair steps.Since #14457 the gateway refuses to start when
token_signing.keyis a regular file under 32 bytes, and prints the manual repair steps fromtoken_secret.signing_key_remedyto its stderr. Underkirocrew restartnobody is reading that stderr. A detached gateway writes it togateway.log, and a service gateway writes it to the journal. The restart prints "Replacement gateway (pid N) died immediately" or "the gateway was NOT restarted" with a pointer tokirocrew logs -forjournalctl, and the person has to open the log to learn that the fix is four steps on one file. #14457 promised a follow-up for the refused state; a dashboard banner cannot work because a refused gateway serves no dashboard, so this puts the steps in the launcher output instead.Why it matters
A truncated key blocks every boot until someone removes it by hand. The restart command is where the operator is looking at that moment, and it already knows the boot failed.
Not a goal
gateway.log, which carry the gateway's own CRITICAL line with the same steps.signing_key_remedy's docstring.What changed (motivation → approach → change)
The restart already detects both failure shapes, so the hint hangs off those two branches rather than parsing logs.
cli_server_restart._signing_key_refusal_lines()takes the same read-onlylstatlookkirocrew doctorand the boot preflight take, throughsigning_key_healthwith the same two bits:confinedfromsandbox.agent_confinement_evidence, andrequire_denied_openwhen the only signal is a Seatbelt verdict Kiro Crew did not create. A sandbox mask over a healthy key never reads as short, and a readable truncated key under a foreign Seatbelt still does. On"short", and only whentoken_secret.open_is_deniedsays this process can open the file, it returns thesigning_key_remedysteps withrestart_command_hint(), and on any other state or any exception it returns nothing. The open check is the guardkirocrew doctoralready applies: a short key that refuses the open may be the mode-0 sandbox mask over a healthy key, and the steps delete the file._restartprints those lines after the "died immediately" message only when the #20055gateway.logrelay printed nothing, because the relayed lines already carry the gateway's own refusal and the same steps, and it appends them to a service report that has aRESTART_NOT_UPfailure. ARESTART_REFUSEDrestart never ran the gateway, so it gets no steps and no probe.Backwards compatibility
Additive: two failure messages gain lines only when the key is short. Exit codes and audit records are unchanged.
Tests
test_replacement_that_dies_on_a_truncated_key_prints_the_repair_stepsandtest_unit_not_up_on_a_truncated_key_prints_the_repair_stepsfail on origin/main and pass here.test_replacement_that_dies_on_a_healthy_key_prints_no_repair_stepscovers ok, absent, masked, other and unstatable.test_a_short_key_this_process_cannot_open_gets_no_removal_stepscovers the doctor guard.test_a_readable_short_key_under_a_seatbelt_follows_doctorruns the realsigning_key_healthon a truncated key: under a foreign Seatbelt the steps print, as the boot preflight and doctor would refuse the key, and under Kiro Crew's own sandbox they do not. The foreign case fails without therequire_denied_openargument.test_relayed_refusal_is_not_followed_by_a_second_copy_of_the_stepschecks that a died report whosegateway.logrelay already shows the refusal does not print the steps a second time.test_a_failing_key_probe_leaves_the_died_report_unchangedandtest_unit_the_manager_refused_to_restart_gets_no_key_stepscover the probe error and the refused verb.test/test_cli_restart.pyandtest/test_cli_restart_readiness.pysince test: split the rest of test_cli.py into topic files (2 of 2) #22152 splittest_cli.py. Those two files andtest_cli_server_facade.pygive 144 passed;test_signing_key_preflight.pyandtest_sandbox_signing_key_mask_unreadable.pygive 103 passed. flake8 and the scoped black gate pass.Manual verification
N/A. The change is two print paths in
_restart, and the tests drive_restartthrough both.Related Issues
Closes #19828
Follow-up to #14457, replacing the refused-state banner promised there.
Tracked follow-up: #20054, implemented in #20055. When the replacement dies, the restart prints the last lines that gateway added to
gateway.log, which also covers the persistence preflight, the preflight timeout and the no-worker-thread refusals.Pattern harvest
Rule candidate: review-prompt
Pattern: a gateway boot refusal whose reason reaches only the gateway's own stderr, where
kirocrew restartnever shows itEvery boot refusal in
slack/gateway.pywrites its reason only to the gateway's own stderr, whichkirocrew restartdoes not show. This PR fixes the short-key case with its repair steps. #20054 / #20055 fix the class by relaying the dead replacement's newgateway.loglines on the "died immediately" branch.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.