Repository navigation
perf(auth): reuse ordered provider alias entries - #138805
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 4, 2026, 11:03 PM ET / September 5, 2026, 03:03 UTC. ClawSweeper reviewWhat this changesReuses prepared provider aliases during authentication lookup, preserving lookup order and adding coverage for result ownership. Merge readiness✅ Ready for maintainer review Keep open: this optimization remains absent from current main, and the reviewed patch has no blocking correctness or security findings. Priority: P3 Review scores
Verification
How this fits togetherProvider authentication lookup combines plugin metadata with current trust settings to identify credential environment variables, local credential evidence, and setup fallbacks. Agent authentication and provider discovery consume these results. flowchart TD
A[Plugin metadata] --> C[Select eligible aliases]
B[Current trust settings] --> C
C --> D[Prepare alias entries once]
D --> E[Sorted environment and evidence lookup]
D --> F[Insertion ordered fallback expansion]
E --> G[Agent authentication and discovery]
F --> G
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -6, Tests +41. Total +35 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep alias preparation within each lookup operation, sharing ordered entries while preserving current trust evaluation and result ownership. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a behavior-preserving optimization, and current-main source directly confirms the repeated preparation it removes. Is this the best way to solve the issue? Yes: operation-local reuse addresses the duplication at its owner; process caching would add invalidation concerns, and sorting fallback expansion would alter existing behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 790fbf0304a6. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
The shared alias-entry preparation is ready for the native landing checks at The same four whole files passed 53/53 before and after: All 29 normal changed-file stages passed. The separate managed Codex review completed two clean partitions with scoped confidence 0.94. Exact-head CI is successful, and the current complete check rollup has no pending or failed checks. Native review artifacts have validated. I accept this smaller canonical flow with the disclosed component-level tradeoff: ordinary and larger-inventory medians improve in both orders, while the complete report retains all 286 adverse comparisons, unequal host spacing and mixed memory/tail results. There is no aggregate numeric pass or Gateway/memory-reduction claim. The prototype-key follow-up is unexecuted and outside this unchanged property-access behavior. The completed ClawSweeper review covers this exact head and has no correctness/security findings, before-merge items or Rank-up moves. I read the complete review. Native preparation completed successfully with the unchanged head and hosted CI/Testbox gates. |
|
Merged via squash.
|
* refs/remotes/origin/main: (602 commits) fix(plugins): trace trust refusals and repair legacy provenance (openclaw#138746) perf(sqlite): reuse compiled plugin state point reads (openclaw#138758) refactor: type chat prefetch dependencies and clean loading tests (openclaw#138793) ci: reduce Doctor test startup and core lint jobs (openclaw#138796) feat(update): retain run history and share outcome reports (openclaw#138690) chore(deps): update @openclaw/fs-safe to 0.8.1 (openclaw#138500) fix: preserve global board ownership from pinning to notifications (openclaw#138675) fix(gateway): deliver session catalog updates from slow hosts (openclaw#138674) perf(sessions): index pending conversation replies (openclaw#127182) perf(auth): reuse ordered provider alias entries (openclaw#138805) docs(diagnostics): clarify whole-process CPU metrics (openclaw#138804) perf(memory): narrow source reads and stream embedding cache rows (openclaw#138766) fix: allow older source on newer Testbox checkouts (openclaw#138782) fix(agents): preserve recovered task progress and lifecycle ownership (openclaw#138785) perf(codex): reduce rollout tail scan CPU (openclaw#138784) perf(gateway): stop projecting history deltas at the byte budget (openclaw#138655) fix(build): bound native declaration inputs to checkout (openclaw#138742) fix(cli): preserve foreground Gateway argument handling (openclaw#138765) fix(ui): align task toolbar with side-panel tabs (openclaw#138769) fix(logbook): drain accepted work before closing SQLite (openclaw#138754) ... # Conflicts: # src/agents/embedded-agent-runner/compact.queued.ts
What Problem This Solves
Provider auth lookup materializes and locale-sorts the same freshly selected alias map separately for env candidates and auth evidence, then enumerates it again for fallback references. This PR prepares the insertion-ordered entries once and derives one sorted array for the two sorted consumers. Fallback references keep their original insertion-order pass, which matters for one-pass alias-chain expansion.
Why This Change Was Made
The owning flow remains
resolveProviderAuthLookupMapsinsrc/secrets/provider-env-vars.ts. The env-only public export still computes only env candidates; its single-use wrapper is folded into that caller.User Impact
No process cache, config/schema option, trust/enablement change or credential-resolution fallback is introduced. Core env arrays keep their shared identity and override precedence; evidence elements keep their canonical references; non-core result containers stay fresh. Production changes are +18/−24, net −6 lines; one preservation test adds 41 lines.
Evidence
Validation
The same four complete files passed before and after: 53/53 cases each, with identical per-file case order and outcomes. The new alias-chain case passes on the original owner too; it protects existing propagation order, fresh containers, evidence identity and shared core arrays rather than claiming a bug reproduction. The files are
provider-env-vars.test.ts,provider-env-vars.dynamic.test.ts,provider-auth-aliases.test.tsandmodel-auth-env.provider-aliases.test.ts.The normal changed-file gate passed all 29 stages. One managed Codex P0–P2 review completed two partitioned passes with no findings, aggregate scoped-clean confidence 0.94; the per-pass scope limits remain retained. Normal shard/Vite warnings were preserved. No product/test retry was used to obtain these results.
Measurement and tradeoffs
A fixed macOS/Node 26.8.1 cohort measured the complete synchronous public exports with canonically prepared metadata: B0/C0/C1/B1, 5,620 calls, 1,536 batch means, plus 26 separate correctness calls. Every full output, ordered key set and recorded ownership fact passed readback. The reducer retains 934 comparisons and all 286 adverse values. No numerical threshold or aggregate numeric pass was defined.
Median latency in microseconds (negative change means lower latency):
The means and tails are mixed. Ordinary full-lookup mean is +10.44% forward and −17.31% reverse; the forward candidate retains a 1.188 ms individual sample and 617.063 µs maximum batch mean. Mixed-control mean is −15.05% forward but +19.04% reverse, with a retained 799.625 µs sample. Policy mean is −25.07% / +1.14%, and reverse policy p95 is +7.00%. Empty-control p95 increases 17.60% / 13.99%. Larger-inventory means improve 18.81% / 0.36%, but its reverse candidate still has an 852.667 µs maximum sample. These values are retained without a causal explanation or dismissal as noise.
First calls are also mixed: the env-only sibling increases 42.79% / 10.44%, empty lookup 1.43% / 2.14%, forward policy 2.35%, reverse mixed lookup 5.14%, and reverse larger lookup 0.16%. Sampled process-tree peak RSS changes −1.40% / +2.94%; kernel child maximum RSS changes +0.79% / +4.15%. This is not evidence of a memory reduction. Native wall decreases 6.16% / 4.98%, while forward user/system CPU increases 0.95% / 5.54%; these include setup/import/encoding and are separate from target latency.
Hosts ran in the fixed order but were not equally spaced: the first inter-host gap was 45.987 s, then 175/179 ms. Samples within each process are correlated, and “first” does not guarantee cold state. Metadata preparation is outside the target clock but inside the bounded native host. This measures lookup preparation from an available snapshot, not disk discovery, credential lookup, provider requests or Gateway latency. No Gateway speedup is claimed. Earlier R2/R3 harness setup failures occurred before target calls and remain retained; the fixed R4 numerical cohort was not rerun or tuned.
The engineering case is a smaller canonical preparation flow with both ordinary and larger-inventory medians lower in both orders. The adverse mean/tail, first-call and RSS results remain part of the decision; they do not support a universal performance claim.
Named follow-up
The prototype-key accumulation boundary remains separate. Source inspection found a possible mismatch between accepted manifest target strings and ordinary-object env/evidence buckets. It has not been runtime-reproduced or established as a credential-disclosure/prototype-pollution exploit. This PR preserves the existing property access and error behavior; a normal-manifest reproduction must precede any dictionary or validation-policy repair.