@ceccec/millennium-solutions 9.7.6 → 9.8.3
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/README.md +299 -107
- package/dist/data/baked/answer_gate.json +1 -0
- package/dist/data/baked/answer_verify_arith.json +1 -0
- package/dist/data/baked/answer_verify_arxiv.json +1 -0
- package/dist/data/baked/anti_fake.json +1 -0
- package/dist/data/baked/api_gates.json +1 -0
- package/dist/data/baked/apis_guru_cross.json +1 -0
- package/dist/data/baked/apis_guru_gaps.json +1 -0
- package/dist/data/baked/apis_theorems.json +1 -0
- package/dist/data/baked/coils.json +1 -0
- package/dist/data/baked/constants_check.json +1 -0
- package/dist/data/baked/contradictions.json +1 -0
- package/dist/data/baked/discover.json +1 -0
- package/dist/data/baked/discoveries.json +1 -0
- package/dist/data/baked/entanglements.json +1 -0
- package/dist/data/baked/evidence.json +1 -0
- package/dist/data/baked/hexbit_route.json +1 -0
- package/dist/data/baked/index.json +41 -0
- package/dist/data/baked/leads.json +1 -0
- package/dist/data/baked/leaks.json +1 -0
- package/dist/data/baked/memory_check.json +1 -0
- package/dist/data/baked/memory_derive.json +1 -0
- package/dist/data/baked/metrics_face.json +1 -0
- package/dist/data/baked/package_gates.json +1 -0
- package/dist/data/baked/prefix_check.json +1 -0
- package/dist/data/baked/prose_check.json +1 -0
- package/dist/data/baked/qpu_court_local.json +1 -0
- package/dist/data/baked/qpu_families.json +1 -0
- package/dist/data/baked/recompute.json +1 -0
- package/dist/data/baked/session_report.json +1 -0
- package/dist/data/baked/theorem_only.json +1 -0
- package/dist/data/baked/trinity.json +1 -0
- package/dist/data/discovered.json +149408 -0
- package/dist/data/formulas.jsonld +470143 -0
- package/dist/mcp.bin.d.ts +2 -0
- package/dist/mcp.bin.js +80 -0
- package/dist/src/0/index.d.ts +1 -0
- package/dist/src/0/index.js +7 -8
- package/dist/src/face/index.d.ts +41 -0
- package/dist/src/face/index.js +32 -0
- package/dist/src/factor/index.d.ts +58 -0
- package/dist/src/factor/index.js +209 -0
- package/dist/src/factor/verify.d.ts +18 -0
- package/dist/src/factor/verify.js +28 -0
- package/dist/src/handle/index.d.ts +9 -0
- package/dist/src/handle/index.js +10 -0
- package/dist/src/mcp/index.d.ts +4199 -0
- package/dist/src/mcp/index.js +249 -0
- package/dist/src/mcp/serve.d.ts +100 -0
- package/dist/src/mcp/serve.js +282 -0
- package/dist/src/mcp/suites.d.ts +1 -0
- package/dist/src/mcp/suites.js +14 -0
- package/dist/src/mirror/index.d.ts +18 -0
- package/dist/src/mirror/index.js +37 -0
- package/dist/src/policy/index.d.ts +8 -0
- package/dist/src/policy/index.js +23 -0
- package/dist/src/the/rosetta/index.d.ts +3 -0
- package/dist/src/the/rosetta/index.js +25 -0
- package/package.json +55 -8
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { toUuid, merkleFold, merge } from '../0/index.js';
|
|
2
|
+
import { factorWitnessed } from '../factor/index.js';
|
|
3
|
+
import { verifyFactors } from '../factor/verify.js';
|
|
4
|
+
import { mirror as digitMirror } from '../mirror/index.js';
|
|
5
|
+
import { decide as policyDecide } from '../policy/index.js';
|
|
6
|
+
import { handle, resolve, HANDLE_HEX } from '../handle/index.js';
|
|
7
|
+
import { checkFace } from '../face/index.js';
|
|
8
|
+
import { CORE as ROSETTA_CORE, DOMAINS as ROSETTA_DOMAINS } from '../the/rosetta/index.js';
|
|
9
|
+
import { TOOLS, NEEDS, WRITES } from './index.js';
|
|
10
|
+
import { computes } from '@uuidna/uuidna';
|
|
11
|
+
export const ledgerStatus = (rows) => {
|
|
12
|
+
const live = rows.filter((r) => !r.revoked);
|
|
13
|
+
const carried = rows.filter((r) => r.revoked && r.supersededBy);
|
|
14
|
+
const keys = new Map(), receipts = new Map();
|
|
15
|
+
for (const r of rows) {
|
|
16
|
+
keys.set(r.key, (keys.get(r.key) ?? 0) + 1);
|
|
17
|
+
receipts.set(r.receipt, (receipts.get(r.receipt) ?? 0) + 1);
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
total: rows.length, live: live.length, revoked: rows.length - live.length, carried: carried.length,
|
|
21
|
+
duplicateKeys: [...keys].filter(([, n]) => n > 1).map(([k]) => k),
|
|
22
|
+
duplicateReceipts: [...receipts].filter(([, n]) => n > 1).map(([k]) => k),
|
|
23
|
+
octave: { size: rows.length, remainder: rows.length % 8, exact: rows.length % 8 === 0 },
|
|
24
|
+
note: 'Measurement of the ledger as given. It says nothing about whether any entry is TRUE — only what the record contains and whether its keys and receipts are unique.',
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export const forensicsOf = (rows, seed = 'axiom:TRINITY') => {
|
|
28
|
+
const breaks = [];
|
|
29
|
+
let prev = toUuid(seed);
|
|
30
|
+
rows.forEach((r, i) => {
|
|
31
|
+
const expected = toUuid(prev + '→' + r.key);
|
|
32
|
+
if (expected !== r.receipt)
|
|
33
|
+
breaks.push({ index: i, key: r.key, expected, found: r.receipt });
|
|
34
|
+
prev = r.receipt;
|
|
35
|
+
});
|
|
36
|
+
const genesis = breaks.filter((b) => b.index < 2);
|
|
37
|
+
return {
|
|
38
|
+
entries: rows.length, breaks: breaks.length, genesisDiscontinuities: genesis.length,
|
|
39
|
+
newBreaks: breaks.filter((b) => b.index >= 2).slice(0, 8),
|
|
40
|
+
intactFromIndex: breaks.length === genesis.length ? 2 : null,
|
|
41
|
+
seal: merkleFold(rows.map((r) => r.receipt)),
|
|
42
|
+
note: 'Chain-of-custody and tamper-evidence, not truth. Indices 0 and 1 are a documented baseline in this deposit; a break at index 2 or later is tampering.',
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export const verifyIn = (rows, uuid) => {
|
|
46
|
+
const at = rows.findIndex((r) => r.receipt === uuid.toLowerCase());
|
|
47
|
+
if (at < 0)
|
|
48
|
+
return { uuid, found: false,
|
|
49
|
+
note: 'Not a receipt in this ledger. That is not the same as opaque or invalid: this entry carries only the ledger it was handed, and the address may belong to the agent-statement receipts, which the full server reads.' };
|
|
50
|
+
const r = rows[at];
|
|
51
|
+
return { uuid, found: true, index: at, key: r.key, name: r.name ?? null, live: !r.revoked,
|
|
52
|
+
supersededBy: r.supersededBy ?? null, reason: r.reason ?? null,
|
|
53
|
+
chainIntactHere: at === 0 || toUuid(rows[at - 1].receipt + '→' + r.key) === r.receipt,
|
|
54
|
+
note: 'The address was found and its chain link recomputed. Integrity and position, never truth of the statement.' };
|
|
55
|
+
};
|
|
56
|
+
export const CANNOT_SHIP = {
|
|
57
|
+
secure_split: 'its shares are drawn from node:crypto randomBytes, and this entry opens no node module — clone the repository for it',
|
|
58
|
+
discover: 'its candidate set is scripts/discover.ts — repository logic, not a module',
|
|
59
|
+
recompute: 'it re-runs every candidate\'s formula, and the formulas are in scripts/discover.ts — the same repository logic. Reading the ledger is not enough: this tool recomputes what the ledger RECORDS, which needs the code that computed it',
|
|
60
|
+
};
|
|
61
|
+
const CORE_TOOLS = Object.entries(NEEDS)
|
|
62
|
+
.filter(([k, n]) => n.length === 1 && n[0] === 'core' && !CANNOT_SHIP[k])
|
|
63
|
+
.map(([k]) => k);
|
|
64
|
+
const LEDGER_TOOLS = Object.entries(NEEDS)
|
|
65
|
+
.filter(([k, n]) => n.length === 1 && n[0] === 'ledger' && !CANNOT_SHIP[k])
|
|
66
|
+
.map(([k]) => k);
|
|
67
|
+
const DATA_TOOLS = ['formulas'];
|
|
68
|
+
const OUTSIDE_ANY_PACKAGE = new Set(['lean', 'net', 'git', 'shared']);
|
|
69
|
+
export const BAKEABLE = TOOLS.map((t) => t.name).filter((n) => !CORE_TOOLS.includes(n) && !LEDGER_TOOLS.includes(n) && !DATA_TOOLS.includes(n)
|
|
70
|
+
&& (NEEDS[n] ?? ['tree']).every((x) => !OUTSIDE_ANY_PACKAGE.has(x))
|
|
71
|
+
&& !WRITES.has(n)
|
|
72
|
+
&& (TOOLS.find((t) => t.name === n)?.inputSchema?.required ?? []).length === 0).sort();
|
|
73
|
+
let BAKE = null;
|
|
74
|
+
export const withBake = (b) => { BAKE = b; };
|
|
75
|
+
export const hasBake = () => BAKE !== null;
|
|
76
|
+
const bakedNames = () => (BAKE ? Object.keys(BAKE.answers).filter((n) => BAKEABLE.includes(n)) : []);
|
|
77
|
+
export const FROM_BAKE = { family: 'qpu_families' };
|
|
78
|
+
const fromBakeNames = () => Object.entries(FROM_BAKE).filter(([, src]) => BAKE?.answers[src] !== undefined).map(([n]) => n);
|
|
79
|
+
export const whyNot = (name) => {
|
|
80
|
+
if (CANNOT_SHIP[name])
|
|
81
|
+
return CANNOT_SHIP[name];
|
|
82
|
+
if (BAKE?.notBaked[name])
|
|
83
|
+
return BAKE.notBaked[name];
|
|
84
|
+
if (WRITES.has(name))
|
|
85
|
+
return 'it writes to the tree, and a package has no tree to write to';
|
|
86
|
+
const req = TOOLS.find((t) => t.name === name)?.inputSchema?.required ?? [];
|
|
87
|
+
if (req.length && BAKEABLE.every((n) => n !== name) && (NEEDS[name] ?? []).every((x) => !OUTSIDE_ANY_PACKAGE.has(x)))
|
|
88
|
+
return `it takes \`${req.join(', ')}\`, and no bare answer stands in for an argument the caller chooses — clone the repository for it`;
|
|
89
|
+
return `it needs ${(NEEDS[name] ?? ['the repository']).join('+')}: clone the repository and run \`npm run mcp\``;
|
|
90
|
+
};
|
|
91
|
+
export const SERVED_CORE = [...CORE_TOOLS].sort();
|
|
92
|
+
export const SERVED_WITH_LEDGER = [...CORE_TOOLS, ...LEDGER_TOOLS, ...DATA_TOOLS].sort();
|
|
93
|
+
export const served = () => [
|
|
94
|
+
...SERVED_CORE,
|
|
95
|
+
...(hasLedger() ? LEDGER_TOOLS : []),
|
|
96
|
+
...(hasFormulas() ? DATA_TOOLS : []),
|
|
97
|
+
...bakedNames(),
|
|
98
|
+
...fromBakeNames(),
|
|
99
|
+
].sort();
|
|
100
|
+
export const formulasFrom = (rows, a = {}) => {
|
|
101
|
+
let out = rows;
|
|
102
|
+
const total = out.length;
|
|
103
|
+
if (a.wing)
|
|
104
|
+
out = out.filter((r) => r.wing === a.wing);
|
|
105
|
+
if (a.file)
|
|
106
|
+
out = out.filter((r) => r.source === a.file);
|
|
107
|
+
if (a.contains) {
|
|
108
|
+
const q = a.contains.toLowerCase();
|
|
109
|
+
out = out.filter((r) => (r.name + ' ' + r.statement).toLowerCase().includes(q));
|
|
110
|
+
}
|
|
111
|
+
const limit = Math.max(1, Math.min(Number(a.limit ?? 40), 500));
|
|
112
|
+
return {
|
|
113
|
+
total, matched: out.length, showing: Math.min(limit, out.length),
|
|
114
|
+
wings: [...new Set(rows.map((r) => r.wing))].sort(),
|
|
115
|
+
formulas: out.slice(0, limit),
|
|
116
|
+
note: 'The proposition the Lean kernel accepted, character for character, with the file and tactic that '
|
|
117
|
+
+ 'discharged it. Nothing here is summarised and nothing is authored. A formula being listed says the '
|
|
118
|
+
+ 'kernel accepted it, not that it is significant.',
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
let ROWS = null;
|
|
122
|
+
export const withLedger = (rows) => { ROWS = rows; };
|
|
123
|
+
export const hasLedger = () => ROWS !== null;
|
|
124
|
+
let FORMS = null;
|
|
125
|
+
export const withFormulas = (rows) => { FORMS = rows; };
|
|
126
|
+
export const hasFormulas = () => FORMS !== null;
|
|
127
|
+
const rowsOrRefuse = (tool) => {
|
|
128
|
+
if (!ROWS)
|
|
129
|
+
throw new Error(`${tool} measures the discovery ledger and no ledger was loaded. `
|
|
130
|
+
+ 'That is NOT a ledger of zero entries — it is an absent one. The published package carries the ledger at '
|
|
131
|
+
+ 'dist/data/discovered.json; if it is missing, pass one, or clone the repository for the full server.');
|
|
132
|
+
return ROWS;
|
|
133
|
+
};
|
|
134
|
+
const H = {
|
|
135
|
+
factor: (a) => JSON.stringify(factorWitnessed(String(a?.n ?? ''))),
|
|
136
|
+
factor_verify: (a) => JSON.stringify(verifyFactors(String(a?.n ?? ''), Array.isArray(a?.factors) ? a.factors.map(String) : [])),
|
|
137
|
+
digit_mirror: (a) => JSON.stringify(digitMirror(String(a?.n ?? ''))),
|
|
138
|
+
policy: (a) => JSON.stringify(policyDecide(String(a?.request ?? ''))),
|
|
139
|
+
api_lattice: () => {
|
|
140
|
+
const rows = TOOLS.filter((t) => (NEEDS[t.name] ?? []).includes('net')).map((t) => ({
|
|
141
|
+
handle: toUuid(t.name).replace(/-/g, '').slice(0, 8), tool: t.name, needs: NEEDS[t.name] ?? [],
|
|
142
|
+
})).sort((a, b) => a.handle.localeCompare(b.handle));
|
|
143
|
+
return JSON.stringify({ tools: rows.length, lattice: rows });
|
|
144
|
+
},
|
|
145
|
+
formulas: (a) => {
|
|
146
|
+
if (!FORMS)
|
|
147
|
+
throw new Error('formulas: the formula catalogue is not loaded. The published package carries it '
|
|
148
|
+
+ 'at dist/data/formulas.jsonld; if it is missing, pass rows, or clone the repository for the full server. '
|
|
149
|
+
+ 'An absent catalogue is NOT a catalogue of zero formulas.');
|
|
150
|
+
return JSON.stringify(formulasFrom(FORMS, a ?? {}));
|
|
151
|
+
},
|
|
152
|
+
ledger_status: () => JSON.stringify(ledgerStatus(rowsOrRefuse('ledger_status'))),
|
|
153
|
+
forensics: () => JSON.stringify(forensicsOf(rowsOrRefuse('forensics'))),
|
|
154
|
+
verify: (a) => {
|
|
155
|
+
const u = String(a?.uuid ?? '');
|
|
156
|
+
if (!u)
|
|
157
|
+
throw new Error('verify: uuid is required. This entry looks an address up in the ledger; for prose auditing, the honesty gate lives in the full server.');
|
|
158
|
+
return JSON.stringify(verifyIn(rowsOrRefuse('verify'), u));
|
|
159
|
+
},
|
|
160
|
+
content_address: (a) => {
|
|
161
|
+
const text = String(a?.text ?? '');
|
|
162
|
+
if (!text)
|
|
163
|
+
throw new Error('content_address: text is required');
|
|
164
|
+
return JSON.stringify({ uuid: toUuid(text), of: text.length + ' character(s)',
|
|
165
|
+
note: 'INTEGRITY and provenance, not encryption and not proof. The same text always gives this address; the address never gives the text back.' });
|
|
166
|
+
},
|
|
167
|
+
merkle_fold: (a) => {
|
|
168
|
+
const items = (a?.items ?? []);
|
|
169
|
+
if (!Array.isArray(items) || !items.length)
|
|
170
|
+
throw new Error('merkle_fold: items must be a non-empty array of strings');
|
|
171
|
+
const xs = items.map(String);
|
|
172
|
+
return JSON.stringify({ root: merkleFold(xs), count: xs.length, pairwise: xs.length > 1 ? merge(xs[0], xs[1]) : null,
|
|
173
|
+
note: 'Order-independent: the same set of items folds to the same root in any order. Leaves and nodes are domain-separated and length-prefixed, so no regrouping of the inputs produces this root.' });
|
|
174
|
+
},
|
|
175
|
+
handle: (a) => {
|
|
176
|
+
const text = String(a?.text ?? '');
|
|
177
|
+
if (!text)
|
|
178
|
+
throw new Error('handle: text is required');
|
|
179
|
+
const given = a?.handle ? String(a.handle) : null;
|
|
180
|
+
if (given) {
|
|
181
|
+
const r = resolve(given, text);
|
|
182
|
+
return JSON.stringify({ handle: given, address: r.uuid, carries: r.carries, hex: HANDLE_HEX,
|
|
183
|
+
note: 'A handle ROUTES and REJECTS; it never identifies. `carries` false is a definite no; `carries` true means NOT EXCLUDED — sixteen bits collide, so it is never "the same".' });
|
|
184
|
+
}
|
|
185
|
+
return JSON.stringify({ handle: handle(text), hex: HANDLE_HEX, address: toUuid(text),
|
|
186
|
+
note: 'The first four hex of the address. Nothing but the message ever travels — the handle plus the message determine the whole address.' });
|
|
187
|
+
},
|
|
188
|
+
family: (a) => {
|
|
189
|
+
const src = BAKE?.answers[FROM_BAKE.family];
|
|
190
|
+
if (src === undefined)
|
|
191
|
+
throw new Error('family filters the lines of qpu_families, and that answer is not loaded here — the published package carries it at dist/data/baked/qpu_families.json');
|
|
192
|
+
const name = String(a?.name ?? '').trim().toLowerCase();
|
|
193
|
+
if (!/^[a-z][a-z0-9]*$/.test(name))
|
|
194
|
+
return JSON.stringify({ status: 'REFUSED', why: 'a family name is one lowercase word, such as analytics' });
|
|
195
|
+
const lines = src.split('\n').filter((l) => l.toLowerCase().includes(name));
|
|
196
|
+
return JSON.stringify({ family: name, lines: lines.length, status: lines.length ? 'FOUND' : 'NOT_FOUND', tests: lines.slice(0, 12),
|
|
197
|
+
baked: true, ...(BAKE?.stamp ?? {}), note: 'filtered from the qpu_families answer baked at build — the same filter the full server applies, over the same lines' });
|
|
198
|
+
},
|
|
199
|
+
honesty_gate: (a) => {
|
|
200
|
+
const text = String(a?.text ?? '');
|
|
201
|
+
if (!text)
|
|
202
|
+
throw new Error('honesty_gate: text is required — the gate reads prose the caller passes in; it reads no file here');
|
|
203
|
+
const r = computes(text);
|
|
204
|
+
return JSON.stringify({ binary: r.binary, hit: r.hit,
|
|
205
|
+
note: r.binary ? 'no overclaim shape (a lexical FLOOR, not truth — passing is not being right)' : 'drains: ' + r.hit });
|
|
206
|
+
},
|
|
207
|
+
verify_face: (a) => {
|
|
208
|
+
const raw = a?.json;
|
|
209
|
+
if (!raw)
|
|
210
|
+
throw new Error('verify_face: json is required — pass the face object or its JSON text. This entry reads no files.');
|
|
211
|
+
const face = (typeof raw === 'string' ? JSON.parse(raw) : raw);
|
|
212
|
+
const r = checkFace(face);
|
|
213
|
+
return JSON.stringify({ ...r,
|
|
214
|
+
note: 'INTEGRITY ONLY. A passing verdict establishes that the rows are unaltered since sealing, NOT that any figure in them is correct. Reading it as evidence a number is right is the error this tool exists to prevent.' });
|
|
215
|
+
},
|
|
216
|
+
rosetta: () => JSON.stringify({ core: ROSETTA_CORE, domains: ROSETTA_DOMAINS.length,
|
|
217
|
+
addresses: ROSETTA_DOMAINS.map((d) => ({ domain: d, uuid: toUuid(d) })),
|
|
218
|
+
distinct: new Set(ROSETTA_DOMAINS.map((d) => toUuid(d))).size === ROSETTA_DOMAINS.length,
|
|
219
|
+
root: merkleFold(ROSETTA_DOMAINS.map((d) => toUuid(d))),
|
|
220
|
+
note: 'Integrity of the cross-domain map, not truth of anything in it.' }),
|
|
221
|
+
audit: () => {
|
|
222
|
+
const here = served();
|
|
223
|
+
const missing = here.filter((n) => !H[n]);
|
|
224
|
+
const extra = Object.keys(H).filter((n) => !here.includes(n));
|
|
225
|
+
return JSON.stringify({
|
|
226
|
+
entry: 'self-sufficient', ledgerLoaded: hasLedger(), bakeLoaded: hasBake(), served: here.length, of: TOOLS.length,
|
|
227
|
+
declaredWithoutHandler: missing, handlerWithoutDeclaration: extra,
|
|
228
|
+
writes: [...WRITES].filter((w) => here.includes(w)),
|
|
229
|
+
root: merkleFold(here.map((n) => toUuid(n + ':' + (TOOLS.find((t) => t.name === n)?.description ?? '')))),
|
|
230
|
+
cannotShip: CANNOT_SHIP,
|
|
231
|
+
note: 'Integrity of THIS entry\'s tool surface. `writes` is empty by construction: nothing reachable from here can write, because nothing reachable from here has a tree to write to.',
|
|
232
|
+
});
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
const first = (d) => (d.split(/(?<=[.—])\s/)[0] ?? d).slice(0, 140);
|
|
236
|
+
export const listTools = (name) => {
|
|
237
|
+
if (name) {
|
|
238
|
+
const t = TOOLS.find((x) => x.name === String(name));
|
|
239
|
+
if (!t)
|
|
240
|
+
throw new Error(`unknown tool: ${String(name)} — call list_tools with no name for the list`);
|
|
241
|
+
const avail = served().includes(t.name);
|
|
242
|
+
return JSON.stringify({ name: t.name, description: t.description, inputSchema: t.inputSchema, available: avail,
|
|
243
|
+
...(bakedNames().includes(t.name) ? { baked: true, ...(BAKE?.stamp ?? {}) } : {}),
|
|
244
|
+
...(avail ? {} : { needs: NEEDS[t.name], why: whyNot(t.name) }) });
|
|
245
|
+
}
|
|
246
|
+
return JSON.stringify({
|
|
247
|
+
entry: 'self-sufficient — runs from the published package with no account, key, model, network or clone',
|
|
248
|
+
serves: `${served().length} of ${TOOLS.length} tools`,
|
|
249
|
+
ledgerLoaded: hasLedger(), bakeLoaded: hasBake(),
|
|
250
|
+
tools: served().map((n) => ({ name: n, description: first(TOOLS.find((t) => t.name === n)?.description ?? '') })),
|
|
251
|
+
baked: bakedNames().length ? { tools: bakedNames().length, ...(BAKE?.stamp ?? {}) } : null,
|
|
252
|
+
elsewhere: TOOLS.filter((t) => !served().includes(t.name)).map((t) => ({ name: t.name, needs: NEEDS[t.name], why: whyNot(t.name) })),
|
|
253
|
+
note: 'The other tools are not hidden and not broken: each names what it needs. Clone the repository for the full surface.',
|
|
254
|
+
});
|
|
255
|
+
};
|
|
256
|
+
export const run = (name, a) => {
|
|
257
|
+
if (name === 'list_tools')
|
|
258
|
+
return listTools(a?.name);
|
|
259
|
+
if (name === 'call_tool')
|
|
260
|
+
return run(String(a?.name ?? ''), a?.arguments ?? {});
|
|
261
|
+
const h = H[name];
|
|
262
|
+
if (!h && BAKE && BAKE.answers[name] !== undefined && BAKEABLE.includes(name)) {
|
|
263
|
+
const args = a && typeof a === 'object' ? Object.keys(a) : [];
|
|
264
|
+
if (args.length)
|
|
265
|
+
throw new Error(`${name} is served BAKED — its bare answer, computed at build from the repository — and a call with `
|
|
266
|
+
+ `arguments (${args.join(', ')}) asks for an answer the package cannot recompute. Call it without arguments, or clone the repository and run \`npm run mcp\`.`);
|
|
267
|
+
let answer = BAKE.answers[name];
|
|
268
|
+
try {
|
|
269
|
+
answer = JSON.parse(BAKE.answers[name]);
|
|
270
|
+
}
|
|
271
|
+
catch { }
|
|
272
|
+
return JSON.stringify({ baked: true, ...BAKE.stamp, tool: name, answer,
|
|
273
|
+
note: 'The bare answer this tool gave at build, from the tree the stamp names — not a recomputation here. Integrity of the stamp, not truth of the answer.' });
|
|
274
|
+
}
|
|
275
|
+
if (!h) {
|
|
276
|
+
const declared = TOOLS.find((t) => t.name === name);
|
|
277
|
+
if (declared)
|
|
278
|
+
throw new Error(`${name} is a tool of this deposit but is not served by the self-sufficient entry: ${whyNot(name)}`);
|
|
279
|
+
throw new Error(`unknown tool: ${name} — call list_tools for what this entry serves`);
|
|
280
|
+
}
|
|
281
|
+
return h(a);
|
|
282
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SUITES: Record<string, string[]>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const SUITES = {
|
|
2
|
+
'mcp-gate': ['node', 'scripts/mcp-gate.ts'],
|
|
3
|
+
'hardcode-gate': ['node', 'scripts/hardcode-gate.ts'],
|
|
4
|
+
'mcp-check': ['node', 'scripts/mcp-check.ts'],
|
|
5
|
+
'mcp-calls': ['node', 'scripts/mcp-calls.ts'],
|
|
6
|
+
'net-tools-test': ['node', 'scripts/net-tools-test.ts'],
|
|
7
|
+
'clay-conditions-self-test': ['node', 'scripts/clay-conditions-test.ts', '--self-test'],
|
|
8
|
+
'clay-conditions': ['node', 'scripts/clay-conditions-test.ts'],
|
|
9
|
+
'environment': ['node', 'scripts/environment.ts'],
|
|
10
|
+
'doi-precedence': ['node', 'scripts/doi-precedence-test.ts'],
|
|
11
|
+
'answer-doi': ['node', 'scripts/answer-doi-test.ts'],
|
|
12
|
+
'answer-tool': ['node', 'scripts/answer-tool-test.ts'],
|
|
13
|
+
'fallbacks': ['node', 'scripts/fallbacks-test.ts'],
|
|
14
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const mirror: (n: string) => {
|
|
2
|
+
status: 'MIRRORED';
|
|
3
|
+
mirror: string;
|
|
4
|
+
involution: boolean;
|
|
5
|
+
} | {
|
|
6
|
+
status: 'REFUSED';
|
|
7
|
+
why: string;
|
|
8
|
+
};
|
|
9
|
+
export interface Semiprime {
|
|
10
|
+
n: string;
|
|
11
|
+
p: number;
|
|
12
|
+
q: number;
|
|
13
|
+
mirror: string | null;
|
|
14
|
+
}
|
|
15
|
+
export declare const semiprimes: (lo: number, hi: number, opts?: {
|
|
16
|
+
noZero?: boolean;
|
|
17
|
+
limit?: number;
|
|
18
|
+
}) => Semiprime[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const mirror = (n) => {
|
|
2
|
+
if (!/^\d+$/.test(n))
|
|
3
|
+
return { status: 'REFUSED', why: 'not a non-negative decimal integer' };
|
|
4
|
+
if (n.includes('0'))
|
|
5
|
+
return { status: 'REFUSED', why: 'a zero digit has no mirror: 10 − 0 is not a digit' };
|
|
6
|
+
const m = [...n].map((c) => String(10 - Number(c))).join('');
|
|
7
|
+
const back = [...m].map((c) => String(10 - Number(c))).join('');
|
|
8
|
+
return { status: 'MIRRORED', mirror: m, involution: back === n };
|
|
9
|
+
};
|
|
10
|
+
const smallestFactor = (n) => {
|
|
11
|
+
if (n < 2)
|
|
12
|
+
return null;
|
|
13
|
+
if (n % 2 === 0)
|
|
14
|
+
return 2;
|
|
15
|
+
for (let d = 3; d * d <= n; d += 2)
|
|
16
|
+
if (n % d === 0)
|
|
17
|
+
return d;
|
|
18
|
+
return null;
|
|
19
|
+
};
|
|
20
|
+
export const semiprimes = (lo, hi, opts = {}) => {
|
|
21
|
+
const out = [];
|
|
22
|
+
const limit = opts.limit ?? 20;
|
|
23
|
+
const start = lo % 2 === 0 ? lo + 1 : lo;
|
|
24
|
+
for (let n = start; n <= hi && out.length < limit; n += 2) {
|
|
25
|
+
const s = String(n);
|
|
26
|
+
if (opts.noZero && s.includes('0'))
|
|
27
|
+
continue;
|
|
28
|
+
const p = smallestFactor(n);
|
|
29
|
+
if (p === null)
|
|
30
|
+
continue;
|
|
31
|
+
const q = n / p;
|
|
32
|
+
if (q === p || smallestFactor(q) !== null)
|
|
33
|
+
continue;
|
|
34
|
+
out.push({ n: s, p, q, mirror: s.includes('0') ? null : mirror(s).status === 'MIRRORED' ? mirror(s).mirror : null });
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const RULES = [
|
|
2
|
+
{ rule: 'access-grant', verdict: 'NEEDS_OWNER', pattern: /\b(tokens?|credentials?|grant|authori[sz]ed access|access keys?|accounts?|logins?|sign-?ups?|invitations?|invite links?|register|registration|computational access|real users?|registers? as|user accounts?|client (?:browser|os|sessions?)|online sessions?|browser sessions?)\b/i,
|
|
3
|
+
reason: 'grants access to people or issues credentials: only the owner decides who gets access, and with what' },
|
|
4
|
+
{ rule: 'agent-payload-path', verdict: 'GATED', pattern: /\b(payload\s+mcp\s+plugin|rbac)\b/i,
|
|
5
|
+
reason: 'agents act on Payload only through the Payload MCP plugin under RBAC: that is the one path, and the roles behind it are set by the owner' },
|
|
6
|
+
{ rule: 'billing', verdict: 'NEEDS_OWNER', pattern: /\b(billing|billable|payment|charge|subscription|price|pricing|meter)\b/i,
|
|
7
|
+
reason: 'takes money or sets prices: needs a payment account, a price and terms that only the owner can set' },
|
|
8
|
+
{ rule: 'public-write', verdict: 'GATED', pattern: /\b(write|publish|commit|seal|push|deploy|create|(?:create|write|edit|change|update|set)\s+(?:\w+\s+){0,2}configs?|payload\s+write|cms\s+write)\b/i,
|
|
9
|
+
reason: 'changes state: stays behind the write gate and is enabled only by the owner, per credential' },
|
|
10
|
+
{ rule: 'read-only', verdict: 'ALLOWED', pattern: /\b(read[- ]?only|reads?|readers?|lattice|apis?|guru|look ?ups?|query)\b/i,
|
|
11
|
+
reason: 'reads public sources and changes nothing: allowed, with a timeout and a result limit' },
|
|
12
|
+
];
|
|
13
|
+
export const decide = (request) => {
|
|
14
|
+
const text = request.trim();
|
|
15
|
+
if (!text)
|
|
16
|
+
return { verdict: 'NEEDS_OWNER', request, reason: 'the request is empty', rule: 'empty' };
|
|
17
|
+
const order = ['NEEDS_OWNER', 'GATED', 'ALLOWED'];
|
|
18
|
+
const hits = RULES.filter((r) => r.pattern.test(text));
|
|
19
|
+
if (!hits.length)
|
|
20
|
+
return { verdict: 'NEEDS_OWNER', request: text, reason: 'no rule of this repository names the request, so the owner decides', rule: 'unmatched' };
|
|
21
|
+
const strictest = hits.sort((a, b) => order.indexOf(a.verdict) - order.indexOf(b.verdict))[0];
|
|
22
|
+
return { verdict: strictest.verdict, request: text, reason: strictest.reason, rule: strictest.rule };
|
|
23
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { toUuid, merkleFold } from '../../0/index.js';
|
|
2
|
+
export const CORE = 'rosetta-core';
|
|
3
|
+
export const DOMAINS = [
|
|
4
|
+
'z9-arithmetic', 'units-triad', 'doubling-orbit', 'inverses', 'powers', 'primes', 'cyclic-groups',
|
|
5
|
+
'boolean-algebra', 'entanglement', 'dialectic', 'games', 'arts', 'gematria', 'language-lens',
|
|
6
|
+
'merkle-ledger', 'harmonic-ledger', 'no-payload-security', 'involutions', 'fibonacci-cassini',
|
|
7
|
+
'lucas-pell', 'finite-fields', 'perfect-amicable', 'collatz', 'stirling', 'graph-coloring',
|
|
8
|
+
'rule90-sierpinski', 'continued-fractions', 'quaternions', 'motzkin', 'bernoulli', 'catalan',
|
|
9
|
+
'divisor-sums', 'platonic-solids', 'crystal-diamond', 'genus-topology', 'surfaces', 'wilson-fermat',
|
|
10
|
+
'figurate', 'rock-paper-scissors', 'self-similarity', 'fair-division', 'honeycomb', 'waves',
|
|
11
|
+
'forensics', 'ramsey', 'inequalities', 'partitions', 'lucas-theorem', 'pigeonhole', 'pick',
|
|
12
|
+
'cantor-pairing', 'chinese-remainder', 'quadratic-residues', 'path', 'abundance', 'cancer',
|
|
13
|
+
'superposition', 'creation-week', 'relations',
|
|
14
|
+
];
|
|
15
|
+
export function report() {
|
|
16
|
+
const addrs = DOMAINS.map((d) => toUuid(CORE + '→' + d));
|
|
17
|
+
const distinct = new Set(addrs).size;
|
|
18
|
+
const root = merkleFold(addrs);
|
|
19
|
+
let o = 'the rosetta — completed (the star: every domain one hop from the core):\n\n';
|
|
20
|
+
o += ' core: ' + toUuid(CORE).slice(0, 13) + '…\n';
|
|
21
|
+
o += ' domains (' + DOMAINS.length + '): ' + DOMAINS.join(' · ') + '\n';
|
|
22
|
+
o += ' each reachable in one hop; ' + distinct + ' distinct addresses (' + (distinct === DOMAINS.length ? 'no collision — complete' : 'COLLISION') + ')\n';
|
|
23
|
+
o += ' folded rosetta root ' + root.slice(0, 13) + '… — the cross-domain translation is complete.';
|
|
24
|
+
return o;
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ceccec/millennium-solutions",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.8.3",
|
|
4
4
|
"description": "Verifiable, recomputable ℤ/9 vortex framework in ONE package — content-addressing, audit ledger, exact arithmetic, and the honesty toolkit. Facts only.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Tsvetan Rouschev",
|
|
@@ -14,7 +14,11 @@
|
|
|
14
14
|
"types": "./dist/mod.core.d.ts",
|
|
15
15
|
"default": "./dist/mod.core.js"
|
|
16
16
|
},
|
|
17
|
-
"./package.json": "./package.json"
|
|
17
|
+
"./package.json": "./package.json",
|
|
18
|
+
"./mcp": {
|
|
19
|
+
"types": "./dist/src/mcp/serve.d.ts",
|
|
20
|
+
"default": "./dist/src/mcp/serve.js"
|
|
21
|
+
}
|
|
18
22
|
},
|
|
19
23
|
"types": "./dist/mod.core.d.ts",
|
|
20
24
|
"files": [
|
|
@@ -29,8 +33,8 @@
|
|
|
29
33
|
},
|
|
30
34
|
"scripts": {
|
|
31
35
|
"docs:dev": "vitepress dev",
|
|
32
|
-
"predocs:build": "node scripts/analytics.ts && node scripts/pages.ts && node scripts/dashboard.ts && node scripts/boundaries.ts && node scripts/rights.ts && node scripts/priorart.ts && node scripts/challenges.ts && node scripts/heart.ts && node scripts/accounting.ts && node scripts/speedup.ts && node scripts/greeting.ts && node scripts/solutions.ts && node scripts/contradictions.ts && node scripts/latex-gate.ts && node scripts/paper.ts",
|
|
33
|
-
"docs:build": "vitepress build && node scripts/e2e.ts",
|
|
36
|
+
"predocs:build": "node scripts/analytics.ts && node scripts/pages.ts && node scripts/dashboard.ts && node scripts/boundaries.ts && node scripts/rights.ts && node scripts/priorart-gen.ts && node scripts/priorart.ts && node scripts/challenges.ts && node scripts/heart.ts && node scripts/accounting.ts && node scripts/speedup.ts && node scripts/greeting.ts && node scripts/solutions.ts && node scripts/contradictions.ts && node scripts/latex-gate.ts && node scripts/paper.ts",
|
|
37
|
+
"docs:build": "NODE_OPTIONS=--max-old-space-size=7168 vitepress build && node scripts/e2e.ts",
|
|
34
38
|
"docs:preview": "vitepress preview",
|
|
35
39
|
"crypto-kat": "node scripts/crypto-kat.ts",
|
|
36
40
|
"prose-trial": "node scripts/prose-trial.ts",
|
|
@@ -99,7 +103,7 @@
|
|
|
99
103
|
"latex-gate": "node scripts/latex-gate.ts",
|
|
100
104
|
"contradictions": "node scripts/contradictions.ts",
|
|
101
105
|
"prior-art": "node scripts/priorart.ts",
|
|
102
|
-
"gates": "node scripts/prose-trial.ts && node scripts/crypto-kat.ts && node scripts/attribution-gate.ts && node scripts/hardcode-gate.ts && node scripts/import-gate.ts && node scripts/one-author-gate.ts && node scripts/orphan-gate.ts && node scripts/security-gate.ts && node scripts/translate-gate.ts && node scripts/lean-agree.ts && node scripts/trial-all.ts && node scripts/readme.ts && node scripts/gaps.ts && node scripts/constants-gate.ts && node scripts/fixture-addresses.ts && node scripts/forensic-audit.ts && node scripts/notice.ts && node scripts/recover.ts && node scripts/independent.ts && node scripts/covered-gate.ts && node scripts/vacuity.ts && node scripts/citations-gate.ts && node scripts/cite-audit.ts && node scripts/lanes-check.ts && node scripts/runnable-gate.ts && node scripts/formulas.ts && node scripts/coils.ts",
|
|
106
|
+
"gates": "node scripts/apis-theorems.ts && node scripts/prose-trial.ts && node scripts/crypto-kat.ts && node scripts/attribution-gate.ts && node scripts/hardcode-gate.ts && node scripts/import-gate.ts && node scripts/one-author-gate.ts && node scripts/orphan-gate.ts && node scripts/security-gate.ts && node scripts/translate-gate.ts && node scripts/lean-agree.ts && node scripts/trial-all.ts && node scripts/readme.ts && node scripts/gaps.ts && node scripts/constants-gate.ts && node scripts/fixture-addresses.ts && node scripts/forensic-audit.ts && node scripts/notice.ts && node scripts/recover.ts && node scripts/independent.ts && node scripts/supersede.ts && node scripts/covered-gate.ts && node scripts/group.ts --emit && node scripts/bridge.ts --emit && node scripts/vacuity.ts && node scripts/citations-gate.ts && node scripts/cite-audit.ts && node scripts/lanes-check.ts && node scripts/runnable-gate.ts && node scripts/formulas.ts && node scripts/coils.ts && node scripts/settled.ts && node scripts/derived-gate.ts && node scripts/mcp-gate.ts && npm run --silent gate:thousand:control && node scripts/qpu-gate.ts && node scripts/discoveries.ts",
|
|
103
107
|
"gates:fire": "node scripts/gates-fire.ts",
|
|
104
108
|
"ci:local": "node scripts/ci-local.ts",
|
|
105
109
|
"metrics": "node scripts/metrics.ts",
|
|
@@ -115,6 +119,7 @@
|
|
|
115
119
|
"docs-gate": "node scripts/docs-gate.ts",
|
|
116
120
|
"priorart:gen": "node scripts/priorart-gen.ts",
|
|
117
121
|
"priorart-check": "node scripts/priorart-gen.ts --check",
|
|
122
|
+
"priorart:arxiv": "node scripts/arxiv-search.ts",
|
|
118
123
|
"apply": "node scripts/apply.ts",
|
|
119
124
|
"ci-drift": "node scripts/ci-drift.ts",
|
|
120
125
|
"carry": "node scripts/carry.ts",
|
|
@@ -171,12 +176,44 @@
|
|
|
171
176
|
"formulas": "node scripts/formulas.ts",
|
|
172
177
|
"discoveries": "node scripts/discoveries.ts",
|
|
173
178
|
"e2e": "node scripts/e2e.ts",
|
|
174
|
-
"release:live": "node scripts/release-live.ts"
|
|
179
|
+
"release:live": "node scripts/release-live.ts",
|
|
180
|
+
"settled": "node scripts/settled.ts",
|
|
181
|
+
"settled:emit": "node scripts/settled.ts --emit",
|
|
182
|
+
"derived-gate": "node scripts/derived-gate.ts",
|
|
183
|
+
"mcp:self": "node mcp.bin.ts",
|
|
184
|
+
"mcp-gate": "node scripts/mcp-gate.ts",
|
|
185
|
+
"entanglements": "node scripts/entanglements.ts",
|
|
186
|
+
"entanglements:control": "node scripts/entanglements.ts --control",
|
|
187
|
+
"readers": "node scripts/readers.ts",
|
|
188
|
+
"readers:list": "node scripts/readers.ts --list",
|
|
189
|
+
"entangle-oeis": "node scripts/entangle-oeis.ts",
|
|
190
|
+
"api-discover": "node scripts/api-discover.ts",
|
|
191
|
+
"api-discover:schemas": "node scripts/api-discover.ts --schemas",
|
|
192
|
+
"waves": "node scripts/waves.ts",
|
|
193
|
+
"waves:quick": "node scripts/waves.ts --quick",
|
|
194
|
+
"group": "node scripts/group.ts",
|
|
195
|
+
"supersede": "node scripts/supersede.ts",
|
|
196
|
+
"ci:watch": "node scripts/ci-watch.ts",
|
|
197
|
+
"ci:watch-wait": "node scripts/ci-watch.ts --wait",
|
|
198
|
+
"cycle": "npm run gates && npm run docs:build",
|
|
199
|
+
"cycle:ship": "git fetch -q --force --tags origin && npm update --no-audit --no-fund @uuidna/qpu @uuidna/uuidna && npm run cycle && git add -A && { git diff --cached --quiet || git commit -m 'regenerate the derived artefacts the chain rewrote'; } && git push origin main && node scripts/ci-watch.ts --wait --for 5400 && node scripts/thousand-bit-gate.ts --decode",
|
|
200
|
+
"bridge": "node scripts/bridge.ts",
|
|
201
|
+
"qpu": "node scripts/qpu-gate.ts",
|
|
202
|
+
"mcp:call": "node scripts/mcp-call.ts",
|
|
203
|
+
"gate:thousand": "node scripts/thousand-bit-gate.ts",
|
|
204
|
+
"gate:thousand:control": "node scripts/thousand-bit-gate.ts --control",
|
|
205
|
+
"gate:leads": "node scripts/leads-closed.ts",
|
|
206
|
+
"gate:api": "node scripts/api-gates.ts",
|
|
207
|
+
"gate:packages": "node scripts/package-gates.ts",
|
|
208
|
+
"test:online-verify": "node scripts/online-verify-e2e-test.ts",
|
|
209
|
+
"test:run-suite-security": "node scripts/run-suite-security-test.ts",
|
|
210
|
+
"cern:lean": "node scripts/cern-lean.ts",
|
|
211
|
+
"push:green": "node scripts/push-when-green.ts",
|
|
212
|
+
"dataset:court": "node scripts/dataset-court.ts"
|
|
175
213
|
},
|
|
176
214
|
"devDependencies": {
|
|
177
215
|
"@types/node": "^26.2.0",
|
|
178
216
|
"@types/three": "^0.185.4",
|
|
179
|
-
"@uuidna/uuidna": "^0.2.6",
|
|
180
217
|
"three": "^0.185.1",
|
|
181
218
|
"typescript": "7.0.2",
|
|
182
219
|
"vitepress": "^2.0.0-alpha.19",
|
|
@@ -206,5 +243,15 @@
|
|
|
206
243
|
"verifiable",
|
|
207
244
|
"recomputable",
|
|
208
245
|
"lean4"
|
|
209
|
-
]
|
|
246
|
+
],
|
|
247
|
+
"bin": {
|
|
248
|
+
"millennium-mcp": "./dist/mcp.bin.js"
|
|
249
|
+
},
|
|
250
|
+
"dependencies": {
|
|
251
|
+
"@uuidna/qpu": "^1.0.0",
|
|
252
|
+
"@uuidna/uuidna": "^0.2.6"
|
|
253
|
+
},
|
|
254
|
+
"overrides": {
|
|
255
|
+
"postcss-selector-parser": "^7.1.6"
|
|
256
|
+
}
|
|
210
257
|
}
|