FE-1625: Make the merged Brunch image deployable on ECS - #9573
Conversation
Bake the AWS RDS global CA bundle into the image and point BRUNCH_POSTGRES_TLS_CA_PATH at it, replace the app-owned OpenTelemetry setup with @local/hash-backend-utils/opentelemetry, drain the pool before telemetry shuts down, bound queries, keep error causes and log idle pool errors, add an OpenTelemetry diagnostic logger to the shared setup, and correct the README, handoff, probe and smoke checks.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 4 Skipped Deployments
|
PR SummaryMedium Risk Overview Telemetry drops a dozen direct Postgres adds query/statement timeouts, sequential pool-then-telemetry Reviewed by Cursor Bugbot for commit 3303de9. Bugbot is set up for automated code reviews on this repo. Configure here. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9573 +/- ##
==========================================
- Coverage 65.93% 65.93% -0.01%
==========================================
Files 1885 1885
Lines 198175 198176 +1
Branches 8230 8230
==========================================
Hits 130673 130673
- Misses 65972 65973 +1
Partials 1530 1530
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
The deployment smoke drops bearer authentication and can falsely accept an empty text-delta event.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Makes the Brunch image deployable on ECS by adding RDS trust configuration, shared telemetry, bounded database behavior, and stronger deployment probes.
Changes:
- Bundles the AWS RDS CA and hardens PostgreSQL startup/shutdown.
- Migrates Brunch to shared OpenTelemetry infrastructure.
- Adds request timeouts, stream validation, documentation, and tests.
File summaries
| File | Description |
|---|---|
yarn.lock |
Updates workspace dependency resolution. |
libs/@local/hash-backend-utils/src/opentelemetry.ts |
Enables warning-level OTel diagnostics. |
libs/@hashintel/brunch-agent/docs/evidence/implementations/mission-8-deployment-handoff.md |
Corrects publication targets. |
apps/brunch-agent/test/telemetry.test.ts |
Tests shared telemetry integration. |
apps/brunch-agent/test/postgres.test.ts |
Tests timeouts and shutdown behavior. |
apps/brunch-agent/test/deployment-smoke-validation.test.ts |
Tests assistant-text validation. |
apps/brunch-agent/test/container-smoke.ts |
Bounds the refusal smoke runtime. |
apps/brunch-agent/test/architecture/boundaries.integration.ts |
Updates the test allowlist. |
apps/brunch-agent/src/telemetry.ts |
Adopts shared OTel utilities. |
apps/brunch-agent/src/telemetry-bootstrap.ts |
Documents telemetry lifecycle. |
apps/brunch-agent/src/rds-iam-probe.ts |
Limits probe output. |
apps/brunch-agent/src/postgres.ts |
Adds query bounds and ordered shutdown. |
apps/brunch-agent/src/deployment-smoke.ts |
Adds request timeouts. |
apps/brunch-agent/src/deployment-smoke-validation.ts |
Requires a text-delta event. |
apps/brunch-agent/src/db.ts |
Unifies startup failure cleanup. |
apps/brunch-agent/README.md |
Documents deployment requirements. |
apps/brunch-agent/package.json |
Replaces direct OTel dependencies. |
apps/brunch-agent/docs/task-dependencies.json |
Records the new workspace dependency. |
apps/brunch-agent/docker/Dockerfile |
Bundles and configures the RDS CA. |
Review details
- Files reviewed: 18/19 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The shared backend utilities pull the type-system (wasm-pack) and graph client (openapi-generator) builds into Brunch's build graph, which the Node-only builder could not run. Mirror the API and worker images: prune with Cargo workspace stubs, install the Rust toolchain, and build with the same tool set and cache mounts. The deployment smoke now requires a text delta with non-whitespace content, so an empty text event cannot pass it.
🌟 What is the purpose of this PR?
#9487 landed the Postgres and telemetry code for Brunch, but the image it produces cannot start on ECS: it requires an RDS CA bundle that nothing provides, and its telemetry setup duplicates and diverges from the one
hash-apiand the workers share. This PR makes the image deployable for the staging rollout and aligns it with the rest of the backend.🔗 Related links
🚫 Blocked by
🔍 What does this change?
BRUNCH_POSTGRES_TLS_CA_PATHto it, the same way the Kratos and Hydra images do. Infrastructure only overrides the path for another CA.src/telemetry.tsnow usesregisterOpenTelemetry,createHttpInstrumentationandcreateUndiciInstrumentationfrom@local/hash-backend-utils/opentelemetryand keeps only the Flue wrapper. Brunch gains thepeer.servicemapping (Anthropic shows up in the service graph),METHOD /pathspan names and bounded provider shutdown; twelve direct@opentelemetry/*dependencies go away. Failure spans carry the error code (ECONNREFUSED, a SQLSTATE) aserror.typeinstead of the constructor name.registerOpenTelemetryinstalls aDiagConsoleLoggerat WARN, so exporter failures reach stderr in every Node service instead of the SDK's no-op handler.close()drains the pool before telemetry shuts down;query_timeoutandstatement_timeoutbound queries on dead connections; idle pool errors are logged to stderr by code; the CA read error keeps itscauseand code; a failed rollback releases the client before the reference is cleared.db.tswraps configuration and runner creation in one failure path that records the span, flushes telemetry and rethrows.turn-timing.test.tsallowlist entry is gone.Pre-Merge Checklist 🚀
🚢 Has this modified a publishable library?
This PR:
📜 Does this require a change to the docs?
The changes in this PR:
🕸️ Does this require a change to the Turbo Graph?
The changes in this PR:
turbo.json's have been updated to reflect thisturbo.jsonchange was needed; the new workspace dependency is reflected in the regenerateddocs/task-dependencies.jsonNODE_ENV: any value other thanproductionsilently selects SQLite.@local/hash-backend-utilsbrings its full dependency set into the image (Temporal, googleapis, Linear SDK). Accepted for now.test:dockerstill does not run in CI (SRE-1032), so the real Postgres, TLS and OTLP paths have no automated coverage.🐾 Next steps
@local/hash-backend-utilsinto a lean package shared byhash-api, the workers and Brunch.HASH_OTLP_ENDPOINTand theBRUNCH_POSTGRES_*variables, and give the task a stop timeout above 60 seconds.🛡 What tests cover this?
Build brunch-agentjobs on this PR exercise it) and any real Postgres or OTLP path (see SRE-1032).