omnius 1.0.475 → 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 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,90 @@ 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
+ }
577269
+ /**
577270
+ * WO-1 (PyTy pattern): parse a failed build/verify command's own output for
577271
+ * named STRUCTURAL contract violations (signature mismatch / duplicate
577272
+ * definition / unknown member or symbol) and return guidance naming the exact
577273
+ * drifted symbols, so the next edit targets the drift instead of guessing.
577274
+ * Uses the model's own compiler output — no separate compiler run. Generic
577275
+ * across gcc/clang/tsc; returns null when there's nothing structural.
577276
+ */
577277
+ diagnosticGuidance(output) {
577278
+ try {
577279
+ const diags = parseCompilerDiagnostics(String(output || ""));
577280
+ const byKind = /* @__PURE__ */ new Map();
577281
+ for (const d2 of diags) {
577282
+ if (d2.kind !== "signature_mismatch" && d2.kind !== "duplicate_definition" && d2.kind !== "unknown_member" && d2.kind !== "unknown_symbol")
577283
+ continue;
577284
+ if (!d2.symbol)
577285
+ continue;
577286
+ const arr = byKind.get(d2.kind) ?? [];
577287
+ if (!arr.includes(d2.symbol) && arr.length < 4)
577288
+ arr.push(d2.symbol);
577289
+ byKind.set(d2.kind, arr);
577290
+ }
577291
+ const parts = [];
577292
+ for (const [kind, syms] of byKind) {
577293
+ if (syms.length)
577294
+ parts.push(`${kind.replace(/_/g, " ")} → ${syms.join(", ")}`);
577295
+ }
577296
+ if (parts.length === 0)
577297
+ return null;
577298
+ return `Compiler reports structural contract violations — reconcile these EXACT symbols before editing unrelated files: ${parts.join("; ")}. A signature/definition mismatch means a declaration and its use disagree; fix them against the locked contract (or regenerate the unit) rather than patching around it.`;
577299
+ } catch {
577300
+ return null;
577301
+ }
577302
+ }
577072
577303
  /**
577073
577304
  * WO-5: decide whether to compact now (threshold AND rubric). The hard ceiling
577074
577305
  * guarantees a truly-full window still compacts.
@@ -577108,6 +577339,7 @@ var init_longhaul_integration = __esm({
577108
577339
  }
577109
577340
  }
577110
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)$/;
577111
577343
  }
577112
577344
  });
577113
577345
 
@@ -592504,6 +592736,24 @@ ${rec.guidance}` : rec.guidance;
592504
592736
 
592505
592737
  ${dir}` : dir;
592506
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
+ }
592749
+ }
592750
+ if (!result.success) {
592751
+ const diag = lh.diagnosticGuidance(result.output ?? result.error ?? "");
592752
+ if (diag) {
592753
+ runtimeSystemGuidance = runtimeSystemGuidance ? `${runtimeSystemGuidance}
592754
+
592755
+ ${diag}` : diag;
592756
+ }
592507
592757
  }
592508
592758
  }
592509
592759
  } catch {
@@ -606797,110 +607047,6 @@ var init_conversational_scrutiny = __esm({
606797
607047
  }
606798
607048
  });
606799
607049
 
606800
- // packages/orchestrator/dist/spec-gate.js
606801
- function definitionCount(source, name10) {
606802
- const n2 = escapeRegExp2(name10);
606803
- const patterns = [
606804
- new RegExp(`}\\s*${n2}\\s*;`, "g"),
606805
- // } Name; (typedef struct/enum)
606806
- new RegExp(`\\b(?:struct|class|enum|union)\\s+${n2}\\s*[:{]`, "g"),
606807
- new RegExp(`\\b(?:interface|type|class|enum)\\s+${n2}\\b`, "g"),
606808
- new RegExp(`\\btypedef\\s+[^;{]+\\b${n2}\\s*;`, "g")
606809
- ];
606810
- let total = 0;
606811
- for (const re of patterns)
606812
- total += (source.match(re) ?? []).length;
606813
- return total;
606814
- }
606815
- function hasField(source, symbol3, field) {
606816
- const n2 = escapeRegExp2(symbol3);
606817
- const block = source.match(new RegExp(`(?:struct|class|enum|union|interface)\\s+${n2}[^{]*{([\\s\\S]*?)}|{([\\s\\S]*?)}\\s*${n2}\\s*;`));
606818
- const body = block?.[1] ?? block?.[2] ?? "";
606819
- if (!body)
606820
- return false;
606821
- return new RegExp(`\\b${escapeRegExp2(field)}\\b`).test(body);
606822
- }
606823
- function hasSignature(source, fragment) {
606824
- const norm = (s2) => s2.replace(/\s+/g, " ").trim();
606825
- return norm(source).includes(norm(fragment));
606826
- }
606827
- function evaluateSpecGate(unit, contract, opts = {}) {
606828
- const violations = [];
606829
- const expected = new Set(opts.expectedSymbols ?? []);
606830
- for (const spec of contract.symbols) {
606831
- const count = definitionCount(unit.source, spec.name);
606832
- const mustDefine = expected.has(spec.name);
606833
- if (count === 0) {
606834
- if (mustDefine) {
606835
- violations.push({
606836
- symbol: spec.name,
606837
- kind: "missing_symbol",
606838
- detail: `unit ${unit.path} must declare ${spec.kind} ${spec.name} but it is absent`
606839
- });
606840
- }
606841
- continue;
606842
- }
606843
- if (count > 1) {
606844
- violations.push({
606845
- symbol: spec.name,
606846
- kind: "duplicate_symbol",
606847
- detail: `${spec.name} is defined ${count}× in ${unit.path}; the contract permits exactly one`
606848
- });
606849
- }
606850
- for (const field of spec.fields ?? []) {
606851
- if (!hasField(unit.source, spec.name, field)) {
606852
- violations.push({
606853
- symbol: spec.name,
606854
- kind: "missing_field",
606855
- detail: `${spec.name} is missing required member "${field}"`
606856
- });
606857
- }
606858
- }
606859
- if (spec.signature && !hasSignature(unit.source, spec.signature)) {
606860
- violations.push({
606861
- symbol: spec.name,
606862
- kind: "signature_divergence",
606863
- detail: `${spec.name} does not match the contract signature "${spec.signature}"`
606864
- });
606865
- }
606866
- }
606867
- const pass = violations.length === 0;
606868
- return {
606869
- pass,
606870
- violations,
606871
- 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(", ")}`
606872
- };
606873
- }
606874
- function evaluateExecutorStep(input) {
606875
- const spec = evaluateSpecGate(input.unit, input.contract, {
606876
- expectedSymbols: input.expectedSymbols
606877
- });
606878
- if (input.convergenceTier === "abandon" || input.convergenceTier === "stalled") {
606879
- return {
606880
- decision: "replan",
606881
- spec,
606882
- reason: `convergence ${input.convergenceTier}: stop patching ${input.unit.path}; re-plan / regenerate from the locked contract`
606883
- };
606884
- }
606885
- const boundaryOk = input.boundaryOk ?? true;
606886
- if (spec.pass && boundaryOk) {
606887
- return { decision: "accept", spec, reason: `${input.unit.path} accepted` };
606888
- }
606889
- return {
606890
- decision: "reject_regenerate",
606891
- spec,
606892
- reason: spec.pass ? `${input.unit.path} passed the spec gate but failed to compile — regenerate` : spec.summary
606893
- };
606894
- }
606895
- function escapeRegExp2(s2) {
606896
- return s2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
606897
- }
606898
- var init_spec_gate = __esm({
606899
- "packages/orchestrator/dist/spec-gate.js"() {
606900
- "use strict";
606901
- }
606902
- });
606903
-
606904
607050
  // packages/orchestrator/dist/index.js
606905
607051
  var dist_exports3 = {};
606906
607052
  __export(dist_exports3, {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "omnius",
3
- "version": "1.0.475",
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.475",
9
+ "version": "1.0.477",
10
10
  "bundleDependencies": [
11
11
  "image-to-ascii"
12
12
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omnius",
3
- "version": "1.0.475",
3
+ "version": "1.0.477",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",