Skip to content

fix(kind): phase 6's guard refused the very success it was checking for - #742

Merged
athvin merged 1 commit into
mainfrom
fix/kind-phase6-termination-reason
Nov 6, 2026
Merged

athvin merged 1 commit into
mainfrom
fix/kind-phase6-termination-reason

Conversation

@athvin

@athvin athvin commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Finishes the last open item from #740/#741. The kind probe's fifth distinct cause — and the second time this one assertion has been wrong.

Phases 1–5 now pass. Phase 6 reached traffic moved blue -> green with a task in flight and then failed:

AssertionError: reconcile_schema: the cutover was visible to the attempt
(termination_reason='Completed', error_detail=None)

A probe bug, not a product failure

The guard was assert t["termination_reason"] is None, resting on a comment that said "a succeeded task carries no reason at all." That is false, and the source settles it:

  1. exec-task posts its verdict with termination_reason: None (exec_task.rs:466/490/518).
  2. The executor's pod watch then annotates the already-succeeded row with the pod's terminated reason — record_evidence, whose SQL is guarded state IN ('succeeded','skipped').
  3. Kubernetes' reason for a container that exits 0 is the literal Completed.

So the guard failed the phase for succeeding. Completed appears nowhere in the Rust source, which is what made it worth tracing rather than assuming.

It is also a race, which is why == "Completed" would be flaky rather than correct: the annotation lands after the verdict, so a read legitimately sees either value. Both mean undisrupted.

The fix

An allowlist of undisrupted values — (None, "Completed") — not a denylist of today's failure reasons. A denylist would silently accept any reason added to exec_task.rs later, which is the defect where an omission reads as permission.

Plus exit_code in (None, 0), so Completed is corroborated by the pod's exit status rather than trusted — that reason is the pod's, and a succeeded row carrying a nonzero exit is incoherent however it got there. Confirmed exit_code is on the TaskInstance schema in openapi.json before asserting on it; asserting a field I had not verified exists is exactly how the previous guard broke.

Verified against the real failed row (state=succeeded, live, launches=1, termination_reason='Completed') — accepted on both sides of the annotation race.

Why the fixture test did not catch it

kind-assertions-test.sh extracts the real block rather than copying it, which is right. But its row() default was termination_reason: None — it modelled the moment before annotation and never the steady state. So it green-lit a guard the live ledger could not satisfy: the fixture asserted the probe's belief rather than the system's behaviour.

The default now models the annotated row, with the unannotated shape kept as its own case so the race is covered both ways, plus new cases refusing an unknown future reason and a nonzero exit.

Mutation-tested — each caught:

Mutation Caught by
revert to is None (the shipped bug) the annotated-Completed case
widen the allowlist to accept everything 7 assertions
drop the exit_code corroboration the nonzero-exit case

Proven before merge, not after

kind.yml's probe is if: github.event_name != 'pull_request', so a PR cannot run it — which is how five causes reached main one at a time. I dispatched it on this branch instead: run 42270118048. The PR's own assertions job covers the cheap half in ~1s.

Two findings recorded, neither needing a change

  • allocatable is 4000m, not the ~2000m every CPU sum in this probe and in values-kind.yaml assumes. The public-repo switch moved ubuntu-latest to 4 vCPU. Phase 6 needed 450m with 2750m free, so CPU has stopped being the constraint that forced the api/dispatcher requests down to 100m/250m. The log_cpu_budget line added for exactly this purpose is what reported it. Worth a follow-up to revisit those trims and the budget table, but nothing here depends on it.
  • The OTel export errors filling the log are expected — kind runs no collector — and are not the failure.

The success line no longer claims "no control_plane_unreachable": that is the reason the first version of this guard wrongly keyed on, and one a running attempt cannot reach. A green line asserting the wrong thing is how that version survived review.

🤖 Generated with Claude Code

The kind probe's fifth distinct cause, and the second time this one assertion
has been wrong. Phases 1-5 now pass; phase 6 reached "traffic moved blue ->
green with a task in flight" and then failed with

    AssertionError: reconcile_schema: the cutover was visible to the attempt
    (termination_reason='Completed', error_detail=None)

A PROBE BUG, NOT A PRODUCT FAILURE. The guard was
`assert t["termination_reason"] is None`, resting on a comment that said "a
succeeded task carries no reason at all". That is false. `exec-task` posts its
verdict with `termination_reason: None`, and then the executor's pod watch
annotates the already-succeeded row with the POD's terminated reason —
`record_evidence`, whose SQL is guarded `state IN ('succeeded','skipped')` —
and Kubernetes' reason for a container that exits 0 is the literal
"Completed". So the guard failed the phase for succeeding.

It is also a RACE, which is why `== "Completed"` would be flaky rather than
correct: the annotation lands after the verdict, so a read legitimately sees
either value. Both mean undisrupted.

The fix is an ALLOWLIST of undisrupted values — `(None, "Completed")` — not a
denylist of today's failure reasons. A denylist would silently accept any
reason added to exec_task.rs later, which is the defect where an omission
reads as permission. Plus an `exit_code in (None, 0)` assertion, so
"Completed" is corroborated by the pod's exit status rather than trusted: that
reason is the pod's, and a succeeded row carrying a nonzero exit is incoherent
however it got there.

Verified against the real failed row (state succeeded, live, launches 1,
termination_reason 'Completed') — accepted on both sides of the annotation
race.

WHY THE FIXTURE TEST DID NOT CATCH THIS. `kind-assertions-test.sh` extracts
the real block rather than copying it, which is right, but its `row()` default
was `termination_reason: None` — it modelled the moment before annotation and
never the steady state. So it green-lit a guard the live ledger could not
satisfy, which is the same shape as the full-stack tier findings: the fixture
asserted the probe's belief rather than the system's behaviour. The default
now models the ANNOTATED row, with the unannotated shape kept as its own case
so the race is covered in both directions, plus cases refusing an unknown
future reason and a nonzero exit.

Mutation-tested: reverting to `is None`, widening the allowlist to accept
everything, and dropping the exit_code corroboration are each caught.

Two findings recorded while here, neither needing a change:

- `allocatable` is 4000m, not the ~2000m every CPU sum in this probe and in
  values-kind.yaml assumes — the public-repo switch moved `ubuntu-latest` to
  4 vCPU. Phase 6 needed 450m with 2750m free, so CPU has stopped being the
  constraint and the 100m/250m request trims made for the 2-vCPU ceiling are
  now merely conservative. The `log_cpu_budget` line added for exactly this
  purpose is what reported it.
- The OTel export errors filling the log are expected: kind runs no collector,
  and they are not the failure.

The success line no longer claims "no control_plane_unreachable" — the reason
the FIRST version of this guard wrongly keyed on, and one a running attempt
cannot reach. A green line asserting the wrong thing is how that version
survived review.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@athvin
athvin merged commit 3ed7b57 into main Nov 6, 2026
43 checks passed
athvin pushed a commit that referenced this pull request Nov 7, 2026
Closes #638, which is a decision rather than an implementation. Records it
beside Phase 4, where #645 can act on it.

Option 1 adopted: anything needing real job execution points at kind, and
`make run` plus the host dev stack keep the API-only work they already do.
Option 3 is refused on §13's own words — "a local or in-process executor, an
`ER_EXECUTOR` flag, or any production path other than `er-server exec-task` in a
Kubernetes Job" — so promoting `FakePodApi` or the observer's `Scripted` is not
available.

Two things the tree said that the ticket did not.

The blocker was never the flag. `ER_DISPATCH_IN_PROCESS` is assigned NOWHERE —
every occurrence is prose or a comment — and up.sh already starts
`er-dispatcher` as its own host process, so local dev already runs Phase 4's
topology. What the phase actually removes locally is the executor's only route
to a `PodApi`: `executor::from_env`'s third `return (None, None)` needs
`KubeApi::in_cluster`. Three documents still claimed otherwise and are fixed
here — the infra-platform skill ("survives only in local dev (`make run`)"),
frontend-testing.md ("er-server runs the dispatcher in-process"), and this
file's own "`make run` … loses `ER_DISPATCH_IN_PROCESS` in Phase 4".

And Option 2 is narrower than the ticket assumes. It offers CLI-seeded rows as
cheap "if the tier only reads rows, which its comment suggests". It does not:
`grow-your-data.spec.ts` creates a source named at runtime, clicks
`wizard-activate-run`, waits out `waitForQuietQueue(page, 780_000)` and asserts
`["run_all_incremental", "run_all_full", "train"]` are all `succeeded`. There is
no row to pre-seed for a source that does not exist until the spec makes it.
Seeding covers four of the five full-stack specs — three read rows and
`run-the-business` asserts a 409 refusal — and the fifth needs a cluster. That
is sized as its own ticket rather than folded into the Phase 4 deletion, since
the engine-side handoff it exercises is already covered by the kind probe's
pipeline phase as seven pods; what is at stake is the UI journey.

Also corrects the kind probe's phase count, which this file had at five. There
are six, and the sixth is not bookkeeping: it flips `svc/er-api` between colours
under an in-flight attempt, proving a serving-path deploy does not fail paying
work. Its guard was fixed in #742 after it refused the very success it was
checking for.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
athvin added a commit that referenced this pull request Nov 7, 2026
#638) (#746)

* wip: claim #638 — decide how local dev runs jobs after Phase 4

* docs(batch): decide how local development runs jobs once Phase 4 lands

Closes #638, which is a decision rather than an implementation. Records it
beside Phase 4, where #645 can act on it.

Option 1 adopted: anything needing real job execution points at kind, and
`make run` plus the host dev stack keep the API-only work they already do.
Option 3 is refused on §13's own words — "a local or in-process executor, an
`ER_EXECUTOR` flag, or any production path other than `er-server exec-task` in a
Kubernetes Job" — so promoting `FakePodApi` or the observer's `Scripted` is not
available.

Two things the tree said that the ticket did not.

The blocker was never the flag. `ER_DISPATCH_IN_PROCESS` is assigned NOWHERE —
every occurrence is prose or a comment — and up.sh already starts
`er-dispatcher` as its own host process, so local dev already runs Phase 4's
topology. What the phase actually removes locally is the executor's only route
to a `PodApi`: `executor::from_env`'s third `return (None, None)` needs
`KubeApi::in_cluster`. Three documents still claimed otherwise and are fixed
here — the infra-platform skill ("survives only in local dev (`make run`)"),
frontend-testing.md ("er-server runs the dispatcher in-process"), and this
file's own "`make run` … loses `ER_DISPATCH_IN_PROCESS` in Phase 4".

And Option 2 is narrower than the ticket assumes. It offers CLI-seeded rows as
cheap "if the tier only reads rows, which its comment suggests". It does not:
`grow-your-data.spec.ts` creates a source named at runtime, clicks
`wizard-activate-run`, waits out `waitForQuietQueue(page, 780_000)` and asserts
`["run_all_incremental", "run_all_full", "train"]` are all `succeeded`. There is
no row to pre-seed for a source that does not exist until the spec makes it.
Seeding covers four of the five full-stack specs — three read rows and
`run-the-business` asserts a 409 refusal — and the fifth needs a cluster. That
is sized as its own ticket rather than folded into the Phase 4 deletion, since
the engine-side handoff it exercises is already covered by the kind probe's
pipeline phase as seven pods; what is at stake is the UI journey.

Also corrects the kind probe's phase count, which this file had at five. There
are six, and the sixth is not bookkeeping: it flips `svc/er-api` between colours
under an in-flight attempt, proving a serving-path deploy does not fail paying
work. Its guard was fixed in #742 after it refused the very success it was
checking for.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: bmoore813 <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants