test(gbrain-doctor): pin schema_version:2 doctor parse path (#1418)

Adds an exec-path regression test that runs a fake gbrain shim emitting
the v0.25+ doctor JSON shape (schema_version: 2, status: "warnings",
exit 1 for health_score < 100, no top-level `engine` field). Confirms
freshDetectEngineTier recovers stdout from the non-zero exit and falls
back to GBRAIN_HOME/config.json for the engine label.

The pre-existing test for #1415 only stripped gbrain from PATH; this
test exercises the actual doctor parse path, closing the gap that
codex's plan review flagged.

Also documents the schema_version separation in
lib/gbrain-local-status.ts: the local CacheEntry stays at version 1,
distinct from the doctor-output schema_version which we accept across
versions in gstack-memory-helpers.

Closes #1418 (credit @mvanhorn for surfacing the doctor + schema_v2
collapse). The fix landed pre-emptively in v1.29.x; this commit pins
it with a stronger test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-05-18 20:36:12 -07:00
parent 8b03c357ef
commit 8c956fa2a8
2 changed files with 43 additions and 0 deletions
+6
View File
@@ -51,6 +51,12 @@ export interface ClassifyOptions {
}
interface CacheEntry {
// Local-cache schema version, controlled by gstack. Not to be confused
// with `gbrain doctor --json` output schema_version (gbrain v0.25+ emits
// schema_version: 2). Doctor-output parsing lives in
// lib/gstack-memory-helpers.ts:freshDetectEngineTier and accepts both
// doctor-output versions. This cache stays strictly at version 1 — a
// future shape change here requires an explicit migration.
schema_version: 1;
status: LocalEngineStatus;
cached_at: number;