Skip to content

fix(ingest): pin queued jobs to immutable deliveries - #1006

Merged
athvin merged 3 commits into
mainfrom
issue/1002-immutable-deliveries
Nov 9, 2026
Merged

athvin merged 3 commits into
mainfrom
issue/1002-immutable-deliveries

Conversation

@athvin

@athvin athvin commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Closes #1002

Claimed by agent — 2026-11-09T03:57:48Z, session Codex:01a1be1b-0c92-7703-a4c2-25cb2c999baa on Mac.lan. This open draft PR is the claim.

Post-merge is part of this pull request. The ledger below records whether
the follow-up work actually happened. /land-pr closes it.

What

Pin accepted CSV deliveries to immutable files and their queued ingestion jobs. A later delivery cannot replace an earlier job’s input; retrying ingestion resets that run’s rows and receipts before replay.

Why

Two accepted deliveries currently overwrite the same source.csv, while both jobs resolve the latest file. This can lose incremental Salesforce data after its cursor advances, and prevents trustworthy provenance for E9 previews (#993). Selected as a prerequisite of the highest-priority active epic #514.

Proof

make check and make check-e2e passed on 004b7c0bdf46b17daa851c1eca0123a6e7307a00, including real Postgres/DuckLake ordering, publication recovery, scope/mapping/integrity checks and both control-task and ingest retries. The overwrite and duplicate-ingest regressions were each observed failing before their fixes.

Fresh-context house review found no instrumentation, tier or reuse candidates. CI run passed; all 15 required contexts were satisfied on the exact head, detect succeeded, and no merge bus was active.

Risk & rollback

Accepted files remain available for replay. Old jobs without immutable pins refuse and need the original input re-delivered; operator runs without a delivery identity retain the legacy drop-directory convention. Drain pinned jobs or stop dispatch before rolling back to an older binary.

Post-merge ledger

Closed by: agent · session Codex:01a1be1b-0c92-7703-a4c2-25cb2c999baa on Mac · 2026-11-09T06:08:58Z

Specific to this change

Context — plan, discoveries, measurements, files

Plan

  • Reproduce the A-then-B overwrite using the existing delivery/run-context test harness, and observe the regression failing before the fix.
  • Add a shared delivery publication/resolution module with immutable paths, a versioned manifest, byte integrity and source-mapping checks. Paths derive only from validated source/delivery identities within the dataset drop root.
  • Use it from upload, push, S3 and Salesforce publication; queue the exact delivery reference only after publication is durable. Preserve recoverable files on enqueue failure.
  • Resolve only the declared delivery for pinned jobs. Refuse missing/corrupt/mismapped pins; define explicit behavior for operator run-all and old unpinned jobs. Preserve retry identity across attempts.
  • Extend real Postgres and lake tests to prove two queued deliveries, extraction ordering, retries and dataset isolation. Update the ingestion design/runbook where semantics change.
  • Run make check, the full PG/lake tier and fresh-context house review.
  • Finish exact-head CI, merge, main gates and the post-merge ledger.

Files expected

er-cli/src/lib.rs (wire the declared §9.1 ingest pre-image), er-server/src/{delivery,lib,runctx,s3_ingest}.rs, relevant dags/{tasks,control,plans} paths, existing import/extract/run-context tests, and engine/control-plane references. Use entity declarations for any persistence change if investigation shows one is needed.

Discoveries

Post-merge watch starts at 2026-11-09T04:38:56Z (30-minute minimum ends 05:08:56Z); it also requires completed main/image checks and actual repaired deployment evidence.

The §9.1 pre-image SQL was already declared/generated but had no caller. The real stage retry appended A twice. stage_ingest now atomically removes this run’s rows/receipts before replay, while #957 (landed via #1003 and included by rebase) owns atomic per-delivery appends. Retry logs: /tmp/immutable-ingest-retry-{red,green}.log.

The source mapping fingerprint must retain IndexMap column order because ingestion hashes values in that order. Legacy queued delivery ids cannot prove which bytes they accepted; they now refuse rather than silently reading latest. The separate Docker runtime repair is owned by PR #1005 and still blocks the deployment ledger on #999.

Measurements

Files

@athvin
athvin force-pushed the issue/1002-immutable-deliveries branch from bee181d to 4960480 Compare November 9, 2026 04:15
@athvin
athvin marked this pull request as ready for review November 9, 2026 04:35
@athvin
athvin merged commit e694f96 into main Nov 9, 2026
46 checks passed
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.

Pin accepted deliveries to immutable inputs before queued ingestion

2 participants