mirror of
https://github.com/garrytan/gbrain.git
synced 2026-08-14 08:53:22 +00:00
Merge origin/master into garrytan/houston-v1 — fold in master's v0.39.0.0 (PR #1283)
Master shipped v0.39.0.0 (brainstorm cost cathedral, PR #1283) — the same content we already integrated via the shanghai-v3 merge at T1. This merge is largely a no-op for code; only CHANGELOG.md + TODOS.md had textual conflicts to reconcile. Resolved conflicts: 1. CHANGELOG.md, region 1 (~line 60): "73 new tests" sentence — master updated the parenthetical to reflect the v81→v86 migration renumber we did in the earlier shanghai-v3 merge. Took master's text since it's more accurate. 2. CHANGELOG.md, region 2 (~line 65): "To take advantage of v0.39.0.0" block. HEAD was empty (we accidentally lost the block in the prior merge); master had the full instructions block referencing migration v86. Took master's block. 3. CHANGELOG.md, region 3 (~line 867): a duplicate v0.38.0.0 "To take advantage" section that included both schema-pack engine steps AND ingestion cathedral steps concatenated together. Master deletes the duplicate (both v0.38.0.0 entries already exist properly earlier in the file at their own dedicated entries). Took master's deletion. 4. TODOS.md (~line 4): our v0.39.1+ schema-cathedral follow-ups block that filed 5 items at v0.39.0.0 ship time. Master had nothing there. Kept ours. Auto-merged successfully (no conflict): src/commands/doctor.ts, src/core/cycle.ts, src/core/migrate.ts, llms-full.txt, TODOS.md (other regions). Regenerated llms-full.txt via `bun run build:llms` to catch CHANGELOG-driven drift after the conflict resolution. Verified: - 3-line version audit: VERSION / package.json / CHANGELOG all 0.39.0.0 - bun install: clean (no changes) - bun run typecheck: clean - bun run verify: all 11 pre-checks green - bun test on key suites: 365 pass, 0 fail (build-llms, resolver, skills-conformance, check-resolvable, active-pack-wiring — covers the prior fix-wave's surface) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+28
-73
@@ -56,12 +56,39 @@ If you wrote integration code against `BudgetExhausted` in the brainstorm orches
|
||||
|
||||
### For contributors
|
||||
|
||||
- `bun test` adds 73 new tests across 9 new files (`test/core/budget/`, `test/core/audit-week-file.test.ts`, `test/core/diarize/`, `test/brainstorm/checkpoint.test.ts`, `test/e2e/brainstorm-resume.test.ts`, `test/core/remediation-checkpoint.test.ts`). Plus F1 closes the pre-existing PGLite `page_links` schema gap (the brainstorm domain-bank queries `page_links` but the embedded schema only defined `links`). Brainstorm now works against PGLite brains in production via the new `page_links` view alias shipped in both the embedded schema bundle and migration v81. F2 adds an E2E pinning the user-facing `--max-cost` pre-flight refusal path. F3 adds `--max-cost` to `gbrain reindex --code`. All previous brainstorm + doctor + eval-contradictions tests still pass.
|
||||
- `bun test` adds 73 new tests across 9 new files (`test/core/budget/`, `test/core/audit-week-file.test.ts`, `test/core/diarize/`, `test/brainstorm/checkpoint.test.ts`, `test/e2e/brainstorm-resume.test.ts`, `test/core/remediation-checkpoint.test.ts`). Plus F1 closes the pre-existing PGLite `page_links` schema gap (the brainstorm domain-bank queries `page_links` but the embedded schema only defined `links`). Brainstorm now works against PGLite brains in production via the new `page_links` view alias shipped in both the embedded schema bundle and migration v86 (renumbered from v81 during merge with master's v0.38 cathedrals which claimed v81-v85). F2 adds an E2E pinning the user-facing `--max-cost` pre-flight refusal path. F3 adds `--max-cost` to `gbrain reindex --code`. All previous brainstorm + doctor + eval-contradictions tests still pass.
|
||||
|
||||
## To take advantage of v0.39.0.0
|
||||
|
||||
`gbrain upgrade` should do this automatically. If it didn't, or if `gbrain doctor`
|
||||
warns about a partial migration:
|
||||
|
||||
1. **Run the orchestrator manually:**
|
||||
```bash
|
||||
gbrain apply-migrations --yes
|
||||
```
|
||||
This applies migration v86 (`page_links_view_alias`) on PGLite + Postgres brains. The alias is required for `gbrain brainstorm` and `gbrain lsd` to work against the domain-bank tiebreaker; without it, the brainstorm domain-bank queries fail with `relation "page_links" does not exist`.
|
||||
2. **Set a cost cap on the commands you care about:**
|
||||
```bash
|
||||
# Sets a per-run dollar ceiling. Throws BudgetExhausted before any LLM call
|
||||
# if the pre-run estimate exceeds the cap, AND mid-run if cumulative spend
|
||||
# blows past it.
|
||||
gbrain brainstorm "test" --max-cost 1
|
||||
gbrain doctor --remediate --max-cost 5
|
||||
gbrain reindex --code --max-cost 10
|
||||
```
|
||||
3. **Verify the outcome:**
|
||||
```bash
|
||||
gbrain doctor # schema_version should be 86
|
||||
gbrain brainstorm --list-runs # confirms the new checkpoint directory exists
|
||||
```
|
||||
4. **If any step fails or the numbers look wrong,** please file an issue:
|
||||
https://github.com/garrytan/gbrain/issues with:
|
||||
- output of `gbrain doctor`
|
||||
- contents of `~/.gbrain/upgrade-errors.jsonl` if it exists
|
||||
- which step broke
|
||||
|
||||
This feedback loop is how the gbrain maintainers find fragile upgrade paths. Thank you.
|
||||
## [0.38.2.0] - 2026-05-22
|
||||
|
||||
**`gbrain doctor` no longer hangs on big brains, and gives you real signal when it has to give up.**
|
||||
@@ -837,78 +864,6 @@ Credited contributors per the CHANGELOG attribution convention; closing comments
|
||||
```bash
|
||||
gbrain apply-migrations --yes
|
||||
```
|
||||
2. **Your existing brain works unchanged.** No data mutation. Pages keep their type values; gbrain-base reproduces pre-v0.38 behavior byte-for-byte.
|
||||
3. **Verify the outcome:**
|
||||
```bash
|
||||
gbrain schema active # should show gbrain-base
|
||||
gbrain stats # should match pre-upgrade output
|
||||
gbrain doctor # should pass
|
||||
```
|
||||
4. **When ready, author your own pack:**
|
||||
```bash
|
||||
# Create ~/.gbrain/schema-packs/my-pack/pack.yaml (see example above)
|
||||
gbrain schema validate my-pack
|
||||
gbrain schema use my-pack
|
||||
gbrain schema active # → my-pack
|
||||
```
|
||||
5. **If any step fails or the numbers look wrong,** please file an issue at https://github.com/garrytan/gbrain/issues with:
|
||||
- output of `gbrain doctor`
|
||||
- output of `gbrain schema active`
|
||||
- which step broke
|
||||
|
||||
### Itemized changes
|
||||
|
||||
#### Engine
|
||||
- Open PageType from closed 23-element union to `string`. TakeKind same. ~30 `as PageType` cast sites widen to `as string` at SQL row boundaries.
|
||||
- New `src/core/schema-pack/` module (10 files): manifest-v1, primitives, loader (YAML/JSON sniffing, hand-rolled flow-sequence parser), closure (E8 alias graph BFS), per-source CTE builder, candidate-audit (sha8-redacted by default), redos-guard (vm.runInContext + 500ms page budget), registry (7-tier resolution, extends-chain depth cap), load-active (boundary helper), op-trust-gate (D13 per-call trust validator).
|
||||
- New `src/core/distribution/` module: named shared-helpers boundary for tarball, trust-prompt, registry-client, remote-source, registry-schema, scaffold-third-party. Re-exports from `src/core/skillpack/` for v0.37 back-compat. Import-allowlist boundary pinned by test.
|
||||
- Pack-aware primitives (each parity-tested against gbrain-base): `inferTypeFromPack`, `inferLinkTypeFromPack`, `frontmatterLinkTypeFromPack`, `expertTypesFromPack`, `extractableTypesFromPack`, `enrichableTypesFromPack`, `rubricNameForType`.
|
||||
- `gbrain-base.yaml` (universal starter pack): 22 page types with priority-correct ordering (writing/wiki subtypes scan FIRST per legacy inferType priority), 12 link verbs, 4 takes_kinds, person+company expert routing, 7 facts-extractable types, person/company/deal enrichable. CI-pinned byte-for-byte parity gate.
|
||||
|
||||
#### Migrations
|
||||
- **v80**: drops `takes_kind_check` CHECK constraint on the takes table (Postgres + PGLite). Closes the v41/v48-era CHECK. Runtime validation against active pack takes over.
|
||||
- **v81**: adds `eval_candidates.schema_pack_per_source JSONB` column. Stores inline canonical closure snapshot `{source_id → {pack_name, pack_version, manifest_sha8, alias_closure_resolved}}` for self-contained eval replay (E11). NULL-tolerant for pre-v0.38 captured rows.
|
||||
|
||||
#### CLI
|
||||
- `gbrain schema active` — show resolved pack + which of 7 tiers provided it.
|
||||
- `gbrain schema list` — list bundled + installed packs.
|
||||
- `gbrain schema show [<pack>]` — pretty-print manifest with page types, link verbs, takes kinds, enrichable types.
|
||||
- `gbrain schema validate [<pack>]` — validate manifest shape.
|
||||
- `gbrain schema use <pack>` — activate pack via file-plane. Validates before writing; refuses malformed packs.
|
||||
|
||||
#### Tooling
|
||||
- `scripts/spike-bun-vm-timeout.ts` — Bun vm.runInContext timeout spike for E9. PASS on Bun 1.3.13.
|
||||
- `scripts/generate-gbrain-base.ts` — codegen validator. Loads gbrain-base.yaml, asserts ALL_PAGE_TYPES coverage + deterministic re-load.
|
||||
|
||||
#### Tests
|
||||
- 95+ new tests across 12 new test files: schema-pack-loader (38), v80-v81-smoke (3), gbrain-base-equivalence (8), distribution-import-boundary (2), schema-pack-load-active (9), schema-pack-trust-boundary (8), infer-type-pack (5), link-inference-pack (10), expert-types-pack (6), extractable-pack (4), enrichable-pack (4), schema-cli (8).
|
||||
- `test/page-type-exhaustive.test.ts` rewritten for v0.38 model.
|
||||
|
||||
#### Plan + design doc
|
||||
- `docs/designs/V038_SCHEMA_PACKS.md` — full design with CEO + Eng + 3× Outside Voice review record. 16 locked decisions (D1-D16, E1-E11). 58 codex findings folded across three review passes.
|
||||
2. **Try the capture verb:**
|
||||
```bash
|
||||
gbrain capture "first thought into v0.38"
|
||||
gbrain query "first thought"
|
||||
```
|
||||
The receipt block should show the slug + file path; the query should
|
||||
return the page within a second.
|
||||
3. **For webhook ingestion** (only if you run `gbrain serve --http`):
|
||||
```bash
|
||||
curl -X POST https://your-brain/ingest \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: text/markdown" \
|
||||
-d "# webhook test"
|
||||
```
|
||||
You should see HTTP 202 + a `job_id`. Run `gbrain query "webhook test"`
|
||||
to confirm the page landed.
|
||||
4. **If any step fails or the numbers look wrong,** please file an issue:
|
||||
https://github.com/garrytan/gbrain/issues with:
|
||||
- output of `gbrain doctor`
|
||||
- contents of `~/.gbrain/upgrade-errors.jsonl` if it exists
|
||||
- which step broke
|
||||
|
||||
This feedback loop is how the gbrain maintainers find fragile upgrade paths. Thank you.
|
||||
2. **Verify the source-routing fix on your federated brains:**
|
||||
```bash
|
||||
gbrain sources current
|
||||
|
||||
@@ -4014,6 +4014,35 @@ export const MIGRATIONS: Migration[] = [
|
||||
ADD COLUMN IF NOT EXISTS schema_pack_per_source JSONB NULL;
|
||||
`,
|
||||
},
|
||||
{
|
||||
version: 86,
|
||||
name: 'page_links_view_alias',
|
||||
// v0.39 — pglite-engine.ts and postgres-engine.ts both query a relation
|
||||
// named `page_links` (LEFT JOIN page_links pl ON pl.to_page_id = p.id —
|
||||
// see pglite-engine.ts:896 / postgres-engine.ts:959). The canonical
|
||||
// table has always been `links`. This migration installs a `page_links`
|
||||
// VIEW that aliases the table so brains initialized before the v0.39
|
||||
// schema bundle pick up the alias on upgrade.
|
||||
//
|
||||
// Fresh installs already get the view via the embedded schema bundle.
|
||||
// This migration is idempotent (CREATE OR REPLACE VIEW) so re-running
|
||||
// is safe on either engine.
|
||||
//
|
||||
// Discovered during the brainstorm-cathedral wave (v0.39.0.0) when the
|
||||
// E2E test had to workaround the missing view to exercise the resume
|
||||
// path. Originally numbered v81; renumbered to v86 during merge with
|
||||
// master's v0.38 cathedrals (provenance / subagent / spend / oauth
|
||||
// binding) which claimed v81-v85.
|
||||
//
|
||||
// Narrow projection (id, from_page_id, to_page_id) so the view does not
|
||||
// depend on columns added in later migrations (link_source,
|
||||
// origin_page_id, resolution_type) — keeps ALTER TABLE DROP COLUMN
|
||||
// and the bootstrap forward-reference probes unblocked on legacy brains.
|
||||
sql: `
|
||||
CREATE OR REPLACE VIEW page_links AS
|
||||
SELECT id, from_page_id, to_page_id FROM links;
|
||||
`,
|
||||
},
|
||||
];
|
||||
|
||||
export const LATEST_VERSION = MIGRATIONS.length > 0
|
||||
|
||||
Reference in New Issue
Block a user