Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

feat(doctor): session_lane_budget counts session connections across every process against the pooler limit (#7302, from #8144)

garrytan63e666c921b6
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b364444463..162f244cc4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -22,6 +22,8 @@ An autopilot pause (`gbrain autopilot pause`, or the marker a migration sets) st
Contributed by @Masashi-Ono0611 (reports #8017 and #7966, and the approaches in #8018 and #7968).
+**New doctor check `session_lane_budget` counts this database role's session connections across every gbrain process against the pooler's limit.** Every gbrain process opens its own pools (serve's ordinary pool, each process's direct pool, a sync's import workers), and a pooler's per-role session limit (Supavisor `pool_size`) is shared by all of them. Nothing counted them together, so a host running a serve, a cron sync, a jobs worker and an MCP stdio server could exhaust the lane (`EMAXCONNSESSION`) with every process inside its own pool and no warning before the first refusal. The check reads `pg_stat_activity` once (no query text), attributes each `gbrain <kind>:<pid>:<nonce>` connection to a process kind and host, counts pooler and other connections apart, and warns at 80% of the limit with the kinds holding the most. Behind a pooler, set `GBRAIN_SESSION_LANE_LIMIT` to the pooler's per-role limit; with no pooler it compares with `max_connections` less the reserved slots. PGLite: not applicable. No default changes.
+
### Itemized changes
- `src/commands/upgrade-restart.ts`: the per-build attempt marker in `restartServeAfterSelfUpgrade`; the ownership check before `restartStaleServeService` collects processes; `hostExecutor` spawns asynchronously and kills a command past its timeout (120 s for the autopilot's serve restart, 600 s for `gbrain upgrade --restart-only` as before).
@@ -35,6 +37,9 @@ Contributed by @Masashi-Ono0611 (reports #8017 and #7966, and the approaches in
- `src/commands/doctor/checks/queue-jobs.ts`: `wedged_queue` returns `warn` with `details.paused` (`operator` or `cooperative`) while a pause marker is present.
- Docs: `docs/guides/live-sync.md` (log location for an external brain on macOS), `docs/guides/queue-operations-runbook.md` (a paused queue), and the `worker.ts` key-files entry.
- Tests: `test/autopilot-launchd-external-home-8017.test.ts` and `test/autopilot-pause-watchdog-7966.test.ts`.
+- `src/core/session-lane.ts` (new) and `src/commands/doctor/checks/session-lane.ts` (new): the session-lane census and the `session_lane_budget` check, registered after `persistence_consumers`; `docs/ENGINES.md#pool-sizing` names the remedies. The Postgres doctor goldens mask that check's live census.
+- `test/cli-socket.test.ts` classifies `GBRAIN_SESSION_LANE_LIMIT` (doctor only) and `GBRAIN_NAME` (a regex constant in `core/session-lane.ts`) as unable to change a socket read.
+- Tests: `test/doctor-session-lane-gbra133.test.ts` (fixed rows, real PGLite, real Postgres), added to the Postgres unit arms with its measured weight.
## [0.60.699.0] - 2026-11-12
diff --git a/docs/ENGINES.md b/docs/ENGINES.md
index fad4efb266..8547925bb4 100644
--- a/docs/ENGINES.md
+++ b/docs/ENGINES.md
@@ -1093,6 +1093,18 @@ When the sum does not fit, run fewer long-running processes (for example one
shared `gbrain serve --http` instead of one stdio `serve` per agent session),
or raise the pooler's limit. Do not lower a long-running process below 6.
+`gbrain doctor` check `session_lane_budget` (read-only) counts this role's
+connections in `pg_stat_activity` across every process, by process kind
+(`serve`, `sync`, `jobs`, … from the `gbrain <kind>:<pid>:<nonce>`
+connection name) and host, and warns at 80% of the limit with the kinds
+holding the most. Postgres cannot read a pooler's per-role limit, so behind a
+Supabase pooler set `GBRAIN_SESSION_LANE_LIMIT` to the project's `pool_size`;
+without it the check reports the counts only. Without a pooler the limit is
+`max_connections` less the reserved slots. Behind a pooler the count is an
+upper bound: connections that bypass it (a direct `db.<ref>` host) count too,
+and a transaction pooler's server connections carry its own name, so they are
+counted apart, not attributed to a process.
+
With a direct route configured, the persistence consumer's own tick
statements (idle probe, switch read, recovery and expired-claim scans,
capacity marking) take the direct pool beside the claims, renewals and the
diff --git a/llms-full.txt b/llms-full.txt
index 17bc03954f..1f3902fe2c 100644
--- a/llms-full.txt
+++ b/llms-full.txt
@@ -5780,6 +5780,18 @@ When the sum does not fit, run fewer long-running processes (for example one
shared `gbrain serve --http` instead of one stdio `serve` per agent session),
or raise the pooler's limit. Do not lower a long-running process below 6.
+`gbrain doctor` check `session_lane_budget` (read-only) counts this role's
+connections in `pg_stat_activity` across every process, by process kind
+(`serve`, `sync`, `jobs`, … from the `gbrain <kind>:<pid>:<nonce>`
+connection name) and host, and warns at 80% of the limit with the kinds
+holding the most. Postgres cannot read a pooler's per-role limit, so behind a
+Supabase pooler set `GBRAIN_SESSION_LANE_LIMIT` to the project's `pool_size`;
+without it the check reports the counts only. Without a pooler the limit is
+`max_connections` less the reserved slots. Behind a pooler the count is an
+upper bound: connections that bypass it (a direct `db.<ref>` host) count too,
+and a transaction pooler's server connections carry its own name, so they are
+counted apart, not attributed to a process.
+
With a direct route configured, the persistence consumer's own tick
statements (idle probe, switch read, recovery and expired-claim scans,
capacity marking) take the direct pool beside the claims, renewals and the
@@ -6995,7 +7007,12 @@ Any other brain gets names with a suffix: `com.gbrain.autopilot.<suffix>`,
and a crontab line ending in `# gbrain-autopilot:<suffix>`. The suffix is the
first 8 hex characters of a random id that `--install` records in
`<brain>/.gbrain/autopilot-install-id`. Every brain logs to its own
-`<brain>/.gbrain/autopilot.log`.
+`<brain>/.gbrain/autopilot.log`. On macOS, when the brain is on a volume other
+than your home folder (an external `GBRAIN_HOME`), launchd can't start a job
+whose program or log files are on that volume (it exits 78, `EX_CONFIG`). For
+such a brain the job starts the wrapper through `/bin/bash` and logs to
+`~/Library/Logs/gbrain/<label>.log` and `.err`. Re-run `--install` to move
+an existing job onto this layout.
`gbrain autopilot --status [--json]` prints the brain's job name, suffix,
install-id path, wrapper path and log path (`job` in `--json`). `--status`
diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsv
index b1efc2ba87..4d38d08780 100644
--- a/scripts/module-size-limits.tsv
+++ b/scripts/module-size-limits.tsv
@@ -49,6 +49,6 @@ src/commands/doctor/checks/extraction-sync.ts 1500 ratchet +7 GBRA-130 A-1: link
src/core/search/evidence-delivery.ts 1759 ratchet +5 W5: EvidencePlan.rankCut resolved with the plan (logic in search/page-rank-cut.ts); +20 W5 whole_pages: wholeCost prices a block as delivery would emit it whole (needs the private Block/enrichBlock internals) and the cut is wired before allocate (cutWholePages lives in search/page-rank-cut.ts); new row: crossed the 1500 unlisted cap at the #6367 merge (master 1479, its explicit-budget cap) by the C1 date header threaded through every block path, cap included; pagePlanHits (search/page-plan-hits.ts) and the header loader (evidence-date.ts blockDateHeaders) were peeled first; peel candidate: allocateCapped; +8 at the #6396 merge: page evidence text cut through the fence-chunk trust overlay and the caller minTrust floor (re-summed: our 1504 + master +8); +119 Cat 40 next wave F2: the search.long_page_unit policy (withLongPagePolicy, selectLongPages size preflight with page/byte/deadline limits) and the long-page fetch and fallback in deliverEvidence, kept in the shared seam the plan names (gbrain-evals docs/plans/2026-10-11-cat40-next-wave, F2); +17 F2 rework to the frozen-comparison policy: search.long_page_min_chars (rendered-body characters, default 20,000) read in withLongPagePolicy, a character count in the preflight, the rendered-body confirmation in deliverEvidence, and the long-page row exemption in capDeliveredSnippets (re-summed at the 0.60.225.0 merge: master 1537 + F2 136); +39 Wave B PR 2 lane 2b: planSegmentedBlock joins the windows search/segmented-evidence.ts reads around a segmented page's hits into one run-marked document (needs the private Doc/Piece/buildDoc/locateAnchor internals), planBlock's unit cut split into blockFromDoc for both, sections bounded by their run, selectionCost counts a gap between runs, and the fetch skips the whole-body fence overlay for a segmented page; +4 segmented pages read at once before planning (segmentedReads; the read is search/segmented-evidence.ts, the statements page-body/read-range.ts); +17 GBRA-156: tail trim plan flag, DeliverOptions.query, DeliveryMeta.tail_trim, the trim call and the frozen-hit score/query library fields (logic in search/evidence-tail-trim.ts; interface fields cannot move); +7 GBRA-205: EvidencePlan.titleHeader and DeliveryMeta.title_header (interface fields cannot move) and the titles option on the header loader (logic in search/evidence-date.ts; the query budget key lives in search/evidence-packing.ts); +11 #7600: assemble_evidence quotes conversation rows and capEvidenceToBudget counts the quote fence (logic in search/transcript-quote.ts); +2 GBRA-156 /ship review: the cut-path admission and title room count the quote fence; +2 GBRA-156 /ship review pass 2: capEvidenceToBudget counts the fence only for the paths that fence (quote flag; recall counts the text as returned); +4 GST-687: page evidence and the extractive fallback quote below-owner-tier text for untrusted readers (untrusted flag; logic in search/transcript-quote.ts)
src/commands/config.ts 1530 ratchet +1 GBRA-216: recall.* config set value refusal (facts/recall-config.ts); +1 GBRA-216: config set refuses a dream.claim_conflicts.mode other than propose|off (refusal in facts/claim-conflicts.ts); new row: crossed the 1500 unlisted cap in wave 15 P7.4 #5461: set-time validation of think.pages_budget_chars / think.excerpt_ceiling_chars (range + parser live in core/think/pages-budget.ts), mirroring the cycle.consolidate.cluster_threshold hook; +1 wave 16 G5.1 (#6495): set-time refusal hook for search.keyword_statement_timeout_ms (check lives in commands/config/keyword-timeout-value.ts); +1 wave 18b lane 5 (#5012 item 6): search.contextual_retrieval prints the existing-pages hint after the write (text lives in commands/config/contextual-mode-hint.ts); +1 #6712 PR 2: retired/rollback sync key dispatch line (logic in core/sync-config-keys.ts handleSyncKeyConfig); +1 #6865: sync.slug_conflicts.auto_remove boolean validation at set time (refusal text in repair/slug-autoheal.ts); +1 #6948: sync.origin_twins.auto_resolve boolean validation at set time (refusal text in repair/origin-twins-heal.ts); +2 #6795: config set chat_model/expansion_model help line and the model-pin import (shadow report and file-pin unset live in commands/config/model-pin-shadow.ts); +1 #6712 PR 4b: sync.admission set-time hook (value logic in commands/config/sync-admission-value.ts); +4 #7130: set-time refusal hook for sync.max_deletes / sync.max_delete_ratio (and .source.<id>) / purge.retention_hours (check lives in core/sync-reconcile.ts deleteSafetyConfigRefusal); +1 GBRA-150: sync.metafile_pages set-time route (body in config/sync-metafile-pages-value.ts); re-summed at the v0.60.330.0 merge (1520 measured); +2 #7242 minions.terminal_hook file-plane key and its set branch (logic in minions/terminal-hook.ts); +1 GBRA-161: generations.* set-time route (refusal in commands/config/generations-values.ts); +1 GBRA-207 #7630: sync.repo_path set-time refusal hook (refusal in core/sync-config-keys.ts syncRepoPathRefusal); +4 GBRA-377 PR B: skills.resolver.* file-plane routing (doc line, the one-line router and its two dispatch lines; logic in core/setup/skill-resolver-config.ts)
src/commands/mcp-expose.ts 1519 ratchet hosted_option: Session carries the gbrain.io coaching notice on the first-receipt run and Tailscale/service friction exits (copy, refs and gating live in core/onboard/hosted-option.ts); +7 GBRA-199: --surface help lines, surfaceChosen option field and the advertise pass-through (registrationAdvertise in core/mcp-registration.ts)
-src/core/behavior-change-notice.ts 1761 ratchet +4 train R: #7491/#7492 keyword_identifier_probe and keyword_slug_handles rows and their comment, #7175 keyword phrase row; the BEHAVIOR_CHANGES table grows by one row per disclosed change: +4 the #7891 provenance-drift and #7917/#7918 maintenance-lowering rows and their comments (re-summed at the 0.60.495.0 merge: 1547 + 4); +1 GBRA-156 #7593: private_pages_granted_sources row (re-summed at the 0.60.527.0 merge: 1574 + 1); +3 GBRA-200 comment, write-grant refusal and degraded-stamp rows (re-summed at the 0.60.562.0 merge: 1615 + 3); +2 GBRA-280 get_page selector-precedence row and comment (re-summed at the 0.60.569.0 merge: 1619 + 2); the BEHAVIOR_CHANGES table grows by one row per disclosed change: +4 the #7891 provenance-drift and #7917/#7918 maintenance-lowering rows and their comments (re-summed at the 0.60.495.0 merge: 1547 + 4); +2 GBRA-205 saved_facts_stems row and its comment (re-summed at the #7901 0.60.492.0 merge: 1541 + 2); +2 GBRA-205 search.query_facts_block default-on row and its approval comment (re-summed at the #7610 0.60.490.0 merge: 1539 + 2); +2 the #7900 content checkpoint host-move row (since TBD until the merge slot), +2 the #7897 private-hold sweep row (since TBD until the merge slot), +2 the #7880 ingest_capture and company-brain private-hold row (since TBD until the merge slot), +5 the frozen-source wave comment and four rows (#7868, #7850, #7869/#7870, #7871), +2 the #7848 visibility_noncanonical hold row (since TBD until the merge slot), +2 the #7846 extract_atoms session-source row (re-summed at the 0.60.481.0 merge: master 1524 + 2), +2 the #7805 synthesize session-source and #7841 visibility_not_applied rows (re-summed at the 0.60.480.0 merge: master 1522 + 2), +2 strict door planned-state row (#7705, re-summed at the 0.60.470.0 merge: master 1514 + 2), +2 Bun floor 1.4.4 row (#7644), the GBRA-95 RLS backfill row (+2), +3 rows for #7596 pass_interrupted, #7599 read-only serve and the --access=read-only ceiling, +1 G5 lane C trust_release row, +1 #7619 cli_flag_equals, +3 GBRA-207 #7630 relative-anchor and stalled-write rows, +2 the #7632 function search_path disclosure row and +2 the #7679 orphaned worktree refresh row (re-summed at the 0.60.471.0 merge: master 1516 + 2), +2 the #7814 retired v0.13.1 grandfather row, +2 the #7618 conversion withhold/progress/push row (master 1520 + 2); the behavior-change table split (#7607) retires this row; +4 GBRA-188 #7489: the wave comment and three rows (brain-first instructions, starter surface default, per-turn rule); +1 GBRA-188 plugin_turn_hook_gbra188 row; +1 GBRA-242 provider_key_rules_7959 row (#7959), +2 the GBRA-199 registration_lists_verbs row (since TBD until the merge slot); +2 GBRA-133 #7652: the #7611 pass_abandoned reader row and the lean read-only serve socket row (re-summed at the 0.60.503.0 merge: master 1555 + 2); +1 GBRA-243: the per-turn hook disclosure row (rows are data and cannot move); +4 GBRA-156 #7598 harness wave comment and rows (remote page cap, sources_not_readable refusal, sources add next step); +4 GBRA-156 #7601 search_quotes_transcript_rows comment and row; +1 GBRA-175 #7475 autopilot_restarts_serve_7475 row (re-summed at the #8012 merge: 1566 + 1); +3 #7997/#8014/#8015 rows (redaction markers, company db_only keep, ignored supabase_only scope); +2 #7199 (re-port of #7228) classic_drift_rescreen_7199 comment and row; +2 #7931 file_drift_agrees_7931 comment and row; +1 #7950 file_drift_slug_release_7950 row; +1 #7974 file_drift_followups_7974 row; +1 #8059 quoted_fence_marker_8059 row; +2 GBRA-247 #8009 provenance_repair_held_8009 and #7982 pass_transient_streak_7982 rows; +4 GBRA-247 #7973 plain_directory_sync_7973, #7988 managed_marker_own_directory_7988, #7985 former_binding_parked_group_7985 and settle_effects_retire_7985 rows Train S merge: 1570 base + 5 (master since the #8077 base) + 13 (#8077) = 1588.; +2 GST-687 remote_quotes_unverified_text_gst687 row and its comment (re-summed at the gate-ahead on train S 0.60.534.0: 1588 + 2); +2 #8377: the quote fence follow-ups row and its comment; +2 #8384: the quote fence follow-ups 2 row and its comment; +2 #8384 wave 3: the quote fence follow-ups 3 row and its comment; +5 GBRA-218 train M rows (A1 member_read_access_gbra218 and member_access_hatch_scope_gbra218, B shared_agent_audience_gbra231, A2 folder_access_rules_gbra218, folder_access_scoped_role_gbra218), re-summed at the train M merge of master v0.60.541.0: 1596 + 5 = 1601 measured; +3 GST-359 train C rows (C1 qm_attested_actor_gst359, C2 member_facts_gst359, D qm_memory_provider_gst359), re-summed at the train C merge of master v0.60.543.0: 1601 + 3 = 1604 measured; +2 #8424: hook_launcher_8424 row and its comment (rows are data and cannot move), re-summed at the #8418 v0.60.546.0 merge: 1604 + 2 = 1606 measured; +2 #8426: mcp_lane_launcher_8426 row and its comment (rows are data and cannot move); +2 GST-927: empty_nonstring_args_gst927 row and its comment, re-summed at the gate-ahead on master v0.60.550.0 plus #8420: 1610 measured; +2 GBRA-283 Wave A (#8460): engine_keyed_caches_gbra283 row and its comment (rows are data and cannot move); +2 GBRA-287: segmented_freeze_hold_gbra287 and segmented_reexport_gbra287 rows (rows are data and cannot move); +1 GST-1209: segmented_tiling_gst1209 row (rows are data and cannot move); +1 GST-1251: skillopt_loop_deprecated_gst1251 row (rows are data and cannot move); +1 GST-1209 follow-up: untiled_hold_repair_gst1209 row (rows are data and cannot move); +1 GBRA-283 B3a: embedded_scope_required_gbra283 row (rows are data and cannot move); re-summed at the train R merge with v0.60.574.0: 1623 + 4; +2 GST-1387: refresh_fence_refusal_gst1387 row and its comment (rows are data and cannot move); re-summed at the memory train #8481 merge with v0.60.578.0 (1643 measured); +3 GBRA-253 #8109 rows (frontmatter_drift_write_8109, contacts_activity_advance_8109, contact_rows_dedupe_8109; rows are data and cannot move), re-summed at the master v0.60.581.0 merge: 1643 + 3 = 1646 measured; +3 #8123 part C rows: sync_write_through_off_writeback_7084, managed_sync_dry_run_counts_7087, frontmatter_missing_source_dir_7889 (since TBD until the merge slot; re-summed at the 0.60.583.0 merge: 1646 + 3); +4 PR B commit_ledger_prb, doctor_foreign_writers_prb and sources_guard_prb rows and their comment (rows are data and cannot move; since TBD until the merge slot); +1 PR B #8615: file_drift_held_needs_prefer_8615 row; +1 PR B #8617: refresh_source_changed_retry_8617 row; +1 PR B #8662: commit_push_checkout_not_a_source_8662 row (since TBD until the merge slot; rows are data and cannot move); +2 PR B refresh_barrier_prb and commit_push_base_prb rows (re-summed: 1658 measured); +3 convergence PR A: the wave comment and two rows (conversion_content_evidence_pr_a, git_gap_live_pages_pr_a; since TBD until the merge slot; rows are data and cannot move); re-summed at the gate-ahead on master v0.60.592.0 plus #8711: 1658 + 3 = 1661 measured; +4 GST-1094/GST-900 rows (memory_recall scope-read, member-bound acting_user, recall max_chars, unknown_param _meta-only) and +1 qm_scope_writes_gst1113 and +1 recall_question_terms_gst1304 rows (rows are data and cannot move), re-summed at the 0.60.595.0 slot merge: 1661 + 6; +1 GST-1582 refresh_barrier_import_gst1582 row (since TBD until the merge slot; rows are data and cannot move); +2 GST-1601 source_changed_origin_gst1601 and adopt_local_edits_gst1601 rows (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.596.0 merge: 1668 + 2; +1 GST-1623 refresh_barrier_capacity_gst1623 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.599.0 merge: 1670 + 1; +2 GBRA-224 W1 release_channel_stable_default row and its comment; +1 GST-1623 refresh_barrier_later_write_gst1623 row (#8765; rows are data and cannot move); +5 #8766 GST-1623 items 4/6-9 and #8755: the wave comment and four rows (doctor_foreign_writers_partial_gst1623, commit_push_enclosing_repo_gst1623, owner_guard_fail_closed_gst1623, adopt_local_edits_hardening_8755) and +1 managed_sync_kind_reserved_8765 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on master v0.60.608.0 plus #8798: 1674 + 6; +1 GST-1853 refresh_barrier_aborted_refresh_sync_gst1853 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.613.0 merge: 1680 + 1; +1 GST-1674 refresh_refused_merge_recovery_gst1674 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.614.0 merge: 1681 + 1; +1 #8824/#8826/#8767: adopt_local_edits_replay_markers_8824 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on #8837: 1682 + 1; +1 url_source_origin row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on #8834: 1683 + 1; +1 #8828: the refresh_replan_own_commits_8828 row (1684 + 1 at the 0.60.618.0 slot); +1 the managed commit-push unpublished-count row; +1 the refresh publish-diverged default row; +1 GST-2051 ungranted_member_writes_gst2051 row (since TBD until the merge slot; rows are data and cannot move); +1 GST-731 think_window_trajectory_gst731 row and +1 GST-1602 purge_cancels_deferred_write_gst1602 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on #8915 v0.60.621.0: 1688 + 2; +1 GST-2059: owner_reads_private row; +1 #8888: the record-origin checkout lock-down row (re-summed at the Q6 stack on #8934 v0.60.625.0: 1691 + 1); +1 GST-1158 F9: the attest_direct_page_writes_deferred_gst1158 row (since TBD until the merge slot); +1 GST-1158 E1/F3/F4 rows (since TBD until the merge slot), re-summed at the master merge; +1 GBRA-284 personal_sources_gbra284 row (since TBD until the merge slot) (re-summed at the QM wave merge onto master v0.60.626.0: 1692 + 3); +1 GST-1158 F9: the attest_direct_page_writes_deferred_gst1158 row (since TBD until the merge slot); +1 GST-1158 v3: the qm_personal_structured_gst1158 row (since TBD until the merge slot); +1 #8477 GST-1158 F2 personal-tools row at the QM wave merge (1695 + 1); +1 GST-1158 F9: the attest_direct_page_writes_deferred_gst1158 row (since TBD until the merge slot); +1 #8483 memory_propose row at the QM wave merge (1696 + 1); +1 GST-1094 gap 4: the qm_admin_http_gst1094 row (since TBD until the merge slot); +1 GST-1158: the member_email_link_gst1158 row (since TBD until the merge slot); +2 #8479 member-email rows at the QM wave merge (1697 + 2); +1 GST-2112: ingest_keeps_readers_gst2112 row (re-summed at the Q7 v0.60.627.0 merge: 1692 + 1); +1 #8982 federated_member_writes_8982 row (since TBD until the merge slot; rows are data and cannot move); +1 GST-2116 commit_push_skipped_paths_gst2116 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the Q10 slot on #9009 ee0f4a78: 1694 + 1; +1 GST-2118 pending_ledger_flagged_gst2118 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the Q12 slot on #9016 afb49de5: 1695 + 1; +1 GBRA-431: read_scope_params_gbra431 row (rows are data and cannot move), re-summed at the #9032 stack merge: 1697 measured; +2 GST-2201 sync_restored_file_gst2201 and purge_keeps_committed_file_gst2201 rows (since is the current VERSION until the merge slot; +1 GST-2243 remember_share_gst2243 row (re-summed at the #9098 stack merge: 1699 + 1); +1 GST-2312 #9024 sync_filter_owned_hold_9024 row (re-summed at the #9064 stack merge: 1700 + 1; rows are data and cannot move); +2 access-privacy wave (0.60.649.0): the owner_private_facts_gst2089 and private_labels_write_ahead_gst2092 rows; +1 GBRA-443 private_labels_batch_exit_gbra443 row (rows are data and cannot move), re-summed at the 0.60.650.0 slot on #9038: 1703 + 1; +1 postgres_tls_default row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.651.0 merge: 1704 + 1; +1 GST-2331 sync_reads_fetch_nothing_gst2331 row (rows are data and cannot move), re-summed at the 0.60.654.0 stack on #9045 6ff5540d: 1705 + 1; +7 QM wave (#9037) rows: attest_scope_read_ops_gst1158, attest_direct_page_writes_deferred_gst1158, personal_sources_gbra284, qm_personal_structured_gst1158, memory_propose_held_writes_gst1158, member_email_link_gst1158, qm_admin_http_gst1094 (re-summed at the 0.60.655.0 stack on #9110 f9b2072e: 1706 + 7); +1 GST-2228 recreated_takes_section_keeps_stored_takes_gst2228 row (since TBD; re-summed at the keep-takes-and-link-dates train merge: 1713 + 1); +1 GST-2228 links_rows_keep_own_dates_gst2228 row (since TBD; re-summed at the same train merge: 1714 + 1); +2 the W1 + memory proposals train (#9133): attest_every_page_write_deferred_gst2249 and memory_proposals_owner_http_gst2407 rows (rows are data and cannot move), re-summed at the #9138 v0.60.661.0 stack merge: 1715 + 2 = 1717 measured; +1 #8903 effect_git_secret_gate_gst1923 row (rows are data and cannot move), re-summed at the 0.60.664.0 stack on #9142 3931adb4: 1717 + 1; +1 GST-2407 PR 3: qm_recall_own_page_contract_v4 row (rows are data and cannot move), re-summed at the 0.60.666.0 stack on #9148 69c12917: 1718 + 1; +2 GST-363 PR 1 and PR 3 (#9135): the serves_several_labels_gst363 and stdio_member_per_harness_gst363 rows; +3 #9134 train rows member_forget_names_host_9101, refresh_fence_retry_id_gst2353 and recorded_read_view_args_gst2214 (rows are data and cannot move), re-summed at the #9134 slot merge onto #8829 dfc24954: 1721 + 3; +3 source-checkouts wave rows (autopilot_git_reconcile_gbra386, unknown_drift_history_rescreen, refresh_abandon_members_gst1465), re-summed at the #9137 stack merge: 1724 + 3; persistence train 13 at 0.60.676.0: its five rows on top of 0.60.675.0; +1 GST-2250 reconcile_publish_opt_out_gst2250 row (since TBD until the merge slot; rows are data and cannot move); +1 #8902 unmanaged_push_history_scan_8902 row (re-summed at the 0.60.678.0 stack on 501742d9: 1733 + 1); +1 GST-2246 maintain_safe_free_phases_gst2246 row (since TBD until the merge slot; rows are data and cannot move), re-summed on the doctor/dream/enrich train at the 0.60.679.0 slot merge onto #9170 82932eda: 1734 + 1; +2 GST-2462 privacy_label_ignored_gst2462 and access_page_rules_gst2462 rows (rows are data and cannot move), re-summed at the #9173 slot merge onto 49a922ef: 1735 + 2; +1 GST-2107 follow-up write_capacity_low_not_refusal_gst2107 row (rows are data and cannot move), re-summed at the 0.60.681.0 slot merge onto #9173 c08d0c8b: 1737 + 1; +1 GST-2490: owner_reads_derived_gst2490 row (rows are data and cannot move); +1 GST-2468: the label_only_operator_repairs_gst2468 row (a BEHAVIOR_CHANGES row cannot move); +1 GST-2446 remember_pageless_reply_gst2446, +1 GST-2492 strict_held_facts_gst2492 and +1 GST-2346 D1 owner_facts_shared_gst2346 rows (rows are data and cannot move), re-summed at the 0.60.685.0 train merge onto #9181 405ea4cf: 1740 + 3; +1 GST-2476: the readers_label_setter_gst2476 row (rows are data and cannot move), re-summed at the #9184 slot merge onto the #9179 train 361d57c6: 1743 + 1; +1 GST-2487: the fence_fact_private_in_place_gst2487 row (rows are data and cannot move), at the same slot merge of #9188 0075f09a: 1744 + 1; +1 GST-2515: the sync_status_commits_waiting_gst2515 row (rows are data and cannot move), at the 0.60.688.0 slot merge onto 599b1234: 1745 + 1; +3 GST-2519: commit_push_untrack_gst2519, db_only_labels_kept_gst2519 and git_ignored_label_repair_gst2519 rows (rows are data and cannot move), re-summed at the 0.60.691.0 slot merge onto #9167 ad4f0aef: 1746 + 3; +3 GST-2492 PR 2: the remember_pageless_ask, strict_fact_writers_held and sync_strict_requires_managed rows (rows are data and cannot move), re-summed at the master v0.60.691.0 merge: 1749 + 3; +3 GST-2346 rows owner_forget_private, owner_forget_readers_page and member_save_withdrawn_scope (rows are data and cannot move), re-summed at the 0.60.693.0 slot merge onto #9202 840858e9: 1752 + 3; +2 GST-2518 page_label_widening_held_gst2518 and GST-2521 owner_labels_guarded_gst2521 rows and +1 GST-2511 fence_fact_widening_held_gst2511 row (rows are data and cannot move), re-summed at the 0.60.694.0 slot merge onto master 2c8320d7: 1755 + 3; +3 the GST-2515/GST-2520 notifier_retry_unwatched_gst2515 and strict_skip_mode_refusal_gst2520 rows and the GST-2456 unmanaged_push_every_site_gst2456 row, re-summed at the 0.60.698.0 slot merge onto #9217 887398f0: 1758 + 3
+src/core/behavior-change-notice.ts 1762 ratchet +4 train R: #7491/#7492 keyword_identifier_probe and keyword_slug_handles rows and their comment, #7175 keyword phrase row; the BEHAVIOR_CHANGES table grows by one row per disclosed change: +4 the #7891 provenance-drift and #7917/#7918 maintenance-lowering rows and their comments (re-summed at the 0.60.495.0 merge: 1547 + 4); +1 GBRA-156 #7593: private_pages_granted_sources row (re-summed at the 0.60.527.0 merge: 1574 + 1); +3 GBRA-200 comment, write-grant refusal and degraded-stamp rows (re-summed at the 0.60.562.0 merge: 1615 + 3); +2 GBRA-280 get_page selector-precedence row and comment (re-summed at the 0.60.569.0 merge: 1619 + 2); the BEHAVIOR_CHANGES table grows by one row per disclosed change: +4 the #7891 provenance-drift and #7917/#7918 maintenance-lowering rows and their comments (re-summed at the 0.60.495.0 merge: 1547 + 4); +2 GBRA-205 saved_facts_stems row and its comment (re-summed at the #7901 0.60.492.0 merge: 1541 + 2); +2 GBRA-205 search.query_facts_block default-on row and its approval comment (re-summed at the #7610 0.60.490.0 merge: 1539 + 2); +2 the #7900 content checkpoint host-move row (since TBD until the merge slot), +2 the #7897 private-hold sweep row (since TBD until the merge slot), +2 the #7880 ingest_capture and company-brain private-hold row (since TBD until the merge slot), +5 the frozen-source wave comment and four rows (#7868, #7850, #7869/#7870, #7871), +2 the #7848 visibility_noncanonical hold row (since TBD until the merge slot), +2 the #7846 extract_atoms session-source row (re-summed at the 0.60.481.0 merge: master 1524 + 2), +2 the #7805 synthesize session-source and #7841 visibility_not_applied rows (re-summed at the 0.60.480.0 merge: master 1522 + 2), +2 strict door planned-state row (#7705, re-summed at the 0.60.470.0 merge: master 1514 + 2), +2 Bun floor 1.4.4 row (#7644), the GBRA-95 RLS backfill row (+2), +3 rows for #7596 pass_interrupted, #7599 read-only serve and the --access=read-only ceiling, +1 G5 lane C trust_release row, +1 #7619 cli_flag_equals, +3 GBRA-207 #7630 relative-anchor and stalled-write rows, +2 the #7632 function search_path disclosure row and +2 the #7679 orphaned worktree refresh row (re-summed at the 0.60.471.0 merge: master 1516 + 2), +2 the #7814 retired v0.13.1 grandfather row, +2 the #7618 conversion withhold/progress/push row (master 1520 + 2); the behavior-change table split (#7607) retires this row; +4 GBRA-188 #7489: the wave comment and three rows (brain-first instructions, starter surface default, per-turn rule); +1 GBRA-188 plugin_turn_hook_gbra188 row; +1 GBRA-242 provider_key_rules_7959 row (#7959), +2 the GBRA-199 registration_lists_verbs row (since TBD until the merge slot); +2 GBRA-133 #7652: the #7611 pass_abandoned reader row and the lean read-only serve socket row (re-summed at the 0.60.503.0 merge: master 1555 + 2); +1 GBRA-243: the per-turn hook disclosure row (rows are data and cannot move); +4 GBRA-156 #7598 harness wave comment and rows (remote page cap, sources_not_readable refusal, sources add next step); +4 GBRA-156 #7601 search_quotes_transcript_rows comment and row; +1 GBRA-175 #7475 autopilot_restarts_serve_7475 row (re-summed at the #8012 merge: 1566 + 1); +3 #7997/#8014/#8015 rows (redaction markers, company db_only keep, ignored supabase_only scope); +2 #7199 (re-port of #7228) classic_drift_rescreen_7199 comment and row; +2 #7931 file_drift_agrees_7931 comment and row; +1 #7950 file_drift_slug_release_7950 row; +1 #7974 file_drift_followups_7974 row; +1 #8059 quoted_fence_marker_8059 row; +2 GBRA-247 #8009 provenance_repair_held_8009 and #7982 pass_transient_streak_7982 rows; +4 GBRA-247 #7973 plain_directory_sync_7973, #7988 managed_marker_own_directory_7988, #7985 former_binding_parked_group_7985 and settle_effects_retire_7985 rows Train S merge: 1570 base + 5 (master since the #8077 base) + 13 (#8077) = 1588.; +2 GST-687 remote_quotes_unverified_text_gst687 row and its comment (re-summed at the gate-ahead on train S 0.60.534.0: 1588 + 2); +2 #8377: the quote fence follow-ups row and its comment; +2 #8384: the quote fence follow-ups 2 row and its comment; +2 #8384 wave 3: the quote fence follow-ups 3 row and its comment; +5 GBRA-218 train M rows (A1 member_read_access_gbra218 and member_access_hatch_scope_gbra218, B shared_agent_audience_gbra231, A2 folder_access_rules_gbra218, folder_access_scoped_role_gbra218), re-summed at the train M merge of master v0.60.541.0: 1596 + 5 = 1601 measured; +3 GST-359 train C rows (C1 qm_attested_actor_gst359, C2 member_facts_gst359, D qm_memory_provider_gst359), re-summed at the train C merge of master v0.60.543.0: 1601 + 3 = 1604 measured; +2 #8424: hook_launcher_8424 row and its comment (rows are data and cannot move), re-summed at the #8418 v0.60.546.0 merge: 1604 + 2 = 1606 measured; +2 #8426: mcp_lane_launcher_8426 row and its comment (rows are data and cannot move); +2 GST-927: empty_nonstring_args_gst927 row and its comment, re-summed at the gate-ahead on master v0.60.550.0 plus #8420: 1610 measured; +2 GBRA-283 Wave A (#8460): engine_keyed_caches_gbra283 row and its comment (rows are data and cannot move); +2 GBRA-287: segmented_freeze_hold_gbra287 and segmented_reexport_gbra287 rows (rows are data and cannot move); +1 GST-1209: segmented_tiling_gst1209 row (rows are data and cannot move); +1 GST-1251: skillopt_loop_deprecated_gst1251 row (rows are data and cannot move); +1 GST-1209 follow-up: untiled_hold_repair_gst1209 row (rows are data and cannot move); +1 GBRA-283 B3a: embedded_scope_required_gbra283 row (rows are data and cannot move); re-summed at the train R merge with v0.60.574.0: 1623 + 4; +2 GST-1387: refresh_fence_refusal_gst1387 row and its comment (rows are data and cannot move); re-summed at the memory train #8481 merge with v0.60.578.0 (1643 measured); +3 GBRA-253 #8109 rows (frontmatter_drift_write_8109, contacts_activity_advance_8109, contact_rows_dedupe_8109; rows are data and cannot move), re-summed at the master v0.60.581.0 merge: 1643 + 3 = 1646 measured; +3 #8123 part C rows: sync_write_through_off_writeback_7084, managed_sync_dry_run_counts_7087, frontmatter_missing_source_dir_7889 (since TBD until the merge slot; re-summed at the 0.60.583.0 merge: 1646 + 3); +4 PR B commit_ledger_prb, doctor_foreign_writers_prb and sources_guard_prb rows and their comment (rows are data and cannot move; since TBD until the merge slot); +1 PR B #8615: file_drift_held_needs_prefer_8615 row; +1 PR B #8617: refresh_source_changed_retry_8617 row; +1 PR B #8662: commit_push_checkout_not_a_source_8662 row (since TBD until the merge slot; rows are data and cannot move); +2 PR B refresh_barrier_prb and commit_push_base_prb rows (re-summed: 1658 measured); +3 convergence PR A: the wave comment and two rows (conversion_content_evidence_pr_a, git_gap_live_pages_pr_a; since TBD until the merge slot; rows are data and cannot move); re-summed at the gate-ahead on master v0.60.592.0 plus #8711: 1658 + 3 = 1661 measured; +4 GST-1094/GST-900 rows (memory_recall scope-read, member-bound acting_user, recall max_chars, unknown_param _meta-only) and +1 qm_scope_writes_gst1113 and +1 recall_question_terms_gst1304 rows (rows are data and cannot move), re-summed at the 0.60.595.0 slot merge: 1661 + 6; +1 GST-1582 refresh_barrier_import_gst1582 row (since TBD until the merge slot; rows are data and cannot move); +2 GST-1601 source_changed_origin_gst1601 and adopt_local_edits_gst1601 rows (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.596.0 merge: 1668 + 2; +1 GST-1623 refresh_barrier_capacity_gst1623 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.599.0 merge: 1670 + 1; +2 GBRA-224 W1 release_channel_stable_default row and its comment; +1 GST-1623 refresh_barrier_later_write_gst1623 row (#8765; rows are data and cannot move); +5 #8766 GST-1623 items 4/6-9 and #8755: the wave comment and four rows (doctor_foreign_writers_partial_gst1623, commit_push_enclosing_repo_gst1623, owner_guard_fail_closed_gst1623, adopt_local_edits_hardening_8755) and +1 managed_sync_kind_reserved_8765 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on master v0.60.608.0 plus #8798: 1674 + 6; +1 GST-1853 refresh_barrier_aborted_refresh_sync_gst1853 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.613.0 merge: 1680 + 1; +1 GST-1674 refresh_refused_merge_recovery_gst1674 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.614.0 merge: 1681 + 1; +1 #8824/#8826/#8767: adopt_local_edits_replay_markers_8824 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on #8837: 1682 + 1; +1 url_source_origin row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on #8834: 1683 + 1; +1 #8828: the refresh_replan_own_commits_8828 row (1684 + 1 at the 0.60.618.0 slot); +1 the managed commit-push unpublished-count row; +1 the refresh publish-diverged default row; +1 GST-2051 ungranted_member_writes_gst2051 row (since TBD until the merge slot; rows are data and cannot move); +1 GST-731 think_window_trajectory_gst731 row and +1 GST-1602 purge_cancels_deferred_write_gst1602 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on #8915 v0.60.621.0: 1688 + 2; +1 GST-2059: owner_reads_private row; +1 #8888: the record-origin checkout lock-down row (re-summed at the Q6 stack on #8934 v0.60.625.0: 1691 + 1); +1 GST-1158 F9: the attest_direct_page_writes_deferred_gst1158 row (since TBD until the merge slot); +1 GST-1158 E1/F3/F4 rows (since TBD until the merge slot), re-summed at the master merge; +1 GBRA-284 personal_sources_gbra284 row (since TBD until the merge slot) (re-summed at the QM wave merge onto master v0.60.626.0: 1692 + 3); +1 GST-1158 F9: the attest_direct_page_writes_deferred_gst1158 row (since TBD until the merge slot); +1 GST-1158 v3: the qm_personal_structured_gst1158 row (since TBD until the merge slot); +1 #8477 GST-1158 F2 personal-tools row at the QM wave merge (1695 + 1); +1 GST-1158 F9: the attest_direct_page_writes_deferred_gst1158 row (since TBD until the merge slot); +1 #8483 memory_propose row at the QM wave merge (1696 + 1); +1 GST-1094 gap 4: the qm_admin_http_gst1094 row (since TBD until the merge slot); +1 GST-1158: the member_email_link_gst1158 row (since TBD until the merge slot); +2 #8479 member-email rows at the QM wave merge (1697 + 2); +1 GST-2112: ingest_keeps_readers_gst2112 row (re-summed at the Q7 v0.60.627.0 merge: 1692 + 1); +1 #8982 federated_member_writes_8982 row (since TBD until the merge slot; rows are data and cannot move); +1 GST-2116 commit_push_skipped_paths_gst2116 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the Q10 slot on #9009 ee0f4a78: 1694 + 1; +1 GST-2118 pending_ledger_flagged_gst2118 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the Q12 slot on #9016 afb49de5: 1695 + 1; +1 GBRA-431: read_scope_params_gbra431 row (rows are data and cannot move), re-summed at the #9032 stack merge: 1697 measured; +2 GST-2201 sync_restored_file_gst2201 and purge_keeps_committed_file_gst2201 rows (since is the current VERSION until the merge slot; +1 GST-2243 remember_share_gst2243 row (re-summed at the #9098 stack merge: 1699 + 1); +1 GST-2312 #9024 sync_filter_owned_hold_9024 row (re-summed at the #9064 stack merge: 1700 + 1; rows are data and cannot move); +2 access-privacy wave (0.60.649.0): the owner_private_facts_gst2089 and private_labels_write_ahead_gst2092 rows; +1 GBRA-443 private_labels_batch_exit_gbra443 row (rows are data and cannot move), re-summed at the 0.60.650.0 slot on #9038: 1703 + 1; +1 postgres_tls_default row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.651.0 merge: 1704 + 1; +1 GST-2331 sync_reads_fetch_nothing_gst2331 row (rows are data and cannot move), re-summed at the 0.60.654.0 stack on #9045 6ff5540d: 1705 + 1; +7 QM wave (#9037) rows: attest_scope_read_ops_gst1158, attest_direct_page_writes_deferred_gst1158, personal_sources_gbra284, qm_personal_structured_gst1158, memory_propose_held_writes_gst1158, member_email_link_gst1158, qm_admin_http_gst1094 (re-summed at the 0.60.655.0 stack on #9110 f9b2072e: 1706 + 7); +1 GST-2228 recreated_takes_section_keeps_stored_takes_gst2228 row (since TBD; re-summed at the keep-takes-and-link-dates train merge: 1713 + 1); +1 GST-2228 links_rows_keep_own_dates_gst2228 row (since TBD; re-summed at the same train merge: 1714 + 1); +2 the W1 + memory proposals train (#9133): attest_every_page_write_deferred_gst2249 and memory_proposals_owner_http_gst2407 rows (rows are data and cannot move), re-summed at the #9138 v0.60.661.0 stack merge: 1715 + 2 = 1717 measured; +1 #8903 effect_git_secret_gate_gst1923 row (rows are data and cannot move), re-summed at the 0.60.664.0 stack on #9142 3931adb4: 1717 + 1; +1 GST-2407 PR 3: qm_recall_own_page_contract_v4 row (rows are data and cannot move), re-summed at the 0.60.666.0 stack on #9148 69c12917: 1718 + 1; +2 GST-363 PR 1 and PR 3 (#9135): the serves_several_labels_gst363 and stdio_member_per_harness_gst363 rows; +3 #9134 train rows member_forget_names_host_9101, refresh_fence_retry_id_gst2353 and recorded_read_view_args_gst2214 (rows are data and cannot move), re-summed at the #9134 slot merge onto #8829 dfc24954: 1721 + 3; +3 source-checkouts wave rows (autopilot_git_reconcile_gbra386, unknown_drift_history_rescreen, refresh_abandon_members_gst1465), re-summed at the #9137 stack merge: 1724 + 3; persistence train 13 at 0.60.676.0: its five rows on top of 0.60.675.0; +1 GST-2250 reconcile_publish_opt_out_gst2250 row (since TBD until the merge slot; rows are data and cannot move); +1 #8902 unmanaged_push_history_scan_8902 row (re-summed at the 0.60.678.0 stack on 501742d9: 1733 + 1); +1 GST-2246 maintain_safe_free_phases_gst2246 row (since TBD until the merge slot; rows are data and cannot move), re-summed on the doctor/dream/enrich train at the 0.60.679.0 slot merge onto #9170 82932eda: 1734 + 1; +2 GST-2462 privacy_label_ignored_gst2462 and access_page_rules_gst2462 rows (rows are data and cannot move), re-summed at the #9173 slot merge onto 49a922ef: 1735 + 2; +1 GST-2107 follow-up write_capacity_low_not_refusal_gst2107 row (rows are data and cannot move), re-summed at the 0.60.681.0 slot merge onto #9173 c08d0c8b: 1737 + 1; +1 GST-2490: owner_reads_derived_gst2490 row (rows are data and cannot move); +1 GST-2468: the label_only_operator_repairs_gst2468 row (a BEHAVIOR_CHANGES row cannot move); +1 GST-2446 remember_pageless_reply_gst2446, +1 GST-2492 strict_held_facts_gst2492 and +1 GST-2346 D1 owner_facts_shared_gst2346 rows (rows are data and cannot move), re-summed at the 0.60.685.0 train merge onto #9181 405ea4cf: 1740 + 3; +1 GST-2476: the readers_label_setter_gst2476 row (rows are data and cannot move), re-summed at the #9184 slot merge onto the #9179 train 361d57c6: 1743 + 1; +1 GST-2487: the fence_fact_private_in_place_gst2487 row (rows are data and cannot move), at the same slot merge of #9188 0075f09a: 1744 + 1; +1 GST-2515: the sync_status_commits_waiting_gst2515 row (rows are data and cannot move), at the 0.60.688.0 slot merge onto 599b1234: 1745 + 1; +3 GST-2519: commit_push_untrack_gst2519, db_only_labels_kept_gst2519 and git_ignored_label_repair_gst2519 rows (rows are data and cannot move), re-summed at the 0.60.691.0 slot merge onto #9167 ad4f0aef: 1746 + 3; +3 GST-2492 PR 2: the remember_pageless_ask, strict_fact_writers_held and sync_strict_requires_managed rows (rows are data and cannot move), re-summed at the master v0.60.691.0 merge: 1749 + 3; +3 GST-2346 rows owner_forget_private, owner_forget_readers_page and member_save_withdrawn_scope (rows are data and cannot move), re-summed at the 0.60.693.0 slot merge onto #9202 840858e9: 1752 + 3; +2 GST-2518 page_label_widening_held_gst2518 and GST-2521 owner_labels_guarded_gst2521 rows and +1 GST-2511 fence_fact_widening_held_gst2511 row (rows are data and cannot move), re-summed at the 0.60.694.0 slot merge onto master 2c8320d7: 1755 + 3; +3 the GST-2515/GST-2520 notifier_retry_unwatched_gst2515 and strict_skip_mode_refusal_gst2520 rows and the GST-2456 unmanaged_push_every_site_gst2456 row, re-summed at the 0.60.698.0 slot merge onto #9217 887398f0: 1758 + 3; +1 #8144 (#7302): session_lane_budget_gbra133 row (since TBD until the merge slot; rows are data and cannot move): 1761 + 1
src/core/git/commit-push.ts 1658 ratchet GST-2519: --untrack (#7753 port: untrackTargets, untrackPaths; untrackAdmitted, the managed-worktree storage.db_only admission; previewUntrack) and the staged-removal hint in skippedPathsError grow the commit door past the 1500 default (master 1487 + 140); GST-2456 (#9174): crossed the 1500 unlisted cap at the GST-2456 merge of master v0.60.678.0: pushBase (the scan base and lease read live from every push URL, #5138) and the scan budget and progress options; Ctx and publish internals keep it in this file (1487 + 31), re-summed at the master 0c577834 merge into #9198: 1627 + 31
src/commands/auth.ts 1503 ratchet new row: crossed the 1500 unlisted cap at the v0.60.595.0 merge: GST-1113 --attest-sources help lines plus GST-1158 F3 --attest-read help lines (3); CLI help lines cannot move
diff --git a/scripts/postgres-arm-weights-postgres-only.json b/scripts/postgres-arm-weights-postgres-only.json
index 60fc63c409..1ba26c298f 100644
--- a/scripts/postgres-arm-weights-postgres-only.json
+++ b/scripts/postgres-arm-weights-postgres-only.json
@@ -38,6 +38,7 @@
"test/doctor-image-embedding-coverage.test.ts": 8379,
"test/doctor-keyword-plan-6495.test.ts": 2724,
"test/doctor-routing-skill-pack-source.test.ts": 2451,
+ "test/doctor-session-lane-gbra133.test.ts": 3770,
"test/doctor-sync-freshness-skill-pack-6076.test.ts": 4137,
"test/embed-stale-images-managed-6529.test.ts": 12913,
"test/embedding-completion-atomic.serial.test.ts": 9621,
diff --git a/scripts/postgres-arm-weights.json b/scripts/postgres-arm-weights.json
index a6abbfd3f8..bab7a98c8f 100644
--- a/scripts/postgres-arm-weights.json
+++ b/scripts/postgres-arm-weights.json
@@ -77,6 +77,7 @@
"test/doctor-image-embedding-coverage.test.ts": 8105,
"test/doctor-keyword-plan-6495.test.ts": 4580,
"test/doctor-routing-skill-pack-source.test.ts": 6433,
+ "test/doctor-session-lane-gbra133.test.ts": 3770,
"test/doctor-strict-facts-outside-git.test.ts": 7643,
"test/doctor-sync-freshness-skill-pack-6076.test.ts": 5394,
"test/edge-whitespace-twins.test.ts": 9721,
diff --git a/src/commands/doctor/checks/session-lane.ts b/src/commands/doctor/checks/session-lane.ts
new file mode 100644
index 0000000000..6a000f586a
--- /dev/null
+++ b/src/commands/doctor/checks/session-lane.ts
@@ -0,0 +1,54 @@
+/**
+ * GBRA-133 `session_lane_budget`: how close this role is to the database's session-connection limit, counted across every
+ * process (src/core/session-lane.ts). A pooler's per-role session limit (Supavisor `pool_size`) is shared by every gbrain
+ * process on every host, so a serve, a cron sync, a jobs worker and an MCP stdio server together can exhaust it
+ * (`EMAXCONNSESSION`) although each stays inside its own pool. Read-only: it counts backends by name, attributes gbrain's
+ * to a process kind and host, and warns at 80% of the limit with the process kinds holding the most. On PGLite it is
+ * not applicable; without a known limit (a pooler, and `GBRAIN_SESSION_LANE_LIMIT` unset) it reports the counts only.
+ */
+import type { Check } from '../../doctor.ts';
+import { checkError } from '../check-fix.ts';
+import { connectedEngine, type DoctorContext, type DoctorEntry } from '../context.ts';
+import { loadConfig } from '../../../core/config.ts';
+import { readSessionLane, SESSION_LANE_LIMIT_ENV, SESSION_LANE_WARN_RATIO } from '../../../core/session-lane.ts';
+
+const DOCS = 'docs/ENGINES.md#pool-sizing';
+
+async function runSessionLaneBudget(ctx: DoctorContext): Promise<Check[]> {
+ const checks: Check[] = [];
+ const engine = connectedEngine(ctx);
+ if (engine.kind !== 'postgres') {
+ checks.push({ name: 'session_lane_budget', status: 'ok', severity: 'info', readiness_state: 'not_applicable', details: { docs: DOCS },
+ message: 'Not applicable: PGLite has no connection pool to share.' });
+ return checks;
+ }
+ try {
+ const census = await readSessionLane(engine, [loadConfig()?.database_url ?? '', process.env.GBRAIN_DIRECT_DATABASE_URL ?? '']);
+ const kinds = Object.entries(census.by_kind).sort((a, b) => b[1] - a[1]).map(([kind, n]) => `${kind} ${n}`).join(', ') || 'none';
+ const counts = `${census.gbrain} named by gbrain processes (${kinds})${census.pooler ? `, ${census.pooler} held by the pooler` : ''}${census.other ? `, ${census.other} by other clients` : ''}`;
+ const details = { ...census, warn_ratio: SESSION_LANE_WARN_RATIO, docs: DOCS };
+ if (census.limit === null) {
+ checks.push({ name: 'session_lane_budget', status: 'ok', severity: 'info', details,
+ message: `This role holds ${census.total} database connection(s): ${counts}. The pooler's session limit is not readable from Postgres; `
+ + `set ${SESSION_LANE_LIMIT_ENV} to it (Supabase: the project's pool_size) to compare.` });
+ return checks;
+ }
+ const share = census.used / census.limit;
+ const where = census.limit_source === 'env' ? `${SESSION_LANE_LIMIT_ENV}=${census.limit}` : `max_connections less reserved slots, ${census.limit}`;
+ if (share >= SESSION_LANE_WARN_RATIO) {
+ checks.push({ name: 'session_lane_budget', status: 'warn', details,
+ message: `${census.used} of ${census.limit} session connection(s) are in use (${Math.round(share * 100)}%, limit ${where}): ${counts}. `
+ + 'One more process of the usual size exhausts the limit (EMAXCONNSESSION). Run fewer long-running processes on this database (share one gbrain serve --http), '
+ + 'keep short-lived ones off the session lane (unset GBRAIN_DIRECT_DATABASE_URL and set GBRAIN_DISABLE_DIRECT_POOL=1 for a cron sync or an MCP stdio server), '
+ + `lower GBRAIN_DIRECT_POOL_SIZE, or raise the limit (${DOCS}).` });
+ return checks;
+ }
+ checks.push({ name: 'session_lane_budget', status: 'ok', details,
+ message: `${census.used} of ${census.limit} session connection(s) are in use (${Math.round(share * 100)}%, limit ${where}): ${counts}.` });
+ } catch (error) {
+ checks.push(checkError('session_lane_budget', 'count the session connections in use', error, { details: { docs: DOCS } }));
+ }
+ return checks;
+}
+
+export const sessionLaneBudgetEntry: DoctorEntry = { name: 'session_lane_budget', emits: ['session_lane_budget'], run: runSessionLaneBudget };
diff --git a/src/commands/doctor/registry.ts b/src/commands/doctor/registry.ts
index caa61be819..cfc6cffe59 100644
--- a/src/commands/doctor/registry.ts
+++ b/src/commands/doctor/registry.ts
@@ -138,6 +138,7 @@ import { dbAheadOfGitEntry } from './checks/db-ahead-of-git.ts';
import { gitIndexLagEntry } from './checks/git-index-lag.ts';
import { strictFactsOutsideGitEntry } from './checks/strict-facts-outside-git.ts';
import { localEditAdoptionsEntry } from './checks/local-edit-adoptions.ts';
+import { sessionLaneBudgetEntry } from './checks/session-lane.ts';
import { syncConfigKeysEntry } from './checks/sync-config-keys.ts';
import { ghostPagesEntry } from './checks/ghost-pages.ts';
import { memberAccessEntry } from './checks/member-access.ts';
@@ -309,6 +310,8 @@ export const DOCTOR_CHECK_REGISTRY: readonly DoctorEntry[] = [
trustReleaseUnpreviewedEntry,
coreMemoryEntry,
persistenceConsumersEntry,
+ // GBRA-133: this role's session connections across every process, against the pooler's limit (read-only).
+ sessionLaneBudgetEntry,
runtimeBuildSkewEntry,
cliSocketRefusalsEntry,
atomHeldFailedEntry,
diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.ts
index 590ab065e6..7ee504f5c8 100644
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@ -1563,6 +1563,7 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText;
{ since: '0.60.693.0', id: 'member_save_withdrawn_scope_gst2346', text: 'A remote `remember` onto a member\'s own page (`memory/members/<id>`) is refused `fact_withdrawn` only when that member could read what was withdrawn: a fact on its own page, its own copy withdrawn by the brain host, or for the brain owner a fact it reads. A claim withdrawn by the brain host or the owner that the member never read no longer refuses its save: the fact saves as the member\'s own active row with the same reply as a new claim. A schema migration makes the database insert guards mark a row on a member page only by that page\'s own withdrawals; a withdrawal still expires matching rows on member pages when it is made, and strikes them in the page\'s file, so an import of a member page\'s file no longer marks a row withdrawn by a withdrawal of another subject. The same holds for each item of a `remember` batch (`items`), a replay with the same `request_id`, a `replaces` and the write receipt (`get_write_request`). Trusted local saves keep the check they had.' },
{ since: '0.60.694.0', id: 'owner_labels_guarded_gst2521', text: 'Labels the owner sets with `gbrain repair visibility` (or its `--readers` setter, or `gbrain repair private-labels`) now raise the page\'s label guard to operator_curated, so a later local agent write at the page\'s own tier that drops or widens them is held like a write over an owner page, with a `lower_page` item. A local write below operator_curated whose `readable_by` would leave the brain owner out of a page the owner reads now publishes with the owner kept in the readers (the rest of the narrowing applies), and its item records the requested readers. Accepting such an item (`gbrain trust confirm tp<id>`) on a page whose own tier is an agent\'s writes only the labels and keeps the agent\'s tier; on an owner page it still endorses the edit at the owner\'s tier. The guard is stored in the database (`page_label_guards`) and set only by label repairs run after the upgrade, so labels set earlier, and a managed Git brain rebuilt from a clone, start unguarded; re-running `gbrain repair visibility --slug` or `--readers` on a page that already has those labels raises the guard without changing them. The owner\'s own label writes, synced owner edits, agent narrowing that keeps the owner, and brains with `access.owner_reads_restricted` on are unchanged.' },
{ since: '0.60.694.0', id: 'page_label_widening_held_gst2518', text: 'A local agent write (`put_page`, `capture`, `edit_page`, `append_page`, `revert_version`, `restore_page`) less trusted than a page that drops or widens its `visibility`, `access`, `confidentiality` or `readable_by` now publishes with the page\'s earlier labels kept, in the database and in the committed file, and its receipt lists them under `privacy_labels_kept`; so does a maintenance job\'s derived page publication, and a page whose tier is still `unknown` counts as the owner\'s. A soft delete no longer lowers the page\'s tier. Before, the page became readable to remote callers and other members at once, and only a `lower_page` item waited for the owner. That item now records the requested labels: `gbrain trust confirm tp<id>` applies them if the page has not changed since, `gbrain trust drop tp<id>` keeps the earlier ones, and undoing a confirm restores them while the page is unchanged since. Narrowing writes, label-neutral writes, writers at or above the page\'s tier, synced owner edits and `gbrain repair visibility` are unchanged.' },
+ { since: 'TBD', id: 'session_lane_budget_gbra133', text: 'New read-only `gbrain doctor` check `session_lane_budget` counts this database role\'s connections across every gbrain process (by process kind and host, from the `gbrain <kind>:<pid>:<nonce>` connection name) and warns at 80% of the limit, naming the kinds holding the most. Behind a Supabase pooler, set `GBRAIN_SESSION_LANE_LIMIT` to the project\'s `pool_size` to compare (Postgres cannot read it); without it the check reports the counts only. Without a pooler the limit is `max_connections` less the reserved slots. Not applicable on PGLite.' },
];
/** The newest disclosed change's release: the notice id moves only when a release adds rows. */
diff --git a/src/core/doctor-categories.ts b/src/core/doctor-categories.ts
index 4013a71284..c9998fe2a3 100644
--- a/src/core/doctor-categories.ts
+++ b/src/core/doctor-categories.ts
@@ -431,6 +431,8 @@ export const OPS_CHECK_NAMES: ReadonlySet<string> = new Set([
'postgres_cancellation_driver',
'plugin_lane_collision',
'pool_budget',
+ // GBRA-133: session connections across every process vs the pooler's per-role limit (doctor/checks/session-lane.ts).
+ 'session_lane_budget',
'progressive_batch_audit_health',
'queue_health',
// Wakeshift PR 1: report-back key, enabled state and dead/id_reused watches (doctor/checks/wakeshift.ts).
diff --git a/src/core/session-lane.ts b/src/core/session-lane.ts
new file mode 100644
index 0000000000..18984f4fca
--- /dev/null
+++ b/src/core/session-lane.ts
@@ -0,0 +1,92 @@
+/**
+ * GBRA-133: the session-lane census behind doctor `session_lane_budget`. A Supabase-style pooler gives each database role a
+ * fixed number of session-mode server connections (Supavisor `pool_size`), and every gbrain process on a host opens its own
+ * pools: serve's ordinary pool, each process's direct pool, a sync's import workers. Nothing counted them together, so one
+ * host could exhaust the lane (`EMAXCONNSESSION`) with no warning before the first refusal.
+ *
+ * One read-only statement over `pg_stat_activity` (no query text) counts this role's client backends in this database by
+ * `application_name`. Every gbrain pool names its connections `gbrain <kind>:<pid>:<nonce8>` (db.ts), so those backends
+ * are attributed to a process kind and, through the live `persistence_consumers` row of the same pid and nonce, to a host.
+ * A transaction-mode pooler's server connections carry the pooler's own name, so they are counted apart (`pooler`), never
+ * attributed. The limit is `GBRAIN_SESSION_LANE_LIMIT` (the pooler's per-role session limit, which Postgres cannot read)
+ * or, with no pooler in front, the server's `max_connections` minus its reserved slots. Behind a pooler the count is an
+ * upper bound: this role's connections that bypass the pooler (a direct `db.<ref>` host) are counted too.
+ */
+import type { BrainEngine } from './engine.ts';
+import { isSupabasePoolerUrl } from './connection-manager.ts';
+
+export const SESSION_LANE_LIMIT_ENV = 'GBRAIN_SESSION_LANE_LIMIT';
+/** At or above this share of the limit the check warns: one more process of the usual size passes it. */
+export const SESSION_LANE_WARN_RATIO = 0.8;
+const POOLER_NAMES = /^(supavisor|pgbouncer|odyssey|pgcat)\b/i;
+const GBRAIN_NAME = /^gbrain ([^:]+):(\d+):([0-9a-f]{0,8})$/i;
+
+export interface SessionLaneProcess { application_name: string; kind: string; pid: number; host_id: string | null; connections: number }
+export interface SessionLaneCensus {
+ /** This role's client backends in this database. */
+ total: number;
+ /** Named by a gbrain pool, a pooler, or anything else. */
+ gbrain: number; pooler: number; other: number;
+ by_kind: Record<string, number>;
+ by_host: Array<{ host_id: string | null; connections: number }>;
+ processes: SessionLaneProcess[];
+ limit: number | null;
+ limit_source: 'env' | 'max_connections' | null;
+ /** The backends the limit is compared with: this role's against a per-role limit (a pooler's, or the env limit), every client backend against max_connections. */
+ used: number;
+ behind_pooler: boolean;
+}
+
+export function sessionLaneLimitFromEnv(env: Record<string, string | undefined> = process.env): number | null {
+ const raw = env[SESSION_LANE_LIMIT_ENV]?.trim();
+ if (!raw) return null;
+ const value = Number(raw);
+ return Number.isInteger(value) && value > 0 ? value : null;
+}
+
+/** The census from the read rows (pure: the doctor test drives it with fixed rows). */
+export function summarizeSessionLane(input: { rows: Array<{ application_name: string | null; connections: number }>; owners: Array<{ pid: number; nonce: string; host_id: string }>;
+ serverClients: number; serverLimit: number | null; envLimit: number | null; pooledUrl: boolean }): SessionLaneCensus {
+ let gbrain = 0, pooler = 0, other = 0;
+ const byKind: Record<string, number> = {};
+ const processes: SessionLaneProcess[] = [];
+ for (const row of input.rows) {
+ const name = row.application_name ?? '';
+ const match = GBRAIN_NAME.exec(name);
+ if (match) {
+ gbrain += row.connections;
+ const kind = match[1]!, pid = Number(match[2]);
+ byKind[kind] = (byKind[kind] ?? 0) + row.connections;
+ const owner = input.owners.find(o => o.pid === pid && o.nonce.slice(0, 8).toLowerCase() === match[3]!.toLowerCase());
+ processes.push({ application_name: name, kind, pid, host_id: owner?.host_id ?? null, connections: row.connections });
+ } else if (POOLER_NAMES.test(name)) pooler += row.connections;
+ else other += row.connections;
+ }
+ processes.sort((a, b) => b.connections - a.connections || a.application_name.localeCompare(b.application_name));
+ const hosts = new Map<string | null, number>();
+ for (const p of processes) hosts.set(p.host_id, (hosts.get(p.host_id) ?? 0) + p.connections);
+ const total = gbrain + pooler + other;
+ const behindPooler = input.pooledUrl || pooler > 0;
+ const limit = input.envLimit ?? (behindPooler ? null : input.serverLimit);
+ return { total, gbrain, pooler, other, by_kind: byKind,
+ by_host: [...hosts].map(([host_id, connections]) => ({ host_id, connections })).sort((a, b) => b.connections - a.connections),
+ processes, limit, limit_source: input.envLimit !== null ? 'env' : limit !== null ? 'max_connections' : null,
+ used: behindPooler || input.envLimit !== null ? total : input.serverClients, behind_pooler: behindPooler };
+}
+
+/** Reads the census on a Postgres engine (read-only; no query text leaves the server). `urls`: the configured database URLs (a Supabase pooler among them means the limit is the pooler's). */
+export async function readSessionLane(engine: BrainEngine, urls: readonly string[], env: Record<string, string | undefined> = process.env): Promise<SessionLaneCensus> {
+ const rows = await engine.executeRaw<{ application_name: string | null; connections: number | string }>(
+ `SELECT application_name, count(*)::int AS connections FROM pg_stat_activity
+ WHERE datname = current_database() AND usename = current_user AND backend_type = 'client backend' GROUP BY application_name`);
+ const [server] = await engine.executeRaw<{ clients: number | string; max_connections: number | string; reserved: number | string }>(
+ `SELECT (SELECT count(*) FROM pg_stat_activity WHERE backend_type = 'client backend')::int AS clients,
+ current_setting('max_connections')::int AS max_connections,
+ (current_setting('superuser_reserved_connections')::int + COALESCE(NULLIF(current_setting('reserved_connections', true), '')::int, 0)) AS reserved`);
+ const owners = await engine.executeRaw<{ pid: number; nonce: string; host_id: string }>(
+ `SELECT pid, nonce, host_id::text AS host_id FROM persistence_consumers WHERE renewed_at > now() - interval '10 minutes'`).catch(() => []);
+ return summarizeSessionLane({ rows: rows.map(row => ({ application_name: row.application_name, connections: Number(row.connections) })),
+ owners: owners.map(o => ({ pid: Number(o.pid), nonce: String(o.nonce ?? ''), host_id: o.host_id })),
+ serverClients: Number(server?.clients ?? 0), serverLimit: server ? Number(server.max_connections) - Number(server.reserved) : null,
+ envLimit: sessionLaneLimitFromEnv(env), pooledUrl: urls.some(isSupabasePoolerUrl) });
+}
diff --git a/test/cli-socket.test.ts b/test/cli-socket.test.ts
index e602e96282..2aafa999b9 100644
--- a/test/cli-socket.test.ts
+++ b/test/cli-socket.test.ts
@@ -100,7 +100,7 @@ const NOT_READ_BEHAVIOR = new Set([
'GBRAIN_GITHUB_REPO', 'GBRAIN_GLOBAL_MAINTENANCE_TIMEOUT_MS', 'GBRAIN_LLM_HALT_COOLDOWN', 'GBRAIN_MAX_FENCES_PER_PAGE', 'GBRAIN_MAX_SKILL_MD_BYTES',
'GBRAIN_MAX_WALK_DEPTH', 'GBRAIN_ORPHANED_PRIVATE_QUEUE_MINUTES', 'GBRAIN_PHANTOM_REDIRECT_LIMIT', 'GBRAIN_PLANNER_AUTO_ANALYZE',
'GBRAIN_REFRESH_DRAIN_WAIT_MS', 'GBRAIN_REFRESH_FETCH_TIMEOUT_MS', 'GBRAIN_REFRESH_SYNC_BUDGET_MS', 'GBRAIN_SKIP_REFERENCE_SWEEP', 'GBRAIN_SKIP_STARTUP_HOOKS', 'GBRAIN_TRAJECTORY_REGRESSION_THRESHOLD',
- 'GBRAIN_WEDGED_QUEUE_WARN_MINUTES', 'GBRAIN_ANTHROPIC_MAX_INFLIGHT',
+ 'GBRAIN_WEDGED_QUEUE_WARN_MINUTES', 'GBRAIN_ANTHROPIC_MAX_INFLIGHT', 'GBRAIN_SESSION_LANE_LIMIT', 'GBRAIN_NAME',
'GBRAIN_SERVE_BOOT_TIMEOUT_SECONDS', 'GBRAIN_SERVE_EOF_DRAIN_MS', 'GBRAIN_SERVE_FAIL_FAST', 'GBRAIN_SERVE_HEAD_DEBOUNCE_MS', 'GBRAIN_SERVE_HEAD_POLL_MS',
'GBRAIN_SERVE_RESTART_REQUIRED_EXIT_SECONDS', 'GBRAIN_SERVE_STALL_WATCHDOG_MS', 'GBRAIN_SERVE_SYNC_IPC', 'GBRAIN_SERVE_SYNC_SETTLE_MS',
'GBRAIN_SURFACE', 'GBRAIN_MCP_FORCE_SURFACE', 'GBRAIN_MCP_INSTRUCTIONS', 'GBRAIN_SOCKET_KINDS', 'GBRAIN_HEALTH_CACHE_TTL_MS', 'GBRAIN_CLIENT_CHECK_INTERVAL',
diff --git a/test/doctor-session-lane-gbra133.test.ts b/test/doctor-session-lane-gbra133.test.ts
new file mode 100644
index 0000000000..0e936dc1dc
--- /dev/null
+++ b/test/doctor-session-lane-gbra133.test.ts
@@ -0,0 +1,105 @@
+/**
+ * GBRA-133 doctor `session_lane_budget`: every gbrain process opens its own pools, and a pooler's per-role session limit
+ * (Supavisor `pool_size`) is shared by all of them, so a host could exhaust it (`EMAXCONNSESSION`) with no warning before
+ * the first refusal. The check counts this role's backends by `application_name`, attributes gbrain's to a process kind
+ * and (through the live consumer row) a host, and warns at 80% of the limit. Pure census cases, plus real PGLite (not
+ * applicable) and real Postgres (backends a second process holds are counted, attributed and warned about) when
+ * DATABASE_URL is set.
+ */
+import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
+import postgres from '#postgres';
+import { randomUUID } from 'node:crypto';
+import type { BrainEngine } from '../src/core/engine.ts';
+import { PGLiteEngine } from '../src/core/pglite-engine.ts';
+import { sessionLaneBudgetEntry } from '../src/commands/doctor/checks/session-lane.ts';
+import type { DoctorContext } from '../src/commands/doctor/context.ts';
+import { readSessionLane, sessionLaneLimitFromEnv, summarizeSessionLane, SESSION_LANE_LIMIT_ENV } from '../src/core/session-lane.ts';
+import { isolatedPersistencePostgres } from './helpers/persistence-postgres.ts';
+import { requirePostgresTestDatabase, testBackends } from './helpers/test-backends.ts';
+import { withEnv } from './helpers/with-env.ts';
+
+describe('GBRA-133: the session-lane census', () => {
+ const owners = [{ pid: 101, nonce: 'aaaaaaaa-1111', host_id: 'host-a' }, { pid: 202, nonce: 'bbbbbbbb-2222', host_id: 'host-b' }];
+ const rows = [
+ { application_name: 'gbrain serve:101:aaaaaaaa', connections: 13 },
+ { application_name: 'gbrain sync:202:bbbbbbbb', connections: 7 },
+ { application_name: 'gbrain jobs:303:cccccccc', connections: 2 },
+ { application_name: 'Supavisor', connections: 1 },
+ { application_name: 'psql', connections: 1 },
+ { application_name: null, connections: 1 },
+ ];
+
+ test('gbrain backends are attributed to a kind and, through the consumer row, a host; the rest are counted apart', () => {
+ const census = summarizeSessionLane({ rows, owners, serverClients: 40, serverLimit: 97, envLimit: 25, pooledUrl: true });
+ expect(census).toMatchObject({ total: 25, gbrain: 22, pooler: 1, other: 2, by_kind: { serve: 13, sync: 7, jobs: 2 }, limit: 25, limit_source: 'env', used: 25, behind_pooler: true });
+ expect(census.processes.map(p => [p.kind, p.pid, p.host_id, p.connections])).toEqual([['serve', 101, 'host-a', 13], ['sync', 202, 'host-b', 7], ['jobs', 303, null, 2]]);
+ expect(census.by_host).toEqual([{ host_id: 'host-a', connections: 13 }, { host_id: 'host-b', connections: 7 }, { host_id: null, connections: 2 }]);
+ });
+
+ test('a nonce that does not match the consumer row leaves the host unknown (a reused pid is not the same process)', () => {
+ const census = summarizeSessionLane({ rows: [{ application_name: 'gbrain serve:101:deadbeef', connections: 3 }], owners, serverClients: 3, serverLimit: 97, envLimit: null, pooledUrl: false });
+ expect(census.processes[0]!.host_id).toBeNull();
+ });
+
+ test('behind a pooler with no configured limit the limit is unknown; without one it is max_connections less reserved, against every client', () => {
+ expect(summarizeSessionLane({ rows, owners, serverClients: 40, serverLimit: 97, envLimit: null, pooledUrl: true })).toMatchObject({ limit: null, limit_source: null });
+ expect(summarizeSessionLane({ rows: rows.filter(r => r.application_name !== 'Supavisor'), owners, serverClients: 40, serverLimit: 97, envLimit: null, pooledUrl: false }))
+ .toMatchObject({ limit: 97, limit_source: 'max_connections', used: 40, behind_pooler: false });
+ expect(summarizeSessionLane({ rows, owners, serverClients: 40, serverLimit: 97, envLimit: null, pooledUrl: false })).toMatchObject({ limit: null, behind_pooler: true });
+ });
+
+ test('the limit env takes a positive integer only', () => {
+ expect(sessionLaneLimitFromEnv({ [SESSION_LANE_LIMIT_ENV]: '25' })).toBe(25);
+ for (const bad of ['', '0', '-3', '2.5', 'many', undefined]) expect(sessionLaneLimitFromEnv({ [SESSION_LANE_LIMIT_ENV]: bad })).toBeNull();
+ });
+});
+
+for (const backend of testBackends()) describe(`[${backend}] GBRA-133: doctor session_lane_budget`, () => {
+ let engine: BrainEngine;
+ let databaseUrl = '';
+ let close: (() => Promise<void>) | undefined;
+ beforeAll(async () => {
+ if (backend === 'pglite') { const pglite = new PGLiteEngine(); await pglite.connect({}); await pglite.initSchema(); engine = pglite; }
+ else { const pg = await isolatedPersistencePostgres(requirePostgresTestDatabase()); engine = pg.engine; databaseUrl = pg.databaseUrl; close = pg.close; }
+ }, 120_000);
+ afterAll(async () => { if (close) await close(); else await engine.disconnect(); });
+ const run = async () => (await sessionLaneBudgetEntry.run({ engine } as DoctorContext)) as Array<{ name: string; status: string; message: string; readiness_state?: string; details?: Record<string, any> }>;
+
+ if (backend === 'pglite') {
+ test('PGLite has no shared pool: not applicable', async () => {
+ const [check] = await run();
+ expect(check).toMatchObject({ name: 'session_lane_budget', status: 'ok', readiness_state: 'not_applicable' });
+ });
+ return;
+ }
+
+ test('backends another process holds are counted, attributed to its kind and host, and warned about at 80% of the limit', async () => {
+ const nonce = 'abcdef12' + randomUUID().slice(8);
+ const host = randomUUID();
+ await engine.executeRaw(
+ `INSERT INTO persistence_consumers (host_id, pid, nonce, kind, mode, host_json_path, persistence_home, version) VALUES ($1, 4242, $2, 'gbra133probe', 'full', '/x', '/x', 'test')`, [host, nonce]);
+ const other = postgres(databaseUrl, { max: 2, prepare: false, connection: { application_name: 'gbrain gbra133probe:4242:abcdef12' } });
+ const held = [await other.reserve(), await other.reserve()];
+ await Promise.all(held.map(c => c`SELECT 1`));
+ try {
+ const census = await readSessionLane(engine, [databaseUrl], {});
+ expect(census.by_kind.gbra133probe).toBe(2);
+ expect(census.processes).toContainEqual({ application_name: 'gbrain gbra133probe:4242:abcdef12', kind: 'gbra133probe', pid: 4242, host_id: host, connections: 2 });
+ expect(census.limit_source).toBe('max_connections');
+
+ const [warn] = await withEnv({ [SESSION_LANE_LIMIT_ENV]: String(census.total) }, run);
+ expect(warn).toMatchObject({ name: 'session_lane_budget', status: 'warn' });
+ expect(warn!.message).toContain(`limit ${SESSION_LANE_LIMIT_ENV}=${census.total}`);
+ expect(warn!.message).toContain('gbra133probe 2');
+ expect(warn!.message).toContain('EMAXCONNSESSION');
+ expect(warn!.details).toMatchObject({ limit: census.total, limit_source: 'env' });
+
+ const [ok] = await withEnv({ [SESSION_LANE_LIMIT_ENV]: String(census.total * 10) }, run);
+ expect(ok).toMatchObject({ name: 'session_lane_budget', status: 'ok' });
+ expect(ok!.message).toContain(`of ${census.total * 10} session connection(s) are in use`);
+ } finally {
+ for (const c of held) c.release();
+ await other.end();
+ }
+ });
+});
diff --git a/test/fixtures/goldens/doctor/content-pglite-human.json b/test/fixtures/goldens/doctor/content-pglite-human.json
index 3b272ef293..1db1e241d0 100644
--- a/test/fixtures/goldens/doctor/content-pglite-human.json
+++ b/test/fixtures/goldens/doctor/content-pglite-human.json
@@ -242,6 +242,7 @@
" [OK] two_consumers_on_host: PGLite admits one process; no consumer heartbeat rows are kept.",
" [OK] consumers_without_heartbeat: PGLite admits one process; no consumer heartbeat rows are kept.",
" [OK] host_identity_mismatch: This process's host identity (<home>/.gbrain/persistence/host.json) owns every binding this filesystem holds.",
+ " [INFO] session_lane_budget: Not applicable: PGLite has no connection pool to share.",
" [OK] runtime_build_skew: No long-running gbrain process (serve, jobs supervisor, worker) is running on this host.",
" [OK] cli_socket_refusals: The warm CLI socket refused no CLI call in the last 24 hours.",
" [OK] extract_atoms_held_failed: No managed atom page or transcript is held after repeated extraction failures.",
diff --git a/test/fixtures/goldens/doctor/content-pglite-json.json b/test/fixtures/goldens/doctor/content-pglite-json.json
index 7b9a5d1f5d..6f1b5a6b6e 100644
--- a/test/fixtures/goldens/doctor/content-pglite-json.json
+++ b/test/fixtures/goldens/doctor/content-pglite-json.json
@@ -3422,6 +3422,18 @@
"name": "host_identity_mismatch",
"status": "ok"
},
+ {
+ "category": "ops",
+ "details": {
+ "docs": "docs/ENGINES.md#pool-sizing"
+ },
+ "elapsed_ms": "<volatile>",
+ "message": "Not applicable: PGLite has no connection pool to share.",
+ "name": "session_lane_budget",
+ "readiness_state": "not_applicable",
+ "severity": "info",
+ "status": "ok"
+ },
{
"category": "ops",
"details": {
diff --git a/test/fixtures/goldens/doctor/hot-checks-pglite-json.json b/test/fixtures/goldens/doctor/hot-checks-pglite-json.json
index 1a48759622..64719078ed 100644
--- a/test/fixtures/goldens/doctor/hot-checks-pglite-json.json
+++ b/test/fixtures/goldens/doctor/hot-checks-pglite-json.json
@@ -3656,6 +3656,18 @@
"name": "host_identity_mismatch",
"status": "ok"
},
+ {
+ "category": "ops",
+ "details": {
+ "docs": "docs/ENGINES.md#pool-sizing"
+ },
+ "elapsed_ms": "<volatile>",
+ "message": "Not applicable: PGLite has no connection pool to share.",
+ "name": "session_lane_budget",
+ "readiness_state": "not_applicable",
+ "severity": "info",
+ "status": "ok"
+ },
{
"category": "ops",
"details": {
@@ -8791,6 +8803,18 @@
"name": "host_identity_mismatch",
"status": "ok"
},
+ {
+ "category": "ops",
+ "details": {
+ "docs": "docs/ENGINES.md#pool-sizing"
+ },
+ "elapsed_ms": "<volatile>",
+ "message": "Not applicable: PGLite has no connection pool to share.",
+ "name": "session_lane_budget",
+ "readiness_state": "not_applicable",
+ "severity": "info",
+ "status": "ok"
+ },
{
"category": "ops",
"details": {
diff --git a/test/fixtures/goldens/doctor/hot-checks-postgres-json.json b/test/fixtures/goldens/doctor/hot-checks-postgres-json.json
index ffab954553..ef457bd281 100644
--- a/test/fixtures/goldens/doctor/hot-checks-postgres-json.json
+++ b/test/fixtures/goldens/doctor/hot-checks-postgres-json.json
@@ -3666,6 +3666,14 @@
"name": "host_identity_mismatch",
"status": "ok"
},
+ {
+ "category": "ops",
+ "details": "<live-census>",
+ "elapsed_ms": "<volatile>",
+ "message": "<live-census>",
+ "name": "session_lane_budget",
+ "status": "<live-census>"
+ },
{
"category": "ops",
"details": {
@@ -8809,6 +8817,14 @@
"name": "host_identity_mismatch",
"status": "ok"
},
+ {
+ "category": "ops",
+ "details": "<live-census>",
+ "elapsed_ms": "<volatile>",
+ "message": "<live-census>",
+ "name": "session_lane_budget",
+ "status": "<live-census>"
+ },
{
"category": "ops",
"details": {
diff --git a/test/fixtures/goldens/doctor/json-pglite-degraded.json b/test/fixtures/goldens/doctor/json-pglite-degraded.json
index 33216de7b1..1060c4594e 100644
--- a/test/fixtures/goldens/doctor/json-pglite-degraded.json
+++ b/test/fixtures/goldens/doctor/json-pglite-degraded.json
@@ -3117,6 +3117,18 @@
"name": "host_identity_mismatch",
"status": "ok"
},
+ {
+ "category": "ops",
+ "details": {
+ "docs": "docs/ENGINES.md#pool-sizing"
+ },
+ "elapsed_ms": "<volatile>",
+ "message": "Not applicable: PGLite has no connection pool to share.",
+ "name": "session_lane_budget",
+ "readiness_state": "not_applicable",
+ "severity": "info",
+ "status": "ok"
+ },
{
"category": "ops",
"details": {
diff --git a/test/fixtures/goldens/doctor/json-pglite-fresh.json b/test/fixtures/goldens/doctor/json-pglite-fresh.json
index 932946be75..02719b5ce1 100644
--- a/test/fixtures/goldens/doctor/json-pglite-fresh.json
+++ b/test/fixtures/goldens/doctor/json-pglite-fresh.json
@@ -3160,6 +3160,18 @@
"name": "host_identity_mismatch",
"status": "ok"
},
+ {
+ "category": "ops",
+ "details": {
+ "docs": "docs/ENGINES.md#pool-sizing"
+ },
+ "elapsed_ms": "<volatile>",
+ "message": "Not applicable: PGLite has no connection pool to share.",
+ "name": "session_lane_budget",
+ "readiness_state": "not_applicable",
+ "severity": "info",
+ "status": "ok"
+ },
{
"category": "ops",
"details": {
diff --git a/test/fixtures/goldens/doctor/json-postgres-fresh.json b/test/fixtures/goldens/doctor/json-postgres-fresh.json
index 038abf31ee..57cae13165 100644
--- a/test/fixtures/goldens/doctor/json-postgres-fresh.json
+++ b/test/fixtures/goldens/doctor/json-postgres-fresh.json
@@ -3170,6 +3170,14 @@
"name": "host_identity_mismatch",
"status": "ok"
},
+ {
+ "category": "ops",
+ "details": "<live-census>",
+ "elapsed_ms": "<volatile>",
+ "message": "<live-census>",
+ "name": "session_lane_budget",
+ "status": "<live-census>"
+ },
{
"category": "ops",
"details": {
diff --git a/test/fixtures/goldens/doctor/registry-build-checks.json b/test/fixtures/goldens/doctor/registry-build-checks.json
index e159fdc11e..9c88532091 100644
--- a/test/fixtures/goldens/doctor/registry-build-checks.json
+++ b/test/fixtures/goldens/doctor/registry-build-checks.json
@@ -1041,6 +1041,10 @@
"category": "ops",
"name": "host_identity_mismatch"
},
+ {
+ "category": "ops",
+ "name": "session_lane_budget"
+ },
{
"category": "ops",
"name": "runtime_build_skew"
diff --git a/test/helpers/doctor-json-golden.ts b/test/helpers/doctor-json-golden.ts
index a1d6da7b2f..1e5fe9ea28 100644
--- a/test/helpers/doctor-json-golden.ts
+++ b/test/helpers/doctor-json-golden.ts
@@ -214,13 +214,25 @@ function maskWriterFloor(value: unknown): unknown {
[k, k === 'floor' && v === SEGMENTED_WRITER_FLOOR ? '<segmented-writer-floor>' : maskWriterFloor(v)]));
}
+/**
+ * GBRA-133: `session_lane_budget` on Postgres reports a live census of the server's connections (every client of the
+ * cluster, other test processes included), so its status, message and counts change between captures; the check's own
+ * test (test/doctor-session-lane-gbra133.test.ts) pins its behavior. PGLite's not-applicable entry stays exact.
+ */
+function maskSessionLaneCensus(report: unknown): unknown {
+ const checks = (report as { checks?: Array<Record<string, unknown>> } | null)?.checks;
+ if (!Array.isArray(checks)) return report;
+ return { ...(report as object), checks: checks.map(check => check.name === 'session_lane_budget' && check.readiness_state !== 'not_applicable'
+ ? { ...check, status: '<live-census>', message: '<live-census>', details: '<live-census>' } : check) };
+}
+
export function doctorJsonNormalizer(extra: Array<[RegExp | string, string]> = [], name = 'doctor-json-v1') {
return defineNormalizer<GbrainRun>(name, (run) => {
const fn = (s: string) => normalizeDoctorText(s, run.roots, extra);
return {
args: run.args.map(fn),
exit_code: run.exitCode,
- report: run.json === null ? null : mapStrings(maskWriterFloor(scrubKeys(run.json, VOLATILE_KEYS)), fn),
+ report: run.json === null ? null : mapStrings(maskSessionLaneCensus(maskWriterFloor(scrubKeys(run.json, VOLATILE_KEYS))), fn),
stdout: run.json === null ? fn(run.stdout).split('\n').filter(Boolean) : '<json>',
stderr: fn(run.stderr).split('\n').filter(Boolean),
};
diff --git a/test/postgres-unit-arms.txt b/test/postgres-unit-arms.txt
index 8844966e9f..b6247d9311 100644
--- a/test/postgres-unit-arms.txt
+++ b/test/postgres-unit-arms.txt
@@ -89,6 +89,7 @@ test/doctor-frontmatter-holds.test.ts
test/doctor-image-embedding-coverage.test.ts
test/doctor-keyword-plan-6495.test.ts
test/doctor-routing-skill-pack-source.test.ts
+test/doctor-session-lane-gbra133.test.ts
test/doctor-strict-facts-outside-git.test.ts
test/doctor-sync-freshness-skill-pack-6076.test.ts
test/edge-whitespace-twins.test.ts