Repository navigation
fix(microsoft-foundry): bound Entra token retention across accounts - #127216
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 6, 2026, 6:34 AM ET / 10:34 UTC. ClawSweeper reviewWhat this changesBounds Microsoft Foundry’s cached Entra credentials to 128 recently used account tuples, removes expired entries during refresh, and adds eviction and concurrency coverage. Merge readiness✅ Ready for maintainer review Still useful: current main and v2026.9.2 retain the unbounded cache. No blocking introduced defect found. The updated maintainer-authored description addresses the prior capacity-tradeoff question. Priority: P2 Review scores
Verification
How this fits togetherMicrosoft Foundry prepares credentials for text and image requests using the selected profile’s scope, subscription, and tenant. Its in-memory token cache avoids repeated Azure CLI calls, while a separate map coordinates concurrent refreshes. flowchart TD
A[Text or image request] --> B[Selected account tuple]
B --> C{Usable cached token?}
C -->|Yes| D[Update recency]
C -->|No| E[Join or start Azure CLI refresh]
E --> F[Remove expired tokens and enforce capacity]
D --> G[Authenticated provider request]
F --> G
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +14, Tests +265. Total +279 across 2 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep retention bounded inside the shared Foundry auth owner; the small growth supplies missing expiry and recency bookkeeping while reusing existing pruning and refresh paths. Do we have a high-confidence way to reproduce the issue? Yes: successive distinct account tuples cause unconditional retained-map insertions on current main, with no deletion or capacity limit. This review established the path from source and did not execute it. Is this the best way to solve the issue? Yes: the patch repairs the shared producer and preserves refresh ownership. Moving the policy into callers would duplicate text/image behavior, while a new cache framework would add unnecessary surface. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e74543854408. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
Preserve active refresh ownership while pruning settled credentials, and remove redundant refresh insertion bookkeeping. Extend recency, expiry, and cache-churn coverage and exercise the public provider with a persisted synthetic profile and isolated az process.
|
Merged via squash.
|
* origin/main: (47 commits) ci: record CPU time for Node test jobs (openclaw#140054) test(crabbox): consolidate wrapper boundary coverage (openclaw#140058) fix(test): keep native filesystem access checks portable (openclaw#140047) fix: preserve models when OAuth preparation fails (openclaw#139951) feat(update): recover failed updates with bounded repair (openclaw#139495) refactor(plugins): share managed npm package traversal (openclaw#140040) chore(ui): refresh control ui locales (openclaw#140059) refactor(auth): share profile failure state reset (openclaw#140049) fix(cron): surface skipped on-exit payloads when jobs are busy (openclaw#139987) fix(codex): preserve exec-server WebSocket backpressure under Bun (openclaw#140048) fix(agents): ground exec approvals in tool results (openclaw#140043) refactor(policy): reuse authored policy value helpers (openclaw#140019) docs: keep ClawSweeper status inspection read-only (openclaw#139958) fix: reduce task maintenance stalls with large histories (openclaw#140038) fix(code-mode): identify unawaited promise output (openclaw#140028) fix(test): release memory search fixtures after failed phases (openclaw#140013) test(gateway): isolate Serve hello lifecycle fixtures (openclaw#140044) fix(microsoft-foundry): bound Entra token retention across accounts (openclaw#127216) fix(process): preserve the cause of cleanup observation failures (openclaw#140015) fix: clear Side chat when its parent conversation is deleted (openclaw#139974) ...
…penclaw#127216) Bound settled Microsoft Foundry Entra credentials to 128 recently used account tuples. Remove unusable and expired entries before capacity eviction while preserving separate single-flight Azure CLI refresh ownership for text and image authentication. Verified recency, expiry-first eviction, active refresh during cache churn, failure cleanup, and the real public-provider/profile-store/az boundary. After 129 distinct tuples, the touched account stays cached and the evicted account causes refresh 130 with correct tenant binding. Exact-head CI #34027488799 passed; no genuine Azure credentials or cross-platform performance ratio claimed. Fixes openclaw#127196 Co-authored-by: Peter Steinberger <[email protected]>
…penclaw#127216) Bound settled Microsoft Foundry Entra credentials to 128 recently used account tuples. Remove unusable and expired entries before capacity eviction while preserving separate single-flight Azure CLI refresh ownership for text and image authentication. Verified recency, expiry-first eviction, active refresh during cache churn, failure cleanup, and the real public-provider/profile-store/az boundary. After 129 distinct tuples, the touched account stays cached and the evicted account causes refresh 130 with correct tenant binding. Exact-head CI #34027488799 passed; no genuine Azure credentials or cross-platform performance ratio claimed. Fixes openclaw#127196 Co-authored-by: Peter Steinberger <[email protected]> (cherry picked from commit 811eb13)
…f 130 CLI spawns (#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: #127216
…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
Closes #127196
What Problem This Solves
Long-lived Microsoft Foundry processes retain an Entra token and expiry value for every historical scope/subscription/tenant tuple. Expired entries and retired profile generations remain in the settled-token map until process exit.
Why This Change Was Made
The provider now retains at most 128 settled tuples, refreshes recency on valid hits, removes unusable exact-key entries, and reclaims expired entries before evicting live accounts. It reuses the existing insertion-order map pruning helper. Active Azure CLI refresh promises remain separately owned and single-flight; capacity eviction never removes active work.
User Impact
Repeated account/profile changes no longer grow settled credential retention without bound. Requests for an evicted tuple transparently use the existing Azure CLI refresh path. Text and image authentication share the repaired provider owner. Configuration, credential formats, Azure API arguments, and authentication decisions are unchanged.
Evidence
A fresh trusted-main proof on
95f963e342ab476912c23c0e7fb9660c69bb9980registered the actual plugin, persisted a synthetic Entra profile through the public auth API, and invoked its public runtime-auth hook through the real process runner and an ordinary syntheticazexecutable. A separate Node 24 process used temporary home/state/Azure directories and a minimal environment; no genuine Azure credentials or production-owner mocks were involved.After filling 128 tuples, touching the first, admitting a 129th, then rereading the touched and untouched oldest tuples, main still made only 129 Azure CLI refreshes. A bounded LRU must make 130, retaining the touched tuple and refreshing the evicted one. All returned credentials matched their selected synthetic tenant. The baseline recorded 30,201.58 ms end to end and RSS 579,354,624 bytes; these are single-run observations, not a memory-savings or speedup claim.
The existing plugin suite now also checks:
azflow refreshes the evicted tuple, reporting only counts, booleans, timing, and RSS.CI #34027488799 completed successfully on exact PR head
b6da19645b3e69905cf8428d09eec66c5e43d8d4. The provider shard passed 1,170 tests across 67 files, including the real process-boundary proof and the expiry, recency, active-refresh, and failure-cleanup cases. CI tested merge1627f54002dc2147b631682c9ea178876a2a2ab3, combining mainb75423c2fcc30bda76fbe0480662bcaaea54a5b4with that exact PR head.Observed candidate output:
{"seededTuples":128,"afterRetouched":129,"afterOldest":130,"allTenantBindingsCorrect":true,"elapsedMs":3201.19518,"rssBytes":647258112}The touched account remained cached and the evicted account refreshed through
az, with every credential bound to its selected synthetic tenant. The Mac baseline and Linux CI have different execution environments; no cross-platform timing or RSS ratio is claimed.Existing scope separation, API-key behavior, near-expiry, invalid-clock, failed-refresh cleanup, and concurrent retry coverage remains intact. Independent Codex source review is clean through P2. No candidate application code ran on credentialed Macs.
Production delta: +14/-0. Tests: +265/-0 in the existing test file; no new test root or production test seam.
Follow-up
The provider reference page still describes native Anthropic support as absent despite the existing implementation. That separate documentation mismatch was recorded for follow-up; this PR changes only token retention and its proof.