Repository navigation
fix: hide agents excluded by operator roles from the picker - #161019
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. Reviewed September 30, 2026, 6:48 PM ET / 22:48 UTC (Revision 5). ClawSweeper reviewWhat this changesThe branch filters agent discovery by operator role, makes Control UI pickers wait for live discovery, preserves unsaved agent edits across reconnect, and serializes subagent completion publication. Merge readiness✅ Ready for maintainer review Keep open: current main and v2026.9.7 still expose the full agent roster to role-limited operators. This branch addresses that distinct problem, and this review found no new blocking defect. Priority: P1 Review scores
Verification
How this fits togetherThe Gateway turns configured agents and the caller’s operator role into an agent roster. The Control UI uses that roster for its picker and directory; subagent completion separately publishes through the session write queue. flowchart LR
A[Configured agents] --> C[Gateway discovery]
B[Current operator role] --> C
C --> D[Live UI roster]
D --> E[Picker and directory]
F[Subagent completion] --> G[Session publication queue]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +50, Tests +336, Docs +11. Total +397 across 38 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep discovery tied to the current Gateway role and live roster while preserving separately authorized session reads and same-owner unsaved drafts. Do we have a high-confidence way to reproduce the issue? Yes. Current main returns an unfiltered roster, and the contributor’s isolated Gateway before-and-after evidence exercises a restricted role; this read-only review did not execute current main. Is this the best way to solve the issue? Yes. Filtering at the Gateway discovery owner and withholding stale browser rosters addresses the reported picker exposure while preserving session-read authorization. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0935289e2e7b. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
|
The persisted-roster finding is repaired in Maintainer decision confirmed for this change: the role agent allowlist is also the discovery ceiling. Existing session-read policy remains independent, as documented; readable cached conversations and group preferences are preserved. Revision 3 maintainer disposition: accept live-only agent discovery and the resulting offline picker/directory limitation for this privacy fix. A saved roster cannot establish the current role's permission to discover an agent. Cached conversations, transcripts, and groups remain available; the documentation now states the tradeoff. The changed paths have no listed CODEOWNERS rule. The required security review passed on the repaired head. The remaining CI failure is being investigated separately against the exact tested merge; it concerns the unchanged session-cancellation fixture. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Published The PR body includes refreshed, inspected screenshots from the final UI source. Revision 3's product disposition remains accepted: picker/directory discovery requires a current live roster; cached conversations and groups remain available. This follows the requested privacy fix and explicit landing instruction. No live Gateway or operator configuration was changed. |
|
🦞👀 Re-review progress:
|
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…#161019) * fix: hide agents excluded by operator roles from the picker * fix: require live discovery before showing agent rosters * fix: serialize subagent completion publication with session metadata * fix: retain authorized agent drafts across live rediscovery
|
Integration cross-reference: #160760 has merged to main as 6daee6e. During its final conflict resolution it reused the canonical subagent completion-publication implementation already landed here as 5ad2c6b, and removed its superseded local completion wrapper and duplicate fixture instead of retaining a second owner. That integration is separate from #160760’s remaining CLI/MCP exec handoff. This PR remains merged; this cross-reference does not reopen it or claim that all unrelated subagent/Stop reports are resolved. |
…rite Scheduled main run 36780090668 failed sessions.abort-embedded.test.ts when a parent Stop's child-row writes (session timing, abort marker) overlapped the killed collector's terminal commit. A session-entry worker write holds the agent-database writer FIFO from its commit grant through settlement, and in that window the collector's retained generation reads as unavailable, so completion failed or was declined and never released its swarm scheduler slot. #161019 moved the collector registry write and publication into that writer turn and #161676 deferred the remaining pre-capture currency check into it. Neither added coverage for the collector path: #161019's worker test stubs assertCurrent, and reverting #161676's deferral leaves every existing test green. Add an end-to-end regression with real SQLite writers: after completion retains generation facts, hold a real child metadata write between its native commit and settlement. Completion must join that writer, keep the staged terminal row off the live registry while waiting, preserve the metadata write, reach terminal state and release its swarm slot. It fails with the original CI error when #161676's deferral is reverted.
…rite (#162359) Scheduled main run 36780090668 failed sessions.abort-embedded.test.ts when a parent Stop's child-row writes (session timing, abort marker) overlapped the killed collector's terminal commit. A session-entry worker write holds the agent-database writer FIFO from its commit grant through settlement, and in that window the collector's retained generation reads as unavailable, so completion failed or was declined and never released its swarm scheduler slot. #161019 moved the collector registry write and publication into that writer turn and #161676 deferred the remaining pre-capture currency check into it. Neither added coverage for the collector path: #161019's worker test stubs assertCurrent, and reverting #161676's deferral leaves every existing test green. Add an end-to-end regression with real SQLite writers: after completion retains generation facts, hold a real child metadata write between its native commit and settlement. Completion must join that writer, keep the staged terminal row off the live registry while waiting, preserve the metadata write, reach terminal state and release its swarm slot. It fails with the original CI error when #161676's deferral is reverted.
Agent discovery became live-only in #161019, but short-route cache resolution still required agentsList to provide routing defaults. A warm reload could finish reading its transcript snapshot and still wait for Gateway connect before returning the route. Project only mainKey and scope through the existing session cache lifecycle. Retire these hints on connect, credential/Gateway changes, and disposal. Keep agent discovery live-only, preserve reserved main-key URL parsing, and retain exact-session live revalidation and refusal on reconnect. Bundled Chromium reloads on two isolated Gateways using the same compiled runtime at 83a9740, identical synthetic sessions, immutable assets, and TCP delays: four interleaved rounds per RTT, alternating before/after order. Median visible time (ms): 0 RTT 321 -> 314; 80 RTT 436.5 -> 316.5; 200 RTT 766 -> 404.5. Per-run before/after values: 0: 329,313,343,307 / 315,313,313,396 80: 429,439,441,434 / 327,323,310,290 200: 770,760,762,776 / 400,417,403,406 At 200 RTT, the original trace read the snapshot at 337 ms, received connect at 671 ms, and rendered at 759 ms. The fixed trace read at 358 ms, rendered at 436 ms, and received connect at 723 ms. Regression proof fails on original production code and passes with the fix. Relevant role-discovery, routing, cache, and reconnect coverage passes: 270 tests across 16 focused files. Repaired the cold-route fixture's missing session capability without changing its assertions. Per-file test wall cost: route-warm-boot 3.49 s; session-roster-warm-boot 10.05 s; route 3.84 s. Validation: core/UI/core-test/root-test tsgo; both import-cycle checks (0); all five typed core lint stripes; oxfmt; diff check; bundled UI build and performance budgets; independent Codex review scoped-clean through P2.
…rite (openclaw#162359) Scheduled main run 36780090668 failed sessions.abort-embedded.test.ts when a parent Stop's child-row writes (session timing, abort marker) overlapped the killed collector's terminal commit. A session-entry worker write holds the agent-database writer FIFO from its commit grant through settlement, and in that window the collector's retained generation reads as unavailable, so completion failed or was declined and never released its swarm scheduler slot. openclaw#161019 moved the collector registry write and publication into that writer turn and openclaw#161676 deferred the remaining pre-capture currency check into it. Neither added coverage for the collector path: openclaw#161019's worker test stubs assertCurrent, and reverting openclaw#161676's deferral leaves every existing test green. Add an end-to-end regression with real SQLite writers: after completion retains generation facts, hold a real child metadata write between its native commit and settlement. Completion must join that writer, keep the staged terminal row off the live registry while waiting, preserve the metadata write, reach terminal state and release its swarm slot. It fails with the original CI error when openclaw#161676's deferral is reverted.
…62794) Agent discovery became live-only in openclaw#161019, but short-route cache resolution still required agentsList to provide routing defaults. A warm reload could finish reading its transcript snapshot and still wait for Gateway connect before returning the route. Project only mainKey and scope through the existing session cache lifecycle. Retire these hints on connect, credential/Gateway changes, and disposal. Keep agent discovery live-only, preserve reserved main-key URL parsing, and retain exact-session live revalidation and refusal on reconnect. Bundled Chromium reloads on two isolated Gateways using the same compiled runtime at 1eea3b8, identical synthetic sessions, immutable assets, and TCP delays: four interleaved rounds per RTT, alternating before/after order. Median visible time (ms): 0 RTT 321 -> 314; 80 RTT 436.5 -> 316.5; 200 RTT 766 -> 404.5. Per-run before/after values: 0: 329,313,343,307 / 315,313,313,396 80: 429,439,441,434 / 327,323,310,290 200: 770,760,762,776 / 400,417,403,406 At 200 RTT, the original trace read the snapshot at 337 ms, received connect at 671 ms, and rendered at 759 ms. The fixed trace read at 358 ms, rendered at 436 ms, and received connect at 723 ms. Regression proof fails on original production code and passes with the fix. Relevant role-discovery, routing, cache, and reconnect coverage passes: 270 tests across 16 focused files. Repaired the cold-route fixture's missing session capability without changing its assertions. Per-file test wall cost: route-warm-boot 3.49 s; session-roster-warm-boot 10.05 s; route 3.84 s. Validation: core/UI/core-test/root-test tsgo; both import-cycle checks (0); all five typed core lint stripes; oxfmt; diff check; bundled UI build and performance budgets; independent Codex review scoped-clean through P2.
What Problem This Solves
Fixes private agents appearing in the Control UI picker and agent directory when the signed-in user’s role allows only a subset of agents.
User Impact
Users discover only agents allowed by their existing role. A saved selection falls back to an allowed agent; an empty allowlist clears the selection. Reloads and reconnects wait for current discovery instead of showing an older browser roster or remembered picker identity. Owners and roles with
agents: "*"retain the full roster.Why This Change Was Made
Filter
agents.listusing the current operator role after asynchronous preparation, then reconcile UI selection against the returned roster. Preserve Gateway routing defaults and ownership metadata; existing session/run authorization stays enforced. Discovery does not grant or revoke session-reading access. Remove the cached discovery fallback and require a live roster for new-session catalog targets; keep stored sessions, groups, transcripts, and draft intent.Evidence
Gateway filtering
Real isolated Gateway + Control UI, synthetic accounts, identical role configuration. Guest allows only
shared; owner allows*. Baseline uses the exact changed modules from4d8c9bddda7f992e293005b78f6bc1f8adea81ed; candidate uses9f53a63f3723452079ba2827895934a35031a8c4. No mocked RPC responses or personal gateway data.Owner and empty-allowlist controls
["shared"]; owner receives all three; empty allowlist receives[]. Both original browser runs passed; this Gateway code is unchanged by the cache repair.Test cost and capture scope
pnpm test src/gateway/server-methods/agents-list.test.ts --maxWorkers=1: 36.03s warm command wall, 38ms test bodies. Cold wall was 164.43s, dominated by shared worker compilation. Only workspace/model roster enrichment is mocked; the handler and role resolver are real.ui/src/app/agent-selection.test.ts: 5.48s command wall, under 50ms test bodies. Browser proof is a local isolated integration run, not an added per-PR E2E suite (baseline 71.19s, candidate 106.82s scenario time).Captured the actual sidebar picker on
/agents, using synthetic trusted-proxy identities, disabled bundled plugins, and no mocked RPC responses. Desktop and mobile cover the changed rendered states. Owner and empty-role screenshots cover permission boundaries. The cache repair below additionally covers loading, reconnect, and failed-refresh states.Persisted-roster and reconnect regression
The later ClawSweeper P1 is fixed by removing persisted agent rosters from discovery and suppressing remembered picker identities without a current roster row. These additional captures run the real Control UI, bootstrap, localStorage version2 boot-record reader, and agent capability against a synthetic WebSocket transport. They prove the browser lifecycle; the original real-Gateway evidence above proves server filtering. Baseline freezes the ten affected production modules at
9f53a63f3723452079ba2827895934a35031a8c4; candidate uses final sourcea4ccc69f5815cbd2c790bfbd880e9ce6262787a3(UI treeddcb19613aeb883ac46814c61ea82777f880f093, refreshed after integrating the tested CI main parent). All accounts and content are synthetic.The same credential/profile starts with an old three-agent boot record while live discovery is held. The restricted response admits only Shared Assistant. A later successful broader response is delivered through
config.changed; the transport then reconnects after the role narrows and fails the new roster request. No application state is patched.Tradeoff: the agent directory and picker wait for live discovery after reload/reconnect. Cached conversation content and groups remain available; shorthand chat routes wait for hello routing defaults. No protocol, config, or stored-data schema change.
CI cancellation repair
The failing CI job exposed a pre-existing Stop race, also reproduced on its unmodified main parent
8c39234ebfff5ce5643bf3c9ee544ecac67e7705. A concurrent cancellation metadata write temporarily invalidated session facts between the terminal registry commit and publication, leaving the scheduler slot active.The three-file repair uses the existing session publication FIFO around native persistence, acknowledgement, and publication. Snapshot capture/restore stays synchronous; transcript/plugin work and terminal cleanup stay outside the FIFO. Current-owner, generation, retirement, and replacement checks remain enforced. The original CI main parent was integrated specifically to repair this owner; the mechanical merge tree matches the inspected CI merge exactly.
The new cases prove staged terminal rows remain private while metadata publication is held, then publish for the current owner and refuse a replaced owner. These are local results; current-head hosted CI remains enforced by the normal landing workflow.
Selected final checks passed: repository guards, core production types, all 27 test type graphs, all three unused-export scans, scoped lint, format, import cycles, and storage/auth guards. Lint found two redundant default type arguments in the new test; those were removed and scoped lint/format plus all 21 publication tests passed again (3.24s wrapper wall). No behavioral source changed after the clean AutoReview.
Reconnect drafts and final browser regressions
Live-only discovery also retires the settings editor's selected target during reconnect. Preserve its unsaved identity draft privately and restore it only when current discovery re-admits the same agent for the same profile and selection intent. Source/profile changes and a newer selection discard it. The page's draft-retention owner keeps discovery and actions unavailable while the roster is absent.
Real Control UI against the existing synthetic Gateway fixture, identical interrupted-save scenario. Baseline is
a4ccc69f5815cbd2c790bfbd880e9ce6262787a3; candidate is607311074a83df2a9ee300c02f1d0d43170709db. The typed name is lost before the repair and retained after live rediscovery.The reconnect cases retain their original assertions. New-session now exercises live roster admission before explicit workspace selection, then holds discovery during reconnect to verify draft retention and blocked dispatch. Warm reload uses a literal conversation key so the test retains its pre-hello transcript/auth-isolation contract; shorthand main routes intentionally require live routing defaults. The draft extraction also shrinks the existing settings page, with the repository size guard passing. These are local command wall times; hosted timing remains visible in the linked CI run.
The earlier CI run also reported a single 120s mobile GitHub-hovercard timeout. Its test and owning hovercard/registration code are unchanged by this PR. An original-order replay of all 21 cases passed in34.83s; this is a non-reproduction, not a repair. CI diagnostics suggest the deferred preview request was never observed after mobile resize/focus, but did not preserve the failing page state, so the cause remains unresolved. No assertion, timeout, or retry policy was weakened; final-head CI remains required.
Independent incremental AutoReview completed at P0–P2 with one suggestion, inspected and rejected: discard a retained local draft when the same operator keeps read access but loses identity-write permission. The draft contains that operator’s own typed input and is restored only for a currently discoverable agent; preserving it does not grant write access. Existing overview controls remain disabled without
agents.updateauthority, andsaveIdentityDraftchecks currentoperator.adminpermission both at entry and immediately before dispatch. Clearing the draft would introduce avoidable data loss rather than repair an authorization leak. No accepted actionable findings remain.Follow-up selected checks passed: repository guards, all 8 affected test type graphs, UI types, i18n, three unused-export scans, formatting, scoped lint, and stylelint. Lint identified a shadowed callback variable; its local name was changed without affecting behavior, followed by passing format/lint/stylelint.
Inherited cancellation fixture failure
The final Node shard on
a4ccc69stalled inchat.abort-errors.test.ts(cascade native new), then the reset/delete cases failed cleanup. The original-order 10-case file reproduces 7 passes and 3 failures both on the tested merge75b750f9and its unmodified main parentb09d30a, using bounded diagnostic timeouts. The fixture held a child metadata writer while waiting for terminal publication through that same writer queue.Main already contains the canonical repair 79f0e9bf127: hold the original abort-marker call after termination, then delegate to the real helper, preserving all lifecycle/transcript assertions. Its published validation reports 10/10 focused cases and 424/424 in the original 31-file group on Linux. No duplicate fixture change or production adjustment is added here; current-head CI must exercise the PR with that main fix.
Receiving validation of canonical
79f0e9bf127: the unchanged 10-case abort/reset file passes on the previously failing exact PR merge with only the canonical test blob applied, using normal configured budgets (73.51s test duration / 76.73s command wall). The formerly stalled native-new/reset/delete cases take 1.59s / 1.94s / 2.92s. This is local receiving proof; current-head hosted CI remains required.