Bound per-tenant runtime lifecycle#316
Merged
Merged
Conversation
# Conflicts: # src/web/server.ts
Owner
Author
|
Code review: reviewed single-flight creation, pin accounting, TTL/LRU eviction, capacity behavior when every runtime is active, prompt-cache co-lifecycle, and release coverage across session/history/chat/reflect routes. Found an account-deletion race where an in-flight creation could reinsert a deleted runtime; fixed in 4e2ccaa with invalidation and a retry regression test. Integrated with latest billing/admission/body/autonomy main. TypeScript, build, and 30 focused tests pass. No remaining blocking issue. |
oratis
marked this pull request as ready for review
July 25, 2026 19:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LISA_TENANT_RUNTIME_TTL_MIN(default 30) andLISA_TENANT_RUNTIME_MAX(default 100)Why
The cloud process retained every tenant's full loaded history and prompt forever. Memory therefore grew with lifetime tenant cardinality, and concurrent first requests could create duplicate contexts before either populated the old map. This establishes the TenantRuntime lifecycle seam before moving advisor/activity state and context compaction into it.
Safety
Pinned runtimes are never evicted. The registry may temporarily exceed its target when every entry is active, then returns under the limit as leases release. Runtime creation failures clear their single-flight slot and remain retryable. The local/global runtime is unchanged and not subject to tenant eviction.
Validation
npm run typecheck— passednpm test— 1393 passed, 1 skippednpm run build— passedDependency
This is intentionally stacked on #315 because it consumes the unified inference permit lifecycle. Review and merge #315 first; this PR then becomes a focused TenantRuntime change.