bus, cli, webui: token limits per instance, model, provider and key (row 125, #1619)
Adds token limits under launch.limits.tokens (instances, providers, keys,
models.P.M). Core (packages/bus/src/limits.mjs) reads the organization
file and the per-turn usage records row 124 writes, then asks every
switched-on limit-check plug-in; the first refusal wins. A limit no
switched-on check reports reads "not enforced". The limit-check kind is
interface 2 (mayLaunch, mustStop, report); a v1 check is refused at load.
The shipped token-limit check is pure and counts known end records only;
unknown turns add nothing and are shown as their own count.
The launcher refuses limit-reached through the host's mayLaunch op, or
limit-check-failed naming the check. The broker asks mustStop after a
usage end and stops the run at its next receive or state. Settings stamps
since on a new or changed limit and runs reset; launch.mjs and
business.mjs validate the shape. Readers: mosaic limits and mosaic limits
reset, the bus limits view, the Console /api/bus/limits route and the
Settings token table with Reset. Key limits stay "not enforced" until
row 126 names accounts on records.
Owner Dewey, design under lead decision 150.
Reviewer Filbert: r1 changes (comment 28965), r2 approve (28981), r3
approve (28996) on candidate manifest 8b71c405...fe56 after the rebase
onto row 164 (37 of 38 paths with identical +/- lines, TOOLS.md:621
bracket). Decision 123 go on the bus.js hunk from Mos (mos-0814). Sage
gate on @BASE@: @GATE@.
Live stays as pinned. Not part of the 8e7ea89a1 window.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
b6827d19ea
commit
5289ca1d2c
38 files changed
+1976
-83
No files matched your search
@@ -616,6 +616,17 @@ mode. Unset means unlimited, zero blocks new launches, and running sessions
|
||||
remain alive when a limit is lowered. Total, provider and exact model limits
|
||||
are checked for each launch; counts have no hard-coded policy ceiling.
|
||||
|
||||
Token limits (row 125) are `limits.tokens.instances.NAME`, `providers.NAME`,
|
||||
`models.PROVIDER.MODEL` and `keys.NAME`, each `{ "limit": N }`. The writer adds
|
||||
and keeps `since`. `scripts/mosaic limits reset WORD... [--business ID]` (for
|
||||
example `reset tokens providers anthropic`) moves one limit's `since` to now,
|
||||
logged with its actor. A token limit is enforced only by a switched-on
|
||||
`limit-check` plug-in (`token-limit` ships): it refuses a launch at the limit
|
||||
and stops the session at the end of the turn that reaches it. Otherwise the
|
||||
read shows it as `not enforced`; a failing check refuses and stops (fail
|
||||
closed). Without `--json` the read prints JSON without `tokens` followed by
|
||||
`token limits:` text lines, so scripts must pass `--json`.
|
||||
|
||||
Convert an old organization file with `scripts/mosaic limits migrate --file
|
||||
ORGANIZATION --models MAPPING --roles-dir roles > CONVERTED`. It needs no bus,
|
||||
never edits the input or system config and has no write flag. Inherited models
|
||||
|
||||
Reference in new issue
Block a user