Repository navigation
feat(cli): relay a dead replacement gateway.log tail on restart - #20055
Conversation
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Check on Windows that the parent's [DESIGN-REVIEWED] 55979df Description read[DESCRIPTION-READ] 53b6ed7abc5afa94080fe05c9d34564625bb3ce8caa9332cb552dd7b795384f5 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 |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. What this change shipsInventory (4 items) — 4 justifiedIntent: when a restarted gateway dies on boot, the person at the restart terminal sees the reason it gave there, not just a pointer to the logs. FIX (#20054;
[FIRST-PRINCIPLES-REVIEWED] 55979df Description read[DESCRIPTION-READ] 48ffb27249247f6968530f986a7951e5531d6bd6bef32e0f03fa02f1bc446f57 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
When kirocrew restart's detached replacement exits at once, print the last 20 non-blank lines it appended to gateway.log, so every boot refusal (persistence preflight, signing-key preflight and its deadline, no worker thread, truncated key) shows its reason in the restart terminal. Only bytes written after the spawn are read, capped at 16 KiB, and each line is reduced to printable characters.
27c4397 to
55979df
Compare
|
|
|
|
|
|
|
|
bolichen97
left a comment
There was a problem hiding this comment.
Readiness sweep: full diff read, PR Readiness success on this head, no live change requests or blocking threads. No regression found.
Problem / Motivation
Goal: When
kirocrew restart's detached replacement gateway exits at once, the restart terminal shows why.Today the restart prints "Replacement gateway (pid N) died immediately (exit status S)" and a pointer to
kirocrew logs -f. The gateway wrote its reason togateway.log, which the restart opened for it as stdout and stderr. At least four boot refusals inslack/gateway.pyend this way: the persistence preflight, the signing-key preflight and its 30 s deadline, the exit when no worker thread is available, and the truncatedtoken_signing.keyrefusal. #19829 relays the repair steps for the last one only, and its First Principles disposition promised this general relay.Why it matters
The person who ran the restart is looking at that terminal, and the restart already knows the boot failed. One relay covers every refusal that writes to the log, including ones added later, with no per-refusal code.
Not a goal
RESTART_NOT_UPreport already names where to look.What changed (motivation → approach → change)
_restartrecords which filegateway.logis and how long it is, as(st_dev, st_ino, size), just before_spawn_detached_gateway, through_gateway_log_mark(). The replacement rotates a non-emptygateway.logtogateway.log.prevat boot (cli._setup_cli_logging) and logs its refusal into a fresh file, so a size alone is no offset into what it wrote. On the_READY_DIEDverdict the restart prints "Its last lines in gateway.log:" followed by_gateway_log_lines_since(mark). Ifgateway.logis still the measured file, that helper reads only the bytes past the recorded size. If it was rotated, it reads what the replacement wrote before the rotation, fromgateway.log.prevpast the recorded size and only when.previs the measured file, then the whole freshgateway.log. It keeps at most the final 16 KiB and the last 20 non-blank lines. It drops a first line the byte cap cut in half, keeps only printable characters in each line, and caps each line at 400 characters, because log text can quote values another process chose. An unreadable log gives an empty list, so the message falls back to today's text and thekirocrew logs -fpointer stays.Backwards compatibility
Additive. The "died immediately" message gains lines only when the replacement wrote to the log. Exit codes and audit records are unchanged.
Tests
test_replacement_that_dies_relays_only_its_own_log_linesfails on origin/main and passes here. It rotates an old, longergateway.logthe way the booting replacement does, and checks that the refusal written to the fresh file is shown and the old lines are not.test_replacement_that_never_becomes_ready_relays_no_log_linescovers the still-running branch.TestGatewayLogRelaycovers an unknown mark, a log that did not grow, a missing log, a log created after the mark, a rotated log shorter and longer than the old one, output written before the rotation and read from.prev, a.prevleft by an earlier boot that is not relayed, the 20-line cap with blank lines, terminal control sequences, a line cut by the byte cap, and the per-line cap.test_cli.pygives 507 passed and 2 failed. The two failures areTestDoctorStttests that fail the same way on origin/main in this environment. flake8 and the scoped black gate pass.Manual verification
N/A. The change is one print path in
_restart, and the tests drive_restartthrough it.Related Issues
Follow-up to #19829, from its First Principles review.
Pattern harvest
Generalizable: a launcher that starts a process and reports its failure should show the reason the process gave, not only point at where it wrote it. This relays the dead replacement's own log tail instead of adding one hint per refusal.
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.
Fixes #20054