Skip to content

fix: retain approval classification resources through cleanup - #143307

Merged
steipete merged 1 commit into
mainfrom
codex/approval-completion-resources
Sep 9, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/approval-completion-resources

Conversation

@steipete

@steipete steipete commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Related: #140674

What Problem This Solves

Resolves a problem where ambiguous approval classification releases its prepared model runtime before inference and transport cleanup finish. Concurrent classifications can rebuild a generation that should still be retained, and a timeout can leave callbacks running beyond their owner.

Why This Change Was Made

Acquire the existing finite model contract and admit cleanup to the parent before preparation. Preserve the caller's result deadline while draining actual completion, response callbacks, and cancellation work before releasing the lease. This is the approval-classifier slice of #140674.

The closed-list shortcut, verified embedded route, exact provider/model/profile/auth matching, final route revalidation, and fail-closed policy remain intact. The ten-second timer still starts after route matching and clears after completion and revalidation, independently of drainage.

User Impact

Approval classification keeps its model and authentication runtime available until its real work finishes, including after a timed-out verdict. Approval decisions, input limits, and timeout behavior are unchanged.

Evidence

Three native regression cases fail against the original code and pass with the repair. They cover overlapping preparation, response-body cancellation, and credential rotation during pending verdicts. All 158 focused tests passed; changed-file gate coverage, isolated Codex review through P2, and the full build passed.

A plain Node run of the emitted classifier used real SQLite authentication state, the production verified-binding machinery, a synthetic plugin, and loopback HTTP. A real response callback remained held after the unchanged deadline returned other at 10,021 ms. Parent drainage, generation reuse, fresh preparation after release, and credential-rotation rejection passed. Strict process cleanup completed in 12.987 seconds; all 12,111 built artifacts remained unchanged. No pending mutation was executed.

These are local observations, not a comparative performance benchmark or paid-provider proof. Native cancellation coverage uses the declared hermetic test transport; the compiled proof uses the actual plugin callback and HTTP path. Broader run-registration physical disposal is a separate slice.

@clawsweeper

clawsweeper Bot commented Sep 9, 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 size: L maintainer Maintainer-authored PR labels Sep 9, 2026
@steipete
steipete marked this pull request as ready for review September 9, 2026 18:04
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 9, 2026
@clawsweeper

clawsweeper Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 9, 2026, 2:10 PM ET / 18:10 UTC.

ClawSweeper review

What this changes

The approval classifier retains its prepared model resources until inference callbacks and cancellation finish, with regression coverage for overlapping requests and credential rotation.

Merge readiness

✅ Ready for maintainer review

This focused repair remains necessary on current main. No actionable introduced defect was found; the broader draft is explicitly a reference, not a replacement landing path.

Priority: P2
Reviewed head: 6080906cb375bdc77567f885fc8331148572ba67

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused lifecycle repair with relevant reported production-path evidence and no identified blocking defect.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured body reports the emitted classifier running through production bindings and real loopback HTTP: a held callback survived the timeout verdict, drainage retained its owner, subsequent acquisition refreshed resources, and credential rotation rejected pending verdicts. The native regressions supplement these reported runtime observations.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured body reports the emitted classifier running through production bindings and real loopback HTTP: a held callback survived the timeout verdict, drainage retained its owner, subsequent acquisition refreshed resources, and credential rotation rejected pending verdicts. The native regressions supplement these reported runtime observations.
Evidence reviewed 8 items Introduced lifecycle repair: The complete merge-base-to-head production diff admits work to the parent before acquisition, reports the verdict separately, and drains the child scope before releasing the lease. Existing route, profile, fingerprint, timeout, and verdict checks remain.
Current main still needs this caller migration: Fetched main still calls the preparation-only helper. That helper releases its acquired lease before returning the prepared model, so existing acquisition support does not already solve this classifier's lifetime.
Latest release comparison: The supplied latest release, v2026.9.3, also contains the preparation-only classifier without the new cleanup scope.
Findings None None.
Security None None.

How this fits together

The system agent interprets user replies to pending configuration proposals. Ambiguous replies use a verified model route to produce an approval verdict, while transport cleanup must finish before its model resources are released.

flowchart TD
  A[User reply and pending proposal] --> B{Clear approval or rejection?}
  B -->|Yes| F[Approval verdict]
  B -->|No| C[Verify route and acquire model resources]
  C --> D[Classify through model transport]
  D --> E[Revalidate route]
  E --> F
  D --> G[Drain callbacks and cancellation]
  G --> H[Release model resources]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +26, Tests +346. Total +372 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 87 61 +26
Tests 2 353 7 +346
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 440 68 +372

Review metrics

Metric Value Why it matters
Production versus regression coverage Net production +26 lines; tests +346 lines Production growth establishes explicit cleanup ownership; most added code exercises overlap, cancellation, and credential drift.

Technical review

Best possible solution:

Use the existing finite model lease through actual cleanup while keeping approval decisions and the caller deadline independent of resource drainage.

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

Yes, source establishes the early-release path, and the supplied regressions exercise overlapping classifications and delayed cancellation. This read-only review did not execute a current-main reproduction.

Is this the best way to solve the issue?

Yes. Migrating this caller to the existing acquisition contract and joining actual transport cleanup repairs the lifecycle owner without adding a parallel API or changing approval policy.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded lifecycle repair for ambiguous approval classification, with no demonstrated widespread outage or changed approval policy.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured body reports the emitted classifier running through production bindings and real loopback HTTP: a held callback survived the timeout verdict, drainage retained its owner, subsequent acquisition refreshed resources, and credential rotation rejected pending verdicts. The native regressions supplement these reported runtime observations.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured body reports the emitted classifier running through production bindings and real loopback HTTP: a held callback survived the timeout verdict, drainage retained its owner, subsequent acquisition refreshed resources, and credential rotation rejected pending verdicts. The native regressions supplement these reported runtime observations.

Label justifications:

  • P2: This is a bounded lifecycle repair for ambiguous approval classification, with no demonstrated widespread outage or changed approval policy.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured body reports the emitted classifier running through production bindings and real loopback HTTP: a held callback survived the timeout verdict, drainage retained its owner, subsequent acquisition refreshed resources, and credential rotation rejected pending verdicts. The native regressions supplement these reported runtime observations.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body reports the emitted classifier running through production bindings and real loopback HTTP: a held callback survived the timeout verdict, drainage retained its owner, subsequent acquisition refreshed resources, and credential rotation rejected pending verdicts. The native regressions supplement these reported runtime observations.

Evidence

What I checked:

  • Introduced lifecycle repair: The complete merge-base-to-head production diff admits work to the parent before acquisition, reports the verdict separately, and drains the child scope before releasing the lease. Existing route, profile, fingerprint, timeout, and verdict checks remain. (src/system-agent/approval-intent.ts:85, 6080906cb375)
  • Current main still needs this caller migration: Fetched main still calls the preparation-only helper. That helper releases its acquired lease before returning the prepared model, so existing acquisition support does not already solve this classifier's lifetime. (src/system-agent/approval-intent.ts:83, 9865df7610c8)
  • Latest release comparison: The supplied latest release, v2026.9.3, also contains the preparation-only classifier without the new cleanup scope. (src/system-agent/approval-intent.ts:83, 1391f7cd2d40)
  • Transport cleanup reaches the retained scope: Transport lifecycle callbacks and stream cancellation report their actual pending promises through observePendingProviderWork; OpenClaw's transport host registers those promises with AsyncWorkScope. Its drain waits for admitted descendants. (packages/ai/src/transports/transport-stream-shared.ts:322, 6080906cb375)
  • Implementation and authorization boundary: The changed inference path explicitly requires the embedded OpenClaw runtime; other harnesses retain the exact-text path. Resource retention does not replace credential matching or final route revalidation. There is no affirmative dependency on the sibling Codex implementation. (src/system-agent/approval-intent.ts:79, 6080906cb375)
  • Regression and runtime evidence: The fully supplied PR body reports three before/after regressions and a compiled classifier run using SQLite auth, production verified bindings, a synthetic plugin, and real loopback HTTP. A held response callback outlived the 10,021 ms 'other' verdict; parent drainage, generation reuse, subsequent fresh preparation, and credential-rotation rejection passed. These are contributor-reported observations, not reviewer-executed checks. Captured context identity: 50a68e13dae46751dca2fdbef93b223729d9150c582144bb04befe6e2d858dff. (src/system-agent/approval-intent.resources.test.ts:26, 6080906cb375)

Likely related people:

  • 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.

@steipete
steipete merged commit 4693a96 into main Sep 9, 2026
247 checks passed
@steipete
steipete deleted the codex/approval-completion-resources branch September 9, 2026 18:25
@steipete

steipete commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR 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. size: L 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