Repository navigation
refactor(dispatcher): delete the legacy in-process dispatch arm (#645) - #756
Merged
Merged
Conversation
This was referenced Nov 7, 2026
athvin
force-pushed
the
issue/645-delete-legacy-dispatch-arm
branch
from
November 7, 2026 14:17
84a8319 to
5d7135e
Compare
athvin
force-pushed
the
issue/645-delete-legacy-dispatch-arm
branch
3 times, most recently
from
November 7, 2026 20:08
08167a3 to
a86da2f
Compare
12 tasks done
Owner
Author
|
Heads-up from #809, just merged: every pull request now carries a post-merge ledger from Not touching your body — a concurrent rewrite would clobber whatever you have in flight. When convenient, append the |
2 of 4 tasks
athvin
marked this pull request as ready for review
November 7, 2026 21:06
`profile`'s DAG opens with a `reconcile_schema` source, but the arm for that task in `run_pod_task` named `lake_maintain`, `lake_migrate` and `train` and not `profile`. `deploy.yml` has listed `profile` in `DAG_KINDS` throughout, so every profile job routed to the executor, planned, launched — and then failed at its first task with "the executor does not yet run task 'reconcile_schema' of kind 'profile'", in dev and in production. Nothing caught it because nothing compared the compiled DAGs against the dispatch tables. `dispatch_coverage.rs` proves each job KIND has a destination and stops one level short of the tasks. So `tests/dag_task_coverage.rs` walks `dag_for` for all eleven kinds and asserts every node has an arm in the table its `NodeKind` selects. It parses the tables, for the reason the file states at length: calling `run_pod_task` to see whether an arm exists would execute the real body of every arm that is not refused. Observed failing on the unfixed tree, naming exactly the one gap; `the_two_tables_are_separate` is likewise observed failing when the region boundaries are made to overlap, because a control node satisfied by a pod arm would otherwise read as routed. This matters more as #645 proceeds: with the legacy in-process arm deleted there is no second path a kind can fall back to, so "every node has a body" stops being a nicety. Two false doc comments in the same file, found while reading it. The module note still said Phase 1 shipped the graphs with "no executor" and bodies that "refuse to run until `er-server exec-task` lands in Phase 2". And `run_pod_task`'s own doc block had come adrift above `run_control_task`, so that function carried two concatenated comments while `run_pod_task` carried none — which is how "Phase 2 runs the maintenance kinds; every other body still refuses" survived being wrong. Refs #645
…he executor's Phase 4 of #645, first step. The legacy in-process arm cannot be deleted while `executor.dagKinds` still gates routing: a kind off the allowlist would fall through to a `run_job` that no longer exists. So the allowlist goes first. `ER_EXECUTOR_DAG_KINDS` is gone, along with `ExecutorConfig::dag_kinds` and `Executor::handles`. `dispatch_once_with_executor` now plans every claim instead of consulting a set, which is safe because `plan_claimed` already refuses a kind the DAG registry cannot parse — terminally, with that reason on the row. That is a better answer than the legacy arm's generic "dispatcher does not handle job kind", and it is the only answer available once the arm is gone. `ExecutorConfig::from_env` no longer returns `None` for a missing variable; it returns `None` only when a configured task template cannot be read. What still disables the executor is the absence of a namespace or an in-cluster identity, which is what keeps a host dispatcher out of the business of creating Jobs. The allowlist had a second consumer worth naming: `AppState.executor_kinds`, which the cancel route read to choose `cancel.sql`'s `canceling` over a direct `mark(…, "canceled")`. Every kind now takes the `canceling` path, so a cancel holds the dataset slot until its pods are provably gone. The direct arm survives only for a kind that does not parse, which cannot have been planned and so has no pods to revoke. `LEGACY_ARM_KINDS` in dispatch_coverage.rs is emptied, which is the exit that file documents for itself — its legacy half returns immediately rather than failing. The list was stale in any case: it named correct, train, profile, apply_approved and apply_corrections as legacy while deploy.yml had been routing all eleven kinds to the executor. Six configuration sites carried the value and are removed together: both deployment templates, `values.yaml`, `values-kind.yaml`, the job-level `DAG_KINDS` env in deploy.yml, and the `--set executor.dagKinds=` in deploy-inactive-colour.sh and deploy-cutover.sh. One behavioural consequence to expect on kind: `values-kind.yaml` listed three kinds, so `make check-kind` now routes all eleven through the executor there. `make check` green. The in-process arm still runs when there is no executor; its deletion, and the guard that stops a dispatcher claiming work it cannot execute, are the next step. Refs #645
…ds moved `run_report_messages` had exactly one caller: `dispatch_claimed`, the legacy in-process arm. The executor's settle emitted the `job.<state>` webhook and the `entity.*` aggregate and nothing else. Since `deploy.yml` lists every kind, every job in dev and production has been taking the executor path — so the run report has not been sent for some time, and nothing reported it, because an email that is never sent looks exactly like a tenant who never configured one. Phase 4 (#645) would have deleted the only caller and made that permanent. So the report moves to where jobs actually settle, riding after the outcome webhook and the aggregate, because a subscriber watching all three should see the outcome first. `Executor` grows a `Mailer` built in `connect`, which keeps the signature the integration tests already call; with no SES configuration it is the `off` mailer and `send` is a no-op. `run_report_messages` itself is unchanged and stays where it is — pure, and already covered by seven unit tests that need no mailer. Only its visibility widens to `pub(crate)`. The entity counts are now read out of `finish`'s output unconditionally rather than inside an `if let`, because the report wants them too and an empty vector is the honest "nothing to announce". The aggregate's own emit is still gated on a non-empty list, so its behaviour does not change. `tests/settle_consequences.rs` closes the class rather than the instance: each settle consequence is named with the CALL that must appear in executor.rs. Call site, not mention — the first version of the gate asked only whether the name appeared, and it passed when the call was deleted while the method and the `run_report_messages` inside it sat there unreached. It would have caught this bug and not the next one. Observed failing on both mutations: the call removed with the method kept, and the method removed entirely. `make check` green. Refs #645
…lowlist `executor_harness.rs` arrived on `main` with #769, which was cut before the allowlist came out, so it set `ExecutorConfig::dag_kinds` to every kind in the registry. That field no longer exists after this branch's first step, so the rebase left the test binary not compiling. Belongs with the allowlist removal rather than on its own, but amending a commit four deep buys nothing when the PR squashes. Refs #645
`pg_mass_update`, `pg_protect_master` and `pg_record_overlays` each reached the engine through `dispatcher::drain_and_correct` — the legacy in-process arm this branch deletes. Each now enqueues a real `apply_corrections` job and runs it through the executor as its own task pods. Their assertions are untouched. They were always about outcomes — the override value lands and a clear nulls the field, protect pins the master and retract restores the policy, suppress excludes the record and retract restores it — and never about which arm produced them. That is what makes these ports rather than rewrites. `Harness::apply_corrections` is the one-line stand-in for a `drain_and_correct` call, because there were six call sites across the three files. It panics with every task row rather than just the state: a pass that settles without doing its work is the failure mode this path has already had once (#760), and "succeeded" on its own never explains it. All three fixtures gain the model artefacts a correction pass resolves through `RunContext` — ER_MODEL_PATH, ER_TF_PATH, ER_LEXICON_PATH and the two version ids. They carried only the lake and the config, because the legacy `run_correct` needed only those, which made every one of them thinner than any real org; a provisioned org declares all of them, in both `scripts/check_kind.sh` and `scripts/frontend-dev/env.sh`. The TF fixture is COPIED, never pointed at, since a snapshot appends to it. Observed passing against a real Postgres and DuckLake: 51s, 42s and 47s respectively, which is seven pods' worth of cold DuckDB opens rather than an in-process call — the point of the exercise. Three of the eight ports #645 needs. `pg_drain_dispatcher.rs` stays on the legacy arm until #770, because it is the only one that asserts `entity.write_back` and the task path does not emit it yet. Refs #645
…EM-only `er_entities::pair_label::read::all` takes its scope as a bare `&str` named `dataset_id` — it is called that way everywhere else, `&d.id` at lib.rs:2640 and 5688 — and the attempt channel's work-order route passed `current.org_id`. It matched nothing. The damage is quiet. The surrounding code degrades a label READ FAILURE to an EM-only estimate on purpose, and zero rows is indistinguishable from "this tenant has no labels", so every `train` on the task path estimated `m` without labels and recorded `m_from_labels: 0` — which the registry then reports as provenance, truthfully describing a training pass that could not have used them. A steward labelling pairs to improve a model was feeding a path that threw the labels away. Fourth instance of one class. The other three (`pending_actions`, `subjects_for_tag`, `unapply_tag`, plus `matching_model::read::list`) went in with #769. The shape is always the same: scope is a `&str`, an org id is a valid `&str`, and the wrong one returns an empty set rather than an error. `pg_train.rs` is ported off `dispatcher::train_and_register` onto a real `train` job, and it is what caught this: `m_from_labels` was 0 against an expected 2. Two things the port had to change beyond the call: - **The env moves onto the org row.** `ensure_org` left it unset because the legacy arm took the env as an argument; a job on the task path reads it from its dataset, so the fixture now stores it with `upsert_org_byo` BEFORE `converge_default_datasets` copies it down. It also gains ER_MODEL_PATH and ER_LEXICON_PATH, which `Train`'s run context resolves and the legacy half did not need. ER_TF_PATH stays the test's own copy, because training appends its snapshot to that file. - **The run id is no longer the test's to choose.** On this path the run id IS the job id, so the version label and the provenance are named after a value only `enqueue` knows. `Harness::run_kind` returns it and the assertions use it, where they used to hard-code `01TRAINJOB…`. Four of the eight ports. `make check` green. Refs #645
…path `pg_entity_events` and `pg_approval` drove the engine through `dispatcher::dispatch_once_with` — the legacy claim-and-run path. Both now run real jobs through the executor: two `run_all_full` runs as seven pods each, and an `apply_approved` per phase. **The harness now claims on every iteration, which is what `run_loop` does.** Claiming once was wrong as soon as the queue held more than the job under test, and `pg_approval` is exactly that case: its phase 2 stages approvals, which enqueues an `apply_corrections`, and `pg::claim` takes the OLDEST queued row for an org with no active job. So the harness claimed that one, pumped it, and the job under test sat `queued` while the budget ran down. The legacy tests could not see this. `dispatch_once_with` returns whether SOMETHING was claimed, and `assert!(run().await)` asked only that — never which job. So `pg_approval`'s closure returns the state its own job SETTLED in now, because on the task path "claimed" means planned and an `apply_approved` whose control task failed would have been claimed just the same. `queued` therefore joins `running` and `dispatching` as a non-terminal state for the settlement loop: a job waiting behind another is not finished, and neither is one a retry put back. Six of the eight ports, and the full 108-test er-server tier is green against a real Postgres and DuckLake — so the harness change did not disturb the four already ported. The two that remain are blocked on something this branch should not decide alone: - `pg_drain_dispatcher.rs` — #770, the task path emits no `entity.write_back`. - `pg_provision.rs` — there is no profile-injection seam. `CreateCatalog` calls `provision::Profile::from_env()` directly, and `dispatch_once_with` exists precisely because a test cannot set env (`set_var` is unsafe under edition 2024 and the workspace denies `unsafe_code`). Nothing under `tests/` so much as mentions `create_catalog` or `lake_init`, so provisioning has NO coverage on the path that runs it, and this is the only provisioning test. Refs #645
occurrence was prose or a comment. So the 53-line `in_process_dispatcher`
spawn in `main.rs`, and the 20-line join that waited for it, were unreachable:
`dsn.filter(|_| env_flag("ER_DISPATCH_IN_PROCESS"))` could not yield `Some`.
`env_flag` goes with it, having had no other caller.
That makes this a deletion of dead code rather than a change of behaviour,
which is why it does not wait on the rest of Phase 4.
The prose is the part that was actively misleading, because several documents
described the flag as live:
- `main.rs`'s own comment claimed `scripts/frontend-dev/env.sh` was "the only
thing that sets this". It was not; nothing was.
- `er-obs`'s `Role::Api` was documented as "the control-plane API (and, under
`ER_DISPATCH_IN_PROCESS`, a dispatcher beside it)".
- `deployment-web-api.yaml` said the flag "is gone from this pod", implying it
exists elsewhere.
- `docs/parity-roadmap.md` described the local stack as one process draining
the queue under the flag — which also made the half-up state it mentions
sound unreachable, when `up.sh` has two processes and checks for exactly it.
- `images.yml` explained a deleted ECR repo with "the in-process dispatcher
runs the pipeline itself".
- `scripts/frontend-dev/{env,up}.sh` both described the flag as something
Phase 4 *would* delete.
**`batch-orchestration-design.md`'s §dispatcher paragraph is rewritten**, and
it is the one that mattered most: it was the design doc's own account of what
the dispatcher IS, and it still described claiming, marking `running`,
reconciling in `spawn_blocking` and running the kind in-process under
`ER_DISPATCH_IN_PROCESS=1` inside the merged `web-api` pod. None of that has
been true since §6.7 split the Deployment and Phase 3 moved the work into
pods. It now describes claim-and-plan, the per-attempt Jobs, and the four
things a settle emits — including the `entity.write_back` events added in
`docs/research-runner-startup.md` keeps its historical claim deliberately: it
is a measurement record and says so ("left standing because the measurements
that follow were taken under it"). Only its own correction block is extended.
`make check` green.
Refs #645
`.claude/skills/er-server-control-plane/SKILL.md` is loaded at the start of every session that touches the control plane, and its §dispatcher said the dispatcher does "claim → mark running → reconcile → open the dataset's lake → run the matching `er-cli` operation **in-process**", ending with "There are no per-run Kubernetes jobs." Every clause of that has been false since Phase 3. A skill is worse than a stale doc when it is wrong, because it is read before the code rather than after. It now describes claim-and-plan, one Job per task attempt, the absence of both the allowlist and the in-process arm, and the four things a settle emits — noting that three of those four once lived only on the in-process arm and were silently not happening for as long as that was true, which is the part a reader needs in order to distrust the right things. The profile seam gets a line, because "a control task reading the environment itself is a control task nothing can test" is the kind of constraint that gets re-broken otherwise. Its references were checked and are clean — which is worth saying, because the body itself warns that they drift, and names the time they described the queue as one-active-per-ORG long after the body said per-DATASET. **`architecture.md` credited an advisory lock with the one-writer-per-dataset guarantee.** Three partial unique indexes on `jobs` do that (`jobs_one_active_per_dataset`, `jobs_one_active_org_level`, `jobs_idempotency`). The advisory lock `pg::claim` takes serves the per-org COUNT cap, because a COUNT is not index-enforceable. The distinction is not pedantic: as written, the invariant appeared to depend on a lock that can be absent while it still holds. `make check` green (the skills gate included). Refs #645
The thing #645 is named for. `dispatcher.rs` goes from 2,617 lines to 919, and `reporter.rs`'s 545 go with it. Thirteen functions, 1,698 lines: `dispatch_claimed` (the whole if-chain), `run_job` and its kind arms, `dispatch_once_with`, `drain_and_correct`, `train_and_register` with `train_half` and `register_half`, `apply_approved_merges`, `provision_tenant`, `provision_dataset`, `write_back_resolutions`, `apply_and_correct` and `config_from_env`. `dispatch_once` now claims and plans, and nothing else — the dispatcher runs no pipeline stage. `dispatch_once_with_executor` folds into it, because with one path there is nothing to route between. Its mailer and provisioning profile parameters are gone: the executor owns the settle that sends the run report and the control task that provisions. **Without an executor it claims nothing, deliberately.** A dispatcher with no namespace and no in-cluster identity — every host, so every `make run` — has nothing to execute a job with, and claiming one would mark a row `running` that nothing could advance. It returns `Ok(false)` and the loop idles. That is what the Phase 4 decision (#638) chose for local development, and it is the one behavioural consequence of this commit that is not simply "less code". `reporter.rs` is deleted whole, and with it the two guards that existed only to exempt its synthetic `inproc` launch identity: the executor's cancel sweep no longer special-cases a `k8s_job_name` of `inproc`, and the attempt-channel's pod binding no longer excludes that literal — the prefix match would have refused it anyway, since no Job yields a pod named `inproc-…`. `pg_attempt_reporter.rs` is deleted rather than ported, as the ticket asks: it asserts the `inproc` identity, which is the one thing here with no successor. Every other test that reached the engine through this arm was PORTED first, across eight files and four earlier commits, which is why this commit can be a deletion and not a rewrite. That ordering was the whole point: the arm's coverage moved before the arm went. What survives in `dispatcher.rs` is what was never the arm: `run_loop`, the scheduler and S3 ticks, `emit_entity_aggregates`, `run_report_messages` and its seven unit tests, `entity_event_name`, `create_tenant_database`, `append_tf_snapshot`, `unix_now`/`fmt_epoch`, and `MAX_APPROVED` — each with a live caller in the executor, a control task or a pod task. `dispatch_pg` and `pg::FailureClass` stay. The ticket lists `classify` for deletion, but `dispatch_pg` is the injected-runner queue harness for `pg_dispatch`, `pg_profile` and `pg_webhook_deliver` — none of which touch the pipeline — and it is the only coverage of `pg::claim`'s one-active-per-dataset enforcement at that level. `fail_or_retry.sql`'s retry branch is production-dead now and is its own commit, with `pg_job_retry.rs`'s rewrite. Two generated skill references move with the code: the `ER_TEST_PG_DSN` count drops to 52, and `reporter.rs` leaves the observability surface listing. `make check` green. `cargo clippy --all-targets` clean, which is the check that matters most for a deletion this size — nothing was left orphaned. Refs #645
…recorded Three defects and a ninth test port, all surfaced by deleting the legacy arm. ## ReconcileSchema held two sessions — #778's fix did not go far enough `reconcile_lake_env` opens its own session while the ctx session is attached to the same catalog, and the ctx session lives to the end of `exec_task::run_inner`, so it is dropped LAST and writes its earlier view back over the committed metadata. #778 fixed that in `LakeInit` and stopped there. The identical pattern was in `ReconcileSchema` — the task `lake_migrate`, `lake_maintain`, `train` AND `profile` all open with — so the schema reconcile never persisted on the task path for any kind. What it looked like: the deploy's tenant sweep reported `migrated` with the same 22 relations applied on every single run, never converging to `current`. The legacy arm hid it by reconciling in the dispatcher's own process, one session. Porting the test is what made it reachable. One caveat on both fixes: `open_lake_env` honours `ER_LAKE_CATALOG_SCHEMA` and the pod's `open_order_session` does not. Not a factor for a file catalog, but it means a pod's session ignores that key — worth knowing before a lake shares a metadata database. ## A failed reconcile recorded no tenant position The finish handler writes `tenant_schema_states` from the task's output doc, and a FAILING task publishes no output. So a breaking lake left the tenant's recorded position at whatever the last good sweep said — `current` — while the job correctly failed. The deploy report and the drift check read that table precisely so they need not open a lake, and they were being told a breaking tenant was fine. The legacy arm recorded this "whatever the outcome was", in as many words. The task path recorded it only on success. Now both: a `reconcile_schema` or `lake_init` failure records `breaking` for ERR_SCHEMA_BREAKING and `errored` otherwise, matching what `schema::tenant_state` derives. ## review.resolved had no emit site left It was emitted ONLY by the legacy arm, so the deletion left a catalogued event nothing fires. `pg_webhook_catalog.rs` caught it — the gate earning its keep, because a webhook that stops being sent is invisible from the inside. Ported into `settle_actions`, which already holds the receipt carrying the resolutions. Fourth settle consequence found this way, after the run report, the entity aggregate and `entity.write_back`. That gate also only scanned `lib.rs` and `dispatcher.rs`; the emit sites have MOVED to the executor and the control tasks, so it now scans those too. ## pg_migrate_tenants, the ninth port It passed `None` for the executor and relied on the arm. With the arm gone a dispatcher without an executor claims nothing, deliberately, so the sweep needs a real one. Two expectations changed, both deliberately: - The retype that makes phase 3's lake breaking is flushed with `DETACH lake`, because the reconcile now runs in another process and reads the catalog from disk rather than inheriting this one's view. - `error_class` is `data` where it was `internal`. The class changed with the classifier, not the behaviour: `internal` was `pg::FailureClass`'s UNCLASSIFIED DEFAULT, and the rules that moved to the executor boundary call a schema mismatch what it is. Terminality — what the assertion beside it is actually about — is unchanged, since `data` maps to `StageFailure` and is not retryable. ## One gate floor lowered `span_boundaries::the_wrapper_is_actually_used`: 9 → 3. Six of the nine blocking hops were the arm; the three left are `match_preview`, `resolve` and `blocking_estimate`, all on the HTTP read path. The test's own message asks for a deliberate lowering, and the floor still does its job — it stops the bare-`spawn_blocking` scan beside it from passing vacuously. `make check` green; the full 107-test er-server tier green against a real Postgres and DuckLake. Refs #645
…r task Steps 5 and 6 of #645. The statement decided retry in the same UPDATE that recorded the failure — a retryable class with attempts left went back to `queued` behind an exponential backoff, clearing the attempt's stamps — and that branch WAS the legacy in-process arm's retry. With the arm deleted it had no production caller left: on the task path a job reaches a terminal state through `job/update/settle.sql`, and retry is per attempt in `task_instance/update/{archive_try,insert_retry_try}.sql` with Airflow's budget arithmetic. So the branch goes and the statement becomes what its one surviving caller needs: `state = 'failed'`, `finished_at = now()`, the class and the detail. The `retryable` param goes with it, which drops `pg::FailureClass::retryable` — `fail_or_retry` was its ONLY caller, in the whole workspace. An `assert!` that `TransientIo` is the retryable one would have been decoration after this, so the four asserts are deleted rather than carried: nothing reads the method, so nothing could break it. `er_dag::TaskError::retryable` is the live verdict now, and it is a different type on a different path. `FailureClass` itself stays, and so does `classify`, for `dispatch_pg` — the injected-runner queue harness for `pg_dispatch`, `pg_profile` and `pg_webhook_deliver`. Its arm docs are rewritten, because each one asserted a retry consequence this type no longer has ("the ONLY class that retries, which is what makes the UI's 'transient failures retry automatically' true"). What it carries now is what a steward is TOLD, not what happens next. **The name overstates what the statement does and is kept anyway.** Renaming it renames the generated `job::update::fail_or_retry` and every caller with it; the `or_retry` half is contradicted in the doc comment instead. Statement names are not append-only here — only lint-rule codes are — so this is a judgement about blast radius, not a rule. `jobs.max_attempts` is the column that paid for it: every statement's RETURNING list still selects it and NONE of them consult it, the requeue branch having been its only reader. Its description said "Maximum attempts before the job fails", which is now false, so it says what it is. The column stays — dropping one is a breaking change the reconciler refuses, and `attempt` is still counted by `claim` and still spent by `resume`. That description change is why `openapi.json`, `schema.d.ts` and `Job.ts` move: it reaches the API contract. ## pg_job_retry.rs is pg_job_failure.rs The file name was the last thing in the tree asserting that a job retries. Its job-requeue phases are not ported, because what they asserted against is gone; `pg_task_instances.rs` Phase C already owns the successor behaviour in more detail than this ever did — the deterministic jitter, the lineage, the M → L OOM escalation, the exhausted budget. What is rewritten rather than deleted is the half that was always the point: a steward can see WHY a job failed. Two assertions are sharper than their predecessors on purpose: - the transient failure asserts `failed`, where it used to assert `queued`. That is the behaviour change, stated as such. - "it left the queue" now CLEARS `not_before` before asserting `claim` returns nothing. The old assertion held for the retry too — that row was merely behind a deadline — so as written it could not tell a terminal failure from a backed-off one. Reinstating the requeue branch now fails this test. The classification table stays, and its duplicate in `dags::tasks::engine_error_class` is left duplicated deliberately: two implementations, pinned by two tables, because a shared fixture would pass on the day they stopped agreeing. Both doc comments now say so and point at each other. `make check` green. Refs #645
…ispatcher Step 7 of #645, and the dispatcher's chart resources with it. ## D-ARGO's own revisit trigger fired "Revisit when a run ever becomes a genuine multi-pod DAG." It is one now, so the decision is amended rather than left to read as current — and the honest part is that its STRONGEST argument is void. "The DAG is inside the process", "no artifact to pass between pods", "Argo would have nothing to orchestrate": there is a graph now, there are edges, and the edges carry references. It stands on the two that survive. Two sources of truth for run state is still fatal, now about a richer table — `task_instances` carries the fingerprints a resume is checked against. And the retry policy got HARDER to express elsewhere, not easier: per-attempt budget with Airflow's arithmetic, deterministic jitter, per-kind base and cap, OOM class escalation, and a separate `launches` counter for infrastructure failures that ran no user code. The revisit trigger is restated, since the original is spent: dynamic fan-out inside a stage, which is the one thing the design refuses outright. D-JOBSPEC, D-PROGRESS, D-SIZING and D-TENANCY are amended per the plan's table. D-DISRUPT and D-SPILL are re-affirmed with their reasons stated rather than left silent — D-DISRUPT's `consolidateAfter` linger is now what makes a per-task pod cost ~1s instead of a cold node, so it is coupled to D-TASKJOB and must not be tuned for cost alone. New: D-TASKJOB, D-CHANNEL, D-FUSION, D-KUEUE. The plan named them and nothing defined them; each is derived from the design doc's own sections (§3.7, §6.2, §6.4, §7.3) rather than invented. ## One error had been copied to four places `architecture.md`, D-TENANCY's title clause, `infrastructure.md` §6's head paragraph and its §6.4 bullet each credited a session-scoped ADVISORY LOCK with one-writer-per-dataset. Three partial unique indexes on `jobs` do that. The advisory lock `pg::claim` takes serves the per-org COUNT cap, because a COUNT is not index-enforceable. It matters beyond pedantry in both directions: as written the invariant appeared to depend on a lock that can be absent while it still holds, and §6's head paragraph used "a dying pod releases it with no cleanup path" as one of three arguments FOR pod-per-run. Two of those three still argue for an ephemeral pod. That one never did. All four are corrected, and the common ancestor is named — the deleted Python `tenant_lock`. ## infrastructure.md §6 Amended per subsection: `pods/log` out and `events: list` in, Job per task attempt, TTL 300, progress through the attempt channel rather than a DSN, the ServiceAccount parameter realised as `er-runner`. The RBAC paragraph is read off `rbac-dispatcher.yaml` rather than off the ticket's summary of it, which omitted the `patch` verbs on both `jobs` and `pods`. Dropping `pods/log` is written up as a containment win and not just tidiness: it let the control plane read whatever a stage wrote to stderr, which is tenant data, and the old paragraph's warning that the read "must never become" a progress stream is now enforced by the API server instead of by prose. TTL 300 rather than the sketch's 3600 gets the arithmetic that makes it matter: a finished Job holds a `count/jobs.batch` slot against no work, and a seven-task run retains seven of them. §6 also opens with a dated banner saying the `server/src/erserver/*.py` paths through it are historical. They are NOT corrected here. Re-deriving every one is its own pass, and a half-updated map is worse than a clearly dated one. ## The dispatcher's chart resources `terminationGracePeriodSeconds` 300 -> 60, memory limit 3Gi -> 768Mi, requests 512Mi -> 256Mi. Both were justified ENTIRELY by the legacy arm — "a killed legacy run strands its row holding the dataset's writer lock", and "runs whole legacy pipelines in-process (DuckDB included)" — which is the evaporation the ticket predicted. What replaces the 300s is not optimism: planning is one transaction that rolls back to `queued` with `attempt` unchanged and zero task rows, the work itself is in Jobs that outlive the pod, and `Executor::adopt` re-stamps `owner_epoch` on both the job and the task_instance rows at startup — so the next dispatcher takes over what this one was driving instead of leaving it for `resume_job` and a human. What is left to drain is one pass of Postgres writes plus at worst one SES send and a webhook drain. The memory ceiling goes because this arm opens no lake at all: the reconcile moved onto the task path, and a control task is structurally barred from linking engine code. DuckDB is still linked into the shared multicall image, which is why the comment says so — nothing on this arm calls it. ## Two things found while doing it **The `ships` column in the generated observability surface is a substring grep.** `skills-check` decides whether an `er_obs::init::Role` ships as a workload with `grep -rqlF "$service" infra/k8s/charts`, so writing the words `dedupe_core` in a chart COMMENT — explaining what a control task may not link — flipped `Dedupe` from "no — local tool" to "yes" in a generated table, against `is_unattended`'s own `Dedupe => false`. Worked around by keeping engine crate names out of that file, with a comment saying why so the next person does not re-trip it. The detector is still wrong for anyone who legitimately needs the word, and that is worth its own change rather than a drive-by here. **`CLAUDE.md` and `agent-skills.md` are regenerated**, not hand-edited. The rebase replayed this branch's older copies of their generated blocks over `main`'s `a241585b`, which had set `claim-ticket`'s `disable-model-invocation: false` and so dropped the "(user-invoked only)" tail from the derived rows. The frontmatter arrived correct and the tables did not, which is exactly the drift the byte-comparison exists to catch. `make check` green. Refs #645
athvin
force-pushed
the
issue/645-delete-legacy-dispatch-arm
branch
from
November 7, 2026 21:16
a86da2f to
461d67a
Compare
athvin
pushed a commit
that referenced
this pull request
Nov 7, 2026
…e work Found by USING the ledger rather than reading it: #809's was the first one ever closed, and the #756 sweep it recorded fitted neither annotation. `n/a` was false (the work was real) and `blocked` was false (nothing blocked it — another ticket owned it). It got `n/a` with the reason spelled out, which blurred the distinction the whole mechanism rests on: an empty box means exactly one thing, and that is only true while every other outcome has somewhere else to go. So there are three annotations now, and the asymmetry is the design: n/a — <why> ticks the item does not apply deferred — #<ticket> ticks real work, owned by a filed ticket blocked — <why> EMPTY could not be established; goes in the report `deferred` is the only one with a syntactic requirement, and it needs one: it TICKS the box, so a deferral naming no ticket would be the way to retire an item into nothing — strictly worse than the unticked box it replaces. `pr_ledger_scan` therefore counts them, and `pr-ledger-audit.sh` reports `LOOSE-DEFER (k)` separately from `OPEN (k)` because the remedy differs: file the ticket, do not do the work. Making that checkable needed the scan to group each box with its CONTINUATION LINES, since the annotation usually lands on a wrapped line — a per-line test would see the tick and the ticket separately and could not relate them. The regrouped scan reproduces #809's real ledger exactly (12 boxes, 0 unticked, 0 loose, and its one ticked box containing the word "deferred" passes because it names #810). The self-test earned its place twice here. It caught that adding a fifth field to the scan broke an assertion through a short `read` folding the trailing fields into one variable — so every caller now reads all five, and the function doc says why. Also corrects what is now false everywhere it was stated: `pull request contract` IS a required context as of today. The order that made it safe — report on real PRs, observe it failing, confirm no open PR would be blocked, then append — is recorded in ci-and-supply-chain as the reusable part, with the two mechanics that cost care: the endpoint REPLACES the context list, and `mergeStateStatus` cannot tell you what blocks a PR (both open ones read BLOCKED straight after the PATCH, neither by the new context).
9 tasks done
athvin
added a commit
that referenced
this pull request
Nov 7, 2026
…e work * wip: claim #810 — a deferred annotation for the ledger * feat(ci): a `deferred` ledger annotation, enforced so it cannot retire work Found by USING the ledger rather than reading it: #809's was the first one ever closed, and the #756 sweep it recorded fitted neither annotation. `n/a` was false (the work was real) and `blocked` was false (nothing blocked it — another ticket owned it). It got `n/a` with the reason spelled out, which blurred the distinction the whole mechanism rests on: an empty box means exactly one thing, and that is only true while every other outcome has somewhere else to go. So there are three annotations now, and the asymmetry is the design: n/a — <why> ticks the item does not apply deferred — #<ticket> ticks real work, owned by a filed ticket blocked — <why> EMPTY could not be established; goes in the report `deferred` is the only one with a syntactic requirement, and it needs one: it TICKS the box, so a deferral naming no ticket would be the way to retire an item into nothing — strictly worse than the unticked box it replaces. `pr_ledger_scan` therefore counts them, and `pr-ledger-audit.sh` reports `LOOSE-DEFER (k)` separately from `OPEN (k)` because the remedy differs: file the ticket, do not do the work. Making that checkable needed the scan to group each box with its CONTINUATION LINES, since the annotation usually lands on a wrapped line — a per-line test would see the tick and the ticket separately and could not relate them. The regrouped scan reproduces #809's real ledger exactly (12 boxes, 0 unticked, 0 loose, and its one ticked box containing the word "deferred" passes because it names #810). The self-test earned its place twice here. It caught that adding a fifth field to the scan broke an assertion through a short `read` folding the trailing fields into one variable — so every caller now reads all five, and the function doc says why. Also corrects what is now false everywhere it was stated: `pull request contract` IS a required context as of today. The order that made it safe — report on real PRs, observe it failing, confirm no open PR would be blocked, then append — is recorded in ci-and-supply-chain as the reusable part, with the two mechanics that cost care: the endpoint REPLACES the context list, and `mergeStateStatus` cannot tell you what blocks a PR (both open ones read BLOCKED straight after the PATCH, neither by the new context). * fix(skills): move the contract detail into a reference, under the 500-line cap `agent skills (lint + drift)` went red on this PR with `ci-and-supply-chain: SKILL.md body is 508 lines (max 500)` — my section had pushed it past the authoring cap. The cap is the economy rule: a SKILL.md is the routing layer, and detail belongs in `references/`. So the detail moves to `references/pr-contract.md` — what the check asserts and what it deliberately does not, the exemption table, the promotion order, and the rollup finding — and SKILL.md keeps a 23-line summary pointing at it. Body is 460 lines now. Every `references/*.md` must be linked from SKILL.md in the exact `](references/x.md)` form or the same gate errors on an unreachable reference, so the pointer is load-bearing rather than courtesy. Worth recording why this reached CI at all: I ran `scripts/skills-check.sh regen`, saw "generated references are current", and took it as the gate. Regen is one stage — it does not lint. The gate is `make skills-check`, which runs the regression test and then `all`. --------- Co-authored-by: bmoore813 <[email protected]>
This was referenced Nov 7, 2026
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.
Closes #645
What
Phase 4: deletes the dispatcher's legacy in-process arm.
dispatcher.rs2,616 → 894 lines,reporter.rsdeleted whole;dispatch_oncenow claims and plans and nothing else. Also retires the per-kind allowlist,ER_DISPATCH_IN_PROCESS, andfail_or_retry.sql's retry branch.Why
Every deployed kind already took the executor path (
deploy.ymllisted all eleven inDAG_KINDS), so the arm was dead weight that still owned three of the four things a settle emits — which is why deleting it surfaced eight silent defects in code that was live in dev and prod.Proof
make checkgreen.make check-e2egreen — 107 passed, 0 failed against real Postgres + DuckLake, which is the tier that matters here because all ten ported test files are behindER_TEST_PG_DSNandmake checkexecutes none of them. Frontend lint/typecheck/format green.make check-kindgreen on a real cluster: all six phases, including the seven-pod pipeline and a blue/green cutover mid-attempt.Risk & rollback
Risk: this removes the only fallback execution path, so a kind the DAG registry cannot parse is now refused terminally at planning rather than routed elsewhere. Rollback:
git revert -m 1 <merge-sha>.Post-merge ledger
Closed by: agent · session
94d0d97f-5484-4656-b727-bbe916f0aa93onbrians-MacBook-Pro· 2026-11-07T21:49:01Zmainis green with this change on it — merge70f31c54;rust,frontend,infraanddevcontainerall success on that SHA, andgit merge-base --is-ancestor 70f31c54 origin/mainconfirms it is onmain.imagesbuilt — run42416716191success, publishingcontainerimage.digest sha256:7ec82160…for70f31c54.deployconverged — verified against the livecinamespace oner-dev, not by the workflow conclusion:*
er-dispatcherandweb-api-greenboth runer-api@sha256:7ec821606434…, the digestimagesrun42416716191published for70f31c54. Content-addressed, so the digest is this code.*
ready=true,restarts=0, and the process emitted"the dispatcher is up"(er_server::dispatcher, 21:43:20Z) — which rules out the failure this box exists for: a rejected config crashlooping the new pod while the old one keeps serving behind a green deploy.* Zero
the executor is disabledwarnings, so the executor is configured. Load-bearing after this change: a dispatcher with no executor now claims nothing at all rather than falling through to the deleted arm.* Zero occurrences of
ER_DISPATCH_IN_PROCESS,in-process, orinprocin the boot log.* Scope, stated honestly: the queue is idle — no job has been enqueued since the deploy — so the settle path is unexercised in dev. It is covered by
make check-kind(six phases, real pods, this branch) and the 107-test Postgres tier. No job was enqueued to manufacture evidence.* Incidental finding:
PlatformReadOnlyis not iner-dev's EKS access entries (onlyAdministratorAccess,PlatformAdmin,er-ci-deploy-dev,er-dev-node,er-dev-builder), so a read-only verification like this one needser-platform. Worth noting wherever the profile-to-permission-set mapping is documented.deploygreen on theworkflow_runpath;kind's nightly leg anddriftlast ran green on59d3f60e(schedule) and have not yet fired on this change, which is "not yet run", not red. Onedeployrun on70f31c54did fail at 21:37:06 and is explained below, not a defect.COMPLETEDat 2026-11-07T21:37:05Z by the merge automation, not by hand.skills-check'sshipscolumn is a substring grep), deploy.yml: a mixed infra/k8s + image-input commit always produces one spurious red deploy #817 (deploy.yml's mixed-commit spurious red).kind-probe-never-passed), and theskills-checksubstring trap inskills-check-ships-column-substring-grep.A
deployrun on the merge SHA failed, and it is a guard workingdeploy.ymlhas two triggers:workflow_runonimages, andpushonmainfiltered toinfra/k8s/**. This commit touches bothinfra/k8s/**and image inputs (rust/,entities/), so the platform-only push path fired at 21:37:06 — beforeimageshad built — found no image tagged70f31c54, and refused to roll the newest ECR digest because real code paths changed between it and this SHA:That is exactly the "merged green is not running" protection, and it was superseded by the
workflow_rundeploy at 21:41:45 onceimagessucceeded. Filed as #817. Worth fixing anyway: a mixed commit will always produce one spurious reddeployonmain, and its own notice line ("this commit touched onlyinfra/k8s, so nothing was built") is false for that case.Specific to this change
check-kindNOT promoted to a required check — and the acceptance criterion as worded cannot be met. Two genuine classifier rows were broken and the probe stayed green both times (exit 0, six phases, zero FAIL lines), each verified running the mutated image byimageID, not by tag:ApplyRecord(record)→TimedOut: unreachable on happy paths. Clause (a) returns first —if row.finish_landed { return RecordEvidence }— because the pod reportsfinishthrough the attempt channel, so the watch never parses the record.RowState::Canceling→Wait: shadowed byexecutor.rs'scancel_sweep(), which callstask_instance::update::settle_canceleddirectly (744–776, 1126, 1205). The job still reachedcanceledand phase 3 passed.classify::terminalis a fallback layer whose rows are shadowed by the primary mechanisms, so breaking the classifier does not move the probe. Baselinemake check-kindis green on this branch (all six phases), which is the evidence that matters for this PR. Filed as kind probe: cover the classifier's fallback rows (ApplyRecord, Canceling) with a phase that reaches them #814 to restate the criterion against something the probe actually depends on.the kind probe does not deploy the image it just built.
kind_env.shpins the mutable tagIMAGE_TAG=kindand the chart sets noimagePullPolicy, so Kubernetes defaults toIfNotPresentand a node holding that tag keeps the stale layer. Measured: registry served864efd5e…while the node ranb7b359c38e01b; the event log says "already present on machine" and the pod reportedcolumn dataset_id is in the live store but not declaredfor 15 tables. CI is immune (fresh cluster per run); local runs are not. Needs a content-addressed tag or an explicitkind load— kind probe deploys a stale image: mutable :kind tag + default IfNotPresent #815:skills-check'sshipscolumn is a substring grep (grep -rqlF "$service" infra/k8s/charts), so naming an engine crate in a chart comment flipped theDeduperole from "local tool" to "deployed", contradictingis_unattended's ownDedupe => false. Worked around by keeping crate names out ofvalues.yaml, with a comment saying why; the detector is still wrong — skills-check: the observability 'ships' column is a substring grep over the charts #816:the dispatcher's reduced resources are unmeasured. Grace 300s → 60s and memory 3Gi → 768Mi were re-justified by reasoning (planning is one transaction;
Executor::adoptre-stampsowner_epoch), not by observation under load — tracked in kind probe: cover the classifier's fallback rows (ApplyRecord, Canceling) with a phase that reaches them #814's sibling work; raise separately if it needs its own card:Context — plan, discoveries, measurements, files
Discoveries
Eight defects, every one silent, every one found by porting a test onto the path the product actually runs.
profile'sreconcile_schemaarm namedlake_maintain,lake_migrate,train— notprofileprofilejob failed at its first task, dev and prodtests/dag_task_coverage.rsto close the classrun_report_messageshad one caller: the legacy armApplyStagedread its payloads from aparamskey nothing wrotesucceededjobpair_label::read::allpassed an org idtrainestimatedmwith no labels, recordingm_from_labels: 0review.resolvedwas emitted only by the armsettle_actionsReconcileSchemaheld two sessions on one catalog (#778's bug, second instance)reconcile_schema/lake_initpublished no output doccurrent, so the drift check was told it was fineTwo rows are the same class — four instances in total, three in #769 and
pair_labelthe fourth. The shape is always: scope is a&str, an org id is a valid&str, and the wrong one returns an empty set rather than an error.pair_labelwas silent because the surrounding code deliberately degrades a label read failure to EM-only, and zero rows is indistinguishable from "this tenant has no labels".The last two were hidden by the arm doing the work in the dispatcher's own process and recording the outcome "whatever it was". The task path recorded only on success.
Plan
Seven steps, all done.
run_jobthat no longer exists.dispatch_claimed,run_job,dispatch_once_with, the async kind arms,reporter.rswhole.ER_DISPATCH_IN_PROCESSand its prose.fail_or_retry.sqlloses its retry branch and becomes a terminal record.pg_attempt_reporter.rsdeleted,pg_job_retry.rsrewritten.Ordering was the point. The arm's coverage moved before the arm went, across nine test files (
pg_mass_update,pg_protect_master,pg_record_overlays,pg_train,pg_entity_events,pg_approval,pg_migrate_tenants, pluspg_drain_dispatcherandpg_provisionwhich landed onmainwith #770 and #778). Their assertions are untouched — they were always about outcomes, never about which arm produced them.Two items on the ticket's deletion list were refused, each after reading the tree:
mark.sqlstays.plan.sqlcommitsdispatching → runningunderWHERE state = 'dispatching', so it cannot stand in formark(job, "running")or the cancel route'scanceled. Nine non-legacy callers.pg::FailureClass::classifystays, fordispatch_pg— the injected-runner queue harness behindpg_dispatch,pg_profileandpg_webhook_deliver, and the only coverage ofpg::claim's one-active-per-dataset enforcement at that level. What did go isFailureClass::retryable, whose only caller in the workspace was the retry branch — so its four asserts went too rather than being kept as decoration.The ticket's ordering note ("deleting
executor.dagKindsmust not land before the arm") reads backwards against its own rationale; the allowlist went first.Behaviour changes
Ok(false)and idle, rather than marking a rowrunningnothing can advance. Decide how local development runs jobs once Phase 4 deletes the legacy arm #638's decision made executable: every host, so everymake run, does API-only work.cancelingpath.AppState.executor_kindswas a second consumer of the allowlist; a cancel now holds the dataset slot until its pods are provably gone.pg_job_retry.rs→pg_job_failure.rs. The name was the last thing in the tree asserting that a job retries.jobs.max_attemptsis now selected by everyjobsstatement's RETURNING list and consulted by none — its description says so, which is why this reachesopenapi.jsonandschema.d.ts.queued, andExecutor::adoptre-stampsowner_epochon both the job and its task rows, so the next dispatcher takes over rather than leaving it for an operator.span_boundaries::the_wrapper_is_actually_used, 9 → 3. Six of the nine blocking hops were the arm; the three left are on the HTTP read path. The test's own message asks for a deliberate lowering.Docs
infrastructure-decisions.mdis at revision 6. D-ARGO's own recorded revisit trigger fired — "a run ever becomes a genuine multi-pod DAG" — so it is amended rather than left reading as current: its strongest argument ("the DAG is inside the process"; "Argo would have nothing to orchestrate") is void, and the decision stands on the two that survive — two-sources-of-truth, and a retry policy that got richer rather than going away. D-JOBSPEC, D-PROGRESS, D-SIZING, D-TENANCY amended; D-DISRUPT and D-SPILL re-affirmed with their reasons stated; D-TASKJOB, D-CHANNEL, D-FUSION, D-KUEUE added, each derived from the design doc's own sections rather than invented.infrastructure.md§6 amended per subsection:pods/logout andevents: listin (read offrbac-dispatcher.yaml, which carriespatchverbs the ticket's summary omitted), Job per task attempt, TTL 300 with thecount/jobs.batcharithmetic that makes it matter, progress through the attempt channel rather than a DSN, and the ServiceAccount parameter realised aser-runner.One error had been copied to four places, all from the deleted Python
tenant_lock:architecture.md, D-TENANCY's title clause, andinfrastructure.md§6's head paragraph and §6.4 bullet each credited a session-scoped advisory lock with one-writer-per-dataset. Three partial unique indexes onjobsdo that; the advisory lock serves the per-org count cap, because aCOUNTis not index-enforceable. It matters because as written the invariant appeared to depend on a lock that can be absent while it still holds — and §6's head paragraph used "a dying pod releases it with no cleanup path" as an argument for pod-per-run..claude/skills/er-server-control-plane/SKILL.mdsaid the dispatcher runs the kind "in-process" and that "There are no per-run Kubernetes jobs" — every clause false since Phase 3, and a skill is worse than a stale doc when wrong, because it is read before the code.Measurements
make check-e2e: 107 passed, 0 failed, 2 ignored —ER_TEST_PG_DSNon a local Postgres.make check-kind: exit 0, six phases, zero FAIL lines, on theer-kindcluster.dispatcher.rs: 2,616 → 894 lines (git show origin/main:… | wc -lvswc -l).reporter.rs: 545 → 0.Files
59 files, +1,478/−3,351 at the time of writing.