Repository navigation
refactor(agents): share one Gateway inventory rule between admission and catalog reads - #197276
Conversation
…and catalog reads Run admission (#169539) and read-only catalog lookups (#197238) each encoded "Gateway inventory belongs to the configured agent; the session cwd only controls execution". Move that rule, and the Gateway lifecycle flag it reads, into the owner layer as resolveInventoryInput, and use it from both callers. Delete the separate lifecycle-flag module. Execution owners (plugin registries, inbound cleanup) stay workspace-scoped, so the shared published-owner resolver keeps its exact workspace match. Co-authored-by: obviyus <[email protected]>
…and catalog reads OpenClaw-Publication: a75ca303-613b-4901-a870-c4f97925ac16
|
🦞👀 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 shares the Gateway inventory-selection rule between run admission and catalog reads and moves its lifecycle flag into the existing runtime owner. Example: A Gateway session runs in /tmp/project-checkout and selects runtime-demo/discovered-row.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR is a focused, behavior-preserving consolidation with no actionable findings; exact-head CI has passed, and collaborator authorship also protects it from cleanup closure. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe prepared-model runtime receives agent, config, environment, and workspace inputs and supplies published catalog facts and leased execution generations to model consumers. flowchart TD
A[Session inputs] --> B[Run admission]
A --> C[Catalog reads]
B --> D[Inventory input owner]
C --> D
D --> E[Configured agent inventory]
B --> F[Workspace scoped execution]
Technical reviewBest possible solution: Keep the inventory projection in the existing runtime owner while retaining exact workspace matching for execution registries. Do we have a high-confidence way to reproduce the issue? This PR addresses duplicated policy rather than a new functional defect; source comparison confirms both existing paths express the same Gateway inventory rule. Is this the best way to solve the issue? The extraction is the smallest complete consolidation: it uses the existing owner, removes the former flag module, and leaves execution-owner matching unchanged. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d3942b513282. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource -3. Total -3 across 5 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
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 Reviewed November 11, 2026, 11:05 AM ET / 16:05 UTC. |
|
Merged via squash.
|
…and catalog reads (openclaw#197276) * refactor(agents): share one Gateway inventory rule between admission and catalog reads Run admission (openclaw#169539) and read-only catalog lookups (openclaw#197238) each encoded "Gateway inventory belongs to the configured agent; the session cwd only controls execution". Move that rule, and the Gateway lifecycle flag it reads, into the owner layer as resolveInventoryInput, and use it from both callers. Delete the separate lifecycle-flag module. Execution owners (plugin registries, inbound cleanup) stay workspace-scoped, so the shared published-owner resolver keeps its exact workspace match. Co-authored-by: obviyus <[email protected]> * refactor(agents): share one Gateway inventory rule between admission and catalog reads OpenClaw-Publication: a75ca303-613b-4901-a870-c4f97925ac16 --------- Co-authored-by: obviyus <[email protected]>
Problem
After #197238, two places encoded the same rule, "Gateway inventory belongs to the configured agent; the session cwd only controls execution":
prepared-model-runtime-lease.ts, from fix: resolve plugin-discovered models outside the agent workspace #169539) builtinventoryInputinline fromcontext.getGatewayLifecycleActive().prepared-model-catalog.ts) built their owninventorycandidate from a separate lifecycle-flag module (prepared-model-runtime-gateway-lifecycle.ts).Change
resolveInventoryInput(input, configuredOwner?)inprepared-model-runtime.owner.tsnow owns the rule. Admission and read-only catalog lookups both call it.prepared-model-runtime-gateway-lifecycle.tsis deleted.Why the shared published-owner resolver does not absorb the rule
I first moved the rule into
resolvePublishedOwner, so every published lookup would ignore the session cwd under a Gateway. Two contracts failed, so I reverted that:prepared-model-runtime.inbound-registry.test.ts: "Historical workspaces and changed policy cannot borrow the current publication". Subagent cleanup must not reuse another workspace's inbound plugin registry.prepared-model-runtime.owner-selection.test.ts, "matches the configured owner for workspace": execution owners stay workspace-scoped.So inventory (catalog rows) and execution (plugin registries) need different owner rules. Only inventory goes through
resolveInventoryInput.Caller map (read-only catalog entry points, non-test)
getPreparedModelCatalogOwnerSnapshot: gateway/server-model-catalog, auto-reply/commands-system-prompt, status/status-text, agents/cli-runner/prompt-contextgetPublishedPreparedModelCatalogOwnerSnapshot: gateway/server-model-catalog, gateway/server-methods/{models, chat-metadata-facts, requester-model-catalog}, agents/{utility-model, model-runtime-choice, model-catalog-view, context}withPreparedModelCatalogOwner: tui/embedded-backend, commands/models/list.list-command, agents/model-runtime-choice (sessions_spawn)loadPreparedModelCatalogSnapshot: tui/embedded-backend, commands/sessions, auto-reply/{model-selection-directive, model-selection}, commands/models/list.status-command, wizard/setup.finalize, agents/model-catalog-viewreadPreparedModelCatalog: media-understanding/runner, tui/embedded-backend, plugin-sdk/agent-runtime, cli/capability-cli/model, auto-reply/{get-reply-native-slash-fast-path, session-reset-model}, flows/doctor-tool-schema-frames, commands/{doctor-hooks-model, models/list.probe}loadPublishedPreparedModelCatalogOwnerSnapshot: agents/model-runtime-choice, auto-reply/commands-models-catalogloadProviderScopedThinkingCatalog: cron/isolated-agent/model-selection, auto-reply/{agent-runner-utils, agent-runner-run-params, model-runtime-normalization, model-selection}, agents/command/{model-selection, run-embedded-attempt}getPreparedModelCatalogSnapshot: extensions/discord native-command options, status/summary.runtime, system-agent/tui-backend, auto-reply/commands-context-reportrefreshExpiredPreparedModelCatalog: plugin-sdk/agent-runtimeAll of them resolve owners through
resolveInputsinprepared-model-catalog.ts.Removed vs retained
inventorycandidate (now one line,resolveInventoryInput(full)). It is how read-only lookups reach the configured owner, and the shared resolver cannot do that without breaking the execution contracts above. Outside a Gateway lifecycle it equalsfull, andnew Setdedupes it.activationFullandactivationExact. Standalone commands publish one owner keyed by the agent's resolved workspace (activateStandalonePreparedModelRuntime(activationExact)). Later workspace-free reads in the same process (for examplestatus-text) need that key.exact/activationExactalso match read-only standalone activations, which are keyed withreadOnly: true.acquireReadOnlyPreparedModelRuntime(activationExact)).openclaw models listwithout a Gateway. ClawSweeper's first review of fix(agents): read published catalog for project-session model lookups #197238 noted that the embedded TUI host publishes configured-provenance owners without a Gateway lifecycle; those reads keep workspace-scoped discovery.Evidence
src/agents/prepared-model-catalog.outside-workspace.test.ts: both cases pass. ReplacingresolveInventoryInput(full)withfullmakes the Gateway case fail again.prepared-model-runtime*,prepared-model-catalog*,model-runtime-choice*,openclaw-tools.subagents.sessions-spawn*,tui/embedded-backend, and the embedded-runner model tests. 723 of 724 pass. The one failure,prepared-model-runtime.startup-registry.test.ts, needs--expose-gc, which the direct run does not pass. It does not touch this code.env -ienvironment,plugins install, stand-in plugin with OAuth anddiscovery: runtime). A real agent turn in a project session calledsessions_spawn:openclaw plugins reload.