fix(types,docs): clear the 5 typecheck errors and the fabricated env vars on the base

Third pass over the base-reds, from the 2026-08-06T22:51Z verdict on #9298 —
it reported "Typecheck (core)" with only the FIRST error; there are five, all on
the pure tip 9995bc4893. Two are real production defects.

**Real bugs**

- open-sse/services/compression/engines/ccr/index.ts:295 called
  enforceGlobalBudget(entry.bytes) against an (owner, bytes) signature. The
  `bytes` argument arrived undefined, so `ccrTotalBytes + undefined` is NaN,
  `NaN > MAX` is false (the eviction loop exits immediately) and `NaN <= MAX` is
  false (the re-admit is refused). The #9061 durable tier therefore NEVER
  repopulated its in-memory map: every retrieve after a restart or an eviction
  re-read from SQLite forever, and evictions could not prefer the owning
  principal. Fixed and pinned by a new case in
  tests/unit/ccr-durable-store-9061.test.ts (11/11) — verified failing against
  the buggy call and passing against the fix.
- open-sse/services/combo/fusionPanel.ts:54 read `step.model` after #8894
  widened ComboStep with ComboProviderWildcardStep (which carries modelPattern,
  not model), so a wildcard step in a fusion panel pushed `undefined` onto the
  panel. Now resolved through getComboModelString(), which already handles every
  step shape and returns null for the ones without a concrete model id.

**Type-only**

- accountSemaphore.ts:203 — isBypassed() returns a plain boolean and cannot
  narrow `number | null` (an `x is null | undefined` predicate would be unsound:
  0 bypasses too). Added resolveActiveCap(), the narrowing companion isBypassed
  is now defined in terms of; the acquire path uses the narrowed value.
- comboStructure.ts:140 — same #8894 widening: `prompt` only exists on a model
  step, so it is now read under a kind check.
- firecrawlQuotaFetcher.ts:136 — the function returns full FirecrawlQuota
  objects but was annotated Promise<QuotaInfo | null>, which made the
  custom-base literal an excess-property error. Widened to the accurate type
  (FirecrawlQuota extends QuotaInfo, so callers are unaffected).

**Fabricated docs (the "Docs sync + fabricated-docs (strict)" HARD failure)**

docs/ops/VM_DEPLOYMENT_GUIDE.md recommended OMNIROUTE_MAX_POOL_SIZE and
OMNIROUTE_DB_POOL_SIZE (#9471). Neither is read anywhere in the codebase.
Replaced with the two knobs that do exist and are already documented in
ENVIRONMENT.md: OMNIROUTE_MEMORY_MB and OMNIROUTE_CHAT_MAX_HEAVY_IN_FLIGHT.

typecheck:core 5 errors -> 0. check:fabricated-docs + check:env-doc-sync OK.
accountSemaphore 6/6, ccr-durable-store 11/11, ccr-protocol 9/9,
combo-fusion-strategy 10/10, combo-fusion-comboref 5/5, combo-fusion-warn 4/4,
firecrawl-executor 7/7, executor-firecrawl-fetch 4/4.

Refs #9298
This commit is contained in:
diegosouzapw
2026-08-07 04:34:58 -03:00
parent b80987e4d4
commit db2c3a4753
7 changed files with 63 additions and 10 deletions

View File

@@ -119,6 +119,32 @@ describe("CCR engine survives losing its in-memory map (#9061)", () => {
);
});
it("re-admits the disk row into the fresh map (the enforceGlobalBudget arity bug)", async () => {
// The restart path re-admits a disk-served block through the same budgets a fresh
// store would face. #9061 called enforceGlobalBudget(entry.bytes) with ONE argument
// against a (owner, bytes) signature: `bytes` arrived undefined, `ccrTotalBytes +
// undefined` is NaN, and `NaN <= MAX` is false — so the re-admit never happened and
// the map stayed empty, re-reading from disk on every single retrieve. Typecheck
// caught the arity; this pins the observable behaviour.
const text = "z".repeat(2_000);
const stored = ccr.tryStoreBlock(text, "principal-readmit");
assert.equal(stored.stored, true);
await ccr.flushCcrDurableWrites();
const restarted = await import(`${ccrPath}?restart=9061-readmit`);
assert.equal(
restarted.getCcrStoreStats("principal-readmit").entries,
0,
"a fresh instance starts with an empty map"
);
assert.equal(restarted.retrieveBlock(stored.hash, "principal-readmit"), text);
assert.equal(
restarted.getCcrStoreStats("principal-readmit").entries,
1,
"the disk-served block must be re-admitted into the map, not re-read every time"
);
});
it("keeps the principal boundary across the restart", async () => {
const text = "y".repeat(2_000);
const stored = ccr.tryStoreBlock(text, "principal-a");