skynet-graph 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +22 -0
- package/LICENSE +661 -0
- package/README.md +245 -0
- package/bin/sg +20 -0
- package/concepts/README.md +23 -0
- package/concepts/_substrate/Claim/Confidence/Trusted.json +6 -0
- package/concepts/_substrate/Claim/Confidence.json +10 -0
- package/concepts/_substrate/Claim/Freshness/Stale.json +7 -0
- package/concepts/_substrate/Claim/Freshness.json +5 -0
- package/concepts/_substrate/Claim/Verification/Refuted.json +6 -0
- package/concepts/_substrate/Claim/Verification.json +6 -0
- package/concepts/_substrate/Claim.json +4 -0
- package/concepts/_substrate/Frontier/InBeam.json +6 -0
- package/concepts/_substrate/Frontier/Stuck.json +6 -0
- package/concepts/_substrate/Frontier.json +5 -0
- package/concepts/_substrate/Intake/ToTask.json +22 -0
- package/concepts/_substrate/Intake/Typed.json +10 -0
- package/concepts/_substrate/Intake.json +27 -0
- package/concepts/_substrate/Task/Answer.json +12 -0
- package/concepts/_substrate/Task/Complexity/Atomic.json +5 -0
- package/concepts/_substrate/Task/Complexity/Compound/Expansion.json +7 -0
- package/concepts/_substrate/Task/Complexity/Compound.json +6 -0
- package/concepts/_substrate/Task/Complexity.json +6 -0
- package/concepts/_substrate/Task/EvalComplexity.json +13 -0
- package/concepts/_substrate/Task/ReportUp.json +6 -0
- package/concepts/_substrate/Task/Rollup.json +10 -0
- package/concepts/_substrate/Task.json +5 -0
- package/concepts/clinical/Diagnosis/Medication.json +6 -0
- package/concepts/clinical/Diagnosis.json +15 -0
- package/concepts/clinical/Observation/LabValue/OutOfRange.json +6 -0
- package/concepts/clinical/Observation/LabValue.json +5 -0
- package/concepts/clinical/Observation.json +6 -0
- package/concepts/common/Document/pathBasket.json +6 -0
- package/concepts/common/Document.json +3 -0
- package/concepts/common/Edge/Distance.json +13 -0
- package/concepts/common/Edge/Stay/LongStay.json +8 -0
- package/concepts/common/Edge/Stay.json +8 -0
- package/concepts/common/Edge/Travel/LongTravel.json +16 -0
- package/concepts/common/Edge/Travel/ShortTravel.json +11 -0
- package/concepts/common/Edge/Travel/targetNode.json +7 -0
- package/concepts/common/Edge/Travel.json +7 -0
- package/concepts/common/Edge.json +3 -0
- package/concepts/common/Vertice.json +3 -0
- package/concepts/supply/Fulfillment.json +10 -0
- package/concepts/supply/Inventory/Reorder.json +7 -0
- package/concepts/supply/Inventory.json +5 -0
- package/concepts/supply/Procurement/SupplierConfirm.json +6 -0
- package/concepts/supply/Procurement.json +8 -0
- package/concepts/supply/Transport.json +5 -0
- package/doc/API.md +556 -0
- package/doc/CAPABILITIES.md +373 -0
- package/doc/MODELISATION.md +511 -0
- package/doc/architecture.md +267 -0
- package/doc/concept-as-graph.md +379 -0
- package/doc/concept-learning.md +168 -0
- package/doc/creative-loop-map.md +202 -0
- package/doc/original-2016-doc.md +148 -0
- package/doc/usage.md +501 -0
- package/lib/authoring/abstract.js +401 -0
- package/lib/authoring/abstraction.js +190 -0
- package/lib/authoring/adapt.js +393 -0
- package/lib/authoring/ancestry.js +216 -0
- package/lib/authoring/author.js +147 -0
- package/lib/authoring/bounded-merge.js +57 -0
- package/lib/authoring/canon.js +158 -0
- package/lib/authoring/clock.js +123 -0
- package/lib/authoring/combinator.js +92 -0
- package/lib/authoring/compete.js +76 -0
- package/lib/authoring/compose-hotspot.js +314 -0
- package/lib/authoring/compress.js +279 -0
- package/lib/authoring/concept-net.js +254 -0
- package/lib/authoring/concepts.js +66 -0
- package/lib/authoring/context-project.js +277 -0
- package/lib/authoring/contract.js +476 -0
- package/lib/authoring/corpus-pack.js +125 -0
- package/lib/authoring/cost-probe.js +86 -0
- package/lib/authoring/crystallize.js +555 -0
- package/lib/authoring/dag-decompose.js +256 -0
- package/lib/authoring/dataset-adapter.js +253 -0
- package/lib/authoring/debug-provider.js +92 -0
- package/lib/authoring/decompose.js +343 -0
- package/lib/authoring/emittability.js +236 -0
- package/lib/authoring/equilibrium.js +160 -0
- package/lib/authoring/extract.js +153 -0
- package/lib/authoring/forest.js +55 -0
- package/lib/authoring/forge-fallback.js +116 -0
- package/lib/authoring/givens.js +121 -0
- package/lib/authoring/glossary.js +177 -0
- package/lib/authoring/grammar-graph.js +191 -0
- package/lib/authoring/granularity.js +80 -0
- package/lib/authoring/graph-net.js +108 -0
- package/lib/authoring/ground.js +148 -0
- package/lib/authoring/higher-order.js +85 -0
- package/lib/authoring/hotspot.js +132 -0
- package/lib/authoring/hysteresis.js +85 -0
- package/lib/authoring/index.js +106 -0
- package/lib/authoring/lattice-morphism.js +61 -0
- package/lib/authoring/lattice-pack.js +148 -0
- package/lib/authoring/leaf-io.js +77 -0
- package/lib/authoring/library.js +156 -0
- package/lib/authoring/lifecycle.js +92 -0
- package/lib/authoring/loop.js +193 -0
- package/lib/authoring/master-loop.js +132 -0
- package/lib/authoring/mdl.js +209 -0
- package/lib/authoring/memo-stability.js +122 -0
- package/lib/authoring/method-explorer.js +138 -0
- package/lib/authoring/method-pack.js +181 -0
- package/lib/authoring/method.js +202 -0
- package/lib/authoring/mine.js +510 -0
- package/lib/authoring/mount.js +119 -0
- package/lib/authoring/negotiate.js +100 -0
- package/lib/authoring/parametric.js +139 -0
- package/lib/authoring/reaggregate.js +75 -0
- package/lib/authoring/rebalance.js +157 -0
- package/lib/authoring/recall.js +135 -0
- package/lib/authoring/registry.js +350 -0
- package/lib/authoring/relearn.js +147 -0
- package/lib/authoring/retention.js +89 -0
- package/lib/authoring/segment-proxy.js +114 -0
- package/lib/authoring/serve-leaf.js +64 -0
- package/lib/authoring/slot-aware-serve.js +77 -0
- package/lib/authoring/sound-invoke.js +59 -0
- package/lib/authoring/split-serve.js +74 -0
- package/lib/authoring/ste.js +239 -0
- package/lib/authoring/stock.js +101 -0
- package/lib/authoring/store.js +94 -0
- package/lib/authoring/supervise.js +138 -0
- package/lib/authoring/support.js +131 -0
- package/lib/authoring/task-mirror.js +51 -0
- package/lib/authoring/typed-loop.js +160 -0
- package/lib/authoring/validate.js +569 -0
- package/lib/authoring/widen.js +88 -0
- package/lib/combos/appliance.js +189 -0
- package/lib/combos/critique.js +377 -0
- package/lib/combos/defaults.js +86 -0
- package/lib/combos/durable-runner.js +115 -0
- package/lib/combos/forge.js +209 -0
- package/lib/combos/index.js +86 -0
- package/lib/combos/learning-library.js +253 -0
- package/lib/combos/mixture-serve.js +193 -0
- package/lib/combos/plan-loop.js +192 -0
- package/lib/combos/proxy-cache.js +272 -0
- package/lib/combos/self-mod.js +94 -0
- package/lib/durable/audit.js +102 -0
- package/lib/durable/checkpoint-store.js +550 -0
- package/lib/durable/fold.js +62 -0
- package/lib/durable/interpreter.js +242 -0
- package/lib/durable/xlate.js +185 -0
- package/lib/graph/Graph.js +2486 -0
- package/lib/graph/expr.js +307 -0
- package/lib/graph/index.js +26 -0
- package/lib/graph/log.js +134 -0
- package/lib/graph/objects/Concept.js +382 -0
- package/lib/graph/objects/Entity.js +503 -0
- package/lib/graph/objects/Node.js +57 -0
- package/lib/graph/objects/PathMap.js +557 -0
- package/lib/graph/objects/Segment.js +100 -0
- package/lib/graph/tasks/stabilize.js +59 -0
- package/lib/graph/tasks/taskflow.js +247 -0
- package/lib/index.js +122 -0
- package/lib/load.js +132 -0
- package/lib/providers/backends.js +117 -0
- package/lib/providers/borderline.js +129 -0
- package/lib/providers/cache.js +226 -0
- package/lib/providers/canonicalize.js +198 -0
- package/lib/providers/constat.js +107 -0
- package/lib/providers/geo.js +53 -0
- package/lib/providers/index.js +116 -0
- package/lib/providers/intake.js +263 -0
- package/lib/providers/llm-local.js +88 -0
- package/lib/providers/llm.js +236 -0
- package/lib/providers/local-host.js +197 -0
- package/lib/providers/merge-consistency.js +162 -0
- package/lib/providers/nogood.js +149 -0
- package/lib/providers/reason-loop.js +223 -0
- package/lib/providers/semiring.js +285 -0
- package/lib/providers/solver-fork.js +163 -0
- package/lib/providers/stats.js +228 -0
- package/lib/providers/verify.js +120 -0
- package/lib/runtime/index.js +135 -0
- package/lib/runtime/invoke-pool.js +92 -0
- package/lib/runtime/protocol.js +210 -0
- package/lib/runtime/transport-socket.js +77 -0
- package/lib/runtime/worker-entry.js +31 -0
- package/lib/sg/cli.js +601 -0
- package/lib/sg/log-sinks.js +214 -0
- package/lib/sg/mcp.js +395 -0
- package/lib/sg/proxy-run.js +66 -0
- package/lib/sg/serve-demo.js +185 -0
- package/lib/sg/serve.js +205 -0
- package/lib/sg/trace.js +118 -0
- package/lib/studio/protocol.js +45 -0
- package/lib/studio/public/app.js +310 -0
- package/lib/studio/public/components/ConceptEditor.js +43 -0
- package/lib/studio/public/components/ConceptTree.js +43 -0
- package/lib/studio/public/components/CorpusPanel.js +68 -0
- package/lib/studio/public/components/ForkTree.js +36 -0
- package/lib/studio/public/components/GrammarGraph.js +99 -0
- package/lib/studio/public/components/GraphCanvas.js +156 -0
- package/lib/studio/public/components/Inspector.js +48 -0
- package/lib/studio/public/components/LearningPanel.js +85 -0
- package/lib/studio/public/components/PromptConsole.js +46 -0
- package/lib/studio/public/components/ProviderTrace.js +39 -0
- package/lib/studio/public/components/SessionSplit.js +47 -0
- package/lib/studio/public/components/TilingOverlay.js +40 -0
- package/lib/studio/public/components/Timeline.js +57 -0
- package/lib/studio/public/index.html +26 -0
- package/lib/studio/public/styles.css +185 -0
- package/lib/studio/public/ws.js +58 -0
- package/lib/studio/server.js +130 -0
- package/lib/studio/session.js +397 -0
- package/lib/studio/studio.js +149 -0
- package/package.json +42 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Nathanael Braun
|
|
3
|
+
* @author : Nathanael BRAUN <pp9ping@gmail.com>
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
'use strict';
|
|
19
|
+
/**
|
|
20
|
+
* Combos — the SHARED product-default module (roadmap P1 / design doc §2).
|
|
21
|
+
*
|
|
22
|
+
* The ONE place the default posture (§4 of studies/2026-07-04-inventaire-outils-combos.md) is
|
|
23
|
+
* decided, so every `lib/combos/*` component wires the SAME knobs instead of each re-deciding them.
|
|
24
|
+
* CONFIG ONLY — each field is a flag or a brick option passed straight through; NO behavior lives
|
|
25
|
+
* here (behavior would make this a brick-in-disguise, violating the thin-assembly rule). The
|
|
26
|
+
* default posture, from the convergent findings:
|
|
27
|
+
* fail-closed ON · admission gate ON · IntakeStatus required downstream · durable memo ON ·
|
|
28
|
+
* author-time validator ON · logs `warn` + audit · constrained grammar OFF (STAGE-1 finding) ·
|
|
29
|
+
* effectful providers / embedded LLM / durable / learning = OPT-IN by argument (never by env).
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* resolveComboDefaults(opts) → the resolved §4 knob-set, host overrides merged in.
|
|
34
|
+
* @returns {{
|
|
35
|
+
* failClosed:boolean, gate:'gated'|'ungated', requireTyped:boolean, memo:boolean,
|
|
36
|
+
* validate:boolean, logLevel:string, audit:boolean, grammar:boolean,
|
|
37
|
+
* ask:(function|{localModel:string}|null), durable:(object|string|null), learning:boolean
|
|
38
|
+
* }}
|
|
39
|
+
*/
|
|
40
|
+
function resolveComboDefaults( opts ) {
|
|
41
|
+
opts = opts || {};
|
|
42
|
+
return {
|
|
43
|
+
failClosed : opts.failClosed !== false, // ON — canon/snap/mount fail-closed
|
|
44
|
+
gate : opts.gate || 'gated', // ON — admission gate (parametric/registry, gated)
|
|
45
|
+
requireTyped: opts.requireTyped !== false, // ON — downstream ensure IntakeStatus=='typed'
|
|
46
|
+
memo : opts.memo !== false, // ON — content-addressed cache, un-cacheable on CanonMiss
|
|
47
|
+
validate : opts.validate !== false, // ON — validateOrThrow before the tree reaches the engine
|
|
48
|
+
logLevel : opts.logLevel || 'warn',
|
|
49
|
+
audit : opts.audit !== false, // ON — apply-correlated trace / durable audit available
|
|
50
|
+
grammar : opts.grammar === true, // OFF — STAGE-1 finding; opt-in, per-call on the borderline gate
|
|
51
|
+
ask : opts.ask || null, // opt-in — NO default LLM backend
|
|
52
|
+
durable : opts.durable || null, // opt-in — off = in-memory / none
|
|
53
|
+
learning : opts.learning === true // opt-in — creative loop off by default
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* buildAsk(d) → resolve `d.ask` to an async `({system,user,maxTokens}) -> string`.
|
|
59
|
+
* - a function → returned as-is (host-supplied backend)
|
|
60
|
+
* - { localModel:'<gguf>' } → the embedded node-llama-cpp `ask` via the shared host, with the §4
|
|
61
|
+
* default `reasoningBudget:0` applied HERE (one place, not re-decided per combo)
|
|
62
|
+
* - null / absent → throws (the combo needs a backend)
|
|
63
|
+
*
|
|
64
|
+
* Grammar is deliberately NOT wired here (finding R3): `makeLocalAsk` reads `jsonSchema`/`gbnf`, never
|
|
65
|
+
* a boolean `grammar`; constrained decoding is a per-call seam on the borderline gate, opt-in. So
|
|
66
|
+
* `buildAsk` never touches grammar — the STAGE-1 default (OFF) is simply "pass no schema".
|
|
67
|
+
* The `llm-local`/`local-host` requires are LAZY (only when `{localModel}` is used), so a host that
|
|
68
|
+
* injects its own `ask` never loads the native dependency.
|
|
69
|
+
*/
|
|
70
|
+
function buildAsk( d ) {
|
|
71
|
+
var a = d && d.ask;
|
|
72
|
+
if ( typeof a === 'function' ) return a;
|
|
73
|
+
if ( a && a.localModel ) {
|
|
74
|
+
var sharedLocalModelHost = require('../providers/local-host.js').sharedLocalModelHost;
|
|
75
|
+
var makeLocalAsk = require('../providers/llm-local.js').makeLocalAsk;
|
|
76
|
+
return makeLocalAsk({
|
|
77
|
+
modelPath : a.localModel,
|
|
78
|
+
reasoningBudget: a.reasoningBudget != null ? a.reasoningBudget : 0,
|
|
79
|
+
seed : a.seed,
|
|
80
|
+
host : sharedLocalModelHost()
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
throw new Error('combo needs a backend: pass opts.ask (a function, or { localModel: "<path.gguf>" })');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
module.exports = { resolveComboDefaults: resolveComboDefaults, buildAsk: buildAsk };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Nathanael Braun
|
|
3
|
+
* @author : Nathanael BRAUN <pp9ping@gmail.com>
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
'use strict';
|
|
19
|
+
/**
|
|
20
|
+
* C2 — the DURABLE WORKFLOW RUNNER (roadmap P4). A thin assembly over the durable executor bricks
|
|
21
|
+
* (`lib/durable/*`): the CheckpointStore (durable marking + content-memo + lease queue, memory or
|
|
22
|
+
* SQLite), the C-xlate (`compileMethod`: a compact select+task+map+reduce spec → a workflow net), the
|
|
23
|
+
* interpreter (`runFlow`: routes typed records, memoizes task calls, fans out maps, folds joins,
|
|
24
|
+
* asserts a per-step contract), and the audit forest (`auditRun`). The properties are already MEASURED
|
|
25
|
+
* (the §11 gate: STRUCT 6 calls vs RAG 24, 0/12 drift-stale; crash-safety via fencing token +
|
|
26
|
+
* rollbackInflight): this combo just names them behind one governed entry point.
|
|
27
|
+
*
|
|
28
|
+
* const runner = createDurableRunner({ store: 'flow.db', runTask });
|
|
29
|
+
* await runner.run('run-1', spec, records); // compile-if-spec → ensureRun → inject → runFlow
|
|
30
|
+
* await runner.resume('run-1', spec); // crash-recovery: reclaim orphaned tokens → finish
|
|
31
|
+
* const { summary } = runner.audit('run-1'); // the derivation forest + verdict + blame
|
|
32
|
+
*
|
|
33
|
+
* The content-memo is SOUND by its key: `keyOf(taskRef, token)` must project to a SUPERSET of the
|
|
34
|
+
* facts each task reads (so it never under-keys → never a false hit) yet ignore incidental fields (so a
|
|
35
|
+
* recurrent class amortizes). The default keys on `{task, payload}` (sound but coarse — incidental
|
|
36
|
+
* fields re-key); pass `opts.keyOf` for tighter amortization (see examples/poc/durable-flow.js).
|
|
37
|
+
* The bricks stay usable "à nu" (`Graph.durable.*`); this is an optional convenience.
|
|
38
|
+
*
|
|
39
|
+
* @param opts.store a file PATH (→ SQLite, crash-safe, cross-restart) or a store; default in-memory.
|
|
40
|
+
* @param opts.runTask (task, token) => {payload?, created?} | Promise<…> the micro-task runner (REQUIRED).
|
|
41
|
+
* @param opts.contract optional per-step contract (assertPost G1/G2) passed to runFlow.
|
|
42
|
+
* @param opts.keyOf optional content-memo key `(taskRef, token) => key`. Default: digest({task,payload}).
|
|
43
|
+
* @param opts.lease/batch/maxSteps optional runFlow bounds.
|
|
44
|
+
* @param opts.* the §4 knobs via resolveComboDefaults.
|
|
45
|
+
* @returns {{ compile, run, resume, audit, stats, marking, store, close }}
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
var defaults = require('./defaults.js');
|
|
49
|
+
var xlate = require('../durable/xlate.js');
|
|
50
|
+
var interp = require('../durable/interpreter.js');
|
|
51
|
+
var audit = require('../durable/audit.js');
|
|
52
|
+
var cp = require('../durable/checkpoint-store.js');
|
|
53
|
+
var digest = require('../providers/canonicalize.js').digest;
|
|
54
|
+
|
|
55
|
+
function looksLikeSpec( x ) { return !!(x && (x.select || x.methods || x.steps || x.map)); }
|
|
56
|
+
|
|
57
|
+
function createDurableRunner( opts ) {
|
|
58
|
+
opts = opts || {};
|
|
59
|
+
var d = defaults.resolveComboDefaults(opts);
|
|
60
|
+
if ( typeof opts.runTask !== 'function' )
|
|
61
|
+
throw new Error('createDurableRunner needs opts.runTask ((task, token) => {payload?, created?})');
|
|
62
|
+
|
|
63
|
+
// the durable store: a file path → SQLite (crash-safe + cross-restart), a store object → as-is, else in-memory.
|
|
64
|
+
var store = (typeof opts.store === 'string') ? cp.createSqliteCheckpointStore({ file: opts.store })
|
|
65
|
+
: (opts.store || cp.createMemoryCheckpointStore());
|
|
66
|
+
|
|
67
|
+
// SOUND-by-default content-memo key (coarse: incidental fields re-key). Host overrides for tighter amortization.
|
|
68
|
+
var keyOf = opts.keyOf || function ( taskRef, token ) { return digest({ task: taskRef.task, payload: token.payload || {} }); };
|
|
69
|
+
|
|
70
|
+
function runFlowOpts( extra ) {
|
|
71
|
+
return Object.assign({ runTask: opts.runTask, keyOf: keyOf, contract: opts.contract,
|
|
72
|
+
lease: opts.lease, batch: opts.batch, maxSteps: opts.maxSteps }, extra);
|
|
73
|
+
}
|
|
74
|
+
function netOf( netOrSpec ) {
|
|
75
|
+
if ( !looksLikeSpec(netOrSpec) ) return netOrSpec; // already a compiled net
|
|
76
|
+
var net = xlate.compileMethod(netOrSpec);
|
|
77
|
+
if ( d.validate ) xlate.validateNet(net); // author-time net validation (default ON)
|
|
78
|
+
return net;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
store: store,
|
|
83
|
+
|
|
84
|
+
/** compile a compact select+task+map+reduce spec → a workflow net (+ validate). */
|
|
85
|
+
compile: function ( spec ) { var net = xlate.compileMethod(spec); if ( d.validate ) xlate.validateNet(net); return net; },
|
|
86
|
+
|
|
87
|
+
/** run a workflow: compile-if-spec → ensureRun → inject records → drain to completion. */
|
|
88
|
+
run: function ( runId, netOrSpec, records, extra ) {
|
|
89
|
+
var net = netOf(netOrSpec);
|
|
90
|
+
store.ensureRun(runId, net);
|
|
91
|
+
if ( records && records.length ) store.inject(runId, records);
|
|
92
|
+
return interp.runFlow(store, runId, net, runFlowOpts(extra));
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
/** crash-recovery: reclaim orphaned in-flight tokens (rollbackInflight), then drain to completion —
|
|
96
|
+
* no effect lost or duplicated (the memo + fencing token make replay exactly-once). */
|
|
97
|
+
resume: function ( runId, netOrSpec, extra ) {
|
|
98
|
+
var net = netOf(netOrSpec);
|
|
99
|
+
if ( store.rollbackInflight ) store.rollbackInflight(runId);
|
|
100
|
+
return interp.runFlow(store, runId, net, runFlowOpts(extra));
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
/** the derivation forest + verdict + blame for a run. */
|
|
104
|
+
audit: function ( runId ) { var a = audit.auditRun(store, runId); return { audit: a, summary: audit.auditSummary(a) }; },
|
|
105
|
+
|
|
106
|
+
/** the run's token status counts { ready, leased, done, failed, … }. */
|
|
107
|
+
stats: function ( runId ) { return store.stats(runId); },
|
|
108
|
+
/** the run's place marking. */
|
|
109
|
+
marking: function ( runId ) { return store.marking ? store.marking(runId) : null; },
|
|
110
|
+
|
|
111
|
+
close: function () { if ( store.close ) store.close(); }
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
module.exports = { createDurableRunner: createDurableRunner };
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Nathanael Braun — AGPL-3.0-or-later.
|
|
3
|
+
*/
|
|
4
|
+
'use strict';
|
|
5
|
+
/**
|
|
6
|
+
* forge (M3) — the one-call STOCK FABRICATION pipeline, promoted from the WikiSQL pilot (2026-07-05) into
|
|
7
|
+
* a reusable brick. Given a class-grouped adapted corpus (each record carries its gold typed-step shape),
|
|
8
|
+
* it runs, per class: a model FORGE decomposition → an engine TRACE (a typed-step Plan chain) → CRYSTALLIZE
|
|
9
|
+
* (distil a per-class structural method) → the GOLD-GATE (admit iff consistent ∧ shape==gold ∧ crystallized)
|
|
10
|
+
* → packStock into a portable `.sgc`. It also emits a VALIDATION DOSSIER — the certification asset: which
|
|
11
|
+
* dataset, which forge model, the per-class verdicts, the aggregate (0 false admitted, by construction of
|
|
12
|
+
* the gate), the soundness gates (neg-control + round-trip), and the sha256 the dossier binds.
|
|
13
|
+
*
|
|
14
|
+
* SOUNDNESS is carried by the GATE + the dataset oracle, never the model: whatever a small model renders,
|
|
15
|
+
* only a gold-matching, consistent, crystallized shape enters the stock. YIELD (how many classes admit) is
|
|
16
|
+
* bounded by model consistency — the soundness-preserving lever is `consistencyVote` (sample N, take the
|
|
17
|
+
* majority shape; still gold-gated).
|
|
18
|
+
*
|
|
19
|
+
* const r = await forgeStock({ classes, stepEnum, ask, name, version, dataset, negControl:true });
|
|
20
|
+
* // r.bundle = the .sgc methods stock ; r.dossier = the validation record ; r.verdict = the pass summary
|
|
21
|
+
*
|
|
22
|
+
* The trace-producing engine run lives here (the Plan provider + the typed-step chain are dataset-agnostic);
|
|
23
|
+
* a dataset supplies only the adapted `classes` (+ optionally a tighter `decompose` for yield).
|
|
24
|
+
*/
|
|
25
|
+
const path = require('path');
|
|
26
|
+
const crypto = require('crypto');
|
|
27
|
+
const Graph = require('../graph');
|
|
28
|
+
const { nextStable } = require('../authoring/supervise.js');
|
|
29
|
+
const { methodTrace } = require('../authoring/mine.js');
|
|
30
|
+
const { createLearningLibrary } = require('./learning-library.js');
|
|
31
|
+
const stockMod = require('../authoring/stock.js'); // goldGate + packStock + consistencyVote + shapeOf
|
|
32
|
+
const packMod = require('../authoring/method-pack.js');
|
|
33
|
+
|
|
34
|
+
// the dataset-agnostic engine scaffold: a Plan concept that decomposes a task segment into a typed-step chain.
|
|
35
|
+
const TREE = { childConcepts: { Plan: { _id: 'Plan', _name: 'Plan', require: ['Segment', 'taskKind'], ensure: ['!$Planned'], provider: ['Plan::plan'] } } };
|
|
36
|
+
const DECL = { origin: { field: 'originNode' }, target: { field: 'targetNode' } };
|
|
37
|
+
const CFG = { label: 'forge', isMaster: true, autoMount: true, conceptSets: ['common'], bagRefManagers: {}, logLevel: 'error' };
|
|
38
|
+
|
|
39
|
+
/** the default typed-step forge: deterministic gold-forge when no model (ask=null), else a generic prompt. */
|
|
40
|
+
function makeDefaultDecompose( stepEnum ) {
|
|
41
|
+
const snap = ( s ) => (stepEnum || []).find(( e ) => String(s || '').toLowerCase().includes(e)) || String(s || '').toLowerCase();
|
|
42
|
+
return async function ( ask, rec, o ) {
|
|
43
|
+
o = o || {};
|
|
44
|
+
if ( !ask ) return o.corrupt ? rec.goldSteps.slice(0, Math.max(1, rec.goldSteps.length - 1)) : rec.goldSteps.slice();
|
|
45
|
+
const txt = await ask({
|
|
46
|
+
system: 'Break the query into an ORDERED list of typed steps. Use ONLY these kinds: ' + (stepEnum || []).join(', ')
|
|
47
|
+
+ '. Reply ONLY JSON: {"steps":["..."]}.',
|
|
48
|
+
user: String(rec.problem || ''), maxTokens: 80, temperature: o.temperature || 0
|
|
49
|
+
});
|
|
50
|
+
try { const m = String(txt).match(/\{[\s\S]*\}/); return (JSON.parse(m ? m[0] : txt).steps || []).map(snap); }
|
|
51
|
+
catch ( e ) { return []; }
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function decomposeVoted( voters, rec, decompose ) {
|
|
56
|
+
const samples = [];
|
|
57
|
+
for ( const ask of voters ) { const s = await decompose(ask, rec, { temperature: 0.7 }); if ( s.length ) samples.push(s); }
|
|
58
|
+
return stockMod.consistencyVote(samples).steps;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function makePlanProvider( decompose, ask, meter, plans, voters ) {
|
|
62
|
+
return { plan: async function ( g, c, scope, argz, cb ) {
|
|
63
|
+
const base = scope._._id, o = scope._.originNode, t = scope._.targetNode;
|
|
64
|
+
const rec = plans[scope._.recId];
|
|
65
|
+
let steps;
|
|
66
|
+
if ( voters ) { meter.calls += voters.length; steps = await decomposeVoted(voters, rec, decompose); }
|
|
67
|
+
else if ( ask ) { meter.calls++; steps = await decompose(ask, rec, {}); }
|
|
68
|
+
else steps = await decompose(null, rec, { corrupt: rec._corrupt });
|
|
69
|
+
if ( !steps.length ) return cb(null, { $_id: '_parent', Plan: true, Planned: true, planFailed: true });
|
|
70
|
+
const tpl = [{ $_id: '_parent', Plan: true, Planned: true, nSteps: steps.length }];
|
|
71
|
+
let prev = o;
|
|
72
|
+
steps.forEach(function ( kind, i ) {
|
|
73
|
+
const last = i === steps.length - 1, tnode = last ? t : base + '_m' + i;
|
|
74
|
+
if ( !last ) tpl.push({ _id: tnode, Node: true, state: kind });
|
|
75
|
+
tpl.push({ _id: base + '_s' + i, Segment: true, originNode: prev, targetNode: tnode, parentSeg: base, state: kind });
|
|
76
|
+
prev = tnode;
|
|
77
|
+
});
|
|
78
|
+
rec._modelSteps = steps;
|
|
79
|
+
cb(null, tpl);
|
|
80
|
+
} };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// run every instance of ONE class through a live graph, capture the trace, crystallize, gold-gate → verdict.
|
|
84
|
+
async function buildClassMethod( sig, recs, ask, meter, voters, decompose ) {
|
|
85
|
+
const plans = {};
|
|
86
|
+
recs.forEach(( r, i ) => { r.recId = sig + '#' + i; r.sig = sig; plans[r.recId] = r; });
|
|
87
|
+
const saved = Graph._providers;
|
|
88
|
+
Graph._providers = Object.assign({}, Graph._providers, { Plan: makePlanProvider(decompose, ask, meter, plans, voters) });
|
|
89
|
+
try {
|
|
90
|
+
const nodes = [], segments = [];
|
|
91
|
+
recs.forEach(( r, i ) => {
|
|
92
|
+
nodes.push({ _id: 'S' + i }, { _id: 'G' + i });
|
|
93
|
+
segments.push({ _id: 'E' + i, originNode: 'S' + i, targetNode: 'G' + i, taskKind: sig, recId: r.recId });
|
|
94
|
+
});
|
|
95
|
+
const mt = methodTrace();
|
|
96
|
+
const g = new Graph({ lastRev: 0, nodes, segments }, CFG, { common: TREE });
|
|
97
|
+
mt.listen(g);
|
|
98
|
+
await nextStable(g);
|
|
99
|
+
|
|
100
|
+
const lib = createLearningLibrary({ learning: true, signature: ( p ) => ({ structure: { taskKind: p.taskKind }, content: {} }),
|
|
101
|
+
target: () => null, dispatchFacts: ( p ) => ({ Segment: true, taskKind: p.taskKind }), forge: async () => null });
|
|
102
|
+
const res = lib.crystallizeFrom(mt.records, { episodeTree: TREE, schemaGraph: g, declaredFrontier: DECL, equivKeys: ['Planned'], idFor: () => 'Crystal_' + sig.replace(/[^A-Za-z0-9]/g, '_') });
|
|
103
|
+
|
|
104
|
+
const gate = stockMod.goldGate({ modelShapes: recs.map(( r ) => r._modelSteps || []), goldSteps: recs[0].goldSteps, crystallized: !!res.admitted });
|
|
105
|
+
return { sig, n: recs.length, modelConsistent: gate.consistent, goldShape: gate.goldShape, modelShape: gate.modelShape || '(none)',
|
|
106
|
+
crystallized: !!res.admitted, crystalReason: res.reason, goldMatch: gate.goldMatch, admitted: gate.admitted,
|
|
107
|
+
reason: gate.reason, candidate: gate.admitted ? res.candidate : null };
|
|
108
|
+
} finally { Graph._providers = saved; }
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Fabricate a gold-verified stock + its validation dossier.
|
|
113
|
+
* @param opts.classes { sig: [ {problem, goldSteps:[kind]} ] } — the adapted, class-grouped corpus.
|
|
114
|
+
* @param opts.stepEnum the typed-step vocabulary (for the default forge prompt).
|
|
115
|
+
* @param opts.decompose optional async (ask, rec, {corrupt,temperature}) -> steps[] (override the default).
|
|
116
|
+
* @param opts.ask the model forge (a chat ask). Omit for the deterministic gold-forge (tests).
|
|
117
|
+
* @param opts.voters optional array of asks → consistencyVote (the yield lever).
|
|
118
|
+
* @param opts.name/version/description/dataset bundle + dossier metadata.
|
|
119
|
+
* @param opts.negControl add a corrupted-shape neg-control (proves the gate is non-vacuous). Default true.
|
|
120
|
+
* @returns { results, bundle, dossier, verdict }
|
|
121
|
+
*/
|
|
122
|
+
async function forgeStock( opts ) {
|
|
123
|
+
opts = opts || {};
|
|
124
|
+
const classes = opts.classes || {};
|
|
125
|
+
const decompose = opts.decompose || makeDefaultDecompose(opts.stepEnum);
|
|
126
|
+
const ask = opts.ask || null;
|
|
127
|
+
const voters = opts.voters || null;
|
|
128
|
+
const meter = { calls: 0 };
|
|
129
|
+
const negControl = opts.negControl !== false;
|
|
130
|
+
|
|
131
|
+
const results = [];
|
|
132
|
+
for ( const sig of Object.keys(classes) ) {
|
|
133
|
+
const recs = (classes[sig] || []).slice();
|
|
134
|
+
if ( recs.length < 2 ) continue; // need ≥2 instances to judge consistency
|
|
135
|
+
results.push(await buildClassMethod(sig, recs, ask, meter, voters, decompose));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const admittedList = results.filter(( v ) => v.admitted && v.candidate ).map(( v ) => ({ sig: v.sig, candidate: v.candidate }));
|
|
139
|
+
const bundle = stockMod.packStock(admittedList, { name: opts.name || 'stock', version: opts.version || '0.0.0', description: opts.description || '' });
|
|
140
|
+
const packed = (packMod.unpackMethods(bundle).methods || []).length;
|
|
141
|
+
// round-trip: a fresh library reloads the .sgc → the methods hydrate (cross-deployment ship-ability).
|
|
142
|
+
const fresh = createLearningLibrary({ learning: true, signature: ( p ) => ({ structure: { taskKind: p.taskKind }, content: {} }),
|
|
143
|
+
target: () => null, dispatchFacts: ( p ) => ({ Segment: true, taskKind: p.taskKind }), forge: async () => null });
|
|
144
|
+
const ld = fresh.load(bundle, { version: opts.version || '0.0.0' });
|
|
145
|
+
const reloaded = ld.added != null ? ld.added : 0;
|
|
146
|
+
|
|
147
|
+
// neg-control: a deliberately-corrupted shape on one class MUST be rejected by the gate (non-vacuity).
|
|
148
|
+
let neg = { ran: false, rejected: null };
|
|
149
|
+
if ( negControl ) {
|
|
150
|
+
// need a MULTI-step gold shape — corrupting a 1-step shape yields the same shape (not a real negative).
|
|
151
|
+
const sig = Object.keys(classes).find(( s ) => (classes[s] || []).length >= 2 && ((classes[s][0] || {}).goldSteps || []).length >= 2 );
|
|
152
|
+
if ( sig ) {
|
|
153
|
+
// the neg-control is a DETERMINISTIC soundness check (corrupt the gold shape) — it uses the
|
|
154
|
+
// default gold-forge, never the caller's model decompose (which need only handle a real ask).
|
|
155
|
+
const recs = classes[sig].slice(0, Math.max(2, 3)).map(( r ) => Object.assign({}, r, { _corrupt: true }));
|
|
156
|
+
const v = await buildClassMethod(sig + '~neg', recs, null, meter, null, makeDefaultDecompose(opts.stepEnum));
|
|
157
|
+
neg = { ran: true, rejected: v.admitted === false, sig };
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const attempted = results.length;
|
|
162
|
+
const admitted = admittedList.length;
|
|
163
|
+
const falseAdmitted = results.filter(( v ) => v.admitted && !v.goldMatch ).length; // 0 by construction of the gate
|
|
164
|
+
const gates = [
|
|
165
|
+
{ name: 'gold-gate: 0 false admitted (shape != gold never enters)', pass: falseAdmitted === 0 },
|
|
166
|
+
{ name: 'stock packs to .sgc and reloads cross-deployment', pass: packed === admitted && reloaded === admitted },
|
|
167
|
+
negControl ? { name: 'neg-control: a corrupted shape is rejected', pass: neg.rejected === true }
|
|
168
|
+
: { name: 'at least one class admitted', pass: admitted >= 1 }
|
|
169
|
+
];
|
|
170
|
+
const pass = gates.every(( g ) => g.pass );
|
|
171
|
+
|
|
172
|
+
const dossier = {
|
|
173
|
+
forge: 'skynet-sg-forge', generated: opts.now || null,
|
|
174
|
+
dataset: { name: opts.dataset || opts.name || 'corpus', classesAttempted: attempted },
|
|
175
|
+
model: { forge: (ask || (voters && voters.length)) ? (opts.modelName || 'embedded model') : 'gold-forge (deterministic)', reasoningBudget: 0, voters: voters ? voters.length : 0, calls: meter.calls },
|
|
176
|
+
classes: results.map(( v ) => ({ sig: v.sig, n: v.n, modelConsistent: v.modelConsistent, modelShape: v.modelShape,
|
|
177
|
+
goldShape: v.goldShape, crystallized: v.crystallized, crystalReason: v.crystalReason, goldMatch: v.goldMatch, admitted: v.admitted, reason: v.reason })),
|
|
178
|
+
summary: { attempted, admitted, falseAdmitted, modelCalls: meter.calls },
|
|
179
|
+
soundness: { negControl: neg, gates },
|
|
180
|
+
gates,
|
|
181
|
+
bundle: { name: bundle.manifest ? bundle.manifest.name : (opts.name || 'stock'), version: opts.version || '0.0.0',
|
|
182
|
+
methods: packed, sha256: crypto.createHash('sha256').update(JSON.stringify(bundle)).digest('hex') },
|
|
183
|
+
verdict: { pass }
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
return { results, bundle, dossier, verdict: { attempted, admitted, falseAdmitted, packed, reloaded, pass } };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Render the validation dossier as a human-readable markdown certificate (the deliverable a buyer reads). */
|
|
190
|
+
function dossierMarkdown( d ) {
|
|
191
|
+
const rows = d.classes.map(( c ) => '| `' + c.sig + '` | ' + c.n + ' | `' + c.modelShape + '` | `' + c.goldShape + '` | '
|
|
192
|
+
+ (c.crystallized ? 'yes' : 'no') + ' | ' + (c.admitted ? '✅ admitted' : '⛔ ' + c.reason) + ' |').join('\n');
|
|
193
|
+
return [
|
|
194
|
+
'# Validation dossier — ' + d.bundle.name + '@' + d.bundle.version,
|
|
195
|
+
'', 'Dataset: **' + d.dataset.name + '** · forge: **' + d.model.forge + '** · model calls: ' + d.model.calls,
|
|
196
|
+
'Bundle sha256: `' + d.bundle.sha256 + '`', '',
|
|
197
|
+
'| class | n | model shape | gold shape | crystallized | gold-gate |',
|
|
198
|
+
'|---|---|---|---|---|---|', rows, '',
|
|
199
|
+
'## Summary',
|
|
200
|
+
'- classes attempted: **' + d.summary.attempted + '**',
|
|
201
|
+
'- admitted (gold-verified): **' + d.summary.admitted + '**',
|
|
202
|
+
'- FALSE admitted (shape ≠ gold): **' + d.summary.falseAdmitted + '** ' + (d.summary.falseAdmitted === 0 ? '(the gate keeps the stock clean)' : '(!!)'),
|
|
203
|
+
'', '## Soundness gates',
|
|
204
|
+
d.gates.map(( g ) => '- ' + (g.pass ? '✅' : '❌') + ' ' + g.name).join('\n'), '',
|
|
205
|
+
'**Verdict: ' + (d.verdict.pass ? '✅ PASS' : '❌ FAIL') + '** — a gold-verified `.sgc` stock certified from the dataset oracle.'
|
|
206
|
+
].join('\n');
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
module.exports = { forgeStock, dossierMarkdown, makeDefaultDecompose, buildClassMethod };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Nathanael Braun
|
|
3
|
+
* @author : Nathanael BRAUN <pp9ping@gmail.com>
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
'use strict';
|
|
19
|
+
/**
|
|
20
|
+
* Combos — THIN, delivered assemblies over the shipped bricks (roadmap P1+, design doc
|
|
21
|
+
* doc/WIP/2026-07-05-combos-design.md). Each combo composes existing library bricks with the §4
|
|
22
|
+
* product posture (defaults.js) wired ON; it never adds new logic (a missing piece goes into the
|
|
23
|
+
* brick, not here) and the underlying bricks stay usable "à nu". Reached lazily via `Graph.combos`.
|
|
24
|
+
*
|
|
25
|
+
* createAppliance C1 — typed-QA appliance (intake→reason-loop→typed refusal→memo) [P1]
|
|
26
|
+
* createDurableRunner C2 — durable workflow executor [P4]
|
|
27
|
+
* createLearningLibrary C3 — learning method library [P2-P3]
|
|
28
|
+
* createSelfMod C5 — supervised self-modification (opt-in, guarded) [P3-bis]
|
|
29
|
+
* createProxyCache C6 — local-first proxy cache / distiller (cover→serve / miss→escalate+enrich)
|
|
30
|
+
*/
|
|
31
|
+
var defaults = require('./defaults.js');
|
|
32
|
+
var appliance = require('./appliance.js');
|
|
33
|
+
var learning = require('./learning-library.js');
|
|
34
|
+
var durable = require('./durable-runner.js');
|
|
35
|
+
var selfmod = require('./self-mod.js');
|
|
36
|
+
var proxy = require('./proxy-cache.js');
|
|
37
|
+
var planLoop = require('./plan-loop.js');
|
|
38
|
+
var mixture = require('./mixture-serve.js');
|
|
39
|
+
var critique = require('./critique.js');
|
|
40
|
+
|
|
41
|
+
module.exports = {
|
|
42
|
+
resolveComboDefaults : defaults.resolveComboDefaults,
|
|
43
|
+
buildAsk : defaults.buildAsk,
|
|
44
|
+
createAppliance : appliance.createAppliance, // C1 — typed-QA appliance
|
|
45
|
+
createLearningLibrary: learning.createLearningLibrary, // C3 (P3 COMPLETE) — ladder + crystallizeFrom + learning forge (adaptOrForgeAsync) + blame/credit + .sgc
|
|
46
|
+
createDurableRunner : durable.createDurableRunner, // C2 — durable workflow runner (compile/run/resume/audit)
|
|
47
|
+
|
|
48
|
+
// C4 — the reactive KG (the engine's ORIGINAL Use-1: rule-KG + concepts + stabilization + travel/geo).
|
|
49
|
+
// A trivial preset over Graph.fromDirs (builtins ON = geo + default llm) — the core + fromDirs stay the
|
|
50
|
+
// real entry, usable "à nu"; this just names the historical capability. Lazy-required (avoids a load-time
|
|
51
|
+
// cycle: lib/index.js → the Graph.combos getter → here → lib/index.js).
|
|
52
|
+
reactiveKG: function ( opts ) { return require('../index.js').fromDirs(Object.assign({ builtins: true }, opts || {})); },
|
|
53
|
+
|
|
54
|
+
// C5 — supervised self-modification (OPT-IN, guarded: author() requires a proposer; rollbackTo is the
|
|
55
|
+
// reversibility guarantee). Edits the LIVE rules — a host builds it explicitly, never a default.
|
|
56
|
+
createSelfMod: selfmod.createSelfMod,
|
|
57
|
+
|
|
58
|
+
// C6 — local-first proxy cache / distiller: serve a query from the minimal local stock when COVERED,
|
|
59
|
+
// escalate to the frontier model on a miss and enrich the stock in passing. The local side never
|
|
60
|
+
// fabricates (0 hallucination); a miss escalates (no false neg); anti-drift + .sgc on demand. A thin
|
|
61
|
+
// preset over createLearningLibrary (forge = the frontier ask).
|
|
62
|
+
createProxyCache: proxy.createProxyCache,
|
|
63
|
+
makeFrontierAsk : proxy.makeFrontierAsk, // wire a chat backend (embedded gguf / endpoint) as the frontier ground-truth
|
|
64
|
+
makeLocalCoverage: proxy.makeLocalCoverage, // wire a small local model as the semantic-key + coverage-check judge
|
|
65
|
+
makeTypedIntakeKey: proxy.makeTypedIntakeKey, // the à-nu typed Intake front door: prose → a DECLARED-vocab class key (distillation par-classe; untyped → exact-key, never a false class)
|
|
66
|
+
|
|
67
|
+
// C7 — the hierarchical PLAN LOOP: a task longer than the context is decomposed into typed leaves (each sees
|
|
68
|
+
// only a projected digest), served by the cost ladder (escalation LOAD-BEARING — kill-gate R1), driven to a
|
|
69
|
+
// BALANCED fixpoint (rebalance brick E2∘E1∘E3∘E4), and reassembled with checkCompose. decompose + serveLeaf
|
|
70
|
+
// are INJECTED (typed-loop + createProxyCache.solve in production) so the combo stays usable "à nu".
|
|
71
|
+
createPlanLoop: planLoop.createPlanLoop,
|
|
72
|
+
|
|
73
|
+
// C8 — the MIXTURE-RUNTIME server: a cheap local model ORIENTED by a forged certified stock, with
|
|
74
|
+
// escalation to a bigger tier. NOTE: the runtime CROSS-AGREEMENT trust tier is REFUTED at scale
|
|
75
|
+
// (precision 25-42 % at N=201 — keep fail-closed; see mixture-serve.js header erratum). What holds:
|
|
76
|
+
// orientation lifts the raw score; 0-false lives at ADMISSION (the forge), never as a runtime badge.
|
|
77
|
+
// small/big/proposeMenu/predict are INJECTED.
|
|
78
|
+
createMixtureServe: mixture.createMixtureServe,
|
|
79
|
+
makeSurfaceDispatch: mixture.makeSurfaceDispatch, // build proposeMenu+predict from a labelled anchor corpus (surface k-NN)
|
|
80
|
+
|
|
81
|
+
// C9 — the external CRITICAL MIND: declared viewpoints established through a witness gate over a
|
|
82
|
+
// statement pool, anchored generation of the MISSING theses (0-fabrication), a typed LEDGER as the
|
|
83
|
+
// deliverable, and a certification-aware verdict (mechanical only at the measured margin bound;
|
|
84
|
+
// below → counts + honest UNDECIDED). ask is INJECTED; frame statuses FREE/MATERIAL/DECLARED announced.
|
|
85
|
+
createCriticalMind: critique.createCriticalMind
|
|
86
|
+
};
|