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
|
@@ -99,7 +99,7 @@ Signa's nested record; the full upstream record is under `_raw`):
|
|
|
99
99
|
`filingRoute` is what lets a finding say which register a right sits on. Use it rather than inferring the
|
|
100
100
|
route from the office code.
|
|
101
101
|
|
|
102
|
-
## Coverage — Signa's live office set (
|
|
102
|
+
## Coverage — Signa's live office set (13) + the disclosure rule
|
|
103
103
|
|
|
104
104
|
Derived from `GET /v1/offices` and committed as a snapshot (`providers/signa/src/offices.generated.js`), so
|
|
105
105
|
a change in what we claim to search arrives as a reviewable diff:
|
|
@@ -117,8 +117,10 @@ a change in what we claim to search arrives as a reviewable diff:
|
|
|
117
117
|
| Singapore | `ipos` | SG |
|
|
118
118
|
| Norway | `nipo` | NO |
|
|
119
119
|
| Sweden | `prv` | SE |
|
|
120
|
+
| Spain OEPM | `es` | ES |
|
|
121
|
+
| Mexico IMPI | `mx` | MX |
|
|
120
122
|
|
|
121
|
-
**Each of the
|
|
123
|
+
**Each of the thirteen is searched as a TERRITORY, not as one register.** The adapter sends
|
|
122
124
|
`filters.jurisdictions` + `territory_match: "protection"` — every right with effect there, whatever
|
|
123
125
|
register it sits on — rather than `filters.offices`, which searches the national register alone. The
|
|
124
126
|
difference is not a margin. On the same term:
|
|
@@ -138,7 +140,7 @@ force there, and a finding may sit on any layer of it.
|
|
|
138
140
|
|
|
139
141
|
**NOT covered: China (CNIPA), Germany, Japan, Korea, Benelux, and other nationals.** The territory
|
|
140
142
|
expansion above does not change this and must not be read as widening it: `SIGNA_OFFICE_KEYS` maps only
|
|
141
|
-
these
|
|
143
|
+
these thirteen, an unmapped region abandons the translation, and a territory the vendor does not index is
|
|
142
144
|
not reachable by asking the question a different way. A Madrid designation of Germany is found only when
|
|
143
145
|
Germany is the territory searched, and it cannot be. For any matter jurisdiction outside this set, give
|
|
144
146
|
that slice a `deferred` coverage-form row (the register sweep **cannot reach** it on Signa) — disclose
|
|
@@ -163,7 +165,7 @@ rows.
|
|
|
163
165
|
**So do not disclose an office-scoped shortfall here; there is not one.** This paragraph described the
|
|
164
166
|
earlier behaviour and outlived it: the executor changed and the doctrine did not, which is the same skew
|
|
165
167
|
that left the grant at two tools while the server served four. The residual gap is the office set above —
|
|
166
|
-
a territory OUTSIDE the
|
|
168
|
+
a territory OUTSIDE the thirteen, which gets the `deferred` row the previous paragraph specifies.
|
|
167
169
|
|
|
168
170
|
## Record base host
|
|
169
171
|
|
package/driver/stage-context.mjs
CHANGED
|
@@ -217,6 +217,9 @@ const correctiveStateReads = (P) => [
|
|
|
217
217
|
{ path: driverDir(P.runDir, "refutation-calls", "call-001.json"), kind: "driver-side", why: "readAcceptedFlags: the review's typed flags, the corrective worklist's source" },
|
|
218
218
|
{ path: driverDir(P.runDir, "declinations.json"), kind: "driver-side", why: "the writer's declinations the corrective pass starts from" },
|
|
219
219
|
{ path: driverDir(P.runDir, REVIEW_EXCLUSIONS_FILE), kind: "driver-side", why: "correctionsExtra names each excluded position a flag is about, with its mark, owner and row, from the exclusions the review was shown" },
|
|
220
|
+
// The writer's own record while a fold is in force, which the correction is handed in place of the folded one.
|
|
221
|
+
{ path: driverDir(P.runDir, "fold.json"), kind: "driver-side", why: "modelRecordPath: whether findings.json is the folded record, which decides the record correctionsExtra names" },
|
|
222
|
+
{ path: driverDir(P.runDir, "findings-unfolded.json"), kind: "conditional", why: "named in the correction's message only while a fold is in force: the writer's own record, which its patch updates" },
|
|
220
223
|
];
|
|
221
224
|
|
|
222
225
|
const UNDECLARED = {
|
package/driver/suite-census.json
CHANGED
|
@@ -339,6 +339,24 @@
|
|
|
339
339
|
"skips": 1,
|
|
340
340
|
"todos": 0
|
|
341
341
|
},
|
|
342
|
+
"a-correction-adds-the-finding-its-flags-name.test.mjs": {
|
|
343
|
+
"tests": 12,
|
|
344
|
+
"asserts": 36,
|
|
345
|
+
"skips": 0,
|
|
346
|
+
"todos": 0
|
|
347
|
+
},
|
|
348
|
+
"a-correction-after-the-fold-is-handed-the-record-its-patch-updates.test.mjs": {
|
|
349
|
+
"tests": 8,
|
|
350
|
+
"asserts": 59,
|
|
351
|
+
"skips": 0,
|
|
352
|
+
"todos": 0
|
|
353
|
+
},
|
|
354
|
+
"a-correction-hands-its-positions-to-the-save.test.mjs": {
|
|
355
|
+
"tests": 6,
|
|
356
|
+
"asserts": 23,
|
|
357
|
+
"skips": 0,
|
|
358
|
+
"todos": 0
|
|
359
|
+
},
|
|
342
360
|
"a-correction-is-checked-against-the-delivered-record.test.mjs": {
|
|
343
361
|
"tests": 9,
|
|
344
362
|
"asserts": 33,
|
|
@@ -346,14 +364,14 @@
|
|
|
346
364
|
"todos": 0
|
|
347
365
|
},
|
|
348
366
|
"a-correction-patches-what-it-carries.test.mjs": {
|
|
349
|
-
"tests":
|
|
367
|
+
"tests": 49,
|
|
350
368
|
"asserts": 88,
|
|
351
369
|
"skips": 0,
|
|
352
370
|
"todos": 0
|
|
353
371
|
},
|
|
354
372
|
"a-correction-session-is-told-it-is-fresh-and-sends-only-the-change.test.mjs": {
|
|
355
|
-
"tests":
|
|
356
|
-
"asserts":
|
|
373
|
+
"tests": 12,
|
|
374
|
+
"asserts": 50,
|
|
357
375
|
"skips": 0,
|
|
358
376
|
"todos": 0
|
|
359
377
|
},
|
|
@@ -5440,8 +5458,8 @@
|
|
|
5440
5458
|
"todos": 0
|
|
5441
5459
|
},
|
|
5442
5460
|
"register-findings-link-to-the-office-record.test.mjs": {
|
|
5443
|
-
"tests":
|
|
5444
|
-
"asserts":
|
|
5461
|
+
"tests": 23,
|
|
5462
|
+
"asserts": 71,
|
|
5445
5463
|
"skips": 0,
|
|
5446
5464
|
"todos": 0
|
|
5447
5465
|
},
|
|
@@ -7313,7 +7331,7 @@
|
|
|
7313
7331
|
},
|
|
7314
7332
|
"the-review-after-a-repair-is-told-what-changed-and-what-rests-on-it.test.mjs": {
|
|
7315
7333
|
"tests": 7,
|
|
7316
|
-
"asserts":
|
|
7334
|
+
"asserts": 34,
|
|
7317
7335
|
"skips": 0,
|
|
7318
7336
|
"todos": 0
|
|
7319
7337
|
},
|
|
@@ -46,14 +46,14 @@ import { writeFileSync, appendFileSync, mkdirSync, readFileSync, existsSync, ren
|
|
|
46
46
|
import { captureCall, stampVerdict } from "./call-capture.mjs";
|
|
47
47
|
import { join, dirname } from "node:path";
|
|
48
48
|
import { driverDir } from "../shared/driver-dir.mjs";
|
|
49
|
-
import { parseFindingsJson, COVERAGE_AREA_STATES, topKeysForVersion, validateFindingForSave, isUseCheckNoResult } from "./findings-model.mjs";
|
|
49
|
+
import { parseFindingsJson, COVERAGE_AREA_STATES, topKeysForVersion, validateFindingForSave, isUseCheckNoResult, findingOrdinalInvalid } from "./findings-model.mjs";
|
|
50
50
|
import { heldResearchAnswers, isResearchAnswer, questionKey, NO_SEARCH_RESULT } from "./research-answers.mjs"; // a "no result" names a question that completed
|
|
51
51
|
import { writeResearchChecks } from "./research-checks.mjs"; // the research behind the use checks, written for the review
|
|
52
52
|
import { normalizeRecordUri } from "./registry-fidelity.mjs"; // the duty's own reading of a record uri
|
|
53
53
|
import { readFrozenMethod, FROZEN_METHOD_FILE } from "./framework-method.mjs";
|
|
54
54
|
import { findCoverageRecommendations } from "./verify.mjs";
|
|
55
55
|
import { declinationCallPaths, readDeclinations } from "./declination-tool.mjs"; // — the seat's own declines, read by the driver never asserted by the seat
|
|
56
|
-
import { reconcileDeclinationDuty, declinationDutyRefusal } from "./declination-duty.mjs";
|
|
56
|
+
import { reconcileDeclinationDuty, declinationDutyRefusal, positionRecords } from "./declination-duty.mjs";
|
|
57
57
|
import { findingUris } from "./record-carry.mjs"; // one derivation of "which records did the findings name", called not copied
|
|
58
58
|
import { foldAfterSave } from "./record-fold.mjs"; // once the delivery seam is passed, the saved record is folded again
|
|
59
59
|
import { SAVED_FINDINGS_FILE } from "./saved-findings-block.mjs"; // the file a later attempt is handed the saved findings in
|
|
@@ -601,8 +601,9 @@ export function rebaseSynthesis(runDir, edit, opts = {}) {
|
|
|
601
601
|
// carries beside its narrative and that object is one too, its envelope is absent or equal to the stored one wherever
|
|
602
602
|
// it is sent, a corrections marker sent inside it or beside it is one the decode reads, a register sent inside it and
|
|
603
603
|
// again beside it carries the same value in both places, the call's own rows each name a finding the stored record
|
|
604
|
-
// holds
|
|
605
|
-
//
|
|
604
|
+
// holds or add one for a position the correction's flags name, and no ordinal carries two different rows, among the
|
|
605
|
+
// call's own rows or its nested ones. A call that fails only on its own rows is refused for the row (`rejectedRow`).
|
|
606
|
+
// Any other shape is read exactly as it always was, so the model meets the refusal it always met, byte for byte.
|
|
606
607
|
|
|
607
608
|
const isPlainObject = (v) => v != null && typeof v === "object" && !Array.isArray(v);
|
|
608
609
|
// Key-sorted JSON: "the same content" must not turn on the order the model wrote its keys in.
|
|
@@ -665,8 +666,9 @@ function liftNestedRows(top, nested) {
|
|
|
665
666
|
*
|
|
666
667
|
* Returns `{registers, rows, lifted}`, or null when the call does not read that way (see above), and null leaves
|
|
667
668
|
* the call to main's reading of it. `rows` are the call's own `findings_patch` with the nested rows after them.
|
|
669
|
+
* `positions` are those a correction may add a finding for (`correctionPositions`).
|
|
668
670
|
*/
|
|
669
|
-
export function registerPatchOf(stored, call) {
|
|
671
|
+
export function registerPatchOf(stored, call, { positions = null } = {}) {
|
|
670
672
|
const doc = call?.findings;
|
|
671
673
|
if (!isPlainObject(stored?.findings) || !isPlainObject(doc) || Object.hasOwn(doc, "findings")) return null;
|
|
672
674
|
// A narrative sent beside it is an object of sections. Text, a list or null is no section patch: merged, its
|
|
@@ -692,27 +694,132 @@ export function registerPatchOf(stored, call) {
|
|
|
692
694
|
// part of its correction was ignored; read as main reads the call, it meets main's refusal. Compared as read, so the
|
|
693
695
|
// answer is the same on the call as it arrives and on the call once its markers are decoded.
|
|
694
696
|
if (Object.keys(doc).some((k) => k !== "findings_patch" && Object.hasOwn(call, k) && !sameValue(asRead(k, doc[k]), asRead(k, call[k])))) return null;
|
|
695
|
-
// The call's own rows each
|
|
696
|
-
//
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
if (call.findings_patch !== undefined && twoRowsForOneOrdinal(call.findings_patch)) return null;
|
|
697
|
+
// The call's own rows are each a finding object named by a positive whole-number ordinal, and no ordinal carries two
|
|
698
|
+
// different rows among them. Read as registers, the last would be applied and the other dropped without a word, the
|
|
699
|
+
// choice turning on the order they were sent in; read as main reads the call, it meets main's refusal. A row sent
|
|
700
|
+
// again with the same content is one row.
|
|
701
|
+
const top = call.findings_patch;
|
|
702
|
+
if (top !== undefined && !(Array.isArray(top) && top.every(isRow))) return null;
|
|
703
|
+
if (top !== undefined && twoRowsForOneOrdinal(top)) return null;
|
|
703
704
|
const { findings_patch: nested, ...registers } = doc;
|
|
704
|
-
const lift = liftNestedRows(
|
|
705
|
-
|
|
705
|
+
const lift = liftNestedRows(top, nested);
|
|
706
|
+
if (!lift) return null;
|
|
707
|
+
// And each replaces a finding the stored record holds, or adds one for a position the correction's flags name
|
|
708
|
+
// (`additionsOf`). A row aimed elsewhere is read as main reads the call.
|
|
709
|
+
const list = Array.isArray(stored.findings.findings) ? stored.findings.findings : [];
|
|
710
|
+
const held = new Set(list.map((f) => f?.ordinal));
|
|
711
|
+
const adds = additionsOf(list, lift.rows, positions);
|
|
712
|
+
if ((top ?? []).some((r) => !held.has(r.ordinal) && !adds.has(r))) return null;
|
|
713
|
+
return { registers, rows: lift.rows, lifted: lift.lifted };
|
|
706
714
|
}
|
|
707
715
|
|
|
708
716
|
/** Would `call` read as a register patch on `stored` but for a corrections marker the decode cannot read? PURE. */
|
|
709
|
-
function markerAloneBlocks(stored, call) {
|
|
717
|
+
function markerAloneBlocks(stored, call, opts = {}) {
|
|
710
718
|
const doc = call?.findings;
|
|
711
719
|
if (!isPlainObject(doc) || Object.hasOwn(doc, "findings")) return false;
|
|
712
720
|
if ([doc, call].every((o) => isMarker(o.corrections))) return false;
|
|
713
721
|
const { corrections: _inner, ...docRest } = doc;
|
|
714
722
|
const { corrections: _outer, ...callRest } = call;
|
|
715
|
-
return registerPatchOf(stored, { ...callRest, findings: docRest }) != null;
|
|
723
|
+
return registerPatchOf(stored, { ...callRest, findings: docRest }, opts) != null;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
// ── A CORRECTION MAY ADD THE FINDING FOR AN EXCLUDED POSITION ITS FLAGS NAME ─────────────────────────
|
|
727
|
+
//
|
|
728
|
+
// A review may flag a position the writer excluded, and the correction answering it is told to record it as a finding
|
|
729
|
+
// or keep its exclusion, in one patch. A patch row replaced the finding its ordinal named, and a row on an ordinal the
|
|
730
|
+
// record did not hold was refused, so that correction could not record the finding: on a test run, 2026-10-31, the
|
|
731
|
+
// writer's four new findings for the flagged positions were refused on every route it tried, and the recheck flagged
|
|
732
|
+
// the same positions again. A row on an ordinal the record does not hold is now added where it is a finding, not
|
|
733
|
+
// withdrawn, naming a record of a position the correction's flags name, which the writer excluded and no current
|
|
734
|
+
// finding delivers (ruled 2026-11-02). The driver hands those positions to the tool's server with the correction's own
|
|
735
|
+
// dispatch, which its retries share; any other call adds nothing, the delivery check's repair among them, whatever
|
|
736
|
+
// flag is still on disk. One finding is added per position: another row for it, in the same call or a later one, is
|
|
737
|
+
// refused as any unknown ordinal is. The exclusion stays in the ledger as history, and the finding delivers the position.
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* The positions a correction may add a finding for, each as every record it holds: those of `named` (the positions
|
|
741
|
+
* its flags name, as the driver handed them to the dispatch) that the writer declined. A position is the declination
|
|
742
|
+
* spec's row, an entry's row standing for every record of the entry. Empty on any other call. PURE.
|
|
743
|
+
*/
|
|
744
|
+
export function correctionPositions(owed, declined, named) {
|
|
745
|
+
if (!Array.isArray(named) || !named.length || !Array.isArray(owed)) return [];
|
|
746
|
+
const ids = new Set(named.map((u) => normalizeRecordUri(u)).filter(Boolean));
|
|
747
|
+
const excluded = new Set((Array.isArray(declined) ? declined : []).map((u) => normalizeRecordUri(u)).filter(Boolean));
|
|
748
|
+
return owed.map(positionRecords).filter((m) => [...m].some((u) => ids.has(u)) && [...m].some((u) => excluded.has(u)));
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* The rows that add a finding: each on an ordinal `list` does not hold, not withdrawn, naming a record of one of
|
|
753
|
+
* `positions` that no current finding delivers, taken in the order sent. A current finding is one of `list`, as the
|
|
754
|
+
* call's own rows replace it, or a row added before it, and is not withdrawn. PURE.
|
|
755
|
+
*/
|
|
756
|
+
function additionsOf(list, rows, positions) {
|
|
757
|
+
const out = new Set();
|
|
758
|
+
if (!Array.isArray(positions) || !positions.length || !Array.isArray(rows)) return out;
|
|
759
|
+
const held = new Map((Array.isArray(list) ? list : []).map((f) => [f?.ordinal, f]));
|
|
760
|
+
const current = new Map(held);
|
|
761
|
+
for (const r of rows) if (isRow(r) && held.has(r.ordinal)) current.set(r.ordinal, r);
|
|
762
|
+
const live = (f) => f?.disposition !== "withdrawn";
|
|
763
|
+
const delivered = new Set(findingUris([...current.values()].filter(live)).keys());
|
|
764
|
+
for (const r of rows) {
|
|
765
|
+
if (!isRow(r) || held.has(r.ordinal) || !live(r)) continue;
|
|
766
|
+
const named = findingUris([r]);
|
|
767
|
+
const position = positions.find((m) => [...m].some((u) => named.has(u)));
|
|
768
|
+
if (!position || [...position].some((u) => delivered.has(u))) continue;
|
|
769
|
+
out.add(r);
|
|
770
|
+
for (const u of position) delivered.add(u);
|
|
771
|
+
}
|
|
772
|
+
return out;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
// ── A PATCH REFUSED FOR ITS ROWS NAMES THE ROW ──────────────────────────────────────────────────────
|
|
776
|
+
//
|
|
777
|
+
// A call carrying rows with a findings object that has no list, beside the object or inside it, is a patch. Where its
|
|
778
|
+
// rows were all that kept it from reading as one, main read it as a whole call, or as a record the object replaced, and
|
|
779
|
+
// refused it for what such a record lacks: the narrative's spine, a key the record does not have, a row the replaced
|
|
780
|
+
// record did not hold, or the run's owed records, named as unaccounted though the stored record held them. On the test
|
|
781
|
+
// run above, the correction was refused as leaving 37 of the run's records unaccounted for, every one of them delivered
|
|
782
|
+
// by the record it was correcting. Such a call is now refused for its first row, in the order sent, that the record
|
|
783
|
+
// cannot take, and the accepted record stands (ruled 2026-11-02).
|
|
784
|
+
//
|
|
785
|
+
// THE WORDS FOR A ROW THE RECORD CANNOT TAKE, approved 2026-11-03, for the plain patch and the nested one alike. The
|
|
786
|
+
// words a row met before said a patch only replaces, and a correction may now add. A value that is not a finding
|
|
787
|
+
// object meets the shape refusal; a row whose ordinal is missing, not a whole number, or below 1 meets the parser's
|
|
788
|
+
// own words for that ordinal; and a row on an ordinal that neither names a finding the record holds nor adds one this
|
|
789
|
+
// correction allows is told both ways a row is taken. Two different rows under one ordinal meet the parser's words for
|
|
790
|
+
// a list carrying them.
|
|
791
|
+
const unknownOrdinal = (o) => `synthesis_patch_ordinal_unknown:${String(o)} — this row neither updates an existing finding nor adds a finding allowed by this correction. Use the existing finding's ordinal for an update. Add a new finding only for an excluded position named in this correction's flags that no current finding delivers. The added finding must not be withdrawn and must cite a record from that position.`;
|
|
792
|
+
const PATCH_SHAPE = "synthesis_patch_shape: `findings_patch` must be an array of complete finding objects. Each row needs a positive whole-number `ordinal`: an existing finding's ordinal for an update, or a new ordinal for an addition allowed by this correction.";
|
|
793
|
+
// findings-model.mjs, `validateFinding`: an ordinal that is missing, not a whole number, or below 1.
|
|
794
|
+
const ordinalInvalid = (o) => `synthesis_findings_invalid: ${findingOrdinalInvalid(o)}`;
|
|
795
|
+
// findings-model.mjs, `validateFinding`: a list carrying two findings under one ordinal.
|
|
796
|
+
const twoRowsFor = (o) => `synthesis_findings_invalid: finding_ordinal_duplicate:${o} (each finding's ordinal must be unique)`;
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* Why the record cannot take `call`'s rows, its own or those inside its findings object, where they are all that keep
|
|
800
|
+
* it from reading as a patch on `stored` (see above); null for any other call. PURE.
|
|
801
|
+
*/
|
|
802
|
+
export function rejectedRow(stored, call, opts = {}) {
|
|
803
|
+
const doc = call?.findings;
|
|
804
|
+
if (!isPlainObject(call) || !isPlainObject(doc) || Object.hasOwn(doc, "findings")) return null;
|
|
805
|
+
const { findings_patch: top, ...rest } = call;
|
|
806
|
+
const { findings_patch: nested, ...registers } = doc;
|
|
807
|
+
if (top === undefined && nested === undefined) return null;
|
|
808
|
+
if (registerPatchOf(stored, call, opts) !== null || registerPatchOf(stored, { ...rest, findings: registers }, opts) === null) return null;
|
|
809
|
+
if ([top, nested].some((x) => x !== undefined && !Array.isArray(x))) return PATCH_SHAPE;
|
|
810
|
+
const rows = [...(top ?? []), ...(nested ?? [])];
|
|
811
|
+
const list = Array.isArray(stored.findings.findings) ? stored.findings.findings : [];
|
|
812
|
+
const held = new Set(list.map((f) => f?.ordinal));
|
|
813
|
+
const adds = additionsOf(list, rows, opts.positions);
|
|
814
|
+
const sent = new Map();
|
|
815
|
+
for (const r of rows) {
|
|
816
|
+
if (!isPlainObject(r)) return PATCH_SHAPE;
|
|
817
|
+
if (!isRow(r)) return ordinalInvalid(r.ordinal);
|
|
818
|
+
if (sent.has(r.ordinal)) { if (!sameValue(sent.get(r.ordinal), r)) return twoRowsFor(r.ordinal); continue; }
|
|
819
|
+
sent.set(r.ordinal, r);
|
|
820
|
+
if (!held.has(r.ordinal) && !adds.has(r)) return unknownOrdinal(r.ordinal);
|
|
821
|
+
}
|
|
822
|
+
return null;
|
|
716
823
|
}
|
|
717
824
|
|
|
718
825
|
/**
|
|
@@ -730,13 +837,14 @@ function markerAloneBlocks(stored, call) {
|
|
|
730
837
|
* record's ladder is the model's own word; `rowsIgnored` for a top-level `findings_patch`, and `rowsDiffering` for
|
|
731
838
|
* those of its rows the record's own list does not hold as sent. Nothing a register patch carries is dropped: a
|
|
732
839
|
* register sent in both places with two values makes the call one main reads as it always did (`registerPatchOf`).
|
|
840
|
+
* A patch refused for its rows (`rejectedRow`) is no whole call, and nothing on it is counted.
|
|
733
841
|
*/
|
|
734
|
-
export function readSynthesisCall(received, stored) {
|
|
842
|
+
export function readSynthesisCall(received, stored, opts = {}) {
|
|
735
843
|
const notes = { decoded: [], keysIgnored: 0, rowsIgnored: 0, rowsDiffering: 0 };
|
|
736
844
|
if (!isPlainObject(received)) return { call: received, notes };
|
|
737
|
-
const asRegisters = registerPatchOf(stored, received) !== null;
|
|
845
|
+
const asRegisters = registerPatchOf(stored, received, opts) !== null;
|
|
738
846
|
if (received.findings !== undefined && !asRegisters) {
|
|
739
|
-
if (received.narrative !== undefined) { // a whole call
|
|
847
|
+
if (received.narrative !== undefined && rejectedRow(stored, received, opts) === null) { // a whole call
|
|
740
848
|
const list = new Map((Array.isArray(received.findings?.findings) ? received.findings.findings : []).map((f) => [f?.ordinal, f]));
|
|
741
849
|
for (const [k, v] of Object.entries(received)) {
|
|
742
850
|
if (k === "narrative" || k === "findings") continue;
|
|
@@ -769,12 +877,13 @@ export function readSynthesisCall(received, stored) {
|
|
|
769
877
|
*
|
|
770
878
|
* A patch naming an ordinal the stored call does not hold is a DEFECT, not an insert: the repair
|
|
771
879
|
* ladder only ever patches findings the parse already quarantined, so an unknown ordinal means the seat
|
|
772
|
-
* is repairing something this run does not have.
|
|
880
|
+
* is repairing something this run does not have. The one exception is the finding a correction adds for a position
|
|
881
|
+
* its flags name (`positions`, see `additionsOf`), which joins the stored list in ordinal order.
|
|
773
882
|
*
|
|
774
883
|
* Returns `{ok: true, merged, lifted}`, where `lifted` counts the rows taken from inside a list-less
|
|
775
884
|
* `findings`, or `{ok: false, reason}`.
|
|
776
885
|
*/
|
|
777
|
-
export function mergeSynthesisPatch(stored, patch) {
|
|
886
|
+
export function mergeSynthesisPatch(stored, patch, { positions = null } = {}) {
|
|
778
887
|
if (!stored) return { ok: false, reason: "synthesis_patch_without_base: this run has no accepted synthesis call to patch — send the complete `narrative` and `findings` instead. A patch is a repair of values the driver is holding, and it is holding none" };
|
|
779
888
|
const out = { narrative: { ...stored.narrative }, findings: { ...stored.findings } };
|
|
780
889
|
// A WHOLE `findings` REPLACES the stored record. That is the schema-migration rung: the key set
|
|
@@ -788,24 +897,35 @@ export function mergeSynthesisPatch(stored, patch) {
|
|
|
788
897
|
// record, then those registers, then the call's top-level registers (copied last, below); a register sent in both
|
|
789
898
|
// places carries one value there, so the order chooses nothing. Rows replace whole findings by ordinal; narrative
|
|
790
899
|
// sections replace sections.
|
|
791
|
-
const asRegisters = registerPatchOf(stored, patch);
|
|
900
|
+
const asRegisters = registerPatchOf(stored, patch, { positions });
|
|
792
901
|
// A list-less `findings` object that reads as registers in every way but its corrections marker: the marker is what
|
|
793
902
|
// is wrong. Read as main reads the call it would replace the record, and it would then be refused for a defect it
|
|
794
903
|
// does not have (rows naming findings the run holds, or a record with no list); it gets the refusal the same marker
|
|
795
904
|
// meets at the top level instead.
|
|
796
|
-
if (!asRegisters && markerAloneBlocks(stored, patch)) return { ok: false, reason: "synthesis_findings_invalid: findings_corrections_invalid (corrections must be an object { applied, note })" };
|
|
905
|
+
if (!asRegisters && markerAloneBlocks(stored, patch, { positions })) return { ok: false, reason: "synthesis_findings_invalid: findings_corrections_invalid (corrections must be an object { applied, note })" };
|
|
797
906
|
if (asRegisters) Object.assign(out.findings, asRegisters.registers);
|
|
798
907
|
else if (patch?.findings !== undefined) out.findings = patch.findings;
|
|
799
908
|
for (const [k, v] of Object.entries(patch?.narrative ?? {})) out.narrative[k] = v;
|
|
800
909
|
const rows = asRegisters ? asRegisters.rows : patch?.findings_patch;
|
|
801
910
|
if (rows != null) {
|
|
802
|
-
if (!Array.isArray(rows)) return { ok: false, reason:
|
|
803
|
-
|
|
911
|
+
if (!Array.isArray(rows)) return { ok: false, reason: PATCH_SHAPE };
|
|
912
|
+
// A finding is added only to the stored list, never to a findings object the call sends in its place.
|
|
913
|
+
const adds = asRegisters || patch?.findings === undefined ? additionsOf(out.findings.findings, rows, positions) : new Set();
|
|
914
|
+
const indexed = (list) => new Map(list.map((f, i) => [f?.ordinal, i]));
|
|
915
|
+
let byOrdinal = indexed(out.findings.findings ?? []);
|
|
804
916
|
for (const r of rows) {
|
|
805
|
-
|
|
806
|
-
if (
|
|
807
|
-
|
|
917
|
+
if (!isPlainObject(r)) return { ok: false, reason: PATCH_SHAPE };
|
|
918
|
+
if (!isRow(r)) return { ok: false, reason: ordinalInvalid(r.ordinal) };
|
|
919
|
+
const at = byOrdinal.get(r.ordinal);
|
|
920
|
+
if (at === undefined && adds.has(r)) {
|
|
921
|
+
const list = [...(out.findings.findings ?? [])];
|
|
922
|
+
const before = list.findIndex((f) => Number.isInteger(f?.ordinal) && f.ordinal > r.ordinal);
|
|
923
|
+
list.splice(before < 0 ? list.length : before, 0, r);
|
|
924
|
+
out.findings.findings = list;
|
|
925
|
+
byOrdinal = indexed(list);
|
|
926
|
+
continue;
|
|
808
927
|
}
|
|
928
|
+
if (at === undefined) return { ok: false, reason: unknownOrdinal(r?.ordinal) };
|
|
809
929
|
out.findings.findings = [...(out.findings.findings ?? [])];
|
|
810
930
|
out.findings.findings[at] = r;
|
|
811
931
|
}
|
|
@@ -934,6 +1054,9 @@ export function synthesisDutyForRun(runDir) {
|
|
|
934
1054
|
* the second returns `write_failed` rather than a partial success — a run holding a findings record
|
|
935
1055
|
* with no narrative reads to every downstream existsSync as "synthesis done", and several of them
|
|
936
1056
|
* (`digestLocked`, the resume guards) key on `narrative.md` alone.
|
|
1057
|
+
*
|
|
1058
|
+
* `correction` is the positions a correction's flags name, as the driver handed them to the tool's server for that
|
|
1059
|
+
* correction's dispatch; absent on every other call, which adds no finding (`correctionPositions`).
|
|
937
1060
|
*/
|
|
938
1061
|
export function recordSynthesis(runDir, received, opts = {}) {
|
|
939
1062
|
const dir0 = String(runDir ?? "");
|
|
@@ -943,7 +1066,7 @@ export function recordSynthesis(runDir, received, opts = {}) {
|
|
|
943
1066
|
const auto = driverReadsFor(dir0);
|
|
944
1067
|
const { asks = auto.asks, ledger = auto.ledger, manifest = auto.manifest,
|
|
945
1068
|
method = auto.method, methodInvalid = auto.methodInvalid ?? null,
|
|
946
|
-
owed = auto.owed, declined = auto.declined, recordOrigins = undefined,
|
|
1069
|
+
owed = auto.owed, declined = auto.declined, recordOrigins = undefined, correction = null,
|
|
947
1070
|
sessionKey = process.env.CLEAROTRON_GATHER_SESSION_KEY || null,
|
|
948
1071
|
heldAnswers = heldResearchAnswers(dir0, sessionKey),
|
|
949
1072
|
now = () => new Date().toISOString() } = opts;
|
|
@@ -981,9 +1104,10 @@ export function recordSynthesis(runDir, received, opts = {}) {
|
|
|
981
1104
|
return { written: null, refused: null, saved: r.saved, save_refused: r.refused, held: r.held, ...(r.write_failed ? { write_failed: r.write_failed } : {}), capture_failed: captureFailed };
|
|
982
1105
|
}
|
|
983
1106
|
const stored = lastAcceptedCall(dir0);
|
|
984
|
-
const
|
|
1107
|
+
const positions = correctionPositions(owed, declined, correction);
|
|
1108
|
+
const read = readSynthesisCall(received, stored, { positions });
|
|
985
1109
|
let call = read.call;
|
|
986
|
-
const asRegisters = registerPatchOf(stored, call);
|
|
1110
|
+
const asRegisters = registerPatchOf(stored, call, { positions });
|
|
987
1111
|
const isPatch = Boolean(call) && (call.findings === undefined || call.narrative === undefined || asRegisters !== null);
|
|
988
1112
|
// WHAT THE TRANSPORT READ THE CALL AS: one run-log row at whichever exit the call takes, beside the decision,
|
|
989
1113
|
// when the reading decoded, lifted or ignored anything. Never in the answer below, which the tool
|
|
@@ -1004,8 +1128,16 @@ export function recordSynthesis(runDir, received, opts = {}) {
|
|
|
1004
1128
|
try { appendFileSync(refusals, JSON.stringify({ at: now(), reason }) + "\n"); } catch { /* best-effort */ }
|
|
1005
1129
|
};
|
|
1006
1130
|
|
|
1131
|
+
// A PATCH THE RECORD CANNOT TAKE FOR ITS ROWS is refused for the row, and the accepted record stands (`rejectedRow`).
|
|
1132
|
+
const rejected = asRegisters === null ? rejectedRow(stored, call, { positions }) : null;
|
|
1133
|
+
if (rejected) {
|
|
1134
|
+
noteRefusal(rejected);
|
|
1135
|
+
recordReading(false);
|
|
1136
|
+
return { written: null, refused: rejected, captured: closeCapture({ ok: false, refused: rejected }), capture_failed: captureFailed };
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1007
1139
|
if (isPatch) {
|
|
1008
|
-
const merged = mergeSynthesisPatch(stored, call); // the call as READ: a decoded marker merges as an object
|
|
1140
|
+
const merged = mergeSynthesisPatch(stored, call, { positions }); // the call as READ: a decoded marker merges as an object
|
|
1009
1141
|
if (!merged.ok) {
|
|
1010
1142
|
noteRefusal(merged.reason);
|
|
1011
1143
|
recordReading(false);
|
package/mcp-server/CHANGELOG.md
CHANGED
package/mcp-server/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trademark-artifacts-mcp",
|
|
3
|
-
"version": "0.5.0-beta.
|
|
3
|
+
"version": "0.5.0-beta.8",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"private": true,
|
|
6
6
|
"description": "MCP server to interrogate clearotron trademark-clearance runs — list/read artifacts, trace the full decision flow, telemetry/cost, coverage, single-run search, and a gated single-step what-if. Imports the clearotron-driver read-only; touches no driver/template/deploy files.",
|
package/package.json
CHANGED
package/portal-ui/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "portal-ui",
|
|
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": "The unified trademark portal UI. One address, one login: who you are decides what you see. Built as a static bundle, served by driver/portal-service.mjs — the browser never reaches profile-service or recipe-service.",
|
|
8
8
|
"engines": {
|
package/providers/README.md
CHANGED
|
@@ -44,7 +44,7 @@ the vendor's own site, over either adapter that needs a sales agreement.
|
|
|
44
44
|
|
|
45
45
|
One API key, issued self-serve from the vendor's own site: no sales call, no contract, no waiting. It
|
|
46
46
|
covers the **US and EU registers together**, plus WIPO/Madrid, the UK, Switzerland, Canada, Australia,
|
|
47
|
-
France, Singapore, Norway and Sweden — **
|
|
47
|
+
France, Spain, Mexico, Singapore, Norway and Sweden — **thirteen offices**. Native sound-alike search, exact result counts,
|
|
48
48
|
opposition state, and one call returns every layer of rights binding a territory, so an EU trade mark that
|
|
49
49
|
blocks use in France is actually found rather than missed by a national-only search.
|
|
50
50
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trademark-oauth-mcp-bridge",
|
|
3
|
-
"version": "0.5.0-beta.
|
|
3
|
+
"version": "0.5.0-beta.8",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"private": true,
|
|
6
6
|
"description": "OAuth 2.1 MCP stdio bridge used by the engine's case-law gather stage (courtlistener / legaldatahunter).",
|
|
@@ -9,21 +9,23 @@
|
|
|
9
9
|
// `status` is load-bearing: providers/signa/src/capabilities.js covers only the `live` ones. An office
|
|
10
10
|
// that stops being live leaves the covered set on the next sync, and this diff is where that is seen.
|
|
11
11
|
//
|
|
12
|
-
// Fetched: 2026-
|
|
12
|
+
// Fetched: 2026-11-02T18:18:06Z
|
|
13
13
|
export const SIGNA_OFFICE_SNAPSHOT = Object.freeze({
|
|
14
|
-
fetched_at: "2026-
|
|
14
|
+
fetched_at: "2026-11-02T18:18:06Z",
|
|
15
15
|
source: "https://api.signa.so/v1/offices",
|
|
16
16
|
offices: Object.freeze([
|
|
17
|
-
Object.freeze({"key":"cipo","code":"CA","jurisdiction":"CA","name":"Canadian Intellectual Property Office","status":"live","update_cadence":"weekly","total_marks":
|
|
18
|
-
Object.freeze({"key":"
|
|
19
|
-
Object.freeze({"key":"
|
|
20
|
-
Object.freeze({"key":"
|
|
21
|
-
Object.freeze({"key":"
|
|
22
|
-
Object.freeze({"key":"
|
|
23
|
-
Object.freeze({"key":"
|
|
24
|
-
Object.freeze({"key":"
|
|
25
|
-
Object.freeze({"key":"
|
|
26
|
-
Object.freeze({"key":"
|
|
27
|
-
Object.freeze({"key":"
|
|
17
|
+
Object.freeze({"key":"cipo","code":"CA","jurisdiction":"CA","name":"Canadian Intellectual Property Office","status":"live","update_cadence":"weekly","total_marks":2191386,"last_synced_at":"2026-11-02T11:35:59.179Z","coverage":null}),
|
|
18
|
+
Object.freeze({"key":"es","code":"ES","jurisdiction":"ES","name":"Spanish Patent and Trademark Office","status":"live","update_cadence":"daily","total_marks":3804298,"last_synced_at":"2026-11-02T11:20:20.112Z","coverage":null}),
|
|
19
|
+
Object.freeze({"key":"euipo","code":"EM","jurisdiction":"EU","name":"European Union Intellectual Property Office","status":"live","update_cadence":"daily","total_marks":3264288,"last_synced_at":"2026-11-02T07:03:56.961Z","coverage":null}),
|
|
20
|
+
Object.freeze({"key":"inpi-fr","code":"FR","jurisdiction":"FR","name":"National Institute of Industrial Property (France)","status":"live","update_cadence":"weekly","total_marks":3537977,"last_synced_at":"2026-10-30T05:11:23.102Z","coverage":null}),
|
|
21
|
+
Object.freeze({"key":"ipau","code":"AU","jurisdiction":"AU","name":"IP Australia","status":"live","update_cadence":"daily","total_marks":2338559,"last_synced_at":"2026-11-01T21:14:20.272Z","coverage":null}),
|
|
22
|
+
Object.freeze({"key":"ipi","code":"CH","jurisdiction":"CH","name":"Swiss Federal Institute of Intellectual Property","status":"live","update_cadence":"daily","total_marks":1150611,"last_synced_at":"2026-11-02T15:01:33.190Z","coverage":null}),
|
|
23
|
+
Object.freeze({"key":"ipos","code":"SG","jurisdiction":"SG","name":"Intellectual Property Office of Singapore","status":"live","update_cadence":"daily","total_marks":882108,"last_synced_at":"2026-11-02T04:15:04.426Z","coverage":null}),
|
|
24
|
+
Object.freeze({"key":"mx","code":"MX","jurisdiction":"MX","name":"Mexican Institute of Industrial Property","status":"live","update_cadence":"daily","total_marks":3819551,"last_synced_at":"2026-11-01T20:25:40.757Z","coverage":null}),
|
|
25
|
+
Object.freeze({"key":"nipo","code":"NO","jurisdiction":"NO","name":"Norwegian Industrial Property Office","status":"live","update_cadence":"daily","total_marks":579877,"last_synced_at":"2026-11-02T04:16:36.648Z","coverage":null}),
|
|
26
|
+
Object.freeze({"key":"prv","code":"SE","jurisdiction":"SE","name":"Swedish Intellectual Property Office","status":"live","update_cadence":"daily","total_marks":612172,"last_synced_at":"2026-11-02T06:15:47.089Z","coverage":null}),
|
|
27
|
+
Object.freeze({"key":"ukipo","code":"GB","jurisdiction":"GB","name":"UK Intellectual Property Office","status":"live","update_cadence":"daily","total_marks":3686027,"last_synced_at":"2026-11-02T03:33:59.564Z","coverage":null}),
|
|
28
|
+
Object.freeze({"key":"uspto","code":"US","jurisdiction":"US","name":"United States Patent and Trademark Office","status":"live","update_cadence":"daily","total_marks":14403594,"last_synced_at":"2026-11-02T13:07:51.356Z","coverage":null}),
|
|
29
|
+
Object.freeze({"key":"wipo","code":"WO","jurisdiction":"WO","name":"World Intellectual Property Organization","status":"live","update_cadence":"weekly","total_marks":10474173,"last_synced_at":"2026-11-02T15:37:25.192Z","coverage":null}),
|
|
28
30
|
]),
|
|
29
31
|
});
|
|
@@ -40,6 +40,7 @@ export const NAMES_IN_FORCE = Object.freeze([
|
|
|
40
40
|
"CLEAROTRON_CODEX_PATH",
|
|
41
41
|
"CLEAROTRON_CODEX_SANDBOX_BYPASS",
|
|
42
42
|
"CLEAROTRON_COMMONLAW_SPLIT",
|
|
43
|
+
"CLEAROTRON_CORRECTION_POSITIONS",
|
|
43
44
|
"CLEAROTRON_COUNT_FIRST",
|
|
44
45
|
"CLEAROTRON_CUSTOMERS_DIR",
|
|
45
46
|
"CLEAROTRON_CUT_PR",
|
|
@@ -74,9 +74,9 @@ const USPTO_WARNINGS = [
|
|
|
74
74
|
|
|
75
75
|
export const PROVIDERS = [
|
|
76
76
|
{
|
|
77
|
-
id: "signa", label: "Signa — recommended: US + EU + WIPO and
|
|
77
|
+
id: "signa", label: "Signa — recommended: US + EU + WIPO and ten more offices", cost: "subscription",
|
|
78
78
|
covers: "the US and EU registers together, plus WIPO/Madrid, the UK, Switzerland, Canada, Australia, "
|
|
79
|
-
+ "France, Singapore, Norway and Sweden —
|
|
79
|
+
+ "France, Spain, Mexico, Singapore, Norway and Sweden — thirteen offices — with native sound-alike search, exact "
|
|
80
80
|
+ "result counts and opposition state. One self-serve key, no sales call.",
|
|
81
81
|
credentials: ["SIGNA_API_KEY"],
|
|
82
82
|
signup: SIGNA_SIGNUP,
|