fix(bootstrap): cover v0.34.1 oauth_clients.{source_id, federated_read} columns#1017
Closed
ChenyqThu wants to merge 1 commit into
Closed
fix(bootstrap): cover v0.34.1 oauth_clients.{source_id, federated_read} columns#1017ChenyqThu wants to merge 1 commit into
ChenyqThu wants to merge 1 commit into
Conversation
…d} columns
Extends applyForwardReferenceBootstrap in both PostgresEngine and
PGLiteEngine to probe oauth_clients.{source_id, federated_read} and
ALTER TABLE ADD COLUMN IF NOT EXISTS them when the table exists but
the columns don't.
Without this, brains upgrading from a pre-v0.34 schema (which has
oauth_clients but no source_id / federated_read columns) crash at
schema-embedded.ts during SCHEMA_SQL replay with:
column "source_id" does not exist
…on the CREATE INDEX idx_oauth_clients_source_id partial-index and the
parallel idx_oauth_clients_federated_read GIN-index statements. The
migration chain (v60-v65) backfills both columns + RLS policies later,
but it can't run until SCHEMA_SQL replay succeeds, so the bootstrap
must add enough state up front.
Pattern lift from garrytan#627 (superseded by upstream fix wave garrytan#682+garrytan#741,
which extended the same mechanism to mcp_request_log.{agent_name,
params, error_message} in v0.26.3). Same shape:
1. Probe rows in the existing information_schema EXISTS round-trip
for the table + each column.
2. needsOauthClientsBootstrap when the table exists but either column
is missing.
3. Extra clause in the early-return guard so fresh installs and
modern brains still no-op.
4. ALTER TABLE block at the end of the function alongside the other
missing-column bootstraps. source_id picks up its FK to sources(id)
and federated_read its NOT NULL DEFAULT '{}'.
Coverage:
- test/schema-bootstrap-coverage.test.ts — REQUIRED_BOOTSTRAP_COVERAGE
gains two entries (oauth_clients.source_id, oauth_clients.federated_read).
Contract test strips both columns, runs the bootstrap, then asserts
they exist after SCHEMA_SQL replay — same as every other v33+ column
the test already covers.
Validation:
- bun run typecheck clean
- bun test test/schema-bootstrap-coverage.test.ts test/bootstrap.test.ts:
11 pass / 0 fail (was 11 pass with 48 expect() calls; now 50 — the +2
new probes).
Field repro (Jarvis KOS v2 fork, 2026-05-09 v0.31.2 → v0.34.4 sync):
schema v45 → v66 bumped via gbrain init --migrate-only, which forced
the SCHEMA_SQL replay path and tripped the idx_oauth_clients_source_id
DDL. Manually ALTER-ed the two columns; migrations then ran v60-v65
clean. Same pattern as the mcp_request_log trap in v0.26.7 sync.
ChenyqThu
pushed a commit
to ChenyqThu/jarvis-knowledge-os-v2
that referenced
this pull request
May 15, 2026
JARVIS-ARCHITECTURE.md §6.25 records the 2026-05-15 follow-up session: diagnostic correction (the historical 117k stderr "fire" that wasn't), two upstream PRs filed (garrytan#1016 google max_batch_tokens, garrytan#1017 oauth_clients forward-bootstrap), CJK keyword-only eval verdict, overlap-matrix verdict, M2-B + M2-C verdicts, mechanical cleanup (48 sync_failures ack'd, bun-test hang root-caused), and the new [facts:absorb] sub-process DB-connection latent bug. 8 TODO items closed, 1 new entry filed. CLAUDE.md "Chinese-first knowledge base" rule tightened per the CJK-eval verdict: the strict invariant is *compound CJK (4+ Han chars without whitespace) requires vector*; English and 2-3 char standalone CJK match fine on keyword. Operational guidance unchanged — the modal operator query on this brain is a compound CJK phrase that depends on vector being live. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Author
|
Superseded by upstream v0.35.5.0 (4446e9f9, PR #1111). The v0.35.5.0
Same pattern as #627 (closed when v0.31.1.1 fixwave superseded with broader v0.20 + v39-v41 column coverage). Production impact for jarvis-knowledge-os-v2 fork: already manually ALTER-ed on the prod DB during v0.34.4 sync (per docs/JARVIS-ARCHITECTURE.md §6.24); v0.35.6.0 sync landed today (2026-05-17) and |
ChenyqThu
pushed a commit
to ChenyqThu/jarvis-knowledge-os-v2
that referenced
this pull request
May 17, 2026
…08 commits, v0.34.4 → v0.35.6.0) Auto-merge: 95% clean. WAL fork patch + pglite 0.4.4 override + google.ts max_batch_tokens patch all survived. Real conflicts: 2 (.gitignore + CLAUDE.md), both mechanical (fork-only block reorder). Key value: - v0.35.5.0 bootstrap fixwave (4446e9f) SUPERSEDES fork PR garrytan#1017 (oauth_clients.source_id + federated_read). Upstream adds 7 probes + files.* + sources.archived.* + DDL connection threading + MIGRATIONS introspection guard — strict superset of our PR. - v0.35.4.0 entity bare-name resolver 58x perf benefits enrich-sweep. - v0.35.5.0 walker pruneDir speeds up sync (descent-time exclusion). - v0.35.6.0 search floor-ratio gate improves retrieval quality. - v0.35.5.1 supervisor clean-exit classification reduces launchd noise. Validation: bun typecheck clean, bun test test/ai/+bootstrap 221/221 pass, bun run build emits 0.35.6.0 binary. Production: bun install postinstall silent-applied migrations (schema_version still 66, 3138 pages preserved, brain_score 80/100 unchanged, RLS 41/41). 5 launchd services bootout/bootstrap clean; kos-compat-api PID 9074 serving /status with 3138 pages locally + via kos.chenge.ink. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ChenyqThu
pushed a commit
to ChenyqThu/jarvis-knowledge-os-v2
that referenced
this pull request
May 17, 2026
§6.26 in JARVIS-ARCHITECTURE.md: 9-version upstream sync (108 commits, v0.34.4 → v0.35.6.0), only 2 real conflicts, PR garrytan#1017 superseded by v0.35.5.0 garrytan#1111 bootstrap fixwave, brain_score 80/100 unchanged, 3138 pages preserved, ~1h end-to-end vs 3-3.5h plan estimate. TODO.md: header bumped to post-v0.35.6.0 state, PR-2 entry marked CLOSED 2026-05-17 with supersede link. README.md: upstream_compat bumped >= 0.35.6.0. CONSOLIDATION-PLAN.md: Last reviewed bumped to 2026-05-17. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
applyForwardReferenceBootstrapin bothPostgresEngineandPGLiteEnginecovers 9 forward-reference targets thatschema-embedded.tsmakes (pages.source_id, pages.deleted_at, links., content_chunks., mcp_request_log.*, subagent_messages.provider_id, ingest_log.source_id, …) — but missed v0.34.1'soauth_clients.{source_id, federated_read}additions.Result: brains upgrading from a pre-v0.34 schema (which has
oauth_clientsbut neither column) crash atschema-embedded.tsduring SCHEMA_SQL replay with:…on the partial-index
CREATE INDEX idx_oauth_clients_source_id ON oauth_clients(source_id) WHERE source_id IS NOT NULLand on the parallelidx_oauth_clients_federated_readGIN-index DDL. Migrations v60-v65 backfill both columns + RLS policies later, but they can't run until SCHEMA_SQL replay succeeds, so the bootstrap must add enough state up front.Patch shape
Same pattern as #627 (superseded by upstream fixwave #682+#741 for
mcp_request_logv0.26.3 columns):information_schemaEXISTS round-trip —oauth_clients_exists,oauth_source_id_exists,oauth_federated_read_exists.needsOauthClientsBootstrapwhen the table exists but either column is missing.ALTER TABLEblock at the end of the function alongside the other missing-column bootstraps.source_idpicks up its FK tosources(id)andfederated_readitsNOT NULL DEFAULT '{}'.Mirrored across
src/core/postgres-engine.tsandsrc/core/pglite-engine.ts. Doc comments at the top of each function updated to list the new coverage.Test follow-through
test/schema-bootstrap-coverage.test.tsgains two entries inREQUIRED_BOOTSTRAP_COVERAGE(oauth_clients.source_id,oauth_clients.federated_read). The existing contract test strips both columns, runs the bootstrap, then asserts they exist after SCHEMA_SQL replay — same loop as every other v33+ column the test already covers.E2E test (
test/e2e/postgres-bootstrap.test.ts) was not extended in this PR — its single "pre-v0.18" mutation scenario is structurally identical for any forward-reference target, and the contract test already validates the per-column bootstrap. Happy to add an oauth-specific E2E case if maintainers prefer.Validation
bun run typecheckcleanbun test test/schema-bootstrap-coverage.test.ts test/bootstrap.test.ts:expect()calls; now 50 — the +2 new probes)Field repro
Hit during the Jarvis KOS v2 fork's v0.31.2 → v0.34.4 sync (commit
1b6acd77):bun installpostinstall rangbrain apply-migrations(requires schema_version ≥ 51 for the v0.32.2 facts orchestrator).gbrain init --migrate-onlyto bump v45 → v66 failed at theidx_oauth_clients_source_idDDL.ALTER TABLE oauth_clients ADD COLUMN IF NOT EXISTS source_id … / federated_read …; migrations v60-v65 then ran clean in under a minute.mcp_request_logtrap that produced fix(bootstrap): cover v0.26.3 mcp_request_log columns #627 in our v0.26.7 sync.🤖 Generated with Claude Code