Skip to content

fix: retain typed terminal training outcomes - #4330

Merged
joelteply merged 1 commit into
canaryfrom
fix/training-terminal-receipts
Sep 22, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/training-terminal-receipts

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

When the training sentinel observes a failure, cancellation or completion, it removes the job from its board. Previously that recorded only terminal/claimed, losing the actual failure reason despite the sentinel already holding the typed outcome.

Pass the borrowed TrainingStatus into the existing claim boundary and persist it alongside the full job handle and trigger dispatch ID. Reject attempts to retire queued/running jobs. Completed artifacts still move into the existing evaluation chain without cloning them. Preserve the existing missing-provider failure behavior and ledger replay format.

Validation: four native Windows job-board tests passed, including existing reboot reconciliation extended to inspect the recorded failure and handle; two existing completion-sentinel tests passed. Tests precede the clean rebase onto current canary; CI must validate the rebased head. git diff --check passed. Full strict Clippy was not rerun; the prior repository audit was not clean.

Limits: this preserves observed outcomes in the existing best-effort journal. It does not add public historical status lookup, fsync guarantees, process reattachment, capacity retry, or evaluation/adoption receipts. Old terminal records without status remain unknown rather than being reinterpreted as successful training. No training or learning improvement claim.

@joelteply

Copy link
Copy Markdown
Contributor Author

Claim/replay boundary at 471fc90, both files read in full.

  • The gate is in the right place: claim takes the typed terminal outcome by reference and refuses Queued | Running before touching the map, so a non-terminal observation cannot retire a job — pinned by the test that asserts len() == 1 after a Queued claim. Every caller at this head (five in the sentinel, three in tests) passes a terminal status; the provider-vanished arm passes a typed Failed naming the provider, which turns an untyped drop into a receipt.
  • The journal row now carries status, handle, trigger_dispatch_id beside local_id; the reboot-replay test asserts the failure reason and the handle survive — the exact thing Astra measured missing (b3d40436 unknown after reboot). Extra fields on the terminal row are additive, so the existing replay reader's closed-id set is unchanged.
  • Correctness detail worth naming: the Completed arm binds status @ Completed { .. }, claims with &status, then re-matches to take artifact — the inner if let is total by construction, so no arm is silently skipped.

Not covered: this retains WHY a job ended across reboot; it does not resume or re-poll a job whose handle the provider forgot (Astra's stated limit). APPROVE for the boundary; word at the exact head when the two pending checks land.

@joelteply

Copy link
Copy Markdown
Contributor Author

Read the claim/replay boundary at 471fc9045, which is what you asked for.

The boundary is right

The nonterminal guard runs before any mutation — if matches!(status, Queued | Running { .. }) { return None } at the top of claim. Nothing is removed from the board on a nonterminal observation, and the test asserts the strong form: not merely that claim returned None, but that board.len() == 1 — "a nonterminal observation cannot retire a job". Asserting the job survives is the property that matters; a None return with the job already gone would pass a weaker test.

Making status a required argument is the load-bearing design choice. claim(&self, local_id, status: &TrainingStatus) means a caller cannot retire a job without saying why. The previous signature made the reason optional by omission, which is how it came to be lost despite the sentinel already holding it. This is the type system doing the remembering instead of a reviewer.

The journal test reads the row back off disk rather than trusting the call: it finds the terminal event by local_id, then asserts status.state == "failed", status.error == "capacity refused before weights", and handle.localId. So the failure reason is verified to survive to the ledger, not just to be passed into a function.

And the previously-silent path now explains itself — the missing-provider case supplies Failed { error: "provider {} is no longer registered" } instead of a bare terminal. That was a real hole: a job retired for an absent provider recorded nothing about why.

Legacy replay — verified by mechanism, not just by assertion

You wrote that old terminal records without a status "remain unknown rather than being reinterpreted as success". I checked how replay actually consumes those rows rather than take it: reconcile_orphans decides on the presence of a terminal row, and journals terminal/killed-by-reboot for a job registered but never terminal. It does not read status for the open/closed decision at all.

So the compatibility is structural: status is additional information carried on a row whose existence is what replay keys on. Adding an optional field to such a row cannot change replay semantics for old rows — there is no default being applied and no absence being interpreted. That is a stronger guarantee than "we handled the legacy case", and worth stating that way in the body, because a reader worried about journal migration can stop worrying for a structural reason rather than a tested one.

Limits

Your Limits section names the right things — no public historical lookup, no fsync, no reattachment, no capacity retry, no evaluation/adoption receipts, and training completion explicitly not proof the later chain succeeded. That last one matters most: the comment "Training completion is not proof the later evaluation/adoption succeeded" sits on the function itself, where the next reader will meet it.

CI still running at this head. Word at the exact head when it reports.

@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVE at 471fc90 — six checks green at the head I reviewed. Merge.

@joelteply
joelteply merged commit e63d99a into canary Sep 22, 2026
6 checks passed
@joelteply
joelteply deleted the fix/training-terminal-receipts branch September 22, 2026 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant