Skip to content

apply_corrections applies nothing on the executor path and reports success #760

Closed

Description

@athvin

apply_corrections applies nothing on the executor path, and reports success.

What happens

ApplyStaged reads the actions it is meant to apply from the work order:

// tasks.rs:642
// The actions themselves ride in the order's params: `drain_actions`
// snapshotted the ids, and the control plane put the payloads where a
// pod can read them without a database credential.
let pending = staged_actions(ctx)?;

staged_actions reads ctx.order.params["staged_actions"] and returns an empty
vector when the key is absent:

// tasks.rs:712
let Some(items) = ctx.order.params.get("staged_actions").and_then(Value::as_array)
else { return Ok(Vec::new()); };

Nothing in the tree writes that key. grep -rn staged_actions crates/ --include='*.rs'
returns three hits: the call, the function, and the .get() inside it.
compose_input (executor.rs:1461) builds the order as
json!({ "pins": pins, "params": job.params }) — the job's params verbatim.

So the pass runs to completion having applied nothing, and settles succeeded.
Observed end to end against a real Postgres and DuckLake, with two pending
actions staged:

drain_actions  succeeded  {"doc":{"action_ids":["01a1b408-…b2dd","01a1b408-…7fdb"]}}
init           succeeded  {"doc":{"mode":"correction_pass",…}}
apply_staged   succeeded  {"doc":{"applied":[],"labels":[],"resolutions":[]}}
settle_actions succeeded  {"doc":{"applied":0}}
finish         succeeded  {"doc":{"settled":"closed"}}

pending_count is still 2 afterwards. The actions stay pending forever: nothing
marks them, so each pass re-drains and re-discards them.

Why it is not visible

  • The job succeeds, so no alert, no failed row, no webhook anomaly.
  • deploy.yml lists every kind in DAG_KINDS, so dev and production have been
    on this path. The legacy in-process arm (dispatcher::drain_and_correct)
    still works and is what every test exercises, which is why the tier is green.
  • Everything that stages a steward action feeds it: the assertion, unmerge and
    bulk-resolve endpoints with apply_now, and the approval sweep, which
    enqueues apply_corrections with {"skip_ingest": true}.

So steward decisions — assertions, merges, unmerges, bulk resolves — are being
silently discarded in dev and production.

Blocks #645

Phase 4 deletes the legacy arm, which is the only working implementation of a
correction pass. It cannot land until this path works.

Suggested fix

Carry the payloads along the DAG's typed edge rather than through the untyped
params channel. DrainActions already reads full PendingAction { id, action, created_by } rows and throws away everything but the id:

  • widen plans::DrainedActions to carry the payloads,
  • wire d.then::<ApplyStaged>((plan, drained)) so drain_actions is a DIRECT
    upstream — compose_input pins direct upstreams only, which is why the data
    cannot reach it today,
  • ApplyStaged::Input = (Plan<RunPlan>, Plan<DrainedActions>), pinning index 1,
  • staged_actions reads the pin instead of params.

That keeps the pod credential-free, which is what the original comment was
after, and makes the dependency explicit instead of implicit. The params
wording in that comment becomes wrong and should go with it.

Changing DrainedActions changes the apply_corrections structural
fingerprint, so an in-flight job planned against the old graph is refused by
plan.sql's fingerprint guard with "clear into a new job" — the intended
behaviour, not a migration.

Acceptance

A pg-tier test that stages actions, runs a real apply_corrections through the
executor with FakePodApi, and asserts pending_count reaches 0 and the
actions are marked applied — i.e. the assertions pg_drain_dispatcher.rs
already makes against the legacy arm, made against the task path.

Found while porting pg_drain_dispatcher.rs off the legacy arm for #645.
A separate scope defect found in the same pass is already fixed in that
branch (84a83192): three control tasks were passing order.org_id to
dataset-scoped reads, which is why drain_actions itself returned [] before
that commit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    mvp

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions