gbrain-local-status: 5s probe timeout misclassifies healthy-but-slow engines as broken-config; /sync-gbrain skips code+memory
Symptom
On a brain whose Postgres sits behind a Supabase transaction-mode pooler (port 6543), /sync-gbrain permanently skips the code + memory stages:
gstack-gbrain-sync (incremental):
SKIP code skipped — local engine broken-config — config at ~/.gbrain/config.json is malformed; see /setup-gbrain Step 1.5
SKIP memory skipped — local engine broken-config — ...
OK brain-sync curated artifacts pushed
…while the engine is in fact healthy: gbrain doctor is green and gbrain sources list --json returns valid JSON with exit 0. The config file is well-formed.
Root cause
lib/gbrain-local-status.ts classifies the engine by probing gbrain sources list --json with PROBE_TIMEOUT_MS = 5_000. On this setup a fresh CLI connection through the pooler takes 6.9–10.7s (measured across runs), so the probe times out every time. The timeout error's stderr matches neither "Cannot connect to database" nor "config.json", so the defensive default (codex #8) classifies it as broken-config — and the 60s cache then propagates the misdiagnosis to the orchestrator and every skill preamble.
The user-facing message ("config at ~/.gbrain/config.json is malformed") points at a file that is fine, so the remediation steps in /setup-gbrain Step 1.5 can't fix it.
Reproduce
Any gbrain on a connection where time gbrain sources list --json > 5s (e.g. Supabase transaction pooler from a residential connection). Then run /sync-gbrain → code+memory SKIP with broken-config.
Suggested fix (any of)
- Raise
PROBE_TIMEOUT_MS(20s covered my worst case), and/or - Honor an env override (e.g.
GSTACK_GBRAIN_PROBE_TIMEOUT_MS) so slow-pooler users can tune it without patching the lib, and/or - Classify the timeout case distinctly (e.g.
slow-engine) instead of falling intobroken-config, with a message that names the real condition ("probe exceeded Ns — engine may be reachable but slow; raise the timeout").
Locally patching PROBE_TIMEOUT_MS 5000→20000 fully resolves it (sync runs all stages), but the patch is reverted by every git reset --hard upgrade.
Another data point from a session-mode Supabase pooler (so not pooler-specific — plain network latency triggers it too):
gbrain sources list --jsonsucceeds (exit 0, valid JSON) but takes 5.3–5.8s across 3 runs (gbrain 0.42.40.0, postgres engine,gbrain doctorgreen,gbrain_doctor_ok: truein the same detect output).PROBE_TIMEOUT_MS = 5_000(lib/gbrain-local-status.ts:76) kills the probe, and the defensive default classifies the timeout asbroken-config→ brain-aware blocks suppressed despite a healthy brain.
An env override (e.g. GSTACK_GBRAIN_PROBE_TIMEOUT_MS) or distinguishing ETIMEDOUT/SIGTERM-on-timeout from real config errors before falling through to the defensive default would fix both this and the original report.
This is a health-check classification contract issue.
A 5s probe timeout should not automatically mean broken config.
It may mean:
healthy but cold
healthy but slow
engine warming
network slow
temporary load
broken config
auth failure
unreachable endpoint
Those states should be separated because /sync-gbrain should not skip code+memory just because a healthy engine was slow to respond once.
A standard AISP-style contract could express this:
[
{
"role": "system",
"content": {
"protocol": "AISP V1.0.0",
"axiom_0": "Human_Sovereignty_and_Wellbeing",
"id": "gstack_gbrain_health_probe_contract_aisp",
"name": "gstack gbrain Health Probe Contract",
"version": "1.0.0",
"license": "MIT",
"summary": "Machine-checkable contract for classifying gbrain health probes without mislabeling slow engines as broken config.",
"flow_format": "mermaid",
"loading_mode": "node",
"tools": ["shell"],
"params": {
"probe_timeout_seconds": "integer",
"engine_url": "string"
},
"system_prompt": ""
}
},
{
"role": "user",
"content": {
"instruction": "STRICTLY OBEY aisp_contract; its non_negotiable rules are inviolable; then RUN aisop.main",
"user_input": "{user_input}",
"aisp_contract": {
"profile": "aisp.skill.v1",
"invocation": {
"mode": "health_check_policy",
"when_to_use": [
"before sync-gbrain skips memory/code sync",
"when local status probe times out",
"when classifying gbrain config health"
],
"when_not_to_use": [
"manual force sync",
"explicit user override"
]
},
"non_negotiable": [
{
"rule": "A single timeout must not be classified as broken config without retry or reason.",
"enforced_by": "classify.step2:sys.assert"
},
{
"rule": "sync-gbrain skip decision must distinguish slow/unknown from broken config.",
"enforced_by": "decision.step2:sys.assert"
}
],
"discovery": {
"category": "health_check",
"tags": ["gstack", "gbrain", "health", "timeout", "sync", "aisp"]
},
"risk_level": "medium",
"resources": []
},
"aisop": {
"main": "graph TD\n probe[Run health probe] --> classify[Classify result]\n classify --> decision[Decide sync behavior]\n decision --> trace[Record probe trace]\n trace --> end_node((End))"
},
"functions": {
"probe": {
"step1": "Run health probe with configured timeout and optional retry/backoff.",
"output_mapping": "probe_result"
},
"classify": {
"step1": "Classify result as healthy, slow_unknown, warming, auth_failure, unreachable, broken_config, or unknown.",
"step2": "sys.assert('timeout alone is not broken_config', 'Timeout must not be classified as broken config without additional evidence')",
"output_mapping": "health_classification"
},
"decision": {
"step1": "Choose sync behavior: proceed, retry, warn, skip, or fail.",
"step2": "sys.assert('skip decision distinguishes slow from broken config', 'sync-gbrain skip must not treat slow as broken config')",
"output_mapping": "sync_decision"
},
"trace": {
"step1": "Record timeout, retries, classification, and sync decision.",
"output_mapping": "health_probe_trace"
},
"end_node": {
"step1": "Return health_probe_trace."
}
}
}
}
]
Minimal implementation:
1. Add retry/backoff or longer timeout for cold local engines.
2. Classify timeout as slow_unknown, not broken_config.
3. Let sync-gbrain choose warn/retry instead of skip where appropriate.
4. Emit trace showing why sync was skipped.
@16francej Please close this issue as resolved. #2077 added a separate timeout state, a longer configurable probe timeout, and proceed-with-warning behavior, so a slow healthy GBrain is no longer mislabeled as broken configuration.
Verified already fixed on main, in two parts:
- The probe timeout is overridable:
GSTACK_GBRAIN_PROBE_TIMEOUT_MS(default now 15s, was 5s) viaprobeTimeoutMs()inlib/gbrain-local-status.ts. - A timed-out probe classifies as
timeout(slow-but-healthy), neverbroken-config, and every consumer (--is-ok, gen-skill-docs,gstack-config gbrain-refresh, the sync stages) treatstimeoutas usable — brain-aware blocks are no longer suppressed for slow poolers.
Regression test: test/gbrain-local-status.test.ts ("returns 'timeout' (not broken-config) when the probe exceeds the deadline (#1964)").
The remaining sibling gap (thin-client/remote-MCP setups misclassified as broken-config) is #2051, fixed in PR #2472. Closing this one.