omnius 1.0.476 → 1.0.477
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/dist/index.js +209 -105
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -576954,9 +576954,148 @@ var init_coherence_gate = __esm({
|
|
|
576954
576954
|
}
|
|
576955
576955
|
});
|
|
576956
576956
|
|
|
576957
|
+
// packages/orchestrator/dist/spec-gate.js
|
|
576958
|
+
function definitionCount(source, name10) {
|
|
576959
|
+
const n2 = escapeRegExp2(name10);
|
|
576960
|
+
const patterns = [
|
|
576961
|
+
new RegExp(`}\\s*${n2}\\s*;`, "g"),
|
|
576962
|
+
// } Name; (typedef struct/enum)
|
|
576963
|
+
new RegExp(`\\b(?:struct|class|enum|union)\\s+${n2}\\s*[:{]`, "g"),
|
|
576964
|
+
new RegExp(`\\b(?:interface|type|class|enum)\\s+${n2}\\b`, "g"),
|
|
576965
|
+
new RegExp(`\\btypedef\\s+[^;{]+\\b${n2}\\s*;`, "g")
|
|
576966
|
+
];
|
|
576967
|
+
let total = 0;
|
|
576968
|
+
for (const re of patterns)
|
|
576969
|
+
total += (source.match(re) ?? []).length;
|
|
576970
|
+
return total;
|
|
576971
|
+
}
|
|
576972
|
+
function hasField(source, symbol3, field) {
|
|
576973
|
+
const n2 = escapeRegExp2(symbol3);
|
|
576974
|
+
const block = source.match(new RegExp(`(?:struct|class|enum|union|interface)\\s+${n2}[^{]*{([\\s\\S]*?)}|{([\\s\\S]*?)}\\s*${n2}\\s*;`));
|
|
576975
|
+
const body = block?.[1] ?? block?.[2] ?? "";
|
|
576976
|
+
if (!body)
|
|
576977
|
+
return false;
|
|
576978
|
+
return new RegExp(`\\b${escapeRegExp2(field)}\\b`).test(body);
|
|
576979
|
+
}
|
|
576980
|
+
function hasSignature(source, fragment) {
|
|
576981
|
+
const norm = (s2) => s2.replace(/\s+/g, " ").trim();
|
|
576982
|
+
return norm(source).includes(norm(fragment));
|
|
576983
|
+
}
|
|
576984
|
+
function evaluateSpecGate(unit, contract, opts = {}) {
|
|
576985
|
+
const violations = [];
|
|
576986
|
+
const expected = new Set(opts.expectedSymbols ?? []);
|
|
576987
|
+
for (const spec of contract.symbols) {
|
|
576988
|
+
const count = definitionCount(unit.source, spec.name);
|
|
576989
|
+
const mustDefine = expected.has(spec.name);
|
|
576990
|
+
if (count === 0) {
|
|
576991
|
+
if (mustDefine) {
|
|
576992
|
+
violations.push({
|
|
576993
|
+
symbol: spec.name,
|
|
576994
|
+
kind: "missing_symbol",
|
|
576995
|
+
detail: `unit ${unit.path} must declare ${spec.kind} ${spec.name} but it is absent`
|
|
576996
|
+
});
|
|
576997
|
+
}
|
|
576998
|
+
continue;
|
|
576999
|
+
}
|
|
577000
|
+
if (count > 1) {
|
|
577001
|
+
violations.push({
|
|
577002
|
+
symbol: spec.name,
|
|
577003
|
+
kind: "duplicate_symbol",
|
|
577004
|
+
detail: `${spec.name} is defined ${count}× in ${unit.path}; the contract permits exactly one`
|
|
577005
|
+
});
|
|
577006
|
+
}
|
|
577007
|
+
for (const field of spec.fields ?? []) {
|
|
577008
|
+
if (!hasField(unit.source, spec.name, field)) {
|
|
577009
|
+
violations.push({
|
|
577010
|
+
symbol: spec.name,
|
|
577011
|
+
kind: "missing_field",
|
|
577012
|
+
detail: `${spec.name} is missing required member "${field}"`
|
|
577013
|
+
});
|
|
577014
|
+
}
|
|
577015
|
+
}
|
|
577016
|
+
if (spec.signature && !hasSignature(unit.source, spec.signature)) {
|
|
577017
|
+
violations.push({
|
|
577018
|
+
symbol: spec.name,
|
|
577019
|
+
kind: "signature_divergence",
|
|
577020
|
+
detail: `${spec.name} does not match the contract signature "${spec.signature}"`
|
|
577021
|
+
});
|
|
577022
|
+
}
|
|
577023
|
+
}
|
|
577024
|
+
const pass = violations.length === 0;
|
|
577025
|
+
return {
|
|
577026
|
+
pass,
|
|
577027
|
+
violations,
|
|
577028
|
+
summary: pass ? `spec gate PASS for ${unit.path}` : `spec gate FAIL for ${unit.path}: ${violations.length} violation(s) — ${violations.map((v) => `${v.symbol}:${v.kind}`).join(", ")}`
|
|
577029
|
+
};
|
|
577030
|
+
}
|
|
577031
|
+
function evaluateExecutorStep(input) {
|
|
577032
|
+
const spec = evaluateSpecGate(input.unit, input.contract, {
|
|
577033
|
+
expectedSymbols: input.expectedSymbols
|
|
577034
|
+
});
|
|
577035
|
+
if (input.convergenceTier === "abandon" || input.convergenceTier === "stalled") {
|
|
577036
|
+
return {
|
|
577037
|
+
decision: "replan",
|
|
577038
|
+
spec,
|
|
577039
|
+
reason: `convergence ${input.convergenceTier}: stop patching ${input.unit.path}; re-plan / regenerate from the locked contract`
|
|
577040
|
+
};
|
|
577041
|
+
}
|
|
577042
|
+
const boundaryOk = input.boundaryOk ?? true;
|
|
577043
|
+
if (spec.pass && boundaryOk) {
|
|
577044
|
+
return { decision: "accept", spec, reason: `${input.unit.path} accepted` };
|
|
577045
|
+
}
|
|
577046
|
+
return {
|
|
577047
|
+
decision: "reject_regenerate",
|
|
577048
|
+
spec,
|
|
577049
|
+
reason: spec.pass ? `${input.unit.path} passed the spec gate but failed to compile — regenerate` : spec.summary
|
|
577050
|
+
};
|
|
577051
|
+
}
|
|
577052
|
+
function escapeRegExp2(s2) {
|
|
577053
|
+
return s2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
577054
|
+
}
|
|
577055
|
+
var init_spec_gate = __esm({
|
|
577056
|
+
"packages/orchestrator/dist/spec-gate.js"() {
|
|
577057
|
+
"use strict";
|
|
577058
|
+
}
|
|
577059
|
+
});
|
|
577060
|
+
|
|
576957
577061
|
// packages/orchestrator/dist/longhaul-integration.js
|
|
576958
577062
|
import fs6 from "node:fs";
|
|
576959
577063
|
import path7 from "node:path";
|
|
577064
|
+
function extractSymbols3(content, language) {
|
|
577065
|
+
const out = [];
|
|
577066
|
+
const seen = /* @__PURE__ */ new Set();
|
|
577067
|
+
const push = (name10, kind, body) => {
|
|
577068
|
+
if (!name10 || seen.has(name10))
|
|
577069
|
+
return;
|
|
577070
|
+
seen.add(name10);
|
|
577071
|
+
const fields = body ? extractFields(body) : [];
|
|
577072
|
+
out.push({ name: name10, kind, ...fields.length ? { fields } : {} });
|
|
577073
|
+
};
|
|
577074
|
+
if (language === "cpp" || language === "unknown") {
|
|
577075
|
+
for (const m2 of content.matchAll(/\{([\s\S]*?)\}\s*([A-Za-z_]\w*)\s*;/g))
|
|
577076
|
+
push(m2[2], "struct", m2[1]);
|
|
577077
|
+
for (const m2 of content.matchAll(/\b(struct|class|enum|union)\s+([A-Za-z_]\w*)\s*(?::[^{]*)?\{([\s\S]*?)\}/g))
|
|
577078
|
+
push(m2[2], m2[1] === "union" ? "struct" : m2[1], m2[3]);
|
|
577079
|
+
}
|
|
577080
|
+
if (language === "typescript" || language === "unknown") {
|
|
577081
|
+
for (const m2 of content.matchAll(/\b(interface|class|enum)\s+([A-Za-z_]\w*)\s*(?:extends[^{]*)?\{([\s\S]*?)\}/g))
|
|
577082
|
+
push(m2[2], m2[1], m2[3]);
|
|
577083
|
+
for (const m2 of content.matchAll(/\btype\s+([A-Za-z_]\w*)\s*=/g))
|
|
577084
|
+
push(m2[1], "type");
|
|
577085
|
+
}
|
|
577086
|
+
return out;
|
|
577087
|
+
}
|
|
577088
|
+
function extractFields(body) {
|
|
577089
|
+
const fields = [];
|
|
577090
|
+
for (const line of body.split(/[;,\n]/)) {
|
|
577091
|
+
const ts = line.match(/^\s*([A-Za-z_]\w*)\s*[?:]/);
|
|
577092
|
+
const c9 = line.match(/([A-Za-z_]\w*)\s*$/);
|
|
577093
|
+
const name10 = ts ? ts[1] : c9 ? c9[1] : void 0;
|
|
577094
|
+
if (name10 && !FIELD_STOPWORDS.test(name10) && !fields.includes(name10))
|
|
577095
|
+
fields.push(name10);
|
|
577096
|
+
}
|
|
577097
|
+
return fields.slice(0, 24);
|
|
577098
|
+
}
|
|
576960
577099
|
function languageOf(p2) {
|
|
576961
577100
|
if (/\.(c|cc|cpp|cxx|h|hh|hpp|hxx|ino)$/i.test(p2))
|
|
576962
577101
|
return "cpp";
|
|
@@ -576964,12 +577103,13 @@ function languageOf(p2) {
|
|
|
576964
577103
|
return "typescript";
|
|
576965
577104
|
return "unknown";
|
|
576966
577105
|
}
|
|
576967
|
-
var JsonConvergenceStore, EDIT_TOOLS, LongHaulComponents;
|
|
577106
|
+
var JsonConvergenceStore, EDIT_TOOLS, LongHaulComponents, FIELD_STOPWORDS;
|
|
576968
577107
|
var init_longhaul_integration = __esm({
|
|
576969
577108
|
"packages/orchestrator/dist/longhaul-integration.js"() {
|
|
576970
577109
|
"use strict";
|
|
576971
577110
|
init_convergence_breaker();
|
|
576972
577111
|
init_coherence_gate();
|
|
577112
|
+
init_spec_gate();
|
|
576973
577113
|
init_dist5();
|
|
576974
577114
|
init_dist();
|
|
576975
577115
|
init_dist();
|
|
@@ -577019,6 +577159,13 @@ var init_longhaul_integration = __esm({
|
|
|
577019
577159
|
adaptiveEdit;
|
|
577020
577160
|
coherenceGate;
|
|
577021
577161
|
contextFolder;
|
|
577162
|
+
/**
|
|
577163
|
+
* WO-6: the locked contract — accumulated from COHERENT boundary units only.
|
|
577164
|
+
* A drifted/incoherent unit is never locked (WO-2 fires regenerate for it
|
|
577165
|
+
* instead), so this can only ever hold a self-consistent type spec. Gives the
|
|
577166
|
+
* breaker's "regenerate from the locked contract" guidance a real target.
|
|
577167
|
+
*/
|
|
577168
|
+
locked = /* @__PURE__ */ new Map();
|
|
577022
577169
|
constructor(options2) {
|
|
577023
577170
|
this.convergenceBreaker = new ConvergenceBreaker({
|
|
577024
577171
|
...options2.convergence,
|
|
@@ -577069,6 +577216,56 @@ var init_longhaul_integration = __esm({
|
|
|
577069
577216
|
return null;
|
|
577070
577217
|
}
|
|
577071
577218
|
}
|
|
577219
|
+
/**
|
|
577220
|
+
* WO-6: lock a boundary unit into the contract IFF it is coherent. A drifted
|
|
577221
|
+
* unit is never locked (WO-2 handles it), so the contract only ever holds
|
|
577222
|
+
* self-consistent symbol shapes. Returns the current contract size.
|
|
577223
|
+
*/
|
|
577224
|
+
maybeLockContract(input) {
|
|
577225
|
+
try {
|
|
577226
|
+
if (!input.content)
|
|
577227
|
+
return this.locked.size;
|
|
577228
|
+
const lang = input.language ?? languageOf(input.path);
|
|
577229
|
+
const verdict = this.coherenceGate.evaluate({
|
|
577230
|
+
source: input.content,
|
|
577231
|
+
language: lang
|
|
577232
|
+
});
|
|
577233
|
+
if (verdict.regime === "regenerate")
|
|
577234
|
+
return this.locked.size;
|
|
577235
|
+
for (const s2 of extractSymbols3(input.content, lang)) {
|
|
577236
|
+
if (!this.locked.has(s2.name))
|
|
577237
|
+
this.locked.set(s2.name, s2);
|
|
577238
|
+
}
|
|
577239
|
+
return this.locked.size;
|
|
577240
|
+
} catch {
|
|
577241
|
+
return this.locked.size;
|
|
577242
|
+
}
|
|
577243
|
+
}
|
|
577244
|
+
/** WO-6: the accumulated locked contract (for the breaker's regenerate target). */
|
|
577245
|
+
lockedContract() {
|
|
577246
|
+
return { symbols: [...this.locked.values()] };
|
|
577247
|
+
}
|
|
577248
|
+
/**
|
|
577249
|
+
* WO-6: gate an emitted boundary unit against the locked contract. Returns
|
|
577250
|
+
* guidance naming symbols that diverge from (or duplicate) a locked shape, so
|
|
577251
|
+
* "regenerate from the locked contract" has a concrete target. Only fires for
|
|
577252
|
+
* symbols already locked from earlier coherent code — never invents violations.
|
|
577253
|
+
*/
|
|
577254
|
+
specGateGuidance(input) {
|
|
577255
|
+
try {
|
|
577256
|
+
if (this.locked.size === 0 || !input.content)
|
|
577257
|
+
return null;
|
|
577258
|
+
const res = evaluateSpecGate({ path: input.path, source: input.content }, this.lockedContract());
|
|
577259
|
+
if (res.pass)
|
|
577260
|
+
return null;
|
|
577261
|
+
const relevant = res.violations.filter((v) => this.locked.has(v.symbol));
|
|
577262
|
+
if (relevant.length === 0)
|
|
577263
|
+
return null;
|
|
577264
|
+
return `${input.path} diverges from the LOCKED CONTRACT (established from earlier coherent code): ${relevant.map((v) => `${v.symbol} (${v.kind})`).join(", ")}. Do not redefine or reshape a locked symbol — reconcile this unit to the contract shape, or regenerate it against the contract.`;
|
|
577265
|
+
} catch {
|
|
577266
|
+
return null;
|
|
577267
|
+
}
|
|
577268
|
+
}
|
|
577072
577269
|
/**
|
|
577073
577270
|
* WO-1 (PyTy pattern): parse a failed build/verify command's own output for
|
|
577074
577271
|
* named STRUCTURAL contract violations (signature mismatch / duplicate
|
|
@@ -577142,6 +577339,7 @@ var init_longhaul_integration = __esm({
|
|
|
577142
577339
|
}
|
|
577143
577340
|
}
|
|
577144
577341
|
};
|
|
577342
|
+
FIELD_STOPWORDS = /^(struct|class|public|private|protected|const|unsigned|signed|static|typedef|enum|union|namespace|template|int|char|float|double|void|bool|long|short|size_t|uint\d+_t|int\d+_t|string|number|boolean|readonly)$/;
|
|
577145
577343
|
}
|
|
577146
577344
|
});
|
|
577147
577345
|
|
|
@@ -592538,6 +592736,16 @@ ${rec.guidance}` : rec.guidance;
|
|
|
592538
592736
|
|
|
592539
592737
|
${dir}` : dir;
|
|
592540
592738
|
}
|
|
592739
|
+
lh.maybeLockContract({ path: editPath, content: writtenContent });
|
|
592740
|
+
const specDir = lh.specGateGuidance({
|
|
592741
|
+
path: editPath,
|
|
592742
|
+
content: writtenContent
|
|
592743
|
+
});
|
|
592744
|
+
if (specDir) {
|
|
592745
|
+
runtimeSystemGuidance = runtimeSystemGuidance ? `${runtimeSystemGuidance}
|
|
592746
|
+
|
|
592747
|
+
${specDir}` : specDir;
|
|
592748
|
+
}
|
|
592541
592749
|
}
|
|
592542
592750
|
if (!result.success) {
|
|
592543
592751
|
const diag = lh.diagnosticGuidance(result.output ?? result.error ?? "");
|
|
@@ -606839,110 +607047,6 @@ var init_conversational_scrutiny = __esm({
|
|
|
606839
607047
|
}
|
|
606840
607048
|
});
|
|
606841
607049
|
|
|
606842
|
-
// packages/orchestrator/dist/spec-gate.js
|
|
606843
|
-
function definitionCount(source, name10) {
|
|
606844
|
-
const n2 = escapeRegExp2(name10);
|
|
606845
|
-
const patterns = [
|
|
606846
|
-
new RegExp(`}\\s*${n2}\\s*;`, "g"),
|
|
606847
|
-
// } Name; (typedef struct/enum)
|
|
606848
|
-
new RegExp(`\\b(?:struct|class|enum|union)\\s+${n2}\\s*[:{]`, "g"),
|
|
606849
|
-
new RegExp(`\\b(?:interface|type|class|enum)\\s+${n2}\\b`, "g"),
|
|
606850
|
-
new RegExp(`\\btypedef\\s+[^;{]+\\b${n2}\\s*;`, "g")
|
|
606851
|
-
];
|
|
606852
|
-
let total = 0;
|
|
606853
|
-
for (const re of patterns)
|
|
606854
|
-
total += (source.match(re) ?? []).length;
|
|
606855
|
-
return total;
|
|
606856
|
-
}
|
|
606857
|
-
function hasField(source, symbol3, field) {
|
|
606858
|
-
const n2 = escapeRegExp2(symbol3);
|
|
606859
|
-
const block = source.match(new RegExp(`(?:struct|class|enum|union|interface)\\s+${n2}[^{]*{([\\s\\S]*?)}|{([\\s\\S]*?)}\\s*${n2}\\s*;`));
|
|
606860
|
-
const body = block?.[1] ?? block?.[2] ?? "";
|
|
606861
|
-
if (!body)
|
|
606862
|
-
return false;
|
|
606863
|
-
return new RegExp(`\\b${escapeRegExp2(field)}\\b`).test(body);
|
|
606864
|
-
}
|
|
606865
|
-
function hasSignature(source, fragment) {
|
|
606866
|
-
const norm = (s2) => s2.replace(/\s+/g, " ").trim();
|
|
606867
|
-
return norm(source).includes(norm(fragment));
|
|
606868
|
-
}
|
|
606869
|
-
function evaluateSpecGate(unit, contract, opts = {}) {
|
|
606870
|
-
const violations = [];
|
|
606871
|
-
const expected = new Set(opts.expectedSymbols ?? []);
|
|
606872
|
-
for (const spec of contract.symbols) {
|
|
606873
|
-
const count = definitionCount(unit.source, spec.name);
|
|
606874
|
-
const mustDefine = expected.has(spec.name);
|
|
606875
|
-
if (count === 0) {
|
|
606876
|
-
if (mustDefine) {
|
|
606877
|
-
violations.push({
|
|
606878
|
-
symbol: spec.name,
|
|
606879
|
-
kind: "missing_symbol",
|
|
606880
|
-
detail: `unit ${unit.path} must declare ${spec.kind} ${spec.name} but it is absent`
|
|
606881
|
-
});
|
|
606882
|
-
}
|
|
606883
|
-
continue;
|
|
606884
|
-
}
|
|
606885
|
-
if (count > 1) {
|
|
606886
|
-
violations.push({
|
|
606887
|
-
symbol: spec.name,
|
|
606888
|
-
kind: "duplicate_symbol",
|
|
606889
|
-
detail: `${spec.name} is defined ${count}× in ${unit.path}; the contract permits exactly one`
|
|
606890
|
-
});
|
|
606891
|
-
}
|
|
606892
|
-
for (const field of spec.fields ?? []) {
|
|
606893
|
-
if (!hasField(unit.source, spec.name, field)) {
|
|
606894
|
-
violations.push({
|
|
606895
|
-
symbol: spec.name,
|
|
606896
|
-
kind: "missing_field",
|
|
606897
|
-
detail: `${spec.name} is missing required member "${field}"`
|
|
606898
|
-
});
|
|
606899
|
-
}
|
|
606900
|
-
}
|
|
606901
|
-
if (spec.signature && !hasSignature(unit.source, spec.signature)) {
|
|
606902
|
-
violations.push({
|
|
606903
|
-
symbol: spec.name,
|
|
606904
|
-
kind: "signature_divergence",
|
|
606905
|
-
detail: `${spec.name} does not match the contract signature "${spec.signature}"`
|
|
606906
|
-
});
|
|
606907
|
-
}
|
|
606908
|
-
}
|
|
606909
|
-
const pass = violations.length === 0;
|
|
606910
|
-
return {
|
|
606911
|
-
pass,
|
|
606912
|
-
violations,
|
|
606913
|
-
summary: pass ? `spec gate PASS for ${unit.path}` : `spec gate FAIL for ${unit.path}: ${violations.length} violation(s) — ${violations.map((v) => `${v.symbol}:${v.kind}`).join(", ")}`
|
|
606914
|
-
};
|
|
606915
|
-
}
|
|
606916
|
-
function evaluateExecutorStep(input) {
|
|
606917
|
-
const spec = evaluateSpecGate(input.unit, input.contract, {
|
|
606918
|
-
expectedSymbols: input.expectedSymbols
|
|
606919
|
-
});
|
|
606920
|
-
if (input.convergenceTier === "abandon" || input.convergenceTier === "stalled") {
|
|
606921
|
-
return {
|
|
606922
|
-
decision: "replan",
|
|
606923
|
-
spec,
|
|
606924
|
-
reason: `convergence ${input.convergenceTier}: stop patching ${input.unit.path}; re-plan / regenerate from the locked contract`
|
|
606925
|
-
};
|
|
606926
|
-
}
|
|
606927
|
-
const boundaryOk = input.boundaryOk ?? true;
|
|
606928
|
-
if (spec.pass && boundaryOk) {
|
|
606929
|
-
return { decision: "accept", spec, reason: `${input.unit.path} accepted` };
|
|
606930
|
-
}
|
|
606931
|
-
return {
|
|
606932
|
-
decision: "reject_regenerate",
|
|
606933
|
-
spec,
|
|
606934
|
-
reason: spec.pass ? `${input.unit.path} passed the spec gate but failed to compile — regenerate` : spec.summary
|
|
606935
|
-
};
|
|
606936
|
-
}
|
|
606937
|
-
function escapeRegExp2(s2) {
|
|
606938
|
-
return s2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
606939
|
-
}
|
|
606940
|
-
var init_spec_gate = __esm({
|
|
606941
|
-
"packages/orchestrator/dist/spec-gate.js"() {
|
|
606942
|
-
"use strict";
|
|
606943
|
-
}
|
|
606944
|
-
});
|
|
606945
|
-
|
|
606946
607050
|
// packages/orchestrator/dist/index.js
|
|
606947
607051
|
var dist_exports3 = {};
|
|
606948
607052
|
__export(dist_exports3, {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omnius",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.477",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "omnius",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.477",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"image-to-ascii"
|
|
12
12
|
],
|
package/package.json
CHANGED