fix(engine): isolate getTenantConfig reads and normalize tenant config - #9627
Conversation
|
Warning ⏸️ LoopOver review result - manual review recommendedReview updated: 2026-07-29 01:42:32 UTC
Review summary Nits — 6 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionPartially addressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9627 +/- ##
==========================================
+ Coverage 90.02% 90.03% +0.01%
==========================================
Files 888 888
Lines 111983 112021 +38
Branches 26570 26575 +5
==========================================
+ Hits 100810 100857 +47
+ Misses 9843 9830 -13
- Partials 1330 1334 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
JSONbored#9614) tenant-config.ts promised full per-tenant isolation but leaked the stored object and skipped normalizing maxConcurrentLoops: - getTenantConfig now deep-copies on BOTH paths (the hit path previously returned the stored object; Object.freeze is shallow), and setTenantConfig deep-freezes the written entry (config, preferences, and the action-class array). - resolveTenantConfig normalizes an explicitly-supplied maxConcurrentLoops override with the exact finiteNonNegativeInt body from tenant-quota.ts:45-47 (JSONbored#5828) -- absent override still inherits DEFAULT_TENANT_CONFIG's 1 -- and drops non-string allowedActionClasses entries, mirroring the existing autonomyLevel guard. - Corrected getTenantConfig's JSDoc; DEFAULT_TENANT_CONFIG, TENANT_AUTONOMY_LEVELS, EMPTY_TENANT_CONFIG_STORE, and every exported type are unchanged. Tests cover every changed branch in BOTH suites: the engine's own node:test suite (packages/loopover-engine/test/tenant-config.test.ts -- the source graded by the engine Codecov flag) at 100% branch, plus the root vitest suite. Closes JSONbored#9614 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Closes #9614
What
packages/loopover-engine/src/tenant-config.tspromised full per-tenant isolation but had two gaps:1. The read path leaked the stored object.
getTenantConfigreturnedstore[tenantId] ?? resolveTenantConfig()— only the miss path was fresh. On a hit it handed back the stored object, andsetTenantConfig'sObject.freezeis shallow, so a caller could mutate a read config and silently rewrite that tenant's storedautonomyLevel/allowedActionClasses. NowgetTenantConfigdeep-copies on both paths andsetTenantConfigdeep-freezes the written entry (config,preferences, and the action-class array).2.
maxConcurrentLoopswas unnormalized.??let-5/0.5/NaN/Infinitythrough. It now uses the exactfiniteNonNegativeIntbody fromtenant-quota.ts:45-47(#5828) on an explicitly-supplied override only — an absent override still inheritsDEFAULT_TENANT_CONFIG's1.resolveTenantConfigalso drops non-stringallowedActionClassesentries, mirroring theautonomyLevelguard.DEFAULT_TENANT_CONFIG,TENANT_AUTONOMY_LEVELS,EMPTY_TENANT_CONFIG_STORE, and every exported type are unchanged; the JSDoc is corrected.Tests
Every changed branch is covered in the engine's own node:test suite (
packages/loopover-engine/test/tenant-config.test.ts) — the suite theengineCodecov flag grades this source with — at 100% line/branch/function, plus the root vitest suite. Verified: engine suite 6/6, root suite 14/14,tsc --noEmitclean,git diff --checkclean.