feat(BA-6852): record Agent kernel transitions into scheduling history#13033
Closed
jopemachine wants to merge 2 commits into
Closed
feat(BA-6852): record Agent kernel transitions into scheduling history#13033jopemachine wants to merge 2 commits into
jopemachine wants to merge 2 commits into
Conversation
Add the unified KernelStatusTransitionAnycastEvent (BEP-1061 3d) and the Manager-side recording/apply contract (3e). Nothing wrote kernel_scheduling_history until now -- KernelSchedulingHistoryCreatorSpec had no caller -- so the kernel scheduling-history APIs always returned empty lists. On receiving the event, the Manager: - applies `from -> to` atomically (UPDATE WHERE status = from), so a duplicate or stale transition matches nothing and is rejected idempotently; a failure report leaves the status untouched and records history only - records the transition into kernel_scheduling_history in the same transaction, mapping the Agent's KernelStatus transition and processing result onto phase/from_status/to_status/result/error_code/message; a redelivered identical record merges by incrementing attempts (at-least-once transport, sweep re-emission) - requests the same follow-up schedule types as the granular event handlers (e.g. CHECK_PULLING_PROGRESS after PULLING) when a transition is applied The phase column derives from the Agent execution stage owning the target status (prepare/create/terminate, per the BEP handler table). Transitions targeting statuses outside the Agent-reportable phase set (e.g. CANCELLED, which belongs to sokovan session scheduling) are ignored. The Agent-side egress that emits this event is BA-6851; until it lands, the granular anycast events remain the live path and this handler consumes only what is published to the unified event. Verified end to end on a live stack by publishing the event to the Redis stream: the Manager consumed it, applied the transition, recorded history visible through the scoped kernel history API, rejected a redelivered copy, and merged repeated failure reports into one row with attempts=2. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Member
Author
|
This work should be done after the agent refactoring. |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves #12785 (BA-6852)
Summary
Nothing wrote
kernel_scheduling_historyuntil now —KernelSchedulingHistoryCreatorSpechad no caller — so the kernel scheduling-history APIs (#12870/#12989/#12866) always returned empty lists. This implements the Manager-side recording/apply contract of BEP-1061 §3e, plus the unified event type from §3d that it consumes.KernelStatusTransitionAnycastEvent(kernel_id, from_status, to_status, reason, result, error_code, message)— no phase/step payload;from/toare sokovanKernelStatusvaluesUPDATE … WHERE status = fromin the scheduler repository, so a duplicate/stale transition matches nothing and is rejected idempotently; aFAILEDreport leaves the status untouchedphase/from_status/to_status/result/error_code/message; a redelivered identical record merges by incrementingattempts(at-least-once transport / sweep re-emission)ScheduleTypemarks as the granular handlers (e.g.CHECK_PULLING_PROGRESSafterPULLING)PREPARING…TERMINATED) are ignored — CANCELLED/reschedule stays with sokovan session scheduling, per the BEPphasederives from the Agent execution stage owning the target status (prepare/create/terminate, per the BEP handler table).TERMINATEDtransitions also free resource allocations, mirroring the existing terminated path.Boundary
The Agent-side egress that emits this event is BA-6851 (not started); until it lands, the granular anycast events remain the live path and this handler consumes only what is published to the unified event. Migrating granular consumers is BA-6853.
Note: BA-6852 is assigned to @HyeockJinKim — this PR was made on jopemachine's direction to unblock the kernel history feature line; happy to hand over or adjust to your planned shape.
Test plan
FAILEDreport without follow-up, stale rejection, unknown/non-reportable statuses ignoredfromrejected without history; redelivered applied transition rejected;FAILEDrecords without status change; repeatedFAILEDmerges to one row withattempts=2; non-reportable target ignoredeventsstream against a running manager — status applied (PULLING → PREPARED), history row recorded and visible to the kernel owner throughscopedKernelSchedulingHistories, redelivered copy rejected (no duplicate), repeated failure reports merged (attempts=2)ruff check/ruff formatclean🤖 Generated with Claude Code