fix(engine): isolate getTenantConfig reads and normalize tenant config - #9621
fix(engine): isolate getTenantConfig reads and normalize tenant config#9621kai392 wants to merge 1 commit into
Conversation
|
Caution 🛑 LoopOver review result - fixes requiredReview updated: 2026-07-29 00:50:59 UTC
Review summary Nits — 2 non-blocking
CI checks failing
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed 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. Decision record
🟩 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 returned the very object held in the store on a hit (only the miss path was a fresh copy), and setTenantConfig's Object.freeze is shallow, so a caller could mutate preferences/allowedActionClasses and silently rewrite a tenant's stored config. Now getTenantConfig deep-copies on BOTH paths, and setTenantConfig deep-freezes the written entry (config, preferences, and the action-class array). - resolveTenantConfig now normalizes an explicitly-supplied maxConcurrentLoops override with the exact finiteNonNegativeInt body used in tenant-quota.ts / loop-consumption.ts / worktree-pool.ts (JSONbored#5828) -- -5/0.5/NaN/Infinity no longer pass through; an absent override still inherits DEFAULT_TENANT_CONFIG's 1. It also drops non-string allowedActionClasses entries rather than copying them through, 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>
|
LoopOver had already started reviewing this pull request — closing it to dodge the one-shot review process is not allowed. Please open a new pull request with the issues addressed. |
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 shared byloop-consumption.ts/worktree-pool.ts), applied to an explicitly-supplied override only — an absent override still inheritsDEFAULT_TENANT_CONFIG's1.resolveTenantConfigalso now drops non-stringallowedActionClassesentries rather than copying them through, 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, and 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.