fix(engine): isolate getTenantConfig reads and normalize tenant config - #9622
fix(engine): isolate getTenantConfig reads and normalize tenant config#9622kai392 wants to merge 1 commit into
Conversation
|
Caution 🛑 LoopOver review result - fixes requiredReview updated: 2026-07-29 01:15:58 UTC
Review summary Nits — 5 non-blocking
CI checks failing
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. |
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: 5 new cases, 100% branch on the changed code, verified non-vacuous. Closes JSONbored#9614 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9622 +/- ##
==========================================
- Coverage 90.02% 90.00% -0.02%
==========================================
Files 888 888
Lines 111983 112021 +38
Branches 26570 26571 +1
==========================================
+ Hits 100810 100823 +13
- Misses 9843 9864 +21
- Partials 1330 1334 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
LoopOver is closing this pull request on the maintainer's behalf (CI is failing (codecov/patch)). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed. |
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 a fresh copy. On a hit it handed back the stored object, andsetTenantConfig'sObject.freezeis shallow (nestedpreferences/allowedActionClassesweren't frozen), so a caller could mutate a read config and silently rewrite that tenant's storedautonomyLevel/allowedActionClasses.Fix:
getTenantConfignow returns a deep copy on both paths, andsetTenantConfigdeep-freezes the written entry (config, itspreferences, and the action-class array).2.
maxConcurrentLoopswas unnormalized.??let-5,0.5,NaN,Infinitypass through verbatim. It now uses the exactfiniteNonNegativeIntbody fromtenant-quota.ts:45-47(the #5828 discipline), applied to an explicitly-supplied override only — an absent override still inheritsDEFAULT_TENANT_CONFIG's1.resolveTenantConfigalso drops non-stringallowedActionClassesentries, mirroring the existingautonomyLevelguard.DEFAULT_TENANT_CONFIG,TENANT_AUTONOMY_LEVELS,EMPTY_TENANT_CONFIG_STORE, and every exported type are unchanged;getTenantConfig's JSDoc is corrected.Tests
5 new cases in
test/unit/tenant-config.test.ts: maxConcurrentLoops normalization (-5/0.5/NaN/Infinity→0, 3→3, absent→1), non-string action-class dropping, deep-copy-on-hit isolation, deep-freeze of the stored entry. 100% branch + statement coverage on the changed code; verified non-vacuous (4/5 fail with the fix reverted).tsc --noEmitclean.