Repository navigation
feat(api): answer GET /healthz?deep=1 from one SELECT now() through the database - #332
Merged
Merged
Conversation
…he database `/healthz` answered `ok` without touching the database, so the availability SLO (99.5 % over 30 days) could not see the tunnel, woven-o11y or the Workers VPC that the product now depends on (ADR-0094, Q-0094.4). With `?deep=1` it now runs one statement through the database and answers 200 `ok`, or 503 `unavailable` with no word of why; the cause goes on the response as `InternalErrorDetail`, which both roots already log. Both deep answers are `no-store`. Plain `/healthz` is unchanged and still never asks the database for a connection. * `Database::ping(&SystemScope)` is a required port method (no default body: an adapter that forgot it would report healthy). The memory adapter answers `Ok`; the Postgres adapter sends `SELECT now()` through the typed, counted path. It is `now()` and not `1` because Hyperdrive can answer a read from its cache when the read uses only IMMUTABLE functions, and `now()` is STABLE. * `thrust_core::ping_database` is the use-case, because the `SystemScope` stays private to `App`. * The query is read with `RawQuery` and `form_urlencoded`, which cannot reject: the deploy's smoke (`?smoke=N`) and the edge's controls (`?edge-control=...`) send their own query strings to `/healthz` and need the 200. Any query with a `deep=1` pair is deep. Tests: `crates/api/core/tests/healthz.rs` drives the router with `oneshot`, over every query of up to two pieces from a table it owns, crossed with a database that is up, one that is down (`PgDatabase` over a `Connector` that refuses, which also counts checkouts) and no `App`, plus a generated variant. `thrust-core` and the Postgres adapter each have a `prop_` test of their own (the memory adapters cannot fail, so without them `ping_database -> Ok(())` would survive). The counting model against a real Postgres gained a `ping` step: one statement, in or out of an open transaction. The contract test `deep_healthz_reports_the_database` runs on every target and reads `x-thrust-db-round-trips` (1 for deep, 0 for plain); the expected main-pass counts go from 74 to 75 and stage 2's from 68 to 69. Shown failing: `cargo mutants` on the handler (10 mutants, 8 caught, 2 do not compile), on `ping_database` and on `PgDatabase::ping`; six defects planted by hand in the handler, each killed; the contract test against the old behaviour on native-memory (74 passed, 1 failed). Passing locally: native-memory and native-pg main passes (75/75), the deps and lint jobs' checks, 2442 hermetic tests. Not run locally: the worker-memory and worker-cf cells (the installed worker-build is 0.8.7 and CI pins 0.9.0); CI runs them. Refs: #42 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…CT now() SPEC §6.4 (line 89) still said the availability probe runs `select 1` through Hyperdrive. ADR-0094 round 29 and the issue always said `SELECT now()`, because Hyperdrive can answer an IMMUTABLE read from its cache. The line now says so and why. * `docs/src/flows/app.md`: a `GET /healthz?deep=1` row, and the note that any other query string is ignored. * `docs/src/architecture/app.md`, `docs/src/contributing/patterns.md`: `ping` joins the calls that take a `SystemScope`. * `docs/src/testing/status.md`: G-3 no longer says `thrust-api` has no tests of its own, and G-48 records what covers the deep check, what was shown failing, and what is not shown (a database that is down is shown in process only, by the owner's decision). * `docs/src/testing/by-change.md`: the `oneshot` router-test gap is closed for `thrust-api` itself. Refs: #42 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
aRustyDev
temporarily deployed
to
preview-control-plane
November 19, 2026 04:48 — with
GitHub Actions
Inactive
One conflict, in docs/src/testing/status.md: #330 added a G-48 row (the `deep` nextest profile) while this branch added a G-48 row for the deep health check. Main's row keeps G-48, since it landed first and other files already cite it (`test_support.rs`, the ci-workflows plan). This branch's row is now G-49, and the one place this branch cites it (the contract test's doc comment) says G-49. Nothing else conflicted. Checked on the merged tree: fmt, 2456 tests of thrust-api, thrust-core and the two adapters, check-deps, check-cargo-lock, check-contract-counts and `cargo metadata --locked`. Refs: #42 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
aRustyDev
temporarily deployed
to
preview-control-plane
November 19, 2026 05:16 — with
GitHub Actions
Inactive
Merged
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.
Refs #42
What
GET /healthz?deep=1runs one statement through the database and answers 200ok, or 503unavailablewith no word of why. Plain/healthzis unchanged and still never asks the database for a connection. This is the code half of #42; thestatus.wovenprobe line is a separate change in the infrastructure repository and goes in after this is released (it would be red until then).Database::ping(&SystemScope), required (no default body, so an adapter that forgot it cannot report healthy). Memory answersOk; Postgres sendsSELECT now()through the typed, counted path.now()and not1, because Hyperdrive can answer a read from its cache when it uses onlyIMMUTABLEfunctions.thrust_core::ping_database, because theSystemScopestays private toApp.RawQuery+form_urlencoded, which cannot reject, becausescripts/smoke-deploy.sh(?smoke=N) andscripts/edge-controls.sh(?edge-control=...) send their own query strings to/healthz. Anydeep=1pair makes the request deep. The 503 body is the fixed wordunavailable; the cause goes on the response asInternalErrorDetail, which both roots already log. Both deep answers areno-store.select 1; it now saysSELECT now()and why (ADR-0094 and the issue always said so). Flows, architecture and patterns pages,status.md(G-3 was stale, new G-49) andby-change.md.Tests
crates/api/core/tests/healthz.rs: the router withoneshot, over every query of up to two pieces from a table the test owns, crossed with a database that is up, one that is down (PgDatabaseover aConnectorthat refuses and counts checkouts) and noApp; plus a generated variant.crates/core/usecases/tests/health.rsandcrates/adapters/postgres/tests/ping.rs:prop_tests (the memory adapters cannot fail, so without theseping_database -> Ok(())survives).pingstep: exactly one statement, in or out of an open transaction.deep_healthz_reports_the_databaseon every target, readingx-thrust-db-round-trips(1 for deep, 0 for plain; absent on memory). Main-pass counts 74 to 75 and stage 2's 68 to 69.Controls (a check that cannot fail is not evidence)
asks_for_deepforced tofalse) on native-memory: 74 passed, 1 failed, at theno-storeassertion.cargo mutants: handler 10 mutants, 8 caught, 2 do not compile;ping_databaseandPgDatabase::ping: theOk(())mutant is caught.no-store, a body that carries the cause, a cause that is not logged, a 500 for the 503, a missingAppanswered healthy, a ping that is skipped): each killed.Run locally
native-memory and native-pg main passes 75/75; the
depsandlintjobs' checks (all ofscripts/check-*, fmt, clippy for the workspace and wasm32,cargo deny,cargo metadata --locked); 2442 hermetic tests; the Docker counting model.Run in CI, not locally
worker-memoryandworker-cfcells: the installedworker-buildis 0.8.7 and CI pins 0.9.0 (theworkercrate is 0.9), and replacing a shared global tool was not mine to do. CI ran them on the previous head (52c985c):worker-cf mainandworker-memory mainboth 75/75, the requiredgategreen and every one of the 48 checksSUCCESS; the merge ofmainbelow re-runs them.Still not shown
A database that is down is shown in process only (no contract pass stops a database, by the owner's decision: a
dbdownpass would be a cell on nearly every Rust PR); G-49 says so.Merge of
main#330 landed a G-48 row of its own (the
deepnextest profile) while this branch added one for the deep health check. Main's keeps G-48, since other files already cite it; this branch's row is G-49. Nothing else conflicted, and the merged tree passes fmt, 2456 tests of the four crates,check-deps,check-cargo-lock,check-contract-countsandcargo metadata --locked.After this merges
curl -sD- 'https://thrust.sow.foo/healthz?deep=1'answers 200okwithcache-control: no-store.Data & Appsline inshared/aws/status-page/files/gatus.yaml, with a temporary wrong-path control (red, then green).Separately, #328 records that the uptime history lives only on the status page's own server.
🤖 Generated with Claude Code