clearotron 0.3.2-beta.7 → 0.3.2-beta.8
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.
- package/.env.example +24 -23
- package/INSTALL.md +142 -75
- package/README.md +3 -3
- package/bin/onboard.mjs +637 -216
- package/bin/start.mjs +133 -23
- package/bin/update.mjs +58 -11
- package/build-info.json +2 -2
- package/docs/architecture/04-configuration-reference.md +26 -11
- package/docs/architecture/05-config-governance.md +17 -7
- package/driver/CHANGELOG.md +76 -0
- package/driver/band-size.mjs +59 -0
- package/driver/config-inventory.mjs +112 -9
- package/driver/contract-arm2-baseline.json +1 -3
- package/driver/contract-e3-backlog.mjs +26 -26
- package/driver/contract-vocabulary.mjs +44 -10
- package/driver/door-gates.mjs +41 -7
- package/driver/driver.config.mjs +272 -59
- package/driver/engine/CONTRACT.md +10 -3
- package/driver/engine/README.md +2 -2
- package/driver/engine/anthropic-agent.mjs +77 -21
- package/driver/engine/auth.mjs +129 -10
- package/driver/engine/jx-turn.mjs +7 -6
- package/driver/engine/mcp/recording-server.mjs +13 -0
- package/driver/engine/openai-agent.mjs +4 -2
- package/driver/engine/probe.mjs +110 -23
- package/driver/findings-model.mjs +1 -1
- package/driver/flag-snapshot.mjs +28 -5
- package/driver/gateway.mjs +24 -18
- package/driver/jx-lanes.mjs +21 -2
- package/driver/jx-units.mjs +6 -3
- package/driver/jx.mjs +4 -2
- package/driver/matter-frame-record.mjs +90 -1
- package/driver/named-band.mjs +34 -2
- package/driver/package.json +1 -1
- package/driver/pipeline.mjs +200 -23
- package/driver/portal-config-view.mjs +30 -1
- package/driver/portal-report.mjs +15 -1
- package/driver/portal-service.mjs +46 -6
- package/driver/predelivery-lint.mjs +12 -2
- package/driver/publish/index.mjs +46 -5
- package/driver/publish/knockout.mjs +10 -1
- package/driver/publish/render-knockout.mjs +69 -7
- package/driver/publish/render.mjs +170 -59
- package/driver/publish/report-data.mjs +4 -1
- package/driver/publish/report-topbar.mjs +58 -0
- package/driver/publish/templates/report.css +18 -1
- package/driver/publish/xlsx.mjs +13 -1
- package/driver/register-availability.mjs +2 -2
- package/driver/register-coverage.mjs +94 -1
- package/driver/register-digest-record.mjs +236 -11
- package/driver/register-plan.mjs +170 -0
- package/driver/result-noun-fields.mjs +2 -2
- package/driver/run-economics.mjs +41 -10
- package/driver/run-requirements.mjs +173 -9
- package/driver/runner.mjs +3 -3
- package/driver/stages.mjs +12 -8
- package/driver/suite-census.json +142 -64
- package/driver/systemd/README.md +7 -4
- package/driver/terminal-clamp.mjs +107 -1
- package/driver/tokens.mjs +169 -3
- package/driver/unit-environment.mjs +42 -15
- package/driver/unit-inventory.mjs +19 -2
- package/driver/verify.mjs +27 -0
- package/mcp-server/CHANGELOG.md +4 -0
- package/mcp-server/package.json +1 -1
- package/mcp-server/server.mjs +15 -1
- package/package.json +1 -1
- package/portal-ui/dist/assets/{index-5UyqAyNM.js → index-6jzO9HiX.js} +155 -79
- package/portal-ui/dist/index.html +1 -1
- package/portal-ui/package.json +1 -1
- package/providers/jx/README.md +2 -1
- package/providers/jx/src/turn-envelope.mjs +8 -3
- package/providers/oauth-mcp-bridge/CHANGELOG.md +4 -0
- package/providers/oauth-mcp-bridge/package.json +1 -1
- package/providers/uspto-local/README.md +1 -1
- package/scripts/authority-boundary-probe.mjs +4 -2
- package/scripts/env-audit.mjs +12 -6
- package/scripts/freeze-example-run.mjs +49 -16
- package/scripts/generated-files-are-current.mjs +69 -4
- package/scripts/settings-render-check.mjs +75 -2
- package/scripts/test-full.mjs +96 -3
- package/scripts/test-run.mjs +10 -0
- package/shared/deployment-box.mjs +7 -2
- package/shared/driver-dir.mjs +1 -1
- package/shared/names-in-force.mjs +1 -1
package/driver/tokens.mjs
CHANGED
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
import { readdirSync, readFileSync } from "node:fs";
|
|
47
47
|
import { join } from "node:path";
|
|
48
48
|
import { driverDir } from "../shared/driver-dir.mjs"; //
|
|
49
|
-
import { resolveModel } from "./driver.config.mjs";
|
|
49
|
+
import { resolveModel, modelFamily } from "./driver.config.mjs";
|
|
50
50
|
import { runLog, note } from "./log.mjs";
|
|
51
51
|
import { writeRunStatus } from "./progress.mjs";
|
|
52
|
-
import { stampRunEconomics, isCodeSide } from "./run-economics.mjs";
|
|
52
|
+
import { stampRunEconomics, isCodeSide, vendorOf } from "./run-economics.mjs";
|
|
53
53
|
|
|
54
54
|
function emptyAcc() {
|
|
55
55
|
return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, attempts: 0, thoughtTurns: 0 };
|
|
@@ -84,9 +84,27 @@ function modelKey(rec) {
|
|
|
84
84
|
// them would break byModel summing to total, and an invisible gap is the failure this file already
|
|
85
85
|
// fixed once for byEngine), and the key says what is missing rather than asserting an Anthropic
|
|
86
86
|
// model produced them.
|
|
87
|
+
//
|
|
88
|
+
// A TURN THAT NAMED NO MODEL, a native-language row recording `modelActual: null` (see isAttemptRow),
|
|
89
|
+
// has no id at all. Its tokens still account, under a key that says the model is missing rather than
|
|
90
|
+
// one built from the absent field. Such a row always carries its vendor's stamp, so it reaches here.
|
|
91
|
+
if (typeof rec.model !== "string") return `${engine || "unknown"}/no-model-reported`;
|
|
87
92
|
return `${engine}/unstamped:${rec.model}`;
|
|
88
93
|
}
|
|
89
94
|
|
|
95
|
+
/**
|
|
96
|
+
* WHETHER A ROW IS A PROVIDER ATTEMPT, the one test rollupTokens and servedModels both apply. A row that
|
|
97
|
+
* names a model is one: every stage attempt row carries the tier it asked for, and a native-language row
|
|
98
|
+
* the id its turn reported. So is a native-language row whose turn ran and named no model, which records
|
|
99
|
+
* `modelActual: null` instead (jxModelFields in jx-lanes.mjs). Without that second half, such a turn's
|
|
100
|
+
* attempt and the tokens it reported were dropped from every total, and a run made only of such turns
|
|
101
|
+
* read as one where nothing was looked at. A row with neither field is not a turn: the run log's events,
|
|
102
|
+
* a tool call, a native-language call no provider served.
|
|
103
|
+
*/
|
|
104
|
+
export function isAttemptRow(rec) {
|
|
105
|
+
return Boolean(rec) && (typeof rec.model === "string" || rec.modelActual === null);
|
|
106
|
+
}
|
|
107
|
+
|
|
90
108
|
// usage shape (gateway.mjs): {input,output,cacheRead,cacheWrite}. There is deliberately NO reasoning-token
|
|
91
109
|
// field: the old `reasoning`/`reasoningTokens` pair was an unfillable slot — no reasoning count exists
|
|
92
110
|
// anywhere in the claude payload (not result.usage, not usage.iterations), so no shipped adapter ever
|
|
@@ -128,7 +146,7 @@ export function rollupTokens(runDir) {
|
|
|
128
146
|
if (!ln.trim()) continue;
|
|
129
147
|
let rec;
|
|
130
148
|
try { rec = JSON.parse(ln); } catch { continue; }
|
|
131
|
-
if (!rec
|
|
149
|
+
if (!isAttemptRow(rec)) continue; // only provider attempts carry tokens (see isAttemptRow)
|
|
132
150
|
const t = tokensOf(rec.usage);
|
|
133
151
|
const accs = [total, (byStage[stage] ??= emptyAcc()), (byModel[modelKey(rec)] ??= emptyAcc())];
|
|
134
152
|
// Engine and billing mode are split out because a token is not a portable unit of cost: a turn on a
|
|
@@ -168,6 +186,154 @@ export function rollupTokens(runDir) {
|
|
|
168
186
|
return { total, byStage, byModel, byEngine, byAuthMode };
|
|
169
187
|
}
|
|
170
188
|
|
|
189
|
+
/**
|
|
190
|
+
* THE MODELS THAT SERVED THIS RUN, as the engine reported them: distinct ids, in the order each first
|
|
191
|
+
* served a turn. Read from every attempt row's `modelActual`, the id the wire named: the stage rows
|
|
192
|
+
* gateway.mjs writes and the native-language rows jx.mjs and jx-units.mjs write, one list across both. Never
|
|
193
|
+
* the tier a stage asked for in place of a model the wire named: a tier goes to the CLI as the vendor's
|
|
194
|
+
* alias, so the request says nothing about which model ran, and this is the record that does. The tier
|
|
195
|
+
* stands in only for a name no client may read (below).
|
|
196
|
+
*
|
|
197
|
+
* THREE-VALUED. `null` when there is no attempt row to read (no telemetry directory, or no row in it is
|
|
198
|
+
* a provider turn), so nothing was looked at. `[]` when attempt rows exist and none names a served model
|
|
199
|
+
* a client may read (an engine that does not report one, a turn killed before it said, a turn the Claude
|
|
200
|
+
* program answered itself), on a stage turn and a native-language turn alike. One more case reads `[]`:
|
|
201
|
+
* a Claude turn served under a deployment name whose requested tier the tier reader cannot place (a request
|
|
202
|
+
* outside opus, sonnet, haiku and fable) is left off, because the name must not be printed and there is no
|
|
203
|
+
* tier word to print instead. In a run that mixes such turns with others, the list names only the others.
|
|
204
|
+
* So does a turn stamped by an engine whose vendor the closed table in run-economics.mjs does not name:
|
|
205
|
+
* nobody can say whose model served it. An empty list is never a guess.
|
|
206
|
+
*
|
|
207
|
+
* WHAT IS LISTED IS WHAT A CLIENT MAY READ, mapped here and nowhere else (servedName below), so meta.json,
|
|
208
|
+
* report-data.json and the report's closing line carry one list and cannot disagree. Through a cloud, a
|
|
209
|
+
* turn reports either that cloud's spelling of a Claude model or a name the company gave its own
|
|
210
|
+
* deployment. The first is listed as the Claude id it names; the second is listed as the tier the turn
|
|
211
|
+
* asked for ("Opus"), never as the name. The attempt row itself keeps what the program reported.
|
|
212
|
+
*/
|
|
213
|
+
export function servedModels(runDir) {
|
|
214
|
+
const dDir = driverDir(runDir);
|
|
215
|
+
let files;
|
|
216
|
+
try { files = readdirSync(dDir).filter((f) => f.endsWith(".jsonl") && f !== "run.jsonl"); }
|
|
217
|
+
catch { return null; }
|
|
218
|
+
const firstSeen = new Map(); // id → the earliest row timestamp that named it
|
|
219
|
+
let attempts = 0;
|
|
220
|
+
for (const file of files) {
|
|
221
|
+
let raw;
|
|
222
|
+
try { raw = readFileSync(join(dDir, file), "utf8"); } catch { continue; }
|
|
223
|
+
for (const ln of raw.split("\n")) {
|
|
224
|
+
if (!ln.trim()) continue;
|
|
225
|
+
let rec;
|
|
226
|
+
try { rec = JSON.parse(ln); } catch { continue; }
|
|
227
|
+
// The same test rollupTokens applies for an attempt row, less the driver's own code-side rows:
|
|
228
|
+
// no provider served those, so they cannot stand for "a turn ran and named no model".
|
|
229
|
+
if (!isAttemptRow(rec) || isCodeSide(rec)) continue;
|
|
230
|
+
attempts += 1;
|
|
231
|
+
const id = typeof rec.modelActual === "string" ? rec.modelActual.trim() : "";
|
|
232
|
+
// `<synthetic>` is the Claude CLI's name for a message it wrote itself, measured in testing on a
|
|
233
|
+
// turn a cloud refused for a missing deployment (2026-09-14). No model served that turn, so a
|
|
234
|
+
// bracketed marker is never listed as one.
|
|
235
|
+
if (!id || /^<.*>$/.test(id)) continue;
|
|
236
|
+
// Keyed on the name a client reads, so two deployments serving one tier, or one model reached
|
|
237
|
+
// through two clouds, are listed once.
|
|
238
|
+
const name = servedName(rec, id);
|
|
239
|
+
if (!name) continue;
|
|
240
|
+
const ts = String(rec.ts ?? "");
|
|
241
|
+
if (!firstSeen.has(name) || ts < firstSeen.get(name)) firstSeen.set(name, ts);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (!attempts) return null;
|
|
245
|
+
return [...firstSeen].sort((a, b) => (a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0)).map(([id]) => id);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// Imported here, beside its one reader: the tier every native-language step asks for (see servedName).
|
|
249
|
+
import { JX_TIER } from "./engine/jx-turn.mjs";
|
|
250
|
+
|
|
251
|
+
// AMAZON'S SPELLING OF A CLAUDE ID: an optional cross-region prefix (`us.`, `eu.`, `apac.`, `global.`), the
|
|
252
|
+
// vendor prefix `anthropic.`, and a version suffix (`-v1:0`), optionally at the end of an inference
|
|
253
|
+
// profile's full address (`arn:aws:bedrock:<region>:<account>:inference-profile/…`), whose account number
|
|
254
|
+
// is the company's and is dropped with the rest. `us.anthropic.claude-opus-4-1-20250805-v1:0` is
|
|
255
|
+
// `claude-opus-4-1-20250805`. Anchored on `anthropic.claude-`, so no other vendor's id is rewritten.
|
|
256
|
+
const AMAZON_CLAUDE_ID_RE = /^(?:arn:aws[\w-]*:bedrock:[^/]*\/)?(?:[a-z]{2,6}(?:-[a-z]+)?\.)?anthropic\.(claude-[a-z0-9.-]+?)(?:-v\d+(?::\d+)?)?$/i;
|
|
257
|
+
// GOOGLE'S SPELLING, `claude-opus-4-1@20250805`. It already names the model; it is listed as the dated id
|
|
258
|
+
// `claude-opus-4-1-20250805` because that is the same model's name on Anthropic's own API and on Amazon's,
|
|
259
|
+
// so a model reached through two routes is one entry rather than two spellings of one model. An older
|
|
260
|
+
// model's Google name carries a version mark before the date (`claude-3-5-sonnet-v2@20241022`), the same
|
|
261
|
+
// mark Amazon writes as `-v2:0`; it is not in the model's own name, so it goes too.
|
|
262
|
+
const GOOGLE_CLAUDE_ID_RE = /^(claude-[a-z0-9.-]+?)(?:-v\d+)?@(\d{8})$/i;
|
|
263
|
+
// THE SHAPE OF A CLAUDE MODEL ID, which is what lets an id be printed as itself. A family and one or two
|
|
264
|
+
// version numbers (`claude-opus-4-1`), or the older order of version before family
|
|
265
|
+
// (`claude-3-5-sonnet`); then an optional date; then an optional context-window mark (`[1m]`), which
|
|
266
|
+
// the program may report beside the model and is kept as reported. Tested lower-cased, after the cloud
|
|
267
|
+
// spellings above are rewritten. A prefix test is not enough: a company may name its own deployment
|
|
268
|
+
// `claude-acme-prod`, or wrap its own name in Amazon's form, and neither is a Claude model. A family with
|
|
269
|
+
// no version, `claude-opus`, names no model either: it is the name an operator types for a deployment of
|
|
270
|
+
// that tier, and printed as itself it would put that name on the report, and a Sonnet deployment's name
|
|
271
|
+
// on a turn that asked for Haiku. A `latest` alias, `-latest` or Google's `@latest`, is a pointer the
|
|
272
|
+
// provider moves, never the name of the model a turn reports, so it reads as the tier too.
|
|
273
|
+
const CLAUDE_MODEL_ID_RE = /^claude-(?:(?:opus|sonnet|haiku|fable)(?:-\d{1,2}){1,2}|\d(?:-\d)?-(?:opus|sonnet|haiku))(?:-\d{8})?(?:\[\d+[km]\])?$/;
|
|
274
|
+
const CLAUDE_TIERS = new Set(["opus", "sonnet", "haiku", "fable"]); // fable is reached through the synthesis override
|
|
275
|
+
// A FABLE REQUEST IS READ HERE, NOT BY modelFamily. modelFamily is also the gateway's family comparison on every
|
|
276
|
+
// turn, and it places opus, sonnet and haiku only: an id naming fable stays unknown there, so it can never
|
|
277
|
+
// refuse a turn (driver.config.mjs says why). The report still needs the tier word of a fable turn served under
|
|
278
|
+
// a company's deployment name, so it is read for the report alone, placed where the family reader places the
|
|
279
|
+
// other three: the whole request, or first in it or after a `/`, with or without `claude-`. So `fable` and a
|
|
280
|
+
// request in a pinned id's spelling (`claude-fable-5-1`) both read fable, and `acme-fable` does not. A turn
|
|
281
|
+
// served as a fable id never reaches this: that id is a Claude model's name and prints as itself. modelFamily is
|
|
282
|
+
// asked first, so a request it places reads as that tier even when it also names fable (`fable-x/sonnet` is
|
|
283
|
+
// Sonnet), and one it cannot place falls through to this reader (`sonnet/fable-x` is Fable).
|
|
284
|
+
const FABLE_REQUEST_RE = /(?:^|\/)(?:claude-)?fable(?:[-.]|$)/i;
|
|
285
|
+
const requestedTier = (asked) =>
|
|
286
|
+
modelFamily(asked) ?? (FABLE_REQUEST_RE.test(String(resolveModel(asked) ?? "")) ? "fable" : null);
|
|
287
|
+
|
|
288
|
+
/** A Claude model id in any cloud's spelling, as its own lower-case name, or null when it is not one. */
|
|
289
|
+
function claudeModelId(id) {
|
|
290
|
+
const raw = String(id ?? "").trim();
|
|
291
|
+
const amazon = AMAZON_CLAUDE_ID_RE.exec(raw);
|
|
292
|
+
const google = amazon ? null : GOOGLE_CLAUDE_ID_RE.exec(raw);
|
|
293
|
+
const named = (amazon ? amazon[1] : google ? `${google[1]}-${google[2]}` : raw).toLowerCase();
|
|
294
|
+
return CLAUDE_MODEL_ID_RE.test(named) ? named : null;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* The name a client reads for one served id, or null when it must not be listed.
|
|
299
|
+
*
|
|
300
|
+
* A CLAUDE ID, in any cloud's spelling, is the model it names. ANY OTHER ID ON A CLAUDE TURN names no
|
|
301
|
+
* Claude model, and on Azure Foundry that is the name a company gave its deployment (`acme-prod-opus`): a
|
|
302
|
+
* company's internal name, and never one to print on its client's report. The turn is listed as the tier
|
|
303
|
+
* it asked for instead, which is what the company deployed under that name.
|
|
304
|
+
*
|
|
305
|
+
* WHOSE TURN IT WAS IS THE VENDOR'S QUESTION, answered by the one closed table of engines (vendorOf in
|
|
306
|
+
* run-economics.mjs), not by a list kept here. An OpenAI turn's id is listed as reported: a Codex id is the
|
|
307
|
+
* model's own name. An Anthropic turn under any engine name is mapped as above; a second list of Claude
|
|
308
|
+
* engines here printed a deployment name, as reported, for every engine it left out. An engine the table
|
|
309
|
+
* does not name is left off: printing its id would make a vendor claim nobody can check.
|
|
310
|
+
*
|
|
311
|
+
* A ROW WITH NO ENGINE STAMP reads as Claude's, as modelKey above reads it, EXCEPT when the id is plainly
|
|
312
|
+
* another vendor's (a `gpt-` or o-series id, by modelFamily's OpenAI reader): printing that as a Claude
|
|
313
|
+
* tier would put a false vendor on a client's report, where a wrong guess in modelKey costs only a key.
|
|
314
|
+
*/
|
|
315
|
+
function servedName(rec, id) {
|
|
316
|
+
const claude = claudeModelId(id);
|
|
317
|
+
if (claude) return claude;
|
|
318
|
+
const engine = typeof rec.engine === "string" ? rec.engine : "";
|
|
319
|
+
const family = engine ? null : modelFamily(id);
|
|
320
|
+
const vendor = engine ? vendorOf(engine) : family && !CLAUDE_TIERS.has(family) ? "openai" : "anthropic";
|
|
321
|
+
if (vendor === "openai") return id;
|
|
322
|
+
if (vendor !== "anthropic") return null;
|
|
323
|
+
// THE TIER THE TURN ASKED FOR, told apart by the kind of row, which its engine stamp names. A stage row
|
|
324
|
+
// (engine "anthropic-agent", another Anthropic engine, or no stamp) records that request as `model`
|
|
325
|
+
// ("opus"), and that holds even when the served id is spelled the same as the request, as it is for a
|
|
326
|
+
// deployment named after its tier. A native-language row (engine "anthropic") records its SERVED id as `model`, beside
|
|
327
|
+
// `modelActual` (jxModelFields), so reading it as the request would hand back the deployment name;
|
|
328
|
+
// every one of those steps asks for JX_TIER. A request in a cloud's spelling is read as the Claude id it
|
|
329
|
+
// names first. modelFamily reads opus, sonnet and haiku, and requestedTier adds fable, for the report
|
|
330
|
+
// alone. A tier neither can place returns null and the id is left off: listing nothing is honest, and
|
|
331
|
+
// listing the name is the leak this prevents.
|
|
332
|
+
const asked = engine === "anthropic" ? JX_TIER : rec.model;
|
|
333
|
+
const tier = requestedTier(claudeModelId(asked) ?? asked);
|
|
334
|
+
return CLAUDE_TIERS.has(tier) ? tier[0].toUpperCase() + tier.slice(1) : null;
|
|
335
|
+
}
|
|
336
|
+
|
|
171
337
|
/**
|
|
172
338
|
* Stamp the rollup onto the run: the `token-rollup` event in _driver/run.jsonl plus `status.json.tokens`.
|
|
173
339
|
*
|
|
@@ -51,36 +51,63 @@ const OPTIONAL = "-";
|
|
|
51
51
|
* @returns {{path: string}|{unresolved: string}}
|
|
52
52
|
*/
|
|
53
53
|
function expandSpecifiers(raw, home) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
// ONE PASS, LEFT TO RIGHT, as systemd reads them. `%%` is an escaped percent and becomes one `%`, so
|
|
55
|
+
// `%%h` is a literal `%h`, never the home. Replacing `%h` first and unescaping after read `%%h` as a
|
|
56
|
+
// `%` followed by the home, and left `50%%` doubled, so a value reached doctor and connect in a form
|
|
57
|
+
// the service was never given. Any other letter after a `%` is a specifier this reader does not
|
|
58
|
+
// implement.
|
|
59
|
+
let unresolved = false;
|
|
60
|
+
const path = String(raw).replace(/%([%A-Za-z])/g, (whole, c) => {
|
|
61
|
+
if (c === "%") return "%";
|
|
62
|
+
if (c === "h" && home) return home;
|
|
63
|
+
unresolved = true;
|
|
64
|
+
return whole;
|
|
65
|
+
});
|
|
66
|
+
return unresolved ? { unresolved: raw } : { path };
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
/**
|
|
62
|
-
* Merge one unit file's environment directives
|
|
70
|
+
* Merge one unit file's environment directives THE WAY SYSTEMD MERGES THEM: every `Environment=`
|
|
71
|
+
* assignment first, then every `EnvironmentFile=`'s contents over them, the files in the order listed.
|
|
63
72
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
73
|
+
* WHERE A LINE SITS DOES NOT DECIDE IT. systemd.exec(5) on `EnvironmentFile=`: "Settings from these files
|
|
74
|
+
* override settings made with Environment=." This reader used to apply the two kinds in file order, so a
|
|
75
|
+
* name set by both came back with the unit's value whenever its `Environment=` line followed the file,
|
|
76
|
+
* which is how every shipped unit is written, while the service ran with the file's. A PATH in the
|
|
77
|
+
* settings file was the case that showed: doctor looked for the engine's program on the unit's PATH,
|
|
78
|
+
* found it, and passed a machine whose services would not find it. The renderer's header
|
|
79
|
+
* (driver/systemd/render-units.mjs) states the same rule, and one unit loads no settings file because of it.
|
|
80
|
+
*
|
|
81
|
+
* Within each kind a later assignment still overrides an earlier one.
|
|
68
82
|
*
|
|
69
83
|
* @param {string} unitText the unit file's contents
|
|
70
84
|
* @param {(path: string) => string|null} readEnvFile returns the file's text, or null if unreadable
|
|
71
|
-
* @returns {{env: Object, missing: string[]}} `missing` names REQUIRED files that could not be read
|
|
85
|
+
* @returns {{env: Object, missing: string[]}} `missing` names REQUIRED files that could not be read, and
|
|
86
|
+
* assignments whose value carries a specifier that could not be expanded
|
|
72
87
|
*/
|
|
73
88
|
function applyUnit(unitText, readEnvFile, home) {
|
|
74
89
|
const env = {};
|
|
90
|
+
const fromFiles = {};
|
|
75
91
|
const missing = [];
|
|
76
92
|
for (const raw of String(unitText ?? "").split("\n")) {
|
|
77
93
|
const line = raw.trim();
|
|
78
94
|
// `Environment=` may carry several assignments on one line; systemd splits on whitespace.
|
|
95
|
+
//
|
|
96
|
+
// ITS VALUES ARE EXPANDED TOO, by the same rule as a file path. Every shipped unit writes
|
|
97
|
+
// `Environment=PATH=%h/.local/bin:%h/.npm-global/bin:…`, and systemd hands the service that PATH with
|
|
98
|
+
// the home filled in. Passed through as written, it named a folder called `%h/.local/bin` that exists
|
|
99
|
+
// nowhere, so a check that looked for the engine's program on the units' PATH found nothing on a
|
|
100
|
+
// machine whose searches found it and ran. A value that cannot be expanded is a hole in the picture,
|
|
101
|
+
// for the reason the file branch below gives: a literal `%h` answers "absent" for a reader that
|
|
102
|
+
// failed.
|
|
79
103
|
const direct = /^Environment=(.*)$/.exec(line);
|
|
80
104
|
if (direct) {
|
|
81
105
|
for (const pair of direct[1].trim().split(/\s+/)) {
|
|
82
106
|
const m = /^"?([A-Za-z_][A-Za-z0-9_]*)=(.*?)"?$/.exec(pair);
|
|
83
|
-
if (m)
|
|
107
|
+
if (!m) continue;
|
|
108
|
+
const value = expandSpecifiers(m[2], home);
|
|
109
|
+
if (value.unresolved !== undefined) missing.push(`${m[1]}=${value.unresolved} (unresolved systemd specifier)`);
|
|
110
|
+
else env[m[1]] = value.path;
|
|
84
111
|
}
|
|
85
112
|
continue;
|
|
86
113
|
}
|
|
@@ -106,10 +133,10 @@ function applyUnit(unitText, readEnvFile, home) {
|
|
|
106
133
|
if (!optional) missing.push(path);
|
|
107
134
|
continue;
|
|
108
135
|
}
|
|
109
|
-
Object.assign(
|
|
136
|
+
Object.assign(fromFiles, parseEnvFile(text));
|
|
110
137
|
}
|
|
111
138
|
}
|
|
112
|
-
return { env, missing };
|
|
139
|
+
return { env: { ...env, ...fromFiles }, missing };
|
|
113
140
|
}
|
|
114
141
|
|
|
115
142
|
/**
|
|
@@ -143,7 +170,7 @@ export function unitEnvironment({ units = [], readEnvFile = () => null, home = n
|
|
|
143
170
|
// name we did not find might live in it — and reporting those as absent would be the original bug
|
|
144
171
|
// with a smaller blast radius. The whole picture is refused instead.
|
|
145
172
|
return { known: false, env, read,
|
|
146
|
-
why: `the units require environment file(s) this command could not read: ${[...new Set(holes)].join(", ")}` };
|
|
173
|
+
why: `the units require environment file(s) or values this command could not read: ${[...new Set(holes)].join(", ")}` };
|
|
147
174
|
}
|
|
148
175
|
return { known: true, env, read, why: null };
|
|
149
176
|
}
|
|
@@ -73,7 +73,24 @@
|
|
|
73
73
|
// it for current state.)
|
|
74
74
|
|
|
75
75
|
/** Where a unit is expected to be installed. "none" is a claim, not an absence — see ORPHANED below. */
|
|
76
|
-
export const BOXES = Object.freeze(["prod", "test", "dev"]);
|
|
76
|
+
export const BOXES = Object.freeze(["prod", "preprod", "test", "dev"]);
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Whose DECLARED units a box is expected to carry, where that is not its own name.
|
|
80
|
+
*
|
|
81
|
+
* `runsOn` is a MEASURED claim — this file says so in as many words: an entry gains a box the day an
|
|
82
|
+
* enumeration of that box shows the unit, never the day somebody intends it. So pre-prod cannot be
|
|
83
|
+
* written into `runsOn` from a machine that has not enumerated pre-prod, and it must not be: that would
|
|
84
|
+
* turn a measurement into a plan, which is the one thing these entries are not.
|
|
85
|
+
*
|
|
86
|
+
* What CAN be stated from here is the expectation. Pre-prod is a packaged install of the same product on
|
|
87
|
+
* its own account, with the same doors and the same worker, so what it is expected to carry is what
|
|
88
|
+
* production is expected to carry. The expectation derives; the measurement stays measured; and a unit
|
|
89
|
+
* genuinely absent on pre-prod is reported rather than skipped, which is the whole point of the box
|
|
90
|
+
* being able to name itself.
|
|
91
|
+
*/
|
|
92
|
+
const EXPECTS_LIKE = Object.freeze({ preprod: "prod" });
|
|
93
|
+
const expectationBox = (box) => EXPECTS_LIKE[box] ?? box;
|
|
77
94
|
|
|
78
95
|
// ── RESOLVED UNITS (ruling 2026-08-25 — option B) ──────────────────────
|
|
79
96
|
//
|
|
@@ -773,7 +790,7 @@ export function unitInventoryVerdict({
|
|
|
773
790
|
// unit that is gone from a box is the ruling taking effect, not drift; reporting it as a fault trains
|
|
774
791
|
// a reader to skim the arm that would have caught a real one. Both are still REPORTED — the
|
|
775
792
|
// distinction is which of them is a fault.
|
|
776
|
-
const declaredHere = (u) => box && u.runsOn.includes(box) && !liveBases.includes(u.unit);
|
|
793
|
+
const declaredHere = (u) => box && u.runsOn.includes(expectationBox(box)) && !liveBases.includes(u.unit);
|
|
777
794
|
const absent = box
|
|
778
795
|
? inventory.filter((u) => declaredHere(u) && !u.retired).map((u) => u.unit).sort()
|
|
779
796
|
: [];
|
package/driver/verify.mjs
CHANGED
|
@@ -42,6 +42,7 @@ import { parseNamedBand, findCollapsedBands } from "./named-band.mjs";
|
|
|
42
42
|
import { parseBlindFrameModel } from "./blind-frame-model.mjs";
|
|
43
43
|
import { parseFrameDiff } from "./frame-diff-model.mjs";
|
|
44
44
|
import { parseVariantManifestModel, variantRomanizationGaps, variantCompletenessGaps, variantTermShapeGaps } from "./variant-manifest-model.mjs";
|
|
45
|
+
import { digestAccountingGap } from "./register-digest-record.mjs";
|
|
45
46
|
|
|
46
47
|
// ── WS-B: the run-scoped profile sidecar ────────────────────────────────────────────────────────────
|
|
47
48
|
// _driver/profile.json carries the run's frozen customer values (floor, platform list) for these
|
|
@@ -2087,6 +2088,32 @@ export const validators = {
|
|
|
2087
2088
|
], "findings+ledger"),
|
|
2088
2089
|
hasCoverageLedgerRow(c) ? ok() : fail("no_coverage_status_row"));
|
|
2089
2090
|
if (!structural.ok) return structural;
|
|
2091
|
+
// ── EVERY RECORD THE RUN CARRIED IN ENDS SOMEWHERE — CHECKED AT THE EXIT, NOT ONLY AT THE CALL ──
|
|
2092
|
+
//
|
|
2093
|
+
// The call-time refusal is scoped to the batch it judges, which is what lets a dense band be
|
|
2094
|
+
// recorded at all: a 1,161-record band does not fit in one turn, and the stage failed on one for 35
|
|
2095
|
+
// minutes without writing a document. It buys that at a price, and this is where the price is paid.
|
|
2096
|
+
// Once batch 1 is accepted the findings document EXISTS, so a seat that stopped after batch 6 no
|
|
2097
|
+
// longer fails as a missing artifact — it ships a document holding half the band, with every call it
|
|
2098
|
+
// made reading as accepted. Nothing else would notice: this stage's other arms read the document's
|
|
2099
|
+
// shape, and half a band is the same shape as a whole one.
|
|
2100
|
+
//
|
|
2101
|
+
// ARMED BY THE SAME ERA STAMP as the call-time rule, so an archived run carries no stamp and replays
|
|
2102
|
+
// to the verdict it always had. A STAMPED run whose transport stored no model is a driver fault and
|
|
2103
|
+
// is named as one, on `coverage_form_missing`'s precedent below and for its reason: an absent
|
|
2104
|
+
// artifact must never read as a satisfied one. A throw fails closed for the same reason — this gate
|
|
2105
|
+
// going quiet is indistinguishable from a complete digest, which is the state it exists to refuse.
|
|
2106
|
+
{
|
|
2107
|
+
let gap;
|
|
2108
|
+
try { gap = digestAccountingGap(dirname(p)); }
|
|
2109
|
+
catch (e) { return fail(`registerdigest_accounting_unreadable:${short(String(e?.message ?? e))} (driver-written — this is a bug, not a model defect)`.slice(0, 200)); }
|
|
2110
|
+
if (gap.armed && gap.unaccounted === null)
|
|
2111
|
+
return fail("registerdigest_accounting_unreadable: stamped for per-record accounting with no owed list in the driver's facts (driver-written — this is a bug, not a model defect)");
|
|
2112
|
+
if (gap.armed && gap.no_model)
|
|
2113
|
+
return fail("registerdigest_model_missing: stamped for per-record accounting and the typed transport stored no model, while the findings document exists (driver-written — this is a bug, not a model defect)");
|
|
2114
|
+
if (gap.armed && gap.unaccounted.length)
|
|
2115
|
+
return fail(`registerdigest_unaccounted_records:${gap.unaccounted.length} of ${gap.owed.length} — ${gap.unaccounted.slice(0, 6).join(",")}${gap.unaccounted.length > 6 ? ` (+${gap.unaccounted.length - 6} more)` : ""}`.slice(0, 200));
|
|
2116
|
+
}
|
|
2090
2117
|
// ── THE COVERAGE FORM, AND THE FOUR STATES THAT ARE NOT THE SAME FACT ──────────────────────────
|
|
2091
2118
|
// not required — no era stamp: EVERY ARCHIVED RUN, and nothing else since M6. A run
|
|
2092
2119
|
// whose plan apparatus is out of reach used to land here too; it now gets a
|
package/mcp-server/CHANGELOG.md
CHANGED
package/mcp-server/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trademark-artifacts-mcp",
|
|
3
|
-
"version": "0.3.2-beta.
|
|
3
|
+
"version": "0.3.2-beta.8",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"private": true,
|
|
6
6
|
"description": "MCP server to interrogate clearotron trademark-clearance runs — list/read artifacts, trace the full decision flow, telemetry/cost, coverage, single-run search, and a gated single-step what-if. Imports the clearotron-driver read-only; touches no driver/template/deploy files.",
|
package/mcp-server/server.mjs
CHANGED
|
@@ -31,7 +31,7 @@ import { join, basename } from "node:path";
|
|
|
31
31
|
import { driverDir } from "../shared/driver-dir.mjs"; //
|
|
32
32
|
import { fileURLToPath } from "node:url";
|
|
33
33
|
|
|
34
|
-
import { enumerateRuns, resolveRun, runAccountKey, runOrganisation, runProfileFacts } from "./lib/runs.mjs";
|
|
34
|
+
import { enumerateRuns, resolveRun, runAccountKey, runOrganisation, runProfileFacts, productIdentityFor } from "./lib/runs.mjs";
|
|
35
35
|
import { ORDERABLE_PRODUCTS } from "../driver/search-policy.mjs";
|
|
36
36
|
import { PRODUCTS } from "../driver/products.mjs";
|
|
37
37
|
|
|
@@ -193,6 +193,20 @@ function runSummary(run) {
|
|
|
193
193
|
? { key: facts.account, name: facts.clientName }
|
|
194
194
|
: { key: null, name: null, known: false, note: "this run's client could not be read from its own record" },
|
|
195
195
|
project: facts.projectKey ? { key: facts.projectKey, name: facts.projectName ?? facts.projectKey } : null,
|
|
196
|
+
// WHAT KIND OF SEARCH IT WAS, on every row, and it is the same defect as the client above one turn
|
|
197
|
+
// later. A mark and a date do not name one run: on the bundled demo data alone, one mark and one day
|
|
198
|
+
// return nine rows across four products — a full country search, a multi-country focus search, a
|
|
199
|
+
// global preliminary search and two knockouts. A session bound to one report is safe whatever the
|
|
200
|
+
// row says, because the scope carries the runId; an account-scoped session has only these rows, and
|
|
201
|
+
// nothing in them told the two apart except the runId string, which is an internal slug a client has
|
|
202
|
+
// never seen and which this tool's own description warns is not theirs to read.
|
|
203
|
+
//
|
|
204
|
+
// RESOLVED AT READ TIME THROUGH THE REGISTRY, never a stored string, for the reason `runs.mjs` gives
|
|
205
|
+
// where this resolver lives: a run freezes its product ID and the name is today's name, so the row,
|
|
206
|
+
// the brief and the report masthead cannot disagree and a renamed product renames everywhere at
|
|
207
|
+
// once. null where the registry cannot name it — the row says nothing rather than guessing, because
|
|
208
|
+
// a hardcoded fallback is how a knockout once announced itself as a product it provably was not.
|
|
209
|
+
product: productIdentityFor(run),
|
|
196
210
|
state: run.state, location: run.location, verdict: run.verdict, url: run.url,
|
|
197
211
|
markName: run.markName, ref: run.ref, classes: run.classes,
|
|
198
212
|
step: s.stepN ? `${s.stepN}/${s.stepTotal} ${s.stepLabel ?? ""}`.trim() : null,
|