Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/patches/a27c56e6c7cb303d # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers ## feat(node): coding workflow on the own Omega model with typed tools (DRA-290) merged `a27c56e6c7cb303d` #1060 · opened 2026-11-07 04:41 UTC · closed 2026-11-15 14:36 UTC · merged 2026-11-15 14:36 UTC Imported from GitHub aien-dev/omega-mv#1060, by drakestapleton Base `340b91051ba04cce9e69fa321be14bfa9d071349` · Head `7989416836ec4039feae04209700e7f18639a1fe` Merged on GitHub as `81a70c069c3355d139583e30e076c6b565f5cd58`; reachable from main `c7acd2607139eedfabeac16b6042cefe8ede431f` (observed 2026-11-18T16:35:38Z) drakestapleton wrote on 2026-11-07 04:41 UTC Linear: DRA-290 (Omega Node, local own-model inference plus typed coding tools in one workflow). Stacked on #1059 (DRA-289); base `node/dra-289-journal`. Needs aien-train #76 (`/v1/completions` in `ollm serve`) for live runs. Status: IMPLEMENTED and EXERCISED on native Linux AArch64 host CPU (DGX Spark host, no GPU), host suite and live own-model run. Not QUALIFIED on the Spark gate, not MERGED, not DEPLOYED. ## What changed (all `.om`, compiled with this checkout's `seed/out/omc`, sha256 `5f90edea…`) - `seed/node/code.om`: the coding workflow. The creator runs the round40 repair protocol (read, check, edit, check again, answer) for 1..4 objectives through the Node's scheduler, authority and journal. One inference at a time; typed read/check/replace jobs plus a review check, each one child process group (`auth_wtool`), cancellable. The round40 `repair.py` policy is enforced by the creator before every grant. Every failure has an explicit reason code; there is no fallback provider. Restart resumes from the journal and the durable workspace. - `seed/node/infer.om`: a bounded completion client. It connects only to 127.0.0.1, refuses port 18091, posts one greedy non-streamed `/v1/completions` request and returns a versioned `OMNI1` record. A 503 is retried once a second while at least 2 s of the deadline remain: `ollm serve` handles one request at a time and keeps generating for a few seconds after a cancelled client has gone. - `seed/node/tool.om`: the read_file / omega_check / replace_text tools inside one root. Paths follow omagent's rule, now moved to `seed/agent/path.om` and shared. Replace writes a temporary file, syncs it and renames it. Tests run sandboxed, and the whole process group is killed on timeout. - `seed/node/gram.om`: the repair grammar. - `seed/agent/agent.om` now kills the tool's whole process group. That first change had a race: end of file on the tool's pipe was taken as the child's exit, so the group SIGKILL could overtake a child still exiting. `/bin/echo` closes stdout before it exits. Under 4 parallel streams, `run-echo` reported `[killed by signal 9]` in 26 of 300 runs, and it failed one full `agent-check` in the DRA-291 evidence run. `agwaitc` now reaps the direct child, polling every 2 ms until the deadline, before the rest of its group is killed. Results: 0 of 2400 stress runs failed, and the new deterministic case `cmd-closes-output-early` passes (output closed, 0.3 s sleep, exit 3; the expected result is `[exit status 3]`). Its mutant `eof-taken-as-exit` was killed 12 of 12 times. The first host receipt (`receipt.7ee902a4…`) rests on the racy agent gate and is superseded by the receipt for the fixed head. It stays in `evidence/`, which takes additions only. - `seed/authority/action.om` renames the local `at` to `ix`, because OM-2 reserves `at`. - The OM-2 composition needs `seed/net/notls.om` after `http.om`. - Per-turn deadline is 900 s. On this shared CPU host the round40 server took 289 s for a 186-token prompt. ## Host run Command: `~/work/omega-node-run.sh ~/work/omega-node-290.sh` (the script is embedded in the receipt). Head `1f671605`, tree `dd9eb500`, clean. Result: `PASS count 50`, `FAIL count 0`. Receipt `evidence/node-code/receipt.13de8cd0….json`. The node binary hashes match the earlier run at `8215c6ca` byte for byte. ``` PASS transport-gate / pool-gate / sched-gate / auth-gate / journal-gate / action-gate (219 checks) PASS build-infer bytes=132576 sha256=8cc5fb3044c9c794326e66b57aac7c6889c5cf498f4750503637d97505c1f806 PASS build-tool bytes=34396 sha256=a1bdecb08c74f89ddbd2bd674b224d21ed2a983268964972dd8f8ee701aa1c8d PASS build-code-main bytes=144120 sha256=6071fa6c28e12aa7846f48f9065718618a533ac0da9acb6ed3898797ed0b0dcd PASS build-code-test bytes=167240 sha256=a89bd509543ecdad68ffd947b37ea190ac488658aae8415568ff93ae4d25c07d PASS code-unit exit=0 code checks=54 fail=0 PASS tool-replay TOOL-REPLAY runs=108 pass=108 fail=0 actions=417 PASS agent-check exit=0 AGENT-CHECK PASS cases=35 mutants=9 PASS tree-unchanged-during-run ``` Negative controls. Each must fail, and each did. - 15 `code.om` mutants, each killed at its pinned check: - `cm1_path_unchecked` 154 - `cm2_old_not_once` 103 (trap) - `cm3_grammar_unchecked` 162 - `cm4_unverified_pass` 168 - `cm5_check_content` 181 - `cm6_exit_ignored` 192 - `cm7_turn_limit` 202 - `cm8_saved_unchecked` 186 - `cm9_notfound_any_state` 171 - `cm10_replace_any_state` 157 - `cm11_goal_text` 151 - `cm12_record_length` 174 - `cm13_cancel_unknown` 197 - `cm14_missing_as_read` 178 - `cm15_prompt_too_long` 203 - 20 tool controls. - `Path refused.` (status 2): `..`, an absolute path, a final symlink, a symlink to a directory. - `File not found.` (1). - over 3800 bytes (3). - `Old text must occur exactly once.` (5): twice, or empty. - Failed tests (6): wrong K, main altered, duplicate function (`omc: line 7: error 10`), missing `end` (`error 15`), required loop missing. - Usage (exit 2): argument count, unknown verb. - I/O error (4): relative work dir; a compiler that hangs, killed at 10 s with no leaked process. - Durable replace leaves no temporary file. ## Live run with the own Omega model Command: `~/work/omega-node-290-live.sh`. Head `fadf3288`, tree `2046ca4d`, clean. That commit builds the same node binaries as this head; the agent fix touches no `seed/node`, `seed/agent/path.om`, `seed/net` or `seed/authority` file. Result: `PASS count 19`, `FAIL count 0`, about 47 minutes. Receipt `evidence/node-code/receipt.dfb50228….json`. The model is the round40 checkpoint (sha256 `7c7b5b52…`, merges `73a29baf…`). It is served by aien-train `ollm serve` (`f99fce9f…`, aien-train `9edd881c`, aien-train #76) inside `bwrap --unshare-net` on 127.0.0.1:18294. No GPU was used, nothing reached the host network, and :18091 was not touched. ``` PASS infer-prompt0 exit 0 ms 116188 OMNI1 1 1 90 35 17 0 0 48|jobs/item76666.om|{"tool":"read_file","path":"jobs/item76666.om"} PASS infer-empty-prompt want=3 / port-18091-refused want=2 / no-server want=4 / deadline-2s want=5 PASS infer-busy-waits exit 0 ms 175284 / busy-5s exit 5 ms 5011 / busy-retried 503s=37 holder exit 0 PASS infer-kinds replace=3 tests-passed=4 extra-key=9 prose=9 truncated=9,fin=2 PASS workflow-4-objectives exit 0 ms 1632430 CWSUM pass=4 fail=0 COMPARE PASS PASS workflow-journal records 116 opens 1 starts 29 ops 29 max_starts_per_op 1 PASS cancel-mid-inference exit 1 ms 20040 ... CWO 0 FAIL 19 1 serve: C 499 91 10 4 22072 PASS server-down exit 1 ms 37 ... CWO 0 FAIL 16 1 PASS crash-restart run1 killed 137 run2 exit 0 ms 295826 run2: CWO 0 PASS 1 6 records 54 opens 2 starts 13 ops 13 max_starts_per_op 1 replace op (1054, 4, 1, 1) starts 1 done(outcome,how) (2, 1) ``` - Four objectives ran end to end through the scheduler, authority and journal. Each model turn matched the recorded round40 turn (`COMPARE PASS`), and no operation started twice. - A cancel during inference ended the objective with 19. The server logged the dropped request as 499 and stopped generating. - With the server down, the objective ended with 16 at once, and no other provider was tried. - The creator was SIGKILLed mid-run. The next incarnation settled the replace from the journal (DONE outcome 2, performed) and did not start it again. ## Status IMPLEMENTED and EXERCISED on native Linux AArch64 host CPU, including the live own-model run. Not QUALIFIED by the Spark gate judge (DRA-292). Not MERGED. Not DEPLOYED. ### Apply it ``` git checkout -b patch-a27c56e6c7cb303d 340b91051ba04cce9e69fa321be14bfa9d071349 curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/a27c56e6c7cb303d.patch | git am ``` Raw patch (mbox) · Diff ### Provenance This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record: ``` github-import 1 aien-dev/omega-mv 1060 7989416836ec4039feae04209700e7f18639a1fe ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":1060,"url":"https://github.com/aien-dev/omega-mv/pull/1060","export_sha256":"7319147b350ad908bf0b731068ec3be7b8dee848041dc862f71455e8e4680140","imported_utc":"2026-11-18T16:35:38Z"} ``` ### Changes ``` diff --git a/.crumb b/.crumb index 27f2da65a..49e6ee5e7 100644 --- a/.crumb +++ b/.crumb @@ -108,14 +108,14 @@ } ], "children_root": "sha256:966bedb54caa4209f9ab84526da66f6b13ce72e8831470170364eb5881355748", - "compiled_at": "2026-11-07T01:51:53Z", + "compiled_at": "2026-11-07T04:39:25Z", "compiler": "crumb-compile/1", - "digest": "sha256:cdc378882f840208aeb97c08c6df21a8770243ed338a140ff7b7d0b1512cfbb1", - "evidence_files": 15694, - "evidence_root": "sha256:3ea442921dd97462efe06f4999454f61457b054f79ee1253e0321c378a1dff05", - "files": 24245, - "generated_at_commit": "7f6a1f4607bc8933edc43b5ff35f4f1ae873f9bc", - "source_tree": "sha256:e9459d5d4adb5006bb78febfe811c61f42b832e43837e5c471e4806fd44b1606" + "digest": "sha256:a6c82328a0c78547a0bdd10b5413abf92c770c77a60d1ff07cecdfe91318248c", + "evidence_files": 15697, + "evidence_root": "sha256:d27e57dca62f72d32e3df2004050ab45a220c65322d8e91a1d018697d89fdb53", + "files": 24256, + "generated_at_commit": "b93031dd0b45fe89bdaacf0956cdda9f51e29b51", + "source_tree": "sha256:1ee369a73a85f886a202b9d6d4debad425c90c490d9b17247718b9128642af7b" }, "owner_lane": "", "provenance": { diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 78cee1798..2356d08a6 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -12,6 +12,7 @@ The current development method is [Human-Directed Agentic Engineering (HDAE)](RE | Claude Opus 5.5 (via omp) | DRA-287 for `seed/node`: `sched.om`, a cooperative scheduler in which one creator owns admission, assignment, collection and review. Workers have topic subscriptions, and jobs can wait on dependency topics. Wake-ups are eventfd hints followed by a rescan, so none is lost. Admitted work and work in review have separate limits; a full review queue stops assignment instead of dropping results. A dead worker's job is rerun when marked safe, otherwise it becomes UNKNOWN. There is no hive-wide barrier. `node_count` added to `transport.om`. `sched-gate.om` runs a real-process acceptance test that measures idle CPU from `/proc` and checks exactly one wake per round over 200 publication rounds. It has eight negative controls. Native AArch64 host evidence only; not QUALIFIED on the Spark gate. | | Claude Opus 5.5 (via omp) | DRA-288 for `seed/node`: `auth.om`, typed worker proposals decided and committed by the creator alone through the action records of `seed/authority/action.om` (one record per operation identity; a performed or UNKNOWN operation is never started again). Proposals are refused as malformed, not the current assignment, another incarnation, stale input, revoked authority or cancelled. Granted tools run as their own process group; cancellation, revocation, stop and worker death kill the whole group, and the outcome comes from the wait status, so a tool that already exited stays performed and a killed one stays UNKNOWN. Operator pause, cancel and revoke reach workers through a per-worker control eventfd with acknowledged seqs. `sched.om` gains `sched_pause` and `sched_cancel`. `auth-gate.om` runs real forked workers and `/bin/sh` tools through seven phases, with twelve negative controls. Native AArch64 host evidence only; not QUALIFIED on the Spark gate. | | Claude Opus 5.5 (via omp) | DRA-289 for `seed/node`: `journal.om`, a checksummed append-only journal of every authority transition (OPEN, ADMIT, START, DONE, RELEASE, REVOKE, PAUSE, CANCEL), each checked by the recovery tables, written and fdatasync'd before anything acts on it or publishes it; a failed write or sync stops all later appends. `flock` fencing that forked workers also hold, fence numbers per creator incarnation, torn-tail cutting, refusal of corrupt records, other format versions and other objectives. Restart recovery settles operations left in flight (idempotent class 3 by its key, class 1 UNKNOWN and never rerun), releases or readmits each job, and restores authority generation and pause. `auth.om` journals through it and accepts class 3. `journal-gate.om` crashes real creators at every boundary, SIGKILLs them mid-tool and checks the result with its own reader; ten negative controls. Native AArch64 host evidence only; not QUALIFIED on the Spark gate. | +| Claude Opus 5.5 (via omp) | DRA-290 for `seed/node`: `code.om`, the coding workflow driving the own Omega model (round40 checkpoint, served by aien-train `ollm serve` `/v1/completions`, aien-train #76) through the Node's scheduler, authority and journal: one inference at a time, typed read/check/replace jobs and a review check, each a cancellable child process group, the round40 repair policy enforced by the creator before every grant, explicit failure reasons and no fallback provider. `infer.om`, a bounded loopback-only completion client returning a versioned record; `tool.om`, the read/check/replace tools inside one root with omagent's path rule (moved to `seed/agent/path.om`), durable replace and sandboxed tests; `gram.om`, the repair grammar. `code-test.om` (54 checks, 15 mutants), `tests/tool-replay.py` (all 108 recorded round40 runs) and live own-model runs with cancellation and crash restart. `seed/agent/agent.om` now kills the tool's whole process group; `seed/authority/action.om` renames a local so the node composes as OM-2. Native AArch64 host evidence only; not QUALIFIED on the Spark gate. | | Grok 4.7 (via Cursor Agent) | Merged main `fd3751b31` (#1020, carrying #1045 and #1050) into #1052. The only conflict was the generated root `.crumb` (child `last_commit` stamps, the `tests` digest, and the root digest). Recompiled with the crumb.lock tool (`d0f0b95d`); `crumb verify .` current. The #525/#962 pins were left as committed: `src/checker2/c2_check.c`, `src/compiler/osc_ir.c` and `src/compiler/osc_ir.h` still hash to the SHA-256s in `ACCEPTED`. | | Claude Opus 5.5 (via omp) | #1020 (actions/cache-4.3.0 ->6.1.0): merged main `d3d1b1bc` and recompiled the root crumb with the crumb.lock tool (`d0f0b95d`). The root crumb's source tree covers `.github/workflows/`, so the bump alone left it stale and `AIEN Checks` failed at `crumb verify .` (`1 of 188 crumbs stale`). | | Claude Opus 5.5 (via omp) | #1018 (actions/upload-artifact-4 ->7): merged main `d3d1b1bc` and recompiled the root crumb with the crumb.lock tool (`d0f0b95d`). The root crumb's source tree covers `.github/workflows/`, so the bump alone left it stale and `AIEN Checks` failed at `crumb verify .` (`1 of 188 crumbs stale`). | @@ -97,6 +98,8 @@ The current development method is [Human-Directed Agentic Engineering (HDAE)](RE | Claude Opus 5.5 | OSC IR v7 memory oracle: independent decoder, validator and interpreter (`seed/wasm/v7/oracle.js`), separate hand-written fixture writer, hand-written expectations and a mutant-checked self-test | | Claude Opus 5.5 | Effect-derived capability manifest (`seed/effects`, M1): host-word manifest, ELF syscall resolution that fails closed, seccomp cBPF output, probe-parity/strace/bwrap gate with negative controls and tool mutants | | Claude Opus 5.5 | seed/agent: omagent, a nanobot-style coding agent in seeded Omega (agent loop, four permissioned tools, JSONL session memory, SSE streaming, CLI), its scripted-mock test referee with six mutants, and the paired startup/RSS benchmark against nanobot | +| Claude Opus 5.5 (AgentGroupKill, via omp) | Omega Node DRA-290: omagent runs each tool command as its own process group (`setpgid` both sides of the fork) and SIGKILLs the whole group when the direct child exits and at the `--cmd-timeout` deadline, so no tool grandchild outlives the call or holds the output pipe open; `check.py` composes `notls.om` again, gains the `cmd-grandchild` and `cmd-timeout-group` /proc survivor cases and two child-only-kill mutants, with the pre-change agent as negative control | +| Claude Opus 5.5 (via omp) | Omega Node DRA-290 fix: omagent took end of file on a tool's output as the child's exit, so the group SIGKILL could overtake a child still exiting (`/bin/echo` closes stdout before it exits; `run-echo` reported `[killed by signal 9]` in 26 of 300 parallel runs). `agwaitc` reaps the direct child up to the deadline before the rest of its group is killed: 0 of 2400 stress runs failed. `check.py` gains the deterministic `cmd-closes-output-early` case (output closed, 0.3 s sleep, exit 3) and the `eof-taken-as-exit` mutant, killed 12 of 12 times. | | Claude Opus 5.5 | Tenstorrent Tensix vecadd (`seed/tensix`): RV32IM asm2 table, hand-written kernel and start code, seeded Omega emitter `irrv32.om` (OSC IR v1 scalar unit -> RV32 elementwise kernel, byte-identical to asm2), hand-written edge disassembly, ttsim WH/BH and qemu interop-oracle gate with negative controls | | Claude Opus 5.5 | AWS Trainium/Inferentia backend `seed/nki`: `irnki.om` OSC IR v1 to `nki.isa` vecadd/elementwise emitter, native-Omega reference lanes, NKI CPU simulator interop-oracle gate (trn1/trn2/trn3) with negative controls and refusals, pinned oracle setup | | Claude Opus 5.5 (via omp) | ORIG-4 shadow advice (#731): `native/orig4/shadow.om` advisor, pin file, in-process tests, host glue, gate `omega-orig4-shadow` and `spec/shadow-advice-v0.md` | diff --git a/evidence/node-code/receipt.13de8cd081400804d8335e190a35973439f86978046be4067ac72c4d4c22cfa0.json b/evidence/node-code/receipt.13de8cd081400804d8335e190a35973439f86978046be4067ac72c4d4c22cfa0.json new file mode 100644 index 000000000..29f0b48d1 --- /dev/null +++ b/evidence/node-code/receipt.13de8cd081400804d8335e190a35973439f86978046be4067ac72c4d4c22cfa0.json @@ -0,0 +1,168 @@ +{ + "issue": "DRA-290", + "source_commit": "1f671605feee17f400329e8ecec9004eb6d17948", + "source_tree": "dd9eb500563a53b1876e0608c56d18c9c7df0028", + "platform": "Linux 7.0.0-1019-nvidia aarch64 spark-b87b", + "cpu_affinity_mask_hex": "300", + "execution": "NATIVE Linux AArch64 host CPU (DGX Spark host, no GPU opened)", + "timestamp_utc": "2026-11-07T04:08:45.058203+00:00", + "independent_review": false, + "native_aarch64": "PASS", + "spark_gate_judge": "NOT_RUN", + "live_hive": "NOT_DEPLOYED", + "script": "~/work/omega-node-290.sh (DRA-290 PR body; run from the worktree of this commit) (compile with seed/out/omc, run under timeout; mutants are one-line sed edits of a disposable copy)", + "hashes": { + "seed/out/omc": "5f90edea61bac241398df5036990d899361a5acd9decb37954ce088ec0f6f6df", + "seed/node/auth-gate.om": "c37e6ee5a041d60840727c1993b08057369099d4042e0456823239b330e2a35a", + "seed/node/auth.om": "edf2f075d3751a8025363bc658252537f865dfc29f975fcf5d93c353b3282b30", + "seed/node/auth-test.om": "af66c87f83d73a5bdbaf181378eb69bb0645a86fe9b39de2f1b714041fbc20b8", + "seed/node/code-main.om": "be20bbbc9793c190966ca50311d28c7f53a21bc1d838646a76a4f3600e2021eb", + "seed/node/code.om": "aa9f8463fbe9534626c205e991e3a2170a25cbf91a106932ec399353583c0bf7", + "seed/node/code-test.om": "df87a21e31f38d85ab9145af3fb18bafc52144a20aed0d9fbad60f6059ddacd0", + "seed/node/gram.om": "ebba1f4c693f218969dc2f17eb680760977d38d694ac76db477853aefa64b291", + "seed/node/infer.om": "8606f2bc917e7942033cf26355e72b92eae75b99c7b25e6f1ced953d8903ff4f", + "seed/node/journal-gate.om": "d0db0257ac03d00a801ca12598d147201d03cad85c806e4d29d260f34587b19f", + "seed/node/journal.om": "786802ccf5d31ee848285fb6853b3895501a54fe9b9ffb09af2585c222c13c38", + "seed/node/journal-test.om": "b3f2d93e64c87c4c8c0193174cbc3ef6435085e47360d59641c63cc96f48274e", + "seed/node/pool-gate.om": "9354978875c6c3986d7bf0fa3977bf6e59e1fddebfd3fd3407083a4fc1a02339", + "seed/node/pool.om": "e7fba928bdc5c4194e7aee42109265de4f172d2b197946133d788b2dbcb30ccc", + "seed/node/pool-test.om": "7e18abdc5d0b377995e210aa336ba03a35d88af193d5387d5da3e8b0b6c01042", + "seed/node/sched-gate.om": "fbad2340b5dfb6cde909d922f153bbf5889ef4796500d31613462ac9b1d8385e", + "seed/node/sched.om": "9bd18158c0b574a9b7d22a54433157fb7216ab4f479c0dd12db2256870150b23", + "seed/node/sched-test.om": "29a3587d35a217403c63395eb2b11b4992727812af66512be3e452ea6381a545", + "seed/node/super.om": "d104ac8116c6df57fdc93f03791d7315e5b60875d8d6177480ef9967b6f53d5a", + "seed/node/tool.om": "49d8eb6a8e2c4ccec5cb28b11233b8ec9fe94165c897239739a1b668d12c9254", + "seed/node/transport-gate.om": "7f85aa57b064957734b8ab0a7b925390fcb50a9c657ba2bf08c26ce5b21377db", + "seed/node/transport.om": "d0dd69ef5e0b71294a2390b3526865d62ca07accd269b9ce57a028339e34f6da", + "seed/node/transport-test.om": "d00b22082c781c5300065faf321f9126a7801fc5b639dbfc47bd75798e5dbae9", + "seed/agent/agent.om": "84a595c27bf23b9562fc2ea7c97f0e2dce17a151ceb28c7928be5adebef1dbce", + "seed/agent/path.om": "1daef7e888e45f7cd7f2f8bb1ea34bc061115c261aac3740f3c799803f7079b2", + "seed/authority/action.om": "59cb9c3dfdcd9193bc4a272deda4fcd256a0d7693f3bcb58bc4e30ed78faab2b", + "seed/authority/action-gate.om": "716761cfee0af722586def0a0e06342bd0d4a8482c64ef75aeb0e92eae21e604", + "seed/node/tests/tool-replay.py": "e220595d7912f3d0219825befc227284dc5782cb969f1f06cc969b6c3251db86", + "/home/drakestapleton/work/omega-node-e5b3/seed/out/omc": "2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f" + }, + "checks": [ + { + "case": "transport-gate", + "compile_exit": 0, + "expected_exit": "0", + "run_exit": 0, + "wall_ms": 13, + "stdout": "PASS node transport\n", + "binary_sha256": "470aefe90345217aa16e9d6ac1de16b8db59566436b842c7a01cbaeee7812234", + "verdict": "PASS", + "leaked_tool_processes_after_run": 0 + }, + { + "case": "pool-gate", + "compile_exit": 0, + "expected_exit": "0", + "run_exit": 0, + "wall_ms": 6069, + "stdout": "stress rolls=2000 busy=10419884 reads=159725 296433\nPASS node pool\n", + "binary_sha256": "afd1063c4e534ade5e798cd1b2ef576873ad51eab9d7a4c6a5a73f8b8c3ef5b4", + "verdict": "PASS", + "leaked_tool_processes_after_run": 0 + }, + { + "case": "sched-gate", + "compile_exit": 0, + "expected_exit": "0", + "run_exit": 0, + "wall_ms": 7921, + "stdout": "idle ticks workers=0 creator=0 wake rounds=200 mean_us=15 max_us=600\nPASS node sched\n", + "binary_sha256": "68b835c0821b44582adbc08fdfdb3049531075699d7841f3df288e28098b0abb", + "verdict": "PASS", + "leaked_tool_processes_after_run": 0 + }, + { + "case": "auth-gate", + "compile_exit": 0, + "expected_exit": "0", + "run_exit": 0, + "wall_ms": 731, + "stdout": "PASS node authority\n", + "binary_sha256": "1cff100077b76e1d773886f7ada81b8945a07621d024fcc092ee15011583ac67", + "verdict": "PASS", + "leaked_tool_processes_after_run": 0 + }, + { + "case": "journal-gate", + "compile_exit": 0, + "expected_exit": "0", + "run_exit": 0, + "wall_ms": 3223, + "stdout": "PASS node journal\n", + "binary_sha256": "4484672957407ad405302b404b1b844c99e721d217dedd48d88ffa35ee9e580d", + "verdict": "PASS", + "leaked_tool_processes_after_run": 0 + }, + { + "case": "action-gate", + "compile_exit": 0, + "expected_exit": "0", + "run_exit": 0, + "wall_ms": 1, + "stdout": "action checks=219 000\n", + "binary_sha256": "f56e5696dfcfc8a16430147db176eb5b6568ec794fd3de9303f9dcd505f246aa", + "verdict": "PASS", + "leaked_tool_processes_after_run": 0 + } + ], + "results": [ + "PASS transport-gate compile=0 exit=0 want=0 ms=13 bin=470aefe90345217a leaked_tools=0 stdout=PASS node transport ", + "PASS pool-gate compile=0 exit=0 want=0 ms=6069 bin=afd1063c4e534ade leaked_tools=0 stdout=stress rolls=2000 busy=10419884 reads=159725 296433 PASS node pool ", + "PASS sched-gate compile=0 exit=0 want=0 ms=7921 bin=68b835c0821b4458 leaked_tools=0 stdout=idle ticks workers=0 creator=0 wake rounds=200 mean_us=15 max_us=600 PASS node sched ", + "PASS auth-gate compile=0 exit=0 want=0 ms=731 bin=1cff100077b76e1d leaked_tools=0 stdout=PASS node authority ", + "PASS journal-gate compile=0 exit=0 want=0 ms=3223 bin=4484672957407ad4 leaked_tools=0 stdout=PASS node journal ", + "PASS action-gate compile=0 exit=0 want=0 ms=1 bin=f56e5696dfcfc8a1 leaked_tools=0 stdout=action checks=219 000 ", + "PASS build-infer compile=0 bytes=132576 sha256=8cc5fb3044c9c794326e66b57aac7c6889c5cf498f4750503637d97505c1f806", + "PASS build-tool compile=0 bytes=34396 sha256=a1bdecb08c74f89ddbd2bd674b224d21ed2a983268964972dd8f8ee701aa1c8d", + "PASS build-code-main compile=0 bytes=144120 sha256=6071fa6c28e12aa7846f48f9065718618a533ac0da9acb6ed3898797ed0b0dcd", + "PASS build-code-test compile=0 bytes=167240 sha256=a89bd509543ecdad68ffd947b37ea190ac488658aae8415568ff93ae4d25c07d", + "PASS code-unit exit=0 code checks=54 fail=0", + "PASS mutant cm1_path_unchecked exit=154 want=154 (killed)", + "PASS mutant cm2_old_not_once exit=103 want=103 (killed)", + "PASS mutant cm3_grammar_unchecked exit=162 want=162 (killed)", + "PASS mutant cm4_unverified_pass exit=168 want=168 (killed)", + "PASS mutant cm5_check_content exit=181 want=181 (killed)", + "PASS mutant cm6_exit_ignored exit=192 want=192 (killed)", + "PASS mutant cm7_turn_limit exit=202 want=202 (killed)", + "PASS mutant cm8_saved_unchecked exit=186 want=186 (killed)", + "PASS mutant cm9_notfound_any_state exit=171 want=171 (killed)", + "PASS mutant cm10_replace_any_state exit=157 want=157 (killed)", + "PASS mutant cm11_goal_text exit=151 want=151 (killed)", + "PASS mutant cm12_record_length exit=174 want=174 (killed)", + "PASS mutant cm13_cancel_unknown exit=197 want=197 (killed)", + "PASS mutant cm14_missing_as_read exit=178 want=178 (killed)", + "PASS mutant cm15_prompt_too_long exit=203 want=203 (killed)", + "PASS tool-replay TOOL-REPLAY runs=108 pass=108 fail=0 actions=417", + "PASS tool-dotdot got=s2 want=s2 ms=1 leaked=0 record=OMNT1 2 13 0|Path refused.", + "PASS tool-absolute got=s2 want=s2 ms=1 leaked=0 record=OMNT1 2 13 0|Path refused.", + "PASS tool-final-symlink got=s2 want=s2 ms=1 leaked=0 record=OMNT1 2 13 0|Path refused.", + "PASS tool-dir-symlink got=s2 want=s2 ms=1 leaked=0 record=OMNT1 2 13 0|Path refused.", + "PASS tool-missing got=s1 want=s1 ms=1 leaked=0 record=OMNT1 1 15 0|File not found.", + "PASS tool-over-3800 got=s3 want=s3 ms=1 leaked=0 record=OMNT1 3 24 0|File is over 3800 bytes.", + "PASS tool-read got=s0 want=s0 ms=1 leaked=0 record=OMNT1 0 15 75|Read succeeded.fn calc x int to int|ret add x int 3|end|fn main to int|ret calc int 5|", + "PASS tool-old-twice got=s5 want=s5 ms=2 leaked=0 record=OMNT1 5 33 75|Old text must occur exactly once.fn calc x int to int|ret add x int 3|end|fn main to i", + "PASS tool-old-empty got=s5 want=s5 ms=1 leaked=0 record=OMNT1 5 33 0|Old text must occur exactly once.", + "PASS tool-replace got=s0 want=s0 ms=11 leaked=0 record=OMNT1 0 11 75|Edit saved.fn calc x int to int|ret add x int 2|end|fn main to int|ret calc int 5|end|", + "PASS tool-check-pass got=s0 want=s0 ms=26 leaked=0 record=OMNT1 0 13 75|Tests passed.fn calc x int to int|ret add x int 2|end|fn main to int|ret calc int 5|en", + "PASS tool-check-wrong-k got=s6 want=s6 ms=11 leaked=0 record=OMNT1 6 39 75|Test failed: calc(5) expected 7, got 8.fn calc x int to int|ret add x int 3|end|fn mai", + "PASS tool-check-main got=s6 want=s6 ms=5 leaked=0 record=OMNT1 6 39 76|main must preserve the requested input.fn calc x int to int|ret add x int 2|end|fn mai", + "PASS tool-check-dup got=s6 want=s6 ms=5 leaked=0 record=OMNT1 6 21 116|omc: line 7: error 10fn calc x int to int|ret add x int 2|end|fn main to int|ret calc", + "PASS tool-check-no-end got=s6 want=s6 ms=6 leaked=0 record=OMNT1 6 21 71|omc: line 6: error 15fn calc x int to int|ret add x int 2|end|fn main to int|ret calc ", + "PASS tool-check-no-loop got=s6 want=s6 ms=6 leaked=0 record=OMNT1 6 22 75|Required loop missing.fn calc x int to int|ret add x int 2|end|fn main to int|ret calc", + "PASS tool-argc got=x2 want=x2 ms=1 leaked=0 record=", + "PASS tool-verb got=x2 want=x2 ms=1 leaked=0 record=", + "PASS tool-relative-work got=s4 want=s4 ms=1 leaked=0 record=OMNT1 4 10 0|I/O error.", + "PASS tool-slow-omc got=s4 want=s4 ms=10007 leaked=0 record=OMNT1 4 10 75|I/O error.fn calc x int to int|ret add x int 2|end|fn main to int|ret calc int 5|end|", + "PASS tool-replace-durable-no-temp a.om big.om dup.om e.om l.om ok.om syn.om z.om ", + "PASS agent-check exit=0 AGENT-CHECK PASS cases=35 mutants=9", + "PASS tree-unchanged-during-run", + "PASS count 50", + "FAIL count 0" + ], + "repeat": null +} diff --git a/evidence/node-code/receipt.7ee902a447a35e1f9f85cd4e8af45720215dbab4577e021df39bcdbf004ea5a1.json b/evidence/node-code/receipt.7ee902a447a35e1f9f85cd4e8af45720215dbab4577e021df39bcdbf004ea5a1.json new file mode 100644 index 000000000..880656d81 --- /dev/null +++ b/evidence/node-code/receipt.7ee902a447a35e1f9f85cd4e8af45720215dbab4577e021df39bcdbf004ea5a1.json @@ -0,0 +1,168 @@ +{ + "issue": "DRA-290", + "source_commit": "8215c6ca3e509c136170ba2f6f3693209ef9e608", + "source_tree": "4d732174e97d195fdadf0e18e7e02bf2ab54ee5d", + "platform": "Linux 7.0.0-1019-nvidia aarch64 spark-b87b", + "cpu_affinity_mask_hex": "7000", + "execution": "NATIVE Linux AArch64 host CPU (DGX Spark host, no GPU opened)", + "timestamp_utc": "2026-11-07T03:04:20.267468+00:00", + "independent_review": false, + "native_aarch64": "PASS", + "spark_gate_judge": "NOT_RUN", + "live_hive": "NOT_DEPLOYED", + "script": "~/work/omega-node-290.sh (DRA-290 PR body) (compile with seed/out/omc, run under timeout; mutants are one-line sed edits of a disposable copy)", + "hashes": { + "seed/out/omc": "5f90edea61bac241398df5036990d899361a5acd9decb37954ce088ec0f6f6df", + "seed/node/auth-gate.om": "c37e6ee5a041d60840727c1993b08057369099d4042e0456823239b330e2a35a", + "seed/node/auth.om": "edf2f075d3751a8025363bc658252537f865dfc29f975fcf5d93c353b3282b30", + "seed/node/auth-test.om": "af66c87f83d73a5bdbaf181378eb69bb0645a86fe9b39de2f1b714041fbc20b8", + "seed/node/code-main.om": "be20bbbc9793c190966ca50311d28c7f53a21bc1d838646a76a4f3600e2021eb", + "seed/node/code.om": "aa9f8463fbe9534626c205e991e3a2170a25cbf91a106932ec399353583c0bf7", + "seed/node/code-test.om": "df87a21e31f38d85ab9145af3fb18bafc52144a20aed0d9fbad60f6059ddacd0", + "seed/node/gram.om": "ebba1f4c693f218969dc2f17eb680760977d38d694ac76db477853aefa64b291", + "seed/node/infer.om": "8606f2bc917e7942033cf26355e72b92eae75b99c7b25e6f1ced953d8903ff4f", + "seed/node/journal-gate.om": "d0db0257ac03d00a801ca12598d147201d03cad85c806e4d29d260f34587b19f", + "seed/node/journal.om": "786802ccf5d31ee848285fb6853b3895501a54fe9b9ffb09af2585c222c13c38", + "seed/node/journal-test.om": "b3f2d93e64c87c4c8c0193174cbc3ef6435085e47360d59641c63cc96f48274e", + "seed/node/pool-gate.om": "9354978875c6c3986d7bf0fa3977bf6e59e1fddebfd3fd3407083a4fc1a02339", + "seed/node/pool.om": "e7fba928bdc5c4194e7aee42109265de4f172d2b197946133d788b2dbcb30ccc", + "seed/node/pool-test.om": "7e18abdc5d0b377995e210aa336ba03a35d88af193d5387d5da3e8b0b6c01042", + "seed/node/sched-gate.om": "fbad2340b5dfb6cde909d922f153bbf5889ef4796500d31613462ac9b1d8385e", + "seed/node/sched.om": "9bd18158c0b574a9b7d22a54433157fb7216ab4f479c0dd12db2256870150b23", + "seed/node/sched-test.om": "29a3587d35a217403c63395eb2b11b4992727812af66512be3e452ea6381a545", + "seed/node/super.om": "d104ac8116c6df57fdc93f03791d7315e5b60875d8d6177480ef9967b6f53d5a", + "seed/node/tool.om": "49d8eb6a8e2c4ccec5cb28b11233b8ec9fe94165c897239739a1b668d12c9254", + "seed/node/transport-gate.om": "7f85aa57b064957734b8ab0a7b925390fcb50a9c657ba2bf08c26ce5b21377db", + "seed/node/transport.om": "d0dd69ef5e0b71294a2390b3526865d62ca07accd269b9ce57a028339e34f6da", + "seed/node/transport-test.om": "d00b22082c781c5300065faf321f9126a7801fc5b639dbfc47bd75798e5dbae9", + "seed/agent/agent.om": "3ec03e33e9cf8e406183e059b9c4829949792288a40ff81c0b3d62f82f54f9ec", + "seed/agent/path.om": "1daef7e888e45f7cd7f2f8bb1ea34bc061115c261aac3740f3c799803f7079b2", + "seed/authority/action.om": "59cb9c3dfdcd9193bc4a272deda4fcd256a0d7693f3bcb58bc4e30ed78faab2b", + "seed/authority/action-gate.om": "716761cfee0af722586def0a0e06342bd0d4a8482c64ef75aeb0e92eae21e604", + "seed/node/tests/tool-replay.py": "e220595d7912f3d0219825befc227284dc5782cb969f1f06cc969b6c3251db86", + "/home/drakestapleton/work/omega-node-e5b3/seed/out/omc": "2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f" + }, + "checks": [ + { + "case": "transport-gate", + "compile_exit": 0, + "expected_exit": "0", + "run_exit": 0, + "wall_ms": 13, + "stdout": "PASS node transport\n", + "binary_sha256": "470aefe90345217aa16e9d6ac1de16b8db59566436b842c7a01cbaeee7812234", + "verdict": "PASS", + "leaked_tool_processes_after_run": 0 + }, + { + "case": "pool-gate", + "compile_exit": 0, + "expected_exit": "0", + "run_exit": 0, + "wall_ms": 2183, + "stdout": "stress rolls=2000 busy=0 reads=2966 2958\nPASS node pool\n", + "binary_sha256": "afd1063c4e534ade5e798cd1b2ef576873ad51eab9d7a4c6a5a73f8b8c3ef5b4", + "verdict": "PASS", + "leaked_tool_processes_after_run": 0 + }, + { + "case": "sched-gate", + "compile_exit": 0, + "expected_exit": "0", + "run_exit": 0, + "wall_ms": 8042, + "stdout": "idle ticks workers=0 creator=0 wake rounds=200 mean_us=84 max_us=571\nPASS node sched\n", + "binary_sha256": "68b835c0821b44582adbc08fdfdb3049531075699d7841f3df288e28098b0abb", + "verdict": "PASS", + "leaked_tool_processes_after_run": 0 + }, + { + "case": "auth-gate", + "compile_exit": 0, + "expected_exit": "0", + "run_exit": 0, + "wall_ms": 753, + "stdout": "PASS node authority\n", + "binary_sha256": "1cff100077b76e1d773886f7ada81b8945a07621d024fcc092ee15011583ac67", + "verdict": "PASS", + "leaked_tool_processes_after_run": 0 + }, + { + "case": "journal-gate", + "compile_exit": 0, + "expected_exit": "0", + "run_exit": 0, + "wall_ms": 3213, + "stdout": "PASS node journal\n", + "binary_sha256": "4484672957407ad405302b404b1b844c99e721d217dedd48d88ffa35ee9e580d", + "verdict": "PASS", + "leaked_tool_processes_after_run": 0 + }, + { + "case": "action-gate", + "compile_exit": 0, + "expected_exit": "0", + "run_exit": 0, + "wall_ms": 2, + "stdout": "action checks=219 000\n", + "binary_sha256": "f56e5696dfcfc8a16430147db176eb5b6568ec794fd3de9303f9dcd505f246aa", + "verdict": "PASS", + "leaked_tool_processes_after_run": 0 + } + ], + "results": [ + "PASS transport-gate compile=0 exit=0 want=0 ms=13 bin=470aefe90345217a leaked_tools=0 stdout=PASS node transport ", + "PASS pool-gate compile=0 exit=0 want=0 ms=2183 bin=afd1063c4e534ade leaked_tools=0 stdout=stress rolls=2000 busy=0 reads=2966 2958 PASS node pool ", + "PASS sched-gate compile=0 exit=0 want=0 ms=8042 bin=68b835c0821b4458 leaked_tools=0 stdout=idle ticks workers=0 creator=0 wake rounds=200 mean_us=84 max_us=571 PASS node sched ", + "PASS auth-gate compile=0 exit=0 want=0 ms=753 bin=1cff100077b76e1d leaked_tools=0 stdout=PASS node authority ", + "PASS journal-gate compile=0 exit=0 want=0 ms=3213 bin=4484672957407ad4 leaked_tools=0 stdout=PASS node journal ", + "PASS action-gate compile=0 exit=0 want=0 ms=2 bin=f56e5696dfcfc8a1 leaked_tools=0 stdout=action checks=219 000 ", + "PASS build-infer compile=0 bytes=132576 sha256=8cc5fb3044c9c794326e66b57aac7c6889c5cf498f4750503637d97505c1f806", + "PASS build-tool compile=0 bytes=34396 sha256=a1bdecb08c74f89ddbd2bd674b224d21ed2a983268964972dd8f8ee701aa1c8d", + "PASS build-code-main compile=0 bytes=144120 sha256=6071fa6c28e12aa7846f48f9065718618a533ac0da9acb6ed3898797ed0b0dcd", + "PASS build-code-test compile=0 bytes=167240 sha256=a89bd509543ecdad68ffd947b37ea190ac488658aae8415568ff93ae4d25c07d", + "PASS code-unit exit=0 code checks=54 fail=0", + "PASS mutant cm1_path_unchecked exit=154 want=154 (killed)", + "PASS mutant cm2_old_not_once exit=103 want=103 (killed)", + "PASS mutant cm3_grammar_unchecked exit=162 want=162 (killed)", + "PASS mutant cm4_unverified_pass exit=168 want=168 (killed)", + "PASS mutant cm5_check_content exit=181 want=181 (killed)", + "PASS mutant cm6_exit_ignored exit=192 want=192 (killed)", + "PASS mutant cm7_turn_limit exit=202 want=202 (killed)", + "PASS mutant cm8_saved_unchecked exit=186 want=186 (killed)", + "PASS mutant cm9_notfound_any_state exit=171 want=171 (killed)", + "PASS mutant cm10_replace_any_state exit=157 want=157 (killed)", + "PASS mutant cm11_goal_text exit=151 want=151 (killed)", + "PASS mutant cm12_record_length exit=174 want=174 (killed)", + "PASS mutant cm13_cancel_unknown exit=197 want=197 (killed)", + "PASS mutant cm14_missing_as_read exit=178 want=178 (killed)", + "PASS mutant cm15_prompt_too_long exit=203 want=203 (killed)", + "PASS tool-replay TOOL-REPLAY runs=108 pass=108 fail=0 actions=417", + "PASS tool-dotdot got=s2 want=s2 ms=2 leaked=0 record=OMNT1 2 13 0|Path refused.", + "PASS tool-absolute got=s2 want=s2 ms=2 leaked=0 record=OMNT1 2 13 0|Path refused.", + "PASS tool-final-symlink got=s2 want=s2 ms=2 leaked=0 record=OMNT1 2 13 0|Path refused.", + "PASS tool-dir-symlink got=s2 want=s2 ms=2 leaked=0 record=OMNT1 2 13 0|Path refused.", + "PASS tool-missing got=s1 want=s1 ms=2 leaked=0 record=OMNT1 1 15 0|File not found.", + "PASS tool-over-3800 got=s3 want=s3 ms=2 leaked=0 record=OMNT1 3 24 0|File is over 3800 bytes.", + "PASS tool-read got=s0 want=s0 ms=2 leaked=0 record=OMNT1 0 15 75|Read succeeded.fn calc x int to int|ret add x int 3|end|fn main to int|ret calc int 5|", + "PASS tool-old-twice got=s5 want=s5 ms=2 leaked=0 record=OMNT1 5 33 75|Old text must occur exactly once.fn calc x int to int|ret add x int 3|end|fn main to i", + "PASS tool-old-empty got=s5 want=s5 ms=2 leaked=0 record=OMNT1 5 33 0|Old text must occur exactly once.", + "PASS tool-replace got=s0 want=s0 ms=10 leaked=0 record=OMNT1 0 11 75|Edit saved.fn calc x int to int|ret add x int 2|end|fn main to int|ret calc int 5|end|", + "PASS tool-check-pass got=s0 want=s0 ms=30 leaked=0 record=OMNT1 0 13 75|Tests passed.fn calc x int to int|ret add x int 2|end|fn main to int|ret calc int 5|en", + "PASS tool-check-wrong-k got=s6 want=s6 ms=15 leaked=0 record=OMNT1 6 39 75|Test failed: calc(5) expected 7, got 8.fn calc x int to int|ret add x int 3|end|fn mai", + "PASS tool-check-main got=s6 want=s6 ms=8 leaked=0 record=OMNT1 6 39 76|main must preserve the requested input.fn calc x int to int|ret add x int 2|end|fn mai", + "PASS tool-check-dup got=s6 want=s6 ms=7 leaked=0 record=OMNT1 6 21 116|omc: line 7: error 10fn calc x int to int|ret add x int 2|end|fn main to int|ret calc", + "PASS tool-check-no-end got=s6 want=s6 ms=8 leaked=0 record=OMNT1 6 21 71|omc: line 6: error 15fn calc x int to int|ret add x int 2|end|fn main to int|ret calc ", + "PASS tool-check-no-loop got=s6 want=s6 ms=8 leaked=0 record=OMNT1 6 22 75|Required loop missing.fn calc x int to int|ret add x int 2|end|fn main to int|ret calc", + "PASS tool-argc got=x2 want=x2 ms=2 leaked=0 record=", + "PASS tool-verb got=x2 want=x2 ms=2 leaked=0 record=", + "PASS tool-relative-work got=s4 want=s4 ms=2 leaked=0 record=OMNT1 4 10 0|I/O error.", + "PASS tool-slow-omc got=s4 want=s4 ms=10008 leaked=0 record=OMNT1 4 10 75|I/O error.fn calc x int to int|ret add x int 2|end|fn main to int|ret calc int 5|end|", + "PASS tool-replace-durable-no-temp a.om big.om dup.om e.om l.om ok.om syn.om z.om ", + "PASS agent-check exit=0 AGENT-CHECK PASS cases=34 mutants=8", + "PASS tree-unchanged-during-run", + "PASS count 50", + "FAIL count 0" + ], + "repeat": null +} diff --git a/evidence/node-code/receipt.dfb50228c1a597f776e7bea0dc6ae8de4903bc6d3f32a5582d67fa2a44649a15.json b/evidence/node-code/receipt.dfb50228c1a597f776e7bea0dc6ae8de4903bc6d3f32a5582d67fa2a44649a15.json new file mode 100644 index 000000000..9fcee7a47 --- /dev/null +++ b/evidence/node-code/receipt.dfb50228c1a597f776e7bea0dc6ae8de4903bc6d3f32a5582d67fa2a44649a15.json @@ -0,0 +1,49 @@ +{ + "issue": "DRA-290", + "source_commit": "fadf3288af0f5204fd5cda3366268b058e1600c6", + "source_tree": "2046ca4db04a62841acb12770d84e6a86701ce78", + "platform": "Linux 7.0.0-1019-nvidia aarch64 spark-b87b", + "cpu_affinity_mask_hex": "per run: one hive pool each (omega-node-run.sh), see the pool lines in each run log", + "execution": "NATIVE Linux AArch64 host CPU; own Omega model round40 (checkpoint sha256 7c7b5b52..., merges 73a29baf..., ollm f99fce9f... from aien-train 9edd881c) served by ollm serve inside bwrap --unshare-net on 127.0.0.1:18294; no GPU; :18091 untouched", + "timestamp_utc": "2026-11-07T04:39:08.552455+00:00", + "independent_review": false, + "native_aarch64": "PASS", + "spark_gate_judge": "NOT_RUN", + "live_hive": "NOT_DEPLOYED", + "script": "~/work/omega-node-290-live.sh (DRA-290 PR body: own-model live runs of omnode-code against aien-train ollm serve)", + "hashes": { + "/home/drakestapleton/.local/share/omega-tool-model/round40/model.ck": "7c7b5b5260f2d9453b6076b64e7f23e88341d96498584f2dfaa229c31ad2e346", + "/home/drakestapleton/.local/share/omega-tool-model/round40/merges.bin": "73a29baf97619a746a21232c403bf08af71a76e48b3b2cde6d64dab766083882", + "/home/drakestapleton/work/omega-node-ollm/ollm": "f99fce9fe914f51b708af5b39c8f07856bdcc6f4523dd43fa457f0d26aaa4745", + "/home/drakestapleton/work/omega-node-e5b3/seed/out/omc": "2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f", + "build/node/infer": "8cc5fb3044c9c794326e66b57aac7c6889c5cf498f4750503637d97505c1f806", + "build/node/tool": "a1bdecb08c74f89ddbd2bd674b224d21ed2a983268964972dd8f8ee701aa1c8d", + "build/node/code-main": "6071fa6c28e12aa7846f48f9065718618a533ac0da9acb6ed3898797ed0b0dcd", + "build/node/code-test": "a89bd509543ecdad68ffd947b37ea190ac488658aae8415568ff93ae4d25c07d" + }, + "checks": [], + "results": [ + "PASS infer-prompt0 prompt0 exit 0 ms 116188 OMNI1 1 1 90 35 17 0 0 48|jobs/item76666.om|{\"tool\":\"read_file\",\"path\":\"jobs/item76666.om\"}", + "PASS infer-testout-replace want=0 testout-replace exit 0 ms 3 OMNI1 3 1 90 52 9 7 7 74|jobs/a.omulong 2ulong 3{\"tool\":\"replace_text\",\"path\":\"jobs/a.om\",\"old\":\"ulong 2\",\"new\":\"ulong 3\"}", + "PASS infer-testout-tests-passed want=0 testout-tests-passed exit 0 ms 1 OMNI1 4 1 90 9 0 0 0 19|Tests passed.|Done.", + "PASS infer-testout-extra-key want=0 testout-extra-key exit 0 ms 2 OMNI1 9 1 90 29 0 0 0 41|{\"tool\":\"read_file\",\"path\":\"x\",\"extra\":1}", + "PASS infer-testout-prose want=0 testout-prose exit 0 ms 1 OMNI1 9 1 90 2 0 0 0 5|hello", + "PASS infer-testout-truncated want=0 testout-truncated exit 0 ms 2 OMNI1 9 2 90 8 0 0 0 11|{\"tool\":\"re", + "PASS infer-empty-prompt want=3 empty-prompt exit 3 ms 1 ", + "PASS infer-port-18091-refused want=2 port-18091-refused exit 2 ms 1 ", + "PASS infer-no-server want=4 no-server exit 4 ms 1 ", + "PASS infer-deadline-2s want=5 deadline-2s exit 5 ms 2017 ", + "PASS infer-busy-waits want=0 busy-waits exit 0 ms 175284 OMNI1 1 1 90 35 17 0 0 48|jobs/item76666.om|{\"tool\":\"read_file\",\"path\":\"jobs/item76666.om\"}", + "PASS infer-busy-5s want=5|8 busy-5s exit 5 ms 5011 ", + "PASS infer-busy-retried 503s=37 holder exit 0", + "PASS infer-kinds replace=3 tests-passed=4 extra-key=9 prose=9 truncated=9,fin=2", + "PASS workflow-4-objectives exit 0 ms 1632430 CWSUM pass=4 fail=0 COMPARE PASS", + "PASS workflow-journal records 116 opens 1 starts 29 ops 29 max_starts_per_op 1", + "PASS cancel-mid-inference exit 1 ms 20040 CWE 0 1001 1 1 CWE 0 1001 5 2 CWE 0 1001 4 2305 CWO 0 FAIL 19 1 serve: C 499 91 10 4 22072 ", + "PASS server-down exit 1 ms 37 CWE 0 1001 1 1 CWE 0 1001 4 262146 CWO 0 FAIL 16 1 ", + "PASS crash-restart run1 killed 137 run2 exit 0 ms 295826 run2: CWO 0 PASS 1 6 records 54 opens 2 starts 13 ops 13 max_starts_per_op 1 replace op (1054, 4, 1, 1) starts 1 done(outcome,how) (2, 1)", + "PASS count 19", + "FAIL count 0" + ], + "repeat": null +} diff --git a/seed/agent/.crumb b/seed/agent/.crumb index 67a6e99bd..9d78e274b 100644 --- a/seed/agent/.crumb +++ b/seed/agent/.crumb @@ -14,26 +14,26 @@ "children": [ { "digest": "7438334c8bac2ff0a0f5e4ac0db8d33fc1bb02ebd56cdef6dfd294fb2ed55ae2", - "last_commit": "5b39ef42", + "last_commit": "f56a372a", "name": "bench", "purpose": "Test-only equal-work benchmark of omagent against nanobot reduced to the same four tools: script" }, { - "digest": "d83674abfa647020999dde6f2a4fded1d42576c32fa06a398621d62f72e46f8a", - "last_commit": "116c3237", + "digest": "a6c05981e41643db53633ee3c6349d4873889d6b92bb413660bab08966a200ed", + "last_commit": "8215c6ca", "name": "tests", "purpose": "Directory tests. Purpose not yet described by a human." } ], - "children_root": "sha256:3056fbde3eb131e54f3a67106a1ed8e53d889920e987ad0117289615257d9081", - "compiled_at": "2026-10-26T21:07:01Z", + "children_root": "sha256:a507bc362f3a99780cd6557ae9f33a44d43739fd7f769f63fa05ecc672faa639", + "compiled_at": "2026-11-07T04:06:15Z", "compiler": "crumb-compile/1", - "digest": "sha256:ceefb1df61f0ff171468dcc0359e11d8d856e64960ab55eba03bcd61d0088daa", + "digest": "sha256:da15f08229e8413763737c200e48bc177d4aa197f1405159f975f16fd9513360", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 6, - "generated_at_commit": "ef7d78bdd0c5738c7dc9c5e9123f985d6e643950", - "source_tree": "sha256:c845b86d94d764c3c6df90c8cab98fcb5188abacb0c49d3c55f78b0683c29b68" + "files": 7, + "generated_at_commit": "fadf3288af0f5204fd5cda3366268b058e1600c6", + "source_tree": "sha256:462b24907bff738565b38d6ef3f6a5a9578bdbc243661deab004b70c4bf75e24" }, "owner_lane": "", "seed": { diff --git a/seed/agent/README.md b/seed/agent/README.md index 163aca560..2c5daca49 100644 --- a/seed/agent/README.md +++ b/seed/agent/README.md @@ -2,13 +2,15 @@ omagent is an agent harness in the style of HKUDS/nanobot (MIT), written in seeded Omega. Only nanobot's architecture was reused. None of its code was copied. The program is one -static ARM64 Linux executable (188,268 bytes with omc 2c824805) built from four sources: +static ARM64 Linux executable (191,608 bytes with omc 5f90edea) built from six sources: ```sh -{ printf 'om2\n'; cat seed/json/json.om seed/json/jsonw.om seed/net/http.om seed/agent/agent.om; } \ +{ printf 'om2\n'; cat seed/json/json.om seed/json/jsonw.om seed/net/http.om seed/net/notls.om seed/agent/path.om seed/agent/agent.om; } \ | seed/out/omc > omagent && chmod +x omagent ``` +`seed/agent/path.om` holds the workspace path rule (`agpathok`); the Omega Node tool adapter +`seed/node/tool.om` composes the same file, so both refuse the same paths. The only compiler needed is the pinned `seed/out/omc`. Every implementation byte is compiled from `.om`. Python appears only in the test referee `tests/check.py`, which also plays the mock model server. @@ -122,9 +124,13 @@ Adapters need TLS and are the natural home for omega-bridge or other universal a 4. **Commands are bounded.** - Children run with an empty environment and stdin on `/dev/null`. - stdout and stderr go to one close-on-exec pipe, and at most 64 KiB is kept. - - At the `--cmd-timeout` deadline (default 10 s), the child gets SIGKILL and is reaped. - - Grandchildren are not killed: there are no process groups yet. One that keeps the pipe - open only delays omagent until the deadline. + - Each command runs as the leader of its own process group (`setpgid` on both sides of the + fork, as in `seed/node/auth.om`). + - When the direct child exits, omagent reaps it and SIGKILLs the rest of its group, so a + background grandchild cannot outlive the call or hold the pipe open; the output read then + ends at end of file. The call returns within about 50 ms of the child's exit. + - At the `--cmd-timeout` deadline (default 10 s), the whole group gets SIGKILL and the child + is reaped. 5. **No secrets in logs.** - The API key is read from `OMAGENT_API_KEY` (or `--key-env NAME`), never from argv. It must be bytes 0x21..0x7e. @@ -177,11 +183,19 @@ kernel-chosen 127.0.0.1 port. It then runs 32 conversations: - malformed output: a bad event, a truncated stream, an error object, a bad call index, HTTP 500 - a model timeout, a command timeout and the round limit +- a command whose background grandchild must die when it exits (the call returns in under + 5 s with a 10 s `--cmd-timeout`), and a timed-out command whose child and grandchild must + both die; both scan `/proc` for survivors +- a command that closes its output, sleeps 0.3 s and exits 3 must report `[exit status 3]`: + end of file is not exit (`/bin/echo` closes stdout before it exits), so the group's SIGKILL + must not overtake a child that is still finishing - session reload, a corrupt session line, no key, two stdin lines, connection refused -Negative controls follow. Two wrong expectations must fail. Six source mutants must each be +Negative controls follow. Two wrong expectations must fail. Nine source mutants must each be caught: allowlist bypass, `..` allowed, symlink followed, fetch allowlist bypass, write flag -ignored, end of stream without `[DONE]` accepted. Output: `AGENT-CHECK PASS cases=32 mutants=6`. +ignored, end of stream without `[DONE]` accepted, SIGKILL to the direct child only (not its +group) after it exits or at the deadline, and end of file taken as the child's exit. Output: +`AGENT-CHECK PASS cases=35 mutants=9`. Exit 0 means PASS, 1 FAIL, and 3 NOT_RUN (no compiler). ## Host dependencies @@ -211,7 +225,7 @@ lines at this commit). Status: HAS (equivalent), PARTIAL (narrower), MISSING (ab | web fetch | `web_fetch` `agent/tools/web.py:1114` (https, redirects, extraction) | PARTIAL: plain `http://` to allowlisted HOST:PORT, raw body | `agtfetch` :2039 | | web search | `web_search` `web.py:367` | MISSING | | | workspace confinement | `restrictToWorkspace` `schema.py:401` (default off) | HAS (always on: no `..`, absolute paths or symlinks) | `agpathok` :1735 | -| command deny-list / timeouts | built-in deny-list `shell.py` ~213-232, timeout `:97` | PARTIAL: allowlist instead of deny-list; timeout kills the child only | `agexec` :1926, `--cmd-timeout` :81 | +| command deny-list / timeouts | built-in deny-list `shell.py` ~213-232, timeout `:97` | PARTIAL: allowlist instead of deny-list; timeout and child exit kill the whole process group | `agexec` :1957, `--cmd-timeout` :81 | | MCP client (stdio, SSE, streamable HTTP) | `agent/tools/mcp.py:1365,1412`, `schema.py:362` | MISSING | | | session history | `session/manager.py`, sessions dir | HAS (one JSONL file per `--session`) | `agsload` :1032, `agappend` :917 | | history compaction / consolidation | Consolidator and AutoCompact `agent/loop.py:433,443`, summaries `agent/memory.py:803-824` | PARTIAL: drops the oldest whole turns, no summaries | `agcompact` :896 | @@ -295,4 +309,4 @@ operator handoff `OmegaBot/eqbench2/` (the first, flawed run is in `OmegaBot/eqb - TLS model endpoints and fetches: NOT_RUN (refused by design in this build). - Real model servers (vLLM, llama.cpp, MAX): NOT_RUN. Only the scripted mock was used. -- One request at a time; no parallel tool calls; no process-group kill; the TOCTOU limit above. +- One request at a time; no parallel tool calls; the TOCTOU limit above. diff --git a/seed/agent/agent.om b/seed/agent/agent.om index e6c2b0684..71fa9aed3 100644 --- a/seed/agent/agent.om +++ b/seed/agent/agent.om @@ -1,5 +1,5 @@ note seed/agent/agent.om -- omagent: a small coding agent in seeded Omega (program mode). -note Compose: { printf 'om2\n'; cat seed/json/json.om seed/json/jsonw.om seed/net/http.om seed/agent/agent.om; } | seed/out/omc > omagent +note Compose: { printf 'om2\n'; cat seed/json/json.om seed/json/jsonw.om seed/net/http.om seed/net/notls.om seed/agent/path.om seed/agent/agent.om; } | seed/out/omc > omagent note Design, safety model, CLI and exit codes: seed/agent/README.md. Tests: seed/agent/tests/check.py. note The model is untrusted: every byte it sends is parsed by json.om/http.om under fixed caps, every note tool call is checked against permissions the operator gave on the command line, and the API key @@ -1705,59 +1705,7 @@ end ret n end -note agpathok: relative, every part nonempty and not . or .., no control bytes, and no part -note (checked with lstat, prefix by prefix) is a symbolic link -note agcomp: the part p[s, i) is not empty, . or .., and the prefix p[0, i) is not a symbolic link -fn agcomp p view uchar * s ulong i ulong to bool -cl = sub i s -if eq cl 0 -ret false -end -if eq get p s 46 -if eq cl 1 -ret false -end -if eq cl 2 -if eq get p add s 1 46 -ret false -end -end -end -st = new uchar 128 0 -r = lstat p 0 i st 0 128 -if lt r 0 -ret true -end -md = or ulong get st 16 shl ulong get st 17 8 -ret ne and md 61440 40960 -end - -fn agpathok p view uchar * to bool -n = len p -if or eq n 0 gt n 4095 -ret false -end -if eq get p 0 47 -ret false -end -s = ulong 0 -for i ulong add n 1 -c = uchar 47 -if lt i n -c = get p i -if or lt c 32 eq c 127 -ret false -end -end -if eq c 47 -if not agcomp p s i -ret false -end -s = add i 1 -end -end -ret true -end +note agpathok and agcomp, the workspace path rule, are in seed/agent/path.om (composed before this file). fn agtread ab view uchar 262144 tp view uint 65536 to void pb = new uchar 4096 0 @@ -1855,8 +1803,10 @@ end ret false end -note agspawn: fork and run the packed argv with stdout and stderr on a close-on-exec pipe and stdin -note on /dev/null; returns the child pid (the pipe's read end in gnum 22) or a negative errno +note agspawn: fork and run the packed argv as the leader of a new process group, stdout and +note stderr on a close-on-exec pipe and stdin on /dev/null. Both sides call setpgid, so the group +note exists before either goes on (as in seed/node/auth.om au_fork). Returns the child pid (the +note pipe's read end in gnum 22) or a negative errno fn agspawn pk view uchar 4096 pn ulong to long pf = new uchar 8 0 r = pipefds pf 0 8 524288 @@ -1868,6 +1818,7 @@ wfd = int or ulong get pf 4 shl ulong get pf 5 8 dn = fopen cdevnull 0 len cdevnull 524288 0 pid = fork if eq pid 0 +r = setpgid 0 0 r = dupfd wfd 1 0 r = dupfd wfd 2 0 if ge dn 0 @@ -1884,28 +1835,75 @@ if lt pid 0 r = fclose rfd ret pid end +r = setpgid int pid int pid put gnum 22 ulong rfd ret pid end +note agreap: reap the direct child without blocking; once it is gone (status in gnum 24, gnum 23 +note = 1) SIGKILL the rest of its process group, so a grandchild cannot outlive the tool call +fn agreap pid int to void +ws = new uchar 4 0 +if ne get gnum 23 0 +ret +end +g = waitpid pid ws 0 4 1 +if eq g long pid +put gnum 23 1 +put gnum 24 or ulong get ws 0 shl ulong get ws 1 8 +r = killpid neg pid 9 +end +end + +note agslice: the next wait in ns, the time left to deadline dl at most 50 ms +fn agslice dl ulong now ulong to long +if gt sub dl now 50000000 +ret 50000000 +end +ret long sub dl now +end + +note agwaitc: end of file only means every holder closed the pipe, not that the child exited +note (coreutils closes stdout before it exits). Reap the direct child first (agreap), polling every +note 2 ms until deadline dl, so the group's SIGKILL cannot overtake a child that already finished; +note true when the deadline passed first +fn agwaitc dl ulong to bool +for it ulong 999999999 +agreap int get gnum 25 +if ne get gnum 23 0 +ret false +end +now = ulong monons +if ge now dl +ret true +end +r = sleepns 2000000 +end +ret true +end + note agdrain: read the child's output into gres (at most 64 KiB kept) until end of file or the -note --cmd-timeout deadline; true on timeout +note --cmd-timeout deadline; true on timeout. It waits in 50 ms slices and calls agreap between +note them (child pid in gnum 25), so after the child exits its group dies and end of file arrives; +note at end of file it waits for the child itself (agwaitc) fn agdrain rfd int to bool buf = new uchar 4096 0 put gnum QRES 0 +put gnum 23 0 dl = add ulong monons get gnum QCTMO for it ulong 999999 now = ulong monons if ge now dl ret true end -wv = waitio rfd 1 long sub dl now +wv = waitio rfd 1 agslice dl now if eq wv 0 -ret true +agreap int get gnum 25 +continue end n = read rfd buf 0 4096 if eq n 0 -ret false +ret agwaitc dl end if lt n 0 if or eq n -4 eq n -11 @@ -1923,7 +1921,9 @@ end ret true end -note agexec: run the packed argv, collect its output, kill it (SIGKILL) at the deadline, reap it +note agexec: run the packed argv, collect its output and reap it. At the --cmd-timeout deadline +note the child's whole process group gets SIGKILL; when the child exits first, agdrain kills the +note group's remaining members, so no tool grandchild outlives the call either way fn agexec pk view uchar 4096 pn ulong to void ws = new uchar 4 0 pid = agspawn pk pn @@ -1933,11 +1933,13 @@ ret end rfd = int get gnum 22 put gnum QTST 0 +put gnum 25 ulong pid tmo = agdrain rfd -if tmo -r = killpid int pid 9 -end +r = killpid neg int pid 9 +if eq get gnum 23 0 r = waitpid int pid ws 0 4 0 +put gnum 24 or ulong get ws 0 shl ulong get ws 1 8 +end r = fclose rfd if ge get gnum QRES QRESC agradd rtrunc @@ -1949,7 +1951,7 @@ agrnum div get gnum QCTMO 1000000000 agradd rsec ret end -wst = or ulong get ws 0 shl ulong get ws 1 8 +wst = get gnum 24 if ne and wst 127 0 put gnum QTST 2 agradd rsig diff --git a/seed/agent/path.om b/seed/agent/path.om new file mode 100644 index 000000000..8694f2506 --- /dev/null +++ b/seed/agent/path.om @@ -0,0 +1,55 @@ +note seed/agent/path.om -- omagent's workspace path rule, shared by seed/agent/agent.om and the +note Omega Node tool adapter seed/node/tool.om (DRA-290). OM-2 unit, no globals; compose before its user. +note agpathok: relative, every part nonempty and not . or .., no control bytes, and no part +note (checked with lstat, prefix by prefix) is a symbolic link +note agcomp: the part p[s, i) is not empty, . or .., and the prefix p[0, i) is not a symbolic link +fn agcomp p view uchar * s ulong i ulong to bool +cl = sub i s +if eq cl 0 +ret false +end +if eq get p s 46 +if eq cl 1 +ret false +end +if eq cl 2 +if eq get p add s 1 46 +ret false +end +end +end +st = new uchar 128 0 +r = lstat p 0 i st 0 128 +if lt r 0 +ret true +end +md = or ulong get st 16 shl ulong get st 17 8 +ret ne and md 61440 40960 +end + +fn agpathok p view uchar * to bool +n = len p +if or eq n 0 gt n 4095 +ret false +end +if eq get p 0 47 +ret false +end +s = ulong 0 +for i ulong add n 1 +c = uchar 47 +if lt i n +c = get p i +if or lt c 32 eq c 127 +ret false +end +end +if eq c 47 +if not agcomp p s i +ret false +end +s = add i 1 +end +end +ret true +end diff --git a/seed/agent/tests/.crumb b/seed/agent/tests/.crumb index 5d76a32d8..4e0a65bc2 100644 --- a/seed/agent/tests/.crumb +++ b/seed/agent/tests/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-26T20:16:39Z", + "compiled_at": "2026-11-07T04:06:15Z", "compiler": "crumb-compile/1", - "digest": "sha256:d83674abfa647020999dde6f2a4fded1d42576c32fa06a398621d62f72e46f8a", + "digest": "sha256:a6c05981e41643db53633ee3c6349d4873889d6b92bb413660bab08966a200ed", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 1, - "generated_at_commit": "e07c7afb70dec01e9d8c9600b5ce7284321b8399", - "source_tree": "sha256:65110105d62eb3b2d571d43673b38bb1ea6ae5fd94338dbb031de23a03128d5b" + "generated_at_commit": "fadf3288af0f5204fd5cda3366268b058e1600c6", + "source_tree": "sha256:6c1d3125cb885e5fe51d4f0cec2cb72520d6dc068911f789237e0f8df4adbf45" }, "owner_lane": "", "seed": { diff --git a/seed/agent/tests/check.py b/seed/agent/tests/check.py index 793d1112d..a2f891599 100755 --- a/seed/agent/tests/check.py +++ b/seed/agent/tests/check.py @@ -26,7 +26,7 @@ import time HERE = os.path.dirname(os.path.abspath(__file__)) AGENT = os.path.dirname(HERE) ROOT = os.path.dirname(os.path.dirname(AGENT)) -SOURCES = ["seed/json/json.om", "seed/json/jsonw.om", "seed/net/http.om", "seed/agent/agent.om"] +SOURCES = ["seed/json/json.om", "seed/json/jsonw.om", "seed/net/http.om", "seed/net/notls.om", "seed/agent/path.om", "seed/agent/agent.om"] KEY = "sk-omagent-test-7f3a9c41d2e8b605" LOG = [] @@ -212,6 +212,34 @@ def no_file(rel): return lambda o: not os.path.exists(os.path.join(o["work"], rel)) +def no_survivor(marker): + """No process whose argv contains marker is alive (zombies have an empty cmdline). Polls up to + 1 s for SIGKILL delivery; any survivor found is killed so it cannot leak into later cases.""" + def f(o): + found = [] + for _ in range(20): + found = [] + for d in os.listdir("/proc"): + if not d.isdigit(): + continue + try: + with open("/proc/%s/cmdline" % d, "rb") as fh: + if marker.encode() in fh.read().split(b"\0"): + found.append(int(d)) + except OSError: + pass + if not found: + return True + time.sleep(0.05) + for p in found: + try: + os.kill(p, 9) + except OSError: + pass + return False + return f + + def no_key_leak(o): blob = o["out"] + o["err"] sess = os.path.join(o["work"], "s.jsonl") @@ -289,6 +317,11 @@ def cases(port): prep=lambda w: os.mkdir(os.path.join(w, "out"))), C("run-echo", [sse_calls([("run_command", '{"argv":["/bin/echo","hi","there"]}')]), sse_text("ran")], S + ["--allow-cmd", "/bin/echo"], 0, [last_tool_has("hi there\n"), last_tool_has("[exit status 0]")]), + # end of file is not exit: a child that closes its output and exits later (as /bin/echo + # does, closing stdout before it exits) must be reaped, not killed with its group + C("cmd-closes-output-early", [sse_calls([("run_command", '{"argv":["/bin/sh","-c","echo hi; exec >&- 2>&-; sleep 0.3; exit 3"]}')]), sse_text("ok")], + S + ["--allow-cmd", "/bin/sh", "--cmd-timeout", "10"], 0, + [last_tool_has("hi\n"), last_tool_has("[exit status 3]")]), C("run-exit-code", [sse_calls([("run_command", '{"argv":["/bin/false"]}')]), sse_text("ran")], S + ["--allow-cmd", "/bin/false"], 0, [last_tool_has("[exit status 1]")]), C("fetch", [sse_calls([("http_fetch", '{"url":"http://%s/page"}' % fetch)]), sse_text("fetched")], @@ -332,6 +365,14 @@ def cases(port): C("cmd-timeout", [sse_calls([("run_command", '{"argv":["/bin/sleep","30"]}')]), sse_text("ok")], S + ["--allow-cmd", "/bin/sleep", "--cmd-timeout", "1"], 0, [last_tool_has("[killed: timeout after 1 s]"), lambda o: o["dt"] < 10]), + # a tool's grandchild: the call returns when the direct child exits, and the group is killed + C("cmd-grandchild", [sse_calls([("run_command", '{"argv":["/bin/sh","-c","sleep 31.7 & echo hi"]}')]), sse_text("ok")], + S + ["--allow-cmd", "/bin/sh", "--cmd-timeout", "10"], 0, + [last_tool_has("hi"), last_tool_has("[exit status 0]"), lambda o: o["dt"] < 5, no_survivor("31.7")]), + C("cmd-timeout-group", [sse_calls([("run_command", '{"argv":["/bin/sh","-c","sleep 32.3 & sleep 32.4"]}')]), sse_text("ok")], + S + ["--allow-cmd", "/bin/sh", "--cmd-timeout", "1"], 0, + [last_tool_has("[killed: timeout after 1 s]"), lambda o: o["dt"] < 10, + no_survivor("32.3"), no_survivor("32.4")]), C("round-limit", [sse_calls([("read_file", '{"path":"a"}')])] * 3, S + ["--max-rounds", "2"], 7, [err_has("round limit"), nposts(2)], prep=prep_file("a", "A")), # sessions and configuration @@ -388,16 +429,22 @@ MUTANTS = [ ("fetch-allowlist-bypass", "if not agallowed IFET nf view part cn 0 cl", "if eq nf 999"), ("write-flag-ignored", "if eq get gnum QWRITE 0", "if eq get gnum QWRITE 7"), ("no-done-accepted", "if eq get gst SFIN 0\nagerr enodone\nret 6", "if eq get gst SFIN 7\nagerr enodone\nret 6"), + ("exit-kills-child-only", "r = killpid neg pid 9", "r = killpid pid 9"), + ("timeout-kills-child-only", "r = killpid neg int pid 9\nif eq get gnum 23 0", "r = killpid int pid 9\nif eq get gnum 23 0"), + ("eof-taken-as-exit", "if eq n 0\nret agwaitc dl\nend", "if eq n 0\nret false\nend"), ] def run_mutants(omc, port, base): - src0 = open(os.path.join(AGENT, "agent.om")).read() + texts = [open(os.path.join(ROOT, s)).read() for s in SOURCES] + own = [i for i, s in enumerate(SOURCES) if s.startswith("seed/agent/")] killed = 0 for name, a, b in MUTANTS: - if src0.count(a) != 1: - raise RuntimeError("mutant %s: anchor found %d times" % (name, src0.count(a))) - src = b"om2\n" + b"".join(open(os.path.join(ROOT, s), "rb").read() for s in SOURCES[:3]) + src0.replace(a, b).encode() + n = sum(texts[i].count(a) for i in own) + if n != 1: + raise RuntimeError("mutant %s: anchor found %d times" % (name, n)) + mt = [t.replace(a, b) if i in own else t for i, t in enumerate(texts)] + src = ("om2\n" + "".join(mt)).encode() p = subprocess.run([omc], input=src, capture_output=True) if p.returncode != 0: raise RuntimeError("mutant %s does not compile" % name) diff --git a/seed/authority/action-gate.om b/seed/authority/action-gate.om index 70144c35b..c6ec3e5b9 100644 --- a/seed/authority/action-gate.om +++ b/seed/authority/action-gate.om @@ -43,8 +43,8 @@ fn actbind r view ulong 32 c view ulong 32 to ulong for g ulong 6 diff = ulong 0 for j ulong 4 -at = add 8 add mul g 4 j -diff = or diff xor get r at get c at +ix = add 8 add mul g 4 j +diff = or diff xor get r ix get c ix end if ne diff 0 ret add 40 g diff --git a/seed/authority/action.om b/seed/authority/action.om index 81dc5cf22..3278e7582 100644 --- a/seed/authority/action.om +++ b/seed/authority/action.om @@ -43,8 +43,8 @@ fn actbind r view ulong 32 c view ulong 32 to ulong for g ulong 6 diff = ulong 0 for j ulong 4 -at = add 8 add mul g 4 j -diff = or diff xor get r at get c at +ix = add 8 add mul g 4 j +diff = or diff xor get r ix get c ix end if ne diff 0 ret add 40 g diff --git a/seed/node/.crumb b/seed/node/.crumb index 0079a1598..8225cd12b 100644 --- a/seed/node/.crumb +++ b/seed/node/.crumb @@ -3,14 +3,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-11-07T01:48:02Z", + "compiled_at": "2026-11-07T03:51:26Z", "compiler": "crumb-compile/1", - "digest": "sha256:bdef0cb529ba5b9ab6c363c18fd4e5ffa8522d8536572d763ca1c9c6270613f6", + "digest": "sha256:24501ac83754018dfd584d223112ae43ce47790ce8b9b15871fbc63a7bc317f1", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 17, - "generated_at_commit": "d429ab0296dedb53e3c824850a48453864fd6a47", - "source_tree": "sha256:f74ef1f7105e222bbe4662398a0142fbe688b45b344ff2ff3b3fc4cf7b2f97a4" + "files": 24, + "generated_at_commit": "507483cd8cb177015006ebcd7d95bd4ae792be56", + "source_tree": "sha256:2c9e620c185d3759a56e4dd7668b796f45515093fc7f2ed4e927bc24039be80c" }, "owner_lane": "", "seed": { diff --git a/seed/node/README.md b/seed/node/README.md index 416662ec2..bdbde47bd 100644 --- a/seed/node/README.md +++ b/seed/node/README.md @@ -1,4 +1,4 @@ -# Omega Node shared-memory transport, epoch pool, worker supervision, scheduling, authority and journal +# Omega Node shared-memory transport, epoch pool, worker supervision, scheduling, authority, journal and coding workflow This is the first implementation component of [Omega Node](https://github.com/aien-dev/omega-harness/issues/205). It provides a bounded, single-publisher artifact log for trusted forked Omega @@ -17,9 +17,13 @@ Source fragments, concatenated in this order before one program with `fn main`: | `seed/authority/action.om` | the existing action records the authority layer commits through | | `journal.om` | durable journal of every authority transition, fencing, restart recovery (DRA-289) | | `auth.om` | typed proposals, one commit owner, cancellation of real child tools, operator controls (DRA-288) | +| `gram.om` | the round40 repair grammar, shared by the tool and the creator (DRA-290) | +| `code.om` | the coding workflow: own-model turns, typed tool jobs, review (DRA-290) | -The component is not yet connected to the live hive. A dashboard and a real -model-backed coding workflow remain implementation work (DRA-290 to DRA-292). The +Two child programs serve the workflow as tools: `infer.om` (one model turn +against a local `ollm serve`) and `tool.om` (read, check, replace inside one +root). The component is not yet connected to the live hive. The operator +view and Spark qualification remain implementation work (DRA-291, DRA-292). The [Linear project](https://linear.app/drake-stapleton/project/omega-node-shared-memory-hive-runtime-37058a1eac4b) tracks that integration. This is a component contract, not a whole-system master plan. @@ -579,3 +583,140 @@ RELEASE per job, sink lines, keys): | `journal.om`: objective check removed | 151 | | `journal.om`: version and record-size check removed | 154 | | `auth.om`: `auth_recover` does not restore pause | 161 | + +## Local inference and the coding workflow (DRA-290) + +Status: IMPLEMENTED in `infer.om`, `tool.om`, `gram.om` and `code.om`, +exercised on native Linux AArch64 by `code-test.om`, the round40 replay +`tests/tool-replay.py`, the tool controls and live runs of the own Omega +model (round40 checkpoint served by aien-train `ollm serve`, DRA-119, inside a +private network namespace). Evidence is in the DRA-290 pull request. Not +QUALIFIED on the Spark and not DEPLOYED. + +All four are OM-2 programs (`printf 'om2\n'` before the sources): + +```sh +L="seed/node/transport.om seed/node/pool.om seed/node/super.om seed/node/sched.om seed/authority/action.om seed/node/journal.om seed/node/auth.om" +{ printf 'om2\n'; cat seed/json/json.om seed/json/jsonw.om seed/net/http.om seed/net/notls.om seed/node/infer.om; } | seed/out/omc > build/node/infer +{ printf 'om2\n'; cat seed/agent/path.om seed/node/gram.om seed/node/tool.om; } | seed/out/omc > build/node/tool +{ printf 'om2\n'; cat $L seed/node/gram.om seed/node/code.om seed/node/code-main.om; } | seed/out/omc > build/node/code-main +{ printf 'om2\n'; cat $L seed/node/gram.om seed/node/code.om seed/node/code-test.om; } | seed/out/omc > build/node/code-test +chmod +x build/node/infer build/node/tool build/node/code-main build/node/code-test +build/node/code-test unit build/node/cu # "code checks=54 fail=0", exit 0 +python3 seed/node/tests/tool-replay.py build/node/tool OMC40 ROUND40 build/node/replay # pass=108 fail=0 +``` + +A failed compile leaves an empty output file that exits 0 when run; check +omc's exit status. `OMC40` is the compiler the round40 model was trained and +evaluated with (sha256 `2c82480596bb…`, omega-mv `e5b32567`): its error text is +part of the prompt, so the check tool must use it. `ROUND40` is the round40 +run directory holding `repair.py` and `final-selected.json`. + +### Programs + +`omnode-code INFER TOOL OMC ROOT WORK JDIR PORT OBJ...` runs 1..4 objectives +`KIND,K,N,A,PATH,TASK` (KIND `add`, `mul` or `loop`) against the files under +ROOT, with the journal in JDIR and compile scratch in `WORK/o`. The creator +holds every objective's state and alone decides; two workers run the granted +jobs, each job one child process in its own process group (`auth_wtool`): + +| Job | Child | Input (packed argv published on the objective's topic) | +| --- | --- | --- | +| 1 inference | `infer PORT 160 900 PROMPT` | the prompt of `repair.py` for the current state | +| 2 read | `tool read ROOT PATH` | | +| 3 check, 5 review | `tool check ROOT PATH WORK/o OMC KIND K N A` | | +| 4 replace | `tool replace ROOT PATH OLD NEW` | old and new as the model gave them | + +`infer` (exit 2 usage, 3 prompt, 4 connect, 5 deadline, 6 HTTP status, 7 +malformed response, 8 busy) connects only to 127.0.0.1, refuses port 18091, +and posts one greedy, non-streamed `/v1/completions` request (aien-train +#76). The server takes one request at a time and keeps generating a few +seconds after a cancelled client is gone, so a 503 is asked again every +second within the deadline; exit 8 means busy until under 2 s were left. +Its record `OMNI1 kind fin ptok ctok plen olen nlen tlen` is followed by +path, old, new and the raw model text; kind 9 is text that is not a protocol +action. No other provider exists: there is no remote or fallback path, so +offline-local is the only mode. + +`tool` returns `OMNT1 status olen clen`, the observation and the file. Paths +pass `agpathok` (`seed/agent/path.om`, shared with omagent) and a final +symbolic link is refused; replace writes a temporary file, syncs, renames and +syncs the directory; check follows `repair.py compile_test` with the test +programs run under `execpure`, 10 s for omc and 2 s per test, killing the +whole process group on timeout. + +Policy (as `repair.py jobs_run`): at most 7 model turns; read_file only when +unread, omega_check only when read or edited, replace_text only when failed, +`Tests passed.` only when the last check passed, `File not found.` only when +the read found nothing; the path must be the objective's. Before a replace is +granted, the creator checks that old occurs exactly once in the source the +model was shown and that the result stays in the repair grammar (`gr_src`). +Every record is checked against its header lengths and the 3968-byte output +page. A check must return exactly the source the creator holds, a replace +exactly the candidate it computed. `Tests passed.` starts a review job, a +fresh check of the saved file, and only its pass is a PASS. Anything else +ends the objective as FAIL with its reason; nothing is retried or repaired. + +| Result | Meaning | +| --- | --- | +| 1 | PASS | +| 10, 11 | action not valid in its state; wrong path | +| 12 | 7 turns used | +| 13 | edit refused (old not exactly once, result outside the grammar, or the tool refused it) | +| 14 | `Tests passed.` without a passing check | +| 15 | the file checked or saved differs from the workflow's source or candidate | +| 16, 17 | inference or tool exited nonzero (no fallback) | +| 18 | malformed record | +| 19 | cancelled (operator `auth_cancel`, or the authority's cancel verdict) | +| 20 | prompt over 3800 bytes | +| 21 | outcome UNKNOWN (a worker or child lost) | +| 22, 23 | job input lost; refused by the authority | + +Output: `CWP i turn n` and `CWR i turn n` lines, each followed by n bytes +(the prompt; the model text) and a newline; `CWE i job event value` job +events (1 issued, 2 model action kind, 3 tool status, 4 outcome word, 5 +cancel); `CWO i PASS|FAIL result turns`; `CWSUM pass= fail=`. Exit 0 when +every objective passed, 1 otherwise, 2 usage, 62 out of time, 30 + a journal +refusal. + +Restart: the journal's objective identity is the objective arguments' FNV-1a +64. On a restart `auth_recover` settles what the last creator left (an +in-flight replace is UNKNOWN and never rerun); the creator cancels recovered +jobs that still wait for input (pool contents are not journaled), and each +objective resumes from the durable file in state unread with its performed +model turns counted against its 7 and its job ids continuing. + +Limits: one inference at a time (one local server); 64 action records per +creator process bound a run to about 4 objectives; lines are split on `\n` +only, so a `\r` makes a line fall outside the grammar where Python's +`splitlines` would split it. + +### Acceptance and controls + +`code-test unit` (54 checks, no child process) feeds crafted model and tool +records to the creator: the round40 prompts byte for byte; every action in +every state; wrong path; old text absent, twice, many times; an edit outside +the grammar; `Tests passed.` unverified or after an edit; `File not found.` +when not missing; header and length faults; tool content that differs from +the source or candidate; outcome words for exit 4, 5 and 8, a killed child, +cancellation, UNKNOWN and a lost input; the turn limit; an over-long prompt. +`code-test cancel MS ...` is `omnode-code` with objective 0's first inference +cancelled through `auth_cancel` after MS milliseconds. + +| Change to `code.om` | Expected exit | +| --- | --- | +| path not compared | 154 | +| old text not required exactly once | 103 (trap) | +| grammar of the result not checked | 162 | +| `Tests passed.` accepted unverified | 168 | +| checked content not compared | 181 | +| child exit status ignored | 192 | +| 8 turns allowed | 202 | +| saved content not compared | 186 | +| `File not found.` accepted in any state | 171 | +| replace accepted in any state | 157 | +| goal text changed | 151 | +| record length not checked against the page | 174 | +| cancelled read as UNKNOWN | 197 | +| missing file read as read | 178 | +| prompt limit raised to 4000 | 203 | diff --git a/seed/node/auth-gate.om b/seed/node/auth-gate.om index c826a9481..d410104de 100644 --- a/seed/node/auth-gate.om +++ b/seed/node/auth-gate.om @@ -1400,8 +1400,8 @@ fn actbind r view ulong 32 c view ulong 32 to ulong for g ulong 6 diff = ulong 0 for j ulong 4 -at = add 8 add mul g 4 j -diff = or diff xor get r at get c at +ix = add 8 add mul g 4 j +diff = or diff xor get r ix get c ix end if ne diff 0 ret add 40 g @@ -2241,7 +2241,7 @@ jn_hit 5 ret sched_review j end -fn jn_start op view ulong 4 cl ulong id ulong at ulong g ulong to ulong +fn jn_start op view ulong 4 cl ulong id ulong att ulong g ulong to ulong r = new ulong 16 0 put r 0 3 for i ulong 4 @@ -2249,7 +2249,7 @@ put r add 3 i get op i end put r 7 cl put r 8 id -put r 9 at +put r 9 att put r 10 g ret jn_append r end diff --git a/seed/node/code-main.om b/seed/node/code-main.om new file mode 100644 index 000000000..80042c8b4 --- /dev/null +++ b/seed/node/code-main.om @@ -0,0 +1,7 @@ +note seed/node/code-main.om -- omnode-code, the coding workflow program: +note omnode-code INFER TOOL OMC ROOT WORK JDIR PORT OBJ [OBJ...] +note with 1..4 objectives "KIND,K,N,A,PATH,TASK" and absolute paths (see +note seed/node/code.om). One hour for the whole run. +fn main to int +ret cw_main 1 3600 +end diff --git a/seed/node/code-test.om b/seed/node/code-test.om new file mode 100644 index 000000000..e04db8ecc --- /dev/null +++ b/seed/node/code-test.om @@ -0,0 +1,489 @@ +note seed/node/code-test.om -- checks of the coding workflow (DRA-290). +note omnode-code-test unit JDIR: the creator's decisions on crafted model +note and tool records, no child process; prints "code checks=N fail=F" and +note exits 0, or 150 + the number of the first failing check. +note omnode-code-test cancel MS INFER TOOL OMC ROOT WORK JDIR PORT OBJ...: +note omnode-code with objective 0's first inference cancelled through +note auth_cancel once it has run MS milliseconds. +text ctunit "unit" +text ctcanc "cancel" +text ctobj "loop,4,3,70,jobs/item76666.om,Fix the error in this file and confirm its goal." +text ctpath "jobs/item76666.om" +text ctbadp "jobs/item76667.om" +text ctsrc "fn calc x int to int\ns = x\nfor i ulong 2\ns = add s int 4\nend\nret s\nend\nfn main to int\nret calc int 70\nend\n" +text ctfix "fn calc x int to int\ns = x\nfor i ulong 3\ns = add s int 4\nend\nret s\nend\nfn main to int\nret calc int 70\nend\n" +text ctold "ulong 2" +text ctnew "ulong 3" +text ctnone "ulong 9" +text ctdup "int 4" +text ctdup2 "s" +text ctgar "ulong 3 x" +text ctrs "Read succeeded." +text ctfnf "File not found." +text cttf "Test failed: calc(70) expected 82, got 78." +text ctes "Edit saved." +text cttp "Tests passed." +text ctp0 "Task: Fix the error in this file and confirm its goal.\nFile: jobs/item76666.om\nGoal: calc starts with x and adds 4 exactly 3 times in a for loop. main calls calc with 70.\nState: unread\nAnswer:\n" +text ctp2 "Task: Fix the error in this file and confirm its goal.\nFile: jobs/item76666.om\nGoal: calc starts with x and adds 4 exactly 3 times in a for loop. main calls calc with 70.\nState: failed\nSource:\nfn calc x int to int\ns = x\nfor i ulong 2\ns = add s int 4\nend\nret s\nend\nfn main to int\nret calc int 70\nend\nTool result: Test failed: calc(70) expected 82, got 78.\nAnswer:\n" +text ctfl "code-test check " +text ctfl2 " FAIL\n" +text ctsum "code checks=" +text ctsum2 " fail=" +text ctomni "OMNI1 " +text ctomnt "OMNT1 " +global ctn ulong 3 +global ctc ulong 1 + +note The creator's pool handle, kept for the record helpers. +fn ct_c to long +ret long get ctc 0 +end + +fn ct_ok b bool to void +put ctn 0 add get ctn 0 1 +if b +ret +end +put ctn 1 add get ctn 1 1 +if eq get ctn 2 0 +put ctn 2 get ctn 0 +end +o = new uchar 4096 0 +p = cw_cat o 0 ctfl +p = cw_dec o p get ctn 0 +p = cw_cat o p ctfl2 +cw_out o p +end + +note Objective 0 in state st (verified vf), its source sel (0 none, 1 the +note broken source, 2 the fixed one), no job, running. +fn ct_set st ulong vf ulong sel ulong to void +cw_s 0 6 st +cw_s 0 8 vf +cw_s 0 9 0 +cw_s 0 10 0 +cw_s 0 12 0 +cw_s 0 13 0 +cw_s 0 14 0 +put cwinf 0 0 +if eq sel 1 +cw_setsrc 0 ctsrc +end +if eq sel 2 +cw_setsrc 0 ctfix +end +end + +note The objective's state: result r and, when r is 0, a job of kind k in +note flight (k 0: none). +fn ct_is r ulong k ulong to bool +if ne cw_g 0 12 r +ret false +end +if ne r 0 +ret true +end +if eq k 0 +ret eq cw_g 0 10 0 +end +id = cw_g 0 10 +ret and gt id 0 and eq rem id 10 k jn_known id +end + +note Record texts by index: 0 path, 1 another path, 2 old, 3 new, 4 old +note text not in the source, 5 old text twice in it, 6 old text many times, +note 7 new text outside the grammar. Appended to b at p; the new length. +fn ct_cat b edit uchar 4096 p ulong s ulong to ulong +if eq s 0 +ret cw_cat b p ctpath +end +if eq s 1 +ret cw_cat b p ctbadp +end +if eq s 2 +ret cw_cat b p ctold +end +if eq s 3 +ret cw_cat b p ctnew +end +if eq s 4 +ret cw_cat b p ctnone +end +if eq s 5 +ret cw_cat b p ctdup +end +if eq s 6 +ret cw_cat b p ctdup2 +end +ret cw_cat b p ctgar +end + +fn ct_len s ulong to ulong +b = new uchar 4096 0 +ret ct_cat b 0 s +end + +fn ct_nums b edit uchar 4096 p ulong a ulong o ulong to ulong +q = cw_cat b p cwsp +q = cw_dec b q 1 +q = cw_cat b q cwsp +q = cw_dec b q 100 +q = cw_cat b q cwsp +q = cw_dec b q 12 +q = cw_cat b q cwsp +q = cw_dec b q a +q = cw_cat b q cwsp +q = cw_dec b q o +ret q +end + +fn ct_tail b edit uchar 4096 p ulong nl ulong tl ulong to ulong +q = cw_cat b p cwsp +q = cw_dec b q nl +q = cw_cat b q cwsp +q = cw_dec b q tl +ret cw_cat b q cwnl +end + +note The model's action k on path text pa, replacing text ol by text nw +note (indices for ct_cat); the raw text is two newlines. +fn ct_act k ulong pa ulong ol ulong nw ulong to void +b = new uchar 4096 0 +p = cw_cat b 0 ctomni +p = cw_dec b p k +p = ct_nums b p ct_len pa ct_len ol +p = ct_tail b p ct_len nw 2 +p = ct_cat b p pa +p = ct_cat b p ol +p = ct_cat b p nw +p = cw_cat b p cwnl +p = cw_cat b p cwnl +cw_ires ct_c 0 b +end + +note A plain answer (Tests passed., File not found.) of kind k. +fn ct_ans k ulong a view uchar * to void +b = new uchar 4096 0 +p = cw_cat b 0 ctomni +p = cw_dec b p k +p = ct_nums b p 0 0 +p = ct_tail b p 0 len a +p = cw_cat b p a +cw_ires ct_c 0 b +end + +note A tool record of job kind k: status st, observation ob, content ct. +fn ct_tool k ulong st ulong ob view uchar * ct view uchar * to void +b = new uchar 4096 0 +p = cw_cat b 0 ctomnt +p = cw_dec b p st +p = cw_cat b p cwsp +p = cw_dec b p len ob +p = cw_cat b p cwsp +p = cw_dec b p len ct +p = cw_cat b p cwnl +p = cw_cat b p ob +p = cw_cat b p ct +cw_tres ct_c 0 k b +end + +fn ct_prompt to void +o = new uchar 4096 0 +ct_set 0 0 0 +n = cw_prmt o 0 +ct_ok cw_eq view part o 0 n ctp0 +ct_set 2 0 1 +cw_seto 0 cttf +n = cw_prmt o 0 +ct_ok cw_eq view part o 0 n ctp2 +end + +note Model actions against the policy. +fn ct_model to void +ct_set 0 0 0 +ct_act 1 0 2 3 +ct_ok ct_is 0 2 +ct_set 0 0 0 +ct_act 1 1 2 3 +ct_ok ct_is 11 0 +ct_set 0 0 0 +ct_act 2 0 2 3 +ct_ok ct_is 10 0 +ct_set 0 0 0 +ct_act 9 0 2 3 +ct_ok ct_is 10 0 +ct_set 1 0 1 +ct_act 3 0 2 3 +ct_ok ct_is 10 0 +ct_set 1 0 1 +ct_act 2 0 2 3 +ct_ok ct_is 0 3 +ct_set 3 0 2 +ct_act 2 0 2 3 +ct_ok ct_is 0 3 +ct_set 4 1 2 +ct_act 2 0 2 3 +ct_ok ct_is 10 0 +ct_edits +ct_answers +end + +fn ct_edits to void +u = new uchar 4096 0 +ct_set 2 0 1 +ct_act 3 0 4 3 +ct_ok ct_is 13 0 +ct_set 2 0 1 +ct_act 3 0 5 3 +ct_ok ct_is 13 0 +ct_set 2 0 1 +ct_act 3 0 6 3 +ct_ok ct_is 13 0 +ct_set 2 0 1 +ct_act 3 0 2 7 +ct_ok ct_is 13 0 +ct_set 2 0 1 +ct_act 3 1 2 3 +ct_ok ct_is 11 0 +ct_set 2 0 1 +ct_act 3 0 2 3 +ct_ok ct_is 0 4 +n = cw_ld u 4 0 +ct_ok cw_eq view part u 0 n ctfix +end + +fn ct_answers to void +ct_set 4 0 1 +ct_ans 4 cttp +ct_ok ct_is 14 0 +ct_set 3 0 2 +ct_ans 4 cttp +ct_ok ct_is 14 0 +ct_set 4 1 2 +ct_ans 4 cttp +ct_ok ct_is 0 5 +ct_set 0 0 0 +ct_ans 5 ctfnf +ct_ok ct_is 10 0 +ct_set 5 0 0 +ct_ans 5 ctfnf +ct_ok ct_is 1 0 +end + +note Malformed model records. +fn ct_bad to void +b = new uchar 4096 0 +ct_set 0 0 0 +p = cw_cat b 0 ctomnt +cw_ires ct_c 0 b +ct_ok ct_is 18 0 +ct_set 0 0 0 +p = cw_cat b 0 ctomni +p = cw_dec b p 4 +p = ct_nums b p 0 0 +p = ct_tail b p 0 3969 +cw_ires ct_c 0 b +ct_ok ct_is 18 0 +ct_set 0 0 0 +p = cw_cat b 0 ctomni +p = cw_dec b p 4 +p = cw_cat b p cwnl +cw_ires ct_c 0 b +ct_ok ct_is 18 0 +end + +note Tool records. +fn ct_tools to void +u = new uchar 4096 0 +ct_set 0 0 0 +ct_tool 2 0 ctrs ctsrc +ct_ok and ct_is 0 0 eq cw_g 0 6 1 +n = cw_ld u 2 0 +ct_ok cw_eq view part u 0 n ctsrc +ct_set 0 0 0 +ct_tool 2 1 ctfnf ctes +ct_ok and ct_is 0 0 eq cw_g 0 6 5 +ct_set 0 0 0 +ct_tool 2 2 ctfnf ctes +ct_ok ct_is 17 0 +ct_set 1 0 1 +ct_tool 3 6 cttf ctsrc +ct_ok and ct_is 0 0 and eq cw_g 0 6 2 eq cw_g 0 8 0 +ct_set 1 0 1 +ct_tool 3 6 cttf ctfix +ct_ok ct_is 15 0 +ct_set 3 0 2 +ct_tool 3 0 cttp ctfix +ct_ok and ct_is 0 0 and eq cw_g 0 6 4 eq cw_g 0 8 1 +ct_set 3 0 2 +ct_tool 3 4 cttp ctfix +ct_ok ct_is 17 0 +ct_saves +end + +fn ct_saves to void +ct_set 2 0 1 +ct_act 3 0 2 3 +ct_ok ct_is 0 4 +cw_s 0 10 0 +ct_tool 4 0 ctes ctfix +ct_ok and ct_is 0 0 eq cw_g 0 6 3 +ct_set 2 0 1 +cw_s 0 15 0 +ct_tool 4 0 ctes ctfix +ct_ok ct_is 15 0 +ct_set 2 0 1 +ct_tool 4 5 ctes ctsrc +ct_ok ct_is 13 0 +ct_set 4 1 2 +ct_tool 5 0 cttp ctfix +ct_ok ct_is 1 0 +ct_set 4 1 2 +ct_tool 5 6 cttf ctfix +ct_ok ct_is 15 0 +ct_set 4 1 2 +ct_tool 5 0 cttp ctsrc +ct_ok ct_is 15 0 +end + +note Job outcome words. +fn ct_fates to void +ct_ok eq cw_fate 2 1 0 +ct_ok eq cw_fate or ulong 2 shl ulong 1024 8 1 16 +ct_ok eq cw_fate or ulong 2 shl ulong 1280 8 1 16 +ct_ok eq cw_fate or ulong 2 shl ulong 2048 8 1 16 +ct_ok eq cw_fate or ulong 2 shl ulong 256 8 3 17 +ct_ok eq cw_fate or ulong 2 shl ulong 9 8 1 21 +ct_ok eq cw_fate or ulong 1 shl ulong 9 8 1 19 +ct_ok eq cw_fate 22 1 19 +ct_ok eq cw_fate 0 4 21 +ct_ok eq cw_fate 90 2 22 +ct_ok eq cw_fate 18 2 23 +end + +note Turn limit and prompt length. +fn ct_limits c long to void +sp = new uchar 4096 0 +ct_set 1 0 0 +cw_s 0 7 7 +cw_plan c +ct_ok ct_is 12 0 +for j ulong 3790 +put sp j 32 +end +ct_set 1 0 0 +cw_setsrc 0 view part sp 0 3790 +cw_s 0 7 0 +cw_plan c +ct_ok ct_is 20 0 +ct_set 0 0 0 +cw_plan c +ct_ok and ct_is 0 1 eq cw_g 0 7 1 +end + +fn ct_unit to int +d = new uchar 1024 0 +n = argread 2 d 0 1000 +if lt n 1 +ret 2 +end +for k ulong 7 +put cwcl k 1 +put cwcf mul k 1024 47 +end +for j ulong ulong n +put cwcf add 5120 j get d j +end +put cwcl 5 ulong n +put cwno 0 1 +if not cw_parse 0 ctobj +ret 3 +end +c = pool_new 4 2 +if le c 0 +ret 50 +end +put ctc 0 ulong c +if ne sup_init c 0 +ret 51 +end +if ne sched_new c 8 8 0 +ret 52 +end +if ne auth_new c 0 +ret 53 +end +e = cw_jopen 1 1 +if ne e 0 +ret int add 30 e +end +ct_prompt +ct_model +ct_bad +ct_tools +ct_fates +ct_limits c +jn_close +ret ct_end +end + +fn ct_end to int +o = new uchar 4096 0 +p = cw_cat o 0 ctsum +p = cw_dec o p get ctn 0 +p = cw_cat o p ctsum2 +p = cw_dec o p get ctn 1 +p = cw_cat o p cwnl +cw_out o p +if eq get ctn 1 0 +ret 0 +end +ret int add 150 get ctn 2 +end + +fn ct_mode to ulong +b = new uchar 16 0 +n = argread 1 b 0 16 +if lt n 1 +ret 0 +end +if cw_eq view part b 0 ulong n ctunit +ret 1 +end +if cw_eq view part b 0 ulong n ctcanc +ret 2 +end +ret 0 +end + +fn main to int +m = ct_mode +if eq m 1 +ret ct_unit +end +if eq m 2 +ms = ct_num 2 +put cwtk 0 1 +put cwtk 1 ms +ret cw_main 3 3600 +end +ret 2 +end + +note Argument i as a decimal of at most 7 digits; 0 when malformed. +fn ct_num i ulong to ulong +b = new uchar 16 0 +n = argread i b 0 16 +if or lt n 1 gt n 7 +ret 0 +end +v = ulong 0 +for j ulong ulong n +c = ulong get b j +if or lt c 48 gt c 57 +ret 0 +end +v = add mul v 10 sub c 48 +end +ret v +end diff --git a/seed/node/code.om b/seed/node/code.om new file mode 100644 index 000000000..1f1403f91 --- /dev/null +++ b/seed/node/code.om @@ -0,0 +1,1297 @@ +note seed/node/code.om -- the Omega Node coding workflow (DRA-290): the +note round40 repair protocol (read, check, edit, check again, answer) driven +note by the own Omega model through the Node's scheduler, authority and +note journal. OM-2. Compose after transport.om, pool.om, super.om, sched.om, +note seed/authority/action.om, journal.om, auth.om, seed/node/gram.om, and +note before one program with fn main (code-main.om or code-test.om). +note Processes. The creator holds every objective's state; it alone reads +note model output and decides. Two workers run granted jobs, each one child +note process in its own process group (auth_wtool): omnode-infer for a model +note turn, omnode-tool for read_file, omega_check and replace_text, and a +note review (a fresh omnode-tool check of the edited file). A job's input is +note the packed argv the creator published on the objective's topic bit; +note the worker proposes it, the creator grants it (generation, staleness, +note cancellation, journal START), the worker runs it and returns the +note child's record (OMNI1 or OMNT1, at most 3968 bytes) with the outcome. +note One inference at a time: the provider is a single local ollm serve. +note A turn has 160 new tokens (as round40 sampled) and 900 s, since the CPU +note server needs minutes for a long prompt on a shared host. +note Policy, as round40 repair.py jobs_run: at most 7 model turns; the action +note must name the objective's path; read_file only when unread, omega_check +note only when read or edited, replace_text only when failed, whose old text +note must occur exactly once in the source the model was shown and whose +note result must stay in the repair grammar (checked here before the grant); +note Tests passed. only when the last check passed (then a review job runs), +note File not found. only when the read found no file. Anything else ends +note the objective as failed; nothing is repaired or retried. +note Results: 1 PASS; failures 10 action not valid in its state, 11 wrong +note path, 12 out of turns, 13 edit refused, 14 Tests passed. unverified, +note 15 the file differs from the workflow's source, 16 inference failed +note (exit status in the event line; no fallback), 17 tool failed, 18 +note malformed record, 19 cancelled, 20 prompt too long, 21 outcome UNKNOWN, +note 22 job input lost, 23 refused by the authority. +note Restart: the journal releases what the last creator left (auth_recover); +note jobs still waiting for input are cancelled; each objective resumes from +note the durable workspace in state unread, with the model turns already +note performed counted against its 7 and its job ids continuing. +note Events on stdout, one line each: CWP (prompt) and CWR (model text) are +note followed by their bytes and a newline; CWE job events; CWO results. +const CWOBJ ulong 4 +text cwtask "Task: " +text cwfile "\nFile: " +text cwgoal "\nGoal: " +text cwstat "\nState: " +text cwsrcl "Source:\n" +text cwtres "Tool result: " +text cwansw "Answer:\n" +text cwnl "\n" +text cwsp " " +text cwgl1 "calc starts with x and adds " +text cwgl2 " exactly " +text cwgl3 " times in a for loop. main calls calc with " +text cwgl4 "calc returns x " +text cwplus "plus " +text cwtims "times " +text cwgl5 ". main calls calc with " +text cwdot "." +text cwsun "unread" +text cwsrd "read" +text cwsfl "failed" +text cwsed "edited" +text cwsck "checked" +text cwsms "missing" +text cwvrd "read" +text cwvck "check" +text cwvrp "replace" +text cwmax "160" +text cwdl "900" +text cwo "/o" +text cwadd "add" +text cwmul "mul" +text cwloop "loop" +text cwhi "OMNI1 " +text cwht "OMNT1 " +text cwep "CWP " +text cwer "CWR " +text cwee "CWE " +text cweo "CWO " +text cwpass "PASS" +text cwfail "FAIL" +text cwsum "CWSUM pass=" +text cwsumf " fail=" +global cwcf uchar 8192 +global cwcl ulong 8 +global cwno ulong 1 +global cwos uchar 2048 +global cwob ulong 64 +global cwsrc uchar 16384 +global cwobs uchar 4096 +global cwcan uchar 16384 +global cwinf ulong 1 +global cwgot ulong 64 +global cwt0 ulong 4 +global cwtk ulong 2 + +note ======== objective words: cwob[16 i + w]: 0 kind (1 add, 2 mul, 3 loop), +note 1 K, 2 N, 3 A, 4 path length, 5 task length, 6 state (0 unread, 1 read, +note 2 failed, 3 edited, 4 checked, 5 missing), 7 model turns, 8 verified, +note 9 phase (0 needs a turn, 1 inference, 2 tool, 3 review, 4 finished), +note 10 job in flight, 11 next job seq, 12 result, 13 source length, 14 +note observation length, 15 candidate length. +fn cw_g i ulong w ulong to ulong +ret get cwob add mul i 16 w +end + +fn cw_s i ulong w ulong v ulong to void +put cwob add mul i 16 w v +end + +note ======== bytes + +fn cw_out o view uchar * n ulong to void +p = ulong 0 +for it ulong 65536 +if ge p n +ret +end +r = write 1 o p sub n p +if le r 0 +ret +end +p = add p ulong r +end +end + +note Append a to o at p; past 4096 bytes the result is 5000 (overflow), and +note an overflowed p stays overflowed. +fn cw_cat o edit uchar 4096 p ulong a view uchar * to ulong +if gt add p len a 4096 +ret 5000 +end +for i ulong len a +put o add p i get a i +end +ret add p len a +end + +fn cw_dec o edit uchar 4096 p ulong v ulong to ulong +d = new uchar 24 0 +k = ulong 0 +x = v +for i ulong 24 +put d k uchar add 48 rem x 10 +k = add k 1 +x = div x 10 +if eq x 0 +break +end +end +if gt add p k 4096 +ret 5000 +end +for j ulong k +put o add p j get d sub sub k j 1 +end +ret add p k +end + +fn cw_eq a view uchar * b view uchar * to bool +if ne len a len b +ret false +end +for i ulong len a +if ne get a i get b i +ret false +end +end +ret true +end + +note Occurrences of a in s, without overlap. +fn cw_count s view uchar * a view uchar * to ulong +c = ulong 0 +i = ulong 0 +for it ulong add len s 1 +if gt add i len a len s +ret c +end +if cw_eq view part s i len a a +c = add c 1 +i = add i len a +else +i = add i 1 +end +end +ret c +end + +note ======== prompt (repair.py prompt and goal) + +fn cw_sname o edit uchar 4096 p ulong st ulong to ulong +if eq st 0 +ret cw_cat o p cwsun +end +if eq st 1 +ret cw_cat o p cwsrd +end +if eq st 2 +ret cw_cat o p cwsfl +end +if eq st 3 +ret cw_cat o p cwsed +end +if eq st 4 +ret cw_cat o p cwsck +end +ret cw_cat o p cwsms +end + +fn cw_goal o edit uchar 4096 p ulong i ulong to ulong +if eq cw_g i 0 3 +q = cw_cat o p cwgl1 +q = cw_dec o q cw_g i 1 +q = cw_cat o q cwgl2 +q = cw_dec o q cw_g i 2 +q = cw_cat o q cwgl3 +q = cw_dec o q cw_g i 3 +ret cw_cat o q cwdot +end +q = cw_cat o p cwgl4 +if eq cw_g i 0 1 +q = cw_cat o q cwplus +else +q = cw_cat o q cwtims +end +q = cw_dec o q cw_g i 1 +q = cw_cat o q cwgl5 +q = cw_dec o q cw_g i 3 +ret cw_cat o q cwdot +end + +note Globals are never call arguments, so text kept in them is copied into +note a local first. sel: 0 path, 1 task, 2 source, 3 observation, 4 edit +note candidate of objective i; 10 + k config slot k. The length. +fn cw_ld d edit uchar 4096 sel ulong i ulong to ulong +if le sel 1 +n = cw_g i add 4 sel +b = add mul i 512 mul sel 128 +for j ulong n bound 4096 +put d j get cwos add b j +end +ret n +end +if eq sel 2 +n2 = cw_g i 13 +for j2 ulong n2 bound 4096 +put d j2 get cwsrc add mul i 4096 j2 +end +ret n2 +end +if eq sel 3 +n3 = cw_g i 14 +for j3 ulong n3 bound 1024 +put d j3 get cwobs add mul i 1024 j3 +end +ret n3 +end +if eq sel 4 +n4 = cw_g i 15 +for j4 ulong n4 bound 4096 +put d j4 get cwcan add mul i 4096 j4 +end +ret n4 +end +k = sub sel 10 +n5 = get cwcl k +for j5 ulong n5 bound 1024 +put d j5 get cwcf add mul k 1024 j5 +end +ret n5 +end + +note Append loaded item sel of objective i to o at p. +fn cw_catl o edit uchar 4096 p ulong sel ulong i ulong to ulong +t = new uchar 4096 0 +n = cw_ld t sel i +ret cw_cat o p view part t 0 n +end + +note The prompt of objective i in its current state; length, 5000 overflow. +fn cw_prmt o edit uchar 4096 i ulong to ulong +p = cw_cat o 0 cwtask +p = cw_catl o p 1 i +p = cw_cat o p cwfile +p = cw_catl o p 0 i +p = cw_cat o p cwgoal +p = cw_goal o p i +p = cw_cat o p cwstat +p = cw_sname o p cw_g i 6 +p = cw_cat o p cwnl +if gt cw_g i 13 0 +p = cw_cat o p cwsrcl +p = cw_catl o p 2 i +end +if gt cw_g i 14 0 +p = cw_cat o p cwtres +p = cw_catl o p 3 i +p = cw_cat o p cwnl +end +ret cw_cat o p cwansw +end + +note ======== packed argv (count, then length-prefixed arguments) + +fn cw_arg d edit uchar 4096 p ulong a view uchar * to ulong +if gt add add p 2 len a 4096 +ret 5000 +end +c = add or ulong get d 0 shl ulong get d 1 8 1 +put d 0 uchar and c 255 +put d 1 uchar shr c 8 +put d p uchar and len a 255 +put d add p 1 uchar shr len a 8 +for i ulong len a +put d add add p 2 i get a i +end +ret add add p 2 len a +end + +note Append loaded item sel of objective i to d as one argument. +fn cw_argl d edit uchar 4096 p ulong sel ulong i ulong to ulong +t = new uchar 4096 0 +n = cw_ld t sel i +ret cw_arg d p view part t 0 n +end + +fn cw_cfg d edit uchar 4096 p ulong k ulong to ulong +ret cw_argl d p add 10 k 0 +end + +fn cw_narg d edit uchar 4096 p ulong v ulong to ulong +t = new uchar 4096 0 +n = cw_dec t 0 v +ret cw_arg d p view part t 0 n +end + +note WORK/o, the objective's private compile directory. +fn cw_wdir t edit uchar 4096 i ulong to ulong +p = cw_catl t 0 14 0 +p = cw_cat t p cwo +ret cw_dec t p i +end + +note ======== events + +fn cw_ev i ulong id ulong what ulong v ulong to void +o = new uchar 4096 0 +p = cw_cat o 0 cwee +p = cw_dec o p i +p = cw_cat o p cwsp +p = cw_dec o p id +p = cw_cat o p cwsp +p = cw_dec o p what +p = cw_cat o p cwsp +p = cw_dec o p v +p = cw_cat o p cwnl +cw_out o p +end + +note A framed transcript record: tag i turn n, newline, the bytes, newline. +fn cw_rec tag ulong i ulong b view uchar * to void +o = new uchar 4096 0 +p = ulong 0 +if eq tag 0 +p = cw_cat o 0 cwep +else +p = cw_cat o 0 cwer +end +p = cw_dec o p i +p = cw_cat o p cwsp +p = cw_dec o p cw_g i 7 +p = cw_cat o p cwsp +p = cw_dec o p len b +p = cw_cat o p cwnl +cw_out o p +cw_out b len b +cw_out cwnl 1 +end + +note Objective i finished with result r (1 PASS, else the failure). +fn cw_end i ulong r ulong to void +o = new uchar 4096 0 +cw_s i 12 r +cw_s i 9 4 +p = cw_cat o 0 cweo +p = cw_dec o p i +p = cw_cat o p cwsp +if eq r 1 +p = cw_cat o p cwpass +else +p = cw_cat o p cwfail +end +p = cw_cat o p cwsp +p = cw_dec o p r +p = cw_cat o p cwsp +p = cw_dec o p cw_g i 7 +p = cw_cat o p cwnl +cw_out o p +end + +note ======== creator: issuing jobs + +note Admit job kind (1 inference, 2 read, 3 check, 4 replace, 5 review) of +note objective i with input pk[0, pn), then publish the input on the +note objective's topic, which makes the job ready. The job id, or 0 when it +note could not be admitted now (the caller tries again at its next step). +fn cw_issue c long i ulong kind ulong pk view uchar 4096 pn ulong to ulong +s = cw_g i 11 +if ge s 99 +cw_end i 20 +ret 0 +end +id = add add mul add i 1 1000 mul s 10 kind +fl = ulong 1 +if eq kind 4 +fl = 0 +end +t = shl ulong 1 i +j = jn_admit id t fl +if lt j 0 +ret 0 +end +cw_s i 11 add s 1 +v = sched_publish c t pk pn +if le v 0 +x = auth_cancel c ulong j +cw_end i 22 +ret 0 +end +cw_s i 10 id +put cwt0 i ulong monons +cw_ev i id 1 kind +ret id +end + +note Start objective i's next model turn: the prompt as the only input. +fn cw_turn c long i ulong to void +pr = new uchar 4096 0 +pk = new uchar 4096 0 +n = cw_prmt pr i +if gt n 3800 +cw_end i 20 +ret +end +p = cw_cfg pk 2 0 +p = cw_cfg pk p 6 +p = cw_arg pk p cwmax +p = cw_arg pk p cwdl +p = cw_arg pk p view part pr 0 n +if gt p 4096 +cw_end i 20 +ret +end +id = cw_issue c i 1 pk p +if gt id 0 +cw_s i 7 add cw_g i 7 1 +cw_s i 9 1 +put cwinf 0 add i 1 +cw_rec 0 i view part pr 0 n +end +end + +note TOOL verb ROOT PATH into pk; the length. +fn cw_targ pk edit uchar 4096 i ulong vb ulong to ulong +p = cw_cfg pk 2 1 +if eq vb 2 +p = cw_arg pk p cwvrd +end +if or eq vb 3 eq vb 5 +p = cw_arg pk p cwvck +end +if eq vb 4 +p = cw_arg pk p cwvrp +end +p = cw_cfg pk p 3 +ret cw_argl pk p 0 i +end + +note A read (2), check (3) or review (5) job for objective i. +fn cw_tool c long i ulong kind ulong to void +pk = new uchar 4096 0 +t = new uchar 4096 0 +p = cw_targ pk i kind +if ne kind 2 +n = cw_wdir t i +p = cw_arg pk p view part t 0 n +p = cw_cfg pk p 2 +p = cw_narg pk p cw_g i 0 +p = cw_narg pk p cw_g i 1 +p = cw_narg pk p cw_g i 2 +p = cw_narg pk p cw_g i 3 +end +id = cw_issue c i kind pk p +if gt id 0 +cw_s i 9 2 +if eq kind 5 +cw_s i 9 3 +end +end +end + +note A replace job for objective i: old (h5 bytes at b[o]) and new (h6 +note bytes after it) as the model gave them. +fn cw_repl c long i ulong b view uchar 4096 o ulong h view ulong 16 to void +pk = new uchar 4096 0 +p = cw_targ pk i 4 +p = cw_arg pk p view part b o get h 5 +p = cw_arg pk p view part b add o get h 5 get h 6 +id = cw_issue c i 4 pk p +if gt id 0 +cw_s i 9 2 +end +end + +note ======== creator: records + +note Parse k decimal fields of record b after the 6-byte tag into h[0..k); +note the offset after the header line, or 0 when malformed. +fn cw_hdr b view uchar 4096 k ulong h edit ulong 16 to ulong +p = ulong 6 +for f ulong k +v = ulong 0 +nd = ulong 0 +for it ulong 12 +c = ulong get b p +if or lt c 48 gt c 57 +break +end +v = add mul v 10 sub c 48 +nd = add nd 1 +p = add p 1 +end +if eq nd 0 +ret 0 +end +put h f v +c2 = get b p +if lt add f 1 k +if ne c2 32 +ret 0 +end +else +if ne c2 10 +ret 0 +end +end +p = add p 1 +end +ret p +end + +fn cw_tag b view uchar 4096 t view uchar * to bool +for i ulong 6 +if ne get b i get t i +ret false +end +end +ret true +end + +note Objective i's model record b: the turn's action, checked against the +note state before anything is granted. +fn cw_ires c long i ulong b view uchar 4096 to void +h = new ulong 16 0 +if not cw_tag b cwhi +cw_end i 18 +ret +end +d = cw_hdr b 8 h +if or eq d 0 gt add add add add d get h 4 get h 5 get h 6 get h 7 3968 +cw_end i 18 +ret +end +x = add add add d get h 4 get h 5 get h 6 +cw_rec 1 i view part b x get h 7 +cw_ev i 0 2 get h 0 +cw_act c i b d h +end + +note The policy of repair.py jobs_run for action kind h[0], with path at +note b[d, d + h4), old after it (h5 bytes), new after that (h6 bytes). +fn cw_act c long i ulong b view uchar 4096 d ulong h view ulong 16 to void +u = new uchar 4096 0 +un = cw_ld u 0 i +k = get h 0 +st = cw_g i 6 +if eq k 4 +if and eq st 4 eq cw_g i 8 1 +cw_tool c i 5 +else +cw_end i 14 +end +ret +end +if eq k 5 +if eq st 5 +cw_end i 1 +else +cw_end i 10 +end +ret +end +if or eq k 9 gt k 5 +cw_end i 10 +ret +end +if not cw_eq view part b d get h 4 view part u 0 un +cw_end i 11 +ret +end +if and eq k 1 eq st 0 +cw_tool c i 2 +ret +end +if and eq k 2 or eq st 1 eq st 3 +cw_tool c i 3 +ret +end +if and eq k 3 eq st 2 +cw_edit c i b add d get h 4 h +ret +end +cw_end i 10 +end + +note replace_text: the model's old must occur exactly once in the source it +note was shown and the result must stay in the grammar; the candidate is +note kept to compare with what the tool saved. +fn cw_edit c long i ulong b view uchar 4096 o ulong h view ulong 16 to void +u = new uchar 4096 0 +un = cw_ld u 2 i +if ne cw_count view part u 0 un view part b o get h 5 1 +cw_end i 13 +ret +end +n = cw_cand i b o h +if gt n 3800 +cw_end i 13 +ret +end +cw_repl c i b o h +end + +note The candidate source of objective i into cwcan: its length, or 5000 +note when it is over 3800 bytes or outside the grammar. +fn cw_cand i ulong b view uchar 4096 o ulong h view ulong 16 to ulong +t = new uchar 4096 0 +u = new uchar 4096 0 +sn = cw_ld u 2 i +k = cw_at view part u 0 sn view part b o get h 5 +p = cw_cat t 0 view part u 0 k +p = cw_cat t p view part b add o get h 5 get h 6 +r = add k get h 5 +p = cw_cat t p view part u r sub sn r +if gt p 3800 +ret 5000 +end +if not gr_src t p +ret 5000 +end +cw_keep i t p +ret p +end + +note The first occurrence of a in s (len s when none). +fn cw_at s view uchar * a view uchar * to ulong +for k ulong len s +if le add k len a len s +if cw_eq view part s k len a a +ret k +end +end +end +ret len s +end + +fn cw_keep i ulong t view uchar 4096 n ulong to void +for j ulong n +put cwcan add mul i 4096 j get t j +end +cw_s i 15 n +end + +note Objective i's tool record b for job kind. +fn cw_tres c long i ulong kind ulong b view uchar 4096 to void +h = new ulong 16 0 +if not cw_tag b cwht +cw_end i 18 +ret +end +d = cw_hdr b 3 h +if or eq d 0 or gt get h 1 1024 gt add add d get h 1 get h 2 3968 +cw_end i 18 +ret +end +st = get h 0 +cw_ev i 0 3 st +if eq kind 2 +cw_read i st b d h +ret +end +if eq kind 4 +cw_saved i st b d h +ret +end +cw_chk i add mul kind 256 st b d h +end + +note A tool record's observation is h1 bytes at b[d], its content the h2 +note bytes after it. cw_same: the content equals loaded item sel. +fn cw_same i ulong sel ulong b view uchar 4096 d ulong h view ulong 16 to bool +u = new uchar 4096 0 +un = cw_ld u sel i +ret cw_eq view part b add d get h 1 get h 2 view part u 0 un +end + +note A check (kind 3) or review (5) record, ks = 256 kind + status: the file +note checked must be the source the workflow holds. +fn cw_chk i ulong ks ulong b view uchar 4096 d ulong h view ulong 16 to void +kind = shr ks 8 +st = and ks 255 +if not cw_same i 2 b d h +cw_end i 15 +ret +end +if eq kind 5 +if eq st 0 +cw_end i 1 +else +cw_end i 15 +end +ret +end +if eq st 0 +cw_s i 6 4 +cw_s i 8 1 +else +if ne st 6 +cw_end i 17 +ret +end +cw_s i 6 2 +cw_s i 8 0 +end +cw_seto i view part b d get h 1 +cw_s i 9 0 +end + +fn cw_read i ulong st ulong b view uchar 4096 d ulong h view ulong 16 to void +if eq st 0 +cw_s i 6 1 +cw_setsrc i view part b add d get h 1 get h 2 +cw_seto i view part b d get h 1 +cw_s i 9 0 +ret +end +if eq st 1 +cw_s i 6 5 +cw_s i 13 0 +cw_seto i view part b d get h 1 +cw_s i 9 0 +ret +end +cw_end i 17 +end + +fn cw_saved i ulong st ulong b view uchar 4096 d ulong h view ulong 16 to void +if eq st 5 +cw_end i 13 +ret +end +if ne st 0 +cw_end i 17 +ret +end +if not cw_same i 4 b d h +cw_end i 15 +ret +end +cw_s i 6 3 +cw_s i 8 0 +cw_setsrc i view part b add d get h 1 get h 2 +cw_seto i view part b d get h 1 +cw_s i 9 0 +end + +fn cw_setsrc i ulong f view uchar * to void +for j ulong len f +put cwsrc add mul i 4096 j get f j +end +cw_s i 13 len f +end + +fn cw_seto i ulong o view uchar * to void +for j ulong len o +put cwobs add mul i 1024 j get o j +end +cw_s i 14 len o +end + +note ======== creator: results + +note A job of objective i in review: its result bytes are read before it is +note released and before the next auth_step, so no later job of the same +note worker (which needs a grant first) can have overwritten them. +fn cw_done c long j ulong id ulong to void +b = new uchar 4096 0 +i = sub div id 1000 1 +kind = rem id 10 +if or ge i get cwno 0 ne id cw_g i 10 +ret +end +r = sched_result get sjw j b +o = get sjout j +cw_s i 10 0 +if eq kind 1 +put cwinf 0 0 +end +cw_ev i id 4 o +f = cw_fate o kind +if ne f 0 +cw_end i f +ret +end +if eq kind 1 +cw_ires c i b +ret +end +cw_tres c i kind b +end + +note The failure for job outcome word o of a job of kind, 0 when its child +note ran and exited 0: refused 16 + verdict (cancelled, verdict 6: 19), +note input lost 90, not performed 1 (cancelled: 19), UNKNOWN 0 or a child +note killed by a signal (21), a nonzero exit (16 inference, 17 tool). +fn cw_fate o ulong kind ulong to ulong +lo = and o 255 +if eq lo 2 +ws = shr o 8 +if ne and ws 127 0 +ret 21 +end +if eq and shr ws 8 255 0 +ret 0 +end +if eq kind 1 +ret 16 +end +ret 17 +end +if or eq lo 1 eq lo 22 +ret 19 +end +if eq lo 0 +ret 21 +end +if eq lo 90 +ret 22 +end +ret 23 +end + +note Collect: every job in review is handled once, then released (again at +note the next step while its DONE is not yet durable). A job whose worker +note died mid-job (UNKNOWN) ends its objective; its slot stays UNKNOWN, +note since only the journal's recovery may settle what may have happened. +fn cw_coll c long to void +for j ulong 64 +s = get sjst j +id = get sjid j +if and eq s 4 ne get cwgot j id +put cwgot j id +cw_done c j id +end +if eq s 4 +x = jn_release j +end +if and eq s 6 ne get cwgot j id +put cwgot j id +cw_lost id +end +end +end + +fn cw_lost id ulong to void +i = sub div id 1000 1 +if and lt i get cwno 0 eq id cw_g i 10 +cw_s i 10 0 +if eq rem id 10 1 +put cwinf 0 0 +end +cw_end i 21 +end +end + +note ======== creator: planning + +note Start a turn for one objective that needs one (one inference in flight +note at a time); the test hook cwtk cancels an inference after ms. +fn cw_plan c long to void +cw_hook c +if gt get cwinf 0 0 +ret +end +for i ulong get cwno 0 bound 4 +if and eq cw_g i 9 0 eq cw_g i 12 0 +if ge cw_g i 7 7 +cw_end i 12 +else +cw_turn c i +ret +end +end +end +end + +fn cw_hook c long to void +k = get cwtk 0 +if eq k 0 +ret +end +i = sub k 1 +if or ne cw_g i 9 1 eq cw_g i 10 0 +ret +end +if lt sub ulong monons get cwt0 i mul get cwtk 1 1000000 +ret +end +for j ulong 64 +if and eq get sjid j cw_g i 10 eq get sjst j 3 +x = auth_cancel c j +put cwtk 0 0 +cw_ev i cw_g i 10 5 ulong x +end +end +end + +fn cw_left to ulong +n = ulong 0 +for i ulong get cwno 0 bound 4 +if eq cw_g i 12 0 +n = add n 1 +end +end +ret n +end + +note Creator loop until every objective finished or dl ns pass: 0 or 62. +fn cw_drive c long dl ulong to int +for t ulong 1000000000 +r = sched_step c 5000000 +cw_coll c +k = auth_step c +cw_plan c +if eq cw_left 0 +ret 0 +end +if ge ulong monons dl +ret 62 +end +end +ret 62 +end + +note ======== worker + +note Worker w: the input of its job (objective i): the newest version on the +note objective's topic that is not newer than the assignment's version. +fn cw_input c long w ulong i ulong dst edit uchar 4096 to long +v = sc_cell w 24 +t = shl ulong 1 i +h = pool_hold c w sc_cell w 16 +if le h 0 +ret neg long 1 +end +cur = ulong 0 +last = ulong 0 +for k ulong 65 +x = node_next h cur t +if le x 0 +break +end +if gt ulong x v +break +end +last = ulong x +cur = last +end +n = neg long 1 +if gt last 0 +n = node_read h last dst +end +r = pool_release c w +ret n +end + +note Worker w, assignment q: propose, wait for the decision, run the child +note when granted, report. Outcome word: the authority's outcome (0 UNKNOWN, +note 1 not performed, 2 performed) plus the wait status shifted by 8; 16 + +note verdict when refused; 90 when the input was not found. +fn cw_job c long w ulong q ulong to void +pk = new uchar 4096 0 +op = new ulong 4 0 +id = sc_cell w 8 +n = cw_input c w sub div id 1000 1 pk +if le n 0 +r = sched_wdone w q 90 pk 0 +ret +end +put op 0 id +put op 1 rem id 10 +put op 2 div id 1000 +put op 3 1 +r = auth_propose w q op cw_class id +v = auth_wdecide c w q 30000000000 +if ne v 0 +r = sched_wdone w q add 16 ulong v pk 0 +ret +end +cw_wrun c w q pk ulong n +end + +note Replace changes the workspace (class 1); the others are rerunnable. +fn cw_class id ulong to ulong +if eq rem id 10 4 +ret 1 +end +ret 2 +end + +fn cw_wrun c long w ulong q ulong pk view uchar 4096 n ulong to void +ob = new uchar 4096 0 +o = auth_wtool c w q pk n cw_class sc_cell w 8 +r = auth_wreport w q ulong o +m = auth_wout w ob +x = or ulong o shl auth_cell w 96 8 +r = sched_wdone w q x ob m +end + +fn cw_worker c long w ulong to int +for it ulong 1000000000 +q = sched_wjob w +if gt q 0 +cw_job c w q +end +r = auth_wwait c w neg int 1 1000000000 +if or eq r 2 eq r 3 +ret 0 +end +if eq r 4 +t = auth_wctl w +end +if lt r 0 +ret 45 +end +end +ret 46 +end + +note ======== setup + +note Objective argument "KIND,K,N,A,PATH,TASK" (KIND add, mul or loop) into +note slot i. false when malformed. +fn cw_parse i ulong a view uchar * to bool +f = new ulong 8 0 +k = ulong 0 +for j ulong len a +if and lt k 5 eq get a j 44 +put f k j +k = add k 1 +end +end +if ne k 5 +ret false +end +if cw_eq view part a 0 get f 0 cwadd +cw_s i 0 1 +end +if cw_eq view part a 0 get f 0 cwmul +cw_s i 0 2 +end +if cw_eq view part a 0 get f 0 cwloop +cw_s i 0 3 +end +if eq cw_g i 0 0 +ret false +end +for m ulong 3 +v = cw_pnum a add get f m 1 get f add m 1 +if gt v 99 +ret false +end +cw_s i add m 1 v +end +ret cw_ptxt i a f +end + +fn cw_pnum a view uchar * s ulong e ulong to ulong +if or ge s e gt sub e s 2 +ret 999 +end +v = ulong 0 +for j ulong sub e s +c = ulong get a add s j +if or lt c 48 gt c 57 +ret 999 +end +v = add mul v 10 sub c 48 +end +ret v +end + +note PATH and TASK of the objective argument a (field ends in f). +fn cw_ptxt i ulong a view uchar * f view ulong 8 to bool +ps = add get f 3 1 +pn = sub get f 4 ps +ts = add get f 4 1 +tn = sub len a ts +if or or eq pn 0 gt pn 128 or eq tn 0 gt tn 383 +ret false +end +cw_put add mul i 512 0 view part a ps pn +cw_put add mul i 512 128 view part a ts tn +cw_s i 4 pn +cw_s i 5 tn +ret true +end + +fn cw_put o ulong a view uchar * to void +for j ulong len a +put cwos add o j get a j +end +end + +note Argument ai into config slot k; false when empty or over 1000 bytes. +fn cw_carg ai ulong k ulong to bool +n = argread ai cwcf mul k 1024 1000 +if lt n 1 +ret false +end +put cwcl k ulong n +ret true +end + +note Next job seq and performed model turns of objective i from the journal. +fn cw_resume i ulong to void +s = ulong 0 +t = ulong 0 +for q ulong 99 +for kd ulong 5 +id = add add mul add i 1 1000 mul q 10 add kd 1 +if jn_known id +s = add q 1 +if and eq kd 0 eq and jn_jout id 255 2 +t = add t 1 +end +end +end +end +cw_s i 11 s +cw_s i 7 t +end + +note FNV-1a 64 of the objective arguments, for the journal's identity. +fn cw_ident a0 ulong n ulong to ulong +b = new uchar 1024 0 +x = ulong 14695981039346656037 +for i ulong n +m = argread add a0 i b 0 1024 +for j ulong ulong m +x = mul xor x ulong get b j 1099511628211 +end +x = mul xor x 255 1099511628211 +end +ret x +end + +note The journal's objective: tag 0x4f4d4e43 ("OMNC"), the objective count, +note the hash of the objective arguments, the issue number. +fn cw_jopen ai ulong n ulong to ulong +d = new uchar 128 0 +o = new ulong 4 0 +for j ulong get cwcl 5 bound 128 +put d j get cwcf add 5120 j +end +put o 0 1330466371 +put o 1 n +put o 2 cw_ident ai n +put o 3 290 +ret jn_open d get cwcl 5 o 3000 +end + +note Make WORK/o for every objective (an existing one is reused). +fn cw_dirs to void +t = new uchar 4096 0 +for i ulong get cwno 0 bound 4 +n = cw_wdir t i +x = makedir t 0 n 448 +end +end + +note omnode-code INFER TOOL OMC ROOT WORK JDIR PORT OBJ... from argument +note k on (1..4 objectives; all paths absolute). Exit 0 all passed, 1 some +note failed, 2 usage, 62 out of time, 30 + journal refusal, 50.. setup. +fn cw_main k ulong dls ulong to int +b = new uchar 1024 0 +c = ulong argcnt +if or lt c add k 8 gt c add k 11 +ret 2 +end +for a ulong 7 +if not cw_carg add k a a +ret 2 +end +end +put cwno 0 sub c add k 7 +for i ulong get cwno 0 bound 4 +m = argread add add k 7 i b 0 1024 +if lt m 1 +ret 2 +end +if not cw_parse i view part b 0 ulong m +ret 2 +end +end +ret cw_run k dls +end + +fn cw_run k ulong dls ulong to int +c = pool_new 4 2 +if le c 0 +ret 50 +end +if ne sup_init c 0 +ret 51 +end +if ne sched_new c 8 8 0 +ret 52 +end +if ne auth_new c 0 +ret 53 +end +e = cw_jopen add k 7 get cwno 0 +if ne e 0 +ret int add 30 e +end +e = auth_recover c +if ne e 0 +ret int add 30 e +end +for j ulong 64 +s = get sjst j +if or eq s 1 eq s 2 +x = auth_cancel c j +end +end +for i ulong get cwno 0 bound 4 +cw_resume i +end +cw_dirs +for w ulong 2 +p = auth_spawn c w +if eq p 0 +exit cw_worker c w +end +if le p 0 +ret 54 +end +end +r = cw_drive c add ulong monons mul dls 1000000000 +x = sched_stop c 2000000000 +sup_closeall +jn_close +ret cw_sum r +end + +fn cw_sum r int to int +o = new uchar 4096 0 +np = ulong 0 +for i ulong get cwno 0 bound 4 +if eq cw_g i 12 1 +np = add np 1 +end +end +p = cw_cat o 0 cwsum +p = cw_dec o p np +p = cw_cat o p cwsumf +p = cw_dec o p sub get cwno 0 np +p = cw_cat o p cwnl +cw_out o p +if ne r 0 +ret r +end +if eq np get cwno 0 +ret 0 +end +ret 1 +end diff --git a/seed/node/gram.om b/seed/node/gram.om new file mode 100644 index 000000000..edeb349f2 --- /dev/null +++ b/seed/node/gram.om @@ -0,0 +1,183 @@ +note seed/node/gram.om -- the bounded repair grammar of the round40 protocol +note (repair.py PATTERNS), shared by the tool adapter (seed/node/tool.om, +note which checks a file) and the coding workflow (seed/node/code.om, whose +note creator checks a proposed edit before granting it). Compiles as OM-1 and +note OM-2; compose before its user. Lines are split at newline bytes only, +note after the source is trimmed of ASCII white space (bytes 0..32). +note Lines: fn calc x int to int | fn main to int | end | s = x | ret s | +note ret (add|mul|sub) x int [1-6] | ret calc int \d{1,2} | +note for i ulong [1-6] | s = add s int [1-6]. +text gcalc "fn calc x int to int" +text gmain "fn main to int" +text gend "end" +text gradd "ret add x int " +text grmul "ret mul x int " +text grsub "ret sub x int " +text grcal "ret calc int " +text gsx "s = x" +text gfor "for i ulong " +text gsadd "s = add s int " +text grets "ret s" + +note Grammar text k (0 calc, 1 main, 2 end, 3 s = x, 4 ret s, 5 ret calc +note int, 6 ret add, 7 ret mul, 8 ret sub, 9 for, 10 s = add): its length. +fn gr_tln k ulong to ulong +if eq k 0 +ret len gcalc +end +if eq k 1 +ret len gmain +end +if eq k 2 +ret len gend +end +if eq k 3 +ret len gsx +end +if eq k 4 +ret len grets +end +if eq k 5 +ret len grcal +end +if le k 8 +ret len gradd +end +if eq k 9 +ret len gfor +end +ret len gsadd +end + +note Byte i of grammar text k. +fn gr_tch k ulong i ulong to uchar +if eq k 0 +ret get gcalc i +end +if eq k 1 +ret get gmain i +end +if eq k 2 +ret get gend i +end +if eq k 3 +ret get gsx i +end +if eq k 4 +ret get grets i +end +if eq k 5 +ret get grcal i +end +if eq k 6 +ret get gradd i +end +if eq k 7 +ret get grmul i +end +if eq k 8 +ret get grsub i +end +if eq k 9 +ret get gfor i +end +ret get gsadd i +end + +note Line s[a, e) is text k followed by one digit 1..6 when dg is 1, by one +note or two digits when dg is 2, or exactly text k when dg is 0. +fn gr_lin s view uchar 4096 a ulong e ulong k ulong dg ulong to bool +n = gr_tln k +if lt sub e a n +ret false +end +for i ulong n +if ne get s add a i gr_tch k i +ret false +end +end +r = sub sub e a n +if eq dg 0 +ret eq r 0 +end +if eq dg 1 +if ne r 1 +ret false +end +c = get s add a n +ret and ge c 49 le c 54 +end +if or eq r 0 gt r 2 +ret false +end +for j ulong r +c = get s add add a n j +if or lt c 48 gt c 57 +ret false +end +end +ret true +end + +note Line s[a, e) is in the grammar. +fn gr_gram s view uchar 4096 a ulong e ulong to bool +for k ulong 5 +if gr_lin s a e k 0 +ret true +end +end +if gr_lin s a e 5 2 +ret true +end +for k2 ulong 5 +if gr_lin s a e add 6 k2 1 +ret true +end +end +ret false +end + +note The end of the line that starts at a (a newline or e). +fn gr_eol b view uchar 4096 a ulong e ulong to ulong +z = a +for j ulong sub e a +if eq get b z 10 +ret z +end +z = add z 1 +end +ret z +end + +note Every line of b[0, n), trimmed, is in the grammar (an empty source too). +fn gr_src b view uchar 4096 n ulong to bool +s = ulong 0 +for i ulong n +if gt get b s 32 +break +end +s = add s 1 +end +e = n +for j ulong sub n s +if gt get b sub e 1 32 +break +end +e = sub e 1 +end +if ge s e +ret true +end +a = s +for it ulong add n 1 +if gt a e +ret true +end +z = gr_eol b a e +if not gr_gram b a z +ret false +end +a = add z 1 +end +ret true +end diff --git a/seed/node/infer.om b/seed/node/infer.om new file mode 100644 index 000000000..d7a7f7a5d --- /dev/null +++ b/seed/node/infer.om @@ -0,0 +1,609 @@ +note Omega Node inference adapter (DRA-290): one bounded completion from the +note own model's ollm serve (aien-train, DRA-119) over loopback, turned into a +note versioned typed record. Composition, OM-2: +note { printf 'om2\n'; cat seed/json/json.om seed/json/jsonw.om +note seed/net/http.om seed/net/notls.om seed/node/infer.om; } | omc +note Usage: omnode-infer PORT MAXTOK DEADLINE_S PROMPT [TESTOUT] +note It connects only to 127.0.0.1 (offline-local: no other host, no TLS, no +note credential) and refuses port 18091. POST /v1/completions with the prompt +note as the whole template, greedy (top_p 0), seed 1, stream false. TESTOUT +note is sent as ollm_test_output, which only a server started with test=1 +note honours; the Node's workflow never passes it. +note The whole exchange (connect, request, generation, response) has one +note deadline. A caller cancels by killing the process group; the server +note sees the connection close and stops generating. +note Record on stdout, exit 0: one line +note OMNI1 kind fin ptok ctok plen olen nlen tlen +note then the path, old, new and raw text bytes back to back. kind: 1 +note read_file, 2 omega_check, 3 replace_text, 4 the answer Tests passed., +note 5 the answer File not found., 9 the text is not a protocol action (the +note model's turn is returned, never repaired). fin: 1 stop, 2 length, 0 +note other. The action is the text before the first newline-Done., trimmed, +note as the round40 repair protocol reads it: a JSON object of exactly +note {tool,path} for read_file and omega_check, or {tool,path,old,new} for +note replace_text; path 1..128 bytes, old 1..40, new 0..40, no NUL byte. +note Other exits: 2 usage, 3 prompt (1..3800 bytes, no NUL), 4 connect, 5 +note deadline, 6 HTTP status other than 200 (OMNE1 status, then the body +note head, on stdout), 7 malformed response, 8 server busy (503) until less +note than 2 s of the deadline is left: a busy server (one request at a time, +note for example still stopping a cancelled one) is asked again every second. +text ipath "/v1/completions" +text imeth "POST" +text ihost "Host" +text ihostv "127.0.0.1" +text ictype "Content-Type" +text ijson "application/json" +text kmodel "model" +text vollm "ollm" +text kprompt "prompt" +text kmaxt "max_tokens" +text ktopp "top_p" +text kseed "seed" +text kstream "stream" +text ktout "ollm_test_output" +text kobj "object" +text vtcomp "text_completion" +text kchoi "choices" +text ktext "text" +text kfin "finish_reason" +text kusage "usage" +text kpt "prompt_tokens" +text kct "completion_tokens" +text vstop "stop" +text vlen "length" +text ktool "tool" +text kpath "path" +text kold "old" +text knew "new" +text tread "read_file" +text tcheck "omega_check" +text trepl "replace_text" +text apass "Tests passed." +text amiss "File not found." +text tdone "\nDone." +text irec "OMNI1 " +text ierr "OMNE1 " + +note The decimal value of a[0, n), or -1 when it is not 1..9 digits. +fn ia_dec a view uchar * n ulong to long +if or eq n 0 gt n 9 +ret neg long 1 +end +v = ulong 0 +for i ulong n +c = ulong get a i +if or lt c 48 gt c 57 +ret neg long 1 +end +v = add mul v 10 sub c 48 +end +ret long v +end + +note Argument i as a number, -1 when it is not one. +fn ia_num i ulong to long +b = new uchar 16 0 +n = argread i b 0 16 +if lt n 0 +ret neg long 1 +end +ret ia_dec b ulong n +end + +note Append the decimal v to o at p; the new end. +fn ia_put o edit uchar 8192 p ulong v ulong to ulong +d = new uchar 24 0 +k = ulong 0 +x = v +for i ulong 24 +put d k uchar add 48 rem x 10 +k = add k 1 +x = div x 10 +if eq x 0 +break +end +end +for j ulong k +put o add p j get d sub sub k j 1 +end +ret add p k +end + +note Append a[0, n) to o at p; the new end. +fn ia_cat o edit uchar 8192 p ulong a view uchar * s ulong n ulong to ulong +for i ulong n +put o add p i get a add s i +end +ret add p n +end + +fn ia_out o view uchar 8192 n ulong to void +p = ulong 0 +for it ulong 64 +if ge p n +ret +end +r = write 1 o p sub n p +if le r 0 +ret +end +p = add p ulong r +end +end + +note The request body into ob (jsonw); its length, or a negative refusal. +fn ia_body ob edit uchar 16384 pr view uchar 4096 pn ulong mt ulong to long +tb = new uchar 4096 0 +x = js_winit ob +js_wobj ob +js_wsbuf ob kmodel 0 len kmodel +js_wsbuf ob vollm 0 len vollm +js_wsbuf ob kprompt 0 len kprompt +js_wsbuf ob pr 0 pn +js_wsbuf ob kmaxt 0 len kmaxt +js_wulong ob mt +js_wsbuf ob ktopp 0 len ktopp +js_wulong ob 0 +js_wsbuf ob kseed 0 len kseed +js_wulong ob 1 +js_wsbuf ob kstream 0 len kstream +js_wbool ob false +if gt argcnt 5 +tn = argread 5 tb 0 4096 +if lt tn 0 +ret neg long 1 +end +js_wsbuf ob ktout 0 len ktout +js_wsbuf ob tb 0 ulong tn +end +js_wobje ob +ret js_wdone ob +end + +note Connect, send the request, read the status. The status, or negative. +fn ia_send cs edit ulong 320 io edit uchar 131072 ob view uchar 16384 bn ulong port ulong dl long to long +a = new uchar 16 0 +r = haddr4 a 2130706433 port +fd = hdial a 5000000000 +if lt fd 0 +ret neg long 1000 +end +r = hinit cs io int fd 0 +hsettmo cs dl dl +hsetbdl cs dl +r = hreqst cs io imeth +r = hfe r hreqtg cs io ipath +r = hfe r hhname cs io ihost +r = hfe r hhval cs io ihostv +r = hfe r hhname cs io ictype +r = hfe r hhval cs io ijson +r = hfe r hhend cs io 0 bn +r = hfe r hput cs io view part ob 1040 bn +r = hfe r hwfin cs io +if lt r 0 +ret r +end +ret hrsprd cs io +end + +note Member key in object o of the parsed src, its value token or jsnone. +fn ia_mem src view uchar * tp view uint 65536 o ulong key view uchar * to ulong +if ne js_type tp o 1 +ret jsnone +end +k = js_first tp o +for it ulong js_nkids tp o +if eq k jsnone +break +end +if js_streq src js_off tp k key +ret add k 1 +end +k = js_mnext tp k +end +ret jsnone +end + +note An unsigned member of object o, or -1. +fn ia_umem src view uchar 16384 tp view uint 65536 o ulong key view uchar * to long +v = ia_mem src tp o key +if eq v jsnone +ret neg long 1 +end +if or ne js_type tp v 7 not js_isu src js_off tp v +ret neg long 1 +end +ret long js_tou src js_off tp v +end + +note fin from token v: 1 stop, 2 length, 0 other. +fn ia_fin src view uchar 16384 tp view uint 65536 v ulong to ulong +if eq v jsnone +ret 0 +end +if ne js_type tp v 6 +ret 0 +end +if js_streq src js_off tp v vstop +ret 1 +end +if js_streq src js_off tp v vlen +ret 2 +end +ret 0 +end + +note Usage of the parsed response into m[2] prompt and m[3] completion +note tokens; false when either is missing. +fn ia_use rb view uchar 16384 tp view uint 65536 m edit ulong 8 to bool +us = ia_mem rb tp 0 kusage +pt = ia_umem rb tp us kpt +ct = ia_umem rb tp us kct +if or lt pt 0 lt ct 0 +ret false +end +put m 2 ulong pt +put m 3 ulong ct +ret true +end + +note The response body rb[0, rn): the text into tx, and m[0] text length, +note m[1] fin, m[2] prompt tokens, m[3] completion tokens. 0 or 7. +fn ia_resp rb view uchar 16384 rn ulong tx edit uchar 8192 m edit ulong 8 to ulong +tp = new uint 65536 0 +x = js_init tp 16384 16 +r = js_parse rb tp rn +if lt r 0 +ret 7 +end +ob = ia_mem rb tp 0 kobj +if or eq ob jsnone ne js_type tp ob 6 +ret 7 +end +if not js_streq rb js_off tp ob vtcomp +ret 7 +end +ch = ia_mem rb tp 0 kchoi +if or eq ch jsnone ne js_type tp ch 3 +ret 7 +end +c0 = js_first tp ch +if eq c0 jsnone +ret 7 +end +t = ia_mem rb tp c0 ktext +if or eq t jsnone ne js_type tp t 6 +ret 7 +end +n = js_sget rb js_off tp t tx +if lt n 0 +ret 7 +end +put m 0 ulong n +put m 1 ia_fin rb tp ia_mem rb tp c0 kfin +if not ia_use rb tp m +ret 7 +end +ret 0 +end + +note true when tx[i, n) starts with a newline then Done. +fn ia_done tx view uchar 8192 i ulong n ulong to bool +if gt add i 6 n +ret false +end +for j ulong 6 +if ne get tx add i j get tdone j +ret false +end +end +ret true +end + +note The action text of tx[0, n): before the first newline-Done., trimmed of +note ASCII white space. Its start in m[4] and length in m[5]. +fn ia_trim tx view uchar 8192 n ulong m edit ulong 8 to void +e = n +for i ulong n +if ia_done tx i n +e = i +break +end +end +s = ulong 0 +for j ulong e +if gt get tx s 32 +break +end +s = add s 1 +end +for k ulong sub e s +if gt get tx sub e 1 32 +break +end +e = sub e 1 +end +put m 4 s +put m 5 sub e s +end + +note true when tx[s, s + n) equals text t. +fn ia_is tx view uchar 8192 s ulong n ulong t view uchar * to bool +if ne n len t +ret false +end +for i ulong n +if ne get tx add s i get t i +ret false +end +end +ret true +end + +note Field f of the action object o (0 path at d[0], at most 128 bytes; 1 +note old at d[128], 40; 2 new at d[192], 40), a string decoded into d with +note no NUL byte. Its length, or -1. +fn ia_sfld src view uchar 8192 tp view uint 65536 o ulong f ulong d edit uchar 8192 to long +v = ulong jsnone +fo = ulong 0 +mx = ulong 128 +if eq f 0 +v = ia_mem src tp o kpath +end +if eq f 1 +v = ia_mem src tp o kold +fo = 128 +mx = 40 +end +if eq f 2 +v = ia_mem src tp o knew +fo = 192 +mx = 40 +end +if eq v jsnone +ret neg long 1 +end +if ne js_type tp v 6 +ret neg long 1 +end +n = js_sget src js_off tp v part d fo mx +if lt n 0 +ret neg long 1 +end +for i ulong ulong n +if eq get d add fo i 0 +ret neg long 1 +end +end +ret n +end + +note Classify the action at a[0, an): kind (1..3, 9), the fields into d at +note 0 (path), 128 (old), 192 (new) with lengths in m[1..3]. +fn ia_json a view uchar 8192 an ulong d edit uchar 8192 m edit ulong 8 to ulong +tp = new uint 65536 0 +x = js_init tp 8192 4 +r = js_parse a tp an +if lt r 0 +ret 9 +end +if ne js_type tp 0 1 +ret 9 +end +tv = ia_mem a tp 0 ktool +if or eq tv jsnone ne js_type tp tv 6 +ret 9 +end +k = ulong 9 +nk = ulong 2 +if js_streq a js_off tp tv tread +k = 1 +end +if js_streq a js_off tp tv tcheck +k = 2 +end +if js_streq a js_off tp tv trepl +k = 3 +nk = 4 +end +if or eq k 9 ne js_nkids tp 0 nk +ret 9 +end +pl = ia_sfld a tp 0 0 d +if lt pl 1 +ret 9 +end +put m 1 ulong pl +if ne k 3 +ret k +end +ol = ia_sfld a tp 0 1 d +nl = ia_sfld a tp 0 2 d +if or lt ol 1 lt nl 0 +ret 9 +end +put m 2 ulong ol +put m 3 ulong nl +ret 3 +end + +note Write the record for text tx[0, m0) with response fields m to stdout. +fn ia_emit tx view uchar 8192 m edit ulong 8 to void +o = new uchar 8192 0 +d = new uchar 8192 0 +a = new uchar 8192 0 +ia_trim tx get m 0 m +s = get m 4 +n = get m 5 +for i ulong n +put a i get tx add s i +end +ac = new ulong 8 0 +k = ulong 9 +if ia_is tx s n apass +k = 4 +end +if ia_is tx s n amiss +k = 5 +end +if eq k 9 +k = ia_json a n d ac +end +p = ia_cat o 0 irec 0 len irec +p = ia_put o p k +put o p 32 +p = ia_put o add p 1 get m 1 +put o p 32 +p = ia_put o add p 1 get m 2 +put o p 32 +p = ia_put o add p 1 get m 3 +put o p 32 +p = ia_put o add p 1 get ac 1 +put o p 32 +p = ia_put o add p 1 get ac 2 +put o p 32 +p = ia_put o add p 1 get ac 3 +put o p 32 +p = ia_put o add p 1 get m 0 +put o p 10 +p = ia_cat o add p 1 d 0 get ac 1 +p = ia_cat o p d 128 get ac 2 +p = ia_cat o p d 192 get ac 3 +p = ia_cat o p tx 0 get m 0 +ia_out o p +end + +note An HTTP error: OMNE1 status, then up to 512 bytes of the body. +fn ia_herr cs edit ulong 320 io edit uchar 131072 st long to int +o = new uchar 8192 0 +b = new uchar 512 0 +n = hbodyrd cs io b +p = ia_cat o 0 ierr 0 len ierr +p = ia_put o p ulong st +put o p 10 +p = add p 1 +if gt n 0 +p = ia_cat o p b 0 ulong n +end +ia_out o p +x = hclose cs +if eq st 503 +ret 8 +end +ret 6 +end + +note The prompt (argument 4) into pr; its length, or -1 when it is empty, +note over 3800 bytes or holds a NUL byte. +fn ia_prompt pr edit uchar 4096 to long +n = argread 4 pr 0 3800 +if lt n 1 +ret neg long 1 +end +for i ulong ulong n +if eq get pr i 0 +ret neg long 1 +end +end +ret n +end + +note Arguments PORT MAXTOK DEADLINE_S into a[0..2]; false when one is out of +note range (port 1..65535 but never 18091, 1..256 tokens, 1..3600 s). +fn ia_args a edit ulong 4 to bool +if or lt argcnt 5 gt argcnt 6 +ret false +end +port = ia_num 1 +mt = ia_num 2 +ds = ia_num 3 +if or or lt port 1 gt port 65535 eq port 18091 +ret false +end +if or lt mt 1 gt mt 256 +ret false +end +if or lt ds 1 gt ds 3600 +ret false +end +put a 0 ulong port +put a 1 ulong mt +put a 2 ulong ds +ret true +end + +note After the status st: the record, or the exit code of a failure. +fn ia_recv cs edit ulong 320 io edit uchar 131072 st long to int +rb = new uchar 16384 0 +tx = new uchar 8192 0 +m = new ulong 8 0 +if eq st neg long 1000 +ret 4 +end +if eq st HETIME +x = hclose cs +ret 5 +end +if lt st 0 +x = hclose cs +ret 4 +end +if ne st 200 +ret ia_herr cs io st +end +rn = hbodyall cs io rb +x = hclose cs +if eq rn HETIME +ret 5 +end +if lt rn 0 +ret 7 +end +e = ia_resp rb ulong rn tx m +if ne e 0 +ret 7 +end +ia_emit tx m +ret 0 +end + +fn ia_main to int +cs = new ulong 320 0 +io = new uchar 131072 0 +pr = new uchar 4096 0 +ob = new uchar 16384 0 +a = new ulong 4 0 +if not ia_args a +ret 2 +end +pn = ia_prompt pr +if lt pn 1 +ret 3 +end +bn = ia_body ob pr ulong pn get a 1 +if lt bn 0 +ret 3 +end +ret ia_ask cs io ob ulong bn get a 0 long mul get a 2 1000000000 +end + +note The exchange within dl ns from now; a 503 is asked again every second +note while at least 2 s are left. The record, or the exit code of a failure. +fn ia_ask cs edit ulong 320 io edit uchar 131072 ob view uchar 16384 bn ulong po ulong dl long to int +t0 = monons +st = ia_send cs io ob bn po dl +for it ulong 3600 +left = sub dl long sub monons t0 +if or ne st 503 lt left 2000000000 +ret ia_recv cs io st +end +x = hclose cs +r = sleepns 1000000000 +st = ia_send cs io ob bn po sub left 1000000000 +end +ret ia_recv cs io st +end + +fn main to int +ret ia_main +end diff --git a/seed/node/journal-gate.om b/seed/node/journal-gate.om index 7a4a8cf8d..5b0751639 100644 --- a/seed/node/journal-gate.om +++ b/seed/node/journal-gate.om @@ -1400,8 +1400,8 @@ fn actbind r view ulong 32 c view ulong 32 to ulong for g ulong 6 diff = ulong 0 for j ulong 4 -at = add 8 add mul g 4 j -diff = or diff xor get r at get c at +ix = add 8 add mul g 4 j +diff = or diff xor get r ix get c ix end if ne diff 0 ret add 40 g @@ -2241,7 +2241,7 @@ jn_hit 5 ret sched_review j end -fn jn_start op view ulong 4 cl ulong id ulong at ulong g ulong to ulong +fn jn_start op view ulong 4 cl ulong id ulong att ulong g ulong to ulong r = new ulong 16 0 put r 0 3 for i ulong 4 @@ -2249,7 +2249,7 @@ put r add 3 i get op i end put r 7 cl put r 8 id -put r 9 at +put r 9 att put r 10 g ret jn_append r end diff --git a/seed/node/journal.om b/seed/node/journal.om index db9b37960..df3369b4b 100644 --- a/seed/node/journal.om +++ b/seed/node/journal.om @@ -721,7 +721,7 @@ jn_hit 5 ret sched_review j end -fn jn_start op view ulong 4 cl ulong id ulong at ulong g ulong to ulong +fn jn_start op view ulong 4 cl ulong id ulong att ulong g ulong to ulong r = new ulong 16 0 put r 0 3 for i ulong 4 @@ -729,7 +729,7 @@ put r add 3 i get op i end put r 7 cl put r 8 id -put r 9 at +put r 9 att put r 10 g ret jn_append r end diff --git a/seed/node/tests/tool-replay.py b/seed/node/tests/tool-replay.py new file mode 100755 index 000000000..c4a319c1a --- /dev/null +++ b/seed/node/tests/tool-replay.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 +"""Replay the 108 recorded round40 runs through omnode-tool (DRA-290). + +For every recorded action the tool is run on a real file tree and the next +recorded prompt is rebuilt from the tool's observation and returned content; +it must equal the recorded prompt byte for byte. +Usage: tool-replay.py TOOL OMC ROUND40 OUTDIR, where ROUND40 holds repair.py +and final-selected.json of the round40 tool-model run (prompt and text are +taken from repair.py; the tool itself is the system under test). OMC must be +the compiler round40 used (sha256 2c82480596bb...), since compiler error +text is part of the prompt.""" +import json, os, shutil, subprocess, sys + +TOOL, OMC, R, OUT = sys.argv[1:5] +sys.path.insert(0, R) +import repair +prompt = repair.prompt; text = repair.text + + +def tool(*a): + p = subprocess.run([TOOL, *a], capture_output=True, timeout=120) + if p.returncode != 0: + return None, f'exit {p.returncode}', b'' + out = p.stdout + nl = out.index(b'\n') + h = out[:nl].split() + assert h[0] == b'OMNT1', out[:80] + st, ol, cl = int(h[1]), int(h[2]), int(h[3]) + body = out[nl + 1:] + assert len(body) == ol + cl, (len(body), ol, cl) + return st, body[:ol].decode(), body[ol:].decode() + + +kinds = {'add': 1, 'mul': 2, 'loop': 3} +runs = json.load(open(R + '/final-selected.json')) +npass = nfail = nact = 0 +for r in runs: + j = r['job'] + root = os.path.join(OUT, j['id']) + work = os.path.join(root, '.work') + shutil.rmtree(root, ignore_errors=True) + os.makedirs(os.path.join(root, os.path.dirname(j['path']))) + os.makedirs(work) + if j['fault'] != 'missing': + open(os.path.join(root, j['path']), 'w').write(j['broken']) + turns = r['turns'] + ok = True + for i, t in enumerate(turns[:-1]): + d = json.loads(text(t['raw'])) + if d['tool'] == 'read_file': + st, ob, c = tool('read', root, d['path']) + elif d['tool'] == 'omega_check': + st, ob, c = tool('check', root, d['path'], work, OMC, str(kinds[j['kind']]), str(j['k']), str(j.get('n', 0)), str(j['a'])) + else: + st, ob, c = tool('replace', root, d['path'], d['old'], d['new']) + nact += 1 + nxt = turns[i + 1] + if st == 1: + c = '' + got = prompt(j, nxt['state'], c, ob) + if got != nxt['prompt']: + ok = False + print('MISMATCH', j['id'], j['fault'], d['tool'], 'status', st, repr(ob)[:200]) + print(' want', repr(nxt['prompt'][-200:])) + break + if ok: + npass += 1 + else: + nfail += 1 +print(f'TOOL-REPLAY runs={len(runs)} pass={npass} fail={nfail} actions={nact}') +sys.exit(0 if nfail == 0 else 1) diff --git a/seed/node/tool.om b/seed/node/tool.om new file mode 100644 index 000000000..a193b0779 --- /dev/null +++ b/seed/node/tool.om @@ -0,0 +1,875 @@ +note Omega Node tool adapter (DRA-290): the typed coding tools of the +note round40 repair protocol, one bounded process per granted tool. OM-2: +note { printf 'om2\n'; cat seed/agent/path.om seed/node/gram.om seed/node/tool.om; } | omc +note The Node's authority runs it in its own process group (auth_wtool), so +note cancellation kills it and every compiler or test run it started. +note Usage: +note omnode-tool read ROOT PATH +note omnode-tool replace ROOT PATH OLD NEW +note omnode-tool check ROOT PATH WORK OMC KIND K N A +note ROOT is the workspace; PATH must pass omagent's path rule (agpathok, +note seed/agent/path.om) inside it, and the file is opened without following +note a final symbolic link. Files are at most 3800 bytes. +note Record on stdout, exit 0: one line OMNT1 status olen clen, then the +note observation and the file content back to back. Status: 0 done (Read +note succeeded., Edit saved., Tests passed.), 1 File not found., 2 path +note refused, 3 file over 3800 bytes, 4 I/O error, 5 replace refused (old +note must occur exactly once, 1..40 bytes; new 0..40), 6 check failed (the +note observation says why). Exit 2: usage. +note replace writes the new content to PATH.omnode-new, syncs it, renames it +note over PATH and syncs the directory: Edit saved. means durable. +note check follows round40 repair.py compile_test: a source that is empty +note or over 600 bytes is refused; it is compiled with OMC (compile only); +note a compiler error is returned as omc printed it, trimmed; then every +note line must be in the bounded repair grammar, calc and main must appear +note once each, main must keep ret calc int A, and a loop goal needs its +note for loop. Then for each input of A, 0, 3, 7 (distinct, in order) the +note candidate with ret calc int replaced is compiled in WORK and run with +note execpure (Landlock, no new privileges, CPU, file, process and memory +note ceilings, seccomp; at most 2 s wall clock, then SIGKILL), and its exit +note status must equal the goal (KIND 1 add x+K, 2 mul x*K, 3 loop x+K*N) +note with no output. The content returned is the file as checked. +text tnew ".omnode-new" +text trec "OMNT1 " +text oread "Read succeeded." +text onf "File not found." +text oedit "Edit saved." +text opass "Tests passed." +text orefu "Refused unsupported source." +text ofns "Required functions missing." +text omain "main must preserve the requested input." +text oloop "Required loop missing." +text otf1 "Test failed: calc(" +text otf2 ") expected " +text otf3 ", got " +text otf4 "." +text orepl "Old text must occur exactly once." +text opath "Path refused." +text obig "File is over 3800 bytes." +text oio "I/O error." +text cread "read" +text crepl "replace" +text ccheck "check" +text fsrc "c.om" +text fbin "c.bin" +text ferr "c.err" +text fout "c.out" +text fnull "/dev/null" + +note ======== records + +fn tl_out o view uchar * n ulong to void +p = ulong 0 +for it ulong 4096 +if ge p n +ret +end +r = write 1 o p sub n p +if le r 0 +ret +end +p = add p ulong r +end +end + +note The number of decimal digits of v. +fn tl_nd v ulong to ulong +if lt v 10 +ret 1 +end +ret add 1 tl_nd div v 10 +end + +note Append the decimal v to o at p; the new end. +fn tl_dec o edit uchar * p ulong v ulong to ulong +d = new uchar 24 0 +k = ulong 0 +x = v +for i ulong 24 +put d k uchar add 48 rem x 10 +k = add k 1 +x = div x 10 +if eq x 0 +break +end +end +for j ulong k +put o add p j get d sub sub k j 1 +end +ret add p k +end + +fn tl_cat o edit uchar * p ulong a view uchar * n ulong to ulong +for i ulong n +put o add p i get a i +end +ret add p n +end + +note The record: status st, observation ob[0, on), content cb[0, cn). +fn tl_rec st ulong ob view uchar * cb view uchar * cn ulong to int +o = new uchar 8192 0 +p = tl_cat o 0 trec len trec +p = tl_dec o p st +put o p 32 +p = tl_dec o add p 1 len ob +put o p 32 +p = tl_dec o add p 1 cn +put o p 10 +p = tl_cat o add p 1 ob len ob +p = tl_cat o p cb cn +tl_out o p +ret 0 +end + +note ======== files + +note Read path pa into b; the length, -2 not found, -3 over 3800 bytes, +note -4 another error (not a regular file included). +fn tl_slurp pa view uchar * b edit uchar 4096 to long +st = new uchar 128 0 +fd = fopen pa 0 len pa 557056 0 +if eq fd -2 +ret neg long 2 +end +if lt fd 0 +ret neg long 4 +end +r = fstat int fd st 0 128 +md = or ulong get st 16 shl ulong get st 17 8 +if or lt r 0 ne and md 61440 32768 +x = fclose int fd +ret neg long 4 +end +n = ulong 0 +for it ulong 4096 +if ge n 4096 +break +end +k = read int fd b n sub 4096 n +if le k 0 +break +end +n = add n ulong k +end +x = fclose int fd +if gt n 3800 +ret neg long 3 +end +ret long n +end + +note Write b[0, n) to the new file pa (truncated, no final symbolic link) +note and sync it. 0 or negative. +fn tl_spit pa view uchar * b view uchar * n ulong to long +fd = fopen pa 0 len pa 557633 420 +if lt fd 0 +ret fd +end +p = ulong 0 +for it ulong 4096 +if ge p n +break +end +k = write int fd b p sub n p +if le k 0 +x = fclose int fd +ret neg long 5 +end +p = add p ulong k +end +r = fsync int fd +x = fclose int fd +ret r +end + +note Rename a over b (packed list), then sync the directory of b. +fn tl_mv a view uchar * b view uchar * to long +pk = new uchar 4096 0 +na = len a +nb = len b +put pk 0 2 +put pk 2 uchar and na 255 +put pk 3 uchar shr na 8 +for i ulong na +put pk add 4 i get a i +end +o = add 4 na +put pk o uchar and nb 255 +put pk add o 1 uchar shr nb 8 +for j ulong nb +put pk add add o 2 j get b j +end +r = renames pk 0 add add o 2 nb 0 +if lt r 0 +ret r +end +s = ulong 0 +for k ulong nb +if eq get b k 47 +s = k +end +end +dn = new uchar 4096 0 +dl = ulong 1 +put dn 0 46 +if gt s 0 +for m ulong s +put dn m get b m +end +dl = s +end +fd = fopen dn 0 dl 540672 0 +if lt fd 0 +ret fd +end +r = fsync int fd +x = fclose int fd +ret r +end + +note ======== read and replace + +fn tl_read pa view uchar * to int +b = new uchar 4096 0 +if not agpathok pa +ret tl_rec 2 opath b 0 +end +n = tl_slurp pa b +if eq n -2 +ret tl_rec 1 onf b 0 +end +if eq n -3 +ret tl_rec 3 obig b 0 +end +if lt n 0 +ret tl_rec 4 oio b 0 +end +ret tl_rec 0 oread b ulong n +end + +note true when a occurs in b at offset i (b holds at least i + len a bytes). +fn tl_at b view uchar 4096 i ulong a view uchar * to bool +for j ulong len a +if ne get b add i j get a j +ret false +end +end +ret true +end + +note Occurrences of a in b[0, bn), counted without overlap. +fn tl_count b view uchar 4096 bn ulong a view uchar * to ulong +an = len a +c = ulong 0 +i = ulong 0 +for it ulong add bn 1 +if gt add i an bn +ret c +end +if tl_at b i a +c = add c 1 +i = add i an +else +i = add i 1 +end +end +ret c +end + +note The offset of the first occurrence of a in b[0, bn) (one is known). +fn tl_find b view uchar 4096 bn ulong a view uchar * to ulong +for i ulong bn +if tl_at b i a +ret i +end +end +ret bn +end + +note Copy b[s, n) to d at p; the new end. +fn tl_tail d edit uchar 4096 p ulong b view uchar 4096 s ulong n ulong to ulong +for i ulong sub n s +put d add p i get b add s i +end +ret add p sub n s +end + +note Durably replace pa with d[0, dn): PATH.omnode-new written and synced, +note renamed over pa, directory synced. 0 or negative. +fn tl_save pa view uchar * d view uchar 4096 dn ulong to long +tn = new uchar 4096 0 +q = tl_cat tn 0 pa len pa +q = tl_cat tn q tnew len tnew +r = tl_spit view part tn 0 q d dn +if eq r 0 +r = tl_mv view part tn 0 q pa +end +if lt r 0 +x = unlink tn 0 q +end +ret r +end + +note replace with PATH at d[0, L0), OLD at aw[0, L1), NEW at aw[1024, L2). +fn tl_repl d view uchar 8192 aw view uchar 2048 l view ulong 4 to int +b = new uchar 4096 0 +o = new uchar 4096 0 +if not agpathok view part d 0 get l 0 +ret tl_rec 2 opath b 0 +end +if or or eq get l 1 0 gt get l 1 40 gt get l 2 40 +ret tl_rec 5 orepl b 0 +end +n = tl_slurp view part d 0 get l 0 b +if eq n -2 +ret tl_rec 1 onf b 0 +end +if eq n -3 +ret tl_rec 3 obig b 0 +end +if lt n 0 +ret tl_rec 4 oio b 0 +end +if ne tl_count b ulong n view part aw 0 get l 1 1 +ret tl_rec 5 orepl b ulong n +end +p = tl_edit b ulong n aw l o +if gt p 3800 +ret tl_rec 3 obig b ulong n +end +if lt tl_save view part d 0 get l 0 o p 0 +ret tl_rec 4 oio b ulong n +end +ret tl_rec 0 oedit o p +end + +note b[0, n) with its one OLD replaced by NEW into o; the length. +fn tl_edit b view uchar 4096 n ulong aw view uchar 2048 l view ulong 4 o edit uchar 4096 to ulong +i = tl_find b n view part aw 0 get l 1 +p = tl_cat o 0 b i +p = tl_cat o p view part aw 1024 get l 2 get l 2 +ret tl_tail o p b add i get l 1 n +end + +note ======== check + +note The trimmed span of b[0, n) (ASCII white space) into m[0], m[1]. +fn tl_trim b view uchar 4096 n ulong m edit ulong 16 to void +s = ulong 0 +for i ulong n +if gt get b s 32 +break +end +s = add s 1 +end +e = n +for j ulong sub n s +if gt get b sub e 1 32 +break +end +e = sub e 1 +end +put m 0 s +put m 1 e +end + +note Grammar and structure of b[0, n): 0 good, else the refusal (1 +note unsupported, 2 functions, 3 main input, 4 loop). The value of the one +note ret calc int line goes to m[2], its line start to m[3], end to m[4]. +fn tl_shape b view uchar 4096 n ulong kind ulong m edit ulong 16 to ulong +tl_trim b n m +for q ulong 4 +put m add 10 q 0 +end +a = get m 0 +for it ulong add n 1 +if gt a get m 1 +break +end +z = gr_eol b a get m 1 +if not tl_tally b a z m +ret 1 +end +a = add z 1 +end +if or ne get m 10 1 ne get m 11 1 +ret 2 +end +if ne get m 12 1 +ret 3 +end +if and eq kind 3 eq get m 13 0 +ret 4 +end +ret 0 +end + +note Count line b[a, z) into m: 10 calc, 11 main, 12 ret calc int (value +note to m[2], span to m[3], m[4]), 13 for loops. false outside the grammar. +fn tl_tally b view uchar 4096 a ulong z ulong m edit ulong 16 to bool +if not gr_gram b a z +ret false +end +if gr_lin b a z 0 0 +put m 10 add get m 10 1 +end +if gr_lin b a z 1 0 +put m 11 add get m 11 1 +end +if gr_lin b a z 9 1 +put m 13 add get m 13 1 +end +if gr_lin b a z 5 2 +put m 12 add get m 12 1 +put m 2 tl_num b add a len grcal z +put m 3 a +put m 4 z +end +ret true +end + +fn tl_num b view uchar 4096 a ulong e ulong to ulong +v = ulong 0 +for i ulong sub e a +v = add mul v 10 sub ulong get b add a i 48 +end +ret v +end + +note ======== processes + +note Wait for pid up to dl ns; kill its group at the deadline. The wait +note status word (exit code in byte 1, signal in byte 0's low 7 bits). +fn tl_wait pid long dl ulong to ulong +ws = new uchar 4 0 +t0 = ulong monons +for it ulong 100000 +g = waitpid int pid ws 0 4 1 +if gt g 0 +ret or ulong get ws 0 shl ulong get ws 1 8 +end +if lt g 0 +ret 65535 +end +if ge sub ulong monons t0 dl +x = killpid neg int pid 9 +g = waitpid int pid ws 0 4 0 +ret 65535 +end +x = sleepns 1000000 +end +ret 65535 +end + +note The child's stdin (k 0) or stdout (k 1) for mode md, opened. +fn tl_fd md ulong k ulong to long +if eq md 0 +if eq k 0 +ret fopen fsrc 0 len fsrc 524288 0 +end +ret fopen fbin 0 len fbin 524865 448 +end +if eq k 0 +ret fopen fnull 0 len fnull 524288 0 +end +ret fopen fout 0 len fout 524865 448 +end + +note Run the packed argv pk[0, pn) in its own process group. md 0 (the +note compiler): stdin c.om, stdout c.bin, execprog, 10 s. md 1 (a test): +note stdin /dev/null, stdout c.out, execpure, 2 s (round40's timeout). +note stderr to c.err. The wait status, or 65535 when it did not finish +note (its group is killed). +fn tl_run pk view uchar 4096 pn ulong md ulong to ulong +pid = fork +if eq pid 0 +r = setpgid 0 0 +fi = tl_fd md 0 +fo = tl_fd md 1 +fe = fopen ferr 0 len ferr 524865 448 +if or or lt fi 0 lt fo 0 lt fe 0 +exit 120 +end +r = dupfd int fi 0 0 +r = dupfd int fo 1 0 +r = dupfd int fe 2 0 +if eq md 1 +r = execpure pk 0 pn +else +r = execprog pk 0 pn +end +exit 121 +end +if lt pid 0 +ret 65535 +end +r = setpgid int pid int pid +if eq md 1 +ret tl_wait pid 2000000000 +end +ret tl_wait pid 10000000000 +end + +note Pack one or two arguments into pk; the length. +fn tl_pack pk edit uchar 4096 a view uchar * b view uchar * to ulong +na = len a +nb = len b +c = ulong 1 +if gt nb 0 +c = 2 +end +put pk 0 uchar c +put pk 1 0 +put pk 2 uchar and na 255 +put pk 3 uchar shr na 8 +for i ulong na +put pk add 4 i get a i +end +o = add 4 na +if eq c 1 +ret o +end +put pk o uchar and nb 255 +put pk add o 1 uchar shr nb 8 +for j ulong nb +put pk add add o 2 j get b j +end +ret add add o 2 nb +end + +note The trimmed compiler message of file c.err into ob; its length. +fn tl_cerr ob edit uchar 4096 to ulong +b = new uchar 4096 0 +m = new ulong 16 0 +n = tl_slurp ferr b +if lt n 0 +ret 0 +end +tl_trim b ulong n m +k = sub get m 1 get m 0 +for i ulong k +put ob i get b add get m 0 i +end +ret k +end + +note Compile src[0, n) to c.bin in the current (WORK) directory with omc +note path oc. 0 compiled, 1 refused by omc (message in c.err), 2 failed. +fn tl_omc oc view uchar * src view uchar * n ulong to ulong +pk = new uchar 4096 0 +none = new uchar 1 0 +if ne tl_spit fsrc src n 0 +ret 2 +end +pn = tl_pack pk oc view part none 0 0 +ws = tl_run pk pn 0 +if eq ws 0 +ret 0 +end +if ne and ws 127 0 +ret 2 +end +c = and shr ws 8 255 +if or eq c 120 eq c 121 +ret 2 +end +ret 1 +end + +note The wait status ws of a test run as the round40 return code: the exit +note code, or minus the signal. +fn tl_code ws ulong to long +if eq ws 65535 +ret neg long 9 +end +if ne and ws 127 0 +ret neg long and ws 127 +end +ret long and shr ws 8 255 +end + +note Test failed: calc(x) expected w, got g. into ob; its length. +fn tl_tfail ob edit uchar 4096 x ulong w ulong g long to ulong +p = tl_cat ob 0 otf1 len otf1 +p = tl_dec ob p x +p = tl_cat ob p otf2 len otf2 +p = tl_dec ob p w +p = tl_cat ob p otf3 len otf3 +v = ulong 0 +if lt g 0 +put ob p 45 +p = add p 1 +v = ulong neg g +else +v = ulong g +end +p = tl_dec ob p v +ret tl_cat ob p otf4 len otf4 +end + +note The goal for input x of kind m[5] (1 add, 2 mul, 3 loop), K m[6], N m[7]. +fn tl_want m view ulong 16 x ulong to ulong +if eq get m 5 1 +ret add x get m 6 +end +if eq get m 5 2 +ret mul x get m 6 +end +ret add x mul get m 6 get m 7 +end + +note true when the file c.out is empty. +fn tl_quiet to bool +st = new uchar 128 0 +r = stat fout 0 len fout st 0 128 +if lt r 0 +ret false +end +for i ulong 8 +if ne get st add 48 i 0 +ret false +end +end +ret true +end + +note Run c.bin for input m[9]: 0 passed, else the observation's length in ob. +fn tl_exec m view ulong 16 ob edit uchar 4096 to ulong +pk = new uchar 4096 0 +none = new uchar 1 0 +pn = tl_pack pk fbin view part none 0 0 +g = tl_code tl_run pk pn 1 +x = get m 9 +w = tl_want m x +if and eq g long w tl_quiet +ret 0 +end +ret tl_tfail ob x w g +end + +note One test: the candidate b with input x = m[9] (ret calc int line +note m[3]..m[4]) compiled and run. 0 passed, else the length of the +note observation in ob, or 4096 for an I/O failure. +fn tl_test oc view uchar * b view uchar 4096 n ulong m view ulong 16 ob edit uchar 4096 to ulong +c = new uchar 4096 0 +p = tl_cat c 0 b get m 3 +p = tl_cat c p grcal len grcal +p = tl_dec c p get m 9 +p = tl_tail c p b get m 4 n +r = tl_omc oc view part c 0 p p +if eq r 1 +ret tl_cerr ob +end +if ne r 0 +ret 4096 +end +ret tl_exec m ob +end + +note Inputs A, 0, 3, 7 without repeats, in that order: the i-th, or 999. +fn tl_input a ulong i ulong to ulong +v = new ulong 4 0 +put v 0 a +put v 1 0 +put v 2 3 +put v 3 7 +k = ulong 0 +for j ulong 4 +dup = false +for q ulong j +if eq get v q get v j +dup = true +end +end +if not dup +if eq k i +ret get v j +end +k = add k 1 +end +end +ret 999 +end + +note The check of b[0, n) (m[5..8] = kind, K, N, A) in WORK; the record. +fn tl_check2 oc view uchar * b view uchar 4096 n ulong m edit ulong 16 to int +ob = new uchar 4096 0 +if or eq n 0 gt n 600 +ret tl_rec 6 orefu b n +end +r = tl_omc oc b n +if eq r 1 +k = tl_cerr ob +ret tl_rec 6 view part ob 0 k b n +end +if ne r 0 +ret tl_rec 4 oio b n +end +sh = tl_shape b n get m 5 m +if eq sh 1 +ret tl_rec 6 orefu b n +end +if eq sh 2 +ret tl_rec 6 ofns b n +end +if or eq sh 3 ne get m 2 get m 8 +ret tl_rec 6 omain b n +end +note round40 wants the line to read exactly ret calc int A (no leading 0). +if ne sub get m 4 get m 3 add len grcal tl_nd get m 8 +ret tl_rec 6 omain b n +end +if eq sh 4 +ret tl_rec 6 oloop b n +end +for i ulong 4 +x = tl_input get m 8 i +if eq x 999 +break +end +put m 9 x +t = tl_test oc b n m ob +if eq t 4096 +ret tl_rec 4 oio b n +end +if ne t 0 +ret tl_rec 6 view part ob 0 t b n +end +end +ret tl_rec 0 opass b n +end + +note Argument i into a fresh slice of d at offset o (at most 1024 bytes); +note its length, or -1. +fn tl_arg i ulong d edit uchar 8192 o ulong to long +ret argread i d o 1024 +end + +fn tl_cnum i ulong to ulong +b = new uchar 16 0 +n = argread i b 0 16 +if or lt n 1 gt n 3 +ret 999 +end +v = ulong 0 +for j ulong ulong n +c = ulong get b j +if or lt c 48 gt c 57 +ret 999 +end +v = add mul v 10 sub c 48 +end +ret v +end + +note check ROOT PATH WORK OMC KIND K N A, after chdir ROOT. +fn tl_check d edit uchar 8192 to int +b = new uchar 4096 0 +m = new ulong 16 0 +put m 5 tl_cnum 6 +put m 6 tl_cnum 7 +put m 7 tl_cnum 8 +put m 8 tl_cnum 9 +if or or lt get m 5 1 gt get m 5 3 or gt get m 6 99 gt get m 7 99 +ret 2 +end +if gt get m 8 99 +ret 2 +end +on = tl_arg 5 d 0 +pn = tl_arg 3 d 1024 +wn = tl_arg 4 d 2048 +if or or lt on 1 lt pn 1 lt wn 1 +ret 2 +end +put m 14 ulong on +put m 15 ulong pn +ret tl_chk1 d ulong wn m b +end + +note check, with OMC at d[0, m14), PATH at d[1024, m15), WORK at d[2048, wn). +fn tl_chk1 d edit uchar 8192 wn ulong m edit ulong 16 b edit uchar 4096 to int +if not agpathok view part d 1024 get m 15 +ret tl_rec 2 opath b 0 +end +n = tl_slurp view part d 1024 get m 15 b +if eq n -2 +ret tl_rec 1 onf b 0 +end +if eq n -3 +ret tl_rec 3 obig b 0 +end +if lt n 0 +ret tl_rec 4 oio b 0 +end +r = chdir d 2048 wn +if lt r 0 +ret tl_rec 4 oio b 0 +end +ret tl_check2 view part d 0 get m 14 b ulong n m +end + +fn tl_main to int +d = new uchar 8192 0 +c = argcnt +if lt c 4 +ret 2 +end +cn = tl_arg 1 d 4096 +if lt cn 1 +ret 2 +end +rn = tl_arg 2 d 5120 +if lt rn 1 +ret 2 +end +if lt chdir d 5120 ulong rn 0 +ret 2 +end +if and heq2 view part d 4096 ulong cn ccheck eq c 10 +ret tl_check d +end +pn = tl_arg 3 d 0 +if lt pn 0 +ret 2 +end +if and heq2 view part d 4096 ulong cn cread eq c 4 +ret tl_read view part d 0 ulong pn +end +if and heq2 view part d 4096 ulong cn crepl eq c 6 +ret tl_rmain d ulong pn +end +ret 2 +end + +note replace ROOT PATH OLD NEW, with PATH at d[0, pn). +fn tl_rmain d edit uchar 8192 pn ulong to int +aw = new uchar 2048 0 +l = new ulong 4 0 +an = argread 4 aw 0 1024 +wn = argread 5 aw 1024 1024 +if or lt an 0 lt wn 0 +ret 2 +end +put l 0 pn +put l 1 ulong an +put l 2 ulong wn +ret tl_repl d aw l +end + +fn heq2 a view uchar * t view uchar * to bool +if ne len a len t +ret false +end +for i ulong len a +if ne get a i get t i +ret false +end +end +ret true +end + +fn main to int +ret tl_main +end ```