Skip to content

refactor(agents): compress auth availability projections - #131863

Merged
steipete merged 1 commit into
mainfrom
claude/availability-reason-compression
Aug 28, 2026
Merged

steipete merged 1 commit into
mainfrom
claude/availability-reason-compression

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Follow-up compression of the availability-reason feature landed in #131697. That change added +275/−124 production lines; two of its projection sites carried provable redundancy: the non-profile sourceEvaluation branch re-derived availability/mode/evidence facts that the direct policy evaluation already owned (via a lossless readiness round-trip), and the indeterminate-route caller re-projected automaticSourceRejection's result field by field after the helper had leaked the full selector decision.

Why This Change Was Made

Behavior-frozen refactor: reuse the recorded direct-policy facts instead of re-deriving them, and let automaticSourceRejection return the projected AuthSourceEvaluation itself so its only caller just attaches route resolution. No selector inputs change; the deliberately load-bearing seams (the profile recompute compensating for requiredProfileSource's cooldown-bypass contract, and the empty-plan reason override that also covers the deferred branch) are byte-identical to the base.

Two further candidate folds were evaluated and skipped with recorded reasons: a typed unusable-window result (breaks the primitive's numeric contract and ripples into status/display adapters) and the gateway projection spreads (each conditional encodes a distinct property-presence rule for legacy clients).

User Impact

None — pure production-LOC reduction. Wire payloads, field values, and property presence are unchanged.

Evidence

  • Net −12 production lines (+16/−28, single file src/agents/model-auth-availability.ts); zero test-file changes (git diff --stat -- '*test*' empty).
  • Frozen contract held: the full required suite — 261 tests across 10 files (evaluator + reasons, route selection, five models.list suites, models.test.ts, models-auth-status) — passes unmodified.
  • Equivalence proofs: producer/selector trace of the readiness round-trip (provider-model-auth-source-plan.ts:109/:115/:122), plus two ephemeral differential checks comparing old vs new projection functions over 1,680 direct/none combinations and 1,536 indeterminate-route cases with own-property presence compared via deepStrictEqual.
  • node scripts/check-changed.mjs exit 0 (formatting, lint, all type shards, dead exports, import cycles, guards); Codex autoreview clean at the default threshold.

@clawsweeper

clawsweeper Bot commented Aug 28, 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 Aug 28, 2026
@steipete
steipete marked this pull request as ready for review August 28, 2026 15:35
@steipete
steipete requested a review from a team as a code owner August 28, 2026 15:35
@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Aug 28, 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 Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 11:43 AM ET / 15:43 UTC.

ClawSweeper review

What this changes

The PR removes redundant model-auth availability projections while retaining the evaluator’s availability, reason, retry-time, selected-auth, and evidence behavior.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open. The introduced refactor is source-equivalent at both projection sites and has no concrete correctness or security finding; it remains an active maintainer PR pending its normal exact-head checks and a fresh automated review in a provisioned environment.

Priority: P3
Reviewed head: 514f92bf6a75fd341f8cc8f0088738eb19ae4197

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused net-negative refactor with source-supported equivalence and no actionable patch defect.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable: this is a maintainer-authored behavior-neutral refactor; no external-contributor proof gate applies.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable: this is a maintainer-authored behavior-neutral refactor; no external-contributor proof gate applies.
Evidence reviewed 7 items Introduced direct-source projection: The new direct-source branch preserves the evaluator result, removes only the reason for conditional re-addition, and overwrites the mode from the selected source; the prior readiness conversion is lossless for the three readiness states.
Selector contract: The shared selector produces either a selected source, an unavailable profile, none, or a rejected all-cooldown/explicit-order decision; the refactor only changes how those existing results are projected.
Indeterminate-route caller: The caller now attaches route resolution to the already-projected rejection; the previous caller exposed only the rejection’s availability fields plus selected profile/mode and profile evidence, all supplied by the new helper result.
Findings None None.
Security None None.

How this fits together

The model-auth resolver combines provider configuration, credential profiles, and route selection into an availability result. Gateway model-list generation consumes that result to expose model availability and actionable auth state to clients.

flowchart LR
  A[Provider configuration] --> C[Auth availability resolver]
  B[Credential profile state] --> C
  C --> D[Auth source selection]
  D --> E[Availability evaluation]
  E --> F[Gateway model list]
  F --> G[Model picker and composer]
Loading

Before merge

  • Resolve merge risk (P1) - The local partial clone could not materialize the fetched-main evaluator blob because its promisor remote was unreachable; the supplied verified test-merge identity limits the merge surface, but final exact-head validation should run in a fully provisioned environment.
  • Resolve merge risk (P1) - Repository-required autoreview could not start because TruffleHog is absent; rerun it before landing.
  • Complete next step (P2) - No repair lane is warranted because no specific introduced defect was found; complete ordinary exact-head validation and the blocked automated review.
Agent review details

Security

None.

PR surface

Source -12. Total -12 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 16 28 -12
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 16 28 -12

Review metrics

Metric Value Why it matters
Production versus test delta production −12, tests 0 The single production file removes duplicate projection logic without adding test-support or runtime surface.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the canonical evaluator projection, land this net-negative cleanup only after fresh automated review and exact-head checks confirm the preserved auth-availability contract.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the canonical evaluator projection, land this net-negative cleanup only after fresh automated review and exact-head checks confirm the preserved auth-availability contract.

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

Not applicable: this PR claims a behavior-preserving refactor, not a user-reported failure; the relevant projection paths are directly inspectable in source.

Is this the best way to solve the issue?

Yes. Reusing the direct policy’s recorded facts removes duplicate conversion while retaining the selector as the single owner of readiness and rejection decisions.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a small internal cleanup with no source-confirmed user-visible behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable: this is a maintainer-authored behavior-neutral refactor; no external-contributor proof gate applies.

Label justifications:

  • P3: This is a small internal cleanup with no source-confirmed user-visible behavior change.
  • 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: Not applicable: this is a maintainer-authored behavior-neutral refactor; no external-contributor proof gate applies.

Evidence

What I checked:

  • Introduced direct-source projection: The new direct-source branch preserves the evaluator result, removes only the reason for conditional re-addition, and overwrites the mode from the selected source; the prior readiness conversion is lossless for the three readiness states. (src/agents/model-auth-availability.ts:784, 514f92bf6a75)
  • Selector contract: The shared selector produces either a selected source, an unavailable profile, none, or a rejected all-cooldown/explicit-order decision; the refactor only changes how those existing results are projected. (src/agents/provider-model-route-auth.ts:147, 514f92bf6a75)
  • Indeterminate-route caller: The caller now attaches route resolution to the already-projected rejection; the previous caller exposed only the rejection’s availability fields plus selected profile/mode and profile evidence, all supplied by the new helper result. (src/agents/model-auth-availability.ts:961, 514f92bf6a75)
  • Consumer and regression coverage: Gateway model-list evaluation passes model and route facts into this resolver, while existing tests cover indeterminate-route auth-order failures and unavailable reasons/retry deadlines. (src/gateway/server-methods/models-list-result.ts:108, 514f92bf6a75)
  • Related feature provenance: The merged availability-reason feature predates this refactor and is attributable to the same area owner; the PR head is a separate one-file follow-up. (src/agents/model-auth-availability.ts:784, d6e1f019f088)
  • Current-base merge context: The supplied verified test merge has current main 9022e0e as first parent and this exact head as second parent; its only resulting changed path is the reviewed evaluator. (src/agents/model-auth-availability.ts:784, 09f076f675ca)

Likely related people:

  • steipete: Auth-availability history identifies this person as author of both the merged availability-reason feature and this follow-up refactor. (role: introduced related behavior and recent area contributor; confidence: high; commits: d6e1f019f088, 514f92bf6a75; files: src/agents/model-auth-availability.ts)

Rank-up moves

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

  • Rerun the required autoreview in an environment with TruffleHog available, then let exact-head checks complete.

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

Copy link
Copy Markdown
Contributor Author

Rank-up move status: exact-head CI is now complete and green on 514f92b. The pre-commit Codex autoreview ran through the standard credential-scanned helper (clean, no accepted/actionable findings); the TruffleHog note reflects the automated reviewer's own provisioning, not a gap in the change. Landing via the native wrapper.

@steipete
steipete merged commit 4601b0a into main Aug 28, 2026
310 checks passed
@steipete
steipete deleted the claude/availability-reason-compression branch August 28, 2026 15:54
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 29, 2026
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