Skip to content

v0.9.0

Choose a tag to compare

@github-actions github-actions released this 11 Aug 13:47
· 300 commits to main since this release
v0.9.0
aa53d9c

Theme: ADR 0005's state-location foundation, delivered end to end. #756 ships all four steps — the state.backend config surface + factory, a working GCS backend, a working S3 backend, and the operator/migration docs — so run state, history, and the DLQ survive an ephemeral CI runner and are shareable across a team, with generation/ETag-preconditioned writes closing the same concurrent-writer failure class as #919 for drt's own state. Write-path semantics grew three ways: first-class run_id/sync_run_id correlation plus opt-in metadata_columns bookkeeping (#762), declarative computed_fields (#763), and REST API body_mode: batch (#770). CI/testing depth: state:modified selection against a prior manifest baseline (#772, ADR 0006) and zero-credential sync.unit_tests (#780). Security: secret provider URIs for AWS/GCP Secret Manager and Vault (#782). drt serve gained a real delivery contract — coalescing instead of dropping concurrent triggers, 202 + poll instead of holding the request open, pluggable auth (#854). Two data-loss bugs closed, both with the same reconcile-against-fresh-state pattern: concurrent GCS watermark writers silently clobbering each other (#919) and drt retry silently dropping dead letters appended by a concurrent drt run (#955) — local (non-object-store) cross-process safety for both stores is tracked separately as #963. The CLI/MCP parity gap that let --limit/--fail-fast/--vars ship without their MCP-tool equivalents for three releases is now a CI gate (#871), and all 11 gaps it found are closed (#870). Also: scope-aware SQL diff closing the last #694-part-2 memory-win gap (#890). No breaking changes — drop-in upgrade from v0.8.5.

Added

  • REST API batch request bodies (#770): body_mode: batch sends the engine's already-sync.batch_size-bounded record chunk in one HTTP request, or further splits it with max_records_per_request, replacing one-request-per-row activation against bulk endpoints without creating a second batching authority in the destination layer. batch_template renders with rows=<post-mapping records> and the existing tojson_safe filter handles the whole list; rate limiting is charged once per outer request, so the configured RPS now buys N records of throughput in batch mode, while retry still wraps the complete request atomically. Non-2xx responses fail the whole request chunk by default; optional dotted error_path maps an exactly length-matched, index-aligned JSON list where null means success and non-null entries become row errors (message priority error → message → error_message). A malformed mapping logs a warning and safely fails the whole sub-chunk rather than partially pairing the wrong records, and global RowError.batch_index offsets remain correct across multiple sub-chunks for DLQ handoff. on_error: fail stops after the first sub-chunk containing any failure; empty batches perform no rendering, limiter acquisition, or network I/O. Default body_mode: record is unchanged. Docs: docs/connectors/rest-api.md.

  • State-aware selection — run only the syncs this PR changed (#772): CI no longer has to choose between running every sync and running nothing when a PR changes project configuration. drt run --select state:modified --state ci-baseline/manifest.json --dry-run --diff compares the current project with a prior drt docs generate --format json artifact; the same --state flag and state:modified / state:new selectors work on drt build, drt test, and drt validate. Manifest schema v3 adds syncs[].config_hash, and one shared resolver carries the resulting diff through selection without inventing a second state format. The hash covers sync-file content (plus referenced local model SQL), not resolved configuration: secrets referenced through environment variables structurally cannot enter it, while an environment-variable-only change is deliberately invisible — the same accepted blind spot dbt documents. A missing, unreadable, or malformed baseline warns and treats every current sync as new/modified, so the first CI run works rather than failing closed; a pre-v3 manifest instead exits clearly because it cannot contain comparable hashes. See ADR 0006.

  • sync.computed_fields — declarative derived columns (#763): drt could rename a column (field_mappings) and obscure one (mask), but not derive one. The workarounds were to push destination-specific formatting into a shared dbt mart — one mart per destination, which is mart sprawl — or to use the REST destination's body_template, which the other 33 structured destinations do not have. Now computed_fields: {name: "<jinja>"} derives payload-shaped columns at the engine seam, so every destination gets them: full_name: "{{ row.first }} {{ row.last }}", phone_e164: "+81{{ row.phone | replace('-', '') }}", source_system: "drt-${ENV}". Same Jinja environment, filters and StrictUndefined strictness as body_template — one templating story. A single-expression template keeps the value's Python type ({{ row.n * 1000 }} reaches a BIGINT column as 5000, not "5000"), while anything with surrounding text renders as a string; Jinja's own native_concat is deliberately not used, because it literal_evals the result and would turn a column holding the string "123" into the integer 123 while leaving "01" alone — the same config behaving differently row by row, decided by the data. Ordering: computed_fields → field_mappings → mask. Templates therefore read source column names, matching how cursor_field and lookups already read, and the rename and mask apply to what they produced. ⚠️ This is not the order sketched in the issue (computed_fields → mask → field_mappings), which would have inverted the shipped meaning of every existing mask: key — they reference post-rename names today, so a mask configured against the destination-facing name would have silently stopped matching and let PII through. A computed field can never read another computed field: every template is evaluated against the record as it arrived, so results do not depend on YAML key order — the same guarantee field_mappings makes, and the reason chaining was rejected rather than overlooked. Writing an existing column name is allowed and replaces it in place, for normalisation (phone → E.164) without inventing a second name. Template syntax is validated at config load — a malformed template stops drt validate instead of surfacing on the first row of a production run — while a missing column stays a run-time error governed by on_error: skip drops the row with a RowError (never half-derived: fields are assigned only once all of them succeeded), fail raises and names the field, since a template failure is nearly always one config defect affecting every row alike and reporting it once beats reporting N skipped rows and zero synced. Error handling deliberately catches every exception a template can raise, not just the missing-column one — {{ row.a / row.b }} over a zero raises ZeroDivisionError straight out of Jinja, and catching narrowly would let it abort a run that had explicitly asked to skip bad rows. ⚠️ One inherited Jinja behaviour to know: a NULL passed through a filter renders as the literal string "None" ({{ row.phone | replace('-', '') }} over a null phone), because Jinja stringifies before filtering; a bare {{ row.phone }} correctly stays null. This is shared with body_template and is not special-cased — write {{ row.phone or '' | replace('-', '') }}. Prior art: dlt's add_map, Census / Hightouch computed mapper fields; aggregations and cross-row logic remain out of scope (that is SQL's job).

  • state: project config block (#756, step 1 of 4): builds on #900's prior pure-interface extraction (StateStore/HistoryStore/DlqBackend Protocols + back-compat aliases, no call-site changes, paired with a set-equality test against each local implementation's public API so a Protocol can't silently stop covering a method — caught a near-miss where StateStore.reset() had arrived nine days after the Protocol's method list was written). This step adds a new drt_project.yml state.backend field (local only for now — this is groundwork, not a new capability) and a shared build_state_bundle() factory replacing 24 direct StateManager/HistoryManager/DlqStore constructions across the CLI/MCP/docs surfaces. Behaviourally a no-op — every call site still gets the same local file-backed stores it did before — but it's what makes a remote (GCS/S3) backend a config change instead of a rewrite in the follow-up PRs this stack sets up. The bundle is cached per project directory rather than constructed fresh per call: drt run --threads N's existing per-instance locking only stays meaningful once every thread shares the same store instance, which matters more once that instance is a network client rather than a local file handle.

  • state.backend: gcs (#756, step 2 of 4): the first working remote backend — state.json/history/DLQ each become one GCS object per sync (or one for state), read-modify-written under a generation precondition rather than last-write-wins, closing the same failure class as #919 (a lost update between two writers that finish together) for drt's own state rather than just watermarks. Reads are pinned by a versioned blob reference rather than if_generation_match on download — the two are not equivalent: a competing writer landing between the metadata check and the download raises 404 on a versioned read but 412 on an if_generation_match download, and conflating the two would let a genuinely-present object's read be mistaken for "never existed", producing a wrong create-only write. Retries use jittered exponential backoff (up to 8 attempts — higher than a single watermark's 5, since state.json is shared by every --threads N worker rather than by two independent writers) and raise StateContentionError on exhaustion for state (silent loss is exactly the bug class this closes) while history/DLQ stay best-effort, matching local's existing swallow-and-log posture. Remote history is additionally capped by history.max_entries (default 500) on top of retention_days, bounding the object a conditional write reads and rewrites — a documented behaviour difference from local, which keeps everything inside the retention window with no count cap. The DLQ observer now buffers failed batches and flushes once per sync instead of writing on every failed batch, which also reduces local DLQ file writes. New object_store_smoke pytest marker (real fake-gcs-server via testcontainers, every PR, no secrets — same posture #941 established for Postgres/MySQL) opens with a mandatory canary asserting the emulator actually enforces both preconditions before any concurrency test runs, so a permissive emulator fails loudly instead of reporting false-green results.

  • state.backend: s3 (#756, step 3 of 4): the same object-store primitive against Amazon S3, using ETag preconditions in place of GCS's generations. S3 has no equivalent of a generation-addressed read, so a stale snapshot surfaces as a 412 on the pinned GetObject (or 404 on a concurrent delete) rather than the versioned-read 404 GCS gets almost for free — the read path retries explicitly rather than relying on a single primitive doing the work. PutObject uses IfNoneMatch: "*" for create-only and IfMatch: <etag> for update-if-unchanged; an S3-compatible endpoint that can't honour a conditional header (e.g. 501) fails loudly rather than silently falling back to an unconditional write. Credential resolution matches S3Destination's existing shape exactly (aws_access_key_id_env/aws_secret_access_key_env/aws_session_token_env, region, endpoint_url) so state storage doesn't introduce a second AWS auth vocabulary. boto3 floor bumped to >=1.35.69 — the version that added conditional-write support to PutObject. Same object_store_smoke marker as the GCS leg, now covering both backends via LocalStack's S3 service, with its own three-part canary (create-only, stale-IfMatch-on-write, stale-IfMatch-on-read all independently verified enforced before any concurrency assertion runs).

  • Remote state operations and migration guide (#756, step 4 of 4): documents GCS/S3 setup, authentication and scoped IAM, the shipped object layout and contention behavior, bidirectional migration from .drt/, and the independence of project state from per-sync watermark storage. The sync-history, DLQ, CI/CD, and LLM API references now point operators to the durable backend where local-only wording previously implied .drt/ was the only location.

  • First-class run_id + sync_run_id correlation (#762, part 1 of 2): every drt run process now generates a run_id (one per process, threaded through every sync it executes), and every run_sync() call — including library callers that never pass one at all — generates its own sync_run_id. Both flow through SyncResult, HistoryEntry, DeadLetter, --output json, OTel span attributes, and failure/degraded alert context, all for free: _run_sync_body stamps both ids onto its total_result object immediately after construction, before any observer or alert dispatcher ever sees it, so no SyncObserver Protocol signature change was needed. Deliberately not reconciled with #768's query-tagging new_run_id() (a short lowercase-hex id sized to fit SQL comments and warehouse label length limits) — forcing a full UUID4 through that path risked corrupting the exact budget it exists to respect. Plain uuid.uuid4(), not the issue's proposed uuid7: none of the six correlation surfaces above sort by id, and uuid7 isn't in the stdlib on any supported Python (3.10–3.13). One documented gap: if run_sync() raises before ever returning a SyncResult, the CLI's --output json error entry for that one failure has no object to read sync_run_id from (the history entry and failure alert written inside the same finally block, before the re-raise, still get it correctly).

  • sync.metadata_columns — opt-in engine-injected bookkeeping columns (#762, part 2 of 2): drt wrote destination rows byte-for-byte from the source, with no marker of when a row synced, which run produced it, or which sync owns it — debugging a stale-looking CRM row meant cross-referencing local .drt/history files a CI runner throws away between runs. Now metadata_columns: {synced_at: _drt_synced_at, run_id: _drt_run_id, sync_name: _drt_sync_name} adds any subset of the three as plain dict enrichment at the engine seam, so every destination that takes a list[dict] gets them — SQL, SaaS, and file/blob alike — not just the REST destination. Prior art: dlt's _dlt_load_id + _dlt_id, dbt's invocation_id. synced_at/run_id are computed once per run_sync() call and shared by every row it writes (matching a load-id's "one per load" semantics), not recomputed per-record or per-batch; run_id is null for library callers that don't pass one to run_sync(), the same nullability part 1's SyncResult.run_id already has. Ordering: last of every transform, applied after mask — unlike computed_fields (which runs first): the column names here are already destination-facing (chosen directly in config, not derived from a source column) and the values are engine bookkeeping, not source data, so there's nothing for field_mappings to rename or mask to obscure. This also means a computed_fields template can never observe a metadata column, since it doesn't exist yet when computed_fields runs. Requires the target column to already exist on the destination — this is dict enrichment, not DDL; a destination without that column fails the write normally, governed by on_error. A record that lands in the DLQ carries its metadata columns from the original failed attempt: drt retry resends the stored record verbatim, so a successfully-retried row's _drt_synced_at/_drt_run_id trace back to when it first failed, not the retry — deliberate, not a gap. Docs: docs/guides/metadata-columns.md.

  • sync.unit_tests — fixture rows in, expected payload out, zero credentials (#780): once mask, field_mappings, and destination lookups could all touch a record before it ships, the only feedback loop for "does this mapping do what I think" was drt run --dry-run against a real warehouse — slow, and unavailable to a contributor without cloud credentials or to CI on a pull request. unit_tests: runs given fixture rows through the real engine transform chain (computed_fields → field_mappings → mask → metadata_columns, via a FakeSource and a capturing destination) and compares the result against expect — no network call, no credential, no destination connection. expect is a subset match per row — only the keys a test declares are checked, so a sync's source columns growing later doesn't break every existing unit test — but row count is still checked exactly, since a transform that drops or duplicates a row is exactly what a unit test exists to catch. drt test --unit, --output json, --select, --fail-fast; wired into drt build and the drt_run_test MCP tool. Not supported yet: a sync whose destination has lookups: configured — lookups resolve against the real destination and there is no fake for that — reported as a failed test rather than a crash; mutually exclusive with --dry-run and --store-failures, which are destination-connected concepts unit tests don't have. alerts are stripped before the sync runs (a shallow model_copy, the caller's own config object untouched) — otherwise a test deliberately exercising a failure path would fire real Slack/webhook alerts from inside run_sync()'s own finally block, since alert dispatch there is not observer-mediated. Prior art: dbt unit tests (1.8+), Census/Hightouch mapper previews with sample records. Docs: docs/guides/sync-unit-tests.md.

  • Secret provider URIs — resolve credentials from AWS/GCP Secret Manager or Vault (#782): production reverse ETL concentrates write credentials to CRMs, ad platforms, and warehouses — exactly the secrets an org keeps in a managed store with rotation policies attached, while the default path (export into an env var in every runner) duplicates secret-distribution logic per orchestrator and breaks rotation the moment it's exported. Any *_env field in a profile or destination config can now be a scheme://... URI instead of a plain env var name: aws-sm://<secret-id-or-arn>#<key> ([aws-secrets] extra), gcp-sm://projects/<project>/secrets/<secret>/versions/<version>#<key> ([gcp-secrets], GCP always names a version explicitly — latest is a real resolvable alias, not an implicit default), and vault://<mount>/data/<path>#<key> ([vault]; #<key> is required here, unlike AWS/GCP, since a KV v2 payload is always a field map with no "the secret is just one string" case to fall back to). Resolution chain: explicit YAML value → OS environment variable → .drt/secrets.toml → provider URI, tried in that order, so a provider URI is automatically inert wherever a real env var or secrets.toml key already resolves. A resolved value is cached by full URI with a 300s default TTL (DRT_SECRET_CACHE_TTL_SECONDS, read on every lookup, so changing it takes effect without a restart; a non-positive value disables caching entirely) — this is what lets drt serve, a long-lived process that re-enters credential resolution on every triggered sync, pick up a rotated secret within one TTL window instead of holding the value it resolved at process start indefinitely (#929, caught and fixed before this shipped in any release). The Vault leg goes one step further for a related reason: hvac.Client() captures VAULT_TOKEN once at construction and never refreshes it, and Vault tokens are conventionally short-TTL, so the Vault client is rebuilt on every fetch rather than cached — avoiding every fetch failing outright once the token expires, in favour of the value-cache's own bounded staleness. Not secret writing or rotation management (drt only reads), not local-file encryption (.drt/secrets.toml is a separate, unrelated mechanism), not OAuth token brokering, and not yet a third-party plugin surface (the provider registry is structured for one, but nothing installs today). Docs: docs/guides/secret-provider-uris.md.

Changed

  • Template rendering compiles once instead of per record (#763): render_template built a fresh Jinja Environment and re-parsed the template on every call, and all five of its callers — HubSpot, Klaviyo, Mixpanel, Zendesk, Linear — call it per record. Two module-level environments and an LRU cache of compiled templates replace that. Behaviour is unchanged, including the exception surface; Jinja templates are safe to render concurrently, which matters because drt run --threads N now renders through one shared cache.

  • Scope-aware SQL diff for tracked+scoped mirror, closing the gap #694 part 2 left open (#890): strategy: tracked + scope composed together still pulled the whole per-sync tracked-key state table into Python before filtering by scope in memory — #694 part 2's server-side NOT EXISTS diff landed, but the scope narrowing came after it, in Python. On real Postgres 16 with 500 scopes × 200 keys (100,000 tracked rows), a run touching one scope and dropping 5 of its keys returned 99,805 rows to Python before this change; 5 after — roughly 20,000× fewer rows crossing the wire, and faster too (44.4ms → 6.6ms, best of 3). Fixed identically across all four SQL destinations that implement tracked+scoped mirror — Postgres/MySQL, Snowflake, ClickHouse, Databricks — each dialect's own diff query now applies the scope filter server-side instead of after the fact. Rows written before scope tracking existed (scope_spec/scope_key still NULL, un-backfilled) correctly fall through to the existing Python-side filter, unchanged from today's behaviour — verified with a mixed backfilled/un-backfilled table rather than assumed.

  • Internal — drt_run_test stopped re-implementing the test loop (#851, PR #927 by @Muawiya-contact): the MCP tool ran its own copy of connect → build query → execute → check → severity → error handling, the same loop execute_tests_for_sync has run for drt test and drt build since #777. Two implementations of one rule is precisely what #400 was, and #836 had to add MCP-side severity tests to pin behaviour a comment was otherwise holding in place. run_test() is now selection plus the JSON envelope: it picks the syncs and delegates per sync, so a change to severity semantics — or to anything else in the loop — reaches the MCP tool by construction rather than by remembering to. The returned shape is unchanged field-for-field, including status / results[].sync / tests[] / skipped / reason, and every existing test passes unmodified. Two arguments carry the difference in surface: json_mode=True + quiet=True, because the shared function prints a test header and a line per test for the CLI and MCP speaks over stdio; and (at the time) store_failures=False, because #779's samples are written to .drt/test_failures/ and MCP exposed no way to read one back — #870 below turns that into a real opt-in parameter once the returned path itself answers the objection. One user-visible edge: the skipped-sync reason in drt test --output json gains the trailing word destinations ("tests not supported for rest_api destinations"), matching the wording the same command has always printed, the wording drt_run_test has always returned, and the wording drt build's tests_skipped_reason inherits.

  • The drift audit now checks that CLI options reach their MCP tool (#871, PR #877 by @Pawansingh3889): scripts/check_drift.sh audited connectors and MCP tool existence, so adding a connector was caught and adding a flag was not. That is why the v0.8.0 wave — --limit, --fail-fast, --failed, --vars, --threads — shipped without MCP parity and went unnoticed for three releases (#870). The release checklist already asked for this by hand (drt-release-check.md, Phase 0 item 12), and it was manually ticked and silently passed each time; asking a human to enumerate "new CLI capabilities" from memory across a thirty-PR release is exactly the task that degrades. New check 9 does the enumeration instead, via scripts/check_cli_mcp_parity.py: it walks the Typer command tree, reads each MCP tool's signature, and reports any behaviour-changing option with no corresponding parameter. Presentation flags (--output, --verbose, --quiet, --log-format, --format) and selection flags (--select, --exclude) are structurally excluded with the reason recorded, and renames are declared rather than guessed (--diff → compute_diff, --sync → sync_name, and --no-state → include_state, an inverted alias). A command that is neither mapped to a tool nor explicitly listed as deliberately unmapped is itself reported — so a new command forces a decision instead of being silently skipped, which is #870's failure mode one level up. The 11 gaps it found are recorded — and, as of #870 directly below, cleared — in scripts/drift_baseline.txt; two of them — test --dry-run and test --store-failures-limit — were found by the check rather than by the hand audit. ⚠️ The check refuses to report success if introspection breaks. Typer 0.27 vendors its own Click, so TyperOption does not subclass the installed click.Option; the obvious isinstance filter matches nothing, every command enumerates zero options, and a parity check written that way passes forever while the gap it exists to catch grows. Options are therefore identified by duck-typing on param_type_name, and a canary assertion exits 2 rather than 0 if known-present options stop enumerating. For the same reason the script imports no click at all — Typer vendors it, so standalone Click is absent from a core install and importing it would work locally and fail in CI. The drift workflow gained a Python setup + core pip install -e . step (checks 1–8 are pure bash), and drt/cli/**, drt/mcp/tools/** were added to its paths: filter — without those a new flag would only have been caught by the weekly cron, reintroducing the lag this fixes. Trigger design is unchanged: the audit stays post-merge + weekly and never comments on contributor PRs.

  • MCP parity closed: --limit/--vars on drt_run_sync, --dry-run/--fail-fast/--store-failures[-limit] on drt_run_test, --check-connection/--strict on drt_validate (#870): all 11 gaps scripts/check_cli_mcp_parity.py (#871) found are now closed or recorded as deliberate. drt_run_sync gains limit (→ extract_limit, same mirror/replace rejection as the CLI — a sample would delete or replace real rows) and vars (already a parsed dict, not the CLI's 'k: v, k2: v2' string — resolved through the same vars: block < DRT_VAR_* < caller precedence via project_vars(), reused rather than reimplemented). drt_run_test gains dry_run, fail_fast, store_failures, and store_failures_limit — the multi-sync --fail-fast loop moved out of drt test into a new shared run_test_suite() (same one-implementation principle #851 above already applied to the per-test loop, applied one level up to the per-sync loop, and to the unit=True path too via run_unit_test_suite() once review caught fail_fast silently not reaching it there) so every surface schedules syncs identically. store_failures reverses #851's earlier "MCP can't read a sample back" reasoning: the returned failures_stored.path is a filesystem path under the project directory, and an MCP client with its own file access (the common case — an agent driving drt via MCP usually also has Read/Bash on the same checkout) can open it directly; MCP itself still doesn't read the file, it just stops pretending the path is useless. drt_validate — previously four lines returning only valid/errors, with no secret scan at all — now also runs the hardcoded-secret scan and reports warnings per sync (including for syncs that failed schema validation, matching the CLI), gains strict (promotes those warnings to errors, matching drt validate --strict) and check_connection (adds a connection_tests dict via the same _run_connection_test the CLI uses, keyed by sync name). run:--threads/--fail-fast/--failed are deliberately excluded, not implemented: drt_run_sync runs exactly one sync per call, and all three are multi-sync scheduling/selection concepts — parallelism across syncs, stopping remaining scheduled syncs, and a status-based selector with the same grammar SELECTION_OPTIONS already excludes --select/--exclude under ("an agent filters via drt_get_status() and calls drt_run_sync per name"). Recorded in COMMAND_EXCLUSIONS["run"] with each reason rather than left as baseline debt, since extending a single-sync tool with a second scheduling authority would contradict the selection precedent already shipped. scripts/drift_baseline.txt's cli-mcp: section is now empty.

  • drt serve gets a real delivery contract (#854, ADR 0004 Tier 3, PR #902 by @Pawansingh3889): at webhook cadence the old endpoint had three defects that compounded — a second trigger was answered 423 Locked and dropped (the sender believed it delivered; nothing ran — silent event loss, not backpressure), the sync ran synchronously inside the request handler (any sender with a delivery timeout recorded a failure for a sync that succeeded, then retried it), and the lock was global across every sync, so unrelated syncs queued behind each other. All three are replaced by one explicit promise, documented in the endpoint docs as a contract rather than an implementation detail: a trigger accepted with 202 will run — different syncs run concurrently, and same-sync triggers coalesce to depth 1 (while a sync runs, the first new trigger creates one pending run; further triggers get the same run id with "coalesced": true, a flag that means "your trigger did not start a run of its own", covering both the trigger that creates the pending run and every one that joins it). Coalescing rather than a deeper queue is deliberate: drt syncs are watermark-driven, so one pending run picks up everything that accumulated — a queue of N would do the same work as a queue of 1. That reasoning holds because triggers are parameterless; if a trigger ever selects rows, the coalescing decision must be revisited. Dry-run and real triggers coalesce separately — a real trigger is never folded into a dry preview. ⚠️ Two behaviour changes: 423 is gone (a concurrent trigger now coalesces instead of dropping), and POST /sync/<name> now returns 202 + a run id immediately instead of holding the request open — poll GET /runs/<id> for the outcome, or pass ?wait=true for the old synchronous 200/207 semantics (a wait=true request against a busy sync coalesces and blocks until the pending run completes). Run ids are in-memory, valid for the lifetime of the drt serve process — deliberately not persisted, because durable run ids are #762's decision to make; when that lands, only the id's durability changes, not this contract. Auth became pluggable (--auth none|bearer|hmac; auto keeps the historical default of bearer-if-token-set): the bearer comparison now uses secrets.compare_digest (it was ==), and new HMAC-SHA256 body-signature verification covers GitHub (sha256=<hex>, default header X-Hub-Signature-256), Shopify (base64, --hmac-header X-Shopify-Hmac-Sha256) and bare-hex senders. Stripe's timestamped scheme and Pub/Sub's OIDC JWT are not covered — OIDC is a filed follow-up (#903 — it needs a JWT dependency decision), and until it lands Pub/Sub push still needs a verifying proxy. Auth covers GET /runs/<id>, not just the POST: that endpoint returns the full SyncResult and any error text, and while the run id is a uuid4 it rides in the URL path, so it reaches every reverse-proxy access log in front of drt. Leaving it as an implicit capability URL would have made the read path quietly weaker than the write path, in the one change whose stated purpose is making the contract explicit. GET /health stays open so load-balancer probes need no credential. Under hmac a GET has no body to sign, so its signature is over the empty body: a constant per secret rather than a per-request signature, documented in the guide together with the openssl one-liner that computes it and with when to prefer bearer for the polling path. One correctness fix underneath: run_drt_sync() gained an optional state_manager param and the server passes a shared state store, since LocalStateManager's thread-safety is an instance lock and the previous per-request instances would have raced load-modify-save on state.json the moment different syncs ran concurrently. That param is typed as the StateStore Protocol (#756) rather than the concrete local class, so drt serve is not the one caller structurally unable to take a remote state backend when those land. Request bodies are capped at 1 MiB (413); the run registry keeps the last 1000 finished runs, evicted by finished_at rather than by membership of a fixed set of state strings, so a status the runner's result contract grows later cannot leave a run permanently un-evictable. Docs: docs/guides/using-webhook-trigger.md (the contract, status-code table, per-scheme auth setup), docs/llm/CONTEXT.md.

Fixed

  • drt retry silently dropped dead letters appended by a concurrent drt run (#955). replay_dead_letters() read the DLQ once at the top, decided what to keep/drop against that snapshot, and wrote the result back at the end with DlqBackend.replace() — an unconditional whole-queue overwrite. A dead letter a concurrent drt run appended between that read and that write was never seen by the snapshot and was silently lost on the overwrite. Same failure class as #919 (concurrent writers, a stale snapshot committed as truth), caught three days after that fix shipped. DeadLetter gains a stable id (assigned once at creation, preserved by drt retry across attempts — a retried-and-failed-again entry keeps its identity; only attempts/timestamp/error_message change) and both backends gain DlqBackend.reconcile(remove_ids=..., updates=...), which re-reads current state itself and touches only the named entries — anything the caller never saw (a concurrent append, or an entry beyond --limit) survives untouched. replay_dead_letters() now calls this instead of replace(); --limit's previously-explicit untouched bookkeeping is now implicit, since reconcile only ever names what it actually processed. ObjectStoreDlqBackend.reconcile() is genuinely cross-process-safe — the same generation/ETag preconditioning append() already used forces a retry against fresh state on a losing race, exhausting attempts raises rather than silently committing stale content. LocalDlqStore.reconcile() is not — it has no OS-level file lock (only a process-local threading.Lock, the same limitation its class docstring already documented), so a genuinely separate drt run process racing the read/write window still loses that append exactly as replace() did; what this fix does close for local is reconciling by identity from a fresh read rather than a stale in-memory snapshot, which matters the moment real file locking lands (a wholesale-overwrite operation could never be made cross-process-safe regardless of locking). Real local cross-process safety is filed separately as #963, covering LocalStateManager/LocalHistoryManager too, not just this class. --clear still uses replace([]) — a full discard racing a concurrent append can still lose that append on either backend, which is the documented "records are unrecoverable" contract, not a gap this fix left open. A retried entry's sync_run_id now correctly carries over from the original failure (previously reset to null on every retry — a byproduct fix, since the reconstructed DeadLetter object needed rebuilding here regardless), matching #762's stated correlation-id semantics: a successfully-retried row traces back to when it first failed, not the retry. Entries written before id existed decode via a content-hash of their own JSONL line rather than a fresh random id per read — replay_dead_letters() reads the queue twice per invocation (once to decide what to retry, again inside reconcile()), and a random per-read id would make every legacy entry's remove/update silently never match, leaving it stuck in the queue and risking a duplicate resend on the next retry (caught in review).

  • Concurrent GCS watermark writers silently discarded each other's updates (#919, PR #935 by @Pawansingh3889). GCSWatermarkStorage.save() loaded the whole watermarks blob, set one key on the resulting dict, and uploaded the whole blob back with no precondition. Two writes that overlapped therefore both read the same base object and the later upload won outright, dropping the other sync's watermark with no error anywhere. That sync then re-read from a stale cursor on its next run and re-processed rows it had already synced, which is silent duplicate work against any destination that is not naturally idempotent. delete() had the same shape. Both now use the standard optimistic concurrency loop: read the object's generation, apply the change, and upload with if_generation_match, so a write that lost its race fails with a 412 and is retried against freshly read state instead of overwriting it. The download is pinned to the generation just read, so the bytes and the precondition token cannot come from different versions of the object, and a first write to a bucket with no object yet asserts if_generation_match=0 ("only if still absent"). That read is itself two round trips, so it sits inside the retry boundary rather than before it: a competing writer landing between the reload() and the pinned download fails the download's own precondition, and because the object still exists that is a 412 rather than the 404 the read guards against. Caught at the same boundary as a lost upload, it costs one attempt and re-reads, instead of escaping save()/delete() as an unhandled PreconditionFailed, which is the one outcome WatermarkContentionError exists to avoid. Retries are bounded at 5 and exhausting them raises WatermarkContentionError rather than returning quietly, since a write that gives up in silence is the same failure this fixes. get() is unchanged, being a plain read with nothing to be conditional about. BigQueryWatermarkStorage was never affected: its save() is a MERGE, which the SQL engine already applies atomically per row. ⚠️ The write path now needs google-api-core (already a transitive dependency of the [gcs] extra) for its precondition exception types, resolved through the same lazy import the GCS client uses so a core install is unaffected. Found while reviewing ADR 0005, whose write-amplification note describes this same read-modify-write shape, so the approach here is a precedent for the remote state backend in #756.

  • Databricks mirror DELETE on a composite upsert_key (#908). Also shipped in 0.8.5.