clearotron 0.5.0-beta.7 → 0.5.0-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 +9 -1
- package/INSTALL.md +1 -1
- package/bin/signa-sync.mjs +1 -1
- package/build-info.json +2 -2
- package/docs/architecture/04-configuration-reference.md +1 -0
- package/docs/configuration.md +1 -1
- package/driver/CHANGELOG.md +7 -0
- package/driver/engine/mcp/correction-positions.mjs +18 -0
- package/driver/engine/mcp/gather-config.mjs +7 -3
- package/driver/engine/mcp/recording-server.mjs +7 -4
- package/driver/findings-model.mjs +4 -2
- package/driver/gateway.mjs +26 -16
- package/driver/package.json +1 -1
- package/driver/pipeline.mjs +46 -11
- package/driver/repair-composers.mjs +13 -7
- package/driver/skills/clearance-register/providers/signa.md +6 -4
- package/driver/stage-context.mjs +3 -0
- package/driver/suite-census.json +24 -6
- package/driver/synthesis-record.mjs +165 -33
- package/mcp-server/CHANGELOG.md +4 -0
- package/mcp-server/package.json +1 -1
- package/package.json +1 -1
- package/portal-ui/package.json +1 -1
- package/providers/README.md +1 -1
- package/providers/oauth-mcp-bridge/CHANGELOG.md +4 -0
- package/providers/oauth-mcp-bridge/package.json +1 -1
- package/providers/signa/src/offices.generated.js +15 -13
- package/shared/names-in-force.mjs +1 -0
- package/shared/register-selection.mjs +2 -2
package/.env.example
CHANGED
|
@@ -191,6 +191,14 @@ CLEAROTRON_DATABASE=clarivate
|
|
|
191
191
|
# effect: tuning
|
|
192
192
|
CLEAROTRON_GATHER_SEND_UNTIL_MS=
|
|
193
193
|
#
|
|
194
|
+
# The records a correction's flags name, as a JSON list: the writer's save may add a finding for an
|
|
195
|
+
# excluded position that holds one of them. The driver writes it into the tool servers' env when it
|
|
196
|
+
# dispatches the correction and the correction's re-emit, and leaves it out of every other dispatch.
|
|
197
|
+
# Leave it empty: a stage's program starts with a listed environment that does not carry this name
|
|
198
|
+
# (driver/engine/engine-env.mjs), so a value set here reaches no tool server.
|
|
199
|
+
# effect: silent-output-change
|
|
200
|
+
CLEAROTRON_CORRECTION_POSITIONS=
|
|
201
|
+
#
|
|
194
202
|
# THERE IS NO RETENTION SETTING AND NO CLEANUP JOB. CLEAROTRON_REGISTER_LEDGER_MAX_BYTES,
|
|
195
203
|
# CLEAROTRON_REGISTER_LEDGER_KEEP and `npm run prune:ledger` are gone with the rotation tool, because the
|
|
196
204
|
# thing they bounded no longer grows: RECORD BODIES ARE WRITTEN INTO THE RUN'S OWN DIRECTORY
|
|
@@ -279,7 +287,7 @@ OPENAI_API_KEY=
|
|
|
279
287
|
# reason worth knowing before you leave it unset: an unset variable took Corsearch in silence, and the
|
|
280
288
|
# credential guard could not catch it because both boxes carried CORSEARCH_SESSION_KEY.
|
|
281
289
|
#
|
|
282
|
-
# ADR-0001 recommends Signa, not Corsearch: one self-serve key, US + EU + WIPO and
|
|
290
|
+
# ADR-0001 recommends Signa, not Corsearch: one self-serve key, US + EU + WIPO and ten more offices.
|
|
283
291
|
#
|
|
284
292
|
# Corsearch.
|
|
285
293
|
CORSEARCH_SESSION_KEY=changeme
|
package/INSTALL.md
CHANGED
|
@@ -117,7 +117,7 @@ run is [mcp-server/CONNECT.md](mcp-server/CONNECT.md), and why something is the
|
|
|
117
117
|
Which register you pick is the first real decision, and the tiers are not equally easy to reach.
|
|
118
118
|
[providers/README.md](providers/README.md) is the canonical ladder and
|
|
119
119
|
[ADR-0001](docs/decisions/0001-register-ladder.md) is the reasoning. The short version: **Signa** is
|
|
120
|
-
the recommended route (one self-serve key,
|
|
120
|
+
the recommended route (one self-serve key, thirteen offices), **`free-tier`** is EU + US with no vendor
|
|
121
121
|
contract but a 41.5 GB build for the US half (§3a), and **Corsearch / Clarivate** are the widest
|
|
122
122
|
coverage on a vendor-issued credential. Whatever the chosen register cannot reach becomes a disclosed
|
|
123
123
|
deferred-coverage row rather than a silent gap, at every tier.
|
package/bin/signa-sync.mjs
CHANGED
|
@@ -104,7 +104,7 @@ if (!live.length) die(`${offices.length} office(s) returned and NONE is status:l
|
|
|
104
104
|
const stamp = String(process.env.SIGNA_SYNC_STAMP ?? "").trim() || new Date().toISOString();
|
|
105
105
|
|
|
106
106
|
const body = `// SPDX-License-Identifier: AGPL-3.0-only
|
|
107
|
-
// Copyright 2026 Cordillera Sàrl
|
|
107
|
+
// Copyright 2026 Cordillera Sàrl. Additional terms under section 7 of the AGPL-3.0 apply — see ADDITIONAL-TERMS.md
|
|
108
108
|
// GENERATED by bin/signa-sync.mjs — do not edit by hand.
|
|
109
109
|
//
|
|
110
110
|
// This is the vendor's own office list, fetched and committed so that a change in what we claim to
|
package/build-info.json
CHANGED
|
@@ -375,6 +375,7 @@ cannot be read as one list.
|
|
|
375
375
|
| `CLEAROTRON_GATHER_SESSION_KEY` / `CLEAROTRON_GATHER_AGENT` / `CLEAROTRON_GATHER_SESSION_ID` | set per stage | Telemetry attribution into the provider-call ledger (set by the gather config; not operator-set). |
|
|
376
376
|
| `CLEAROTRON_GATHER_SEND_UNTIL_MS` | set per turn | When a turn's register tools stop sending new questions: a quarter of the turn, at most five minutes, ahead of its deadline (set by the gather config; not operator-set). |
|
|
377
377
|
| `CLEAROTRON_RECORD_AXIS` | set per dispatch (unset ⇒ the stage is not fanned out) | Binds one fan-out turn of a recording stage to the single member it may write. `stageOnce` suffixes a fan-out stage's label with its axis, the gather config resolves `<stage>:<axis>` back to the base stage's tool group, and this carries the axis to the recording server. A call whose payload names a different member than the turn is bound to is REFUSED, so a seat cannot write into a sibling's file — without the binding every turn of the fan-out would record over member one. Set by the driver; not operator-set. |
|
|
378
|
+
| `CLEAROTRON_CORRECTION_POSITIONS` | set per dispatch (unset ⇒ the dispatch is not a correction's) | The excluded positions named by the review flags a correction answers, as a JSON list of record ids, carried to the recording server for that correction's dispatch and its retries. The writer's save may add a finding for one of those positions; on any other dispatch it adds none (set by the gather config; not operator-set). |
|
|
378
379
|
| `PORTAL_READ_MODEL` | `sonnet` | The model the portal's own compose-read turn uses. Distinct from the pipeline's tiers: this is a portal surface, not a stage. |
|
|
379
380
|
| `CLEAROTRON_ORDER_PROBE_SEED` | unset | Seed for `scripts/band-shape-probe.mjs`, so an ordering probe can be replayed. A diagnostic script's knob, not a run's. |
|
|
380
381
|
| `PROBE_TERM` | `DELTA` | The mark word `providers/uspto-local/bin/verify-index.mjs` searches when verifying a built local USPTO index. A diagnostic script's knob, not a run's. Change it when a row reports MEASURES NOTHING: that means the term had no exact hit, so the row's timing is not a result. |
|
package/docs/configuration.md
CHANGED
|
@@ -22,7 +22,7 @@ that:
|
|
|
22
22
|
|
|
23
23
|
| | Provider | How you get it | Coverage |
|
|
24
24
|
|---|---|---|---|
|
|
25
|
-
| **1 — recommended** | `signa` | **Self-serve API key**, issued from the vendor's site. No sales call |
|
|
25
|
+
| **1 — recommended** | `signa` | **Self-serve API key**, issued from the vendor's site. No sales call | 13 offices: US, EU, WIPO/Madrid + 10 |
|
|
26
26
|
| **2 — free, with real limits** | `free-tier` (`euipo` + `uspto-local`) | Two free accounts, and a 41.5 GB local build for the US half | EU + US, and nothing else. No sound-alike search |
|
|
27
27
|
| **3 — widest coverage** | `corsearch`, `clarivate` | Credential issued by the vendor | Global; Clarivate reaches 186 offices |
|
|
28
28
|
|
package/driver/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# clearotron-driver
|
|
2
2
|
|
|
3
|
+
## 0.5.0-beta.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed: A conflict the reviewing step sends back for correction can now be reported as a finding; the correction could previously change only findings already in the report.
|
|
8
|
+
- New: Searches on the Signa register now reach Spain and Mexico, so an order naming either country is searched there rather than reported as not covered.
|
|
9
|
+
|
|
3
10
|
## 0.5.0-beta.7
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
// THE POSITIONS A CORRECTION HANDS ITS SAVE: the excluded positions its review flags name, for which the writer's save
|
|
5
|
+
// may add a finding (synthesis-record.mjs, `correctionPositions`). The driver writes them into the tool servers' env
|
|
6
|
+
// for that correction's dispatch (gather-config.mjs), and the save tool's server reads them there, never from the
|
|
7
|
+
// payload (recording-server.mjs). Their own module, so a server reading them imports nothing else.
|
|
8
|
+
|
|
9
|
+
/** Where a correction's positions reach the save tool's server. */
|
|
10
|
+
export const CORRECTION_POSITIONS_ENV = "CLEAROTRON_CORRECTION_POSITIONS";
|
|
11
|
+
|
|
12
|
+
/** The positions a server was handed, or null where it was handed none it can read: no correction's dispatch. PURE. */
|
|
13
|
+
export function correctionPositionsFrom(env = process.env) {
|
|
14
|
+
if (!env) return null;
|
|
15
|
+
let v;
|
|
16
|
+
try { v = JSON.parse(String(env.CLEAROTRON_CORRECTION_POSITIONS ?? "")); } catch { return null; }
|
|
17
|
+
return Array.isArray(v) && v.length && v.every((u) => typeof u === "string") ? v : null;
|
|
18
|
+
}
|
|
@@ -11,6 +11,7 @@ import { fileURLToPath } from "node:url";
|
|
|
11
11
|
import { dirname, join } from "node:path";
|
|
12
12
|
import { requireRegisterProvider } from "../../driver.config.mjs";
|
|
13
13
|
import { ledgerPath, runRecordLogPath } from "../../../providers/_shared/ledger-path.mjs";
|
|
14
|
+
import { CORRECTION_POSITIONS_ENV } from "./correction-positions.mjs"; // the positions a correction hands its save
|
|
14
15
|
|
|
15
16
|
const MCP_DIR = dirname(fileURLToPath(import.meta.url));
|
|
16
17
|
const NODE = process.execPath;
|
|
@@ -849,7 +850,7 @@ export const claudeToolAnswerBytes = (env = process.env) =>
|
|
|
849
850
|
// The mcp-config server env carries ONLY the per-run, non-secret values (session key + ledger paths +
|
|
850
851
|
// agent + the run dir the band tools serve, and the answer size above). Creds (CORSEARCH_SESSION_KEY /
|
|
851
852
|
// PERPLEXITY_API_KEY / EUIPO_*) are inherited from the engine env.
|
|
852
|
-
function serverEnv({ sessionKey, agent, runDir, recordAxis, bandGroups = false }) {
|
|
853
|
+
function serverEnv({ sessionKey, agent, runDir, recordAxis, bandGroups = false, correctionPositions = null }) {
|
|
853
854
|
const e = {};
|
|
854
855
|
// — see buildGatherMcpConfig: a register server without a run is refused there, so by the time
|
|
855
856
|
// the record-log line below runs, `runDir` is present for every config that could use it.
|
|
@@ -862,6 +863,9 @@ function serverEnv({ sessionKey, agent, runDir, recordAxis, bandGroups = false }
|
|
|
862
863
|
// the server per turn so the acceptance boundary can refuse a payload naming any other index, which
|
|
863
864
|
// turns O3c's measured 224/0 habit into a structure. Absent for every non-fan-out stage.
|
|
864
865
|
if (recordAxis) e.CLEAROTRON_RECORD_AXIS = String(recordAxis);
|
|
866
|
+
// THE POSITIONS A CORRECTION'S FLAGS NAME, for which the writer's save may add a finding (synthesis-record.mjs,
|
|
867
|
+
// `correctionPositions`). The driver's answer for the correction it dispatches, and absent on every other dispatch.
|
|
868
|
+
if (Array.isArray(correctionPositions) && correctionPositions.length) e[CORRECTION_POSITIONS_ENV] = JSON.stringify(correctionPositions);
|
|
865
869
|
// — THE RUN'S REGISTER, so a recording tool gates a record link at the call as verify.mjs gates the
|
|
866
870
|
// saved file (record-origins.mjs). Handed over explicitly: Codex gives a server only its own `env` and
|
|
867
871
|
// the names it forwards, so a value left to inheritance reaches a Claude server and never a Codex one.
|
|
@@ -915,7 +919,7 @@ export function withSendUntil(mcpConfigJson, sendUntilMs) {
|
|
|
915
919
|
return JSON.stringify(cfg);
|
|
916
920
|
}
|
|
917
921
|
|
|
918
|
-
export function buildGatherMcpConfig(groups = [], { sessionKey, agent, runDir, recordAxis, bandGroups = false } = {}) {
|
|
922
|
+
export function buildGatherMcpConfig(groups = [], { sessionKey, agent, runDir, recordAxis, bandGroups = false, correctionPositions = null } = {}) {
|
|
919
923
|
const localKeys = new Set(), bridgeKeys = new Set();
|
|
920
924
|
for (const g of groups) { const r = resolveGroup(g); r.local.forEach((k) => localKeys.add(k)); r.bridges.forEach((k) => bridgeKeys.add(k)); }
|
|
921
925
|
const mcpServers = {};
|
|
@@ -945,7 +949,7 @@ export function buildGatherMcpConfig(groups = [], { sessionKey, agent, runDir, r
|
|
|
945
949
|
+ "belong to their run, and the box-global ledger is retired. Pass runDir.");
|
|
946
950
|
}
|
|
947
951
|
}
|
|
948
|
-
const env = serverEnv({ sessionKey, agent, runDir, recordAxis, bandGroups });
|
|
952
|
+
const env = serverEnv({ sessionKey, agent, runDir, recordAxis, bandGroups, correctionPositions });
|
|
949
953
|
for (const k of localKeys) mcpServers[k] = { command: NODE, args: [join(MCP_DIR, localEntry(k).script)], env };
|
|
950
954
|
// — THE BRIDGES GET THE AUDIT ENV, AND ONLY THAT. Until now they were spawned with no env at
|
|
951
955
|
// all, so a case-law tool call had nowhere to log: `tool-calls.jsonl` recorded server/tool/ok and the
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
// same served-vs-granted delta as the record tools, pinned by the same census.
|
|
38
38
|
import { serve } from "./stdio-server.mjs";
|
|
39
39
|
import { recordSynthesis } from "../../synthesis-record.mjs"; // the writer
|
|
40
|
+
import { correctionPositionsFrom } from "./correction-positions.mjs"; // the positions a correction's dispatch hands its save
|
|
40
41
|
import { recordRegisterDigest } from "../../register-digest-record.mjs"; // conversion 11 — the findings document
|
|
41
42
|
import { FINDING_KEYS_CURRENT, COVERAGE_AREA_STATES } from "../../findings-model.mjs";
|
|
42
43
|
import { recordBlindFrame } from "../../blind-frame-record.mjs";
|
|
@@ -234,7 +235,9 @@ async function record_synthesis(params) {
|
|
|
234
235
|
// The intake asks, the plan-execution receipt and the frozen framework are read from the RUN by
|
|
235
236
|
// `recordSynthesis` itself. They are not parameters and there is nothing to thread here: a seat that
|
|
236
237
|
// could hand us its own receipt could waive its own coverage join.
|
|
237
|
-
|
|
238
|
+
// THE CORRECTION'S POSITIONS ARE THE DRIVER'S AND ARE READ HERE, never taken from the payload: a seat that could name
|
|
239
|
+
// them could add a finding for any position it chose. Absent on every dispatch that is not a correction's.
|
|
240
|
+
return recordSynthesis(runDir, params, { correction: correctionPositionsFrom(process.env) });
|
|
238
241
|
}
|
|
239
242
|
|
|
240
243
|
async function search_run_artifacts(params) {
|
|
@@ -1098,13 +1101,13 @@ serve({
|
|
|
1098
1101
|
findings_patch: {
|
|
1099
1102
|
type: "array",
|
|
1100
1103
|
description:
|
|
1101
|
-
"A TARGETED CORRECTION
|
|
1104
|
+
"A TARGETED CORRECTION. Send complete finding objects in `findings_patch`. To change an existing finding, use its current `ordinal`. To add a finding for an excluded position named in this correction's review flags, use a new `ordinal` after the highest in the current record and cite a record from that position. Include `narrative` only for sections you changed, and a `findings` object only for changed registers or the corrections marker. Do not send a `findings[]` list. The driver keeps everything the patch does not change. A patch does not delete findings; withdraw a finding using its existing disposition fields.",
|
|
1102
1105
|
items: {
|
|
1103
1106
|
type: "object",
|
|
1104
1107
|
required: ["ordinal"],
|
|
1105
|
-
description: "One complete finding object. `ordinal`
|
|
1108
|
+
description: "One complete finding object. `ordinal` identifies the finding being changed or the new finding being added for a flagged excluded position.",
|
|
1106
1109
|
properties: {
|
|
1107
|
-
ordinal: { type: "number", description: "
|
|
1110
|
+
ordinal: { type: "number", description: "For an existing finding, use its current ordinal. For a new finding answering a review flag about an excluded position in this correction, use an unused positive whole number after the highest ordinal in the current record." },
|
|
1108
1111
|
// ── — THE ROW IS A FINDING, AND THE SCHEMA NOW SAYS WHICH KEYS THAT MEANS ──
|
|
1109
1112
|
//
|
|
1110
1113
|
// The description above has always called this "one complete finding object" while the
|
|
@@ -810,6 +810,8 @@ const OWN_RIGHTS_KEYS = ["source"];
|
|
|
810
810
|
const DEADLINE_KEYS = ["kind", "date"]; // #6 — a CLIENT-facing time-critical date (opposition / SOU / renewal)
|
|
811
811
|
|
|
812
812
|
const short = (v) => String(v ?? "").replace(/\s+/g, " ").trim().slice(0, 40);
|
|
813
|
+
/** The parser's words for an ordinal that is missing, not a whole number, or below 1. The save's transport uses them too. */
|
|
814
|
+
export const findingOrdinalInvalid = (ord) => `finding_ordinal_invalid:${short(ord)} (ordinal must be an integer >= 1)`;
|
|
813
815
|
// The version-laddered key allowlists, in ONE place — both parsers (strict + lenient) read it, so a new
|
|
814
816
|
// version can never tighten one path and leave the other on the old list.
|
|
815
817
|
const topKeysFor = (mode) => (mode.v7 ? TOP_KEYS_V7 : mode.v6 ? TOP_KEYS_V6 : mode.v5 ? TOP_KEYS_V5 : mode.v4 ? TOP_KEYS_V4 : TOP_KEYS);
|
|
@@ -1379,7 +1381,7 @@ function validateFinding(f, idx, seenOrdinals, mode = { v4: false, manifest: nul
|
|
|
1379
1381
|
|
|
1380
1382
|
// ordinal — 1-based, integer, unique (the F1/F2 drill-through id; markers and cards share it).
|
|
1381
1383
|
const ord = f.ordinal;
|
|
1382
|
-
if (!Number.isInteger(ord) || ord < 1) throw new Error(
|
|
1384
|
+
if (!Number.isInteger(ord) || ord < 1) throw new Error(findingOrdinalInvalid(ord));
|
|
1383
1385
|
if (seenOrdinals.has(ord)) throw new Error(`finding_ordinal_duplicate:${ord} (each finding's ordinal must be unique)`);
|
|
1384
1386
|
seenOrdinals.add(ord);
|
|
1385
1387
|
|
|
@@ -1813,7 +1815,7 @@ function validateNet(f, ord, mode) {
|
|
|
1813
1815
|
// `findings?_` and would aim the repair turn at register-coverage-ledger.json — forbidding the model
|
|
1814
1816
|
// to rewrite the only file that could fix it.
|
|
1815
1817
|
// It reaches the wire as a validator `reason` (verify.mjs checkFindingsSibling), which is the only shape
|
|
1816
|
-
// gateway.mjs:
|
|
1818
|
+
// gateway.mjs:1204 judgeArtifacts mints as `invalid_file:<path>:<token>`; a bespoke throw would match nothing.
|
|
1817
1819
|
// The precedent is one line up the file: findings_mark_assessment_* was named plural for the same
|
|
1818
1820
|
// routing reason.
|
|
1819
1821
|
//
|
package/driver/gateway.mjs
CHANGED
|
@@ -887,7 +887,11 @@ async function runStageLadder(name, opts, stageCodexHome = null) {
|
|
|
887
887
|
// sweep) — a hard-wall timeout breaks after ONE attempt (a 1.5× extension can't fit
|
|
888
888
|
// an already-over-budget resume; the caller records the coverage-limited deferral).
|
|
889
889
|
excludeTools, bandSize, derivedLimit = null, // copper-lattice re-route: tool names dropped from this stage's allowedTools
|
|
890
|
+
// THE CORRECTION THIS DISPATCH IS, when it is one: `{positions}`, the excluded positions its flags name. Its save may
|
|
891
|
+
// add a finding for them, and its retries say so (`patchRows`); every other dispatch carries none.
|
|
892
|
+
correction = null,
|
|
890
893
|
} = opts;
|
|
894
|
+
const adds = Boolean(correction);
|
|
891
895
|
if (!message) throw new Error(`runStage(${name}): message is required`);
|
|
892
896
|
if (!sessionKey) throw new Error(`runStage(${name}): sessionKey is required`);
|
|
893
897
|
const files = (Array.isArray(expectFile) ? expectFile : [expectFile]).filter(Boolean);
|
|
@@ -930,7 +934,7 @@ async function runStageLadder(name, opts, stageCodexHome = null) {
|
|
|
930
934
|
// The bound card index rides the same label the grant was resolved from — derived by the SAME
|
|
931
935
|
// declared rule (`perAxis`), never by a second string-sniff that could disagree with it.
|
|
932
936
|
const cfg = buildGatherMcpConfig(groups, { sessionKey, agent, runDir, recordAxis: recordAxisFor(name)?.axis,
|
|
933
|
-
bandGroups: GROUP_READING_STAGES.has(name) });
|
|
937
|
+
bandGroups: GROUP_READING_STAGES.has(name), correctionPositions: correction?.positions ?? null });
|
|
934
938
|
gatherMcpConfig = cfg ? JSON.stringify(cfg) : undefined;
|
|
935
939
|
gatherAllowedTools = allowedToolsFor(groups);
|
|
936
940
|
gatherSeatWrites = seatWritesForGroups(groups); // — the SAME derivation allowedToolsFor uses
|
|
@@ -1091,7 +1095,7 @@ async function runStageLadder(name, opts, stageCodexHome = null) {
|
|
|
1091
1095
|
try { const fresh = refreshMessage(attempt); if (typeof fresh === "string" && fresh) base = fresh; }
|
|
1092
1096
|
catch (e) { note(`[${name}] refreshMessage failed on attempt ${attempt}, dispatching the original text: ${String(e?.message ?? e).slice(0, 120)}`); }
|
|
1093
1097
|
}
|
|
1094
|
-
const effMessage = warm ? warmPatchMessage(lastFail, files, { supplementalLane }) : correctiveMessage(base, attempt, lastFail, files, { supplementalLane });
|
|
1098
|
+
const effMessage = warm ? warmPatchMessage(lastFail, files, { supplementalLane, adds }) : correctiveMessage(base, attempt, lastFail, files, { supplementalLane, adds });
|
|
1095
1099
|
note(`[${name}] attempt ${attempt}/${maxRetries + 1}${warm ? " [warm patch]" : ""} (engine=${engine.name} agent=${agent} model=${model ?? "default"} key=${key} timeout=${effTimeout}s)`);
|
|
1096
1100
|
// The engine runs ONE turn and returns the normalized tuple. Every adapter returns the same shape
|
|
1097
1101
|
// (zero change); anthropic-agent = claude -p off-gateway with the stall-watchdog. A warm retry threads
|
|
@@ -1351,7 +1355,7 @@ async function runStageLadder(name, opts, stageCodexHome = null) {
|
|
|
1351
1355
|
note(`[${name}] FORM defect at write time (${triggeredBy.slice(0, 140)}) — repairing INSIDE this dispatch (${formRepairsUsed}/${MAX_FORM_REPAIRS}) at ${rel(target)}; the retry ladder is not charged`);
|
|
1352
1356
|
//: a form repair is a real model invocation, so it gets its own record rather than hiding
|
|
1353
1357
|
// inside the attempt it belongs to. Hoisted only to be recordable — the message is unchanged.
|
|
1354
|
-
const repairMessage = warmPatchMessage(triggeredBy, files, { supplementalLane });
|
|
1358
|
+
const repairMessage = warmPatchMessage(triggeredBy, files, { supplementalLane, adds });
|
|
1355
1359
|
const repairDispatch = envGateOn("CLEAROTRON_DISPATCH_RECORD")
|
|
1356
1360
|
? recordDispatch(runDir, name, { attempt, repair: formRepairsUsed + 1, kind: "form-repair", message: repairMessage })
|
|
1357
1361
|
: null;
|
|
@@ -2250,7 +2254,7 @@ function rel(p) {
|
|
|
2250
2254
|
// missing_file) get corrective text — a timeout/transport failure is fixed by re-running, not by different content.
|
|
2251
2255
|
// opts.supplementalLane (trailing + optional, so every positional caller is unchanged): the failing stage
|
|
2252
2256
|
// ran without register_enumerate, so a hint that names it would contradict the prompt it is appended to.
|
|
2253
|
-
export function correctiveMessage(baseMessage, attempt, lastFail, expectFile, { supplementalLane = false } = {}) {
|
|
2257
|
+
export function correctiveMessage(baseMessage, attempt, lastFail, expectFile, { supplementalLane = false, adds = false } = {}) {
|
|
2254
2258
|
if (attempt <= 1 || !lastFail) return baseMessage;
|
|
2255
2259
|
// A6 (addendum 2026-07-30): the max_tokens fault wraps the underlying content failure (or stands bare
|
|
2256
2260
|
// on a transport-shaped turn). The retry must be told the CAUSE was the output ceiling — an unnamed
|
|
@@ -2287,7 +2291,7 @@ export function correctiveMessage(baseMessage, attempt, lastFail, expectFile, {
|
|
|
2287
2291
|
`\n\nCORRECTION: ${budget}${requiredFileClause(inner, { names, toolWritten })}`;
|
|
2288
2292
|
return baseMessage +
|
|
2289
2293
|
`\n\nCORRECTION: your previous attempt failed file validation (${inner}). ${budget}Re-do the task and make sure ` +
|
|
2290
|
-
`${correctionHint(inner, { gridLedgerName: gridLedgerNameFor(expectFile), supplementalLane, undispatchable: frameDiffUndispatchable(expectFile, inner), heldRecord: heldSynthesisRecord(files) })}. ` +
|
|
2294
|
+
`${correctionHint(inner, { gridLedgerName: gridLedgerNameFor(expectFile), supplementalLane, undispatchable: frameDiffUndispatchable(expectFile, inner), heldRecord: heldSynthesisRecord(files), adds })}. ` +
|
|
2291
2295
|
requiredFileClause(inner, { names, toolWritten });
|
|
2292
2296
|
}
|
|
2293
2297
|
|
|
@@ -2377,16 +2381,22 @@ const CLEARANCE_FINDINGS_TOKEN_RE = /(?<!knockout_|knockoutassess_)findings?_/;
|
|
|
2377
2381
|
// patch the follow-ups above it ask for. A record nobody saved yet, or one whose version is being replaced, still
|
|
2378
2382
|
// takes the complete save.
|
|
2379
2383
|
// The patch a held record takes, in the tool's own words; the retry for most findings checks leaves the narrative as it is.
|
|
2380
|
-
|
|
2381
|
-
|
|
2384
|
+
// On the correction answering a review's flags, and on its retries, the rows are described in the words ruled for that
|
|
2385
|
+
// correction (2026-11-02): it may add the finding for an excluded position its flags name (synthesis-record.mjs).
|
|
2386
|
+
export const REPLACED_ROWS = "the complete corrected finding object(s), each with the `ordinal` it replaces";
|
|
2387
|
+
export const CORRECTION_ROWS = "the complete finding objects you changed or added: keep each existing finding's `ordinal`; for a new finding answering a flag about an excluded position named in this correction, use the next unused ordinal after the highest in the current record and cite a record from that position";
|
|
2388
|
+
/** The rows a held record's patch carries: on a correction's dispatch (`adds`), the finding it may add among them. PURE. */
|
|
2389
|
+
export const patchRows = (adds = false) => (adds ? CORRECTION_ROWS : REPLACED_ROWS);
|
|
2390
|
+
const heldRecordPatch = (adds = false) => `ONE \`record_synthesis\` PATCH call, sending only the change: \`findings_patch\` carrying ${patchRows(adds)}, and \`findings\` carrying any register you corrected, complete, and never a \`findings[]\` list`;
|
|
2391
|
+
const heldRecordRetry = (adds = false) => `Fix exactly that in ${heldRecordPatch(adds)}; leave the narrative prose unchanged`;
|
|
2382
2392
|
const VERSION_FAILURE_RE = /finding_legacy_scale_forbidden|schema_version/;
|
|
2383
2393
|
// A USE CHECK'S CORRECTION corrects what depends on the finding too, so it never says to leave the narrative as it is
|
|
2384
2394
|
// (design, 2026-10-28). A held record takes the patch, in the tool's own words, with the narrative sections it changes;
|
|
2385
2395
|
// a record not yet accepted is completed by its first call, which the line after every hint names. The caller prints a
|
|
2386
2396
|
// full stop after the hint, so the ruled sentences go without their last one.
|
|
2387
2397
|
const USE_CHECK_TOKEN_RE = /finding_use_check_(missing|source_missing):/;
|
|
2388
|
-
const useCheckCorrection = (heldRecord) => heldRecord
|
|
2389
|
-
? `${RESEARCH_CORRECTION} Send it in ${
|
|
2398
|
+
const useCheckCorrection = (heldRecord, adds = false) => heldRecord
|
|
2399
|
+
? `${RESEARCH_CORRECTION} Send it in ${heldRecordPatch(adds)}. In \`narrative\`, send only the sections you changed — the rest are held`
|
|
2390
2400
|
: RESEARCH_CORRECTION.replace(/\.$/, "");
|
|
2391
2401
|
/**
|
|
2392
2402
|
* Does the driver hold an accepted synthesis record for the run these files belong to? Read from either of the files
|
|
@@ -2397,7 +2407,7 @@ export const heldSynthesisRecord = (files) => {
|
|
|
2397
2407
|
return Boolean(f) && existsSync(synthesisCallPaths(dirname(f)).accepted);
|
|
2398
2408
|
};
|
|
2399
2409
|
|
|
2400
|
-
export function correctionHint(lastFail, { gridLedgerName = "common-law-grid.json", supplementalLane = false, undispatchable = [], toolWritten = null, heldRecord = false } = {}) {
|
|
2410
|
+
export function correctionHint(lastFail, { gridLedgerName = "common-law-grid.json", supplementalLane = false, undispatchable = [], toolWritten = null, heldRecord = false, adds = false } = {}) {
|
|
2401
2411
|
// The repair act, for the hints that name one. Kept to a single sentence and a single decision so a
|
|
2402
2412
|
// new hint has one thing to append rather than a branch to reproduce.
|
|
2403
2413
|
const resaveClause = toolWritten
|
|
@@ -2497,8 +2507,8 @@ export function correctionHint(lastFail, { gridLedgerName = "common-law-grid.jso
|
|
|
2497
2507
|
`registration — never overwrite or transpose another's facts; a finding with no fetched record → []), the four ` +
|
|
2498
2508
|
`meters as {token, basis} (basis = verified-from-record | inferred-from-signal), quadrant {x,y} in [0,1], a ` +
|
|
2499
2509
|
`typed source, a disposition, and a unique 1-based ordinal. The failed check was: ${tok}.${extra} ` +
|
|
2500
|
-
(USE_CHECK_TOKEN_RE.test(lastFail) ? useCheckCorrection(heldRecord)
|
|
2501
|
-
: heldRecord && !VERSION_FAILURE_RE.test(lastFail) ?
|
|
2510
|
+
(USE_CHECK_TOKEN_RE.test(lastFail) ? useCheckCorrection(heldRecord, adds)
|
|
2511
|
+
: heldRecord && !VERSION_FAILURE_RE.test(lastFail) ? heldRecordRetry(adds)
|
|
2502
2512
|
: `Fix exactly that, re-save the COMPLETE findings.json, and leave the narrative prose unchanged`);
|
|
2503
2513
|
} else if (/coverage_status_offenum/.test(lastFail)) {
|
|
2504
2514
|
// D1 — the off-enum PROSE Status cell (distinct from coverage_status_invalid, which is the JSON
|
|
@@ -3535,7 +3545,7 @@ function repairSiblingName(lastFail, expectFile) {
|
|
|
3535
3545
|
: null;
|
|
3536
3546
|
}
|
|
3537
3547
|
|
|
3538
|
-
export function warmPatchMessage(lastFail, expectFile, { supplementalLane = false } = {}) {
|
|
3548
|
+
export function warmPatchMessage(lastFail, expectFile, { supplementalLane = false, adds = false } = {}) {
|
|
3539
3549
|
const files = (Array.isArray(expectFile) ? expectFile : [expectFile]).filter(Boolean);
|
|
3540
3550
|
const names = files.map(rel).join(", ");
|
|
3541
3551
|
// named_band_missing (2026-07-14, copper-keystone): the band is ABSENT, not defective — the repair is a
|
|
@@ -3655,7 +3665,7 @@ export function warmPatchMessage(lastFail, expectFile, { supplementalLane = fals
|
|
|
3655
3665
|
? `Do NOT redo the work from scratch. This stage's own output is the driver's — it is rendered from your \`${outIsToolWritten.tool}\` call and you hold no tool that writes it, so there is nothing there for you to rewrite or protect.`
|
|
3656
3666
|
: `Do NOT redo the work from scratch, and do NOT rewrite ${names || "the findings file"} (it already passed validation).`;
|
|
3657
3667
|
return `You are RESUMING your own session for this stage — your prior work and inputs are already in your context. ${standsClause}\n` +
|
|
3658
|
-
`Your saved ${sibling} failed validation (${lastFail}). Fix exactly this: ensure ${correctionHint(lastFail, { gridLedgerName: gridLedgerNameFor(files), supplementalLane, undispatchable: frameDiffUndispatchable(files, lastFail), heldRecord: heldSynthesisRecord(files) })}.\n` +
|
|
3668
|
+
`Your saved ${sibling} failed validation (${lastFail}). Fix exactly this: ensure ${correctionHint(lastFail, { gridLedgerName: gridLedgerNameFor(files), supplementalLane, undispatchable: frameDiffUndispatchable(files, lastFail), heldRecord: heldSynthesisRecord(files), adds })}.\n` +
|
|
3659
3669
|
`Re-save the COMPLETE corrected JSON at ${sib}. Do not stop until it exists and is valid.`;
|
|
3660
3670
|
}
|
|
3661
3671
|
// — A BLIND-FRAME REPAIR IS A TOOL CALL, NOT A FILE WRITE, and this branch is what stops the two
|
|
@@ -3707,7 +3717,7 @@ export function warmPatchMessage(lastFail, expectFile, { supplementalLane = fals
|
|
|
3707
3717
|
// DIRECTIVES again, which is the 2026-07-29 reopen loss. Caught by frame-diff-model.test.mjs's
|
|
3708
3718
|
// cardinality pin, which asserts the warm path carries the full list without the caller passing
|
|
3709
3719
|
// anything.
|
|
3710
|
-
: `What you sent did not pass (${lastFail}). Fix exactly this: ensure ${correctionHint(lastFail, { supplementalLane, undispatchable: frameDiffUndispatchable(files, lastFail), toolWritten: toolWritten.tool, heldRecord: heldSynthesisRecord(files) })}.\n`) +
|
|
3720
|
+
: `What you sent did not pass (${lastFail}). Fix exactly this: ensure ${correctionHint(lastFail, { supplementalLane, undispatchable: frameDiffUndispatchable(files, lastFail), toolWritten: toolWritten.tool, heldRecord: heldSynthesisRecord(files), adds })}.\n`) +
|
|
3711
3721
|
`Call \`${toolWritten.tool}\` with the values from the work already in your context — never by writing or editing any file. ` +
|
|
3712
3722
|
`Do not stop until the tool accepts the call.`;
|
|
3713
3723
|
}
|
|
@@ -3727,7 +3737,7 @@ export function warmPatchMessage(lastFail, expectFile, { supplementalLane = fals
|
|
|
3727
3737
|
}
|
|
3728
3738
|
const defective = failingTarget(lastFail, files) ?? files[0] ?? null;
|
|
3729
3739
|
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` +
|
|
3730
|
-
`Your saved ${defective ? rel(defective) : names || "output"} failed validation (${lastFail}). Fix exactly this: ensure ${correctionHint(lastFail, { gridLedgerName: gridLedgerNameFor(files), supplementalLane, undispatchable: frameDiffUndispatchable(files, lastFail), heldRecord: heldSynthesisRecord(files) })}.\n` +
|
|
3740
|
+
`Your saved ${defective ? rel(defective) : names || "output"} failed validation (${lastFail}). Fix exactly this: ensure ${correctionHint(lastFail, { gridLedgerName: gridLedgerNameFor(files), supplementalLane, undispatchable: frameDiffUndispatchable(files, lastFail), heldRecord: heldSynthesisRecord(files), adds })}.\n` +
|
|
3731
3741
|
editRepairTail(defective || names || "the stage output");
|
|
3732
3742
|
}
|
|
3733
3743
|
|
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.0-beta.
|
|
5
|
+
"version": "0.5.0-beta.8",
|
|
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": {
|
package/driver/pipeline.mjs
CHANGED
|
@@ -5469,6 +5469,9 @@ async function stageOnce(name, ctx, opts = {}) {
|
|
|
5469
5469
|
...(name === "register-unit" && ctx.registerPlan?.contract?.supplemental_lane
|
|
5470
5470
|
? { excludeTools: [REGISTER_ENUMERATE_TOOL] } : {}),
|
|
5471
5471
|
...(opts.maxRetries != null ? { maxRetries: opts.maxRetries } : {}),
|
|
5472
|
+
// The correction this dispatch is, when it is one: its save may add the finding for an excluded position its flags
|
|
5473
|
+
// name. Only the correction's own dispatches carry it.
|
|
5474
|
+
...(opts.correction ? { correction: opts.correction } : {}),
|
|
5472
5475
|
});
|
|
5473
5476
|
// run.jsonl "stage" event carries the input→output LINKAGE telemetry (what this stage handed downstream),
|
|
5474
5477
|
// the WHY (trigger), and the model — the per-attempt execution detail (wall/status/usage) is in _driver/<stage>.jsonl.
|
|
@@ -6164,7 +6167,12 @@ function withPositionLabels(scope, P) {
|
|
|
6164
6167
|
return { ...scope, positionLabels: scope.positions.map(label) };
|
|
6165
6168
|
}
|
|
6166
6169
|
|
|
6167
|
-
|
|
6170
|
+
/**
|
|
6171
|
+
* The review as the correction reads it, once: the pieces of its message, and the excluded positions its flags name,
|
|
6172
|
+
* which its dispatch also hands the writer's save (synthesis-record.mjs, `correctionPositions`), so the positions the
|
|
6173
|
+
* message names are the positions the save may add a finding for. IMPURE (reads the run).
|
|
6174
|
+
*/
|
|
6175
|
+
export function correctionReading(P) { // @internal
|
|
6168
6176
|
const review = existsSync(P.seniorEyeReview) ? readFileSync(P.seniorEyeReview, "utf8") : "";
|
|
6169
6177
|
const rulingsTail = extractRulingsTail(existsSync(P.placement) ? readFileSync(P.placement, "utf8") : "");
|
|
6170
6178
|
// — THE FLAGS ARRIVE AS A TYPED WORKLIST, not only as a wall of prose. The reviewer already
|
|
@@ -6210,11 +6218,20 @@ export function correctionsExtra(P, depth = null, framework = null) { // @inte
|
|
|
6210
6218
|
// declaration, never assumed on its behalf. The positions the flags named ride either way, with their rows.
|
|
6211
6219
|
const named = flaggedPositions(rows);
|
|
6212
6220
|
const scope = withPositionLabels({ ...correctionScope(rows), ...(named.length ? { positions: named } : {}) }, P);
|
|
6221
|
+
return { review, rulingsTail, worklist, scope, positions: named };
|
|
6222
|
+
}
|
|
6223
|
+
|
|
6224
|
+
export function correctionsExtra(P, depth = null, framework = null, reading = correctionReading(P)) { // @internal
|
|
6225
|
+
const { review, rulingsTail, worklist, scope } = reading;
|
|
6213
6226
|
// THE RUNG RIDES THE CORRECTIVE RE-EMISSION, byte-identically with the fresh dispatch. Appended rather
|
|
6214
6227
|
// than threaded through `repairFollowup`'s fields so both dispatches carry the SAME STRING from the
|
|
6215
6228
|
// SAME function, and an arm can compare them without knowing how either is assembled.
|
|
6229
|
+
// THE RECORD ITS PATCH UPDATES. The save patches the writer's own record, and the flags name its findings in its
|
|
6230
|
+
// numbering; from the delivery seam on, findings.json is the folded record, renumbered. So while a fold is in force,
|
|
6231
|
+
// a correction re-armed on a later pass is handed the writer's record (record-fold.mjs), as the lint's repair is: a
|
|
6232
|
+
// number read off the folded record names another finding there, and the next one after it a finding already held.
|
|
6216
6233
|
return repairFollowup("synthesis:corrective", {
|
|
6217
|
-
narrative: P.narrative, findings: P.findings, placement: P.placement,
|
|
6234
|
+
narrative: P.narrative, findings: modelRecordPath(P.runDir, P.findings), placement: P.placement,
|
|
6218
6235
|
rulingsTail, scope, worklist, review,
|
|
6219
6236
|
}) + stageCharter("synthesis", depth, framework);
|
|
6220
6237
|
}
|
|
@@ -7594,8 +7611,9 @@ async function runPostRepairCorrection(ctx, P, run, { rec, items, points, ground
|
|
|
7594
7611
|
const rows = rec.flags.map((f, i) => ({ n: i + 1, kind: f.kind, text: f.text, fix: f.fix ?? null, ordinals: flagOrdinals(f) }));
|
|
7595
7612
|
const review = readFileSync(Pv.seniorEyeReview, "utf8");
|
|
7596
7613
|
const rulingsTail = extractRulingsTail(existsSync(P.placement) ? readFileSync(P.placement, "utf8") : "");
|
|
7614
|
+
// The writer's own record, in the numbering of the items and of the patch, while the delivery fold is in force.
|
|
7597
7615
|
const followup = repairFollowup("synthesis:post-repair-corrective", {
|
|
7598
|
-
narrative: P.narrative, findings: P.findings, placement: P.placement, rulingsTail,
|
|
7616
|
+
narrative: P.narrative, findings: modelRecordPath(runDir, P.findings), placement: P.placement, rulingsTail,
|
|
7599
7617
|
items: named, renumbered: anyRenumbered(items), worklist: correctionsWorklist(rows, { afterRepair: true }), review, whole,
|
|
7600
7618
|
});
|
|
7601
7619
|
const before = lastAcceptedCall(runDir);
|
|
@@ -7644,6 +7662,8 @@ async function runPostRepairCorrection(ctx, P, run, { rec, items, points, ground
|
|
|
7644
7662
|
return { ran: true, ok: Boolean(pass.ok), rollback, applied };
|
|
7645
7663
|
}
|
|
7646
7664
|
|
|
7665
|
+
// `resume.correction` is the first correction's (see its dispatch), handed on by that caller alone: the correction after
|
|
7666
|
+
// the review of a repair shares this follow-up and is handed no positions.
|
|
7647
7667
|
async function enforceCorrectionsReachFindings(ctx, P, pre, resume) {
|
|
7648
7668
|
if (!pre) return; // no findings.json before the pass — nothing to enforce
|
|
7649
7669
|
const { run } = ctx;
|
|
@@ -7661,7 +7681,9 @@ async function enforceCorrectionsReachFindings(ctx, P, pre, resume) {
|
|
|
7661
7681
|
await stage("synthesis", ctx, {
|
|
7662
7682
|
force: true, sessionKey: resume.synthesisKey, model: resume.synthesisModel, thinking: resume.synthesisThinking,
|
|
7663
7683
|
trigger: "corrective-findings",
|
|
7664
|
-
|
|
7684
|
+
...(resume.correction ? { correction: resume.correction } : {}),
|
|
7685
|
+
// The writer's own record while a fold is in force, as the correction's own message names it (`correctionsExtra`).
|
|
7686
|
+
followup: repairFollowup("synthesis:corrective-findings", { findings: modelRecordPath(run.runDir, P.findings), named, seniorEyeReview: P.seniorEyeReview, adds: Boolean(resume.correction) }) + stageCharter("synthesis", ctx.depth, ctx.framework),
|
|
7665
7687
|
});
|
|
7666
7688
|
if (readState().stale) {
|
|
7667
7689
|
runLog(run.runDir, { event: "corrective-findings-stale", named });
|
|
@@ -14603,7 +14625,11 @@ async function pipelineInner(job, opts = {}) {
|
|
|
14603
14625
|
// silently: if the surface ever did move, the corrective's `row_index` would point into the previous
|
|
14604
14626
|
// pass's list and a declination would land on the wrong record.
|
|
14605
14627
|
prepareDeclinationSpec(ctx, P);
|
|
14606
|
-
|
|
14628
|
+
// THE CORRECTION RIDES ITS OWN DISPATCH: the excluded positions its flags name go to the writer's save with this
|
|
14629
|
+
// dispatch, its retries and the follow-up below, and with no other. The message names the same positions.
|
|
14630
|
+
const reading = correctionReading(P);
|
|
14631
|
+
const correction = { positions: reading.positions };
|
|
14632
|
+
const correctivePass = await stage("synthesis", ctx, { force: true, followup: correctionsExtra(P, ctx.depth, ctx.framework, reading), correction, sessionKey: synthesisKey, model: synthesisModel, thinking: synthesisThinking, trigger: "corrective" });
|
|
14607
14633
|
// half one — the corrective pass rewrites findings.json under a closed minimal-edit contract,
|
|
14608
14634
|
// so it is the pass most likely to change one record's fate. Its own account, at its own moment; the
|
|
14609
14635
|
// winner rule in record-discard.mjs lets this carry cancel an earlier discard.
|
|
@@ -14660,7 +14686,7 @@ async function pipelineInner(job, opts = {}) {
|
|
|
14660
14686
|
+ (repaired.leftRemoved.length ? `. ${repaired.leftRemoved.length} removal(s) the reviewer DID name stay removed.` : "")
|
|
14661
14687
|
+ " The reviewer re-reads the repaired document before it ships.");
|
|
14662
14688
|
}
|
|
14663
|
-
await enforceCorrectionsReachFindings(ctx, P, preCorrective, { synthesisKey, synthesisModel, synthesisThinking }); // A1 freshness gate
|
|
14689
|
+
await enforceCorrectionsReachFindings(ctx, P, preCorrective, { synthesisKey, synthesisModel, synthesisThinking, correction }); // A1 freshness gate
|
|
14664
14690
|
}
|
|
14665
14691
|
// — WHAT THE DRIVER OBSERVED, flag by flag, written before the recheck is dispatched. The
|
|
14666
14692
|
// recheck's whole cost is re-reading two documents to work out whether its own corrections landed;
|
|
@@ -14766,8 +14792,10 @@ async function pipelineInner(job, opts = {}) {
|
|
|
14766
14792
|
const rc = firstRef.key
|
|
14767
14793
|
? await stage("narrative-refutation", ctx, {
|
|
14768
14794
|
force: true, sessionKey: firstRef.key, model: firstRef.model, thinking: firstRef.thinking, trigger: "verdict-recheck",
|
|
14795
|
+
// The record its flags and the table above number, which is the writer's own while a fold is in force: a
|
|
14796
|
+
// correction that saved nothing leaves the earlier pass's fold standing (record-fold.mjs).
|
|
14769
14797
|
followup: repairFollowup("narrative-refutation:verdict-recheck", {
|
|
14770
|
-
narrative: P.narrative, findings: P.findings, seniorEyeReview: P.seniorEyeReview,
|
|
14798
|
+
narrative: P.narrative, findings: modelRecordPath(run.runDir, P.findings), seniorEyeReview: P.seniorEyeReview,
|
|
14771
14799
|
correctionsScope, appliedTable, restoredTable, evidenceTable, planAuditCarry,
|
|
14772
14800
|
writerExclusions: writerExclusionBlock(P, { review: "later", named: correctionsScope?.positions ?? [] }),
|
|
14773
14801
|
}),
|
|
@@ -18699,9 +18727,13 @@ function experimentEngineName() {
|
|
|
18699
18727
|
* The cap is deliberately far above any real number of concurrent draws, because this lock exists to be
|
|
18700
18728
|
* SEEN and never to ration. A draw that blocked here would be a new failure mode in place of an old one.
|
|
18701
18729
|
*/
|
|
18702
|
-
/**
|
|
18730
|
+
/**
|
|
18731
|
+
* Which findings the review is asked to ground in a profile, from the findings, the framework's bands and the depth. Read
|
|
18732
|
+
* from the writer's own record while a fold is in force, in the numbering of the narrative the review reads and of the
|
|
18733
|
+
* flags it writes (record-fold.mjs).
|
|
18734
|
+
*/
|
|
18703
18735
|
export const reviewProfileSelection = (ctx) => profileOrdinals({
|
|
18704
|
-
findings: safeReadJson(ctx.paths.findings),
|
|
18736
|
+
findings: safeReadJson(modelRecordPath(ctx.paths.runDir, ctx.paths.findings)),
|
|
18705
18737
|
bandOrder: ctx.framework?.bands ?? null,
|
|
18706
18738
|
maxRank: ctx.depth?.profileKeptBandRank ?? null,
|
|
18707
18739
|
});
|
|
@@ -18904,6 +18936,7 @@ async function runExperimentInner(job, opts) {
|
|
|
18904
18936
|
reviewerVerdict: existsSync(P.seniorEyeReview),
|
|
18905
18937
|
});
|
|
18906
18938
|
const whichPass = correctivePassState({ trigger: opts.dispatchTrigger ?? null, ready: correctiveReady.ready });
|
|
18939
|
+
let armCorrection = null;
|
|
18907
18940
|
if (opts.dispatchTrigger === "corrective") {
|
|
18908
18941
|
if (!correctiveReady.ready) {
|
|
18909
18942
|
// REFUSED BY NAME, never a fresh pass wearing a corrective label — which is exactly the quietly
|
|
@@ -18912,7 +18945,9 @@ async function runExperimentInner(job, opts) {
|
|
|
18912
18945
|
runLog(ctx.paths.runDir, { event: "experiment-refused", stage: name + (axis ? `:${axis}` : ""), reason: "no-corrective-state" });
|
|
18913
18946
|
return { ok: false, shadowDir, output: null, fail: "no_corrective_state", correctivePass: whichPass };
|
|
18914
18947
|
}
|
|
18915
|
-
const
|
|
18948
|
+
const reading = correctionReading(P);
|
|
18949
|
+
const blocks = correctionsExtra(P, ctx.depth, ctx.framework, reading); // depth+framework are RUN-level; only `P` is the sandbox's
|
|
18950
|
+
armCorrection = { positions: reading.positions }; // the arm's save may add what production's may
|
|
18916
18951
|
extra = [extra, blocks].filter(Boolean).join("\n\n");
|
|
18917
18952
|
extraIds = [...(extraIds ?? []), { id: "corrective-blocks", chars: blocks.length }];
|
|
18918
18953
|
}
|
|
@@ -19014,7 +19049,7 @@ async function runExperimentInner(job, opts) {
|
|
|
19014
19049
|
// ordering is not on the record is an arm nobody can attribute later, and attribution is the entire
|
|
19015
19050
|
// point of the probe — experiment runs were the one dispatch path that never wrote it.
|
|
19016
19051
|
runLog(shadowDir, { event: "order-probe", seed: orderProbeSeed() });
|
|
19017
|
-
const r = await stage(name, shadowCtx, { force: true, model, extra, sessionKey, trigger: "experiment" });
|
|
19052
|
+
const r = await stage(name, shadowCtx, { force: true, model, extra, sessionKey, trigger: "experiment", ...(armCorrection ? { correction: armCorrection } : {}) });
|
|
19018
19053
|
const out = STAGES[name].out ? STAGES[name].out(shadowCtx.paths, axis) : null;
|
|
19019
19054
|
|
|
19020
19055
|
// — AN ARM THAT PRODUCED NOTHING DOES NOT PRINT OK.
|
|
@@ -46,7 +46,7 @@ import { editRepairTail, abbrev } from "./repair-contract.mjs";
|
|
|
46
46
|
// `connotation-remedy` quotes the refusal token and turns it into a fix instruction. Both helpers
|
|
47
47
|
// are the gateway's, and calling them here rather than re-deriving the text is the point: one
|
|
48
48
|
// derivation, and a composer that drifts from the hint the gateway gives is impossible by construction.
|
|
49
|
-
import { correctionHint, gridLedgerNameFor } from "./gateway.mjs";
|
|
49
|
+
import { correctionHint, gridLedgerNameFor, patchRows } from "./gateway.mjs";
|
|
50
50
|
import { basename } from "node:path";
|
|
51
51
|
// ── REGISTERED IN PLACE ─────────────────────────────────────────────────────────────────────────────
|
|
52
52
|
// These six are already named, exported, and living beside the subject they repair. Moving them into
|
|
@@ -131,7 +131,9 @@ const restingLine = (r) => {
|
|
|
131
131
|
return `- ${r.label}, which names finding ${(r.ordinals ?? []).join(", ")}: ${r.text}`;
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
// `adds`: the correction answering a review's flags, whose save may add the finding for an excluded position they name;
|
|
135
|
+
// the correction after the review of a repair is handed no positions and keeps the words for a replacement.
|
|
136
|
+
const correctiveRules = ({ narrative, findings, placement, rulingsTail, adds = false }) => [
|
|
135
137
|
// ── — THE PASS THAT WRITES THE DEFECT ──────────────────────────────────
|
|
136
138
|
//
|
|
137
139
|
// Five verdict refusals in seven days, all one shape: a coverage or search-completion claim
|
|
@@ -184,7 +186,7 @@ const correctiveRules = ({ narrative, findings, placement, rulingsTail }) => [
|
|
|
184
186
|
// on the serial critical path, and a conversion that answered it with "re-send everything
|
|
185
187
|
// through a tool" would have paid that cost back in a different currency. The driver holds the
|
|
186
188
|
// accepted values; the seat sends what changed.
|
|
187
|
-
`Send it all in ONE \`record_synthesis\` PATCH call, sending only the change: \`narrative\` carrying only the sections you corrected; \`findings_patch\` carrying
|
|
189
|
+
`Send it all in ONE \`record_synthesis\` PATCH call, sending only the change: \`narrative\` carrying only the sections you corrected; \`findings_patch\` carrying ${patchRows(adds)}; and \`findings\` carrying the "corrections" marker and any register from step 3, complete, and never a \`findings[]\` list. The driver merges this patch into the last accepted record, keeps the values the patch does not replace, and renders both files. There is no file to write or edit and nothing you write by hand is read.`,
|
|
188
190
|
// 2026-07-04 (the VENZY corrective thrash): three attempts died inventing three different keys
|
|
189
191
|
// while trying to EXPRESS a hold. The contract is closed and every correction is expressible
|
|
190
192
|
// inside it — say so.
|
|
@@ -206,13 +208,17 @@ export const REPAIR_COMPOSERS = [
|
|
|
206
208
|
// nothing else of the review, so a session that starts with nothing would have no flag to apply; the
|
|
207
209
|
// review's own file is named for it to open. `seniorEyeReview` is that file: the run's review on the first
|
|
208
210
|
// cycle, and the review after the delivery-check repair on the pass that applies it.
|
|
209
|
-
|
|
211
|
+
// `adds` on the first correction's own follow-up, whose save may add the finding for an excluded position its flags
|
|
212
|
+
// name; the correction after the review of a repair is handed none, and its follow-up keeps the words for a replacement.
|
|
213
|
+
compose: ({ findings, named, seniorEyeReview, adds = false }) => lines(
|
|
210
214
|
`This is a fresh session: your earlier synthesis is not in your context, and the driver holds the record it last accepted from you. Your corrective pass updated the narrative but did NOT re-emit ${findings} — the structured findings the client report renders from. The review named: ${named.join(", ")}. Its flags are in ${seniorEyeReview}; open it and ${findings} for the findings it names.`,
|
|
211
215
|
`Apply each flag to the finding objects it names: correct the fields, or set "disposition": "withdrawn" + "withdrawn_reason" for a killed finding, and add the "corrections": {"applied": true, "note": "…"} marker inside the call's \`findings\` object. Change nothing else.`,
|
|
212
|
-
`Send the correction with \`record_synthesis\`, sending only the change: a PATCH call carrying \`findings_patch\` —
|
|
216
|
+
`Send the correction with \`record_synthesis\`, sending only the change: a PATCH call carrying \`findings_patch\` — ${patchRows(adds)} — and \`findings\` carrying only the "corrections" marker, never a \`findings[]\` list; nothing else. The driver merges this patch into the last accepted record, keeps the values the patch does not replace, and renders both files. There is no file for you to write or edit and nothing you write by hand is read.`,
|
|
213
217
|
),
|
|
214
218
|
samples: [{ name: "the standard re-emit demand", tail: "tool",
|
|
215
|
-
args: { findings: "findings.json", named: ["#1", "#4"], seniorEyeReview: "senior-eye-review.md" } }
|
|
219
|
+
args: { findings: "findings.json", named: ["#1", "#4"], seniorEyeReview: "senior-eye-review.md" } },
|
|
220
|
+
{ name: "the first correction's re-emit demand, which may add a finding", tail: "tool",
|
|
221
|
+
args: { findings: "findings.json", named: ["#1", "#4"], seniorEyeReview: "senior-eye-review.md", adds: true } }],
|
|
216
222
|
},
|
|
217
223
|
{
|
|
218
224
|
trigger: "intake-asks-followup",
|
|
@@ -293,7 +299,7 @@ export const REPAIR_COMPOSERS = [
|
|
|
293
299
|
// exactly as it governs a first draft, and this instruction was the one place the engine invited
|
|
294
300
|
// a hedge into a deliverable. It fired on 4 of 4 delivered clearances in the 2026-08-09 round.
|
|
295
301
|
`This is a fresh session: your earlier synthesis is not in your context, and you do NOT redo it from scratch. The driver holds the record it last accepted from you; your earlier work is in ${narrative} and ${findings} — open them for the parts each flag names — and your inputs are listed below. The independent refutation flagged the corrections below. Apply them (minimum-change per flag — correct the statement to what the evidence supports, demote the tier, remove the sentence, or verify-flag for re-check) to BOTH deliverables. A caveat, hedge, qualifier or disclaimer is NEVER a repair: an unsupported statement is corrected or it is removed, never softened.`,
|
|
296
|
-
...correctiveRules({ narrative, findings, placement, rulingsTail }),
|
|
302
|
+
...correctiveRules({ narrative, findings, placement, rulingsTail, adds: true }),
|
|
297
303
|
scopeBlock ? lines(scopeBlock, ``) : "",
|
|
298
304
|
positionsLine ? lines(positionsLine, ``) : "",
|
|
299
305
|
worklist ? lines(worklist, ``) : "",
|