omnius 1.0.591 → 1.0.592

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.
Files changed (131) hide show
  1. package/.aiwg/addons/omnius-docs/README.md +15 -1
  2. package/.aiwg/addons/omnius-docs/manifest.json +28 -68
  3. package/.aiwg/addons/omnius-docs/skills/agent-failure-recovery/SKILL.md +2 -1
  4. package/.aiwg/addons/omnius-docs/skills/browser-interaction-validation/SKILL.md +2 -1
  5. package/.aiwg/addons/omnius-docs/skills/evidence-directed-delivery/SKILL.md +2 -1
  6. package/.aiwg/addons/omnius-docs/skills/hardware-evidence-audit/SKILL.md +2 -1
  7. package/.aiwg/addons/omnius-docs/skills/omnius-docs/SKILL.md +17 -7
  8. package/.aiwg/addons/omnius-docs/skills/omnius-inference-docs/SKILL.md +27 -0
  9. package/.aiwg/addons/omnius-docs/skills/omnius-integration-docs/SKILL.md +21 -0
  10. package/.aiwg/addons/omnius-docs/skills/omnius-ops-docs/SKILL.md +2 -0
  11. package/.aiwg/addons/omnius-docs/skills/omnius-realtime-docs/SKILL.md +2 -0
  12. package/.aiwg/addons/omnius-docs/skills/omnius-sponsor-docs/SKILL.md +2 -0
  13. package/.aiwg/addons/omnius-docs/skills/omnius-telegram-docs/SKILL.md +2 -0
  14. package/.aiwg/addons/omnius-docs/skills/omnius-tools-docs/SKILL.md +23 -0
  15. package/.aiwg/addons/omnius-docs/skills/omnius-version-compatibility-docs/SKILL.md +23 -0
  16. package/.aiwg/addons/omnius-docs/skills/runtime-provenance-audit/SKILL.md +2 -1
  17. package/.aiwg/addons/omnius-docs/skills/secrets-and-config-audit/SKILL.md +2 -1
  18. package/.aiwg/addons/omnius-docs/skills/test-surface-audit/SKILL.md +2 -1
  19. package/.aiwg/addons/omnius-docs/skills/workspace-reality-audit/SKILL.md +2 -1
  20. package/.aiwg/addons/omnius-rest-docs/README.md +3 -0
  21. package/.aiwg/addons/omnius-rest-docs/manifest.json +27 -20
  22. package/.aiwg/addons/omnius-rest-docs/skills/omnius-rest-docs/SKILL.md +9 -5
  23. package/README.md +36 -0
  24. package/dist/discovery.d.ts +50 -0
  25. package/dist/index.js +5975 -4021
  26. package/dist/library.d.ts +7 -0
  27. package/dist/library.js +950 -0
  28. package/dist/postinstall-daemon.cjs +18 -0
  29. package/dist/providerRegistry.d.ts +80 -0
  30. package/dist/service-version.d.ts +35 -0
  31. package/docs/.vitepress/config.mts +8 -0
  32. package/docs/DISCOVERY.json +20224 -0
  33. package/docs/DISCOVERY.md +648 -0
  34. package/docs/HANDOFF-crl-encoder-decoder-fix.md +129 -0
  35. package/docs/agent-memory/INDEX.md +9 -4
  36. package/docs/agent-memory/index.md +7 -0
  37. package/docs/concept-relational-language.md +869 -0
  38. package/docs/context-management-medium-models-proposal.md +449 -0
  39. package/docs/dedup-false-positive-meta-analysis.md +96 -0
  40. package/docs/discovery/catalog-overrides.json +724 -0
  41. package/docs/duplicate-calls-root-cause-analysis.md +91 -0
  42. package/docs/duplicate-calls-root-cause-deep.md +155 -0
  43. package/docs/ephemeral-skill-pack-small-context.md +57 -0
  44. package/docs/explorations/context-window-todo-association.md +156 -0
  45. package/docs/explorations/todo-association-verify.json +30 -0
  46. package/docs/explorations/verification-ledger.json +45 -0
  47. package/docs/explorations/verify-todo-association.sh +30 -0
  48. package/docs/flowstate.md +806 -0
  49. package/docs/getting-started/install.md +24 -0
  50. package/docs/getting-started/model-providers.md +13 -0
  51. package/docs/guides/agent-integration.md +87 -0
  52. package/docs/guides/bring-your-own-inference.md +126 -0
  53. package/docs/guides/tools-and-web-search.md +95 -0
  54. package/docs/index.md +14 -0
  55. package/docs/longhaul-35b-workorders.md +496 -0
  56. package/docs/memory-integration-analysis.md +303 -0
  57. package/docs/model-capability-awareness-and-multimodal-memory-root-fix.md +799 -0
  58. package/docs/multimodal-identity-memory-implementation.md +76 -0
  59. package/docs/omnius-self-edit-eval-2026-06-10.md +169 -0
  60. package/docs/opencode-agentic-loop-comparison.md +290 -0
  61. package/docs/operations/security-and-remote-access.md +2 -2
  62. package/docs/operations/version-compatibility.md +63 -0
  63. package/docs/proposals/git-progress-tracking-strategy.md +289 -0
  64. package/docs/proposals/opencode-modules/backendAdapter.ts +443 -0
  65. package/docs/proposals/opencode-modules/childSession.ts +288 -0
  66. package/docs/proposals/opencode-modules/compactionAgent.ts +101 -0
  67. package/docs/proposals/opencode-modules/orchestrator.ts +387 -0
  68. package/docs/proposals/opencode-modules/runner.ts +258 -0
  69. package/docs/reference/auth-map.md +87 -196
  70. package/docs/reference/configuration.md +27 -0
  71. package/docs/reference/rest-api.md +7 -0
  72. package/docs/reference/slash-commands.md +125 -2
  73. package/docs/research/_archived/README.md +18 -0
  74. package/docs/research/_archived/context_window_attention_model.py +418 -0
  75. package/docs/research/_archived/context_window_attention_spec.md +55 -0
  76. package/docs/research/_archived/context_window_attention_weights.json +68 -0
  77. package/docs/research/k-splanifolds.pdf +0 -0
  78. package/docs/research/personality-verbosity-control.md +293 -0
  79. package/docs/rest/INDEX.md +7 -0
  80. package/docs/rest/QUICKREF.md +18 -0
  81. package/docs/rest/REST-DOCS-MANIFEST.json +1 -0
  82. package/docs/rest/auth-and-scopes.md +7 -1
  83. package/docs/rest/endpoints/discovery.md +44 -0
  84. package/docs/rest/endpoints/events.md +5 -0
  85. package/docs/rest/endpoints/tools.md +9 -0
  86. package/docs/reviews/adversary-system-review.md +42 -0
  87. package/docs/sana-and-video-generation-integration-plan.md +712 -0
  88. package/docs/session-diary-llm-training-analysis.md +218 -0
  89. package/docs/telegram-dmn-curiosity-outreach-scaffold.md +91 -0
  90. package/docs/telegram-mid-horizon-download-loop-handoff.md +468 -0
  91. package/docs/telegram-reflection-corpus-integration-plan.md +306 -0
  92. package/docs/telegram-unified-tooling-architecture.md +332 -0
  93. package/docs/threat-model.md +868 -0
  94. package/docs/trajectory-grounding.md +160 -0
  95. package/docs/voice-flow-architecture.md +489 -0
  96. package/docs/work-orders/WO-AM-GAPS.md +638 -0
  97. package/docs/work-orders/daemon-hud-ui-overhaul.md +82 -0
  98. package/docs/work-orders/hermes-architecture-deltas/01-public-scrutiny-provenance-control/INDEX.md +21 -0
  99. package/docs/work-orders/hermes-architecture-deltas/01-public-scrutiny-provenance-control/WORKORDER.md +225 -0
  100. package/docs/work-orders/hermes-architecture-deltas/02-context-engine-plugin-boundary/INDEX.md +20 -0
  101. package/docs/work-orders/hermes-architecture-deltas/02-context-engine-plugin-boundary/WORKORDER.md +198 -0
  102. package/docs/work-orders/hermes-architecture-deltas/03-typed-gateway-event-stream/INDEX.md +19 -0
  103. package/docs/work-orders/hermes-architecture-deltas/03-typed-gateway-event-stream/WORKORDER.md +172 -0
  104. package/docs/work-orders/hermes-architecture-deltas/04-task-local-gateway-context/INDEX.md +19 -0
  105. package/docs/work-orders/hermes-architecture-deltas/04-task-local-gateway-context/WORKORDER.md +169 -0
  106. package/docs/work-orders/hermes-architecture-deltas/05-process-lifecycle-monitoring-notifications/INDEX.md +22 -0
  107. package/docs/work-orders/hermes-architecture-deltas/05-process-lifecycle-monitoring-notifications/WORKORDER.md +189 -0
  108. package/docs/work-orders/hermes-architecture-deltas/06-vision-evidence-routing-ladder/INDEX.md +22 -0
  109. package/docs/work-orders/hermes-architecture-deltas/06-vision-evidence-routing-ladder/WORKORDER.md +199 -0
  110. package/docs/work-orders/hermes-architecture-deltas/07-durable-multi-agent-kanban/INDEX.md +20 -0
  111. package/docs/work-orders/hermes-architecture-deltas/07-durable-multi-agent-kanban/WORKORDER.md +174 -0
  112. package/docs/work-orders/hermes-architecture-deltas/08-completion-critic-reconciliation-ledger/INDEX.md +22 -0
  113. package/docs/work-orders/hermes-architecture-deltas/08-completion-critic-reconciliation-ledger/WORKORDER.md +226 -0
  114. package/docs/work-orders/hermes-architecture-deltas/INDEX.md +38 -0
  115. package/docs/work-orders/omnius-context-engineering-behavior-fixes.md +281 -0
  116. package/docs/work-orders/telegram-dropbear-context-rca-workorder.md +202 -0
  117. package/docs/work-orders/world-class-memory-compiler/README.md +162 -0
  118. package/docs/work-orders/world-class-memory-compiler/TRACKER.md +179 -0
  119. package/docs/work-orders/world-class-memory-compiler/WO-01-exact-request-budget.md +79 -0
  120. package/docs/work-orders/world-class-memory-compiler/WO-02-typed-memory-fabric.md +65 -0
  121. package/docs/work-orders/world-class-memory-compiler/WO-03-dependency-working-set.md +55 -0
  122. package/docs/work-orders/world-class-memory-compiler/WO-04-inference-memory-compiler.md +67 -0
  123. package/docs/work-orders/world-class-memory-compiler/WO-05-artifact-fidelity-materialization.md +72 -0
  124. package/docs/work-orders/world-class-memory-compiler/WO-06-temporal-hybrid-retrieval.md +49 -0
  125. package/docs/work-orders/world-class-memory-compiler/WO-07-evaluation-harness.md +45 -0
  126. package/docs/work-orders/world-class-memory-compiler/WO-08-rollout-legacy-removal.md +45 -0
  127. package/docs/x402-remote-inference-plan.md +323 -0
  128. package/npm-shrinkwrap.json +108 -117
  129. package/package.json +7 -6
  130. package/templates/AGENTS.md +6 -0
  131. package/templates/OMNIUS.md +20 -0
@@ -0,0 +1,496 @@
1
+ # Work Orders — Long-Haul Implementation on a 35B-Class Model
2
+
3
+ **Origin:** Root-cause review of the `myactuator` ESP32/PlatformIO session (35B `ornith-vision`)
4
+ plus a 2026-literature sweep of surprising remedies. See companion analysis in
5
+ `docs/context-management-medium-models-proposal.md` and
6
+ `docs/duplicate-calls-root-cause-analysis.md`.
7
+
8
+ ## Implementation status (Ralph loop + live wiring, 2026-07-04)
9
+
10
+ All 8 core modules implemented, unit-tested, and wired into `agenticRunner.ts` via a single
11
+ fault-tolerant integration bundle (`packages/orchestrator/src/longhaul-integration.ts`,
12
+ `LongHaulComponents`). Full monorepo `pnpm -r build` exits 0 (cli, apps/api, apps/worker included).
13
+
14
+ | WO | Module | Tests | Live in `agenticRunner` |
15
+ |----|--------|-------|--------------------------|
16
+ | WO-1 | `execution/src/boundary-verifier.ts` | 12 ✅ | **glue live**; compiler-runner dormant (needs repo profile — fires only when a runner is supplied) |
17
+ | WO-2 | `orchestrator/src/coherence-gate.ts` | 8 ✅ | **LIVE** — scans full-file writes to boundary files; regenerate guidance via `runtimeSystemGuidance` |
18
+ | WO-3 | `orchestrator/src/convergence-breaker.ts` | 9 ✅ | **LIVE** — wired into `focusSupervisor`; cross-session ledger at `.omnius/convergence-ledger.json` (gated on `disablePersistentMemory`) |
19
+ | WO-4 | `memory/src/context-folding.ts` | 5 ✅ | bundle instantiated; active-window rewrite dormant (needs context-frame-builder integration) |
20
+ | WO-5 | `memory/src/compaction-policy.ts` | 9 ✅ | decision/validate/SNR available via bundle; SNR already computed in the context dump; compaction firing unchanged (advisory) |
21
+ | WO-6 | `orchestrator/src/spec-gate.ts` | 8 ✅ | functions live; dormant until a planner supplies a `LockedContract` |
22
+ | WO-7 | `execution/src/harness-plan.ts` | 8 ✅ | plan+guard live; execution gated on the sandbox + security review |
23
+ | WO-8 | `execution/src/adaptive-edit-strategy.ts` | 7 ✅ | **LIVE** — tracks edit failures per file at the tool seam; rewrite guidance via `runtimeSystemGuidance` |
24
+ | WO-9 | `orchestrator/src/focusSupervisor.ts` (family-key normalization) | 17 ✅ | **LIVE** — generic action-identity canonicalizer collapses command-string/path/error variants so WO-3 actually escalates; `resolve()` on success. Found + fixed from live monitoring. |
25
+
26
+ **Cross-cutting genericity invariant:** every triage component is **toolchain-agnostic** and validated
27
+ across ecosystems — never tuned to a specific project or command (that would be reward-hacking the
28
+ demo, not hardening the harness). WO-1 parses gcc/clang **and** tsc; WO-2 scans C/C++ **and** TS;
29
+ WO-8 keys on file path (tool-neutral); WO-9's normalizer keys on shell *grammar* only, proven on
30
+ npm/cargo/pytest/make/go with pio as just one row.
31
+
32
+ **74 new unit tests, all green** (66 module + 8 integration-bundle). Wiring is additive and
33
+ try/catch-guarded so a long-haul component can never throw into the agentic loop; when
34
+ `disablePersistentMemory` is set, the convergence ledger stays in-memory (test-isolated).
35
+
36
+ **LIVE now** (behavior changes in the loop): WO-3 (convergence escalation past `forced_replan`),
37
+ WO-8 (edit→rewrite guidance), WO-2 (coherence→regenerate guidance on full-file writes).
38
+ **Dormant-by-necessity** (infra not present): WO-1 compiler runner, WO-4 active-window rewrite,
39
+ WO-6 locked contract, WO-7 execution. These are instantiated and one dependency away from firing;
40
+ each is documented above. Runtime behavior (as opposed to type/unit correctness) needs live-model
41
+ validation — the loop cannot be exercised end-to-end without a backend.
42
+
43
+ ## The failure signature these work orders attack
44
+
45
+ Observed in `~/Documents/Projects/myactuator/.omnius` telemetry:
46
+
47
+ | Signal | Value | Contract that fixes it |
48
+ |---|---|---|
49
+ | Successful builds, ever | **0** (9 FAILED markers) | WO-1, WO-2 |
50
+ | Duplicate-call dedup events | **15,342** | WO-3 |
51
+ | Lifetime tool failures | **15,505** | WO-3, WO-8 |
52
+ | `forced_replan` never escalating past itself | ∞ loop | WO-3 |
53
+ | Context frame @ 82k tokens, `signalToNoiseRatio: null` | bloat | WO-4, WO-5 |
54
+ | `file_edit` hash-mismatch retried 8× identically | thrash | WO-8 |
55
+ | Cross-file type drift (3× `MotorConfig`) | incoherent base | WO-1, WO-2, WO-6 |
56
+ | `z212/MCP2515` hallucinated package | ungrounded | WO-1, WO-7 |
57
+
58
+ The convergence-cliff literature (Yang et al., EMNLP 2025: rounds 1–2 capture ~75% of
59
+ reachable improvement; 96.5% of refinement sequences resolve in ≤3 iterations; skill loops
60
+ plateau by round 5) says a trajectory that has not converged in ~3 rounds essentially never
61
+ will — it needs a *different* trajectory, not more iterations. Every work order below is built
62
+ so the harness can detect "not converging" and switch strategy instead of brute-forcing.
63
+
64
+ ---
65
+
66
+ ## Verified integration map (anchors)
67
+
68
+ | Package | File | Role |
69
+ |---|---|---|
70
+ | orchestrator | `src/agenticRunner.ts` (33k LOC — **do not enlarge**; wire, don't grow) | main turn loop; calls supervisor, ledger, compaction, context dump |
71
+ | orchestrator | `src/focusSupervisor.ts` (1212 LOC) | failure-family counting → `forced_replan` directives |
72
+ | orchestrator | `src/dedup-gate.ts` | cross-turn duplicate-call gate |
73
+ | orchestrator | `src/completionLedger.ts`, `src/completion-evidence-gate.ts` | completion evidence |
74
+ | orchestrator | `src/resolution-memory.ts` | cross-session failure→fix learning |
75
+ | orchestrator | `src/contextWindowDump.ts` | telemetry frame dumps |
76
+ | memory | `src/compaction.ts` (155 LOC), `src/context-window.ts` (336 LOC) | context management |
77
+ | execution | `src/typecheckRunner.ts`, `src/buildRunner.ts`, `src/linterRunner.ts` | verifier primitives (already exist!) |
78
+ | execution | `src/tool-executor.ts`, `src/tools/file-edit.ts` (671 LOC), `src/tools/batch-edit.ts` | tool dispatch + edits |
79
+ | execution | `src/model-broker.ts` | model tier selection |
80
+ | backend-vllm | `src/routing.ts` | request→backend routing |
81
+
82
+ Persistence convention: session-scoped JSON under the project `.omnius/` dir, matching the
83
+ existing `error-patterns.json` / `resolution-memory.json` / handoffs pattern.
84
+
85
+ ---
86
+
87
+ ## WO-1 — In-Loop Structural Verifier (verify *during* generation, not after)
88
+
89
+ **Insight:** Decoding-Time Verification (arXiv 2605.17626) — interleave the compiler/type-checker
90
+ at structural boundaries; "early errors corrupt the autoregressive context." Qwen3-4B
91
+ 72.3%→82.0% (C→Rust) with in-loop verification.
92
+
93
+ **Root-cause tie:** `pal.cpp` was written whole against an imagined `MotorConfig`/`Command`
94
+ shape; the mismatch was only discovered after 300+ lines, then patched forever.
95
+
96
+ **Anchors:** new `packages/execution/src/boundary-verifier.ts`; reuses `typecheckRunner.ts`,
97
+ `buildRunner.ts`, `linterRunner.ts`. Integration point: `tool-executor.ts` post-write hook +
98
+ `agenticRunner.ts` turn epilogue.
99
+
100
+ **Design:** after any file-mutating tool that touches a "structural boundary" (a header/interface
101
+ file, a new function/struct/class), synchronously run the cheapest applicable verifier for that
102
+ language (tsc/clang/pio check) scoped to the changed unit. Emit a `BoundaryVerdict {ok, diagnostics[],
103
+ scope}` that the turn epilogue attaches to the frame. On failure, the next turn is gated with the
104
+ exact diagnostics as authoritative evidence and forbidden from proceeding to unrelated files.
105
+
106
+ **Acceptance (measurable):**
107
+ - After editing a header, a signature-mismatch is reported within the same turn (not N turns later).
108
+ - `boundary-verifier` unit tests: given a fixture with a header/impl drift, verdict.ok === false and
109
+ diagnostics name the drifted symbol.
110
+ - Regression harness: replaying the myactuator `pal.cpp` edit produces a boundary block before the
111
+ next unrelated file edit.
112
+
113
+ **Telemetry:** `boundaryVerifier: { runs, blocked, avgMs }` in the context dump.
114
+
115
+ **Depends on:** none. **Status:** SPEC (verifier primitives already exist → medium effort).
116
+
117
+ ---
118
+
119
+ ## WO-2 — Contract-Coherence Regime Switch (patch ⇄ regenerate)
120
+
121
+ **Insight:** Patch repair beats regeneration *when invariants hold*; below a coherence floor you
122
+ must regenerate the type layer wholesale (Solvita 2605.15301; Beyond-Accuracy 2511.11012). myactuator
123
+ was below the floor (3× `MotorConfig`) so every patch was whack-a-mole.
124
+
125
+ **Anchors:** new `packages/orchestrator/src/coherence-gate.ts`. Consumes WO-1 verifier diagnostics +
126
+ a lightweight structural scan (duplicate type/symbol defs, header/impl signature-match ratio).
127
+ Integration point: `agenticRunner.ts` before choosing edit strategy; emits a new
128
+ `FocusRequiredNextAction: "regenerate_from_spec"` (enum widened here).
129
+
130
+ **Design:** compute `coherenceScore ∈ [0,1]` from: (a) duplicate top-level symbol definitions,
131
+ (b) fraction of impl methods whose signature matches a declaration, (c) unresolved-symbol density.
132
+ Below `regenThreshold` (default 0.6) the gate forces a **full-file / whole-module regeneration from
133
+ the locked contract (WO-6)** and forbids incremental `file_edit` on the incoherent unit until it
134
+ compiles once. Above threshold, patch mode as today.
135
+
136
+ **Acceptance:** unit test on a 3×-duplicate-typedef fixture → score < 0.6 → verdict `regenerate`;
137
+ a coherent fixture → `patch`. Integration: myactuator `types.h` replay → `regenerate`.
138
+
139
+ **Depends on:** WO-1 (diagnostics), WO-6 (locked contract as regeneration source). **Status:** SPEC.
140
+
141
+ ---
142
+
143
+ ## WO-3 — Convergence Circuit-Breaker (the hard cliff) — **IMPLEMENTED THIS PASS**
144
+
145
+ **Insight:** Rounds 1–2 = ~75% of reachable improvement; ≤3 iterations resolves 96.5%; plateau by
146
+ round 5 (Yang et al. EMNLP 2025; EvoSkills 2604.01687; Practical Limits 2605.01471). More iterations
147
+ on the same trajectory ≈ zero marginal value.
148
+
149
+ **Root-cause tie:** `focusSupervisor` escalates to `forced_replan` at family-count ≥ 2 but **never
150
+ escalates further**, and its `failureFamilies` map is **session-local** — a resumed session re-earns
151
+ the count from zero. The myactuator `pio run` family repeated across 5 sessions with no global
152
+ "abandon this trajectory."
153
+
154
+ **Anchors:** new `packages/orchestrator/src/convergence-breaker.ts` (+ test); minimal additive hook in
155
+ `focusSupervisor.ts observeToolResult`; exported from `src/index.ts`. Cross-session store:
156
+ `.omnius/convergence-ledger.json` (matches `error-patterns.json` convention).
157
+
158
+ **Design:** pure `ConvergenceBreaker` observes the same failure-family key focusSupervisor already
159
+ computes. `totalRounds = sessionCount + priorSessionCarry(family)`. A *productive mutation* since the
160
+ last failure decays the carry (progress resets the cliff). Tiers by `totalRounds`:
161
+ `healthy < 2 ≤ converging_warn < 3 ≤ stalled < 5 ≤ abandon`. `stalled` → directive to **stop
162
+ patching, regenerate the incoherent layer** (`run_verification`/replan); `abandon` → escalate
163
+ focusSupervisor to `terminal_incomplete` + `report_incomplete` with a regeneration instruction,
164
+ instead of emitting `forced_replan` forever. Cross-session carry is loaded on construction and
165
+ persisted on each trip so a resumed session trips immediately.
166
+
167
+ **Acceptance (measurable):**
168
+ - Same family observed 5× (across a simulated session boundary) → verdict `abandon`, tripped === true.
169
+ - A productive mutation between failures decays the count (no false abandon).
170
+ - focusSupervisor with a breaker injected escalates to `terminal_incomplete` on abandon; **without** a
171
+ breaker, behavior is byte-identical to today (existing `focusSupervisor.test.ts` stays green).
172
+ - Cross-session: store round-trips the carry; a fresh breaker seeded from the store trips on round 1.
173
+
174
+ **Telemetry:** `convergence: { family, totalRounds, tier }` in the context dump + a
175
+ `.omnius/convergence-ledger.json` audit trail.
176
+
177
+ **Depends on:** none. **Status:** ✅ IMPLEMENTED (module + unit tests + additive focusSupervisor hook).
178
+
179
+ ---
180
+
181
+ ## WO-4 — Context-Folding (10× smaller active context)
182
+
183
+ **Insight:** Context-Folding (arXiv 2510.11967) — branch into a subtask sub-trajectory, then *fold*
184
+ it to a one-line outcome; active context up to 10× smaller, beats summarization.
185
+
186
+ **Root-cause tie:** a single 380 KB myactuator frame contained "duplicate" ×276, "error" ×423 —
187
+ finished-subtask noise crowding out the live type contract.
188
+
189
+ **Anchors:** new `packages/memory/src/context-folding.ts`; integrates with `compaction.ts` +
190
+ `context-window.ts`; frame assembly in `agenticRunner.ts` (`upsertContextFrame`).
191
+
192
+ **Design:** a `FoldableSegment` boundary opened when the agent starts a named subtask (e.g. "make
193
+ cem_driver.cpp compile") and closed on its boundary-verifier success (WO-1). On close, replace the
194
+ segment's turns with `folded: { subtask, outcome, artifacts[], verifier: pass }`. Folded segments are
195
+ excluded from the active window but retained on disk for audit and re-expansion.
196
+
197
+ **Acceptance:** a run that folds 3 completed subtasks shows active-window tokens drop ≥5× vs unfolded;
198
+ folded outcomes remain queryable. **Depends on:** WO-1 (fold trigger). **Status:** SPEC.
199
+
200
+ ---
201
+
202
+ ## WO-5 — Decision-Based Compaction + Validation
203
+
204
+ **Insight:** Self-Compacting agents (arXiv 2606.23525) — model fires compaction by rubric (fire when
205
+ subtask resolved/converging, **hold when mid-derivation/stuck**), +18.1 pts at 30–70% lower cost.
206
+ Slipstream (2605.08580) — trajectory-grounded validation that compaction didn't drop architectural
207
+ decisions.
208
+
209
+ **Root-cause tie:** myactuator compaction fired on a token threshold and `signalToNoiseRatio` was
210
+ `null` (never computed); the locked type contract was at risk each compaction.
211
+
212
+ **Anchors:** extend `packages/memory/src/compaction.ts` with a `shouldCompact(rubric)` decision fn;
213
+ new `packages/memory/src/compaction-validator.ts` (Slipstream check); pin the locked contract into the
214
+ system-prompt region so it survives every compaction. Integration: `agenticRunner.ts` compaction gate
215
+ (currently threshold-only at `compactionThreshold`/`compactionPercent`).
216
+
217
+ **Design:** replace pure-threshold firing with `threshold AND rubric`: hold if a boundary-verifier is
218
+ mid-run or the last N turns are a single unresolved derivation; fire when the last subtask verified or
219
+ the trajectory is converging. Post-compaction, the validator asserts every pinned invariant (locked
220
+ contract symbols, open bugs, next-action) still appears; if not, it rolls back and keeps the pre-compaction frame.
221
+
222
+ **Acceptance:** compute and emit `signalToNoiseRatio` (no longer null); validator blocks a compaction
223
+ that drops a pinned symbol in a fixture. **Depends on:** WO-6 (what to pin). **Status:** SPEC.
224
+
225
+ ---
226
+
227
+ ## WO-6 — Strong-Planner / Weak-Executor + Spec-as-Executable-Gate
228
+
229
+ **Insight:** Scaffolding out-levers model size ("Sonnet+plan > Opus+vibe"); planner-executor with a
230
+ strong planner and cheap executor + re-plan on failure; SDD specs *execute as validation gates*.
231
+
232
+ **Root-cause tie:** the 35B decided the type architecture across 40 files; the excellent
233
+ `contracts/` docs were never enforced as gates → definitions diverged file-by-file.
234
+
235
+ **Anchors:** new `packages/orchestrator/src/plan-executor.ts` + `src/spec-gate.ts`; model tiering via
236
+ `execution/src/model-broker.ts` + `backend-vllm/src/routing.ts`. Integration: `agenticRunner.ts` run
237
+ setup (a plan phase precedes the execute loop).
238
+
239
+ **Design:** a one-time plan phase (larger tier via broker, or the current session) emits a locked
240
+ **type/interface contract** (structs, signatures, file manifest) derived from the project's spec docs.
241
+ The executor loop (35B) fills one manifest unit at a time; every unit must pass its `spec-gate`
242
+ (declared symbols present, signatures match the contract) — a hard gate, not advice. Re-plan triggers
243
+ on WO-3 `stalled`.
244
+
245
+ **Acceptance:** spec-gate rejects a unit whose emitted `MotorConfig` diverges from the contract;
246
+ the locked contract is the single source WO-2 regenerates from. **Depends on:** WO-2, WO-3.
247
+ **Status:** SPEC.
248
+
249
+ ---
250
+
251
+ ## WO-7 — Code-as-Harness (env manipulation via code, fewer brittle tool-args)
252
+
253
+ **Insight:** Code-as-Agent-Harness (arXiv 2605.18747) — the agent manipulates its environment by
254
+ writing code rather than emitting brittle structured tool calls.
255
+
256
+ **Root-cause tie:** a large share of the 15,505 failures were malformed tool arguments
257
+ (obsolete metadata envelopes, a `ce_m_driver.h` typo, hash mismatches).
258
+
259
+ **Anchors:** new `packages/execution/src/tools/harness-exec.ts` (sandboxed, allow-listed); reuses the
260
+ existing `code-sandbox.ts` tool. Integration: register in the tool registry; route multi-step file/env
261
+ ops through a single code cell.
262
+
263
+ **Design:** expose a constrained code channel (fs + shell within the project root, no network) so a
264
+ batch of edits/reads/moves is one verified code cell with real error messages, instead of a dozen
265
+ brittle `file_edit` calls each subject to the hash/`old_string` contract.
266
+
267
+ **Acceptance:** a 5-file rename that today needs 5 hash-guarded edits completes as one code cell with a
268
+ single pass/fail. **Depends on:** existing `code-sandbox.ts`. **Status:** SPEC (security review required
269
+ per `browser-control-safety`/`token-security` conventions).
270
+
271
+ ---
272
+
273
+ ## WO-8 — Adaptive Edit Strategy (HarnessBridge-lite: auto-switch edit→rewrite)
274
+
275
+ **Insight:** HarnessBridge (arXiv 2606.12882) — a learnable controller for the harness↔model
276
+ interface. The harness should *adapt* rather than let a weak model bang on a brittle primitive.
277
+
278
+ **Root-cause tie:** `file_edit expected_hash=…` rejected and retried **8× identically**; 965
279
+ `file_edit:not_found`.
280
+
281
+ **Anchors:** new `packages/execution/src/adaptive-edit-strategy.ts` (+ test); minimal hook in
282
+ `tool-executor.ts` / `tools/file-edit.ts`.
283
+
284
+ **Design:** per-file counter of consecutive `file_edit` failures (hash-mismatch / old_string-not-found
285
+ / not_found). After `switchThreshold` (default 2) failures on a file, the strategy recommends
286
+ switching that file to a **full-file rewrite** (`file_write`) seeded with the current file contents,
287
+ and the executor surfaces that as the required recovery. Counter resets on a successful mutation.
288
+
289
+ **Acceptance:** 2 hash-mismatch failures on one file → strategy returns `mode: "rewrite"` with the
290
+ current contents as the base; a success resets the counter; unit tests cover mismatch, not-found, and
291
+ reset. **Depends on:** none. **Status:** SPEC (small, self-contained — next after WO-3).
292
+
293
+ ---
294
+
295
+ ## WO-9 — Convergence Family Normalization & Correctness (from live monitoring)
296
+
297
+ **Origin:** Live 35B run on `myactuator` (2026-07-04, turn 14–16). WO-3 was confirmed firing —
298
+ `.omnius/convergence-ledger.json` was created and tracking the `pio run` failure — **but the breaker
299
+ never escalated** because the model re-ran the same logical action with trivially different command
300
+ strings, so the ledger fragmented into 3 families each stuck at `rounds=1`:
301
+
302
+ ```
303
+ rounds=1 shell:cd firmware/esp32 && pio run 2>&1 | tail -100 :tool_failed
304
+ rounds=1 shell:cd firmware/esp32 && pio run 2>&1 :tool_failed
305
+ rounds=1 shell:cd /home/roko/.../firmware/esp32 && pio run :tool_failed
306
+ ```
307
+
308
+ None reaches `stalled`(3)/`abandon`(5). The 35B slips the guard by varying the command — the same
309
+ evasion behind the original 15k-thrash. (Positive: context stayed ~1.2–1.4k tokens, no bloat.)
310
+
311
+ ### Root cause (two fragmentation axes) — anchors
312
+
313
+ 1. **Command-string axis.** `actionFamily(toolName, args)` in
314
+ `packages/orchestrator/src/focusSupervisor.ts` keys a shell family on the raw command:
315
+ ```ts
316
+ if (toolName === "shell") {
317
+ const command = args?.["command"] ?? args?.["cmd"] ?? "";
318
+ return `${toolName}:${compactTarget(String(command ?? "") || "no-command", 120)}`;
319
+ }
320
+ ```
321
+ `compactTarget()` only collapses whitespace + truncates — no semantic normalization. So
322
+ `pio run`, `pio run 2>&1`, and `pio run | tail -100` are three families.
323
+
324
+ 2. **Error-class axis.** `failureFamilyKey()` = `` `${actionFamily(...)}:${errorClass}` ``. The
325
+ breaker is fed this (`family`, with errorClass) at `focusSupervisor.ts` ~line 662. A command that
326
+ fails with a different `errorClass` each attempt fragments a second way. Convergence should track
327
+ *"stuck repeating this action,"* independent of which error each attempt throws.
328
+
329
+ 3. **No `resolve()` on success.** The breaker never clears a family when the underlying work
330
+ succeeds (the `resolve()` API exists in `convergence-breaker.ts` but is unwired). A family that
331
+ accumulates rounds then finally passes could still carry stale rounds and falsely trip later.
332
+
333
+ ### Genericity & anti-reward-hacking guardrails (PRIMARY constraint)
334
+
335
+ The `pio run` case is the *symptom that surfaced the gap*, **not** the thing to fix. The normalizer
336
+ MUST be a generic **action-identity canonicalizer** that reduces any semantically-equivalent shell
337
+ invocation to the same key across **any** toolchain — never a PlatformIO/`pio`-aware special case.
338
+ Tuning to the demo command would be reward-hacking (making this run look good instead of making the
339
+ harness robust) and is explicitly forbidden.
340
+
341
+ Rules:
342
+
343
+ 1. **No tool-name allow-lists / no project-specific patterns.** The normalizer never matches `pio`,
344
+ `platformio`, `firmware/esp32`, or any literal from this repo. It operates only on *shell
345
+ grammar* (pipes, redirections, path syntax, whitespace) — decoration that is semantically neutral
346
+ for *every* command.
347
+ 2. **Strip only meaning-preserving decoration.** Remove trailing display filters (`| tail`, `| head`,
348
+ `| less`, `| cat`, `| grep` used for viewing), stream redirections (`2>&1`, `>/dev/null`,
349
+ `2>/dev/null`), and normalize absolute↔relative path *form* (via the run's cwd, not a hard-coded
350
+ root). Never remove flags/arguments that change *what the command does*.
351
+ 3. **Conservative — prefer false-split over false-merge.** Collapsing two genuinely different
352
+ commands into one family causes *premature abandonment* of distinct work — worse than leaving
353
+ them split. When a token's semantic effect is uncertain, keep it. `npm test` and
354
+ `npm test -- --grep auth` must stay **distinct**; `cargo build -e x` and `cargo build -e y` must
355
+ stay **distinct**.
356
+ 4. **Validated across ecosystems, not one.** Correctness is demonstrated on npm, cargo, pytest, make,
357
+ go, and generic shell — with `pio` as merely one of several rows — so the rules cannot silently
358
+ overfit. The same discipline applies to the other triage components (WO-1 parses gcc/clang **and**
359
+ tsc; WO-2 scans C/C++ **and** TS; WO-8 keys on file path, tool-agnostic).
360
+
361
+ ### Design
362
+
363
+ - **9a — Generic action-identity canonicalizer** for family keying. New
364
+ `normalizeShellForFamily(cmd, cwd?)`: collapse whitespace (reuse the pattern from
365
+ `packages/execution/src/tools/shell.ts:899 normalizeCommand`), strip trailing *display* pipelines
366
+ and stream redirections, and canonicalize path *form* against the run's cwd (relative↔absolute) —
367
+ all grammar-level, tool-agnostic. Semantically-meaningful arguments are preserved verbatim.
368
+ Examples (each collapses to one family; none is pio-specific):
369
+ `npm test 2>&1 | tail -50` ≡ `npm test`; `cargo build 2>&1` ≡ `cargo build`;
370
+ `cd <abs>/svc && pytest -q | tee log` ≡ `cd svc && pytest -q | tee log` (only the `cd` path form
371
+ is normalized; `-q` and the writing `tee` are preserved). Counter-examples that must **stay
372
+ distinct:** `npm test` vs `npm run test:e2e`; `make` vs `make clean`; `go build ./a` vs
373
+ `go build ./b`.
374
+ - **9b — Coarser convergence key.** Feed the breaker the normalized **action** family
375
+ (`actionFamily(...)` alone, no `:errorClass`) rather than `failureFamilyKey`. Keeps the focus
376
+ `failureFamilies` map as-is (error-specific); only the convergence trajectory is coarsened, so
377
+ error-message churn on the same action doesn't fragment it either.
378
+ - **9c — Wire `resolve()` on verified success.** When a verification-like shell command succeeds,
379
+ clear that action family's carry (generic: any command that previously failed and now succeeds).
380
+
381
+ ### Full integration modification points (exact)
382
+
383
+ | # | File · anchor | Change |
384
+ |---|---------------|--------|
385
+ | 1 | `orchestrator/src/focusSupervisor.ts` · `actionFamily()` shell branch | wrap `command` in `normalizeShellForFamily(...)` before `compactTarget` |
386
+ | 2 | `orchestrator/src/focusSupervisor.ts` · new top-level helper near `actionFamily`/`compactTarget` | add `normalizeShellForFamily(cmd: string): string` (9a) |
387
+ | 3 | `orchestrator/src/focusSupervisor.ts` · breaker wiring (~L662) | change `family` → `convergenceFamily` where `const convergenceFamily = actionFamily(input.toolName, input.args)` (9b) |
388
+ | 4 | `orchestrator/src/focusSupervisor.ts` · `observeToolResult` shell-success branch (`if (input.toolName === "shell" && input.success)`) | add `this.convergenceBreaker?.resolve(actionFamily(input.toolName, input.args))` (9c) |
389
+ | 5 | `orchestrator/src/convergence-breaker.ts` | no change required (keys on `obs.family`); optionally accept a `normalizeFamily` fn for defense-in-depth |
390
+ | 6 | `orchestrator/tests/focusSupervisor.test.ts:1104` | update the `forbiddenActionFamilies` expected string if the normalized shell family differs (**test modification point**) |
391
+ | 7 | `orchestrator/tests/*` (new) | add: `normalizeShellForFamily` collapses the 3 pio variants; breaker escalates `stalled`→`abandon` after 3/5 *varied* pio-run failures; `resolve()` clears on success |
392
+ | 8 | `orchestrator/src/longhaul-integration.test.ts` (new case) | end-to-end: 3 varied `pio run` failures through a `FocusSupervisor` → terminal escalation |
393
+
394
+ ### Acceptance (measurable — proven generic, parameterized over ecosystems)
395
+
396
+ - **Genericity table** (drives a parameterized test — pio is one row of many): for each
397
+ `{ base, variants[] }` below, all variants collapse to one family:
398
+ | base | variants that must MERGE |
399
+ |------|--------------------------|
400
+ | `npm test` | `npm test 2>&1`, `npm test \| tail -50` |
401
+ | `cargo build` | `cargo build 2>&1 \| head`, `cargo build 2>/dev/null` |
402
+ | `cd firmware && pio run` (path FORM only) | `cd <abs>/firmware && pio run 2>&1`, `cd <abs>/firmware && pio run \| tail` |
403
+ | `pytest -q` | `pytest -q 2>&1`, `pytest -q \| tail -80` |
404
+ | `make` | `make 2>/dev/null`, `cd <abs> && make` |
405
+ | `go test ./...` | `go test ./... 2>&1 \| tail` |
406
+ | `pio run` | `pio run 2>&1`, `cd <abs>/firmware/esp32 && pio run \| tail -100` |
407
+ - **Non-merge table** (must stay DISTINCT — proves conservatism): `npm test` ≠ `npm run test:e2e`;
408
+ `make` ≠ `make clean`; `go build ./a` ≠ `go build ./b`; `cargo build -e x` ≠ `cargo build -e y`.
409
+ - For any base, three *varied* failures → one family, `rounds` 3 → `stalled`; a 5th → `abandon` →
410
+ `focusSupervisor` state `terminal_incomplete` (validated with a non-pio base, e.g. `npm test`).
411
+ - A successful verification command clears the family (`resolve()`), so a later unrelated failure
412
+ starts at round 1.
413
+ - `focusSupervisor.test.ts` updated and green; full orchestrator suite has no new regressions;
414
+ `pnpm -r build` exits 0.
415
+
416
+ ### Peripheral gaps folded in / noted
417
+
418
+ - **WO-8 edit families** key on file path (`adaptive-edit-strategy.ts`) — stable, low fragmentation
419
+ risk; verify `batch_edit`/`file_patch` path extraction is consistent (`realMutationPaths[0]`).
420
+ - **WO-1 boundary compiler runner** remains dormant (needs a repo profile / runner) — separate,
421
+ already tracked in the status table.
422
+
423
+ **Status:** ✅ IMPLEMENTED + LIVE-WIRED. `normalizeShellForFamily()` +
424
+ `actionFamily(…, cwd)` + coarse convergence key (`convergenceFamilyCounts`) + `resolve()` on shell
425
+ success, all in `focusSupervisor.ts`; cwd threaded from `agenticRunner`. 17 new WO-9 tests
426
+ (cross-ecosystem merge/non-merge, path-form, escalation on varied commands, resolve) + updated the
427
+ one focusSupervisor test that encoded the old pager-evasion behavior. Found during live monitoring;
428
+ fixes the 5-families-at-rounds-1 fragmentation.
429
+
430
+ ## Root refinement — progress = verification delta, not edit activity (from live monitoring + literature)
431
+
432
+ **Observed live (post-WO-9):** the breaker never escalated the myactuator *edit* loop — the model
433
+ edited ~1000× without ever compiling, and WO-3/WO-9's progress-decay treated every mutation as
434
+ "advancing," so a *futile* edit loop looked like progress forever.
435
+
436
+ **Literature confirms this is the crux.** *Coherence Collapse* (arXiv 2603.24631): agents reach/near
437
+ correct code then degrade it; the fix is quality-tracked verification, not edit counting. RLCSF /
438
+ Lanser-CLI (arXiv 2510.22907) and PyTy: "coding agents fail when text-level guesses outrun program
439
+ facts" — progress must be measured by the **compiler/verification signal**, not by edits.
440
+
441
+ **Root fix (implemented):** the convergence breaker's decay is now driven by a **verification signal
442
+ delta** — `failureSignal` (a generic error count) must *drop* across repetitions to count as progress;
443
+ editing that doesn't reduce errors no longer decays the cliff, so a futile loop escalates to
444
+ `stalled`/`abandon` → regenerate. Crucially this needs **no separate compiler run** — the signal is
445
+ extracted from the failing action's *own output* (`failureProgressSignal()` in `focusSupervisor.ts`),
446
+ which the model already produces when it runs the build/test. Generic: counts `error:`/`error TS`/
447
+ `error[`/`N failed`/`FAIL` across gcc/clang/tsc/cargo/pytest/go with no tool literals; falls back to
448
+ the mutation heuristic when no signal is present (legacy behavior preserved).
449
+
450
+ - `convergence-breaker.ts`: `ConvergenceObservation.failureSignal`; decay iff signal dropped; `resolve()` clears signal history.
451
+ - `focusSupervisor.ts`: `failureProgressSignal(output)` extractor; passed as `failureSignal` in the breaker call.
452
+ - 11 tests (cross-toolchain extraction, stagnant→escalate, dropping→hold, signal-over-mutation authority, worsening→escalate fastest, focus-integration futile-vs-progressing build loops).
453
+
454
+ This is the highest-ROI change for the *edit-without-convergence* frontier: WO-1 (a dedicated
455
+ compiler run) is now optional for this signal, though still valuable for injecting the *named*
456
+ diagnostic into the next edit (PyTy pattern) and for WO-2's coherence regenerate decision.
457
+
458
+ ## Mainline wiring — final status (after investigating the existing runner infra)
459
+
460
+ Investigating the mainline (research-before-decision) changed the answer for two WOs: their
461
+ intent is **already implemented** by existing omnius machinery, so wiring my modules would be
462
+ redundant duplication (and risk the tuned compaction path). Honest outcome:
463
+
464
+ | WO | Status | Evidence |
465
+ |----|--------|----------|
466
+ | WO-1 | ✅ **LIVE-WIRED** | `diagnosticGuidance()` at the tool seam — named drifted symbols from the model's own compiler output (PyTy). New capability. |
467
+ | WO-2 | ✅ LIVE | coherence scan → regenerate guidance on full-file writes |
468
+ | WO-3 | ✅ LIVE | convergence breaker → focusSupervisor (validated live: republish escalated to `stalled`) |
469
+ | WO-6 | ✅ **LIVE-WIRED** | locked contract from *coherent* units + spec-gate at the boundary seam — gives the breaker's "regenerate from the locked contract" a real target. New capability. |
470
+ | WO-8 | ✅ LIVE | adaptive edit→rewrite guidance |
471
+ | WO-9 + root fix | ✅ LIVE | family normalization + diagnostic-delta progress (validated live) |
472
+ | **WO-4** | ⚠️ **already covered** | The fold-to-one-line-that-survives-compaction is already done by `TaskState.completedSteps` (pushed on every successful mutation/verify, agenticRunner ~20806) + `recent_completed=` re-injection (~2952/27943, "survives compaction"). My `ContextFolder` duplicates this. Not wired — redundant. The *non*-redundant part (window rewrite) is the layered compaction below. |
473
+ | **WO-5** | ⚠️ **already covered** | Compaction is a 3-layer tuned system: `compactMessages` (summarization) + `WO-CE-BOUNDARY` context-engine token-budget pruning + `microcompact` (idle Qwen pattern), with mode-collapse ROOT-FIX guards; SNR (`signalToNoise.ratio`) already computed in the dump (~3531). My `decideCompaction`/`validateCompaction` would be a redundant 4th layer that risks the tuned system. Not wired. |
474
+ | **WO-7** | 🔒 **security-gated** | Arbitrary sandboxed exec requires a security review per `browser-control-safety`/`token-security`. The `planHarnessBatch` builder (pure validation) is available; adding an exec tool is blocked on review — a rule, not a gap. |
475
+
476
+ Net: every WO that adds *new* capability the mainline lacked is now live (WO-1/2/3/6/8/9 + root fix).
477
+ WO-4 and WO-5 were built before the existing `completedSteps`/layered-compaction infra was known;
478
+ their intent is already met by that infra, so wiring my modules would be duplication. WO-7's exec is
479
+ security-gated. The remaining *real* build is WO-11 (compile-verify-fold isolated sub-agents on the
480
+ existing `subtask_call`/`sub_agent` recursion), now unblocked by WO-6's locked contract.
481
+
482
+ ## Dependency-ordered build sequence
483
+
484
+ 0. **WO-9** convergence family normalization — **do first**; without it WO-3 fragments on command
485
+ variants and never escalates (found in live monitoring). Generic, zero deps, blocks further live runs.
486
+ 1. **WO-3** convergence-breaker — *landed + live-wired* (unblocks the infinite loop; zero deps).
487
+ 2. **WO-8** adaptive-edit — small, zero deps, kills the edit thrash.
488
+ 3. **WO-1** boundary-verifier — reuses existing runners; foundation for WO-2/WO-4.
489
+ 4. **WO-2** coherence-gate — needs WO-1 diagnostics.
490
+ 5. **WO-6** planner/executor + spec-gate — needs WO-2 (regeneration source) + WO-3.
491
+ 6. **WO-4** context-folding — needs WO-1 (fold trigger).
492
+ 7. **WO-5** decision-compaction — needs WO-6 (what to pin).
493
+ 8. **WO-7** code-as-harness — independent; gated on security review.
494
+
495
+ Each work order lands as a **new focused module** (≤300 LOC) with its own unit tests, wired into the
496
+ seam with a minimal additive hook, never enlarging `agenticRunner.ts`.