clearotron 0.6.0 → 0.7.0-beta.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.
- package/INSTALL.md +7 -4
- package/QUICKSTART.md +1 -0
- package/README.md +5 -2
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/bin/clearotron.mjs +4 -2
- package/bin/onboard.mjs +158 -29
- package/build-info.json +2 -2
- package/docs/CLIENT-MCP.md +3 -1
- package/docs/DELIVERY.md +6 -3
- package/docs/architecture/02-architecture.md +1 -1
- package/docs/branding.md +4 -4
- package/docs/report-data/clearance-1.schema.json +320 -0
- package/docs/report-data/knockout-1.schema.json +268 -0
- package/driver/CHANGELOG.md +39 -0
- package/driver/connotation-search.mjs +1 -1
- package/driver/contract-e3-backlog.mjs +1 -1
- package/driver/coverage-ledger.mjs +18 -2
- package/driver/deferral-row.mjs +1 -1
- package/driver/degraded-parts.mjs +1 -0
- package/driver/driver.config.mjs +4 -3
- package/driver/effective-scope.mjs +3 -1
- package/driver/engagement-receipt.mjs +3 -3
- package/driver/engine/anthropic-agent.mjs +15 -1
- package/driver/engine/common.mjs +7 -0
- package/driver/engine/mcp/band-server.mjs +7 -16
- package/driver/engine/mcp/codex-config.mjs +3 -0
- package/driver/engine/mcp/recording-server.mjs +45 -34
- package/driver/engine/openai-agent.mjs +74 -7
- package/driver/gateway.mjs +67 -10
- package/driver/jx.mjs +13 -5
- package/driver/manuals-seen.mjs +146 -0
- package/driver/mark-logos.mjs +144 -0
- package/driver/methodology-witness.mjs +2 -1
- package/driver/owner-use-check.mjs +3 -3
- package/driver/package.json +1 -1
- package/driver/pipeline-knockout.mjs +4 -0
- package/driver/pipeline.mjs +92 -7
- package/driver/portal-local-auth.mjs +6 -2
- package/driver/portal-report.mjs +43 -12
- package/driver/portal-routes/me.mjs +4 -1
- package/driver/portal-runs.mjs +6 -9
- package/driver/profiles.mjs +4 -4
- package/driver/publish/README.md +9 -7
- package/driver/publish/email-conditions.mjs +2 -2
- package/driver/publish/evidence-words.mjs +21 -0
- package/driver/publish/index.mjs +104 -90
- package/driver/publish/knockout.mjs +75 -49
- package/driver/publish/office-record-links.mjs +11 -9
- package/driver/publish/page-shell.mjs +98 -0
- package/driver/publish/publish-inputs.mjs +4 -0
- package/driver/publish/regions.mjs +24 -3
- package/driver/publish/register-record.mjs +150 -0
- package/driver/publish/render-knockout.mjs +195 -642
- package/driver/publish/render.mjs +270 -363
- package/driver/publish/report-data.mjs +225 -12
- package/driver/publish/strings.mjs +662 -0
- package/driver/publish/templates/knockout.css +200 -0
- package/driver/publish/templates/report.css +72 -52
- package/driver/publish/xlsx.mjs +148 -125
- package/driver/record-goods.mjs +42 -0
- package/driver/reference-score.mjs +4 -1
- package/driver/register-reach.mjs +39 -0
- package/driver/registry-fidelity.mjs +3 -8
- package/driver/repair-composers.mjs +6 -2
- package/driver/repair-targets.mjs +4 -1
- package/driver/run-delivered.mjs +6 -1
- package/driver/runner.mjs +73 -29
- package/driver/scope-facts.mjs +27 -6
- package/driver/search-policy.mjs +9 -4
- package/driver/stages.mjs +3 -3
- package/driver/steps/overview-and-cards.mjs +50 -14
- package/driver/steps/verdict-gate.mjs +33 -13
- package/driver/suite-census.json +368 -68
- package/driver/terminal-clamp.mjs +6 -1
- package/mcp-server/CHANGELOG.md +4 -0
- package/mcp-server/lib/audit-view.mjs +5 -2
- package/mcp-server/lib/brief.mjs +2 -1
- package/mcp-server/lib/evidence.mjs +31 -4
- package/mcp-server/lib/knockout.mjs +1 -1
- package/mcp-server/lib/scrub.mjs +1 -1
- package/mcp-server/package.json +1 -1
- package/mcp-server/server.mjs +5 -3
- package/package.json +4 -1
- package/portal-ui/dist/assets/{index-CYaO2ygd.js → index-CtkllKJ2.js} +225 -77
- package/portal-ui/dist/assets/{index-izLa9apq.css → index-CxAkJXIT.css} +25 -5
- package/portal-ui/dist/index.html +2 -2
- package/portal-ui/package.json +3 -3
- package/providers/_shared/ledger.mjs +30 -2
- package/providers/_shared/record-uri.mjs +15 -0
- package/providers/clarivate/src/adapter.js +11 -0
- package/providers/clarivate/src/core.js +17 -1
- package/providers/oauth-mcp-bridge/CHANGELOG.md +4 -0
- package/providers/oauth-mcp-bridge/package.json +1 -1
- package/scripts/README.md +147 -3
- package/scripts/e2e-first-time.mjs +3 -3
- package/scripts/freeze-example-run.mjs +3 -3
- package/scripts/mint-search-level-tags.mjs +61 -0
- package/scripts/mint-source-pin-census.mjs +89 -0
- package/scripts/release-note-required.mjs +65 -6
- package/scripts/test-durations-reporter.mjs +25 -0
- package/scripts/test-full.mjs +72 -18
- package/scripts/test-run.mjs +18 -1
- package/shared/brand.mjs +85 -5
- package/shared/inline-markdown.mjs +53 -0
- package/shared/portal-tokens.mjs +2 -1
- package/shared/register-selection.mjs +8 -3
- package/shared/search-level-tags.json +25 -0
- package/shared/tools/derive-band-pairs.mjs +10 -0
- package/driver/own-rights.mjs +0 -83
- package/driver/use-check.mjs +0 -85
package/driver/gateway.mjs
CHANGED
|
@@ -262,6 +262,7 @@ import { progressQuantity } from "./repairs.mjs";
|
|
|
262
262
|
// SIBLING ARTIFACT rather than the fail string, because the fail string is cut at 160 chars.
|
|
263
263
|
import { undispatchableFiringDirectives } from "./frame-diff-model.mjs";
|
|
264
264
|
import { witnessStageMethodology, describeMethodologyDrift } from "./methodology-witness.mjs";
|
|
265
|
+
import { measureManualsSeen } from "./manuals-seen.mjs";
|
|
265
266
|
// — the meaning-sweep form and its accumulator. Both PURE and acyclic: connotation-search.mjs
|
|
266
267
|
// imports nothing, disposition-union.mjs imports only it, and neither reaches back here.
|
|
267
268
|
import { parsePrRiskResults, connotationObligations, parseDispositionForm, CONNOTATION_FORM_TOKEN_SRC,
|
|
@@ -351,10 +352,11 @@ export function spentBudgetCleanly({ fail, killed, code, wall, derivedLimitSec }
|
|
|
351
352
|
// — THE TOOL GAUGE, AND WHY NULL IS NOT ZERO HERE EITHER.
|
|
352
353
|
//
|
|
353
354
|
// `toolCalls` and `toolWaitMs` say how much of a turn was tool wait rather than generation. An engine
|
|
354
|
-
// that cannot report them is NOT a turn that called no tools: `openai-agent`
|
|
355
|
-
//
|
|
356
|
-
// "called no tools", and a cross-engine comparison would then conclude tool
|
|
357
|
-
// phenomenon — from an instrument that had simply gone quiet.
|
|
355
|
+
// that cannot report them is NOT a turn that called no tools: `openai-agent` reports no whole-turn tool
|
|
356
|
+
// count, so a codex attempt's `toolCalls` is unmeasured. Writing 0 for it would make every codex turn read
|
|
357
|
+
// as "called no tools", and a cross-engine comparison would then conclude tool calls are an Anthropic-only
|
|
358
|
+
// phenomenon — from an instrument that had simply gone quiet. Its tool wait it does time, from when each
|
|
359
|
+
// tool item opens and closes in its stream (openai-agent.mjs, codexTiming).
|
|
358
360
|
//
|
|
359
361
|
// PRESENT AND NULL, never absent, which is this file's own house rule: a field written even when null
|
|
360
362
|
// keeps "this engine cannot report" visibly different from "this record predates the gauge". The first
|
|
@@ -397,6 +399,14 @@ export function toolGauge(turn) {
|
|
|
397
399
|
// model asked for. An OBJECT is a measurement (`{}`: none); null is "this engine cannot report".
|
|
398
400
|
toolCallsByName: turn?.toolCallsByName && typeof turn.toolCallsByName === "object" && !Array.isArray(turn.toolCallsByName)
|
|
399
401
|
? { ...turn.toolCallsByName } : null,
|
|
402
|
+
// ms from spawn to the engine's first output, on both engines; null when it never spoke or cannot report. With
|
|
403
|
+
// `toolWaitMs` and `activeMs` it splits a turn into start-up, tool wait and work. RECORDING ONLY.
|
|
404
|
+
firstByteMs: n(turn?.firstByteMs),
|
|
405
|
+
// The first call's cache read and write in tokens, where the engine reports them (Claude), and how many times the turn
|
|
406
|
+
// searched for a tool to load (`ToolSearch`), read off its own per-name counts. null where the engine cannot say.
|
|
407
|
+
firstCallCache: turn?.firstCallCache && Number.isFinite(turn.firstCallCache.read) && Number.isFinite(turn.firstCallCache.creation)
|
|
408
|
+
? { read: turn.firstCallCache.read, creation: turn.firstCallCache.creation } : null,
|
|
409
|
+
toolSearchCalls: turn?.toolCallsByName && typeof turn.toolCallsByName === "object" ? (turn.toolCallsByName.ToolSearch ?? 0) : null,
|
|
400
410
|
};
|
|
401
411
|
}
|
|
402
412
|
|
|
@@ -797,6 +807,7 @@ async function runStageLadder(name, opts, stageHome = null, engine = selectEngin
|
|
|
797
807
|
let lastJson = null; // the failed attempt's parsed envelope — warm eligibility needs its status
|
|
798
808
|
let lastKey = sessionKey; // the failed attempt's session key — the warm patch resumes exactly it
|
|
799
809
|
let lastSessionRef = sessionKey; // the failed attempt's engine sessionRef — anthropic warm-resume (--resume) reuses it
|
|
810
|
+
let lastKillClass = null; // how the failed attempt's hard-wall kill read (killedWhile): a working one is resumed warm
|
|
800
811
|
// statOf feeds the ONE artifact-state snapshot both the exit-1 rescue and AD-4's emitted-vs-landed
|
|
801
812
|
// gauge read. It is taken PER ATTEMPT, just before the turn is dispatched — it used to be taken
|
|
802
813
|
// once before the whole ladder, which is the cross-attempt rescue hole post-merge audit 2 found: a
|
|
@@ -873,7 +884,12 @@ async function runStageLadder(name, opts, stageHome = null, engine = selectEngin
|
|
|
873
884
|
// lane: if attempt 2 comes back with rows ruled (`call_partial` — a seat that has now recorded
|
|
874
885
|
// rulings), attempt 3 can still warm, which is the case warm is good at.
|
|
875
886
|
const vetoedResume = vetoResumeRuledNone(attempt, lastUnion);
|
|
876
|
-
|
|
887
|
+
// A TURN STOPPED AT ITS HARD WALL WHILE STILL WORKING IS RESUMED, NOT RESTARTED. Its single extended retry (ladder/next-rung.mjs)
|
|
888
|
+
// continues the same session with the message design wrote, so an hour of work is not done again; a kill that was silent, or
|
|
889
|
+
// was only making its own record write, is retried fresh as before. The classification is killedWhile, below.
|
|
890
|
+
const timeoutResume = lastFail === "timeout" && lastKillClass === "working";
|
|
891
|
+
const warm = attempt > 1 && !warmUsed && process.env.CLEAROTRON_WARM_RETRY !== "0" && (timeoutResume || (!vetoedResume && warmEligible(lastFail, lastJson)));
|
|
892
|
+
const timeoutWarm = warm && timeoutResume;
|
|
877
893
|
if (warm) warmUsed = true;
|
|
878
894
|
else if (vetoedResume && !warmUsed && process.env.CLEAROTRON_WARM_RETRY !== "0" && warmEligible(lastFail, lastJson))
|
|
879
895
|
note(`[${name}] attempt ${attempt - 1} left this stage's meaning population with ZERO ruled rows (${String(lastFail).slice(0, 100)}) — a resumed session re-reads its own output and cannot rule what it did not rule; SKIPPING the warm patch and dispatching attempt ${attempt} FRESH (the warm attempt is not spent: a partial failure later in this ladder still gets it)`);
|
|
@@ -913,8 +929,8 @@ async function runStageLadder(name, opts, stageHome = null, engine = selectEngin
|
|
|
913
929
|
try { const fresh = refreshMessage(attempt); if (typeof fresh === "string" && fresh) base = fresh; }
|
|
914
930
|
catch (e) { note(`[${name}] refreshMessage failed on attempt ${attempt}, dispatching the original text: ${String(e?.message ?? e).slice(0, 120)}`); }
|
|
915
931
|
}
|
|
916
|
-
const effMessage = warm ? warmPatchMessage(lastFail, files, { supplementalLane, adds }) : correctiveMessage(base, attempt, lastFail, files, { supplementalLane, adds });
|
|
917
|
-
note(`[${name}] attempt ${attempt}/${maxRetries + 1}${warm ? " [warm patch]" : ""} (engine=${engine.name} agent=${agent} model=${model ?? "default"} key=${key} timeout=${effTimeout}s)`);
|
|
932
|
+
const effMessage = timeoutWarm ? warmTimeoutMessage(files) : warm ? warmPatchMessage(lastFail, files, { supplementalLane, adds }) : correctiveMessage(base, attempt, lastFail, files, { supplementalLane, adds });
|
|
933
|
+
note(`[${name}] attempt ${attempt}/${maxRetries + 1}${timeoutWarm ? " [warm resume: the timed-out turn was still working]" : warm ? " [warm patch]" : ""} (engine=${engine.name} agent=${agent} model=${model ?? "default"} key=${key} timeout=${effTimeout}s)`);
|
|
918
934
|
// The engine runs ONE turn and returns the normalized tuple. Every adapter returns the same shape
|
|
919
935
|
// (zero change); anthropic-agent = claude -p off-gateway with the stall-watchdog. A warm retry threads
|
|
920
936
|
// the prior attempt's sessionRef so the engine resumes the SAME session (anthropic: via
|
|
@@ -938,7 +954,7 @@ async function runStageLadder(name, opts, stageHome = null, engine = selectEngin
|
|
|
938
954
|
const dispatch = envGateOn("CLEAROTRON_DISPATCH_RECORD")
|
|
939
955
|
? recordDispatch(runDir, name, {
|
|
940
956
|
attempt,
|
|
941
|
-
kind: warm ? "warm-patch" : followup ? "followup" : attempt === warmEscalatedAt ? "fresh-escalation" : vetoedResume ? "fresh-total-defect" : attempt > 1 ? "corrective" : "fresh",
|
|
957
|
+
kind: timeoutWarm ? "warm-timeout" : warm ? "warm-patch" : followup ? "followup" : attempt === warmEscalatedAt ? "fresh-escalation" : vetoedResume ? "fresh-total-defect" : attempt > 1 ? "corrective" : "fresh",
|
|
942
958
|
message: effMessage,
|
|
943
959
|
// — THE RESOLVED GRANT, recorded beside the sha of the message it went out with. This is
|
|
944
960
|
// the value handed to `engine.runTurn` below as `allowedTools`, not a re-derivation of it: a
|
|
@@ -953,8 +969,8 @@ async function runStageLadder(name, opts, stageHome = null, engine = selectEngin
|
|
|
953
969
|
// precede its own settle, so they stay outside it.
|
|
954
970
|
const dispatchedAt = Date.now();
|
|
955
971
|
const mcpConfig = turnConfig(effTimeout); // this turn's copy, with its time to stop sending
|
|
956
|
-
|
|
957
|
-
|
|
972
|
+
const witnessed = witnessStageMethodology(runDir, name, effMessage, engineResolveSkill);
|
|
973
|
+
for (const line of describeMethodologyDrift(witnessed)) note(`[${name}] ${line}`);
|
|
958
974
|
// — the frozen judged-by set, hashed into THIS PROCESS'S MEMORY before the seat runs. Never
|
|
959
975
|
// written to disk before the comparison, so the thing being watched cannot reach it. See
|
|
960
976
|
// run-integrity.mjs for why it is not a manifest file and why the append-only journals are excluded.
|
|
@@ -1245,6 +1261,8 @@ async function runStageLadder(name, opts, stageHome = null, engine = selectEngin
|
|
|
1245
1261
|
if (killClass) killSeen = true;
|
|
1246
1262
|
fail = nameTheFailure(fail, { usage, json, stdout: turn.stdout, stderr, signals: turn.signals, name,
|
|
1247
1263
|
gauge: { modelMismatch, famRequested, famActual, modelRequested, modelActual } });
|
|
1264
|
+
// How a hard-wall kill read (killedWhile), once per attempt: both rows record it and the next rung reads it. null otherwise.
|
|
1265
|
+
const attemptKilledWhile = fail === "timeout" ? killedWhile(turn, stallSec ?? Number(process.env.CLEAROTRON_STALL_MS || 120000) / 1000) : null;
|
|
1248
1266
|
|
|
1249
1267
|
// AD-4 house rule — both computed UNCONDITIONALLY, three-valued on purpose:
|
|
1250
1268
|
// wrote: did THIS attempt move any expected artifact? true/false when the stage has expected files,
|
|
@@ -1450,6 +1468,10 @@ async function runStageLadder(name, opts, stageHome = null, engine = selectEngin
|
|
|
1450
1468
|
// not left looking like an artifact problem. It names a fact; it moves no retry policy. See
|
|
1451
1469
|
// `spentBudgetCleanly`.
|
|
1452
1470
|
budgetSpentCleanly: spentBudgetCleanly({ fail, killed, code, wall, derivedLimitSec: derivedLimit?.sec }),
|
|
1471
|
+
killedWhile: attemptKilledWhile,
|
|
1472
|
+
// The share of each told manual this turn's model was shown, read off its saved stream (manuals-seen.mjs); null
|
|
1473
|
+
// where the stream cannot say. A resumed turn is shown only what it read after resuming, so read it beside `warm`.
|
|
1474
|
+
manualsSeen: measureManualsSeen(turn, witnessed.told, engine.name),
|
|
1453
1475
|
// AD-4 emitted-vs-landed, UNCONDITIONAL (was success-only, which made a failed attempt's mid-write
|
|
1454
1476
|
// artifact invisible): `output` = what LANDED on disk after this attempt (null when the stage has no
|
|
1455
1477
|
// expected file); `wrote` = whether THIS attempt emitted it (see the computation above the runDir
|
|
@@ -1520,6 +1542,7 @@ async function runStageLadder(name, opts, stageHome = null, engine = selectEngin
|
|
|
1520
1542
|
// …and the same fact on this row, because one of the two carrying it records half the runs and
|
|
1521
1543
|
// reads as done. Three-valued and beside the numbers it is about. See `spentBudgetCleanly`.
|
|
1522
1544
|
budgetSpentCleanly: spentBudgetCleanly({ fail, killed, code, wall, derivedLimitSec: derivedLimit?.sec }),
|
|
1545
|
+
killedWhile: attemptKilledWhile,
|
|
1523
1546
|
formRepairs: formRepairsThisAttempt || undefined, //, see the stage row above
|
|
1524
1547
|
});
|
|
1525
1548
|
} catch { /* telemetry best-effort — never fail a turn over a journal line */ }
|
|
@@ -1535,6 +1558,7 @@ async function runStageLadder(name, opts, stageHome = null, engine = selectEngin
|
|
|
1535
1558
|
lastKey = key;
|
|
1536
1559
|
lastQuantity = quantity; //: rides the ladder's final return, so the run-level catch stamps the exact count
|
|
1537
1560
|
lastSessionRef = turn.sessionRef ?? lastSessionRef; // anthropic warm-resume target for the next attempt
|
|
1561
|
+
lastKillClass = attemptKilledWhile;
|
|
1538
1562
|
note(`[${name}] attempt ${attempt} FAILED: ${fail}${quantity === null ? "" : ` (count ${quantity}${noChange ? ", unchanged" : ""})`}`);
|
|
1539
1563
|
|
|
1540
1564
|
// What the ladder does next after this failure — escalate, retry, break, or return — is ladder/next-rung.mjs.
|
|
@@ -2805,6 +2829,39 @@ export function warmEligible(fail, json) {
|
|
|
2805
2829
|
return json?.status === "ok" && WARM_ELIGIBLE_RE.test(fail ?? "");
|
|
2806
2830
|
}
|
|
2807
2831
|
|
|
2832
|
+
/**
|
|
2833
|
+
* How a turn stopped at its hard wall read when it was stopped: "working" when it asked for a tool other than its own record
|
|
2834
|
+
* write within the stage's last stall window, "record-only" when its only asks there were that write, "silent" when it asked
|
|
2835
|
+
* for none, and null for anything that is not a hard-wall kill or a turn whose engine could not say. The window is the stage's
|
|
2836
|
+
* own `stallSec`, 120 s where it sets none, read back from the end of the turn. Measured before this was built, over saved
|
|
2837
|
+
* hard-wall kills: 10 of 14 on production and 18 of 24 on a test machine were working. PURE.
|
|
2838
|
+
*/
|
|
2839
|
+
export function killedWhile(turn, stallSec) {
|
|
2840
|
+
if (!turn?.killed || !turn?.signals?.hardWall || turn?.signals?.stalled) return null;
|
|
2841
|
+
const asked = turn.lastToolAsk;
|
|
2842
|
+
const wallMs = Number(turn.wall) * 1000;
|
|
2843
|
+
if (!asked || !Number.isFinite(wallMs)) return null;
|
|
2844
|
+
const windowMs = (Number.isFinite(stallSec) && stallSec > 0 ? stallSec : 120) * 1000;
|
|
2845
|
+
const within = (ms) => Number.isFinite(ms) && wallMs - ms <= windowMs;
|
|
2846
|
+
return within(asked.workMs) ? "working" : within(asked.recordMs) ? "record-only" : "silent";
|
|
2847
|
+
}
|
|
2848
|
+
|
|
2849
|
+
/**
|
|
2850
|
+
* What a session resumed after a working hard-wall kill reads: design's words, with the stage's own closing tail, the record
|
|
2851
|
+
* tool's for a tool-written stage and the whole-file write for any other. Approved word for word. PURE.
|
|
2852
|
+
*/
|
|
2853
|
+
export function warmTimeoutMessage(expectFile) {
|
|
2854
|
+
const files = (Array.isArray(expectFile) ? expectFile : [expectFile]).filter(Boolean);
|
|
2855
|
+
const names = files.map(rel).join(", ");
|
|
2856
|
+
const toolWritten = files.length ? toolWrittenArtifact(files[0]) : null;
|
|
2857
|
+
const tail = toolWritten
|
|
2858
|
+
? `Call \`${toolWritten.tool}\` with the values from the work already in your context — never by writing or editing any file. Do not stop until the tool accepts the call.`
|
|
2859
|
+
: fullWriteTail(names || "the stage output");
|
|
2860
|
+
return `You are RESUMING your own session for this stage — your prior work and inputs are already in your context. Do NOT redo the work from scratch.\n` +
|
|
2861
|
+
`Your previous turn was stopped at the stage's time limit while you were still working. Everything you already recorded through the stage's tools is kept; do not record it again. Continue from the last step you completed, finish what remains, and then ` +
|
|
2862
|
+
tail + ` This attempt has a longer limit, but not an unlimited one: finish the remaining work rather than revisiting finished steps.`;
|
|
2863
|
+
}
|
|
2864
|
+
|
|
2808
2865
|
// ── — THE FIRST RETRY IS ROUTED BY THE RUN'S OWN COUNTED STATE, NOT BY A TOKEN NAME ────────────
|
|
2809
2866
|
//
|
|
2810
2867
|
// Two m-seat failures in the same hour, on the same engine, with opposite correct answers:
|
package/driver/jx.mjs
CHANGED
|
@@ -191,7 +191,7 @@ export function deriveLaneDepthVerdicts({ sidecar, slices } = {}) {
|
|
|
191
191
|
|
|
192
192
|
const ran = deepRan.length ? "full" : candidatesState === "ran" ? "candidates" : null;
|
|
193
193
|
const shortfall = asked === "full" && ran !== "full";
|
|
194
|
-
let cause = null, why = null;
|
|
194
|
+
let cause = null, why = null, detail = null;
|
|
195
195
|
if (shortfall) {
|
|
196
196
|
// "The lane ran as a slice-1 candidate lane" is said only of a lane whose candidates ran: a lane
|
|
197
197
|
// that ran nothing is not established, whatever this build carries for it.
|
|
@@ -202,15 +202,23 @@ export function deriveLaneDepthVerdicts({ sidecar, slices } = {}) {
|
|
|
202
202
|
+ `Only the candidate search ran; the deeper web search and native-language review were not performed.`;
|
|
203
203
|
} else if (ran === null) {
|
|
204
204
|
cause = "not-established";
|
|
205
|
-
|
|
205
|
+
// THE CLIENT READS THIS UNDER "LEFT OPEN" too: the owner's sentence (2026-11-18), in place of
|
|
206
|
+
// the record's own terms. What the record does say, slice by slice, stays beside it as `detail`, for the run
|
|
207
|
+
// record and whoever reads it. Not reported as candidates: that would be a claim no artifact supports.
|
|
208
|
+
why = `Whether the full-depth ${languageOfLane(lane)}-language search ran cannot be confirmed from this search's record, `
|
|
209
|
+
+ `so it is treated as not done.`;
|
|
210
|
+
detail = `${deep.length ? `the deep slice(s) ${deepStates.map((d) => `${d.name}=${d.state ?? "no record"}`).join(", ")} did not state that they ran, and ` : ""}`
|
|
206
211
|
+ `slice 1 for this lane is ${candidatesState ?? "unrecorded"} — what this lane delivered CANNOT be established from `
|
|
207
|
-
+ `this run's own record
|
|
212
|
+
+ `this run's own record.`;
|
|
208
213
|
} else {
|
|
209
214
|
cause = "requested-full-ran-candidates";
|
|
210
|
-
|
|
215
|
+
// The owner's 2026-11-11 sentence pattern, ruled for this cause on 2026-11-18; the slices' own states stay as `detail`.
|
|
216
|
+
why = `A full-depth ${languageOfLane(lane)}-language search was requested, but only the candidate search ran; `
|
|
217
|
+
+ `the deeper web search and native-language review were not performed.`;
|
|
218
|
+
detail = `asked for full and ran candidates only — ${deepStates.map((d) => `${d.name} ${d.state ?? "no record"}`).join(", ")}`;
|
|
211
219
|
}
|
|
212
220
|
}
|
|
213
|
-
out[lane] = { asked, ran, shortfall, cause, why,
|
|
221
|
+
out[lane] = { asked, ran, shortfall, cause, why, ...(detail ? { detail } : {}),
|
|
214
222
|
basis: "_driver/jx-lanes.json:lanes[].depth (asked) vs fold.slices (ran)" };
|
|
215
223
|
}
|
|
216
224
|
return out;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright 2026 Cordillera Sàrl. Additional terms under section 7 of the AGPL-3.0 apply — see ADDITIONAL-TERMS.md
|
|
3
|
+
//
|
|
4
|
+
// HOW MUCH OF EACH MANUAL A STAGE WAS TOLD TO READ REACHED THE MODEL.
|
|
5
|
+
//
|
|
6
|
+
// methodology-witness.mjs records which manuals a stage is told to read, with the path and sha it resolved. It cannot say
|
|
7
|
+
// what the model saw of them. On Codex a long read loses its middle: the model is shown the first and last part of a tool
|
|
8
|
+
// output (engine/mcp/codex-config.mjs, CODEX_SHOWN_OUTPUT_BYTES). On Claude the model is shown what its Read calls
|
|
9
|
+
// returned. So after each attempt this reads the attempt's saved stream for the text the model was shown and records, per
|
|
10
|
+
// told manual, the share of the manual's lines that appear in it. Measured on saved streams before this was built
|
|
11
|
+
// (production, 2026-11-18): about a quarter of the told bytes of a Codex common-law half or register unit, and half of a
|
|
12
|
+
// report overview's, never reached the model under the cut.
|
|
13
|
+
//
|
|
14
|
+
// THE RULE, said once. A manual line counts when it holds 20 characters or more after its surrounding spaces are trimmed;
|
|
15
|
+
// it was seen when the same trimmed line appears in what the model was shown, after a line-number prefix (`cat -n`,
|
|
16
|
+
// `nl`, `grep -n`, Claude's Read) is taken off. A line repeated in a manual counts each time. The share is a lower bound
|
|
17
|
+
// on Codex, where the cut's size is the product's own measurement, not the vendor's.
|
|
18
|
+
//
|
|
19
|
+
// UNKNOWN IS null, NEVER 0. A stream that was not saved, was cut short, holds a line carrying a tool output that is not
|
|
20
|
+
// JSON before its last, or holds no event of the engine's own shape, says nothing about what was seen, and an engine this does not read is the
|
|
21
|
+
// same. A manual that changed since the stage was told it, or that holds no line long enough to count, is null on its
|
|
22
|
+
// own. Recording only, and it never throws: the attempt's result does not depend on it.
|
|
23
|
+
import { createHash } from "node:crypto";
|
|
24
|
+
import { closeSync, openSync, readFileSync, readSync } from "node:fs";
|
|
25
|
+
import { CODEX_SHOWN_OUTPUT_BYTES } from "./engine/mcp/codex-config.mjs";
|
|
26
|
+
|
|
27
|
+
const MIN_CHARS = 20;
|
|
28
|
+
const NUMBERED = /^\s*\d+(?:\t|→|:)/;
|
|
29
|
+
|
|
30
|
+
/** The countable form of one line: its line-number prefix off, its spaces trimmed; null when too short to count. PURE. */
|
|
31
|
+
export function countable(line, { numbered = false } = {}) {
|
|
32
|
+
const raw = String(line ?? "");
|
|
33
|
+
const s = (numbered ? raw.replace(NUMBERED, "") : raw).trim();
|
|
34
|
+
return s.length >= MIN_CHARS ? s : null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** What a Codex model was shown of one output: all of it under the cut, else its first and last half of the cut. PURE. */
|
|
38
|
+
export function codexShown(output, cutBytes = CODEX_SHOWN_OUTPUT_BYTES) {
|
|
39
|
+
const b = Buffer.from(String(output ?? ""), "utf8");
|
|
40
|
+
if (b.length <= cutBytes) return b.toString("utf8");
|
|
41
|
+
const half = Math.floor(cutBytes / 2);
|
|
42
|
+
return `${b.subarray(0, half).toString("utf8")}\n${b.subarray(b.length - half).toString("utf8")}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// A synthesis stream runs to tens of megabytes, and this runs in the driver after every attempt: so a line is parsed only
|
|
46
|
+
// when it can carry what is read (measured 2026-11-18 on a 64 MB stream: 306 MB at peak when every line was parsed).
|
|
47
|
+
const READERS = {
|
|
48
|
+
// Codex: every command's output, under the cut. Its events are `thread.*`, `turn.*` and `item.*`.
|
|
49
|
+
"openai-agent": {
|
|
50
|
+
ours: /"type"\s*:\s*"(thread|turn|item)\./,
|
|
51
|
+
carries: (l) => l.includes('"command_execution"'),
|
|
52
|
+
read: (e, add, { cutBytes }) => {
|
|
53
|
+
if (e?.type === "item.completed" && e.item?.type === "command_execution") add(codexShown(e.item.aggregated_output, cutBytes));
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
// Claude: what each Read call returned, matched to the call by its id.
|
|
57
|
+
"anthropic-agent": {
|
|
58
|
+
ours: /"type"\s*:\s*"(system|assistant|user|result)"/,
|
|
59
|
+
carries: (l) => l.includes('"tool_use"') || l.includes('"tool_result"'),
|
|
60
|
+
read: (e, add, _opts, reads) => {
|
|
61
|
+
for (const c of Array.isArray(e?.message?.content) ? e.message.content : []) {
|
|
62
|
+
if (e.type === "assistant" && c?.type === "tool_use" && c.name === "Read") reads.add(c.id);
|
|
63
|
+
if (e.type === "user" && c?.type === "tool_result" && reads.has(c.tool_use_id))
|
|
64
|
+
add(typeof c.content === "string" ? c.content : Array.isArray(c.content) ? c.content.map((x) => x?.text ?? "").join("\n") : "");
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/** Each line of a saved stream as bytes, read a megabyte at a time, so a long stream is never held whole. */
|
|
71
|
+
function* fileLines(file) {
|
|
72
|
+
const fd = openSync(file, "r");
|
|
73
|
+
try {
|
|
74
|
+
const chunk = Buffer.alloc(1 << 20);
|
|
75
|
+
let rest = Buffer.alloc(0);
|
|
76
|
+
for (let n; (n = readSync(fd, chunk, 0, chunk.length, null)) > 0;) {
|
|
77
|
+
let buf = Buffer.concat([rest, chunk.subarray(0, n)]), at;
|
|
78
|
+
while ((at = buf.indexOf(10)) >= 0) { yield buf.subarray(0, at); buf = buf.subarray(at + 1); }
|
|
79
|
+
rest = Buffer.from(buf);
|
|
80
|
+
}
|
|
81
|
+
if (rest.length) yield rest;
|
|
82
|
+
} finally { closeSync(fd); }
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const textLines = function* (text) { for (const l of String(text ?? "").split("\n")) yield Buffer.from(l); };
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The countable lines a session showed its model, from its stream's lines as bytes, or null when the stream cannot say:
|
|
89
|
+
* no event of the engine's own shape, or a line that carries what is read and is not JSON before the last line (a killed
|
|
90
|
+
* turn may tear its last). Only such a line is parsed. PURE but for the lines it is handed.
|
|
91
|
+
*/
|
|
92
|
+
function shownFrom(lines, engine, { cutBytes = CODEX_SHOWN_OUTPUT_BYTES } = {}) {
|
|
93
|
+
const reader = READERS[engine];
|
|
94
|
+
if (!reader) return null;
|
|
95
|
+
const set = new Set();
|
|
96
|
+
const add = (shown) => { for (const l of shown.split("\n")) { const c = countable(l, { numbered: true }); if (c) set.add(c); } };
|
|
97
|
+
const reads = new Set();
|
|
98
|
+
let ours = false, torn = false;
|
|
99
|
+
for (const line of lines) {
|
|
100
|
+
if (!line.toString("utf8", 0, 64).trim()) continue;
|
|
101
|
+
if (torn) return null;
|
|
102
|
+
if (!ours && reader.ours.test(line.toString("utf8", 0, 200))) ours = true;
|
|
103
|
+
if (!reader.carries(line)) continue;
|
|
104
|
+
let e;
|
|
105
|
+
try { e = JSON.parse(line.toString("utf8")); } catch { torn = true; continue; }
|
|
106
|
+
reader.read(e, add, { cutBytes }, reads);
|
|
107
|
+
}
|
|
108
|
+
return ours ? set : null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** The countable lines a session showed its model, from its stream's text; see shownFrom. PURE. */
|
|
112
|
+
export const shownLines = (streamText, engine, opts) => shownFrom(textLines(streamText), engine, opts);
|
|
113
|
+
|
|
114
|
+
const sha12 = (buf) => createHash("sha256").update(buf).digest("hex").slice(0, 12);
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* `{ [ref]: share }` for the told rows (methodology-witness.mjs), each share from 0 to 1 at three places, or null for a
|
|
118
|
+
* manual that changed since it was told or holds nothing countable; null in whole when `shown` is null. PURE but for
|
|
119
|
+
* `readManual`.
|
|
120
|
+
*/
|
|
121
|
+
export function manualShares(told, shown, { readManual = (p) => readFileSync(p) } = {}) {
|
|
122
|
+
if (!shown || !Array.isArray(told)) return null;
|
|
123
|
+
const out = {};
|
|
124
|
+
for (const row of told) {
|
|
125
|
+
if (!row?.ref) continue;
|
|
126
|
+
let buf = null;
|
|
127
|
+
try { buf = row.path ? readManual(row.path) : null; } catch { buf = null; }
|
|
128
|
+
if (!buf || (row.sha && sha12(buf) !== row.sha)) { out[row.ref] = null; continue; }
|
|
129
|
+
const lines = String(buf).split("\n").map((l) => countable(l)).filter(Boolean);
|
|
130
|
+
out[row.ref] = lines.length ? Math.round((lines.filter((l) => shown.has(l)).length / lines.length) * 1000) / 1000 : null;
|
|
131
|
+
}
|
|
132
|
+
return out;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The attempt row's `manualsSeen`: the shares for what this turn was told, read from the stream the engine saved, or
|
|
137
|
+
* null when nothing was told or the stream cannot say. Never throws.
|
|
138
|
+
*/
|
|
139
|
+
export function measureManualsSeen(turn, told, engine, { readManual } = {}) {
|
|
140
|
+
try {
|
|
141
|
+
if (!Array.isArray(told) || !told.length) return null;
|
|
142
|
+
const s = turn?.stream;
|
|
143
|
+
if (!s?.file || s.present !== true || s.reason) return null;
|
|
144
|
+
return manualShares(told, shownFrom(fileLines(s.file), engine), readManual ? { readManual } : {});
|
|
145
|
+
} catch { return null; }
|
|
146
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright 2026 Cordillera Sàrl. Additional terms under section 7 of the AGPL-3.0 apply — see ADDITIONAL-TERMS.md
|
|
3
|
+
//
|
|
4
|
+
// mark-logos.mjs — the logo of each cited registration, fetched once the findings are final and saved with the run.
|
|
5
|
+
//
|
|
6
|
+
// A lawyer compares logos first, and the report showed none. So after the record is final and before the report is
|
|
7
|
+
// published, both pipelines run this one step: for each registration the report will show, it reads the run's saved
|
|
8
|
+
// record, and where that record says the mark is figurative and that an image exists, it asks the register the run is
|
|
9
|
+
// set to use for that one image. It writes what happened to each registration in `_driver/logos.json`, which the report
|
|
10
|
+
// reads, and the images under `_driver/logos/`.
|
|
11
|
+
//
|
|
12
|
+
// WHICH REGISTRATIONS. The ones the report shows and no others: a clearance's findings, withdrawn ones left out, and
|
|
13
|
+
// the registrations each cites; a Knockout's listed filings. Measured on a 55-finding global preliminary of 2026-11-03:
|
|
14
|
+
// 28 of the 3,497 records it held, so 28 image requests (that count approved 2026-11-18).
|
|
15
|
+
//
|
|
16
|
+
// WHAT A ROW SAYS, and only `failed` reads as "Logo not retrieved" on the page:
|
|
17
|
+
// fetched the image is saved; `file` is relative to the run folder, `contentType` PNG, JPEG, GIF or WebP
|
|
18
|
+
// failed a request was made and did not land, or brought back something that is not one of those images
|
|
19
|
+
// no-logo the record says a word mark, or that no image exists
|
|
20
|
+
// unknown the record cannot say, or this run makes no register call: a replay, an injected fetcher, no credential,
|
|
21
|
+
// or a register whose adapter fetches no image. Nothing is requested.
|
|
22
|
+
//
|
|
23
|
+
// THE REGISTER THE RUN IS SET TO USE, AND NO OTHER (ruled 2026-11-18: one run never mixes registers). A register that
|
|
24
|
+
// cannot fetch an image leaves its rows `unknown`; no second service is asked.
|
|
25
|
+
//
|
|
26
|
+
// A RESUME OR A REPUBLISH ASKS NOTHING AGAIN. A row already `fetched` whose file is still there is kept as it is.
|
|
27
|
+
//
|
|
28
|
+
// RECORDING ONLY, and it never throws: a logo that could not be had never stops a report.
|
|
29
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
30
|
+
import { join } from "node:path";
|
|
31
|
+
import { normalizeRecordUri } from "../providers/_shared/record-uri.mjs";
|
|
32
|
+
import { readRecordArtifacts } from "./registry-fidelity.mjs";
|
|
33
|
+
import { DRIVER_DIR, driverDir, ensureDriverDir } from "./run-record.mjs";
|
|
34
|
+
import { runLog } from "./log.mjs";
|
|
35
|
+
|
|
36
|
+
export const LOGOS_FILE = "logos.json";
|
|
37
|
+
export const LOGOS_DIR = "logos";
|
|
38
|
+
|
|
39
|
+
// The register's own words for the kind of mark, as saved records carry them (counted on the test machine,
|
|
40
|
+
// 2026-11-18: Clarivate's eight values and Signa's three). Any other value is unknown and fetches nothing.
|
|
41
|
+
const FIGURATIVE = new Set(["WORD AND DESIGN", "DESIGN MARK", "DESIGN AND COLOR", "STYLIZED LETTERS", "COMBINED", "FIGURATIVE"]);
|
|
42
|
+
const WORD = new Set(["WORD ONLY", "WORD MARK", "BLOCK LETTERS", "WORD"]);
|
|
43
|
+
|
|
44
|
+
/** Whether a saved record carries a logo: "logo", "no-logo" or "unknown". PURE. */
|
|
45
|
+
export function logoOf(record) {
|
|
46
|
+
if (!record || typeof record !== "object") return "unknown";
|
|
47
|
+
const feature = String(record.markFeature ?? "").trim().toUpperCase();
|
|
48
|
+
if (record.imageAvailable === false || WORD.has(feature)) return "no-logo";
|
|
49
|
+
return FIGURATIVE.has(feature) && record.imageAvailable === true ? "logo" : "unknown";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The image type the bytes open as, by their first bytes, or null for anything else. PURE. */
|
|
53
|
+
export function imageTypeOf(bytes) {
|
|
54
|
+
const b = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes ?? []);
|
|
55
|
+
if (b.length >= 8 && b.subarray(0, 8).equals(Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]))) return { type: "image/png", ext: "png" };
|
|
56
|
+
if (b.length >= 3 && b[0] === 0xff && b[1] === 0xd8 && b[2] === 0xff) return { type: "image/jpeg", ext: "jpg" };
|
|
57
|
+
if (b.length >= 6 && /^GIF8[79]a$/.test(b.subarray(0, 6).toString("latin1"))) return { type: "image/gif", ext: "gif" };
|
|
58
|
+
if (b.length >= 12 && b.subarray(0, 4).toString("latin1") === "RIFF" && b.subarray(8, 12).toString("latin1") === "WEBP") return { type: "image/webp", ext: "webp" };
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** The registrations the report will show, in its order and once each. PURE. */
|
|
63
|
+
export function citedRefs({ findings = null, registerRecords = null } = {}) {
|
|
64
|
+
const out = [];
|
|
65
|
+
const add = (ref) => { const k = normalizeRecordUri(ref); if (k && !out.includes(k)) out.push(k); };
|
|
66
|
+
for (const f of Array.isArray(findings) ? findings : []) {
|
|
67
|
+
if (f?.disposition === "withdrawn") continue;
|
|
68
|
+
for (const r of Array.isArray(f?.owner?.registrations) ? f.owner.registrations : []) add(r?.uri);
|
|
69
|
+
}
|
|
70
|
+
for (const m of Array.isArray(registerRecords?.marks) ? registerRecords.marks : [])
|
|
71
|
+
for (const r of Array.isArray(m?.records) ? m.records : []) add(r?.recordId);
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const fileFor = (ref, ext) => `${ref.replace(/^\/mark\//, "").replace(/[^a-z0-9_-]+/gi, "-")}.${ext}`;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The rows for these registrations: kept where an earlier pass saved the image, fetched where the record carries a logo
|
|
79
|
+
* and a request may be made, and said for the rest. `fetchImage(ref)` resolves `{ ok, bytes, contentType }` or
|
|
80
|
+
* `{ ok: false, cause }`; `mayCall` is `{ ok }` or `{ ok: false, why }`. Writes the images it fetched. IMPURE.
|
|
81
|
+
*/
|
|
82
|
+
export async function logoRows({ runDir, refs, records, register, fetchImage, mayCall, prior = [] }) {
|
|
83
|
+
const kept = new Map(prior.filter((r) => r?.state === "fetched" && r.file && existsSync(join(runDir, r.file))).map((r) => [r.ref, r]));
|
|
84
|
+
const rows = [];
|
|
85
|
+
for (const ref of refs) {
|
|
86
|
+
if (kept.has(ref)) { rows.push(kept.get(ref)); continue; }
|
|
87
|
+
const record = records.get(ref);
|
|
88
|
+
if (!record) { rows.push({ ref, register, state: "unknown", cause: "the run holds no saved record of this registration" }); continue; }
|
|
89
|
+
const has = logoOf(record);
|
|
90
|
+
if (has !== "logo") {
|
|
91
|
+
rows.push({ ref, register, state: has, ...(has === "unknown" ? { cause: "the record does not say whether the mark has a logo" } : {}) });
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (!mayCall?.ok) { rows.push({ ref, register, state: "unknown", cause: mayCall?.why ?? "this run makes no register call" }); continue; }
|
|
95
|
+
if (typeof fetchImage !== "function") { rows.push({ ref, register, state: "unknown", cause: "this register's adapter fetches no image" }); continue; }
|
|
96
|
+
let got;
|
|
97
|
+
try { got = await fetchImage(ref); } catch (e) { got = { ok: false, cause: `the request threw: ${String(e?.message ?? e).slice(0, 120)}` }; }
|
|
98
|
+
if (!got?.ok) { rows.push({ ref, register, state: "failed", cause: String(got?.cause ?? "the request did not land").slice(0, 200) }); continue; }
|
|
99
|
+
const kind = imageTypeOf(got.bytes);
|
|
100
|
+
if (!kind) { rows.push({ ref, register, state: "failed", cause: "the answer is not a PNG, JPEG, GIF or WebP image" }); continue; }
|
|
101
|
+
const file = `${DRIVER_DIR}/${LOGOS_DIR}/${fileFor(ref, kind.ext)}`; // relative to the run folder, the same on every system
|
|
102
|
+
try {
|
|
103
|
+
ensureDriverDir(runDir, LOGOS_DIR);
|
|
104
|
+
writeFileSync(join(runDir, file), got.bytes);
|
|
105
|
+
rows.push({ ref, register, state: "fetched", file, contentType: kind.type, bytes: got.bytes.length });
|
|
106
|
+
} catch (e) { rows.push({ ref, register, state: "failed", cause: `the image could not be saved: ${String(e?.message ?? e).slice(0, 120)}` }); }
|
|
107
|
+
}
|
|
108
|
+
return rows;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The step both pipelines run before publishing. `findingsPath` for a clearance, `registerRecordsPath` for a Knockout;
|
|
113
|
+
* `provider` is the run's register adapter; `injectedFetcher` true when the run answers its record fetches itself (a
|
|
114
|
+
* replay, a test). Writes `_driver/logos.json`; returns it, or null when it could not. Never throws.
|
|
115
|
+
*/
|
|
116
|
+
export async function markLogos(runDir, { findingsPath = null, registerRecordsPath = null, provider = null, injectedFetcher = false,
|
|
117
|
+
env = process.env, agentId = null, sessionKey = null } = {}) {
|
|
118
|
+
try {
|
|
119
|
+
const read = (p) => { try { return p ? JSON.parse(readFileSync(p, "utf8")) : null; } catch { return null; } };
|
|
120
|
+
const findings = read(findingsPath)?.findings ?? null;
|
|
121
|
+
const refs = citedRefs({ findings, registerRecords: read(registerRecordsPath) });
|
|
122
|
+
const at = driverDir(runDir, LOGOS_FILE);
|
|
123
|
+
const prior = read(at)?.rows ?? [];
|
|
124
|
+
const register = provider?.id ?? null;
|
|
125
|
+
const credential = provider?.credEnv ? String(env[provider.credEnv] ?? "").trim() : "";
|
|
126
|
+
const mayCall = injectedFetcher ? { ok: false, why: "this run answers its record fetches from saved records and makes no register call" }
|
|
127
|
+
: !provider ? { ok: false, why: "no register is set for this run" }
|
|
128
|
+
: !credential ? { ok: false, why: `${provider.credEnv ?? "the register's credential"} is not set, so no register call is made` }
|
|
129
|
+
: { ok: true };
|
|
130
|
+
const fetchImage = typeof provider?.markImage === "function" ? (ref) => provider.markImage(ref, { agentId, sessionKey }) : null;
|
|
131
|
+
const rows = await logoRows({ runDir, refs, records: readRecordArtifacts(runDir), register, fetchImage, mayCall, prior });
|
|
132
|
+
const doc = { schema: 1, register, takenAt: new Date().toISOString(), rows };
|
|
133
|
+
writeFileSync(at, JSON.stringify(doc, null, 2) + "\n");
|
|
134
|
+
return doc;
|
|
135
|
+
} catch { return null; }
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** The run's log line for the step: how many registrations ended in each state, or that the step could not write. */
|
|
139
|
+
export function logosStep(runDir, doc) {
|
|
140
|
+
const counts = {};
|
|
141
|
+
for (const r of doc?.rows ?? []) counts[r.state] = (counts[r.state] ?? 0) + 1;
|
|
142
|
+
try { runLog(runDir, doc ? { event: "logos", register: doc.register, ...counts } : { event: "logos-not-written" }); } catch { /* a log line never stops a publish */ }
|
|
143
|
+
return counts;
|
|
144
|
+
}
|
|
@@ -59,7 +59,7 @@ export function skillRefsIn(message) {
|
|
|
59
59
|
* the invisibility it is fixing.
|
|
60
60
|
*/
|
|
61
61
|
export function witnessStageMethodology(runDir, stage, message, resolveSkill, { platform = process.platform } = {}) {
|
|
62
|
-
const out = { drift: [], fellBackToBase: [], recorded: 0 };
|
|
62
|
+
const out = { drift: [], fellBackToBase: [], recorded: 0, told: [] };
|
|
63
63
|
const underSkills = new RegExp(`${sepClass(platform)}skills${sepClass(platform)}`);
|
|
64
64
|
const nameOf = platform === "win32" ? win32.basename : basename;
|
|
65
65
|
try {
|
|
@@ -97,6 +97,7 @@ export function witnessStageMethodology(runDir, stage, message, resolveSkill, {
|
|
|
97
97
|
|
|
98
98
|
doc.stages[stage] = seen;
|
|
99
99
|
out.recorded = seen.length;
|
|
100
|
+
out.told = seen; // the rows themselves, so the caller measures this turn against what IT was told (manuals-seen.mjs)
|
|
100
101
|
ensureDriverDir(runDir);
|
|
101
102
|
writeFileSync(`${path}.tmp`, JSON.stringify(doc, null, 2) + "\n");
|
|
102
103
|
renameSync(`${path}.tmp`, path); // atomic: a torn witness must never look like drift
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
//
|
|
17
17
|
// ── WHY THE DRIVER RUNS THE QUERY, RATHER THAN THE SEAT BEING TOLD TO ───────────────────────────────
|
|
18
18
|
//
|
|
19
|
-
// The clearance lane
|
|
20
|
-
//
|
|
21
|
-
// only proof a query ran." That was the best substrate available there.
|
|
19
|
+
// The clearance lane enforced its use-check on the DOCUMENT SHAPE of the narrative, and the retired gate
|
|
20
|
+
// said plainly why: "There is no perplexity call ledger … so the cited result inside the narrative is the
|
|
21
|
+
// only proof a query ran." That was the best substrate available there; it is a findings-record field now.
|
|
22
22
|
//
|
|
23
23
|
// This lane has a better one. The driver already owns the register store, already runs the sweep, and
|
|
24
24
|
// already writes a receipts ledger — so it can issue the query ITSELF and record the outcome at the
|
package/driver/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "clearotron-driver",
|
|
3
3
|
"private": true,
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.7.0-beta.0",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
7
7
|
"description": "Deterministic driver for the trademark clearance workflow: orchestration in code (fan-out, fan-in barrier, gating, retries); the model does judgment leaves only, through a reasoning CLI spawned per stage.",
|
|
8
8
|
"engines": {
|
|
@@ -57,6 +57,7 @@ import { correctionsAppliedTable, unresolvedFlags } from "./corrections-feedforw
|
|
|
57
57
|
import { settledKnockoutReading } from "./knockout-register-record.mjs";
|
|
58
58
|
import { stripNextStepSections } from "./knockout-next-step.mjs";
|
|
59
59
|
import { publishKnockout, composeKnockoutEmail, knockoutName } from "./publish/knockout.mjs";
|
|
60
|
+
import { markLogos, logosStep } from "./mark-logos.mjs";
|
|
60
61
|
import { writeRunStatus, readRunStatus, rollupStatus, identitySeed, recordTransition, resumeRecord } from "./progress.mjs"; // — the identity seed is shared; the stepper is not
|
|
61
62
|
import { batchMarkName } from "./mark-name.mjs";
|
|
62
63
|
import { runLog, note, outputMeta } from "./log.mjs";
|
|
@@ -1471,6 +1472,9 @@ export async function knockoutInner(ctx, job, opts = {}) {
|
|
|
1471
1472
|
const moved = withCitedFilings(held, merged);
|
|
1472
1473
|
if (moved !== held) atomicWrite(K.registerRecords, JSON.stringify(moved, null, 2) + "\n");
|
|
1473
1474
|
} catch { /* no record on this run, or none readable: publish says which */ }
|
|
1475
|
+
// THE LOGOS of the listed filings, as the clearance's are fetched (mark-logos.mjs), before the page is built.
|
|
1476
|
+
logosStep(run.runDir, await markLogos(run.runDir, { registerRecordsPath: K.registerRecords, provider: (() => { try { return adapterForRegister(ctx.register ?? null); } catch { return null; } })(),
|
|
1477
|
+
injectedFetcher: Boolean(opts.recordFetcher), agentId: ctx.agent ?? null }));
|
|
1474
1478
|
published = await publishKnockout({
|
|
1475
1479
|
runId, codename: run.codename, runDir: run.runDir,
|
|
1476
1480
|
findings: merged, plan, framework: ctx.framework, overall,
|