Repository navigation
feat(extract): Salesforce Bulk API 2.0 extract job to Parquet (#512) - #873
Merged
Merged
Conversation
The org-scoped credential a Salesforce extract authenticates with (webhook plaintext-secret discipline, deliberately no history trigger) and the per-(dataset, source) SystemModstamp high-water mark (the s3_ingest_cursor shape for an API-polled provider).
A pod task pulls one sObject (client-credentials auth, SOQL built from the source's declared columns, SystemModstamp watermark, converted leads excluded for Lead per spec 1.26) and stages the result as an ordinary drop-root CSV delivery; a control task enqueues the incremental run and advances the cursor, publish-then-advance like the S3 poller. The credential rides the work order, resolved server-side and URL-guard re-checked per attempt. Routes: connections CRUD (admin, secret never listed or echoed) and POST .../extract (steward), both validated by the shared params parser.
…ange touches pg_connections proves the role gates, the URL-guard refusals, that the secret never appears in a 201, a listing or an audit row (mutation-tested), every extract 422-before-queueing, the 202 enqueue, schedule param validation and the idempotent soft delete. connectors.md §4.1 records what is now built and the client-credentials deviation; backend-design's phase-3 ledger stops claiming no connector ships; generated references regenerated.
athvin
force-pushed
the
issue/512-salesforce-extract
branch
from
November 8, 2026 15:40
8da7aa1 to
c85647f
Compare
athvin
marked this pull request as ready for review
November 8, 2026 15:40
pg_schema_replay/pg_schema_race age a store by dropping dataset_id from every table that carries one; a NOT NULL dataset_id only heals through 0004_dataset_id_required (the reconciler rightly refuses to add it as Breaking), so the new table joins DATASET_SCOPED with required=true. Both tests reproduced red in CI and green locally with this.
This was referenced Nov 8, 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 #512
What
The Salesforce side of E2: a
salesforce_connectionresource (org-scoped, admin),a
sf_extract_cursorwatermark, a newextractjob kind whose pod task pulls ansObject through Bulk API 2.0 (client-credentials flow) and lands the result as a
CSV delivery in the dataset's
drop_root, where the existingIngesttask andthe rest of the incremental pipeline take over. The Bulk API client is
er-server/src/salesforce.rs(thes3_ingest.rsshape), proven against a localmock server in
tests/salesforce_mock.rs.Why
Issue #512's remaining gap is extraction only: "Our ingestion reads S3 and CSV,
not an org." Bulk API 2.0 query results are already CSV, so the extract job is a
pure producer at the edge of an unchanged engine — exactly the connector contract
in
connectors.md§1.Proof
make checkgreen locally (exit 0) in the worktree, rebased ontob3e35e46;post-rebase, the byte gates were re-proven (
mcp_manifest,response_envelopes,er-entity verify: "145 generated files are current … every statement plans",make skills-checkok). The pg family ran for real against a dedicatedPostgres:
pg_connections … 1 passedunderER_TEST_PG_DSN(port 5477), andsalesforce_mock … 3 passed. Two gate mutations were observed failing: a 201echoing
client_secret, and a broken cross-page watermark max.Risk & rollback
New job kind + new entities are additive; no existing DAG, route or schema
changes shape.
git revert <merge-sha>rolls back cleanly (the reconciler onlyever adds the two new tables).
Post-merge ledger
Closed by: agent · session
93a44611-348c-4819-b503-ac48b5acd076onMac· 2026-11-08T16:50:00Zmainis green with this change on it — merge SHAb4186c34;rustrun 42498531096 success on that SHA itself, withfrontend,infraanddevcontainergreen beside it and zero non-successcompleted runs on
mainthrough the watch.imagesbuilt — run 42498531095 success;er-apiresolved tosha256:a3d9483f…ander-webtosha256:84962bcd…fromb4186c34.deployconverged — run 42500136096: the NEW colour's pod (thea3d9483f…image) answereder-api-preview /readyz -> 200before theflip — a line the booted process emitted, and readiness requires
ensure_schemato have reconciled the two new tables — thenCut overand
Retire the old colourboth succeeded.deploysuccess (above),
driftlatest run success,kindlatest run success.Donethrough the automation (read backfrom the board), and E2 — Dataset model and extraction to DuckDB #512 closed
COMPLETEDby the merge.UI), feat(extract): deletion propagation — getDeleted poll and a full-refresh landing mode #880 (deletion propagation), test(extract): executor-harness e2e of the extract DAG against a mock Salesforce #881 (extract-DAG e2e).
connectors.md§4.1 (what isbuilt, the client-credentials deviation, the deletions gap) and
backend-design's phase-3 ledger updated in this PR; the DATASET_SCOPED
rule (a NOT NULL
dataset_idon a new entity must join fixup 0004 orthe aged-store tests fail) is written at the list itself in
fixups.rs,plus session memory
salesforce-extract-shipped.Specific to this change
exposure of
extract) — deferred — feat(ui): Salesforce connections settings surface and extract exposure #879.getDeletedpoll + a full-refresh landing mode;stage_ingestisfull_refresh: falseunconditionally) — deferred — feat(extract): deletion propagation — getDeleted poll and a full-refresh landing mode #880.(the Bulk client is mock-proven; the DAG wiring is assembly-proven; the
two together are not) — deferred — test(extract): executor-harness e2e of the extract DAG against a mock Salesforce #881.
Context — plan, discoveries, measurements, files
Plan
entities/salesforce_connection/— org-scoped (webhookshape:
org_idNOT NULL + V15 index), columnsname,instance_url,auth_kind(client_credentialsv1),client_id,client_secret,api_version,is_active. Nohistory: true— the history triggercopies whole rows as jsonb, which would duplicate the secret into an
append-only side table.
languages: [rust]only — no TS binding and no JSONwire, so the secret cannot reach
openapi.json/bindings (the Column visibility: visibility:internal in entity.yaml, generated wire structs, V18 lint #858 defectclass). Statements:
create/create,read/list_active(projection dropsthe secret in
pg.rs),read/by_id(with secret — work-order resolutiononly),
update/deactivate(soft, the webhook rule).entities/sf_extract_cursor/— thes3_ingest_cursorshape:natural_key [dataset_id, source], the watermark as verbatim SalesforceISO text (so it round-trips into the next SOQL literal unchanged),
create/advanceupsert (COALESCE keeps the mark on a full refresh) +read/get.er-server/src/salesforce.rs). Token fetch (OAuth client-credentials), BulkAPI 2.0 query job lifecycle (create → poll → paged CSV results via
Sforce-Locator), SOQL builder (fields from the source spec's declaredcolumns;
SystemModstamp > $watermark;IsConverted = falsefor Lead whenasked — spec unit 1.26; user
WHEREpassthrough — unit 1.2). reqwest withredirect::Policy::none()+ timeouts (thewebhook::client()discipline).Unit tests against a local mock HTTP server: auth, paging, retryable vs
terminal error mapping.
POST/GET /v1/orgs/{org}/connections+DELETE /v1/orgs/{org}/connections/{id}(admin;urlguard::checkoninstance_url— SSRF);POST /v1/orgs/{org}/datasets/{ds}/extract(steward+, enqueues
extractwith params{connection_id, object, source, mode, where?, exclude_converted_leads?}parsed by a sharedextract_params.rs, theprofile_paramspattern). Audit rows carry ids andinstance_url, never the secret.JobKind::Extract(ALL→ 12), a two-node DAG:extract(pod — the pull and the staged-rename publish intodrop_root;no lake open, so no
reconcile_schema) →advance_sf_cursor(control —enqueues
run_all_incrementalon an idempotency key, audits, emitsimport.received, then advances the watermark; the s3-ingestpublish-then-advance ordering). Work order gains a
#[serde(default)]connectionfield resolved server-side inattempt_work_order(themodelsprecedent — pods cannot read Postgres), URL-guard re-checked perattempt.
SCHEDULABLE_KINDS→ 8, with extract schedule params validated atcreate.
dag_assembly,dag_task_coverage(
variant()arm),dispatch_coverage,mcp_manifest+response_envelopesopenapi.jsonregen,egress_guard(no bareClient::new()),entities regen (
er-entity verify), tests registered intests/main.rs.pg_connections.rs(one test per file): CRUD + roleenforcement + cross-org 404 + secret never in list body or audit detail +
urlguard refusal observed failing.
connectors.md§4: record what is now built and thedeliberate deviation — v1 auth is OAuth client-credentials, not the
web-server flow the doc sketched (no redirect URI, no refresh token, no user
interaction; right shape for a headless extract job).
make checkgreen; PR ready;/land-pr.Discoveries
s3_ingest::classifyrejectsnon-
.csv;find_deliveriesglobs{source}.csv;land_base_deliveryis acsv::Reader). Bulk API 2.0 results are CSV — so the extract job lands CSVdeliveries and no ingestion change is needed. The epic's "Parquet per
object" is satisfied downstream: DuckLake materialises
raw_recordsasParquet on object storage.
er-dag/src/task.rs:320-326); theSalesforce credential must ride the work order, resolved server-side —
three precedents (
lake_env,models,labels).webhook.secretis theplaintext-column precedent.
history: truewould leak the secret into*_history— so the connection entity does not set it.connectors.md§4 designed the web-server OAuth flow; a headless extract jobwants client-credentials. Recorded as a deviation, not silently diverged.
stage_ingestpassesfull_refresh: falseunconditionally, so even a full-mode extract upsertsrather than tombstones. Recorded in
connectors.md§4.1;getDeleted+ afull-refresh landing mode are one follow-up ticket (filed at merge).
client_secretfails
pg_connectionsnaming the body, and breaking the cross-pagewatermark max fails
salesforce_mock. Both reverted.Measurements
Files