Skip to content

fix(tests): cut Foundry cache eviction test runtime - #154223

Merged
steipete merged 1 commit into
mainfrom
upd/slow-foundry-eviction
Sep 21, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/slow-foundry-eviction

Conversation

@steipete

@steipete steipete commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Related: #127216

What Problem This Solves

Foundry token-cache eviction coverage took over a minute in the provider test shard because one test booted a cold source runtime and launched 130 synthetic Azure CLI subprocesses.

User Impact

No user-visible behavior changes. Provider tests retain cache-eviction coverage with substantially less test execution time. Production code is unchanged.

Why This Change Was Made

The registered provider already has fast tests for LRU recency, expired-token reclamation, and in-flight refresh ownership. The boundary test now seeds cache pressure through the existing mocked CLI boundary, then uses one real subprocess running a synthetic az executable to refresh the evicted tenant. It verifies the tenant-bound bearer token, CLI arguments, and subsequent cache reuse. Source modules load once in the file's shared runtime instead of in a second cold child.

Production LOC: 0. Test LOC: +87 / -140 (net -53). No new production seam, dependency, configuration, timeout increase, or skipped test.

Evidence

Standalone command before and after: node scripts/run-vitest.mjs extensions/microsoft-foundry/index.test.ts --maxWorkers=1.

Measurement Before After
Eviction boundary test 65.061 s 0.232 s
Total execution time for all 97 tests 71.564 s 5.922 s
Complete command wall time 293.80 s 188.26 s

All 97 tests passed in both runs. The baseline's instrumented account loop took 17.432 s; the remaining 47.629 s included cold-child startup/source imports and surrounding overhead. The loop combined profile writes and 130 subprocess refreshes; those costs were not independently timed. Shared transform/compiler preparation dominates the remaining command wall time on the loaded host.

P1 autoreview: scoped-clean, no accepted/actionable findings. Formatting and git diff --check passed.

node scripts/check-changed.mjs passed every selected step except the extension-lint bootstrap, which hit the documented nested-checkout host error: Declaration input escapes checkout through ancestor node_modules/@types/events. Extension-test typechecking and all three unused-export scans passed. The local dependency installation was preserved.

The approved lint substitute was run against the changed file:

node_modules/.bin/oxlint --tsconfig test/tsconfig/tsconfig.extensions.test.json extensions/microsoft-foundry/index.test.ts

A temporary debugger; canary proved that the command inspected the file and enforced lint rules. It was then removed, and the reviewed file's SHA-256 was restored exactly:

CANARY exit=1
extensions/microsoft-foundry/index.test.ts:2379:1: error eslint(no-debugger): `debugger` statement is not allowed help: Remove the debugger statement

CLEAN exit=0
(no diagnostics)

Hosted extension lint remains the authority for the complete declaration-boundary preparation.

A fresh Linux Testbox authenticated and synchronized successfully, then passed all 97 tests: 640 ms total test time, 29.5 ms for the eviction test, and 18.63 s command wall time. The first lease had failed SSH authentication before executing tests.

A temporary negative control removed capacity pruning and made the new test fail at its bearer-token assertion, confirming that it still catches unbounded cache retention. The runtime was restored byte-for-byte. The diagnostic wrapper then failed because it searched JSON failure messages for literal token values; Vitest emits a summarized stack and redacts token values in its formatted diff. Local inspection confirmed the expected assertion failure (150 ms test time). This diagnostic error stopped the one-shot remote command before the 73-file replay and remote changed checks. Those broader results are not claimed here; hosted CI supplies the remaining shard evidence.

Maintainer review disposition

ClawSweeper reviewed head 9a9360eca5faba319bf54f5c6dfd4c086bae6091 at 2026-09-21 01:00 UTC and reported no findings, no security concerns, and no before-merge actions. The latest review contains no Rank-up moves or additional proof requests, so none were skipped. The campaign review of record is scoped-clean; no semantic changes were made during landing.

@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 21, 2026 00:54
@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 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 20, 2026, 9:41 PM ET / September 21, 2026, 01:41 UTC (Revision 2).

ClawSweeper review

What this changes

The PR speeds up Foundry token-cache eviction coverage by replacing repeated CLI launches with mocked cache seeding while retaining one real subprocess refresh.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused test-performance improvement absent from current main. No actionable correctness or security findings remain, consistent with the previous review.

Priority: P3
Reviewed head: 9a9360eca5faba319bf54f5c6dfd4c086bae6091

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-supported test optimization with preserved regression assertions and no identified blocker.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored test optimization is exempt from external-contributor runtime proof; recorded suite timings and the pruning negative control directly validate its purpose without claiming live Azure coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored test optimization is exempt from external-contributor runtime proof; recorded suite timings and the pruning negative control directly validate its purpose without claiming live Azure coverage.
Evidence reviewed 7 items Introduced change: The pinned introduction delta changes only the existing test: it seeds 129 account tuples through the provider, refreshes the evicted first tuple through the real process runner, and asserts tenant-bound bearer output, CLI arguments, and cache reuse.
Remaining regression coverage: Separate tests retain LRU recency, expiry-first reclamation, active-refresh ownership, failed-refresh cleanup, and scope separation. The production owner still caps settled tokens at 128 and keeps refresh promises separately owned.
Current main still needs the optimization: The Foundry subtree is unchanged between the pinned merge base and fetched main, so main retains the original expensive test. The merged retention repair at #127216 supplies background, not a replacement for this optimization.
Findings None None.
Security None None.

How this fits together

Microsoft Foundry authentication turns a selected account profile into a cached bearer token, refreshing through Azure CLI when necessary. This change reduces the cost of testing that eviction and refresh path.

flowchart LR
  A[Synthetic account profiles] --> B[Registered Foundry provider]
  B --> C{Token cached?}
  C -->|Yes| F[Prepared bearer token]
  C -->|Evicted| D[Azure CLI adapter]
  D --> E[Synthetic CLI subprocess]
  E --> F
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests -53. Total -53 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 87 140 -53
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 87 140 -53

Review metrics

Metric Value Why it matters
Eviction-test execution time 65.061 s → 0.232 s, as reported The recorded comparison demonstrates substantial savings while the negative control checks that capacity regression detection survives.

Technical review

Best possible solution:

Keep eviction semantics covered at the registered provider boundary while reserving real subprocess work for the refresh contract.

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

Not applicable to a product defect; the test-cost problem has recorded before/after measurements, and source confirms the repeated subprocess work being removed.

Is this the best way to solve the issue?

Yes. The change reuses existing fixtures, preserves focused cache invariants and one real CLI refresh, and adds no production seam.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 20eebbd5c7bf.

Labels

Label justifications:

  • P3: This improves test execution cost without changing production behavior.
  • 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: The maintainer-authored test optimization is exempt from external-contributor runtime proof; recorded suite timings and the pruning negative control directly validate its purpose without claiming live Azure coverage.

Evidence

What I checked:

  • Introduced change: The pinned introduction delta changes only the existing test: it seeds 129 account tuples through the provider, refreshes the evicted first tuple through the real process runner, and asserts tenant-bound bearer output, CLI arguments, and cache reuse. (extensions/microsoft-foundry/index.test.ts:765, 9a9360eca5fa)
  • Remaining regression coverage: Separate tests retain LRU recency, expiry-first reclamation, active-refresh ownership, failed-refresh cleanup, and scope separation. The production owner still caps settled tokens at 128 and keeps refresh promises separately owned. (extensions/microsoft-foundry/runtime.ts:28, 9a9360eca5fa)
  • Current main still needs the optimization: The Foundry subtree is unchanged between the pinned merge base and fetched main, so main retains the original expensive test. The merged retention repair at fix(microsoft-foundry): bound Entra token retention across accounts #127216 supplies background, not a replacement for this optimization. (extensions/microsoft-foundry/index.test.ts, 20eebbd5c7bf)
  • Latest release comparison: The supplied latest release, v2026.9.5, also contains the original real-provider boundary test with its 180-second timeout. (extensions/microsoft-foundry/index.test.ts:760, ec9c1a13db89)
  • Recorded performance and negative control: The complete supplied PR body reports all 97 tests passing before and after, eviction-test time falling from 65.061 s to 0.232 s, and a fresh Linux Testbox pass. It also reports that removing capacity pruning makes the replacement assertion fail. The broader remote replay was explicitly not completed. These are contributor-recorded results; this review did not execute tests. (9a9360eca5fa)
  • Process isolation: The retained subprocess uses synthetic credentials, an explicit temporary working directory and environment, and the existing cancellation signal. The process owner disables inherited environment extension and preserves its normal command safety boundary; no production authority, dependency, or permission changes are introduced. (src/process/exec-spawn.ts:317, 9a9360eca5fa)

Likely related people:

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

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 (1 earlier review cycle)
  • reviewed 2026-09-21T01:00:34.198Z sha 9a9360e :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 37833f6 into main Sep 21, 2026
167 checks passed
@steipete
steipete deleted the upd/slow-foundry-eviction branch September 21, 2026 01:58
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 21, 2026
…f 130 CLI spawns (openclaw#154223)

The Foundry cache-eviction boundary test spent over a minute booting a cold source runtime and launching 130 synthetic Azure CLI subprocesses. Seed cache pressure through the existing mocked CLI boundary, load the shared runtime once, and keep one real subprocess refresh for the evicted tenant.

Preserve assertions for the tenant-bound bearer token, Azure CLI arguments, and subsequent cache reuse. Existing provider tests continue to cover LRU recency, expired-token reclamation, and in-flight refresh ownership. Production code and user-visible behavior are unchanged; the test diff is +87/-140 lines.

Recorded proof: all 97 tests passed before and after; eviction-test execution fell from 65.061 s to 0.232 s. Linux Testbox proof passed all 97 tests in 640 ms of test execution, with an 18.63 s command wall time. Disabling capacity pruning made the replacement fail its bearer-token assertion. Exact-head CI passed, and the scoped review plus ClawSweeper review found no actionable defects.

Related: openclaw#127216
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: microsoft-foundry 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: 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