Skip to content

fix(sandbox): normalize session aliases in explain - #182406

Merged
steipete merged 1 commit into
mainfrom
steipete/fix-51245
Oct 24, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/fix-51245

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: openclaw sandbox explain rejects an unscoped channel session alias such as telegram:slash:123, and expands the short name main literally instead of honoring session.mainKey.

User Impact

sandbox explain --session now resolves channel aliases and the configured main session the same way the rest of OpenClaw does, so the diagnostic reports the right agent and sandbox policy.

Why This Change Was Made

The command treated every colon-bearing key as already agent-scoped and kept its own short-name expansion and agent-mismatch check. It now uses the existing agent-selection owner and toAgentStoreSessionKey before session lookup and channel inference, removing the local colon heuristic, the duplicate mismatch policy, and the separate short-name builder. Stored delivery metadata still takes precedence, global sessions stay global, and conflicting agents are still rejected by the canonical resolver.

Production LOC +9/-18 (net -9); tests +48/-6; docs +2/-1. No new config, dependency, API, protocol, or persistence surface.

Evidence

  • Red on main: node scripts/run-vitest.mjs src/commands/sandbox-explain.test.ts failed the 4 new regression cases (14 passed).
  • Green: node scripts/run-vitest.mjs src/commands/sandbox-explain.test.ts src/agents/sandbox-explain.test.ts passed 23 of 23, exercising the real resolver against a temporary session store.
  • Targeted typecheck, oxlint, oxfmt, and git diff --check passed.
  • Independent review: clean, no actionable findings.
  • Gap: this changes only the diagnostic command. It does not change sender authorization and does not claim to fix the reported live Telegram elevated-execution denial; no live Telegram flow was run, so PR CI remains the broad proof.

Related: #51245

Use the canonical agent resolver and store-key expansion before diagnostic
session lookup. Channel-prefixed aliases and the main alias now resolve like
other session consumers, while global sessions and mismatched-agent rejection
retain their existing owners.

This repairs sandbox explain diagnostics only; sender authorization is unchanged.
Refs #51245.
@clawsweeper

clawsweeper Bot commented Oct 24, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T08:15:06.427351Z 556e3a7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations docker Docker and sandbox tooling size: S labels Oct 24, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR normalizes sandbox-explain session aliases through existing agent and session-key resolvers.

Example: With agent builder and session.mainKey set to operator, run openclaw sandbox explain --session main.

  • Before: The diagnostic inspects agent:builder:main.
  • After: The diagnostic inspects agent:builder:operator.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused, correct repair with useful command-level regression coverage and green exact-head CI; evidence remains in process and the linked issue is only partly addressed.
Proof confidence 🦐 gold shrimp (3/6) The supplied evidence exercises sandboxExplainCommand with real resolvers and temporary session storage, rather than the shipped CLI; this maintainer-authored diagnostic change is outside the ordinary contributor proof gate and does not materially change authority.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Operators cannot inspect unscoped channel aliases reliably, and main can select the wrong configured session.
Reason: The maintainer-authored direction restores existing diagnostic contracts with less production code; Related wording correctly preserves the linked report's broader scope.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR provides a focused diagnostic fix still needed on current main, with no actionable correctness findings.

Priority: P2
Reviewed head: 556e3a7df9f55e819eccc505b9c708b347616967

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped-CLI capture is supplied for alias expansion; the available evidence exercises the command in process.
Agent review details

How this fits together

The sandbox diagnostic accepts CLI agent/session selectors, reads existing session metadata and sandbox configuration, and prints effective policy without authorizing execution.

flowchart TD
  A[CLI selectors] --> B[Canonical agent resolution]
  B --> C[Canonical session key]
  C --> D[Read-only session lookup]
  D --> E[Sandbox and channel diagnostics]
  E --> F[JSON or terminal report]
Loading

Technical review

Best possible solution:

Use the existing normalization owners for this diagnostic and retain separate tracking for live Telegram sender authorization.

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

Current-main source establishes both failing paths, and the PR reports four new cases failing before the fix; no target code was executed during this read-only review.

Is this the best way to solve the issue?

This is the smallest complete diagnostic repair: reuse canonical agent selection and store-key expansion while preserving global sessions, stored delivery precedence, and mismatch rejection.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7a9a6a981aba.

Provenance checked

  • Diagnostic alias expansion changes intended behavior with a stated reason (9f90984: The original sandbox inspector expanded short names locally and treated colon-bearing input as already scoped; the later localization preserved that behavior.)
  • Explicit agent selection and mismatch rejection keeps the original intent (fix(cli): preserve explicit read-only agent targets #123868: Read-only commands must honor explicit agents without requiring an ambient default; canonical session resolution continues to reject conflicting scoped agents.)
  • Stored delivery metadata and channel inference keeps the original intent (1fb7766: The refactor localized existing preparation without changing behavior and added preservation cases for stored delivery and main-key selection.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 1c055ba adds src/commands/sandbox-explain.ts:157 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1c055ba5e521; files: src/commands/sandbox-explain.ts)

PR surface

Source -9, Tests +42, Docs +1. Total +34 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 9 18 -9
Tests 1 48 6 +42
Docs 1 2 1 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 59 25 +34

Review metrics

Metric Value Why it matters
Production versus tests Production +9/-18; tests +48/-6 The patch removes duplicate production policy while extending the existing table with distinct alias and metadata regressions.

Labels

Label changes:

  • add P2: Incorrect session selection affects an operator diagnostic; this patch does not change live execution or message delivery.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Incorrect session selection affects an operator diagnostic; this patch does not change live execution or message delivery.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 24, 2026, 4:27 AM ET / 08:27 UTC.

@steipete
steipete merged commit 8f03d13 into main Oct 24, 2026
128 of 131 checks passed
@steipete
steipete deleted the steipete/fix-51245 branch October 24, 2026 15:56
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
Use the canonical agent resolver and store-key expansion before diagnostic
session lookup. Channel-prefixed aliases and the main alias now resolve like
other session consumers, while global sessions and mismatched-agent rejection
retain their existing owners.

This repairs sandbox explain diagnostics only; sender authorization is unchanged.
Refs openclaw#51245.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docker Docker and sandbox tooling docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S 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