perf(secrets): propagate snapshots and eliminate esm side-effects in auth env vars#86439
Conversation
|
Codex review: needs maintainer review before merge. Reviewed May 27, 2026, 3:17 AM ET / 07:17 UTC. Summary PR surface: Source +61, Tests +230. Total +291 across 26 files. Reproducibility: not applicable. as a user bug reproduction: this is an internal performance/auth hot-path cleanup. The PR body supplies a Windows Node 22.19 micro-benchmark plus focused auth/provider tests for the changed lookup path. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Land this after an auth/provider reviewer confirms the snapshot-context boundaries and the exact-head build check completes cleanly or is explicitly explained. Do we have a high-confidence way to reproduce the issue? Not applicable as a user bug reproduction: this is an internal performance/auth hot-path cleanup. The PR body supplies a Windows Node 22.19 micro-benchmark plus focused auth/provider tests for the changed lookup path. Is this the best way to solve the issue? Mostly yes: the combined lookup-map resolver is the narrow maintainable direction for removing duplicate metadata snapshot loads. It still needs auth/provider maintainer review because credential discovery context separation is compatibility-sensitive. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against f327df866cb0. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +61, Tests +230. Total +291 across 26 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
There was a problem hiding this comment.
Pull request overview
This PR removes an import-time ESM side effect in model-auth env var helpers and improves performance of provider auth env-var/evidence resolution by reusing already-loaded plugin metadata snapshots (avoiding redundant snapshot loads and config-fingerprint cache bypass).
Changes:
- Propagate
metadataSnapshotintoresolveProviderAuthAliasMap()when resolving provider env-var candidates/evidence to prevent duplicate snapshot loads. - Avoid collapsing
params.configto{}in snapshot/alias resolution hot paths (while still passing{}only at the finalloadPluginMetadataSnapshot()fallback boundary). - Remove
PROVIDER_ENV_API_KEY_CANDIDATESexport to eliminate top-level ESM execution, and update related tests/mocks.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/secrets/provider-env-vars.ts | Reuses a single metadata snapshot across env-var candidate/evidence + alias resolution; avoids eager {} config fallback except for load fallback. |
| src/secrets/provider-env-vars.dynamic.test.ts | Adds regression test asserting only one metadata snapshot load occurs during env-var candidate + alias resolution. |
| src/agents/provider-auth-aliases.ts | Avoids {} config fallback and passes {} only when actually loading a snapshot; supports snapshot reuse via metadataSnapshot. |
| src/agents/model-auth-env-vars.ts | Removes top-level PROVIDER_ENV_API_KEY_CANDIDATES export to eliminate ESM import side effects. |
| src/agents/models-config.uses-first-github-copilot-profile-env-tokens.test.ts | Updates mocks to reflect removed PROVIDER_ENV_API_KEY_CANDIDATES export. |
| src/agents/models-config.runtime-source-snapshot.test.ts | Updates mocks to reflect removed PROVIDER_ENV_API_KEY_CANDIDATES export. |
| src/agents/models-config.providers.nvidia.test.ts | Updates mocks to reflect removed PROVIDER_ENV_API_KEY_CANDIDATES export. |
| src/agents/models-config.providers.moonshot.test.ts | Updates mocks to reflect removed PROVIDER_ENV_API_KEY_CANDIDATES export. |
| src/agents/model-auth.profiles.test.ts | Updates mocks to reflect removed PROVIDER_ENV_API_KEY_CANDIDATES export. |
|
ClawSweeper PR egg ✨ Hatched: 🥚 common Velvet Review Wisp Hatch commandComment Hatchability rules:
Rarity: 🥚 common. What is this egg doing here?
|
27af451 to
2419cd6
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
2419cd6 to
617651f
Compare
617651f to
569f658
Compare
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
395f04f to
640a111
Compare
640a111 to
a4edf29
Compare
|
Behavior addressed: provider auth env lookup now resolves alias, env candidate, and auth evidence maps from one plugin metadata snapshot and reuses those maps in auth/model-list/pi callers while preserving core/env/evidence lookup semantics. Real environment tested: local macOS checkout plus Blacksmith Testbox and GitHub CI. Exact steps or command run after this patch:
Evidence after fix: focused tests passed 21 files / 322 tests; lint and diff check passed; autoreview had no accepted/actionable findings; Testbox Observed result after fix: lookup maps reuse one metadata snapshot, full mocks include the new export, the previous missing mock CI failure is gone, and the merge-ref lint issue from stale base is gone after rebasing onto current What was not tested: live provider credentials or live model calls. |
…auth env vars (openclaw#86439) * perf(secrets): propagate snapshots and eliminate esm side-effects in auth env vars * perf(secrets): reuse provider auth lookup maps * test(auth): update provider env var mocks * test(auth): cover rebased provider env mocks --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
…026.5.27) (#698) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [ghcr.io/openclaw/openclaw](https://openclaw.ai) ([source](https://github.com/openclaw/openclaw)) | patch | `2026.5.26` → `2026.5.27` | --- ### Release Notes <details> <summary>openclaw/openclaw (ghcr.io/openclaw/openclaw)</summary> ### [`v2026.5.27`](https://github.com/openclaw/openclaw/blob/HEAD/CHANGELOG.md#2026527) [Compare Source](openclaw/openclaw@v2026.5.26...v2026.5.27) ##### Highlights - Safer local/runtime boundaries: OpenClaw now rejects unsafe command wrappers, malformed CLI numeric options, unsafe Node runtime env overrides, no-auth Tailscale exposure, and non-admin device-role pairing approvals before they can affect live runs. ([#​87308](openclaw/openclaw#87308), [#​87305](openclaw/openclaw#87305), [#​87292](openclaw/openclaw#87292), [#​87146](openclaw/openclaw#87146)) - Matrix and auto-reply delivery are steadier: mention previews stay inert, final mention replies deliver normally, shared-DM notices are awaited, MXID parsing ignores filenames, and reasoning-prefixed `NO_REPLY` responses stay suppressed. - Provider and agent reliability improved across OpenAI-compatible embeddings, cached token usage, Anthropic/Codex/Claude runtime state, unsupported tool-schema quarantine, heartbeat templates, and session fallback errors. ([#​85269](openclaw/openclaw#85269), [#​82062](openclaw/openclaw#82062), [#​85416](openclaw/openclaw#85416), [#​86855](openclaw/openclaw#86855)) - Plugin and package release paths got tighter: Pixverse ships as an external video plugin with region selection, package exclusions and shrinkwrap inventory match the published npm shape, and release/package smoke commands fail bounded instead of hanging. - Gateway hot paths do less rediscovery by reusing current plugin metadata fingerprints, stable plugin index fingerprints, read-only session metadata, active working stores, status fast paths, and auth/env snapshots. ([#​86439](openclaw/openclaw#86439)) ##### Changes - Memory: add a core OpenAI-compatible embedding provider for local and hosted OpenAI-style endpoints, with config, doctor, and docs support. ([#​85269](openclaw/openclaw#85269)) Thanks [@​dutifulbob](https://github.com/dutifulbob). - Plugin SDK: mark memory-specific embedding provider registration as deprecated compatibility and surface non-bundled usage in plugin compatibility diagnostics. ([#​85072](openclaw/openclaw#85072)) Thanks [@​mbelinky](https://github.com/mbelinky). - Pixverse: add video generation provider support, API region selection, and external plugin publishing. - Plugins: expose approval action metadata for plugin-driven approval surfaces. ##### Fixes - Security/CLI/runtime: harden hostname normalization for repeated trailing dots, block side-effecting command wrappers, reject unsafe Node runtime env overrides, reject loose numeric CLI and gateway options, require admin approval for node device-role pairing, and reject no-auth Tailscale exposure. ([#​87305](openclaw/openclaw#87305), [#​87292](openclaw/openclaw#87292), [#​87308](openclaw/openclaw#87308), [#​87146](openclaw/openclaw#87146)) Thanks [@​pgondhi987](https://github.com/pgondhi987). - Doctor: validate runtime tool schemas for every configured embedded agent while skipping ACP-only profiles, so bad non-default plugin or MCP tools are reported before assistant turns. - Telegram: route `sendMessage` action replies through durable outbound delivery so completed agent responses remain retryable when the gateway send path times out. ([#​87261](openclaw/openclaw#87261)) Thanks [@​mbelinky](https://github.com/mbelinky). - Matrix/auto-reply: keep draft previews mention-inert, preserve final mention delivery, send mention finals normally, await shared DM notices, ignore filename-embedded MXIDs, and suppress reasoning-prefixed `NO_REPLY` responses. - Agents/providers: add OpenAI-compatible cache retention, forward cached token usage in chat completions, preserve runtime context before active user turns, strip stale Anthropic thinking, load Claude CLI OAuth for Pi auth profiles, avoid false Codex runtime live switches, and quarantine unsupported tool schemas. ([#​82062](openclaw/openclaw#82062), [#​87167](openclaw/openclaw#87167), [#​86855](openclaw/openclaw#86855)) - Gateway/performance: cache plugin metadata fingerprints and stable plugin index fingerprints, borrow read-only session metadata safely, keep the active session working store hot, keep status on a bounded fast path, and preserve model auth profile suffixes. ([#​86439](openclaw/openclaw#86439)) - Package/install/release: align npm package exclusions and inventory, omit unpacked test helpers, skip Homebrew until macOS packages need it, cap tsdown heap in containers, bound install/release smoke waits, and harden post-publish verification. - Codex/Auth: bound ChatGPT OAuth token exchange and refresh requests, and honor cancellation across Codex and Anthropic OAuth login flows. - QA/E2E/CI: bound Telegram, kitchen-sink, Open WebUI, ClawHub, MCP, Discord, realtime, labeler, and GitHub API waits; fail empty explicit test, live-media, gateway CPU, startup benchmark, plugin gauntlet, and beta-smoke runs instead of false-greening. - Agents/Codex: keep spawned agent bootstrap files rooted in the agent workspace while running task commands, transcripts, and compaction from the requested cwd. ([#​87218](openclaw/openclaw#87218)) Thanks [@​mbelinky](https://github.com/mbelinky). </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMDEuMSIsInVwZGF0ZWRJblZlciI6IjQzLjEwMS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL3BhdGNoIl19--> Reviewed-on: https://git.erwanleboucher.dev/eleboucher/homelab/pulls/698
…auth env vars (openclaw#86439) * perf(secrets): propagate snapshots and eliminate esm side-effects in auth env vars * perf(secrets): reuse provider auth lookup maps * test(auth): update provider env var mocks * test(auth): cover rebased provider env mocks --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
…auth env vars (openclaw#86439) * perf(secrets): propagate snapshots and eliminate esm side-effects in auth env vars * perf(secrets): reuse provider auth lookup maps * test(auth): update provider env var mocks * test(auth): cover rebased provider env mocks --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
Summary
What problem does this PR solve?
model-auth-env-vars.tswhich executed a full candidate resolution on import.configto{}on default fallback) which caused cache fingerprint mismatches and cache bypass.Why does this matter now?
What is the intended outcome?
What is intentionally out of scope?
What does success look like?
What should reviewers focus on?
Verification of snapshot passing into
resolveProviderAuthAliasMapinsidesrc/secrets/provider-env-vars.ts.Absence of
PROVIDER_ENV_API_KEY_CANDIDATESin non-test production code.Mark as AI-assisted in the PR description
Linked context
Which issue does this close?
Closes #
Which issues, PRs, or discussions are related?
Related #
Was this requested by a maintainer or owner?
Yes, requested as part of the performance part 2 proposal.
Real behavior proof (required for external PRs)
Evidence after fix (screenshot, recording, terminal capture, console output, redacted runtime log, linked artifact, or copied live output): We ran a performance micro-benchmark measuring snapshot resolution times before and after this patch using an active dummy snapshot to evaluate in-memory propagation.
Observed result after fix:
provider-env-vars.dynamic.test.tsare green.What was not tested: Integration of actual cloud providers on a live staging server (which is out of scope for pure static metadata snapshot propagation checks).
Proof limitations or environment constraints: Tested locally on Windows host.
Tests and validation
Which commands did you run?
pnpm exec vitest run --config test/vitest/vitest.secrets.config.ts src/secrets/provider-env-vars.dynamic.test.tspnpm exec vitest run --config test/vitest/vitest.agents.config.ts src/agents/model-auth.profiles.test.tspnpm check:test-typesWhat regression coverage was added or updated?
only loads plugin metadata snapshot once when resolving env var candidates, avoiding duplicate snapshot loadsinprovider-env-vars.dynamic.test.ts.does not reuse a load-path current snapshot for default provider env lookups without parametersinprovider-env-vars.dynamic.test.tsto enforce default snapshot isolation and prevent fingerprint mismatches.What failed before this fix, if known?
model-auth-env-varsmodule always triggered an early disk scan.Risk checklist
Did user-visible behavior change? (
No)Did config, environment, or migration behavior change? (
No)Did security, auth, secrets, network, or tool execution behavior change? (
Yes)What is the highest-risk area?
How is that risk mitigated?
tsgocompiler across all core and extension packages, and fully covered by extensive existing auth unit tests.Current review state
What is the next action?
What is still waiting on author, maintainer, CI, or external proof?
Which bot or reviewer comments were addressed?