Repository navigation
fix(registry): make a manifest's declared driver identity persist - #1734
Merged
Merged
Conversation
install.ts reads manifest.runtime.runtimeType to fill a runtimeType the caller
omitted — the path a native first-party app installs through, since the Hub
sends no runtimeType of its own. No schema path existed for that field and
ManifestRuntimeSchema is strict, so every write dropped it: the fallback could
never fire and a hand-written test fixture kept it green.
- declare runtimeType on ManifestRuntimeSchema (driver identity; stays
the deployment shape, whose enum kept refusing 'native' — the value the
seeder was writing into it)
- seed-native-agents: one buildRegistryManifest, identity only, no enum-invalid
; refreshed on every boot like the rest of the manifest
- agentManifestRegistry: carry runtimeType through publish normalization, and
refuse a deployment shape in that field
- tests: model round-trips (constructor + upsert), the route fixture now comes
from the real schema, seeder and validator coverage
Measured before the fix: new AgentRegistry({manifest:{runtime:{type:'native',
runtimeType:'native'}}}).toObject() == {type:'native',connection:'mcp'}.
Removing the schema path again fails 4 tests, the route fallback included.
lilyshen0722
force-pushed
the
kai/task043-native-manifest-runtime
branch
from
September 18, 2026 08:16
65ee104 to
119f182
Compare
…eType Wren's shape read (69353) calls the entitlement consequence out as the thing to get right: publish is plain `auth`, so with runtimeType now persisting any owner can declare one, and install copies the manifest value BEFORE the gate reads it. These two cases pin that shape: - a manifest-declared 'native' install by a non-admin, non-entitled installer is refused with cloud_agents_not_entitled (the manifest is not a bypass) - an explicit caller runtimeType wins over the manifest, so a manifest edit cannot re-shape an install the caller already typed Both fixtures come from the real schema, so they fail if the schema path goes away again — verified: dropping runtimeType fails the first, letting the manifest overwrite the caller fails the second. Open, for Vera's 69355 and Sam's ruling: whether a first-party BUILTIN native app (scout, pod-welcomer, …) should stay entitlement-gated like every other in-process runtime, or be exempt as the onboarding wedge. That is policy, not code shape — this commit pins the mechanism either way.
…back asserted #1733's suite pins the seeder shape it was written against — "keeps manifest.runtime.type and drops runtimeType" — and that assertion is exactly what TASK-043 inverts, so it fails against this branch (1 of 44 suites, on the merged base). The guard's intent survives the fix and stays asserted: every row the OLD seeder wrote still carries enum-invalid type:'native' (findOneAndUpdate does not run validators), so declaredExemptRuntime's `type` fallback is still load-bearing — and the read-order test above it already pins runtimeType-first, which is what makes the two PRs order-independent as Wren described.
Ruling (Wren 69359/69361, Sam 69364): first-party native apps are entitlement-free, so the 403 the restored manifest runtimeType produced is not intended. Scout reaches every signup ungated — authController upserts it at workspace creation, capped by dailyRunCap — so gating the Hub copy of the same app would gate a thing we hand out at signup. cloudAgents exists for the operator-run tiers; the in-process native runtime is the capped one. Exemption = effectiveRuntimeType native AND the row itself declares native AND registry 'commonly-official' AND verified. The row, never manifest content: publish is plain auth, so an exemption earnable by declaring 'native' would hand any publisher in-process compute for free. Requiring the row to declare native stops an official row's provenance being borrowed by an explicit caller runtimeType to skip another tier's gate. Tests (non-admin, no entitlement): official+verified native installs and persists runtimeType; community-declared native 403s; official row that does not declare native 403s; unverified official 403s. Mutations: dropping the exemption fails the first, dropping the declares-native half fails the third.
…loud gate" Decision card 69363 ruled option 1 — keep the gate (Sam 69366). The first-party native exemption this reverts was implemented on Wren's 69359/69361 key and Sam's 69364 confirmation; Sam then overrode both, and the reason is checkable in the repo: the first-teammate path never meets this gate. Scout is installed at registration by the server (authController.ts:215, buildInstallationConfig) and the hire path writes the model directly (personaHireService.ts:79-93), neither of which goes through routes/registry/install.ts — the gate is route-level only. Its actual subject is a non-admin adding further native apps from the Hub, and #529 deliberately routes that 403 to the BYO flow; exempting it would widen who can consume platform compute without a pricing sentence behind it. Content is byte-identical to 4b58841 (git diff 4b58841 HEAD is empty), so re-gating is a zero-diff re-clear. The exemption itself is preserved in history at ef8d8ff should a product row for it land. Non-admin tests kept: a community row declaring native 403s, and an explicit caller runtimeType beats the manifest. This reverts commit ef8d8ff.
lilyshen0722
added a commit
that referenced
this pull request
Sep 18, 2026
…ips the schema, and a guard set enumerated by its refusal code (#1735) Rule 24 (Tests and assertions): a test whose fixture builds its own document proves the reader can read a field, never that the field can be there. The write is where a strict schema drops what the reader expects, and findOneAndUpdate does not run validators — so both failure halves can coexist with a green suite. Check: for each cross-layer read, confirm the writing schema declares the path and that one test round-trips through the real model. Rule 25 (Guards and predicates): enumerate a guard set by the refusal code the client branches on, not by the predicate. Two guards refusing the same thing for the same stated reason can be implemented by different mechanisms, so a predicate grep returns a closed-looking set that is not closed. Both earned by TASK-043 / PR #1734.
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.
Closes TASK-043.
routes/registry/install.tsfalls back to the registry manifest's declaredruntimeTypewhen the caller omits one — the path a native first-party app installed from the Hub takes, because the Hub's install POST sends noruntimeTypeof its own. That fallback read a field the schema could not store.Measured, before the fix
ManifestRuntimeSchemaisstrict: truewith noruntimeTypepath, so every write dropped the identity while keepingtype: 'native'— a value the schema's own enum (standalone/commonly-hosted/hybrid) refuses, stored only becausefindOneAndUpdatedoes not run validators by default. So an install landed withruntimeTypeunset,agentEventServicequeued its events for the external queue, and nothing listened: an in-process agent that never replies.The route's test stayed green because its fixture was a hand-written object, not a shape the schema can produce. That gap is the defect behind the defect.
The fix
models/AgentRegistry.tsruntimeTypeonManifestRuntimeSchema— the driver identity axis, next totype's deployment shapescripts/seed-native-agents.tsbuildRegistryManifest(app)used by both the$setand$setOnInsertmanifests: declares the identity, writes no enum-invalidtype. Refreshed on every boot like the rest of the manifest, so existing first-party rows pick it up on deploy — no backfill scriptutils/agentManifestRegistry.tsruntimeTypethrough publish normalization (free token, not an enum, so a new driver needs no release) and refuse a deployment-shape value in that fieldScope note for review: the publish pass-through is here because without it the new schema path has exactly one writer — the boot seeder — and the fallback stays dead for every agent that arrives through publish. Say the word and I will split it out; the model + seeder change stands alone.
Evidence
agentRegistry.manifestRuntime.test.js(new): identity survives the constructor, survives an upsert with$seton a real row (the seeder's write path — construction and update are separate Mongoose paths), an undeclared field is still stripped, andtype: 'native'still fails the enum.registry.install-runtime-type.test.js: the fallback fixture is now round-tripped through the real model, so deleting the schema path breaks the route test too.seed-native-agents.config.test.js+agentManifestRegistry.test.js: the seeder's manifest shape and the validator's pass-through/refusal.runtimeTypefromManifestRuntimeSchemafails 4 tests — includingcopies manifest.runtime.runtimeType into the installation when the caller omits runtimeType.npx jest __tests__/unit/{routes/registry,models,utils,scripts}→ 84 suites, 544 tests pass.npm run lint:ts→ 0 errors.npm run tsc:check→ exit 0.Not touched: deployment-shape semantics (no existing reader of
manifest.runtime.type; frontend has none), the install route's own logic, or the cloud-entitlement gate.Addendum — head moved to
4b588411(base refreshed onto3058d7c8, #1733 merged)Two test commits on top of the fix:
auth, so with the field persisting any owner can declare one, andinstall.tscopies the manifest value before the gate reads it. Pinned: an unentitled non-admin installing an agent whose manifest declaresnativegets403 cloud_agents_not_entitled(a manifest is not a bypass), and an explicit callerruntimeTypebeats the manifest (a manifest edit cannot re-shape an install the caller already typed). Both fixtures come from the real schema; each fails under its own mutation.manifest.runtime.typeand dropsruntimeType" — exactly the shape this PR inverts, so it reds on the refreshed base. The assertion is inverted; thetypefallback it guards stays asserted, because every row the old seeder wrote still carries enum-invalidtype:'native'.Suites over
routes/registry+models+utils+scripts: 44 suites / 210 tests green,lint:ts0 errors,tsc:checkexit 0.Open, deliberately not decided here (Vera 69355, card to Sam): restoring the field makes
effectiveRuntimeTyperesolve tonativefor a first-party builtin app installed from the Hub, andnativeis inCLOUD_RUNTIME_TYPES— so a non-entitled non-admin now gets 403 where the install previously "succeeded" with aruntimeTypethat went nowhere (a dead agent). Whether first-party builtin apps should be exempt from that gate is policy, not code shape. The tests above pin the mechanism and hold under either ruling.Entitlement gate: no exemption — head
bf043234Decision card 69363 ruled option 1, keep the gate (Sam 69366), overriding Wren's 69361 key and Sam's own earlier 69364 confirmation in chat. An exemption was briefly implemented at
ef8d8ff7and is reverted atbf043234; the tree is byte-identical to4b588411(git diff --quiet 4b588411 HEADexits 0), so a re-gate is a zero-diff re-clear.Why the gate is right, checkable in the repo rather than by intent: the first-teammate path never enters this route.
authController.ts:215installs Scout at registration by writingAgentInstallationdirectly withbuildInstallationConfig(scoutApp), andpersonaHireService.ts:79-93does the hire install withfindOneAndUpdate+upsert. ThecloudAgentsgate exists only inroutes/registry/install.ts, so its actual subject is a non-admin adding further native apps from the Hub — which is exactly the path #529 routes to the BYO flow. Exempting it would widen who can consume platform compute with no pricing sentence behind it.Kept from the entitlement work (non-admin, non-entitled): a community row declaring native still 403s, and an explicit caller
runtimeTypestill beats the manifest. The exemption patch itself is preserved in history atef8d8ff7should it ever come back as its own product row.Suites over
routes/registry+models+utils+scripts+security: 95 suites / 685 tests green,lint:ts0 errors,tsc:checkexit 0.