Skip to content

refactor(agents): deslop agent subsystems third pass - #159346

Merged
steipete merged 2 commits into
mainfrom
deslop/l104-agents-subsystems3
Sep 27, 2026
Merged

steipete merged 2 commits into
mainfrom
deslop/l104-agents-subsystems3

Conversation

@steipete

@steipete steipete commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Maintainer-requested third cleanup pass across agent subsystems: repeated runtime forwarding, request/result projections, and locally duplicated types make ownership harder to follow.

User Impact

The cleanup preserves credential resolution order, auth-profile semantics, sandbox containment, subagent authority and fencing, transcript formats, model-facing text, and public SDK exports. No migration or configuration change is required.

Bugs found during the sweep are also fixed: remote sandbox reads/writes preserve path newlines; unpinned remove/rename through an in-mount parent symlink operate on the intended entry; and structured input accepts its own declared choice labels when they contain surrounding whitespace.

Why This Change Was Made

Production code is reduced by 1,358 net lines. Recent merged cleanup diffs were inspected first; the sweep prioritized untouched files and recorded coverage of every production file over 200 lines.

  • Sessions: share guarded extension forwarding, event payload bases, tool argument types, prompt expansion and ordered guideline collection; simplify persistence and resource-provenance projections.
  • Subagents: share native/ACP thread-binding requests, terminal cleanup and cancellation projections; remove forwarding layers and redundant intermediate failure state.
  • Harness: derive outbox kernel parameters from the existing worker operation contract, share hook parameter types, and remove one-use adapters.
  • CLI runner: simplify argument construction, environment/session metadata projection and redundant result handling.
  • Auth profiles: share promotion, cooldown-expiry and ordered OAuth failure mechanics; remove private Doctor/portability forwarding helpers.
  • Sandbox/recovery/failover: simplify bridge reuse and SSH parameter types, reuse the deferred-promise owner, and consolidate equivalent result and predicate branches.

Fixes found along the way

Remote canonicalization used line-delimited output and shell substitutions that lost path newline bytes. A real shell-backed filesystem regression failed with FileNotFoundError for the truncated root, then passed with byte-preserving framing. Existing containment checks remain in place.

Remote remove/rename already separated a filename from its parent, but an obsolete final-symlink option could then drop a symlinked parent and target a same-named root sibling. Parent canonicalization now resolves the full parent; the guest filesystem engine retains final-entry no-follow handling. Regression coverage protects root siblings, symlink targets, escaping parents, and equivalent missing-path queue identities.

Structured-input validation accepted padded labels and the Gateway returned those display bytes, but the decoder compared a trimmed answer to an untrimmed label. The execution regression first returned declined, then passed after decoding and Other-field classification normalized labels consistently. Displayed labels and schema values stay unchanged.

Evidence

Final validation passed for head e7ffdfbf8f10752c6fa88601f227f830455f5205. This PR is ready to land; it has not been merged.

  • Blacksmith Testbox: both regressions reproduced before their fixes, then all 20 focused tests passed.
  • Directory proof: 372 initial suites passed; four stale-fixture failures were repaired at public resource-loading and real requester-owner boundaries. All ten changed test files then passed individually, and the rebased subagent/harness run passed 156 suites (one existing skip).
  • Rebased importer proof passed 835 suite executions with one opt-in benchmark skipped (1,949 seconds). Import-boundary proof passed again (46 seconds); the inherited provisioning fix passed (88 seconds); pnpm build passed (419 seconds).
  • Independent review completed at P2. Two reported findings were rejected against full source: materialization still requires a SecretRef in its matching predicate, and the shared kill-completion helper still passes expectedEntry.
  • Rebased onto current main without conflicts; Git range-diff confirmed the main cleanup patch unchanged. The final correction review is scoped-clean at P2. Real-shell negative controls reproduced both original parent-alias failures and the missing-path trailing-slash identity regression; restoring the candidate passed both files (1.77s and 1.82s with --maxWorkers=1). All 50 sandbox/importer suites, boundary checks and build passed after those corrections. The conflict-resolved candidate has a fresh scoped-clean P2 review. Final Testbox gates passed: node scripts/check-changed.mjs (1,299s), 51 reconciled CLI/extension/steering/result/path suites (100s), four boundary suites (22s), and pnpm build (367s).

A supplemental broad importer selection found unrelated tooling failures. The PR provisioning failure is already fixed on main by 0a9fa7dafabec7ce52c5dac5bd71b9e3c1bcc784 and is included by the rebase. The inherited SSH QA fixture lifetime failure is tracked separately in #159572, including readiness-failure and parent-death cleanup regressions.

Current-head verification and compatibility

CI run 36300740291 passed on the exact head: 158 successful jobs, including openclaw/ci-gate; 20 jobs were inapplicable/skipped. Blacksmith Testbox provider blacksmith-testbox, lease tbx_01m3grs8m4mgmhbpy2p1dh9fgs, completed the final command successfully and was stopped. Earlier required cross-shard directory/importer proof is summarized above; passing proof was reused where inputs stayed unchanged.

There are no changed config keys/defaults, database schemas, migrations, serialized credential/session formats, retention rules, or permissions. The auth-profiles/doctor.ts edit removes a private forwarding helper while preserving the public hint operation. The failover/message-patterns.ts edit replaces six equivalent substring alternatives with some; it does not read or write stored data. The assertion baseline only shrinks verified counts. Existing auth, session persistence, compatibility, and importer tests passed; no migration is introduced or required.

Changed-test cost

Linux Testbox command wall time, each run with pnpm test <file> --maxWorkers=1:

Test file (under src/agents/) Wall seconds
harness/structured-input-execution.test.ts 3
harness/structured-input.test.ts 2
sandbox/remote-fs-bridge.path-bytes.test.ts 1.82
sandbox/remote-fs-bridge.parent-alias.test.ts 1.77
sandbox/remote-fs-bridge.test.ts 21
sessions/resource-loader.test.ts 17
subagents/announce/subagent-announce-delivery.test.ts 22
subagents/completion/subagent-completion-admission.cancel-rollback.test.ts 16
subagents/completion/subagent-completion-admission.store.test.ts 29
subagents/registry/subagent-registry-lifecycle-wake.retry.test.ts 14
subagents/registry/subagent-registry-lifecycle.test.ts 29

Current-head CI compact Node test shards took 85–546 seconds each, including setup and multiple files. GitHub's run-log archive endpoint failed twice with an HTTP/2 stream cancellation, so per-file CI time is unavailable; these are shard wall times, not standalone file measurements. No retries, increased timeouts, skipped regressions, or weaker assertions were added.

@clawsweeper

clawsweeper Bot commented Sep 27, 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 gateway Gateway runtime docker Docker and sandbox tooling agents Agent runtime and tooling size: XL labels Sep 27, 2026
@clawsweeper clawsweeper Bot added 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. labels Sep 27, 2026
@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 27, 2026, 7:53 AM ET / 11:53 UTC (Revision 6).

ClawSweeper review

What this changes

Consolidates agent session, authentication, subagent, harness, CLI, and sandbox code while correcting remote filesystem path handling and whitespace-padded structured-input choices.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open. Current main still has the remote path and padded-choice behavior this branch repairs. The pinned test merge is clean, and the reviewed owner paths reveal no concrete introduced defect. The linked SSH QA fixture PR addresses separate work.

Priority: P2
Reviewed head: e7ffdfbf8f10752c6fa88601f227f830455f5205

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The branch has focused before-and-after shell evidence and exact-head CI, while its broad refactor warrants ordinary maintainer review.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR reports before-fix failures and after-fix results from the production remote filesystem bridge using a real shell and filesystem on Linux; exact-head CI is independently confirmed. The Gateway-shaped structured-input test is supplemental, and no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR reports before-fix failures and after-fix results from the production remote filesystem bridge using a real shell and filesystem on Linux; exact-head CI is independently confirmed. The Gateway-shaped structured-input test is supplemental, and no stored-data contract changes.
Evidence reviewed 12 items Remote path fix: The introduced resolver preserves newline bytes with NUL framing, resolves the full parent, and checks that the canonical path remains within the mount.
Sandbox boundary regression: The production remote bridge is exercised through a real local shell runner; the test checks the requested entry, root sibling, final symlink target, and escaping parent.
Path-byte regression: The shell-backed bridge test covers newline-bearing roots and parents through read, pin, and write operations.
Findings None None.
Security None None.

How this fits together

The agent runtime receives turns, credentials, tool requests, and session records, then routes work through a harness, subagents, and sandboxed tools. It returns results and replies and persists session history.

flowchart LR
  A[Chat turn and session] --> B[Agent runtime]
  C[Credentials and configuration] --> B
  B --> D{Harness or subagent}
  D --> E[Sandboxed tools]
  D --> F[Structured input]
  E --> G[Results and transcript]
  F --> G
Loading

Before merge

  • Resolve review confidence - ClawSweeper must reach high confidence before merge readiness is known.
  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

None.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/agents/auth-profiles/doctor.ts, migration/backfill/repair: src/agents/failover/message-patterns.ts, unknown-truncated-pull-files. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep sandbox path pinning and choice decoding with their existing owners, guarded by the shell-backed containment and path-byte regressions.

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

Yes for the targeted defects: the shell-backed bridge regressions specify newline-path and parent-alias failures, and the structured-input execution test specifies the padded-choice failure. This read-only review did not run them.

Is this the best way to solve the issue?

Yes. The fixes stay with the existing sandbox resolver and structured-input decoder, without adding a competing owner, setting, or stored format.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against fe609d4ce1a8.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR reports before-fix failures and after-fix results from the production remote filesystem bridge using a real shell and filesystem on Linux; exact-head CI is independently confirmed. The Gateway-shaped structured-input test is supplemental, and no stored-data contract changes.

Label justifications:

  • P2: This is a bounded agent-runtime cleanup with targeted sandbox and structured-input fixes.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR reports before-fix failures and after-fix results from the production remote filesystem bridge using a real shell and filesystem on Linux; exact-head CI is independently confirmed. The Gateway-shaped structured-input test is supplemental, and no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR reports before-fix failures and after-fix results from the production remote filesystem bridge using a real shell and filesystem on Linux; exact-head CI is independently confirmed. The Gateway-shaped structured-input test is supplemental, and no stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: 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 (5 earlier review cycles)
  • reviewed September 26, 2026, 10:54 PM ET / September 27, 2026, 02:54 UTC sha unknown :: blocked before merge. :: none
  • reviewed 2026-09-27T05:37:45.599Z sha a4ebae4d2808ae44ca430835562d0fb28d524b4f :: blocked before merge. :: none
  • reviewed 2026-09-27T06:30:49.037Z sha e7ffdfb :: blocked before merge. :: none
  • reviewed 2026-09-27T06:46:38.080Z sha e7ffdfb :: blocked before merge. :: none
  • reviewed 2026-09-27T07:42:54.683Z sha e7ffdfb :: blocked before merge. :: none

Consolidate subsystem projections, runtime forwarding, and typed contracts while preserving authentication, lifecycle authority, and persistence semantics. Preserve canonical remote sandbox path bytes and decode padded structured-input labels consistently. Keep model-facing display text unchanged.
Canonicalize the full parent before unlink or rename, leaving final-entry symlink handling to the guest filesystem owner. Keep missing path spellings on one mutation queue identity. Retain public event payload types at their dispatch boundary and shrink verified assertion allowances.
@steipete
steipete force-pushed the deslop/l104-agents-subsystems3 branch from a4ebae4 to e7ffdfb Compare September 27, 2026 06:22
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 27, 2026
@steipete
steipete marked this pull request as ready for review September 27, 2026 06:39
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: e7ffdfbf8f10752c6fa88601f227f830455f5205
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/auth-profiles/doctor.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/oauth-refresh-failure.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/portability.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/profiles.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/usage-state.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/sandbox/browser.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/sandbox/remote-fs-bridge-canonical-path.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/sandbox/remote-fs-bridge-paths.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/sandbox/remote-fs-bridge-pinned-frame.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/sandbox/remote-fs-bridge.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/sandbox/ssh.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/sessions/auth-storage-projection.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 27, 2026
@steipete
steipete enabled auto-merge (squash) September 27, 2026 12:31
@steipete
steipete merged commit 9ca49c5 into main Sep 27, 2026
321 of 323 checks passed
@steipete
steipete deleted the deslop/l104-agents-subsystems3 branch September 27, 2026 12:31
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 28, 2026
* refactor(agents): deslop agent subsystems third pass

Consolidate subsystem projections, runtime forwarding, and typed contracts while preserving authentication, lifecycle authority, and persistence semantics. Preserve canonical remote sandbox path bytes and decode padded structured-input labels consistently. Keep model-facing display text unchanged.

* fix(agents): preserve remote mutation parent identity

Canonicalize the full parent before unlink or rename, leaving final-entry symlink handling to the guest filesystem owner. Keep missing path spellings on one mutation queue identity. Retain public event payload types at their dispatch boundary and shrink verified assertion allowances.
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 3, 2026
Block A (announce deps seam): subagent-announce-deps.ts and the
`export { testing }` / `subagentAnnounceDeps.*` calls resurrected the
module-level deps object that upstream ffcd6e7 (openclaw#154985, keep announce
overrides in test support) removed, using createLazyImportLoader where
c61ba3e (openclaw#158020) uses createLazyPromise. The announce host now calls the
runtime barrel directly (getRuntimeConfig, callSubagentLifecycleGateway for
cleanup) and tests use upstream's announceTesting seam, which spies on that
barrel. The format e2e suite drops its second seam.

Block B (descendant wake old shape): subagent-announce-descendant-wake.ts and
the findings-wake wrapper kept the pre-9ca49c5ac1 (openclaw#159346) shape
(stripWakeRunSuffixes, isWakeContinuationRun, wakeSubagentRunAfterDescendants)
plus the accepted steer-dispatch reservation (#1404). The file is
upstream bytes again and the host makes upstream's runDescendantWake call. The
findings-wake file and the fork-only wake-ownership test are deleted; the
nested-matrix and continuation test-support helpers drop the wake-ack and
reservation fakes.

What stayed (continuation): the host keeps one lazy
loadSubagentContinuationRuntime (createLazyPromise) and reads
resolveContinuationRuntimeConfig from the runtime barrel at call time, so
continuation suites that mock the barrel still steer it. The two continuation
topology/runtime contract tests now point at the host instead of the deleted
deps file.

Home: restored to upstream (drift residue). Upstream's descendant-wake
currency matrix (subagent-announce-delivery.test.ts + test-support at
b51feb9) passes 148/148 against this shape.

Refs #1418

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docker Docker and sandbox tooling docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed size: XL 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