Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(doctor): session_lane_budget takes its environment from the caller (#7302, from #8144)
garrytana24544913e18
diff --git a/src/commands/doctor/checks/session-lane.ts b/src/commands/doctor/checks/session-lane.tsindex 6a000f586a..9523bb1ea1 100644--- a/src/commands/doctor/checks/session-lane.ts+++ b/src/commands/doctor/checks/session-lane.ts@@ -23,7 +23,7 @@ async function runSessionLaneBudget(ctx: DoctorContext): Promise<Check[]> {return checks;}try {- const census = await readSessionLane(engine, [loadConfig()?.database_url ?? '', process.env.GBRAIN_DIRECT_DATABASE_URL ?? '']);+ const census = await readSessionLane(engine, [loadConfig()?.database_url ?? '', process.env.GBRAIN_DIRECT_DATABASE_URL ?? ''], process.env);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 };diff --git a/src/core/session-lane.ts b/src/core/session-lane.tsindex 18984f4fca..7ca08708c9 100644--- a/src/core/session-lane.ts+++ b/src/core/session-lane.ts@@ -37,7 +37,7 @@ export interface SessionLaneCensus {behind_pooler: boolean;}-export function sessionLaneLimitFromEnv(env: Record<string, string | undefined> = process.env): number | null {+export function sessionLaneLimitFromEnv(env: Record<string, string | undefined>): number | null {const raw = env[SESSION_LANE_LIMIT_ENV]?.trim();if (!raw) return null;const value = Number(raw);@@ -74,8 +74,8 @@ export function summarizeSessionLane(input: { rows: Array<{ application_name: stused: 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> {+/** 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). `env`: the caller's environment, which holds the limit. */+export async function readSessionLane(engine: BrainEngine, urls: readonly string[], env: Record<string, string | undefined>): Promise<SessionLaneCensus> {const rows = await engine.executeRaw<{ application_name: string | null; connections: number | string }>(`SELECT application_name, count(*)::int AS connections FROM pg_stat_activityWHERE datname = current_database() AND usename = current_user AND backend_type = 'client backend' GROUP BY application_name`);