Repository navigation
fix(server): restore the entity.* aggregate the DAG path dropped - #629
Merged
Merged
Conversation
A regression I introduced in #498 and did not notice. Putting `run_all_full` on the executor allowlist moved pipeline runs off the legacy arm. The legacy arm's tail did two things once a run settled: dispatcher.rs emit_entity_aggregates(client, &completed, &entity_counts) dispatcher.rs run_report_messages(..., &entity_counts) The DAG path's settle did one: executor.rs webhook::emit_job_event(&self.client, &settled) `emit_job_event` sends the `job.*` event for the outcome. It does NOT send the `entity.*` aggregates, and `emit_entity_aggregates` had exactly one caller — the arm the pipeline kinds had just stopped using. So since #498 deployed, every pipeline run on the ci namespace has emitted no `entity.created`, `entity.merged` or `entity.member_added` aggregate, and the emailed run report has carried no entity counts. A subscriber keyed on `entity.*` simply stopped hearing, with nothing reporting that. ## Why the counts have to ride in the task output Counting is a lake query; emitting is a Postgres write. No single process does both any more, and the legacy code's own comment says why: Read HERE because this is the half that holds the lake session; the half that can emit holds the Postgres client. In `run_job` those were two halves of one function. Split across a pod boundary they are a pod and the control plane — and the control plane cannot open a lake, which `lib.rs`'s clear-closure probe already states outright ("THIS process cannot open a lake (§3.5 draws that line at the lake, and the control plane is on the wrong side of it)"). So `finish` counts — it is the last task of the run and the last place a lake session exists — and publishes into `FinishReport`. Settle reads the counts off the row map the readiness pass already loaded, and emits. Best-effort at both ends, as the legacy arm was: a count that cannot be read must not fail a teardown whose run is already written. Absent for every kind with no `finish` task, which is correct rather than a gap: `lake_maintain`, `train` and `profile` reconcile no entities, so there is nothing to announce. §10 says as much — "Entity aggregates fire at settle". ## Tests The boundary is JSON and nothing type-checks `output["doc"]["entity_counts"]` — it is `Value::get` on strings, so a rename on either side would compile and then silently emit nothing, which is this exact bug a second time. Three tests pin it: the round trip through `Plan(FinishReport)` using the settle path's literal key chain, an empty count set reading as "nothing to announce" rather than as a missing reading, and an output written BEFORE the field existed still deserializing — `#[serde(default)]` is what keeps a `{"settled": "closed"}` row already in the ledger readable, and `pg_task_instances.rs` writes exactly that shape. `make check` green. Co-Authored-By: Claude Fable 5 <[email protected]>
This was referenced Nov 6, 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.
A regression I introduced in #498 and did not notice. I found it while implementing the "where does
run_job's tail land" decision I had deferred — which is itself the argument for not having deferred it.What broke
Putting
run_all_fullon the executor allowlist moved pipeline runs off the legacy arm. That arm's tail did two things once a run settled:The DAG path's settle did one:
emit_job_eventsends thejob.*event for the outcome. It does not send theentity.*aggregates — andemit_entity_aggregateshad exactly one caller, the arm the pipeline kinds had just stopped using.So since #498 deployed, every pipeline run on the
cinamespace has emitted noentity.created,entity.mergedorentity.member_addedaggregate, and the emailed run report has carried no entity counts. A subscriber keyed onentity.*simply stopped hearing, with nothing reporting that. Dev-only, since prod isn't deployed.Why the counts have to ride in the task output
Counting is a lake query; emitting is a Postgres write. No single process does both any more — and the legacy code's own comment says exactly why:
In
run_jobthose were two halves of one function. Split across a pod boundary they're a pod and the control plane, and the control plane cannot open a lake — whichlib.rs's clear-closure probe already states outright: "THIS process cannot open a lake (§3.5 draws that line at the lake, and the control plane is on the wrong side of it)".So
finishcounts — it's the last task of the run and the last place a lake session exists — and publishes intoFinishReport. Settle emits, reading the counts off the row map the readiness pass already loaded, so no extra query. Best-effort at both ends exactly as the legacy arm was: a count that can't be read must not fail a teardown whose run is already written.Absent for every kind with no
finishtask, which is correct rather than a gap —lake_maintain,trainandprofilereconcile no entities, so there's nothing to announce. §10 says as much: "Entity aggregates fire at settle."Tests
The boundary is JSON, and nothing type-checks
output["doc"]["entity_counts"]— it'sValue::geton strings, so a rename on either side would compile and then silently emit nothing, which is this exact bug a second time. Three tests pin it:Plan(FinishReport)using the settle path's literal key chain;finishis a teardown onAllTerminal, so it also runs after a failedinit);#[serde(default)]is what keeps a{"settled": "closed"}row already in the ledger readable, andpg_task_instances.rswrites exactly that shape.make checkgreen.🤖 Generated with Claude Code