Skip to content

refactor(agents): simplify runtime-auth deadline plumbing - #189183

Merged
roboclaw-bot merged 1 commit into
mainfrom
loop/simplify-189144
Oct 31, 2026
Merged

roboclaw-bot merged 1 commit into
mainfrom
loop/simplify-189144

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Follow-up to #189144, which fixed stalled provider authentication but added 126 net production lines. This requested simplification targets a net reduction of at least 60 production lines and moves the combined change toward the loop’s net-zero goal.

User Impact

No user-visible behavior change. Authentication still shares the run deadline, propagates cancellation, rejects late credentials, and preserves recovery from provider AbortErrors. Error text and public SDK types are unchanged.

Why This Change Was Made

Inline request authentication into its owning controller, removing the single-use forwarding factory and its duplicated parameter contract. Call the existing timer clamp directly, inline the one-use key-sink type, and return the existing refresh promise. Keep the unchanged pure cooldown policy beside the existing auth-profile failure policy so the controller stays within the source-size limit.

Production delta: −61 lines; test delta: 0. Combined with #189144: +65 production lines. The shared auth deadline remains necessary to distinguish run cancellation from a provider’s own abort and to share the preparation/execution budget.

Evidence

  • All tests added by fix(agents): fail stalled provider authentication at the run deadline #189144 remain unchanged, including slow-success, cancellation, hung credential/exchange, late result, and provider-abort recovery cases.
  • 77 focused tests across four files passed unchanged in 141.90 seconds (controller, request-auth, binding, and auth-profile failure policy).
  • Targeted core typecheck, changed-file lint/format, and git diff --check: passed.
  • Local autoreview (P0–P2) against 4382e6e9232f, with full affected source and auth test context: scoped-clean, no actionable findings. The final committed head fe628f869ec5 only adds mechanical unused-import/shadowing cleanup and restores the original clock-read placement to that reviewed snapshot. Local ClawSweeper is unavailable on this host; hosted ClawSweeper review completed on fe628f869ec5 with zero findings and no before-merge actions.
  • Broad proof: PR CI passed on fe628f869ec5; no inherited-failure exception was used. Landed through scripts/pr as bae3b0bdbf72. No live Gateway or protected checkout was used.

Co-authored-by: Alex Mittell [email protected]

Inline request auth into its controller and reuse the timer clamp directly.
Keep deadline, cancellation, account authority, and error behavior unchanged.

Co-authored-by: Alex Mittell <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Oct 31, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review October 31, 2026 07:26
@github-actions

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: fe628f869ec5fb90a7de0572b94e96ac2642411b
  • Maintainer: @roboclaw-bot
  • Repository role: maintain

These security sensitive changes were made:

  • src/agents/embedded-agent-runner/run/auth-controller.request-auth.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/embedded-agent-runner/run/auth-controller.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/embedded-agent-runner/run/auth-controller.types.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/embedded-agent-runner/run/auth-profile-failure-policy.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/runtime-auth-refresh.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.

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. labels Oct 31, 2026
@clawsweeper

clawsweeper Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR inlines request authentication into its controller, removes redundant forwarding helpers, and relocates unchanged cooldown policy.

Example: An OAuth credential exchange finishes after a run's 100 ms deadline.

  • Before: The deadline aborts authentication and prevents installation of the late credential.
  • After: The same rejection remains in place through the simplified controller.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, useful refactor with no identified defect; validation is reported through existing in-process tests, with broad CI still running.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored behavior-preserving refactor is outside the ordinary contributor proof gate; supplied evidence reports focused tests rather than a live Gateway or provider run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
Reason: The maintainer-authored direction is established, and the verified reduction removes redundant internal contracts without changing public SDK types, settings, or user behavior.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR meaningfully simplifies auth plumbing while preserving existing behavior; no actionable defect was found.

Priority: P3
Reviewed head: fe628f869ec5fb90a7de0572b94e96ac2642411b

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped Gateway/provider run is supplied; the reported validation exercises the auth owner through existing in-process tests.
Agent review details

How this fits together

The embedded runner's auth controller receives selected profiles, run authority, cancellation, and deadlines, then resolves credentials and supplies checked authentication to provider transports.

flowchart TD
  A[Embedded agent run] --> B[Auth controller]
  C[Run deadline and cancellation] --> B
  B --> D[Canonical credential owner]
  D --> E[Runtime auth exchange]
  E --> F[Current authority check]
  F --> G[Credential installation and provider handoff]
Loading

Technical review

Best possible solution:

Retain the controller-owned implementation with the existing deadline, cancellation, account-authority, and cooldown contracts intact.

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

This is a refactor rather than a new bug report; source comparison establishes preserved behavior, and no target code was executed during this read-only review.

Is this the best way to solve the issue?

The change uses existing owners, removes the replaced factory and unused exports completely, and preserves the timer clamp's exact calculation.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Request authentication and deadline plumbing keeps the original intent (fix: renew OAuth credentials during long custom transport attempts #184791: Enable selected-account renewal before physical requests; fix(agents): fail stalled provider authentication at the run deadline #189144 subsequently bounded lookup and exchange by the run lifetime.)
  • Refresh timer clamp keeps the original intent (85b169c: Prevent oversized Node timers from becoming a hot refresh loop; the direct shared-helper call preserves the existing floor and maximum.)
  • Cooldown probe policy keeps the original intent (1b1cebf: Keep profile admission aligned with effective auth routes; later runner consolidation reused this policy, whose logic is moved unchanged here.)
  • Controller parameter types keeps the original intent (7bd53ff: Keep existing controller parameters in the owning type module; inlining the single-use key-sink shape preserves its structural contract.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Hannes Rudolph: Raw commit c152c59 adds src/agents/embedded-agent-runner/run/auth-controller.ts:530 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c152c5976b21; files: src/agents/embedded-agent-runner/run/auth-controller.ts)
  • RoboClaw: Raw commit 7bd53ff adds src/agents/embedded-agent-runner/run/auth-controller.ts:135 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7bd53ff28f69; files: src/agents/embedded-agent-runner/run/auth-controller.ts)

PR surface

Source -61. Total -61 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 120 181 -61
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 120 181 -61

Review metrics

Metric Value Why it matters
Production versus test delta Production −61 lines; tests unchanged The reduction removes forwarding machinery and duplicate parameter contracts without adding test scaffolding.

Labels

Label changes:

  • add P3: This is a behavior-preserving simplification with no new user-facing capability or reported urgent failure.
  • 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:

  • P3: This is a behavior-preserving simplification with no new user-facing capability or reported urgent failure.
  • 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 31, 2026, 3:31 AM ET / 07:31 UTC.

@roboclaw-bot
roboclaw-bot merged commit bae3b0b into main Oct 31, 2026
221 checks passed
@roboclaw-bot
roboclaw-bot deleted the loop/simplify-189144 branch October 31, 2026 07:36
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

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

Inline request auth into its controller and reuse the timer clamp directly.
Keep deadline, cancellation, account authority, and error behavior unchanged.

Co-authored-by: Alex Mittell <[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 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: 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