Skip to content

fix(agents): reject invalid selectors before routing - #153387

Merged
steipete merged 5 commits into
mainfrom
codex/strict-workspace-agent-boundary-482
Sep 20, 2026
Merged

steipete merged 5 commits into
mainfrom
codex/strict-workspace-agent-boundary-482

Conversation

@steipete

@steipete steipete commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Related: #150153, #152895

What Problem This Solves

Run workspace selection could silently choose main for a blank or unrepresentable explicit agent ID. Strict selection also exposed callers that manufactured empty IDs or reported malformed input as Gateway unavailability.

User Impact

Workspace APIs reject invalid explicit IDs before choosing a workspace. Gateway requests with malformed session keys or unrepresentable agent IDs receive INVALID_REQUEST before lookup or dispatch. Valid IDs, omitted selectors, and existing fixed-store global ownership retain their behavior. Deprecated Plugin SDK resolver aliases preserve blank-as-omitted input through their existing compatibility window; strict SDK and core selection reject supplied blanks. This is a preparatory split; canonical session-key storage migration remains separate.

Why This Change Was Made

The existing selection owner validates raw selectors. A shared Gateway adapter returns normalized explicit IDs or client errors before store lookup, and status reporting reuses its already-resolved owner. Removing duplicate routing checks and the private workspace selection wrapper leaves production code 18 lines smaller. The existing deprecated SDK adapter prepares its optional agent ID once for both initial resolution and ambient fallback, preserving the shipped contract without relaxing core admission.

Caller fixtures use valid fully qualified keys. Main independently repaired the transcript provider-reload test timing in #142102; this PR leaves that file unchanged and retains the main fix when merged.

Evidence

  • The initial regressions failed 13 cases before the owner repair. A registered RPC regression also reproduced UNAVAILABLE for agentId: "!!!" before the adapter repair.
  • Focused proof: 261 owner/caller tests and 730 complete fixture-suite tests passed. The original broader agent-scope run also passed, with one existing platform skip.
  • SDK compatibility follow-up: four new cases failed before the adapter repair; all 97 SDK, workspace, and agent-owner cases then passed, with one existing platform skip. The compatibility contract was checked against the published v2026.9.5 source and documentation.
  • An isolated, no-mock source API smoke reproduced five baseline wrong/default selections and verified rejection after repair, with three valid/omitted-selector controls preserved. This is actual source API proof, not installed-Gateway proof.
  • Deslop and fresh P2 autoreviews are clean. Native changed checks passed for the production repair, fixture cutover, and SDK compatibility repair, including core and extension type checks, lint, and runtime import-cycle checks.

@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 20, 2026
@steipete
steipete marked this pull request as ready for review September 20, 2026 03:09
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 20, 2026
@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 20, 2026, 3:01 AM ET / 07:01 UTC (Revision 5).

ClawSweeper review

What this changes

Rejects invalid agent selectors before workspace selection and Gateway lookup, preserves deprecated SDK blank-input behavior, and updates regression coverage and documentation.

Merge readiness

⛔ Blocked before merge - 1 item remains

The fix remains necessary on current main. The latest commit resolves the previous SDK blank-selector compatibility blocker, and no actionable introduced defect was found.

Priority: P2
Reviewed head: 3ffa07e98203499260c21a2724982ab3e44c9bcc

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful regression coverage and the previous SDK compatibility concern addressed.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its captured evidence describes an isolated source-API before/after smoke and registered Gateway regression coverage, not an installed-Gateway run; the patch does not introduce a material new authority grant or lifetime.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its captured evidence describes an isolated source-API before/after smoke and registered Gateway regression coverage, not an installed-Gateway run; the patch does not introduce a material new authority grant or lifetime.
Evidence reviewed 9 items Current main still contains the defect: Current main treats blank explicit IDs as absent and passes nonblank IDs through the normalizer that can substitute main. The branch replaces that selection with strict validation.
Existing normalization owner explains the failure: normalizeAgentId returns main when strict normalization fails; normalizeAgentIdStrict returns an error for blank or unrepresentable input. Both implementations belong to this repository's normalization package.
Previous compatibility blocker resolved: The exact head commit, whose recorded parent is the previously reviewed head, normalizes optional agentId once and uses it for both strict resolution and ambient fallback. Its tests cover blank inputs with ambient, prepared, and session-key owners while retaining strict rejection.
Findings None None.
Security None None.

How this fits together

Agent selection maps request IDs and session keys to the agent that owns a workspace or conversation. Gateway requests pass that selection through session authorization before dispatch.

flowchart TD
  A[Agent ID and session key] --> B[Gateway input validation]
  A --> C[Deprecated SDK adapter]
  C --> D[Strict agent selection]
  B --> D
  D --> E[Invalid input error]
  D --> F[Selected workspace or session]
  F --> G[Session authorization and dispatch]
Loading

Before merge

  • Resolve merge risk (P1) - External callers relying on malformed session keys or unrepresentable IDs will now receive errors; usage of those invalid inputs is not inventoried. Deprecated SDK aliases retain blank-as-omitted compatibility.
Agent review details

Security

None.

PR surface

Source -18, Tests +77, Docs +3. Total +62 across 20 files.

View PR surface stats
Area Files Added Removed Net
Source 7 53 71 -18
Tests 11 165 88 +77
Docs 2 4 1 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 20 222 160 +62

Review metrics

Metric Value Why it matters
Production versus regression coverage production −18 lines; tests and test support +77 lines The repair removes duplicate selection logic while expanding boundary coverage and correcting positive-path fixtures.

Merge-risk options

Maintainer options:

  1. Retain the documented input boundary (recommended)
    Accept the maintainer-authored rejection of invalid selectors while retaining the repaired deprecated SDK blank-input compatibility.

Technical review

Best possible solution:

Keep strict validation in the existing selection owner and preserve the shipped blank-input contract in the deprecated SDK adapter through its documented retirement window.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: current main can select main when workspace resolution receives an unrepresentable explicit ID, and treats blanks as omitted. The added owner and RPC regressions target those paths; this read-only review did not execute them.

Is this the best way to solve the issue?

Yes. Reusing the existing strict normalizer and keeping compatibility translation in the existing SDK adapter addresses the defect without another selection owner or a storage migration.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1b3f38e7e4ff.

Labels

Label justifications:

  • P2: This is a bounded repair for incorrect agent selection and misleading Gateway errors on invalid inputs.
  • merge-risk: 🚨 compatibility: Strict resolver input behavior changes for invalid callers, although the previously identified deprecated SDK blank-input regression is repaired.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its captured evidence describes an isolated source-API before/after smoke and registered Gateway regression coverage, not an installed-Gateway run; the patch does not introduce a material new authority grant or lifetime.

Evidence

What I checked:

  • Current main still contains the defect: Current main treats blank explicit IDs as absent and passes nonblank IDs through the normalizer that can substitute main. The branch replaces that selection with strict validation. (src/agents/agent-scope.ts:320, 1b3f38e7e4ff)
  • Existing normalization owner explains the failure: normalizeAgentId returns main when strict normalization fails; normalizeAgentIdStrict returns an error for blank or unrepresentable input. Both implementations belong to this repository's normalization package. (packages/normalization-core/src/agent-id.ts:11, 3ffa07e98203)
  • Previous compatibility blocker resolved: The exact head commit, whose recorded parent is the previously reviewed head, normalizes optional agentId once and uses it for both strict resolution and ambient fallback. Its tests cover blank inputs with ambient, prepared, and session-key owners while retaining strict rejection. (src/plugin-sdk/agent-scope-runtime.ts:35, 3ffa07e98203)
  • Published SDK compatibility baseline: The v2026.9.5 adapter and underlying selection implementation accept blanks as omitted. Published documentation retains the deprecated aliases through November 29, 2026; the new adapter preserves that behavior without changing the window. (src/plugin-sdk/agent-scope-runtime.ts:26, ec9c1a13db89)
  • Gateway rejection precedes target lookup: Session mutation preparation invokes input validation before resolving the sharing target. Existing agent-run, incognito, sharing, target-identity, and commit-time authorization checks remain in place. (src/gateway/session-sharing.ts:225, 3ffa07e98203)
  • Registered RPC regression coverage: The Gateway regression checks INVALID_REQUEST and no agent-command dispatch for a malformed session key and an unrepresentable explicit agent ID. Fixture-only changes qualify positive-path session keys without weakening their delivery or cancellation assertions. (src/gateway/server.agent.gateway-server-agent-a.test.ts:763, 3ffa07e98203)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-09-20T03:17:28.749Z sha 840ff1a :: blocked before merge. :: none
  • reviewed 2026-09-20T04:23:21.092Z sha 258bd50 :: blocked before merge. :: none
  • reviewed 2026-09-20T05:23:57.516Z sha df12a0d :: blocked before merge. :: none
  • reviewed 2026-09-20T05:44:08.468Z sha 579fff6 :: blocked before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M and removed size: S labels Sep 20, 2026
@steipete steipete changed the title fix(agents): reject invalid workspace agent selectors fix(agents): reject invalid selectors before routing Sep 20, 2026
Keep positive message and reply-dispatch fixtures on fully qualified main-agent
identities so strict admission reaches their sanitization, mirroring, and
cancellation assertions. Preserve rejection coverage and lifecycle expectations.
@steipete
steipete merged commit bedaf6c into main Sep 20, 2026
215 checks passed
@steipete
steipete deleted the codex/strict-workspace-agent-boundary-482 branch September 20, 2026 08:08
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 21, 2026
* fix(agents): reject invalid workspace agent selectors

* fix(agents): preserve selector errors across callers

* test(agents): qualify session keys in dispatch fixtures

Keep positive message and reply-dispatch fixtures on fully qualified main-agent
identities so strict admission reaches their sanitization, mirroring, and
cancellation assertions. Preserve rejection coverage and lifecycle expectations.

* test(transcripts): defer timing repair to main

* fix(plugin-sdk): preserve blank selector compatibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant