Skip to content

refactor(auth): reuse failure state reset - #135699

Closed
vincentkoc wants to merge 1 commit into
mainfrom
refactor/auth-profile-failure-reset
Closed

vincentkoc wants to merge 1 commit into
mainfrom
refactor/auth-profile-failure-reset

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Maintainer-requested duplication cleanup: manual auth-profile failure clearing carried a private copy of the canonical failure-state reset. Keeping both implementations made future reset-field changes vulnerable to drift.

Why This Change Was Made

src/agents/auth-profiles/usage-state.ts remains the existing owner of reusable auth-profile failure-state normalization. The manual clear path now calls resetAuthProfileFailureState(existing ?? {}), and the duplicate resetUsageStats path is deleted.

The canonical helper was not widened or otherwise changed. Overrides, reset fields, preserved usage history, undefined-stat behavior, locking, owner persistence, profile replacement, successful-use reset, rotation, and provider bypass semantics remain unchanged. There are no configuration, schema, SDK, dependency, transaction, locking, persistence, or recovery changes.

User Impact

No user-visible behavior changes. Auth-profile cooldown clearing continues to reset the same failure fields while preserving unrelated usage history.

Evidence

  • Diff: one production file, +4/-24 (net -20); tests +0/-0.
  • Patch ID: 5dcb228b7f9d40cdb38c4aaff1560fb735ca67ac.
  • Focused owner-boundary tests passed before and after the final refresh: 5 files, 187 tests.
    • src/agents/auth-profiles/usage.test.ts
    • src/agents/auth-profiles/usage.inherited-owner.test.ts
    • src/agents/auth-profiles/upsert-with-lock.sqlite.test.ts
    • src/agents/auth-profiles/profiles.test.ts
    • src/agents/auth-profiles/order.test.ts
  • The five test blobs and their runner configuration are byte-identical to the reviewed parent. The earlier 186-test planning count was stale; the live suite consistently reports 187.
  • A 100,000-case differential compared the removed implementation with the canonical helper across ordinary and malformed values, overrides, throwing proxies, property descriptors, getter/trap order, and fresh-input mutation checks: zero mismatches.
  • node scripts/check-changed.mjs --dry-run -- src/agents/auth-profiles/usage.ts passed classification.
  • node scripts/check-changed.mjs -- src/agents/auth-profiles/usage.ts passed conflict, ratchet, attribution, registry, wildcard export, duplicate coverage, dependency pin, formatting, plugin boundary, wrapper shadowing, package patch, and core graph-boundary checks. It then stopped in core typechecking because the linked shared install lacks markdown-it-cjk-friendly, mdast-util-from-markdown, mdast-util-gfm-table, micromark-extension-gfm-table, and libphonenumber-js/min.
  • pnpm check:test-types reached the same missing-dependency blocker after the task-local sparse profile was expanded for its tracked UI config inputs.
  • pnpm check:import-cycles passed with zero runtime value cycles.
  • pnpm check:madge-import-cycles passed with zero cycles.
  • git diff --check passed.
  • pnpm build was not run against an incomplete dependency tree. Available idle ordinary checkouts had different lockfiles, so dependencies were not installed, reconciled, or borrowed in the worktree.
  • No new test was added: existing owner-boundary tests already pin complete manual clearing, preserved history, missing-entry behavior, inherited-owner persistence, login replacement, successful-use reset, and profile ordering.
  • No CI or Crabbox/Testbox run was dispatched in this executor phase.

Overlap heads were rechecked immediately before push and remained open and unchanged:

The acting executor directly inspected the required Codex source at ../codex/codex-rs/cli/src/main.rs:220-245 and ../codex/codex-rs/cli/src/main.rs:2840-2870. Those sections cover unrelated CLI subcommand, prompt normalization, completion generation, and test-import behavior; this refactor does not affect Codex protocol or runtime contracts.

@vincentkoc vincentkoc self-assigned this Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 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 agents Agent runtime and tooling size: XS maintainer Maintainer-authored PR labels Sep 2, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 3, 2026, 2:12 AM ET / 06:12 UTC.

ClawSweeper review

What this changes

The PR deletes a duplicate manual cooldown-reset helper and uses the shared auth-profile failure-state reset routine instead.

Merge readiness

⛔ Blocked before merge - 2 items remain

The introduced call is source-equivalent to the removed helper and correctly consolidates reset behavior, but this auth-profile path has an explicit security code-owner requirement; keep the PR open for that owner review.

Priority: P3
Reviewed head: bd9181158da3a9d775a5f235f155b74e70299f71
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A clean, source-equivalent consolidation backed by existing boundary coverage; required code-owner review is the remaining merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored PR is a bounded behavior-neutral refactor; source comparison and existing auth-profile boundary coverage are the applicable evidence, not a separate contributor real-flow proof gate.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR is a bounded behavior-neutral refactor; source comparison and existing auth-profile boundary coverage are the applicable evidence, not a separate contributor real-flow proof gate.
Evidence reviewed 6 items Introduced refactor: The pinned PR delta replaces the local reset call with resetAuthProfileFailureState(existing ?? {}) and deletes the duplicate implementation.
Canonical behavior equivalence: The shared helper resets the same failure fields in the same order while spreading existing usage history and optional overrides afterward; the guarded caller has an existing entry, so the empty-object fallback preserves the prior undefined-input behavior.
Existing boundary coverage: Existing tests cover clearing all failure fields, preserving usage timestamps, unknown-profile no-op behavior, and inherited-owner persistence; the PR does not alter those test files.
Findings None None.
Security None None.

How this fits together

Auth-profile usage state records cooldown and failure data in the profile store. Manual cooldown clearing resets that state, which subsequent provider and model selection reads.

flowchart LR
A[Manual cooldown clear] --> B[Locked auth-profile update]
B --> C[Shared failure-state reset]
C --> D[Persisted usage state]
D --> E[Provider and model selection]
Loading

Decision needed

Question Recommendation
Does a listed @openclaw/openclaw-secops code owner approve this behavior-preserving change to auth-profile failure-state handling? Approve after code-owner review: A listed security owner confirms the shared helper preserves manual cooldown-clearing semantics, then ordinary exact-head merge gates may decide landing.

Why: Repository policy requires listed-owner involvement for paths with explicit restricted/security ownership, even though the source change is behavior-neutral.

Before merge

  • Complete next step (P2) - Obtain review from a listed @openclaw/openclaw-secops code owner before merge.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source -20. Total -20 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 4 24 -20
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 1 4 24 -20

Review metrics

Metric Value Why it matters
Production versus test LOC production -20, tests 0 The branch removes a duplicate production implementation and adds no new test surface.

Technical review

Best possible solution:

Retain one canonical failure-state reset implementation and merge after the listed security code owner confirms the behavior-preserving refactor.

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

Not applicable: this PR is a behavior-preserving refactor, and direct source comparison establishes the relevant equivalence without a user-facing failure scenario.

Is this the best way to solve the issue?

Yes. Reusing the existing owner for failure-state reset removes duplicate policy while preserving the manual clear operation’s guarded locked-update behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a small behavior-preserving internal cleanup rather than a user-visible defect or feature.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is a bounded behavior-neutral refactor; source comparison and existing auth-profile boundary coverage are the applicable evidence, not a separate contributor real-flow proof gate.

Evidence

What I checked:

  • Introduced refactor: The pinned PR delta replaces the local reset call with resetAuthProfileFailureState(existing ?? {}) and deletes the duplicate implementation. (src/agents/auth-profiles/usage.ts:1286, bd9181158da3)
  • Canonical behavior equivalence: The shared helper resets the same failure fields in the same order while spreading existing usage history and optional overrides afterward; the guarded caller has an existing entry, so the empty-object fallback preserves the prior undefined-input behavior. (src/agents/auth-profiles/usage-state.ts:11, bd9181158da3)
  • Existing boundary coverage: Existing tests cover clearing all failure fields, preserving usage timestamps, unknown-profile no-op behavior, and inherited-owner persistence; the PR does not alter those test files. (src/agents/auth-profiles/usage.test.ts:814, bd9181158da3)
  • Current-main comparison: Current main still has the duplicate local helper and invokes it from manual cooldown clearing, so this PR is neither redundant nor implemented on main. (src/agents/auth-profiles/usage.ts:844, 2dfb4417c2a8)
  • Required code-owner routing: The affected auth-profile directory is explicitly routed to the security owners, and repository policy requires listed-owner involvement for restricted/security ownership paths. (.github/CODEOWNERS:45, bd9181158da3)
  • Direct Codex gate check: Direct inspection of the sibling Codex checkout found CLI completion, prompt-normalization, and test-import code only; this PR neither imports nor changes a Codex protocol or runtime contract, so no dependency-specific review gate applies. (codex-rs/cli/src/main.rs:220, 5adb68a49933ae446bf11935662c83dba55a0804)

Likely related people:

  • openclaw/openclaw-secops: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • jesse-merhi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Obtain review from a listed @openclaw/openclaw-secops code owner.

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 (2 earlier review cycles)
  • reviewed 2026-09-02T00:16:31.256Z sha 7f45f71 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-03T05:05:16.575Z sha bd91811 :: blocked before merge. :: none

@vincentkoc

Copy link
Copy Markdown
Member Author

@openclaw/openclaw-secops please provide a non-author approval for exact head bd9181158da3a9d775a5f235f155b74e70299f71.

Exact-head openclaw/ci-gate is green, and ClawSweeper reviewed this head with no code or security findings. I am a secops member but authored this PR, so my membership cannot satisfy the required independent owner review.

@vincentkoc

Copy link
Copy Markdown
Member Author

Closing as superseded by #140049, landed in signed squash commit 873f424.

The replacement contains this PR’s complete intended change: manual cooldown clearing now uses resetAuthProfileFailureState, while preserving locked owner-store updates and missing-record behavior. It also removes the unused inline-key reader and stale comments.

Current main contains that implementation and descends from the landed commit. The prior secops request was a gate for merging this PR; it is moot for a superseded closure and is not being treated as approval.

@vincentkoc vincentkoc closed this Sep 7, 2026
@RomneyDa
RomneyDa deleted the refactor/auth-profile-failure-reset branch October 22, 2026 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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