Skip to content

refactor(server): unblock Phase 4's two structural obstacles - #611

Merged
athvin merged 1 commit into
mainfrom
bm/phase4-unblock
Nov 5, 2026
Merged

athvin merged 1 commit into
mainfrom
bm/phase4-unblock

Conversation

@athvin

@athvin athvin commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Neither of these is one of the open decisions in Phase 4. Both are work the design already specified, and both have to happen before the legacy arm can be deleted at all.

1. dispatch_coverage.rs blocked its own premise

Phase 1 said this file would be rewritten to scan dag_for. It was not — and the textual scan it kept made it an obstacle to Phase 4. The test hard-asserted that lake_maintain has a match arm in dispatcher.rs as its own self-check, so deleting the legacy arms would have failed the very file that exists to prove kinds are routed. The deletion could not be done without first rewriting the thing guarding it.

Split in two, because there are two destinations and they retire at different times:

  • The DAG half is permanent and registry-backed. Every enqueueable kind must JobKind::parse and assemble a non-empty graph via dags::dag_for. A missing kind is now a None, not a missing line of text.
  • The legacy half stays textual by necessity (the arms are string literals and two are async pre-branches in dispatch_once) but covers exactly LEGACY_ARM_KINDS and retires itself: when Phase 4 empties that list the test stands down rather than failing. Its self-checks draw from that same list, so they go away with it instead of outliving it.

A third test keeps the list honest — it may name only kinds the product actually enqueues, so a stale entry can't make Phase 4 look larger than it is.

Observed failing before being trusted

Planted Result
deleted a real arm (renamed dispatcher.rs's "profile" arm) CAUGHT — "these kinds are NOT on the executor allowlist … ["profile"]"
a legacy kind with no arm CAUGHT
a stale entry naming a non-enqueueable kind CAUGHT
LEGACY_ARM_KINDS emptied — Phase 4's exit stands down, as intended

That last row is the one that matters: it demonstrates the deletion this file used to block now passes through it cleanly.

2. The new arm depended on the legacy arm's classifier

dags/tasks.rs::engine_error ran engine failure strings through pg::FailureClass::classify and mapped the result onto er_errors. So new-arm code depended on a type the legacy arm owns, and classify could not be deleted while the new arm called it.

§6.5 says the two taxonomies "collapse into the latter at the executor boundary". engine_error is that boundary, so the substring rules live there now and produce an ErrorClass directly. The rules are carried over unchanged.

Proven behaviour-preserving, not assumed

A temporary differential test compared the new classifier against the old mapping across 29 strings — every case from the old table, plus capitalisation variants, empty input, and messages that satisfy two arms at once ("open lake AND config:", "param: and timed out"). They agree everywhere.

The 14-case table moved here from pg_job_retry.rs rather than being deleted with the rules: the message shapes are what the assertion is really about, and they outlive whichever type does the classifying. A second test pins the property that table protects — only transient_io is retryable, so a precondition or a panic never is. Guessing "retryable" on an unrecognised failure is how a real bug becomes three identical pod launches.

Scope, precisely

This removes the new DAG arm's dependency. classify still has callers in reporter.rs, dispatcher.rs and pg_job_retry.rs — all legacy, all deleted in Phase 4 — and in lib.rs's dispatch_pg, the injected-runner test helper that is already named on Phase 4's decision list and is not touched here.

make check green.

🤖 Generated with Claude Code

Neither of these is one of the open decisions in Phase 4. Both are work the
design already specified and that has to happen before the legacy arm can be
deleted at all.

## 1. `dispatch_coverage.rs` blocked its own premise

Phase 1 said this file would be rewritten to scan `dag_for`. It was not, and
the textual scan it kept made it an obstacle to Phase 4: the test hard-asserted
that `lake_maintain` has a `match` arm in `dispatcher.rs` as its own self-check,
so deleting the legacy arms would fail the file that exists to prove kinds are
routed. The deletion could not be done without first rewriting the thing
guarding it.

Split in two, because there are two destinations and they retire at different
times:

- **The DAG half is permanent and registry-backed.** Every enqueueable kind
  must `JobKind::parse` and assemble a non-empty graph through `dags::dag_for`.
  A missing kind is now a `None`, not a missing line of text.
- **The legacy half stays textual by necessity** — the arms are string literals
  and two are async pre-branches — but covers exactly `LEGACY_ARM_KINDS` and
  RETIRES ITSELF: when Phase 4 empties that list the test stands down instead
  of failing. Its self-checks use members of that same list, so they go away
  with it rather than outliving it.

A third test keeps the list honest: it may name only kinds the product actually
enqueues, so a stale entry cannot make Phase 4 look larger than it is.

Observed failing before being trusted, four ways:

  deleted a real arm (renamed dispatcher.rs's "profile" arm)  -> CAUGHT,
      "these kinds are NOT on the executor allowlist … ["profile"]"
  a legacy kind with no arm                                   -> CAUGHT
  a stale entry naming a non-enqueueable kind                 -> CAUGHT
  LEGACY_ARM_KINDS emptied (Phase 4's exit)                   -> stands down

## 2. The new arm depended on the legacy arm's classifier

`dags/tasks.rs::engine_error` ran engine failure strings through
`pg::FailureClass::classify` and mapped the result onto `er_errors`. So
new-arm code depended on a type the legacy arm owns, and `classify` could not
be deleted while the new arm called it.

§6.5 says the two taxonomies "collapse into the latter at the executor
boundary". `engine_error` IS that boundary, so the substring rules now live
there and produce an `ErrorClass` directly. The rules are carried over
unchanged.

Proven behaviour-preserving rather than assumed: a temporary differential test
compared the new classifier against the old mapping across 29 strings —
every case from the old table plus capitalisation variants, empty input, and
messages that satisfy two arms at once ("open lake AND config:",
"param: and timed out") — and they agree everywhere. The 14-case table moved
here from `pg_job_retry.rs` rather than being deleted with the rules: the
message shapes are what the assertion is really about, and they outlive
whichever type classifies them. A second test pins the property that table
protects — only `transient_io` is retryable, so a precondition or a panic
never is.

Scope, precisely: this removes the NEW DAG ARM's dependency. `classify` still
has callers in `reporter.rs`, `dispatcher.rs`, `pg_job_retry.rs` (all legacy,
all deleted in Phase 4) and in `lib.rs`'s `dispatch_pg` — the injected-runner
test helper, which is already named on Phase 4's decision list and is not
touched here.

`make check` green.

Co-Authored-By: Claude Fable 5 <[email protected]>
@athvin
athvin force-pushed the bm/phase4-unblock branch from 2a939bf to 41c2eb3 Compare November 5, 2026 19:47
@athvin
athvin merged commit c222974 into main Nov 5, 2026
39 checks passed
@athvin athvin added the merge-bus eligible for the merge bus label Nov 5, 2026
@athvin
athvin deleted the bm/phase4-unblock branch November 5, 2026 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-bus eligible for the merge bus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants