modelpace 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,383 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import {
6
+ normalizePolicy,
7
+ starterPolicy,
8
+ appendDispatchRecord,
9
+ collectDispatchScores,
10
+ formatDispatchScores,
11
+ formatDecisionText,
12
+ collectSpeed,
13
+ formatSpeedText,
14
+ renderDashboardHtml,
15
+ startDashboardServer,
16
+ } from '../src/index.mjs';
17
+ import { planDispatch, resolveDays } from '../src/context.mjs';
18
+
19
+ const HELP_EN = `modelpace - Multi-model dispatch, quota pacing & acceptance scoring for T3 Code
20
+
21
+ Usage:
22
+ modelpace plan [options] Recommend the best delegate_task target
23
+ modelpace record --json FILE|- Append a dispatch acceptance record (JSONL)
24
+ modelpace scores [options] Summarize and rank acceptance scores
25
+ modelpace speed [options] Local Speed leaderboard from session logs
26
+ modelpace dashboard [options] Write a self-contained HTML dashboard (quota, speed, scores)
27
+ modelpace serve [options] Serve the live dashboard on localhost
28
+ modelpace validate --config F Validate a dispatch.config.json (schemaVersion 2)
29
+ modelpace init [--out FILE] Print or write a starter dispatch.config.json
30
+
31
+ Plan options:
32
+ --config FILE Path to dispatch.config.json (or MODELPACE_CONFIG)
33
+ --slot SLOT Target slot name (defaults via taskToSlot)
34
+ --task TASK general | research | review | slice | long (default: general)
35
+ --tier TIER Sensitivity / permission tier
36
+ --wait-minutes N Max minutes willing to wait for a reset (0..1440)
37
+ --claude-model ID Optional Claude model family (e.g. sonnet, opus)
38
+ --snapshot FILE|- Usage snapshot JSON file (v2, T3 getConfig, v1, or Claude JSON)
39
+ --budget FILE Optional pay-as-you-go budget overlay JSON file
40
+ --t3-origin URL Live T3 server origin (or MODELPACE_ORIGIN)
41
+ --t3-token TOKEN Bearer token for T3 server (or MODELPACE_TOKEN)
42
+ --t3-token-cmd CMD Command to mint a short-lived bearer token (or MODELPACE_TOKEN_CMD)
43
+ --t3-auto Discover the local T3 Code and use a 2-minute session (or MODELPACE_AUTO=1)
44
+ --scores FILE JSONL acceptance scores file (or MODELPACE_SCORES; default: $XDG_DATA_HOME/modelpace/scores.jsonl)
45
+ --speed FILE Optional speed metrics JSON ({ "<model>": { "longRate": 120 } })
46
+ --speed-scan Measure Speed from local session logs and use it as a tie-breaker
47
+ --days N Speed window in days (default: 30)
48
+ --now ISO Evaluate at this instant instead of the current time (replays a saved snapshot)
49
+ --format text|json Output format (default: text)
50
+ --lang en|zh Output language (default: en)
51
+
52
+ Speed options:
53
+ --days N Window in days (default: 30)
54
+ --format text|json|html Output format (default: text)
55
+ --out FILE Write the output to FILE instead of stdout
56
+ --scores FILE Add the Dispatch Pass column from an acceptance ledger
57
+
58
+ Dashboard / serve options:
59
+ Accept the plan options above (snapshot source, --scores, --days, --task, ...).
60
+ dashboard --out FILE Write HTML to FILE (default: stdout)
61
+ serve --port N Listen on 127.0.0.1:N (default: 0, a free port)
62
+
63
+ Next steps:
64
+ 1. modelpace plan --t3-auto --task slice Ask the local T3 Code for a recommendation
65
+ (offline replay: plan --snapshot examples/sample-snapshot.json --now 2026-11-23T07:05:00Z --task slice)
66
+ 2. Read the "Action:" line: run -> pass the printed delegate_task target; refresh -> see the hint in the reasons
67
+ 3. After verifying the delegated result: modelpace record --json record.json (template: examples/record.example.json)
68
+ Agents: read AGENTS.md; field reference: docs/SCHEMA.md
69
+ `;
70
+
71
+ const HELP_ZH = `modelpace - 面向 T3 Code 的多模型派发、节奏门控与验收评分引擎
72
+
73
+ 用法:
74
+ modelpace plan [选项] 推荐最合适的 delegate_task 目标
75
+ modelpace record --json FILE|- 追加一条派发验收记录(JSONL)
76
+ modelpace scores [选项] 汇总并排序历史验收评分
77
+ modelpace speed [选项] 从本机会话日志统计 Speed 排行
78
+ modelpace dashboard [选项] 输出自包含 HTML 仪表盘(额度、速度、评分)
79
+ modelpace serve [选项] 在本机启动实时仪表盘
80
+ modelpace validate --config F 校验 dispatch.config.json (schemaVersion 2)
81
+ modelpace init [--out FILE] 输出或写入初始配置模板
82
+
83
+ 下一步:
84
+ 1. modelpace plan --t3-auto --task slice --lang zh 向本机 T3 Code 要一个派发建议
85
+ (离线回放:plan --snapshot examples/sample-snapshot.json --now 2026-11-23T07:05:00Z --task slice)
86
+ 2. 看 "建议动作" 一行:run 就把打印的 delegate_task target 交给 delegate_task;refresh 看理由里的提示
87
+ 3. 独立验证结果后记录:modelpace record --json record.json(模板:examples/record.example.json)
88
+ 选项与英文帮助相同(modelpace --help);Agent 请读 AGENTS.md
89
+ `;
90
+
91
+ async function readStdin(stream) {
92
+ const chunks = [];
93
+ for await (const chunk of stream) {
94
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
95
+ }
96
+ return Buffer.concat(chunks).toString('utf8');
97
+ }
98
+
99
+ function parseJson(text, label) {
100
+ try {
101
+ return JSON.parse(text);
102
+ } catch {
103
+ throw new Error(`${label} is not valid JSON`);
104
+ }
105
+ }
106
+
107
+ function readJsonFile(filePath, hint) {
108
+ let raw;
109
+ try {
110
+ raw = fs.readFileSync(path.resolve(filePath), 'utf8');
111
+ } catch (error) {
112
+ throw new Error(`Cannot read ${filePath}: ${error.code ?? error.message}${hint ? ` (${hint})` : ''}`);
113
+ }
114
+ return parseJson(raw, filePath);
115
+ }
116
+
117
+ function parseFlags(args, valueFlags, booleanFlags = []) {
118
+ const opts = {};
119
+ const positional = [];
120
+ for (let i = 0; i < args.length; i++) {
121
+ const arg = args[i];
122
+ if (booleanFlags.includes(arg)) {
123
+ opts[arg.slice(2)] = true;
124
+ continue;
125
+ }
126
+ if (valueFlags.includes(arg)) {
127
+ const val = args[i + 1];
128
+ if (val === undefined || (val.startsWith('--') && val !== '-')) {
129
+ throw new Error(`Missing value for ${arg}`);
130
+ }
131
+ opts[arg.slice(2)] = val;
132
+ i++;
133
+ continue;
134
+ }
135
+ if (arg.startsWith('--')) {
136
+ throw new Error(`Unknown option: ${arg}`);
137
+ }
138
+ positional.push(arg);
139
+ }
140
+ return { opts, positional };
141
+ }
142
+
143
+ function writeOutput(out, content, write) {
144
+ if (!out) {
145
+ write(content);
146
+ return;
147
+ }
148
+ const outPath = path.resolve(out);
149
+ fs.mkdirSync(path.dirname(outPath), { recursive: true });
150
+ fs.writeFileSync(outPath, content, 'utf8');
151
+ write(`Wrote ${outPath}\n`);
152
+ }
153
+
154
+ /** 未指定配置时回落到内置默认策略(官方 T3 Code 实例 id),builtin 标记用来在输出里提示。 */
155
+ function loadConfig(configPath, env) {
156
+ const resolved = configPath ?? env.MODELPACE_CONFIG;
157
+ if (!resolved) return { policy: normalizePolicy(starterPolicy()), builtin: true };
158
+ return { policy: normalizePolicy(readJsonFile(resolved, 'create one with "modelpace init --out FILE", or omit --config to use the built-in policy')), builtin: false };
159
+ }
160
+
161
+ const BUILTIN_NOTE = {
162
+ en: 'Note: using the built-in default policy (official T3 Code instance ids). Pass --config FILE to use your own; "modelpace init" writes a starting point.\n',
163
+ zh: '提示:正在使用内置默认策略(官方 T3 Code 实例 id)。用 --config FILE 指定自己的策略,"modelpace init" 可生成起点。\n',
164
+ };
165
+
166
+ export async function runCli(
167
+ argv,
168
+ { env = process.env, stdin = process.stdin, write = (s) => process.stdout.write(s), now = () => Date.now(), signal } = {},
169
+ ) {
170
+ const [cmd, ...rest] = argv;
171
+ if (!cmd || cmd === '--help' || cmd === '-h' || cmd === 'help') {
172
+ const lang = argv.includes('zh') ? 'zh' : 'en';
173
+ write(lang === 'zh' ? HELP_ZH : HELP_EN);
174
+ return 0;
175
+ }
176
+ if (cmd === '--version' || cmd === '-v') {
177
+ const pkg = JSON.parse(
178
+ fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8'),
179
+ );
180
+ write(`${pkg.version}\n`);
181
+ return 0;
182
+ }
183
+
184
+ if (cmd === 'init') {
185
+ const { opts } = parseFlags(rest, ['--out']);
186
+ const content = JSON.stringify(starterPolicy(), null, 2) + '\n';
187
+ if (opts.out) {
188
+ const outPath = path.resolve(opts.out);
189
+ fs.mkdirSync(path.dirname(outPath), { recursive: true });
190
+ fs.writeFileSync(outPath, content, 'utf8');
191
+ write(`Wrote starter config to ${outPath}\n`);
192
+ } else {
193
+ write(content);
194
+ }
195
+ return 0;
196
+ }
197
+
198
+ if (cmd === 'validate') {
199
+ const { opts } = parseFlags(rest, ['--config']);
200
+ const cfgPath = opts.config ?? env.MODELPACE_CONFIG;
201
+ if (!cfgPath) throw new Error('validate requires --config FILE (create one with "modelpace init --out dispatch.config.json")');
202
+ const policy = normalizePolicy(readJsonFile(cfgPath, 'create one with "modelpace init --out FILE"'));
203
+ write(`Valid dispatch policy (schemaVersion=${policy.schemaVersion}, slots=${Object.keys(policy.slots).join(', ')})\n`);
204
+ return 0;
205
+ }
206
+
207
+ if (cmd === 'record') {
208
+ const { opts } = parseFlags(rest, ['--json', '--scores', '--config']);
209
+ if (!opts.json) throw new Error('record requires --json FILE|- (a record file; see examples/record.example.json)');
210
+ const record = opts.json === '-' ? parseJson(await readStdin(stdin), 'The record on stdin') : readJsonFile(opts.json, 'see examples/record.example.json');
211
+ const { policy } = loadConfig(opts.config, env);
212
+ const result = appendDispatchRecord(record, {
213
+ scoresFile: opts.scores,
214
+ env,
215
+ config: policy.scoring,
216
+ });
217
+ write(`Recorded ${result.identity} × ${result.task} -> ${result.file}\n`);
218
+ return 0;
219
+ }
220
+
221
+ if (cmd === 'scores') {
222
+ const { opts } = parseFlags(rest, ['--scores', '--config', '--format', '--lang']);
223
+ const format = opts.format ?? 'text';
224
+ const lang = opts.lang ?? 'en';
225
+ if (!['text', 'json'].includes(format)) throw new Error('--format must be text or json');
226
+ if (!['en', 'zh'].includes(lang)) throw new Error('--lang must be en or zh');
227
+
228
+ const { policy } = loadConfig(opts.config, env);
229
+ const summary = collectDispatchScores({ scoresFile: opts.scores, env }, policy.scoring);
230
+ if (format === 'json') {
231
+ write(JSON.stringify(summary, null, 2) + '\n');
232
+ } else {
233
+ write(formatDispatchScores(summary, { lang }).join('\n') + '\n');
234
+ }
235
+ return 0;
236
+ }
237
+
238
+ if (['plan', 'dashboard', 'serve'].includes(cmd)) {
239
+ const { opts } = parseFlags(
240
+ rest,
241
+ [
242
+ '--config', '--slot', '--task', '--tier', '--wait-minutes', '--claude-model',
243
+ '--snapshot', '--budget', '--t3-origin', '--t3-token', '--t3-token-cmd',
244
+ '--scores', '--speed', '--format', '--lang', '--days', '--out', '--port', '--now',
245
+ ],
246
+ ['--t3-auto', '--speed-scan'],
247
+ );
248
+ const format = opts.format ?? 'text';
249
+ const lang = opts.lang ?? 'en';
250
+ if (!['text', 'json'].includes(format)) throw new Error('--format must be text or json');
251
+ if (!['en', 'zh'].includes(lang)) throw new Error('--lang must be en or zh');
252
+ const days = resolveDays(opts.days, '--days');
253
+ const fixedNow = opts.now === undefined ? null : Date.parse(opts.now);
254
+ if (fixedNow !== null && !Number.isFinite(fixedNow)) throw new Error('--now must be an ISO 8601 timestamp');
255
+ if (fixedNow !== null && cmd === 'serve') throw new Error('--now is not supported for serve');
256
+
257
+ const { policy, builtin } = loadConfig(opts.config, env);
258
+ const snapshotSource = opts.snapshot ?? env.MODELPACE_SNAPSHOT;
259
+ if (cmd === 'serve' && snapshotSource === '-') throw new Error('serve cannot read the snapshot from stdin');
260
+ const waitMinutes = opts['wait-minutes'] !== undefined ? Number(opts['wait-minutes']) : 0;
261
+ const request = {
262
+ ...(opts.slot ? { slot: opts.slot } : {}),
263
+ ...(opts.task ? { task: opts.task } : {}),
264
+ ...(opts.tier ? { tier: opts.tier } : {}),
265
+ ...(opts['claude-model'] ? { claudeModel: opts['claude-model'] } : {}),
266
+ waitMinutes,
267
+ };
268
+ const hasSource = Boolean(snapshotSource || opts['t3-origin'] || env.MODELPACE_ORIGIN || opts['t3-auto'] || env.MODELPACE_AUTO === '1');
269
+
270
+ const load = async () => {
271
+ const currentMs = fixedNow ?? now();
272
+ const rawSnapshot = !snapshotSource
273
+ ? null
274
+ : snapshotSource === '-'
275
+ ? parseJson(await readStdin(stdin), 'The snapshot on stdin')
276
+ : readJsonFile(snapshotSource, 'a saved usage snapshot; examples/sample-snapshot.json shows the shape');
277
+ return planDispatch({
278
+ policy,
279
+ request,
280
+ rawSnapshot,
281
+ origin: opts['t3-origin'] ?? env.MODELPACE_ORIGIN,
282
+ bearer: opts['t3-token'] ?? env.MODELPACE_TOKEN,
283
+ tokenCommand: opts['t3-token-cmd'] ?? env.MODELPACE_TOKEN_CMD,
284
+ auto: Boolean(opts['t3-auto']) || env.MODELPACE_AUTO === '1',
285
+ budget: opts.budget ? readJsonFile(opts.budget) : null,
286
+ scoresPath: opts.scores ?? env.MODELPACE_SCORES,
287
+ speedMetrics: opts.speed ? readJsonFile(opts.speed) : null,
288
+ speedScan: Boolean(opts['speed-scan']) || cmd !== 'plan',
289
+ days,
290
+ env,
291
+ now: currentMs,
292
+ });
293
+ };
294
+
295
+ if (cmd === 'plan') {
296
+ if (!hasSource) throw new Error('plan needs a usage source: pass --t3-auto (local T3 Code), --t3-origin URL with --t3-token, or --snapshot FILE (replay a saved snapshot with --now)');
297
+ const { decision } = await load();
298
+ if (format === 'json') {
299
+ write(JSON.stringify(decision, null, 2) + '\n');
300
+ } else {
301
+ if (builtin) write(BUILTIN_NOTE[lang]);
302
+ write(formatDecisionText(decision, { lang }));
303
+ }
304
+ return 0;
305
+ }
306
+
307
+ const toDashboardInput = (loaded) => ({
308
+ decision: loaded.decision,
309
+ snapshot: loaded.snapshot,
310
+ scoresSummary: loaded.scoresSummary,
311
+ speedRanking: loaded.speed?.ranking ?? [],
312
+ options: { now: loaded.now, days, warnings: loaded.speed?.warnings ?? [] },
313
+ });
314
+
315
+ if (cmd === 'dashboard') {
316
+ const html = renderDashboardHtml(toDashboardInput(await load()));
317
+ writeOutput(opts.out, html, write);
318
+ return 0;
319
+ }
320
+
321
+ const port = opts.port === undefined ? 0 : Number(opts.port);
322
+ if (!Number.isInteger(port) || port < 0 || port > 65535) throw new Error('--port must be an integer in 0..65535');
323
+ const dashboard = await startDashboardServer({
324
+ port,
325
+ load: async () => toDashboardInput(await load()),
326
+ options: { days },
327
+ });
328
+ write(`modelpace dashboard: ${dashboard.url}\n`);
329
+ await new Promise((resolve) => {
330
+ if (signal?.aborted) return resolve();
331
+ signal?.addEventListener('abort', resolve, { once: true });
332
+ if (!signal) {
333
+ process.once('SIGINT', resolve);
334
+ process.once('SIGTERM', resolve);
335
+ }
336
+ });
337
+ await dashboard.close();
338
+ return 0;
339
+ }
340
+
341
+ if (cmd === 'speed') {
342
+ const { opts } = parseFlags(rest, ['--days', '--format', '--out', '--scores', '--config', '--lang']);
343
+ const format = opts.format ?? 'text';
344
+ const lang = opts.lang ?? 'en';
345
+ if (!['text', 'json', 'html'].includes(format)) throw new Error('--format must be text, json or html');
346
+ if (!['en', 'zh'].includes(lang)) throw new Error('--lang must be en or zh');
347
+ const days = resolveDays(opts.days, '--days');
348
+ const { policy } = loadConfig(opts.config, env);
349
+ const currentMs = now();
350
+ const speed = await collectSpeed({
351
+ days,
352
+ now: currentMs,
353
+ scoresFile: opts.scores ?? env.MODELPACE_SCORES,
354
+ scoring: policy.scoring,
355
+ env,
356
+ });
357
+ let output;
358
+ if (format === 'json') {
359
+ output = JSON.stringify({ days, ranking: speed.ranking, metrics: speed.metrics, sources: speed.sources, warnings: speed.warnings }, null, 2) + '\n';
360
+ } else if (format === 'html') {
361
+ output = renderDashboardHtml({
362
+ speedRanking: speed.ranking,
363
+ options: { now: currentMs, days, warnings: speed.warnings },
364
+ });
365
+ } else {
366
+ output = formatSpeedText(speed, { lang }).join('\n') + '\n';
367
+ }
368
+ writeOutput(opts.out, output, write);
369
+ return 0;
370
+ }
371
+
372
+ throw new Error(`Unknown command: ${cmd}. Run "modelpace --help" for usage.`);
373
+ }
374
+
375
+ if (process.argv[1] && fs.realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) {
376
+ runCli(process.argv.slice(2)).then(
377
+ (code) => process.exit(code),
378
+ (error) => {
379
+ process.stderr.write(`${error?.message ?? error}\n`);
380
+ process.exit(1);
381
+ },
382
+ );
383
+ }
package/docs/SCHEMA.md ADDED
@@ -0,0 +1,170 @@
1
+ # Schema reference
2
+
3
+ modelpace reads three JSON shapes: the **config** (your policy), the **record** (one acceptance outcome per line in the ledger) and the **snapshot** (the quota state `plan` decides on). `modelpace validate --config FILE` checks a config; every record is validated when it is written and read.
4
+
5
+ Working examples: [`examples/multi-account.config.json`](../examples/multi-account.config.json), [`examples/sample-snapshot.json`](../examples/sample-snapshot.json) and [`examples/multi-account.snapshot.json`](../examples/multi-account.snapshot.json).
6
+
7
+ ## Config (`dispatch.config.json`, `schemaVersion: 2`)
8
+
9
+ Without `--config` (or `MODELPACE_CONFIG`) the built-in default policy is used: the official T3 Code default instance ids `codex`, `claudeAgent` and `antigravity`, one instance per driver. `modelpace init` prints it as a starting point.
10
+
11
+ | Field | Type | Meaning |
12
+ | --- | --- | --- |
13
+ | `schemaVersion` | `2` | Optional; any other value is rejected. |
14
+ | `tiers` | string[] | Permission/sensitivity tiers you can ask for with `--tier` (default `work`, `personal`, `public`). |
15
+ | `defaultTier` | string \| null | Tier used when the request has none; must be listed in `tiers`. |
16
+ | `taskToSlot` | object | Maps a task (`general`, `research`, `review`, `slice`, `long`) to a slot name. |
17
+ | `instances` | object | Per T3 provider-instance policy, keyed by instance id (see below). |
18
+ | `slots` | object | **Required**, at least one. `slots.<name>.candidates` is an ordered array of candidates (see below). |
19
+ | `pacing` | object | Even Pace and freshness thresholds (see below). |
20
+ | `scoring` | object | Acceptance-score settings (see below). |
21
+
22
+ ### `instances.<instanceId>`
23
+
24
+ The key is the T3 provider instance id (official defaults equal the driver name, for example `codex`, `claudeAgent`, `antigravity`; extra accounts get ids you chose in T3 Code).
25
+
26
+ | Field | Type | Meaning |
27
+ | --- | --- | --- |
28
+ | `driver` | string | T3 driver kind. Used when the snapshot does not carry one. |
29
+ | `enabled` | boolean | `false` disables every candidate on this instance. |
30
+ | `tiers` | string[] | Tiers allowed on this instance; omit for all. |
31
+ | `tasks` | string[] | Tasks allowed on this instance; omit for all. |
32
+ | `shortWindowMaxUsedPercent` | 0..100 | Skip when a short (session) window is used beyond this. |
33
+ | `weeklyMinRemainingPercent` | 0..100 | Floor for the weekly window's effective remaining percent. |
34
+ | `scoreProvider` | string | Provider name used in the score identity. Defaults to the driver, then the instance id. |
35
+
36
+ ### `slots.<name>.candidates[]`
37
+
38
+ Candidates are tried in `priority` order (default: array order). Each one targets one model on one instance.
39
+
40
+ | Field | Type | Meaning |
41
+ | --- | --- | --- |
42
+ | `id` | string | Unique within the slot; defaults to `instanceId:model:index`. |
43
+ | `instanceId` | string | **Required.** Must match an instance id in the snapshot. |
44
+ | `model` | string | **Required.** Model slug passed to `delegate_task`. |
45
+ | `effort` | string | Effort label, part of the score identity (default `default`). |
46
+ | `options` | object | Passed through into `recommended.target.options`, for example `{ "reasoningEffort": "high" }`. |
47
+ | `pool` | string | Quota pool for drivers that split windows per model family (Antigravity: `gemini`, `carbon`, `argon`). |
48
+ | `priority` | number | Lower runs first among equally qualified candidates. |
49
+ | `tiers`, `tasks` | string[] | Restrict the candidate to these tiers / tasks. |
50
+ | `maxShortUsedPercent`, `minRemainingPercent` | 0..100 | Per-candidate overrides of the instance thresholds. |
51
+ | `scoreTier` / `serviceTier` | string | The **service tier** in the score identity (default `default`). Not the permission tier. |
52
+ | `allowRedeem` | boolean | `false` stops `plan` from suggesting a reset credit for this candidate. |
53
+ | `enabled` | boolean | `false` skips the candidate. |
54
+
55
+ ### `pacing`
56
+
57
+ | Field | Default | Meaning |
58
+ | --- | --- | --- |
59
+ | `paceMarginPercent` | 10 | A long window may be this far behind Even Pace before it blocks (> 0). |
60
+ | `longTaskMinRemainingPercent` | 30 | Minimum effective remaining percent for `long` tasks. |
61
+ | `defaultMinRemainingPercent` | 20 | Minimum for every other task. |
62
+ | `shortWindowMaxUsedPercent` | 90 | Default short-window cap. |
63
+ | `recheckAfterMinutes` | 15 | Gap used for `nextCheckAt`. |
64
+ | `maxSnapshotAgeMinutes` | 15 | A snapshot (or instance `checkedAt`) older than this yields `refresh`. |
65
+ | `resetCredit.skipIfResetWithinHours` / `expiryWarnHours` | 6 / 72 | Reset-credit handling. |
66
+ | `expiringBoost` | see source | Prefer quota that resets soon; `null` disables it. |
67
+
68
+ ### `scoring`
69
+
70
+ | Field | Default | Meaning |
71
+ | --- | --- | --- |
72
+ | `mode` | `demote` | `demote`, `strict` (drop) or `advisory` (warn) for candidates below the pass rate. |
73
+ | `minPassRate` | 0.85 | Lower bound of the pass rate to count as `qualified`. |
74
+ | `minSamples` | 5 | Records needed in a cell (identity × task) before it counts. |
75
+ | `speedTieBreakerMarginRatio` | 0.15 | Median durations within this ratio count as a tie. |
76
+ | `aliases` | `provider: { claudeAgent: claude }`, `tier: { "-": default }` | Maps spellings to one identity; `model` and `effort` aliases are allowed too. |
77
+ | `durationUnreadableProviders` | `[]` | Providers whose records may have `durationMin: null`. |
78
+ | `rejectRules`, `disabledProviders` | `[]` | Reject records matching `{ providerIn, providerNotIn, siteContains, modelIn, tierIn, reason }`. |
79
+ | `pricing` | `{ currency: "USD", ... }` | `monthlyPrice` per score provider, used for nominal cost per run. |
80
+
81
+ ## Record (one JSON object per ledger line)
82
+
83
+ The ledger is JSONL at `--scores FILE`, `MODELPACE_SCORES`, or by default `$XDG_DATA_HOME/modelpace/scores.jsonl` (`~/.local/share/modelpace/scores.jsonl`; `%LOCALAPPDATA%\modelpace\scores.jsonl` on Windows). All fifteen fields are required and unknown fields are rejected.
84
+
85
+ | Field | Type | Meaning |
86
+ | --- | --- | --- |
87
+ | `date` | `YYYY-MM-DD` | Calendar date of the work. |
88
+ | `taskId` | string \| null | Your id for the task. |
89
+ | `title` | string | Short summary. |
90
+ | `task` | enum | `general`, `research`, `review`, `slice` or `long`. |
91
+ | `executor` | object | Who did it; see below. |
92
+ | `scorer` | string | Who judged it (for example `orchestrator`, `user`). |
93
+ | `accepted` | boolean | Whether the result was accepted after independent verification. |
94
+ | `firstPass` | boolean | Accepted without rework. |
95
+ | `reworkRounds` | integer ≥ 0 | Rework rounds before acceptance. |
96
+ | `scopeViolation` | boolean | The executor touched things outside its brief. |
97
+ | `falseReport` | boolean | The executor reported success that verification contradicted. |
98
+ | `stoppedOnDenial` | boolean \| null | `true`/`false` when a permission denial happened; `null` when none. |
99
+ | `durationMin` | number \| null | Wall minutes; `null` only for providers in `durationUnreadableProviders`. |
100
+ | `quotaDelta` | number \| null | Percentage points of quota the run consumed. |
101
+ | `note` | string | Free text, may be empty. |
102
+
103
+ A record counts as a **success** when `accepted`, no `falseReport`, no `scopeViolation`, `stoppedOnDenial` is not `false`, and `reworkRounds <= 1`.
104
+
105
+ ### `executor` and the score identity
106
+
107
+ `executor` has five required string tokens (no whitespace, no `/`): `provider`, `model`, `effort`, `tier`, `site`. The first four form the **score identity** `provider/model/effort/tier`, after `scoring.aliases` are applied. `site` is a free label (for example `local`) used by `rejectRules`.
108
+
109
+ `plan` computes the same identity for every candidate and looks up the cell for the requested task:
110
+
111
+ - `provider` = the instance's `scoreProvider`, else its driver, else the instance id;
112
+ - `model`, `effort` = the candidate's `model` and `effort`;
113
+ - `tier` = the candidate's `scoreTier`, else `serviceTier`, else `default` (this is not the `--tier` permission tier).
114
+
115
+ `decision.recommended.executor` carries exactly these four values: copy them into the record and add a `site`.
116
+
117
+ ```json
118
+ {
119
+ "date": "2026-11-23",
120
+ "taskId": "task-123",
121
+ "title": "Add retry to the sync job",
122
+ "task": "slice",
123
+ "executor": { "provider": "codex", "model": "gpt-5.3-codex", "effort": "high", "tier": "default", "site": "local" },
124
+ "scorer": "orchestrator",
125
+ "accepted": true,
126
+ "firstPass": true,
127
+ "reworkRounds": 0,
128
+ "scopeViolation": false,
129
+ "falseReport": false,
130
+ "stoppedOnDenial": null,
131
+ "durationMin": 4.2,
132
+ "quotaDelta": 3,
133
+ "note": "Verified with unit tests."
134
+ }
135
+ ```
136
+
137
+ ## Snapshot (`schemaVersion: 2`)
138
+
139
+ `plan --snapshot FILE|-` accepts this shape, a raw T3 `server.getConfig` response, or what `--t3-auto` / `--t3-origin` fetch live (which are converted to this shape). Timestamps are ISO 8601 strings.
140
+
141
+ | Field | Type | Meaning |
142
+ | --- | --- | --- |
143
+ | `schemaVersion` | `2` | Required for this shape. |
144
+ | `observedAt` | timestamp | When the snapshot was taken. |
145
+ | `source` | string | Free label (`json`, `t3-rpc`, ...). |
146
+ | `instances` | object | Keyed by instance id (the ids your config's candidates refer to). |
147
+
148
+ ### `instances.<instanceId>`
149
+
150
+ | Field | Meaning |
151
+ | --- | --- |
152
+ | `instanceId`, `driver`, `displayName` | Identity; `driver` defaults to the key. |
153
+ | `enabled`, `status` | `enabled: false` and the statuses `disabled`, `unavailable` and `not_applicable` block the candidate; `ready` is the normal state. |
154
+ | `plan` | Subscription plan label. |
155
+ | `checkedAt` | When this provider's usage was last read; compared with `pacing.maxSnapshotAgeMinutes`. |
156
+ | `models` | Optional list of model slugs. |
157
+ | `windows[]` | Quota windows (below). |
158
+ | `resetCredits` | `{ known, availableCount, nextExpiresAt, cards[] }`; a card has `creditId`, `resetType` (`claudeSession`, `claudeWeekly`, `claudeFable`, `claudeFull`, `codexRateLimits`, `custom`), `status`, `resetsLeft`, `coversWindowIds`, `coversWindowPrefixes`, `expiresAt`. |
159
+ | `budget` | Pay-as-you-go balance `{ spent, budget, balance, isAvailable, currency, month, resetsAt }`, or `null`. |
160
+
161
+ ### `windows[]`
162
+
163
+ | Field | Meaning |
164
+ | --- | --- |
165
+ | `id`, `kind`, `label` | `kind` is `session` (short window) or `weekly` (long window). |
166
+ | `usedPercent` / `remainingPercent` | One of them is enough; they must add up to 100 (±1). |
167
+ | `resetsAt` | When the window resets. |
168
+ | `windowDurationMins` | Window length; with `resetsAt` it gives the Even Pace line. |
169
+ | `pool` | Model-family pool (`gemini`, `carbon`, `argon`, ...) or `null`. |
170
+ | `modelIds`, `providerIds` | Optional restriction of the window to models/providers, or `null`. |