Repository navigation
Description
Out of scope
No relay-policy relaxation, credential forwarding, key rotation, new provider interface, or change to the independent maintenance git-step and failure-reporting issues (#3357/#3364). No package fix is presumed for an installation outside the package's declared peer range.
Context and diagnosis — 2026-11-04
The reported API_KEY_INVALID failure is explained by an unsupported optional provider SDK. The published @schlessera/brain 0.44.0 declares @google/genai ^2.24.0, but @google/genai 2.10.0 ignores the httpOptions.fetch hook that the Gemini embedding and completion providers use for relayed requests.
Source boundaries: peerDependencies (packages/core/package.json:107-109); getClient (packages/core/src/providers/embeddings/gemini.ts:67-90); providerRelayFetch (packages/common/src/provider-relay.ts:69-86). The provider deliberately gives the SDK the nonsecret brain-provider-relay-placeholder while the host relay owns the real key. Ignoring the fetch hook instead sends that placeholder through the ordinary provider transport, which explains invalid-key errors with no matching relay receipts.
The earlier operator handoff is now satisfied: the failing maintenance windows had no Gemini relay receipts, and the cron/server key values were equal byte for byte. No key value, fingerprint, installation identifier or private tracker reference is recorded here. Historical source-only fixtures passed against the supported workspace dependency; they did not exercise the incompatible SDK.
Reproduction evidence
A keyless probe against the actual installed @google/genai 2.10.0 constructed GoogleGenAI with apiKey: "brain-provider-relay-placeholder" and httpOptions: { fetch: relay }, then invoked models.embedContent and models.generateContent. The probe replaced global fetch with a local synthetic Response producer before either invocation. It made no network/provider request and used only fictional Odysseus input.
Observed: relayCalls=0, directCalls=2; both intercepted ordinary requests carried the placeholder as x-goog-api-key. The operations were batchEmbedContents and generateContent. The SDK source uses global fetch and does not consume the supplied hook. This reproduces the dependency incompatibility; it is not evidence that the configured real key is invalid. The supported dependency correction is now installed and qualified; see the completion receipt below.
Scope and remaining completion
The diagnostic deliverable is complete. Correct the consumer's dependency constraint and lockfile to satisfy the released core peer requirement, then verify its own importer's installed SDK and the admitted maintenance path. That installation correction does not require a new brain-kit release. Keep this issue open solely for sanitized supported-installation verification; no unspecified engine implementation is agent-ready.
Acceptance criteria
- Explain the failing request path with a keyless causal reproduction and distinguish it from a wrong host key.
- Establish whether the failing requests reached the relay and whether cron/server key values differed, without publishing secrets.
- After correcting the consumer dependencies, verify the actual provider importer's SDK satisfies the released peer range and honors the relay fetch for embeddings and chunk-context completions.
- Record a bounded/scheduled maintenance result with no invalid-placeholder authentication errors and matching Gemini relay receipts. Report any independent maintenance failure separately.
Verification
Retain the keyless old-SDK control and compare with the corrected resolved SDK, intercepting ordinary network transport in both. Record versions and relay/direct counts. For the admitted maintenance check, correlate its time window with relay receipt operation/status/outcome counts. Do not claim successful supported-version operation from the incompatible-SDK probe alone.
Contract impact
None. The correction conforms to the already published optional peer requirement; CLI/MCP/wire/environment relay contracts are unchanged.
Reconciliation 2026-11-04: replaces the earlier unresolved-cause brief using the completed operator checks and installed-SDK probe. Remove needs: repro and needs: human. Preserve p1 and milestone 0.45.0, keep agent-ready absent, and close only after the supported installation is verified. Earlier fixture/reproduction receipts remain in the dated comments.
Supported-installation verification — 2026-11-04
Supported installation verified: @schlessera/brain 0.44.0 with @google/genai 2.24.0, satisfying the declared ^2.24.0 peer range. Both actual embedding and completion importers resolve that supported SDK. Keyless intercepted controls: relay-hook calls 2, ordinary transport calls 0; retained 2.10.0 control: relay-hook calls 0, intercepted ordinary calls 2. No network in either control.
One admitted maintenance invocation completed indexing with 549 embeddings and no API_KEY_INVALID or deferred-context failure. Matching Gemini relay receipts: completions 548, embeddings 13; every receipt has HTTP status 200 and outcome completed, with no outstanding dispatched requests.
Overall maintenance exit status was 2 due to the independent git packing failure. That remains separate from the now-verified provider dependency correction. No new engine release or relay-policy change was required.
Activity
schlessera commentedon Nov 2, 2026
Triage (2026-11-02, source at
3984040f1):needs: repro.The report is evidence that the hosted path misbehaves. It does not yet reproduce the failure or name its cause. The body traces the relayed path and lists unconfirmed candidates.
What was tried in this triage. I read the source only. I did not run the existing
packages/ui-server/tests/maintenance-provider-relay.test.tsor a new fixture: this triage checkout has no installed dependencies, and the native proof image is absent here. That test already provesbrain searchrelays correctly in a maintenance worker. It does not exercise the cron host,brain maintainor chunk-context completions.What completes the repro. Either is enough:
Agent, keyless: the cron-path fixture in Scope step 1. If it fails on main, record the failing assertion here, remove
needs: reproand addagent-ready. If it passes, record the run and how it differs from the hosted run.Operator, on the affected install (sanitized result posted here): look at the relay's metered receipts for one failing
maintainrun.GEMINI_API_KEYwith the server's, byte for byte (quoting, whitespace).BRAIN_PROVIDER_RELAY_SOCKETandBRAIN_WITHHELD_KEYS.Post only which case applied, never a key or host detail.
There is no dependency on #3357 or #3364.
schlessera commentedon Nov 2, 2026
Claiming (token
wi-3363-b5dd) to build the keyless cron-path reproduction from the triage comment. Branch:test/3363-cron-gemini-key-repro. Collision check: path overlap only with #3335 onpackages/ui-server/src/brain/host-boundary.ts(I expect to add a test, not edit it); the rest are closure-only reports. Scope stays off #3357 and #3364.schlessera commentedon Nov 2, 2026
Keyless cron-path reproduction (2026-11-02): the engine path is correct on
mainat3984040f1.needs: reprostays.PR #3378 adds
packages/ui-server/tests/cron-maintain-provider-relay.test.ts. It covers Scope step 1:brain-ui-cron run maintain -- … maintainhost execution, with a native-storage fixture;brain maintain, indexing a multi-chunk note (generated chunk contexts) and a single-chunk note;BRAIN_UI_CLI_PROVIDER_ORIGINS. It records each request'sx-goog-api-keyand answers any other key with Google'sAPI_KEY_INVALID400.The relay's
provider_relay_usagereceipts in the run's UI database show what went through the relay.What it shows:
generateContent(chunk-context) request reaches the provider with the host key. There is exactly one completed relay receipt per request, so nothing goes around the relay.GEMINI_API_KEY. It hasBRAIN_WITHHELD_KEYS=GEMINI_API_KEYand the relay socket, and the brain's.env(holding another fixture key) is masked.SKIP embed batch: {"error":{"code":400,… "API_KEY_INVALID" …andN chunk context(s) failed — deferred to the next --embeddings run. Those requests still go through the relay, with one Gemini receipt per request carrying the upstream's 400.Failing-first and mutation evidence.
CRON_MAINTAIN_EVERY_REQUEST_RELAYED,CRON_MAINTAIN_WORKER_KEYLESSandCRON_MAINTAIN_WRONG_VALUE_METERED(expected 4 receipts, received 0). With that mutation the wrong value bypasses the relay, which is the triage's other branch.providerRelayFetchturnCRON_MAINTAIN_NO_PROVIDER_FAILUREred.maintainsub-path reads a key the boundary did not remove" nor "a request path that does not useproviderRelayFetch" reproduces onmain.Differences from the hosted run that this fixture cannot cover:
brainCLI runs from this tree's source, not an installed build.Conclusion. The remaining cause must be the host supplying the run a
GEMINI_API_KEYvalue that the provider rejects.Next action (operator, unchanged from triage): for one failing
maintainrun, look at the relay's metered receipts.GEMINI_API_KEYwith the server's byte for byte (quoting, whitespace).BRAIN_PROVIDER_RELAY_SOCKETandBRAIN_WITHHELD_KEYS.Post only which case applied, never a key or host detail.
test(ui-server): drive cron maintain through the provider relay with …
schlessera commentedon Nov 4, 2026
Reproduction snapshot — 2026-11-04: inconclusive; retain
needs: reproandneeds: human.Inspected clean
origin/main/ HEAD53b862123d7b8e4c9d039859fabdc9fc6ad4cd36(fetched before investigation). I read the full issue and all three comments, checked the native parent endpoint (404, explicitly “No parent issue found”), and inspected #1673/#2743, #3378, #3357, #3364 and #3246. #3378 is now merged, squash78cd31ee9f67f0e54631de9f3f2e67cb0e0e033e; its fixture is present in this snapshot. The issue remains standalone; no relationship or assignment changes.Environment. Ubuntu 26.04.1 LTS, Linux
7.0.0-42-genericx86_64; Bun1.4.4(38afee6c8), bubblewrap0.11.1, installed@google/genai2.24.0 from the frozen lockfile, Python3.14.4, Linux-PAM1.7.0-5ubuntu3.2; rootless Docker29.1.3. Runtime fixture commands used--network none, the repository's offline preload, real bubblewrap, and only fictional Odysseus keys/content. Docker base image IDsha256:eff16c30e6f3f4af0a03fa4b706120d5e9b0891c344a27d64559aff5900a4a27, with the host's/usrand actual Bun executable mounted read-only. No live provider requests or credentials were used.bun.lockSHA-256:ecf6986227406c1fd9d835ae3c119d561e012df5a1bedcae599907332fc20a3e.Expected versus observed. With a valid fictional host key, every embedding and chunk-context request should carry that key, have one settled relay receipt, and leave the worker keyless. That is what happened:
cron-maintain-provider-relay.test.ts,maintenance-provider-relay.test.tsandcron-emit.test.ts: 36 pass / 0 fail, 110 assertions, exit 0. This includes the real cron-host → maintenance-worker →brain maintainpath and theCRON_MAINTAIN_NO_PROVIDER_FAILURE,CRON_MAINTAIN_HOST_KEY_AT_PROVIDER,CRON_MAINTAIN_EVERY_REQUEST_RELAYEDandCRON_MAINTAIN_WORKER_KEYLESSassertions.GEMINI_BASE_URLandGOOGLE_GEMINI_BASE_URLunset and removed the custom origin authorization, and redirected only the host's final Google transport to the loopback stub. Both source entry points and freshly builtdistentry points passed: 8 pass / 0 fail, 40 assertions, exit 0. In each healthymaintain: 1 embeddings + 3generateContentrequests, all carrying the host key, and 4 settled receipts withfamily=gemini,origin=https://generativelanguage.googleapis.com,status=200,outcome=completed. The worker observation was exactlykey:null,withheld:"GEMINI_API_KEY",socket:"/run/brain-providers/relay.sock",dotenv:"EACCES".brain-ui-cron environment→ temporary environment file → the installed pam_env module using a private PAM configuration. For source and built entry points, plain and space-padded fictional values were byte-identical after parsing (PAM_EMITTER_BYTE_IDENTICAL). A prequoted key was refused with exit 1, empty stdout, andcannot emit unsafe /etc/environment value for GEMINI_API_KEY. Thus the emitter did not introduce literal quotes around a plain key in these cases.SKIP embed batch: … API_KEY_INVALIDandN chunk context(s) failed — deferred to the next --embeddings run, with four settled Gemini receipts carrying upstream 400. This control supplies an invalid value directly; it bypasses the environment emitter and is not a reproduction of the reported regression or its cause. With no key, the fixtures observe zero provider contacts and zero receipts.Direct host execution could not create the user namespace (
write failed /proc/self/uid_map: Operation not permitted). The first Docker attempt lacked permission for a fresh procfs (bwrap: Can't mount proc on /newroot/proc: Operation not permitted). Adding the documented container-onlysystempaths=unconfinedoption alongsideseccomp=unconfinedallowed the real worker tests to run. These were environment prerequisite failures, not issue reproductions. No product guard was removed or mutated.Source/citation check. The issue's trace is explicitly pinned to
3984040f1; I verified the named anchors there and located them at the inspected SHA. Current anchors includeproviderRelayFor(packages/ui-server/src/brain/host-boundary.ts:422-429),runCredential(packages/ui-server/src/brain/host-boundary.ts:435-436),if (relay)(same file:447-451),const turnProfile(packages/ui-sdk/src/server/worker-launcher.ts:693-695),else if (maintenance?.providerRelay)(same file:713),providerRelayFetch(packages/common/src/provider-relay.ts:69-87), andconst secret = credential(key)?.trim()(packages/ui-sdk/src/server/provider-relay.ts:402-403). The Gemini embedding/completion relay choices remain atpackages/core/src/providers/embeddings/gemini.ts:70-90andpackages/core/src/providers/completions/gemini.ts:66-67. Line movement does not reveal a bypass. The emitter's quoted output is intentional PAM input; its unsafe-character refusal is atemitEnvironment,packages/ui-server/src/cron/emit.ts:314-338.Repeatable commands and temporary probes. From the inspected checkout, save the three snippets below into one fresh directory outside authored source. These derive extra cases from the checked-in fixture instead of changing it. The PAM probe checks only the named fixture value; it does not authenticate, read account credentials, or modify the system PAM configuration.
The image is a locally available diagnostic base, not a published project proof image. The command also requires the documented Linux user/PID/mount namespace and procfs permissions. The private PAM probe uses the upstream pam_start_confdir API and pam_env envfile option.
pam-read.py
emitter-probe.ts
make-first-party.py
Limits and next step. This tests real worker isolation and provider routing with a test storage broker/startup-view stand-in, not actual Btrfs qualification. The default-origin variant tests origin selection, key placement and metering while intercepting the final host transport; it does not exercise Google's DNS/TLS/service or actual key validity. Built entry points still use this checkout's Bun workspace dependencies, not the affected published 0.44.0 installation. Emission/PAM parsing is a separate probe, not a booted cron daemon or the affected host's actual environment file. None of this identifies why that host's request was rejected; “the host must supply a wrong key” remains an inference, not a demonstrated cause.
The outstanding action remains the body's operator check: for one failing
maintainrun, post only whether matching Gemini relay receipts carry upstream 400. If yes, report whether the cron-run and server key values match byte-for-byte (a boolean, never values or fingerprints). If no matching receipts exist, report only whether the worker hadBRAIN_PROVIDER_RELAY_SOCKETandBRAIN_WITHHELD_KEYS. Also distinguish the installed package/dependency versions from this snapshot. This evidence will select a concrete follow-up reproduction without exposing keys or installation details.Readiness: no defect conclusively reproduced, so
needs: reprostays; the explicitly reserved operator check is still missing, soneeds: humanstays andagent-readyremains absent. Preservetype: fix,area: core,area: ui-sdk,area: ui-server,priority: p1and milestone0.45.0. Checkout remains clean at the inspected SHA; no authored files, commits, pushes, PRs, assignments or issue state changed by this research.