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:
@@ -53,9 +53,11 @@ export interface JobUsage {
|
||||
/** How many model calls the run has made (each bills separately). */
|
||||
steps: number;
|
||||
/** The MOST RECENT model call's accounting (2026-09 dock contract): the
|
||||
* per-blob context line reads last-step input+output against the model's
|
||||
* CONTEXT_LIMITS — never the cumulative totals. Absent until the first
|
||||
* call completes; absent provider fields stay absent (never zero). */
|
||||
* per-blob context line reads last-step input+output against the
|
||||
* model's LIVE catalog limit (server-joined onto the activity feed —
|
||||
* never the cumulative totals, never a client-side table). Absent
|
||||
* until the first call completes; absent provider fields stay absent
|
||||
* (never zero). */
|
||||
lastStep?: CallUsage;
|
||||
}
|
||||
|
||||
|
||||
+14
-1367
File diff suppressed because it is too large
Load Diff
@@ -153,6 +153,25 @@ export function toModelDto(model: Model<Api>): ModelDto {
|
||||
};
|
||||
}
|
||||
|
||||
/** The live-limits index (context-meter amendment, owner 2026-09-23):
|
||||
* provider:id → contextWindow from pi's catalog, over the SAME keyed
|
||||
* providers the picker federates. The one source for every context
|
||||
* meter's denominator — the stats-bar join holds /api/models' copy,
|
||||
* and the activity feed (observability.ts) resolves job limits
|
||||
* server-side through this. No hardcoded fallback exists anywhere:
|
||||
* a model missing here reads limit-null (usage-only, honest render). */
|
||||
export function catalogContextLimits(): Map<string, number> {
|
||||
const keyed = keyedProviderIds();
|
||||
const index = new Map<string, number>();
|
||||
for (const provider of piModels().getProviders()) {
|
||||
if (!keyed.has(provider.id)) continue;
|
||||
for (const model of piModels().getModels(provider.id)) {
|
||||
index.set(`${provider.id}:${model.id}`, model.contextWindow);
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
/** The full picker payload: every model of every configured provider
|
||||
* (sorted by provider then id — stable, diff-friendly) + the config
|
||||
* defaults a settings-less chat runs + the background roles' resolved
|
||||
|
||||
@@ -22,15 +22,22 @@
|
||||
import { extractionStatuses, type ExtractionPhase } from "../agent/subagents/extraction.ts";
|
||||
import { chatStore } from "../store/chats.ts";
|
||||
import { graphRevision } from "./graph.ts";
|
||||
import { catalogContextLimits } from "./model-catalog.ts";
|
||||
import { listJobs } from "./jobs.ts";
|
||||
import type { JobRecord } from "../core/contracts.ts";
|
||||
|
||||
export { abortExtraction, extractionStatuses, type ExtractionPhase, type RunningExtraction } from "../agent/subagents/extraction.ts";
|
||||
export { chatStore } from "../store/chats.ts";
|
||||
|
||||
/** A running sub-agent job, joined with its chat's title for the dock. */
|
||||
/** A running sub-agent job, joined with its chat's title for the dock.
|
||||
* contextLimit (context-meter amendment, owner 2026-09-23): the model's
|
||||
* live catalog limit, resolved SERVER-SIDE from pi's catalog — the dock
|
||||
* reads it off the feed instead of any client-side table. Null when the
|
||||
* model is missing from the catalog (the blob then renders no context
|
||||
* line — never a fake window). */
|
||||
export interface ActivityJob extends JobRecord {
|
||||
title: string;
|
||||
contextLimit: number | null;
|
||||
}
|
||||
|
||||
/** One extraction-pipeline run (title joined), oldest first. */
|
||||
@@ -54,11 +61,16 @@ export interface ActivityExtraction {
|
||||
* returns the same stamp. */
|
||||
export function activityFeed(): { jobs: ActivityJob[]; extractions: ActivityExtraction[]; graphRevision: number } {
|
||||
const chats = chatStore.listChats();
|
||||
const limits = catalogContextLimits();
|
||||
const jobs: ActivityJob[] = [];
|
||||
for (const chat of chats) {
|
||||
for (const job of listJobs(chat.id)) {
|
||||
if (job.status === "running") {
|
||||
jobs.push({ ...job, title: chat.title ?? chat.id });
|
||||
jobs.push({
|
||||
...job,
|
||||
title: chat.title ?? chat.id,
|
||||
contextLimit: job.usage ? (limits.get(job.usage.model) ?? null) : null,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user