Context-meter amendment: CONTEXT_LIMITS dies — pi's live catalog is the only limit source
Owner ruling (2026-09-23, amendment to 04e336d): no hardcoded fallback exists anywhere. contextWindow(record, limits) resolves the denominator ONLY from the live index (provider:id -> contextWindow straight from pi's catalog); a model missing from it (historical session, package update, failed fetch) reads limit null and the meter renders usage-only — the honest-render precedent, never a fake window. - src/core/prices.ts: the 1354-entry CONTEXT_LIMITS table (65KB) and its generation apparatus deleted; the fold returns limit: number | null. PRICES untouched (regen verified byte-identical via the reworked sync-pricing script). - scripts/sync-pricing.ts: generates PRICES only; contextWindow leaves the priced map, the guard, and the template. - The dock meter's owner-selected treatment: the activity feed carries the limit server-side. catalogContextLimits() (server/model-catalog.ts) builds the index over the same keyed providers the picker federates; activityFeed() joins it onto every running job (ActivityJob.contextLimit, null when the model is missing — the dock reads it off the feed, no client-side table, no regression while the UI's catalog-join chunk lands). - components/activity-dock.tsx: toBlobs reads job.contextLimit (import of CONTEXT_LIMITS gone); stats-bar renders usage-only on null limit (mechanical interim — UI stream's join chunk follows). - tests: usage.test.ts pins the no-fallback contract (index hit / absent / empty / missing-model -> null); activity-feed.test.ts pins the server join (catalog model -> 1048576, unknown -> null, no-usage -> null); render pins updated to the interim usage-only render.
This commit is contained in:
@@ -26,6 +26,7 @@ function job(over: Partial<ActivityFeed["jobs"][number]> = {}): ActivityFeed["jo
|
||||
createdAt: new Date(NOW - 45_000).toISOString(),
|
||||
updatedAt: new Date(NOW - 1000).toISOString(),
|
||||
title: "Limits lesson",
|
||||
contextLimit: null,
|
||||
...over,
|
||||
};
|
||||
}
|
||||
@@ -91,19 +92,23 @@ describe("activity dock pure layer", () => {
|
||||
};
|
||||
const withLast = job({
|
||||
usage: { ...base, lastStep: step(90_000, 2_000) },
|
||||
// The amendment (owner 2026-09-23): the limit is the server's
|
||||
// live-catalog join riding the feed — the dock never resolves it.
|
||||
contextLimit: 131_072,
|
||||
});
|
||||
const blob = toBlobs({ jobs: [withLast], extractions: [] })[0]!;
|
||||
assert.equal(blob.context?.used, 92_000);
|
||||
assert.equal(blob.context?.limit, 1048576);
|
||||
assert.equal(blob.context?.limit, 131_072);
|
||||
// No lastStep yet (capture pending) → "—", even though usage exists.
|
||||
const stripped = toBlobs({ jobs: [job({ usage: { ...base } })], extractions: [] })[0]!;
|
||||
assert.equal(stripped.context, null);
|
||||
// Unknown model → no limit → "—".
|
||||
const unknownModel = toBlobs({
|
||||
jobs: [job({ usage: { ...base, model: "nope/unknown", lastStep: step(5, 5) } })],
|
||||
// Model missing from the live catalog (historical session,
|
||||
// package update) → the feed carries null → no context line.
|
||||
const uncatalogued = toBlobs({
|
||||
jobs: [job({ usage: { ...base, model: "nope/unknown", lastStep: step(5, 5), } })],
|
||||
extractions: [],
|
||||
})[0]!;
|
||||
assert.equal(unknownModel.context, null);
|
||||
assert.equal(uncatalogued.context, null);
|
||||
});
|
||||
|
||||
it("extraction blobs carry no money/context (—, the doctrine)", () => {
|
||||
|
||||
Reference in New Issue
Block a user