Repository navigation
feat(api): bulk export — an async, snapshot-pinned, tenant-scoped artifact (#1230) - #1239
Merged
Merged
Conversation
…d three routes (#1230) POST …/exports pins a snapshot and enqueues kind export; one read-only pod task pages the declared golden or duplicates reads at that snapshot into one CSV or JSON Lines artifact beside the lake (written .partial, then renamed; a 1M-row ceiling fails loudly). GET …/exports/{id} reads the job back; …/download streams the file behind the org guard (409 until succeeded, 410 after seven days). No presigned URL: the API pod has no S3 grant, and an S3-backed lake is refused at enqueue. A File envelope class documents the download; MCP never offers it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… lake is zero rows (#1230) export_write.rs: golden CSV across a page boundary with one header, at R after R+1 committed; golden JSONL at the latest; duplicates JSONL; a lake no run has finished in exports zero rows rather than failing (found by this test); the row ceiling fails by name and leaves no file or .partial. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…uter (#1230) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…l files (#1230) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
|
The marketing preview was removed because this PR is closed or merged. |
…fied (#1230) Co-Authored-By: Claude Opus 5.5 <[email protected]>
… developer reference (#1230) Co-Authored-By: Claude Opus 5.5 <[email protected]>
athvin
marked this pull request as ready for review
November 25, 2026 19:19
athvin
temporarily deployed
to
marketing-preview
November 25, 2026 19:24 — with
GitHub Actions
Inactive
7 tasks done
This branch was previously deployed
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 #1230
What
Bulk export of a dataset's results at one pinned snapshot:
POST …/exports(steward+) takes{kind: golden|duplicates, format: csv|jsonl, snapshot?}. It pins the snapshot through E11.2 — Run-to-snapshot identity, explicit snapshot reads #1229'spin_requested, enqueues job kindexport, auditsexport.create, and returns{export_id, snapshot, state}.GET …/exports/{id}(viewer+) returns the job read back: state, kind, format, snapshot, rows, error_class,expires_at.GET …/exports/{id}/download(viewer+) streams the artifact with its media type andContent-Disposition. It is a 409 until the export succeeds and a 410 after seven days or once swept.export_idis the job id. No new table: the job row already holds state, params, error and timestamps.exportis read-only and has noreconcile_schema. It pages the declared, snapshot-pinned golden and duplicates reads, so it adds no new SQL. It writes<lake>/exports/<id>.<ext>beside the data directory, never inside it, where DuckLake's orphan cleanup would delete it. The file is written.partialand then renamed. A 1M-row ceiling fails loudly, never truncates.lake_maintainsweeps expired artifacts and.partialfiles dead for a day.fileenvelope class documents the download astext/csv|application/x-ndjson. MCP never offers the download: an agent gets the status, not a million rows.Why
#1230, part of #521. A customer needs the whole result set, consistent with one run, without paging the API.
Proof
make check: 1,189 passed, 0 failed.er-server+er-cli --testsagainst Postgres withDEDUPE_E2E_DUCKLAKE=1: 497 passed.make frontend: 964 passed.The gates caught three things on the way, each fixed in its own commit:
every_pod_task_has_an_explicit_route: an export routes embedded, not DuckFleet-qualified;/docs/apigrouping test: exports belong under Results;gates.mdand developer reference.Every test added here was observed failing first.
export_write.rs(real lake), page size 2:Catalog Error;.partial.pg_exports.rs(router, Postgres and a lake):exportsunits: request parsing (unknown fields refused), the path beside the data directory, an S3 lake refused, a path-shaped id refused, and the sweep removing only the expired.a_file_download_is_never_offered(er-mcp), and the envelope classifier'sFilecase.pg_exports:/datasets/second/exports/{id}was not 404pg_exports: 410 expectedpg_exports: 403 expectedRisk & rollback
Additive: three new routes and one new job kind.
lake_maintaingains a file sweep of<lake>/exports/only. The one shared-type change isDatasetDetail: Clone. Rollback:git revert <merge-sha>. Export jobs already queued would then fail to parse their kind, which is a terminalconfigfailure.Post-merge ledger
Closed by: agent · session
Claude Code:d1e3b2dc-3174-4091-9c30-c08fc4820306onMac· 2026-11-25T19:37:01Zmainis green with this change on it: mergec185fbf9. Push runs rust 45684809459 (the full suite, after the PR head's legitimate pass-key reuse from a green run of the identical Rust tree), frontend 45684809425, images 45684809345, infra, devcontainer and marketing preview: all success.images: run 45684809345 succeeded.deployconverged. Process proof was read once the AWS session was restored (2026-11-26). The live colour in dev (ci/web-api-green-5d5f9c8844-88dxb, logged"er-server listening"at 01:36:40Z) and prod (app/web-api-blue-7544598cbb-8rjth, at 01:51:39Z) both runer-api@sha256:5d993716…, built frombae09b2e, which contains this merge (git merge-base --is-ancestor c185fbf9 bae09b2eholds). (Earlier note: run 45685779516 (DEPLOY_SHA: c185fbf9) succeeded, but the AWS SSO session (er-platform/er-prodadmin) has been expired since 12:10Z, so the live pods'er-server listeningline could not be read. To be ticked afteraws sso login.)deployis green.driftandkindwere already red on schedule before feat(api): typed response structs, batch 3 — reviews+merges (#1193) #1202.api-contractskill (thefileenvelope class) ander-engine-ops's orchestration reference (theexportkind, and why it has noreconcile_schema).Specific to this change
Context — plan, discoveries, measurements, files
Plan
Design change from the ticket: an authenticated streamed download, not a presigned URL. Probed 2026-11-25:
envs/*/pod_identity.tf: SES, plus Bedrock in dev);tenant-runners.json), and every other tenant's lake is on EFS, which the API pod mounts;duckfleet_artifacts.rsalready states the policy "signed URLs never travel in query responses".Presigning would need a new er-api read grant across tenant prefixes, a cross-tenant blast radius, to serve a URL the guard cannot see. Streaming through
er-serverkeeps the org guard on every byte.COPY … TOstatements underentities/golden_record/read/andentities/acct_golden_record/read/(and duplicate membership), takingsnapshotand a target path. Hand-written lake SQL is forbidden in er-server, andread/accepts COPY.JobKind::Export, shaped likeprofile: one pod task (ExportResults) writing<lake root>/exports/<export_id>.<parquet|csv>, params parsed by a sharedexport_params.rs. The snapshot is pinned at enqueue (E11.2 — Run-to-snapshot identity, explicit snapshot reads #1229'spin_requested).POST …/exports(steward+) enqueues and returns{export_id, snapshot, status}.GET …/exports/{id}returns status, row count, snapshot, kind, format,expires_at.GET …/exports/{id}/downloadstreams the file. Cross-org → 404.lake_maintain.job.failed), a concurrent newer run (the export stays on its snapshot), cross-dataset and cross-org refused, and an expired export as 410.Discoveries
duckfleet_artifacts.rsalready forbids signed URLs in responses. An S3-backed lake answers 501 at enqueue. Lifting that is E11.3a — Exports for S3-backed lakes: a scoped er-api read on export prefixes #1240.arrow-csvandarrow-jsonare in the build andparquetis not. That is E11.3b — Parquet export format #1241.Measurements
Files