Skip to content

fix(sandbox): attribute slow dependency builder retirement - #191985

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-sandbox-builder-retire-native-attribution-20260919
Nov 3, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-sandbox-builder-retire-native-attribution-20260919

Conversation

@steipete

@steipete steipete commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Slow sandbox startup reports only an aggregate dependency-builder retirement duration, hiding whether the engine spends that time killing, waiting, or verifying termination.

User Impact

Operators can attribute retirement stalls from the existing slow-send detail line. This is diagnostics-only: engine commands, authority checks, terminal-state proof, and template publication behavior stay the same. No configuration or schema changes.

Why This Change Was Made

Add fixed owner phases for registry/lock/claim/target/identity work and kill/wait/verify, plus a bounded verify-attempt count in the existing report. OpenClaw performs one terminal-state inspect per builder, with no verification retry or backoff. Native engine cleanup and internal polling remain charged to their command. Physical removal remains housekeeping. Inclusive parent/child timings overlap.

Production growth is 21 lines, necessary for the requested attribution; no runtime speedup is claimed. Simplification retained the existing diagnostics owner and phase helper without a new abstraction, cache, or logging stream.

Evidence

  • 22 focused tests pass: dependency template owner/lifecycle and chat-send diagnostics. The new owner→slow-send regression fails on the unchanged parent because all retirement sub-stages are absent; both successful and refused terminal-state verification pass with the change. Test growth is 49 lines with a scoped allocation.
  • Rebased focused proof:22 tests pass in45.53s including worker compilation and two suite shards. Fresh Codex P0–P2 review is scoped-clean. All three changed TypeScript files remain byte-identical to the original reviewed implementation.
  • No Control UI imports of changed modules; no shared/config/packages modules changed.
  • Faithful fake: two A/A controls plus five serial interleaved pairs, 62,002 files / 1.181 GB and 10,001 synthetic sessions; all contents identical, kill1/wait1/verify1/stop0/rm1 and zero surviving builders in every arm. APFS and an 8 MB database do not qualify native Podman/btrfs or the physical 35 GiB production shape.
  • Rebased pnpm check:changed passed all guards, types, format and lint; its sole failure was the main systemKind unused export from improve(ui): clarify Systems devices and backup access #192070 / 9ce5ba172a8e, reproduced on exact main parent b0c014629908. Final main includes 2dbd7f79bbf1, which removes that unused export. Rerunning only the two previously failing scans on final head ff3b6291a846 passes production and full-tree with zero findings (118.335s). Earlier unrelated failures were consumed from upstream fixes. No unresolved local failures remain; the original aggregate failure is retained as history, not relabeled as a passing run.

Release-note context: slow sandbox sends expose dependency builder retirement sub-stage timings and verification attempt count.

Metric Baseline median / p95 Candidate median / p95
Retirement 172.489 / 192.110 ms 176.875 / 735.167 ms
Fresh preparation 23.038 / 23.268 s 21.592 / 51.360 s
Main-thread CPU 689.821 / 716.315 ms 672.142 / 1501.998 ms
Node process CPU 27.379 / 28.606 s 25.842 / 48.194 s
Main-isolate allocation 311.095 / 335.157 MB 318.875 / 326.974 MB
Unchanged warm turn 5.516 / 6.785 s 5.298 / 19.475 s

Five-sample p95 equals the maximum. No speedup or tail non-regression claim. Retirement median +2.54%, allocation median +2.50%; candidate p95 retirement +282.7%, preparation +120.7%, process CPU +68.5%, main CPU +109.7%, warm latency +187%. A/A preparation itself varied 25.175→56.149 s. External process timestamp windows account for 97.3%/99.3% of the two retirement tail increases but include startup/scheduling and intervening owner work, so do not isolate observer overhead. The unchanged warm path also varied. All tails remain in the evidence.

Candidate kill/wait/verify medians: 34.476/35.279/34.859 ms, each count1. CPU covers the preparation-window Node process (workers included, Git/Python excluded); allocation is main-isolate V8 allocation. This requested attribution has +21 production LOC and no behavior/performance fix.

Workload: node --expose-gc --import ./scripts/tsx.mjs scripts/perf/local-workspace-checkpoint-measure.ts --source-root <frozen-revision> --output <fresh-arm> --mode preparation --serial-turns --fresh-only --burst 1 --requests 1 --files 62000 --file-bytes 19050 --acceleration --sandbox-backend podman --fake-builder-removal-ms 36000.

Landing status

The shared exact-budget reconciliation #192026 merged as a4d7594944569e50a7149d560e68d73899fb16b8 after green exact-head CI41699981740. Newer main introduced81 more unallocated lines: #191470 contributed80, and #156399's10 were offset by9 deletions elsewhere. Scalar-only follow-up #192207 merged as 135c63eff31e1d76c8bf8832495573c08dd627a2 after green exact-head CI41703636481 and funds exactly that81, with no reserve. This PR's49 regression lines retain their own49-line allocation throughout.

Merged as 2780c3f622408f82cab88572b5aa8748c61cdeab from exact head ff3b6291a846955708f00f5725ad84f232b5e7b4. CI41707010703 passed all43 executed jobs; final Codex review is scoped-clean. No red-CI exception or reduced regression coverage is used.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: S labels Nov 3, 2026
@steipete
steipete marked this pull request as ready for review November 3, 2026 14:59
@clawsweeper

clawsweeper Bot commented Nov 3, 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 Nov 3, 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-11-03T19:52:56.070973Z ff3b629 New commits
ℹ️ 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.

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

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

These security sensitive changes were made:

  • src/agents/sandbox/dependency-template.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.

Carefully review these changes before merging.

@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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Nov 3, 2026
@clawsweeper

clawsweeper Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR adds dependency-builder retirement sub-stage timings and a verification-call count to slow chat-send diagnostics.

Example: The synthetic regression spends 19,000 ms killing a builder, 500 ms waiting, and 200 ms verifying termination.

  • Before: The slow-send line exposes only aggregate retirement time.
  • After: It includes kill=19000ms, wait=500ms, verify=200ms, and verify.attempts=1 under the retirement detail prefix.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused instrumentation with no actionable defect; confidence in exercised behavior rests on the reported in-process regression rather than a shipped-entry-point trace.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored diagnostics PR is outside the ordinary proof gate; supplied evidence covers the retirement-to-log path using mocked engine I/O and time, with measurements still pending.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Operators investigating slow sandbox startup cannot distinguish engine kill, wait, and termination-verification delays.
Reason: The maintainer-authored direction has clear diagnostic value and adds bounded measurements without changing execution, configuration, or storage.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR adds useful retirement attribution through existing owners, with no concrete correctness or security findings.

Priority: P3
Reviewed head: c879d99dd73200eaa7ce99476b18165f0d463c93

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped Gateway slow-send trace exercising the new retirement fields is supplied; the body reports the regression failing on the parent and passing on the head.
Agent review details

How this fits together

Sandbox dependency preparation retires its disposable builder before publishing template files; request-scoped observers carry retirement measurements into Gateway slow-send logs.

flowchart LR
  A[Chat send] --> B[Sandbox preparation]
  B --> C[Dependency builder retirement]
  C --> D[Container engine]
  C --> E[Request diagnostics observer]
  E --> F[Slow send log]
Loading

Technical review

Best possible solution:

Retain the focused instrumentation at the existing retirement and reporting owners while preserving termination and housekeeping behavior.

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

Current-main source confirms that retirement lacks these sub-stage measurements; the PR reports a parent-failing regression, but no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch is the smallest complete extension: fixed marks reuse the existing phase helper, and the existing request diagnostics owner counts verification calls without introducing retries or another logging path.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Dependency builder retirement keeps the original intent (941f173: Prove builder termination before template publication while leaving physical removal to existing housekeeping.)
  • Dependency cleanup attribution keeps the original intent (8d4e07d: Expose dependency cleanup latency through existing slow-send diagnostics without promising a speedup.)
  • Slow-send reporting keeps the original intent (c422fb2: Keep numeric timing collection while avoiding message formatting for fast sends.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 941f173 adds src/agents/sandbox/dependency-template.ts:114 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 941f173975b3; files: src/agents/sandbox/dependency-template.ts)
  • Josh Avant: Raw commit a11879c adds src/agents/sandbox/dependency-template.ts:85 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: a11879cd40f6; files: src/agents/sandbox/dependency-template.ts)

PR surface

Source +21, Tests +49, Docs +11, Other +2. Total +83 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 21 0 +21
Tests 1 49 0 +49
Docs 1 11 0 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 5 83 0 +83

Review metrics

Metric Value Why it matters
Production versus test growth Production +21 lines; tests +49 lines The growth adds fixed phase boundaries and report-window counting, with focused success/failure coverage and no new production abstraction.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is a low-risk diagnostic improvement that does not change sandbox execution or reduce startup latency.
  • 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 November 3, 2026, 10:18 AM ET / 15:18 UTC.

Expose fixed kill, wait, verification, and surrounding retirement phases on the existing slow-send detail line, with a bounded verification attempt count. Preserve immutable-ID commands, terminal-state proof, and cleanup authority.
@steipete
steipete force-pushed the steipete/perf-micro-sandbox-builder-retire-native-attribution-20260919 branch from c879d99 to ff3b629 Compare November 3, 2026 19:50
@steipete
steipete enabled auto-merge (squash) November 3, 2026 19:59
@steipete
steipete merged commit 2780c3f into main Nov 3, 2026
128 checks passed
@steipete
steipete deleted the steipete/perf-micro-sandbox-builder-retire-native-attribution-20260919 branch November 3, 2026 20:05
@steipete

steipete commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 4, 2026
…191985)

Expose fixed kill, wait, verification, and surrounding retirement phases on the existing slow-send detail line, with a bounded verification attempt count. Preserve immutable-ID commands, terminal-state proof, and cleanup authority.
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 P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed 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