Skip to content

fix(health): fail readiness fast on PG pool saturation - #503

Closed
samxu01 wants to merge 3 commits into
mainfrom
cody/health-ready-fast-fail
Closed

fix(health): fail readiness fast on PG pool saturation#503
samxu01 wants to merge 3 commits into
mainfrom
cody/health-ready-fast-fail

Conversation

@samxu01

@samxu01 samxu01 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

What changed

  • fail immediately when the PostgreSQL pool is already saturated instead of waiting on a timed-out
  • reuse a shared pool snapshot helper between and
  • add regression coverage for the new readiness behavior

Why

GH#454 is already fixed on by PR #455 plus the later summarizer/db-health follow-up. This PR addresses a smaller current gap next to that work: readiness should fail fast from pool state during saturation so Kubernetes can react immediately.

Test

�[41m �[0m
�[41m�[37m This is not the tsc command you are looking for �[0m
�[41m �[0m

To get access to the TypeScript compiler, �[34mtsc�[0m, from the command line either:

  • Use �[1mnpm install typescript�[0m to first add TypeScript to your project �[1mbefore�[0m using npx
  • Use �[1myarn�[0m to avoid accidentally running code from un-installed packages

@samxu01 samxu01 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. The only thing I'd flag is that the new readiness short-circuit duplicates the pool-saturation snapshot logic already used in /api/health/db; if this grows further, I'd extract a tiny shared helper for the readiness decision itself so the two endpoints stay aligned.

@samxu01 samxu01 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One-line second opinion: yes, fail-fast on pool saturation makes sense here, because readiness should reflect queue pressure before requests start timing out.

samxu01 added a commit that referenced this pull request Jun 29, 2026
…nly.me demo

Replace stale/weak screenshots with real, unedited captures of agents doing real
work, align the front door with the shared-memory wedge, and point the demo at
commonly.me.

- Landing "In action" leads with the real engineering flow: an agent ships PR
  #503 with a passing test, a teammate reviews it and flags real code duplication
  (was an idle pod-monitoring shot).
- README hero + table use real captures (real engineering, artifact generation,
  multi-runtime roster, identity/memory) — drops stale v1 feed/pods/task-board.
- Hero copy: drop off-message "social layer for agents and humans" →
  "the open-source workspace where your agents and team share one memory" + badges.
- Demo links app-dev.commonly.me → commonly.me (README hero + footer; repo
  homepage + description updated via gh repo edit).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
samxu01 and others added 2 commits June 29, 2026 03:03
…503)

Theo's review flagged that the PG-pool detail block was duplicated between
/api/health/db and /api/health/ready. Extract the shared {max,total,idle,
waiting,connectionTimeoutMillis} shape into one pgPoolDetail() helper called
from both — behavior identical, the two probes can no longer drift.

(Cody's codex-exec couldn't land the follow-up push reliably, so applied
directly; same author/branch as the original PR.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
samxu01 added a commit that referenced this pull request Jun 29, 2026
Adds /api/health/db (lightweight pool-stats probe, 503 on saturation) and makes
/api/health/ready fail fast when the PG pool is saturated (waiting>0 && idle===0)
— the signal that would have caught the 2026-05-26 pool-exhaustion incident
before user impact. Shared {max,total,idle,waiting,connectionTimeoutMillis}
detail extracted into one pgPoolDetail() helper so /db and /ready can't drift.
Includes a 90-line unit test for /ready saturation behavior.

Authored by Cody (cloud-codex) end-to-end; review note (extract the shared
helper) raised by Theo and applied as a follow-up.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@samxu01

samxu01 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

Squash-merged to main as 353763c (local squash + push). Theo's review note (shared pgPoolDetail helper) addressed; CI green.

@samxu01 samxu01 closed this Jun 29, 2026
@samxu01
samxu01 deleted the cody/health-ready-fast-fail branch June 29, 2026 10:13
samxu01 added a commit that referenced this pull request Jun 29, 2026
OpenClaw agents (Theo/Nova/Pixel/Ops) have no shell — they triage, review, coordinate, and research. Only Cody (Codex runtime) authors code and opens real labeled PRs (e.g. #503). Credit code authorship to Cody and reframe the OpenClaw agents accordingly, matching the hedged landing copy and docs/agents/AGENT_CODING_CAPABILITY.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_019vuFLFHnmJKmMxosHSWA4P
samxu01 added a commit that referenced this pull request Jun 29, 2026
#528)

Fails a pull_request against main when its merge-base has drifted more than MAX_BEHIND (40) commits behind origin/main, forcing a rebase before merge. Codifies the stale-base squash-merge footgun that silently reverted intervening merged work (#503 clobbered #506/#507).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_019vuFLFHnmJKmMxosHSWA4P
lilyshen0722 added a commit that referenced this pull request Jul 2, 2026
…erged #542

The README pointed its real-work proof at PR #503, which was closed/reverted (the
stale-base squash-merge incident). The live showcase pod ("Commonly Engineering")
actually features PR #542 — Cody extending a Cloudflare-aware rate-limit fix across
the auth/uploads/showcase routes, with Theo reviewing. Point both README references
at #542 so the marketing claim matches the real, merged, showcase-featured exchange.
lilyshen0722 added a commit that referenced this pull request Jul 2, 2026
 to #542

Consistent with the README re-anchor — link a merged, live PR instead of the
closed/reverted one.
samxu01 added a commit that referenced this pull request Jul 2, 2026
… + button contrast (#555)

* fix(showcase): resolve the showcase pod id at build + fix blue-button contrast

The public "Watch a live room" CTA was dead in production — it rendered "This room
isn't public" because the deployed frontend requested
`/api/showcase/__SHOWCASE_POD_ID__` (the literal placeholder). Root cause: vite's
`define: { 'process.env': {} }` clobbers all process.env reads, and only
REACT_APP_API_URL had an explicit passthrough — REACT_APP_SHOWCASE_POD_ID did not,
so V2Showcase fell back to the '__SHOWCASE_POD_ID__' sentinel. (Same trap the
API_URL comment already documents.) The showcase API + pod are fine — publicRead:true,
4 members; only the client id substitution was broken.

- vite.config.ts: add `'process.env.REACT_APP_SHOWCASE_POD_ID'` to `define` (the
  Dockerfile + CI already pass it as a build arg/env).
- v2-showcase.css: `.v2-showcase__btn--primary` rendered dark-on-blue — the
  `.v2-root a { color: inherit }` (0,1,1) trap beat the single-class #fff rule.
  Re-assert with a `.v2-root` prefix (0,2,0). "Sign up to join" / "Start your own
  room" now compute white (verified live).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MnRCAFgjrrGZxo9VRCmCm9

* docs(readme): re-anchor the "real work" proof from reverted #503 to merged #542

The README pointed its real-work proof at PR #503, which was closed/reverted (the
stale-base squash-merge incident). The live showcase pod ("Commonly Engineering")
actually features PR #542 — Cody extending a Cloudflare-aware rate-limit fix across
the auth/uploads/showcase routes, with Theo reviewing. Point both README references
at #542 so the marketing claim matches the real, merged, showcase-featured exchange.

* docs(agents): re-anchor the coding-capability example from reverted #503 to #542

Consistent with the README re-anchor — link a merged, live PR instead of the
closed/reverted one.

---------

Co-authored-by: Lily Shen <ls111@rice.edu>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
samxu01 added a commit that referenced this pull request Jul 2, 2026
…exchange (#556)

The old marketing shot was anchored to the reverted #503 story. Recaptured from the
now-working public showcase (fixed in #555): the real PR #542 thread — founder flags
that routes/showcase.ts still keys its rate-limiter on req.ip; Theo triages; Cody
patches it (8e484cd) swapping in cloudflareIpRateLimitKeyGenerator across all three
routes; Theo reviews with real depth (shared ipRateLimit.ts reduces duplication, the
CJS/ESM module.exports shim is intentional) and ships it.

Matches the re-anchored README/agent-docs (#542, not #503). Both copies updated
(screenshots/ for README, assets/landing/ for the bundled hero). Captured from
commonly.me/v2/showcase.


Claude-Session: https://claude.ai/code/session_01MnRCAFgjrrGZxo9VRCmCm9

Co-authored-by: Lily Shen <ls111@rice.edu>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant