Repository navigation
fix(models): keep each prepared runtime's authored config source - #189192
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR retains each published runtime config object's authored source for later model-runtime rebuilds. Example: Save a provider key while an older prepared runtime holds a plugin SecretRef named PLUGIN_KEY.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR repairs a current source-generation mismatch and addresses all prior findings; no remaining introduced defect was found, but required CI still fails. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe config publisher pairs resolved runtime values with authored configuration, which model preparation captures and supplies to plugin validation. flowchart LR
A[Authored config] --> C[Runtime publisher]
B[Resolved config] --> C
C --> D[Published source association]
D --> E[Immutable runtime capture]
E --> F[Prepared model runtime]
F --> G[Plugin validation]
Technical reviewBest possible solution: Keep source associations with the existing publisher and preserve immutable captures, including authoritative source replacement and removal. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the older-generation fallback directly, and the PR reports an isolated Gateway reproduction; this review executed no target code. Is this the best way to solve the issue? The publisher-owned association is a small, complete repair that preserves existing capture isolation and avoids caller-specific workarounds. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 07ec4dc256bd. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +27, Tests +38. Total +65 across 4 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed October 31, 2026, 6:44 AM ET / 10:44 UTC (Revision 4). |
fcfde8e to
8a6e99e
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Maintainer override: the only failing required job on head 03be193 is Both fail identically on unmodified |
|
Landed as 8ca9161 under the maintainer override above. The snapshot publisher now records the authored source it publishes with each runtime config, so an older runtime generation validates plugin secret inputs against its own SecretRef instead of the resolved value. This removes the false |
…nclaw#189192) ## Problem After saving a provider key in the Control UI (`models.authSetApiKey`), a live Gateway logged `[plugins] typesafe invalid config: apiKey: must be object` once per prepared model runtime rebuild. The TypeSafe plugin's `apiKey` is a SecretRef object, and its manifest declares it as a secret input, so validation must compare against the authored source, not the resolved string. Call chain: 1. The auth mutation rebuilds existing prepared-runtime owners (`prepared-model-runtime-auth-publication.ts` → `publishPreparedModelRuntimeOwnerBatch`). 2. Each owner rebuilds from the config it was admitted with, an older runtime generation (`prepared-model-runtime.build.ts`). 3. `projectConfigOntoRuntimeSourceSnapshot` maps that old config onto the current source snapshot. The config write added a top-level `meta` key that the old config lacks, so the projection returns the resolved config as its own source. 4. `loadAgentRuntimePluginRegistryHandle` passes that as `activationSourceConfig`, and plugin config validation sees the resolved string. ## Fix The runtime snapshot publisher (`publishRuntimeConfigSnapshot`) now records the authored source it publishes with each runtime config object, in a separate map next to the existing captures (`recordPublishedRuntimeConfigSource`). Every publication overwrites it (with the runtime itself when no source is published), so a source republished for the same runtime object (`setRuntimeConfigSourceSnapshotIfCurrent`) stays authoritative. `projectConfigOntoRuntimeSourceSnapshot` uses that record for configs that are not frozen captures, so an older runtime generation projects its own source instead of failing open against a newer one. The record is not a capture: the config keeps its identity, and `captureRuntimeConfig` still freezes an isolated runtime/source pair for rebuilds. ## User impact Saving a provider key no longer produces false invalid-config errors for plugins with secret inputs, and those plugins validate against their real authored config during rebuilds. ## Proof - `src/config/runtime-source-projection.test.ts`: - "keeps an older runtime generation on its own published source": a held generation still projects its SecretRef after a newer generation adds `meta`, and `captureRuntimeConfig` still returns a frozen copy. Fails on `main` (projects the resolved string). - "follows a newer source republished for the same runtime object": republishing the same runtime object with a new source wins, also after the next generation. Fails on the previous head of this PR. - An isolated Gateway reproduction (TypeSafe with an env SecretRef, bundled plugins on, then `models.authSetApiKey` for `particle`) logged `typesafe invalid config` before the fix and zero after, with `models.list` succeeding. The scratch harness is not committed: it needs a 15 s wait. - Projection, runtime snapshot, owner, inbound-registry, sources and loader-shared suites pass. `pnpm check:changed` passes. `pnpm check:madge-import-cycles` reports 0 cycles. Known remaining: `plugins/loader-load-context.ts` (context-engine owner capture) and `decisions/registry-adoption.ts` use the same projection on held configs. They produced no warnings in the reproduction after this fix. No overlap with Pash/Sarah changes. ## Merge danger Two-way door: a revert fully undoes it. No state, config or contract change. Blast radius: prepared model runtime rebuilds after config writes. Co-authored-by: Ayaan Zaidi <[email protected]>
…9192) ## Problem After saving a provider key in the Control UI (`models.authSetApiKey`), a live Gateway logged `[plugins] typesafe invalid config: apiKey: must be object` once per prepared model runtime rebuild. The TypeSafe plugin's `apiKey` is a SecretRef object, and its manifest declares it as a secret input, so validation must compare against the authored source, not the resolved string. Call chain: 1. The auth mutation rebuilds existing prepared-runtime owners (`prepared-model-runtime-auth-publication.ts` → `publishPreparedModelRuntimeOwnerBatch`). 2. Each owner rebuilds from the config it was admitted with, an older runtime generation (`prepared-model-runtime.build.ts`). 3. `projectConfigOntoRuntimeSourceSnapshot` maps that old config onto the current source snapshot. The config write added a top-level `meta` key that the old config lacks, so the projection returns the resolved config as its own source. 4. `loadAgentRuntimePluginRegistryHandle` passes that as `activationSourceConfig`, and plugin config validation sees the resolved string. ## Fix The runtime snapshot publisher (`publishRuntimeConfigSnapshot`) now records the authored source it publishes with each runtime config object, in a separate map next to the existing captures (`recordPublishedRuntimeConfigSource`). Every publication overwrites it (with the runtime itself when no source is published), so a source republished for the same runtime object (`setRuntimeConfigSourceSnapshotIfCurrent`) stays authoritative. `projectConfigOntoRuntimeSourceSnapshot` uses that record for configs that are not frozen captures, so an older runtime generation projects its own source instead of failing open against a newer one. The record is not a capture: the config keeps its identity, and `captureRuntimeConfig` still freezes an isolated runtime/source pair for rebuilds. ## User impact Saving a provider key no longer produces false invalid-config errors for plugins with secret inputs, and those plugins validate against their real authored config during rebuilds. ## Proof - `src/config/runtime-source-projection.test.ts`: - "keeps an older runtime generation on its own published source": a held generation still projects its SecretRef after a newer generation adds `meta`, and `captureRuntimeConfig` still returns a frozen copy. Fails on `main` (projects the resolved string). - "follows a newer source republished for the same runtime object": republishing the same runtime object with a new source wins, also after the next generation. Fails on the previous head of this PR. - An isolated Gateway reproduction (TypeSafe with an env SecretRef, bundled plugins on, then `models.authSetApiKey` for `particle`) logged `typesafe invalid config` before the fix and zero after, with `models.list` succeeding. The scratch harness is not committed: it needs a 15 s wait. - Projection, runtime snapshot, owner, inbound-registry, sources and loader-shared suites pass. `pnpm check:changed` passes. `pnpm check:madge-import-cycles` reports 0 cycles. Known remaining: `plugins/loader-load-context.ts` (context-engine owner capture) and `decisions/registry-adoption.ts` use the same projection on held configs. They produced no warnings in the reproduction after this fix. No overlap with Pash/Sarah changes. ## Merge danger Two-way door: a revert fully undoes it. No state, config or contract change. Blast radius: prepared model runtime rebuilds after config writes. Co-authored-by: Ayaan Zaidi <[email protected]> Release adaptation: clean -x backport onto 82f1197; production and regression hunks unchanged. Add a separate 38-line test-budget allocation for the two upstream regression tests; shared scalar unchanged. Preserve baseline e13cf15 and audit pin bd692e9. Companion dispositions at pinned audit: - #193903 / b43ad0a: not-applicable; independent catalog/capture-memo optimization, no prerequisite for the source association. - #196984 / b8980ca: present-equivalent; current reader already follows equivalent runtime copies. - #199956 / ea69fcb: not-applicable; independent live-reader ownership retention; authored-source association unchanged. - No later #189192 mention. Existing publication, capture, runtime-plugin, loader and decision consumers retain their interfaces; no generated/registry companion needed. Workflow optimizations excluded from this product-only scope. Release proof: unmocked production publication/projection regression boundary fails on parent (2 failed, 4 passed) and passes after pick; projection plus snapshot suites 50 passed; retained-runtime plugin consumer suites 18 passed. Targeted type-aware lint (4 files), format and diff checks pass. Upstream live Gateway proof above is historical; this lane does not claim a fresh live Gateway/model run or full release qualification. Self-review/pr-simplify: retain the minimal separate weak association because raw publication identity and frozen captures have distinct lifetimes. Delta: 27 production and 38 regression lines, plus the 3-line budget record. (cherry picked from commit 8ca9161) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 7ddb9e2a14671b47081bec40224e1f6f7316690d)
Problem
After saving a provider key in the Control UI (
models.authSetApiKey), a live Gateway logged[plugins] typesafe invalid config: apiKey: must be objectonce per prepared model runtime rebuild. The TypeSafe plugin'sapiKeyis a SecretRef object, and its manifest declares it as a secret input, so validation must compare against the authored source, not the resolved string.Call chain:
prepared-model-runtime-auth-publication.ts→publishPreparedModelRuntimeOwnerBatch).prepared-model-runtime.build.ts).projectConfigOntoRuntimeSourceSnapshotmaps that old config onto the current source snapshot. The config write added a top-levelmetakey that the old config lacks, so the projection returns the resolved config as its own source.loadAgentRuntimePluginRegistryHandlepasses that asactivationSourceConfig, and plugin config validation sees the resolved string.Fix
The runtime snapshot publisher (
publishRuntimeConfigSnapshot) now records the authored source it publishes with each runtime config object, in a separate map next to the existing captures (recordPublishedRuntimeConfigSource). Every publication overwrites it (with the runtime itself when no source is published), so a source republished for the same runtime object (setRuntimeConfigSourceSnapshotIfCurrent) stays authoritative.projectConfigOntoRuntimeSourceSnapshotuses that record for configs that are not frozen captures, so an older runtime generation projects its own source instead of failing open against a newer one. The record is not a capture: the config keeps its identity, andcaptureRuntimeConfigstill freezes an isolated runtime/source pair for rebuilds.User impact
Saving a provider key no longer produces false invalid-config errors for plugins with secret inputs, and those plugins validate against their real authored config during rebuilds.
Proof
src/config/runtime-source-projection.test.ts:meta, andcaptureRuntimeConfigstill returns a frozen copy. Fails onmain(projects the resolved string).models.authSetApiKeyforparticle) loggedtypesafe invalid configbefore the fix and zero after, withmodels.listsucceeding. The scratch harness is not committed: it needs a 15 s wait.pnpm check:changedpasses.pnpm check:madge-import-cyclesreports 0 cycles.Known remaining:
plugins/loader-load-context.ts(context-engine owner capture) anddecisions/registry-adoption.tsuse the same projection on held configs. They produced no warnings in the reproduction after this fix.No overlap with Pash/Sarah changes.
Merge danger
Two-way door: a revert fully undoes it. No state, config or contract change. Blast radius: prepared model runtime rebuilds after config writes.