This repository was archived by the owner on May 26, 2026. It is now read-only.
feat(KR-P2-CLEANUP ST4): BOOT-PANEL flip-to-real + BootGateRunner history ring#62
Merged
Merged
Conversation
2 tasks
…tory ring
Flips /api/boot-status from the hardcoded stub to a live read of
BootGateRunner.last_result() + recent_history(limit=20), with the
same uninitialized → stub + error fallback shape as ST2/ST3.
agent/boot_gates.py:
- New BootHistoryEntry frozen dataclass (boot_id, started_at,
completed_at, summary). ``elapsed_ms`` is a computed property.
- Module-level ``_recent_history: deque[BootHistoryEntry]`` ring
capped at 20. Wipes on process restart — durable history lives
in the chain-event log (kora.boot.ready / kora.boot.failed via
KR-P2-I-integration ST2's emit listener).
- BootGateRunner classmethods:
* record(entry) — append (called by boot_coordinator)
* last_result() — newest entry or None
* recent_history(limit) — oldest→newest, clamped to ring max
* _reset_history_for_tests() — test-only ring clear
agent/boot_coordinator.py:
- run_boot_sequence now records every terminal outcome (READY /
STOPPED, including diagnostic-mode runs) via
BootGateRunner.record(). New _record_boot_history helper is
fail-soft — recording errors don't break the boot path.
- boot_id minted as ``boot_{uuid4-hex[:8]}``; started_at captured
at runner construction; completed_at at record time.
kora_cli/web_server.py:
- GET /api/boot-status now reads BootGateRunner.last_result() +
recent_history(limit=20). Live branch: returns real current +
history (newest-first ordering for the panel) WITHOUT ``stub``;
empty-history branch: returns stub-shape with stub:True +
``error`` naming the cause (panel renders distinct banner).
- New _project_boot_entry_current / _project_boot_entry_history
helpers translate BootHistoryEntry/BootSummary/GateResult into
panel-shaped dicts. GateResult has no ``title`` field (title is
a Gate ClassVar); projection falls back to gate_id when no
title can be resolved — acceptable degradation from stub for ST4.
- Stub body extracted into _boot_status_stub(error=...) for shape
symmetry with ST2/ST3.
Tests (tests/kora_cli/test_web_server_boot_status.py): full rewrite
covering both branches:
- Empty-history branch: stub + stub:True + error + per-entry
shape sanity (outcome/gate_outcome/gate_class enum membership)
- Live branch single boot: current renders the recorded boot;
history is empty; no stub flag
- Live branch multiple boots: history rendered newest-first;
failed entry surfaces failed_gate_id + detail
- Ring max enforcement (record 25 → only last 20 visible)
- BootGateRunner.last_result() / recent_history() / limit=0
edge cases
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…in test helper GateResult dataclass has no defaults for started_at + completed_at (they're required fields per agent/boot_gates.py:97-98). The test helper omitted them, which would have failed at fixture construction in CI. Added with sensible defaults the panel projection doesn't use but the dataclass demands. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
b3dde75 to
e2c8d82
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
KR-P2-CLEANUP ST4 of 5. Flips
/api/boot-statusfrom the hardcoded stub to a live read ofBootGateRunner.last_result()+recent_history(limit=20), with the same uninitialized → stub +errorfallback shape established by ST2/ST3.agent/boot_gates.pyBootHistoryEntry— new frozen dataclass:boot_id,started_at,completed_at,summary(BootSummaryreference).elapsed_msis a computed property._recent_history: deque[BootHistoryEntry]ring capped at 20. Wipes on process restart — durable boot history lives in the chain-event log (kora.boot.ready/kora.boot.failedvia KR-P2-I-integration ST2's emit listener).BootGateRunnerclassmethods:record(entry)— append (called byboot_coordinator)last_result()— newest entry orNonerecent_history(limit)— oldest→newest, clamped to ring max_reset_history_for_tests()— test-only ring clearagent/boot_coordinator.pyrun_boot_sequencenow records every terminal outcome (READY / STOPPED, including diagnostic-mode runs) viaBootGateRunner.record(). New_record_boot_historyhelper is fail-soft — recording errors don't break the boot path.boot_idminted asboot_{uuid4-hex[:8]};started_atcaptured at runner construction;completed_atat record time.Endpoint flip —
kora_cli/web_server.pycurrent(the newest BootHistoryEntry) +history(the rest, newest-first ordering for the panel) WITHOUTstubflag.stub: True+errorfield naming the cause (panel renders distinct banner).Two projection helpers (
_project_boot_entry_current/_project_boot_entry_history) translateBootHistoryEntry/BootSummary/GateResultinto panel-shaped dicts. Note:GateResulthas notitlefield (title is aGateClassVar); projection falls back togate_idwhen no title can be resolved — acceptable degradation from stub for ST4.Stub body extracted into
_boot_status_stub(error=...)for shape symmetry with ST2/ST3.Tests —
tests/kora_cli/test_web_server_boot_status.py(full rewrite, 282 LOC)stub:True+error+ per-entry shape sanity (outcome / gate_outcome / gate_class enum membership)currentrenders the recorded boot;historyis empty; nostubflagfailed_gate_id+detailBootGateRunner.last_result()/recent_history()/limit=0edge casesSub-task chain (this bucket — all independent off main)
Test plan
pytest tests/kora_cli/test_web_server_boot_status.py/api/boot-statusshows the recorded boot with no STUB banner🤖 Generated with Claude Code