interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

GitHub aien-dev/omega-bridge#54 (code only)

closed derived f28a326db3c228b9 #54

Imported from GitHub aien-dev/omega-bridge#54 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 077d3d22fe811f20d307832676c7f6a5363929e4 · Head 2518f9f788c865c30265af5a09e520885356ac1a

Fetch it

A git bundle of the pull request's head, 30885 bytes.

curl -fsSL https://interplane.io/drakestapleton/omega-bridge/patches/f28a326db3c228b9.bundle -o f28a326db3c228b9.bundle
git fetch f28a326db3c228b9.bundle refs/pull/54/head

Raw bundle · 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-bridge
54
2518f9f788c865c30265af5a09e520885356ac1a
{"kind":"github-import","owner":"aien-dev","repo":"omega-bridge","number":54,"url":"https://github.com/aien-dev/omega-bridge/pull/54","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:40:01Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/README.md b/README.md
index 44bb4b4..19c01c6 100644
--- a/README.md
+++ b/README.md
@@ -79,6 +79,8 @@ A worked integration: [examples/deepinfer](examples/deepinfer/README.md) replace
 
 `f32` and `ushort` array kinds (4-byte and 2-byte elements) are qualified by `OMEGA_NATIVE_OMC=<seeded omc> sh tests/native/kinds.sh`. The contract is in [native call ABI](docs/NATIVE-ABI.md).
 
+`tools/native --host` admits an OM-2 unit that reads files and its own credentials through nine host words (`fclose fopen fstat stat getuid geteuid getgid getegid lstat`), compiled by the OM-2 compiler of omega-mv #1008; without the flag any host word is refused, and every other host word is refused either way. The words used are named in the unit's identity (` host=...`). AArch64 Linux, hosted only. Qualified by section 11 of `tests/native/v2/run.sh`; the contract is in [native call ABI](docs/NATIVE-ABI.md#abi-v2-om-2-units-omega-mv-747-contract-specomegese-om2md-section-6-errata-e1-and-e5).
+
 The native target defaults to `aarch64linux`. Hosted x86-64 SysV Linux bindings
 are selected explicitly; there is no build-host architecture inference:
 
diff --git a/docs/NATIVE-ABI.md b/docs/NATIVE-ABI.md
index 068a8e9..b1b05c3 100644
--- a/docs/NATIVE-ABI.md
+++ b/docs/NATIVE-ABI.md
@@ -7,7 +7,7 @@ adapts the foreign side to them.
 
 ## Target selection and compiler custody
 
-`tools/native [--target aarch64linux|x86linux] [--freestanding] OUTDIR unit.om...`
+`tools/native [--target aarch64linux|x86linux] [--freestanding] [--host] OUTDIR unit.om...`
 selects the output ABI explicitly. The default is `aarch64linux`; it keeps the
 existing generator invocation and compiler inputs unchanged. The tool does not
 infer a target from the build host or try to execute a generated library.
@@ -600,8 +600,9 @@ toolchain) with its vector count and toolchain path.
 ABI v2 adds to every v1 rule and check above; nothing in v1 changes. An OM-2 unit is one whose first
 line that is not a note (a line whose first word is `note`) is exactly `om2`; a first such line that
 starts with the word `om2` but is not exactly `om2` (`om2 diag`, `om2 fmt`) is refused. Every other
-unit is OM-1 and gets the v1 binding, byte for byte what the generator of 3f05908 writes (checked on
-every unit in `tests/native` and `tests/native/g1`, alone and as the v1 suite's set, in all six outputs).
+unit is OM-1 and gets the v1 binding, byte for byte what the generator of f637021 writes (checked on
+every unit in `tests/native` and `tests/native/g1`, alone and as the v1 suite's set, in all six outputs;
+the baseline was 3f05908 until #26 (f637021)'s f32 and ushort kinds changed the Python output for every unit).
 
 **Symbols.** Every OM-2 unit is bound as v2, whatever its parameter kinds (erratum E1): each
 `export fn NAME` (source order) gets `uint32_t omega2_NAME(uint64_t *result, ...)`; without any
@@ -693,6 +694,26 @@ function and can be linked into a freestanding binding. The prototypes stay thos
 memory passed as edit. Function-mode stack exhaustion faults as in v1. Loops in the seeded compiler
 run at most 1,000,000 passes (trap 4 beyond); a unit over a longer view must loop in parts (`part`).
 
+**Host words** (`tools/native --host`; omega-mv #1008, `fn hostval` in `seed/omc/omc.om`). The OM-2
+compiler of omega-mv #1008 (omc sha256 `3988c31f9697a01f1436b7a75f6c956b37bc5301155b3ec8ca1b06b92118f7c4`)
+lets an OM-2 function unit use nine host words: `fclose fopen fstat stat getuid geteuid getgid getegid
+lstat`. Every other host word stays refused in function mode by the compiler, and OM-1 units get none.
+The bridge admits such a unit only when the caller asks: without `--host`, a unit whose source names any
+of the 83 host words (outside a note line) is refused with status 110 and nothing is installed; with
+`--host`, the nine words are admitted in an OM-2 unit and every other host word, or any host word in an
+OM-1 unit, is still refused. `src/native.om` judges the source itself (`fn hscan`): words are split at
+blanks, tabs, CR, LF and parentheses as the compiler splits them, and a line whose first word is exactly
+`note` is skipped, so a note may name a host word. The scan is conservative: a host word inside a text
+literal also counts. The identity of a unit that uses any of the nine gains ` host=w1,w2,...` (the words
+in the order above, only those used), in the embedded string and in `work/ident.txt`, which then comes
+from the generator (output word `ident`) for every OM-2 unit; a unit without host words gets the same
+bytes with and without `--host`. `--host` is AArch64 Linux only and hosted only: with `--target x86linux`
+or `--freestanding` it is refused (110) before OUTDIR is created. The words run on the calling thread
+with its credentials and file descriptors; a descriptor a unit opens is the process's descriptor until
+the unit closes it, and a trap between `fopen` and `fclose` leaks it (write units so nothing between
+them can trap). Out buffers still live on the Omega stack until the copy after status 0: a unit that
+returns a secret leaves a copy there until the thread's next call overwrites it.
+
 ### AArch64 qualification (`OMEGA_NATIVE_OMC=<seed omc> OMEGA_NATIVE_OMC2=<OM-2 omc> sh tests/native/v2/run.sh [measure]`)
 
 Recorded with the OM-2 compiler of omega-mv `om2/compiler-s4` @ f6a6492fd (draft PR #764, ledger L834),
@@ -736,6 +757,20 @@ prototype-only branch disabled (definitions in `omega_api_decl.h`: the freestand
 undeclared `abort`), and the inline branch disabled (`omega_api.h` loses `static inline`: caught by the
 byte-identity check).
 
+Host words (section 11): without `--host`, `tests/native/v2/host/hfile.om` (all nine words) is refused
+and nothing is installed; `--host --freestanding` and `--host --target x86linux` are refused before
+OUTDIR; with `--host` its identity names the nine words, and a C caller (`hcall.c`) and a Rust caller
+(`hcall.rs`) check its results against libc and `std`: the uid/gid sum, a 5-byte read, `-ENOENT` for a
+missing path, `-ELOOP` for a symlink (`fopen` with `O_NOFOLLOW`), `st_size`. The v2 set built with
+`--host` is byte-identical in all nine outputs. The generator, fed directly: `geteuid` after `(`, a tab
+and before a CR is refused without host and named with it; host words in note lines (also indented,
+tab-separated) pass without host; `(note geteuid` is not a note; `unlink` (outside the nine) and
+`geteuid` in an OM-1 unit are refused even with host; `getuidx` is not a host word; the freestanding
+outputs `freest` and `fapic` refuse `host` (exit 110) on a unit they accept without it. Mutant: the scan
+removed from `fn unit` lets the parenthesised `geteuid` through without host (caught). The zig and go
+callers need their toolchains on PATH (zig 0.13.0, go 1.27.3 were used); without them the run reports
+NOT_RUN and exits 1.
+
 The C caller covers: values; empty views (NULL, misaligned); NULL with len 1; misalignment by 1, 2 and
 4 for 4- and 8-byte elements and an edit; `len*size` overflow (2^62 x 4, 2^61 x 8, 2^64-1); address wrap
 at 2^64-16 (end 2^64 refused, end 2^64-8 accepted); a 2^32+5-element length accepted and passed whole
diff --git a/src/native.om b/src/native.om
index 3eece7b..4f99927 100644
--- a/src/native.om
+++ b/src/native.om
@@ -30,6 +30,15 @@ global ue ulong 256
 text hx "0123456789abcdef"
 global xt ulong 1
 text xtname "x86linux"
+note Host words (docs/NATIVE-ABI.md, host words): hok is 1 when the generator's second argument is host,
+note hm the host words the current unit uses (bit k-1 for word k of hw). hw lists every host word of the
+note omc keyword table; only its first nine (the file and identity words an OM-2 function unit may
+note use) can pass, and only with host; any other refuses the unit.
+global hok ulong 1
+global hm ulong 1
+text hname "host"
+text hpre " host="
+text hw "|fclose|fopen|fstat|stat|getuid|geteuid|getgid|getegid|lstat|fsync|fchmod|fseek|socknew|listen|accept|fork|dupfd|monons|unlink|makedir|getdnts|connect|bind|waitpid|recv|send|sleepns|argcnt|argread|waitio|execprog|renames|rmdir|killpid|pipefds|getpid|realns|sockname|cwd|readlnk|sockopt|random|envcnt|envread|chdir|ftrunc|link|symlnk|chmod|faccess|truncate|chown|fchdir|getppid|umask|fdsync|memfd|setsid|getpgid|setpgid|pread|pwrite|getsid|syncfs|shutdown|devctl|mapnew|mapdrop|mapread|mapwrite|devcall|uvmctl|mapaddr|mapget|mapset|maphold|mapbind|flock|execpure|peercred|pollfds|sendmsg|peername|"
 text xjmp ") \":\\nendbr64\\njmp \" OMBR_SYM(ombr_code_~) \":\\nendbr64\\njmp \" OMBR_SYM(ombr2_code_"
 text xasm "/* SysV AMD64 adapter to the pinned private Omega frame ABI. R12 anchors the native\n * stack, R14 the runtime table, R15 the owned-stack floor. Advanced host helpers\n * that clobber those registers are forbidden in function mode; legacy read/write preserve them.\n * CET shadow-stack enforcement is not supported by the nonlocal trap return. */\n__asm__(\".text\\n.balign 16\\n.local ombr_enter\\n.hidden ombr_enter\\n.type ombr_enter,@function\\nombr_enter:\\n\"\n        \"endbr64\\npush %rbx\\npush %rbp\\npush %r12\\npush %r13\\npush %r14\\npush %r15\\npush %rcx\\n\"\n        \"mov %rsp,%r12\\nmov %rdx,%r14\\nmov %r9,%r15\\nmov %rdi,%r10\\n\"\n        \"mov %r8,%rbp\\nmov %r8,%rsp\\nsub $256,%rsp\\n\"\n        \"mov 0(%rsi),%rax\\nmov %rax,-8(%rbp)\\nmov 8(%rsi),%rax\\nmov %rax,-16(%rbp)\\n\"\n        \"mov 16(%rsi),%rax\\nmov %rax,-24(%rbp)\\nmov 24(%rsi),%rax\\nmov %rax,-32(%rbp)\\n\"\n        \"mov 32(%rsi),%rax\\nmov %rax,-40(%rbp)\\nmov 40(%rsi),%rax\\nmov %rax,-48(%rbp)\\n\"\n        \"call *%r10\\nmov %r12,%rsp\\nmov (%rsp),%rcx\\nmov %rax,(%rcx)\\nxor %eax,%eax\\n\"\n        \"ombr_leave:\\nadd $8,%rsp\\npop %r15\\npop %r14\\npop %r13\\npop %r12\\npop %rbp\\npop %rbx\\nret\\n\"\n        \".size ombr_enter,.-ombr_enter\\n.local ombr_trap\\n.hidden ombr_trap\\n.type ombr_trap,@function\\nombr_trap:\\n\"\n        \"endbr64\\nmov %r12,%rsp\\nlea -1(%rsi),%eax\\ncmp $13,%eax\\nmov $34,%eax\\ncmovbe %esi,%eax\\njmp ombr_leave\\n\"\n        \".size ombr_trap,.-ombr_trap\\n.local ombr_no_entry\\n.hidden ombr_no_entry\\n.type ombr_no_entry,@function\\nombr_no_entry:\\n\"\n        \"endbr64\\nmov %r12,%rsp\\nmov $34,%eax\\njmp ombr_leave\\n.size ombr_no_entry,.-ombr_no_entry\\n\");\nuint32_t ombr_xenter(const void *code, const uint64_t *args, const ombr_rt *rt, uint64_t *out, void *top, void *floor) __asm__(\"ombr_enter\") __attribute__((visibility(\"hidden\")));\n/* The true mapping floor must not move when ABI-v2 out buffers lower top. */\n#define ombr_enter(code,args,rt,out,top) ombr_xenter(code,args,rt,out,top,ombr_stk - OMBR_STACK)\n"
 text xs "/* ombr_enter"
@@ -44,7 +53,7 @@ text fr "__asm__(OMBR_CODE_SECTION \".balign 4\\n\" OMBR_LOCAL(ombr_code_~) OMBR
 text pre "/* Generated by omega-bridge src/native.om: native call ABI v1 (docs/NATIVE-ABI.md).\n * The Omega machine code below is embedded byte for byte as the seeded compiler wrote it.\n * This file only adapts the C calling convention to it. Regenerate it; do not edit it. */\n#include <pthread.h>\n#include <signal.h>\n#include <stdint.h>\n#include <sys/mman.h>\n#define OMEGA_OK 0u\n#define OMEGA_BAD_ARG 32u\n#define OMEGA_REENTRY 33u\n#define OMEGA_BAD_RT 34u\n#define OMEGA_NO_STACK 35u\n#define OMBR_STACK (8u << 20)\n#define OMBR_GUARD (8u << 20)\n/* entry[2] is the trap entry (OSC-1 section 7). */\ntypedef struct ombr_rt { const void *entry[32]; } ombr_rt;\ntypedef struct ombr_span { uintptr_t lo, hi; int w; } ombr_span;\nstatic _Thread_local volatile sig_atomic_t ombr_active;\nstatic _Thread_local unsigned char *ombr_stk;\nstatic pthread_key_t ombr_key;\nstatic int ombr_keyok;\nstatic pthread_once_t ombr_once = PTHREAD_ONCE_INIT;\nuint32_t ombr_enter(const void *code, const uint64_t *args, const ombr_rt *rt, uint64_t *out, void *top)\n    __attribute__((visibility(\"hidden\")));\nextern const unsigned char ombr_trap[] __attribute__((visibility(\"hidden\")));\nextern const unsigned char ombr_no_entry[] __attribute__((visibility(\"hidden\")));\n/* The object format's spelling of the embedded code and runtime symbols. ELF keeps them local and hidden\n * in .text.omega_bridge. Mach-O (macOS) prefixes C symbol names with an underscore and keeps them local\n * by not declaring them .globl; .alt_entry keeps the runtime entries in ombr_enter's atom. */\n#if defined(__APPLE__) && defined(__MACH__)\n#define OMBR_SYM(n) \"_\" #n\n#define OMBR_LOCAL(n) \"\"\n#define OMBR_HIDDEN(n) \"\"\n#define OMBR_FUNC(n) \"\"\n#define OMBR_ALT(n) \".alt_entry _\" #n \"\\n\"\n#define OMBR_SIZE(n) \"\"\n#define OMBR_LEAVE \"Lombr_leave\"\n#define OMBR_CODE_SECTION \".section __TEXT,__text,regular,pure_instructions\\n\"\n#define OMBR_PREVIOUS \"\"\n#elif defined(__ELF__)\n#define OMBR_SYM(n) #n\n#define OMBR_LOCAL(n) \".local \" #n \"\\n\"\n#define OMBR_HIDDEN(n) \".hidden \" #n \"\\n\"\n#define OMBR_FUNC(n) \".type \" #n \",%function\\n\"\n#define OMBR_ALT(n) OMBR_FUNC(n)\n#define OMBR_SIZE(n) \".size \" #n \",.-\" #n \"\\n\"\n#define OMBR_LEAVE \"ombr_leave\"\n#define OMBR_CODE_SECTION \".section .text.omega_bridge,\\\"ax\\\",@progbits\\n\"\n#define OMBR_PREVIOUS \".previous\\n\"\n#else\n#error \"omega-bridge native binding: ELF or Mach-O objects only\"\n#endif\n/* ombr_enter saves the callee-saved registers on the caller's stack, keeps that stack pointer in x19 and\n * runs the code on the binding's own stack. A normal return stores x0 through out and\n * returns 0. A runtime entry restores the stack pointer from x19 and returns a status; out is not\n * written. A unit's code must not write x18, x19 or x29 and must keep sp balanced; it may write x0..x17,\n * x20..x28 and v0..v31 (x20..x28 and d8..d15 are restored here). Runtime entries are reached by blr/br, so they start with bti jc. */\n#if !defined(__aarch64__)\n#error \"omega-bridge native binding: the embedded code is AArch64\"\n#endif\n__asm__(\".text\\n.balign 4\\n\" OMBR_LOCAL(ombr_enter) OMBR_HIDDEN(ombr_enter) OMBR_FUNC(ombr_enter)\n        OMBR_SYM(ombr_enter) \":\\n\"\n        \"hint #34\\nstp x29,x30,[sp,#-176]!\\nmov x29,sp\\nstp x19,x20,[sp,#16]\\nstp x21,x22,[sp,#32]\\n\"\n        \"stp x23,x24,[sp,#48]\\nstp x25,x26,[sp,#64]\\nstp x27,x28,[sp,#80]\\nstp d8,d9,[sp,#96]\\n\"\n        \"stp d10,d11,[sp,#112]\\nstp d12,d13,[sp,#128]\\nstp d14,d15,[sp,#144]\\nstr x3,[sp,#160]\\n\"\n        \"mov x19,sp\\nmov x16,x0\\nmov x17,x1\\nmov x7,x2\\nmov sp,x4\\n\"\n        \"ldp x0,x1,[x17]\\nldp x2,x3,[x17,#16]\\nldp x4,x5,[x17,#32]\\nblr x16\\n\"\n        \"mov sp,x19\\nldr x9,[sp,#160]\\nstr x0,[x9]\\nmov w0,#0\\n\"\n        OMBR_LEAVE \":\\nldp d14,d15,[sp,#144]\\nldp d12,d13,[sp,#128]\\nldp d10,d11,[sp,#112]\\n\"\n        \"ldp d8,d9,[sp,#96]\\nldp x27,x28,[sp,#80]\\nldp x25,x26,[sp,#64]\\nldp x23,x24,[sp,#48]\\n\"\n        \"ldp x21,x22,[sp,#32]\\nldp x19,x20,[sp,#16]\\nldp x29,x30,[sp],#176\\nret\\n\" OMBR_SIZE(ombr_enter)\n        OMBR_LOCAL(ombr_trap) OMBR_HIDDEN(ombr_trap) OMBR_ALT(ombr_trap) OMBR_SYM(ombr_trap) \":\\nhint #38\\n\"\n        \"mov sp,x19\\nsub x2,x1,#1\\nmov w3,#34\\ncmp x2,#13\\ncsel w0,w1,w3,ls\\nb \" OMBR_LEAVE \"\\n\"\n        OMBR_SIZE(ombr_trap)\n        OMBR_LOCAL(ombr_no_entry) OMBR_HIDDEN(ombr_no_entry) OMBR_ALT(ombr_no_entry) OMBR_SYM(ombr_no_entry) \":\\nhint #38\\n\"\n        \"mov sp,x19\\nmov w0,#34\\nb \" OMBR_LEAVE \"\\n\" OMBR_SIZE(ombr_no_entry));\nstatic void ombr_free(void *p)\n{\n    munmap(p, OMBR_STACK + OMBR_GUARD);\n}\nstatic void ombr_init(void)\n{\n    ombr_keyok = pthread_key_create(&ombr_key, ombr_free) == 0;\n}\n/* The thread's Omega stack: OMBR_STACK usable bytes above an OMBR_GUARD no-access region. A function-mode\n * unit has no call cycles and at most 4 MiB of local arrays per function (OMEGESE, local arrays), so a frame that\n * would pass the bottom starts inside the guard and faults there; nothing below the guard is touched. */\nstatic unsigned char *ombr_stack(void)\n{\n    if (ombr_stk)\n        return ombr_stk;\n    pthread_once(&ombr_once, ombr_init);\n    if (!ombr_keyok)\n        return 0;\n    unsigned char *p = mmap(0, OMBR_STACK + OMBR_GUARD, PROT_READ | PROT_WRITE,\n                            MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0);\n    if (p == MAP_FAILED)\n        return 0;\n    if (mprotect(p, OMBR_GUARD, PROT_NONE) != 0 || pthread_setspecific(ombr_key, p) != 0) {\n        munmap(p, OMBR_STACK + OMBR_GUARD);\n        return 0;\n    }\n    ombr_stk = p + OMBR_GUARD + OMBR_STACK;\n    return ombr_stk;\n}\nstatic int ombr_span_add(ombr_span *sp, unsigned *ns, const void *p, uint64_t n, uint64_t want, uint64_t es, int w)\n{\n    uintptr_t lo = (uintptr_t)p;\n    if (!p || n != want || lo % es != 0u || n > (UINTPTR_MAX - lo) / es)\n        return 1;\n    sp[*ns].lo = lo;\n    sp[*ns].hi = lo + n * es;\n    sp[*ns].w = w;\n    (*ns)++;\n    return 0;\n}\nstatic int ombr_overlap(const ombr_span *sp, unsigned ns)\n{\n    for (unsigned i = 0; i < ns; i++)\n        for (unsigned j = i + 1; j < ns; j++)\n            if ((sp[i].w || sp[j].w) && sp[i].lo < sp[j].hi && sp[j].lo < sp[i].hi)\n                return 1;\n    return 0;\n}\n/* One read-only runtime table for every call and thread: the code only reads it (a write would fault). */\nstatic const ombr_rt ombr_rt_table = {{ ombr_no_entry, ombr_no_entry, ombr_trap, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry }};\nstatic uint32_t ombr_run(const void *code, const uint64_t *args, uint64_t *result, int has_value)\n{\n    if (ombr_active)\n        return OMEGA_REENTRY;\n    ombr_active = 1;\n    unsigned char *top = ombr_stack();\n    if (!top) {\n        ombr_active = 0;\n        return OMEGA_NO_STACK;\n    }\n    uint64_t v = 0;\n    uint32_t s = ombr_enter(code, args, &ombr_rt_table, &v, top);\n    ombr_active = 0;\n    if (s == OMEGA_OK)\n        *result = has_value ? v : 0u;\n    return s;\n}\n"
 note mo: the output names; tb: the binding texts, fragments separated by ~ (byte 126): 0-11 h,
 note 12-21 python, 22-34 rust, 35-46 zig, 47-64 go (its C preamble includes the generated header).
-text mo "chpythonrustziggoapihapicfreestfapic"
+text mo "chpythonrustziggoapihapicfreestidentfapic"
 text tb "/* Generated by omega-bridge src/native.om: native call ABI v1 (docs/NATIVE-ABI.md).\n * C and C++ declarations for libomega_native. Regenerate it; do not edit it.\n * Status: 0 done; 1..14 the Omega trap code; 32 argument refused (null, wrong length, misaligned,\n * overlap); 33 reentry; 34 bad runtime entry; 35 no stack. The result is written only on status 0.\n * A long is its two's-complement bits; an array is its address then its element count.\n * Parameter names carry o_ so no language's reserved words collide. */\n#ifndef OMEGA_NATIVE_H\n#define OMEGA_NATIVE_H\n#include <stdint.h>\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n#define OMEGA_OK 0u\n#define OMEGA_BAD_ARG 32u\n#define OMEGA_REENTRY 33u\n#define OMEGA_BAD_RT 34u\n#define OMEGA_NO_STACK 35u\n~/* ~ */\nuint32_t omega_~(uint64_t *result~, uint64_t o_~, void *o_~, const void *o_~, void *o_~, const void *o_~_len~);\n~#ifdef __cplusplus\n}\n#endif\n#endif\n~# Generated by omega-bridge src/native.om: native call ABI v1 (docs/NATIVE-ABI.md).\n# ctypes declarations for libomega_native.so beside this file. Regenerate it; do not edit it.\n# Status: 0 done; 1..14 the Omega trap code; 32 argument refused (None, wrong length, misaligned,\n# overlap); 33 reentry; 34 bad runtime entry; 35 no stack. The result (a ctypes.c_uint64 passed with\n# ctypes.byref) is written only on status 0. A scalar is an int in 0 .. 2**64-1 (a long is passed as its\n# two's-complement bits); anything else raises ctypes.ArgumentError, nothing is truncated. An array is a\n# ctypes array of its element type (bytes for a view uchar, c_float for f32, c_uint16 for ushort) then its element count; an edit array must\n# be writable, so bytes are refused there.\nimport ctypes, os, sys\nOMEGA_OK, OMEGA_BAD_ARG, OMEGA_REENTRY, OMEGA_BAD_RT, OMEGA_NO_STACK = 0, 32, 33, 34, 35\nlib = ctypes.CDLL(os.path.join(os.path.dirname(os.path.abspath(__file__)),\n    \"libomega_native.dylib\" if sys.platform == \"darwin\" else \"libomega_native.so\"))\nclass _u64:\n    @classmethod\n    def from_param(cls, v):\n        if type(v) is not int or v < 0 or v > 18446744073709551615:\n            raise ValueError(\"omega scalar: an int in 0 .. 2**64-1 expected, got %r\" % (v,))\n        return ctypes.c_uint64(v)\n_res = ctypes.POINTER(ctypes.c_uint64)\n_a3 = ctypes.POINTER(ctypes.c_uint64)  # edit ulong: a writable ctypes array of c_uint64\n_a4 = ctypes.POINTER(ctypes.c_uint64)  # view ulong: a ctypes array of c_uint64\n_a5 = ctypes.POINTER(ctypes.c_ubyte)  # edit uchar: a writable ctypes array of c_ubyte\n_a6 = ctypes.c_char_p  # view uchar: bytes, or a ctypes array of c_char\n_a7 = ctypes.POINTER(ctypes.c_float)  # edit f32: a writable ctypes array of c_float\n_a8 = ctypes.POINTER(ctypes.c_float)  # view f32: a ctypes array of c_float\n_a9 = ctypes.POINTER(ctypes.c_uint16)  # edit ushort: a writable ctypes array of c_uint16\n_a10 = ctypes.POINTER(ctypes.c_uint16)  # view ushort: a ctypes array of c_uint16\n~# ~\nomega_~ = lib.omega_~\nomega_~.argtypes = [_res~, _u64~, _a~]\nomega_~.restype = ctypes.c_uint32\n~// Generated by omega-bridge src/native.om: native call ABI v1 (docs/NATIVE-ABI.md).\n// Declarations for libomega_native (build with -L <its directory>; Rust 1.82 or later). Regenerate it; do not edit it.\n// Status: 0 done; 1..14 the Omega trap code; 32 argument refused (null, wrong length, misaligned,\n// overlap); 33 reentry; 34 bad runtime entry; 35 no stack. The result is written only on status 0.\n// A long is its two's-complement bits (an i64 as u64); an array is its pointer then its element count.\n#[allow(dead_code)]\npub const OMEGA_OK: u32 = 0;\n#[allow(dead_code)]\npub const OMEGA_BAD_ARG: u32 = 32;\n#[allow(dead_code)]\npub const OMEGA_REENTRY: u32 = 33;\n#[allow(dead_code)]\npub const OMEGA_BAD_RT: u32 = 34;\n#[allow(dead_code)]\npub const OMEGA_NO_STACK: u32 = 35;\n#[allow(dead_code)]\n#[link(name = \"omega_native\")]\nunsafe extern \"C\" {\n~    // ~\n    pub fn omega_~(result: *mut u64~, o_~: u64~: *mut u64~: *const u64~: *mut u8~: *const u8~_len: u64~) -> u32;\n~}\n~// Generated by omega-bridge src/native.om: native call ABI v1 (docs/NATIVE-ABI.md).\n// Declarations for libomega_native (build with -L<its directory> -lomega_native -lc). Regenerate it; do not edit it.\n// Status: 0 done; 1..14 the Omega trap code; 32 argument refused (null, wrong length, misaligned,\n// overlap); 33 reentry; 34 bad runtime entry; 35 no stack. The result is written only on status 0.\n// A long is its two's-complement bits (@bitCast); an array is its pointer then its element count.\npub const OMEGA_OK: u32 = 0;\npub const OMEGA_BAD_ARG: u32 = 32;\npub const OMEGA_REENTRY: u32 = 33;\npub const OMEGA_BAD_RT: u32 = 34;\npub const OMEGA_NO_STACK: u32 = 35;\n~// ~\npub extern fn omega_~(result: ?*u64~, o_~: u64~: ?[*]u64~: ?[*]const u64~: ?[*]u8~: ?[*]const u8~_len: u64~) u32;\n~// Generated by omega-bridge src/native.om: native call ABI v1 (docs/NATIVE-ABI.md).\n// cgo package omeganative: this file, omega_native.h and libomega_native.so in one folder. Regenerate it;\n// do not edit it. No run-time path is baked in: the program's build names the folder (CGO_LDFLAGS set to\n// -Wl,-rpath,<folder>), or LD_LIBRARY_PATH does.\n// Status: 0 done; 1..14 the Omega trap code; 32 argument refused (nil, wrong length, misaligned,\n// overlap); 33 reentry; 34 bad runtime entry; 35 no stack. The result is written only on status 0.\n// A long is its two's-complement bits (an int64 as uint64); an array is an unsafe.Pointer to memory\n// holding no Go pointers, then its element count.\npackage omeganative\n\n/*\n#cgo CFLAGS: -I${SRCDIR}\n#cgo LDFLAGS: -L${SRCDIR} -lomega_native\n#include \"omega_native.h\"\n*/\nimport \"C\"\n\nimport \"unsafe\"\n\nconst (\n\tOmegaOK uint32 = 0\n\tOmegaBadArg uint32 = 32\n\tOmegaReentry uint32 = 33\n\tOmegaBadRt uint32 = 34\n\tOmegaNoStack uint32 = 35\n)\n~\n// ~\nfunc Omega_~(result *uint64~, o_~ uint64~ unsafe.Pointer~ unsafe.Pointer~ unsafe.Pointer~ unsafe.Pointer~_len uint64~) uint32 {\n\treturn uint32(C.omega_~((*C.uint64_t)(unsafe.Pointer(result))~, C.uint64_t(o_~)~, o_~_len)~))\n}\n"
 note Freestanding output (freest) accepts pure units only: no storage (global, text), host words, floats
 note or input; an OM-1 unit integer scalars only (no arrays). fw lists the words a pure unit may use; the
@@ -437,13 +446,30 @@ end
 end
 ret 1
 end
-note rmode: the one argument as an output number: 1 c, 2 h, 3 python, 4 rust, 5 zig, 6 go.
+note hostarg: 1 when the second argument (z bytes, read into md) is host.
+fn hostarg z long to ulong
+if ne z 4
+ret 0
+end
+for j ulong 4
+if ne get md j get hname j
+ret 0
+end
+end
+ret 1
+end
+note rmode: the first argument as an output number: 1 c, 2 h, 3 python, 4 rust, 5 zig, 6 go, 7 api,
+note 8 apih, 9 apic, 10 freest, 11 ident (each OM-2 unit's identity, one line each). An optional second
+note argument is x86linux or host.
 fn rmode to ulong
 if or lt argcnt 2 gt argcnt 3
 trap 10
 end
 if eq argcnt 3
 z = argread 2 md 0 8
+if eq hostarg z 1
+put hok 0 1
+else
 if ne z 8
 trap 10
 end
@@ -454,6 +480,7 @@ end
 end
 put xt 0 1
 end
+end
 k = argread 1 md 0 8
 if lt k 0
 trap 10
@@ -493,6 +520,12 @@ end
 if eq mdis 31 5 1
 m = 11
 end
+if eq mdis 36 5 1
+m = 12
+end
+if and eq get hok 0 1 or eq m 10 eq m 12
+trap 10
+end
 if eq m 0
 trap 10
 end
@@ -1942,6 +1975,37 @@ ohx8
 ofv 13
 h = get s2 3
 orng h add h 64
+ohost
+end
+note ohost: " host=W,W" naming the host words the unit uses (hm) in hw order; nothing when it uses none.
+fn ohost to void
+m = get hm 0
+if eq m 0
+ret
+end
+for j ulong len hpre
+ob get hpre j
+end
+c = ulong 0
+k = ulong 0
+i = ulong 1
+while lt k 9
+j = i
+while ne get hw j 124
+j = add j 1
+end
+if ne and shr m k 1 0
+if gt c 0
+ob uchar 44
+end
+for x ulong sub j i
+ob get hw add i x
+end
+c = add c 1
+end
+k = add k 1
+i = add j 1
+end
 end
 fn esz j ulong to ulong
 ret tsize get qt j
@@ -2670,7 +2734,7 @@ ofv 32
 opn j
 end
 end
-if eq get st 5 11
+if eq get st 5 12
 ofq 5
 else
 ofv 143
@@ -2706,7 +2770,7 @@ end
 if eq m 6
 goone
 end
-if and ge m 7 ne m 10
+if or and ge m 7 le m 9 eq m 12
 apone
 end
 end
@@ -2773,8 +2837,113 @@ end
 if eq m 4
 rsid
 end
+if eq m 11
+oid
+ob uchar 10
+end
 ret nx
 end
+note hsep: 1 when byte b separates words for omc (space, tab, carriage return, newline, ( or )).
+fn hsep b uchar to ulong
+if eq hblank b 1
+ret 1
+end
+if or or eq b 10 eq b 40 eq b 41
+ret 1
+end
+ret 0
+end
+note hblank: 1 when byte b is a blank for omc (space, tab, carriage return).
+fn hblank b uchar to ulong
+if or or eq b 32 eq b 9 eq b 13
+ret 1
+end
+ret 0
+end
+note hwfind: k when bytes s .. x-1 are word k (from 1) of hw, else 0.
+fn hwfind s ulong x ulong to ulong
+n = sub x s
+k = ulong 0
+i = ulong 1
+while lt i len hw
+j = i
+while ne get hw j 124
+j = add j 1
+end
+k = add k 1
+if eq sub j i n
+if eq hweq s i n 1
+ret k
+end
+end
+i = add j 1
+end
+ret 0
+end
+fn hweq s ulong o ulong n ulong to ulong
+for j ulong n
+if ne get inb add s j get hw add o j
+ret 0
+end
+end
+ret 1
+end
+note hword: the unit uses host word k; refused unless the generator has host, the unit is OM-2 (v2 1) and
+note k is one of the first nine.
+fn hword k ulong v2 ulong to void
+if eq get hok 0 0
+trap 10
+end
+if or gt k 9 eq v2 0
+trap 10
+end
+put hm 0 or get hm 0 shl 1 sub k 1
+end
+note hline: every word of bytes s .. e-1 through hwfind and hword.
+fn hline s ulong e ulong v2 ulong to void
+i = s
+while lt i e
+if eq hsep get inb i 1
+i = add i 1
+else
+x = i
+while and lt x e eq hsep get inb x 0
+x = add x 1
+end
+k = hwfind i x
+if gt k 0
+hword k v2
+end
+i = x
+end
+end
+end
+note hscan: the host words of the unit at p .. q-1, split as omc splits words. A line whose first
+note blank-separated word is exactly note is skipped; a host word inside a text literal refuses the unit
+note too (fail closed).
+fn hscan p ulong q ulong v2 ulong to void
+put hm 0 0
+i = p
+while lt i q
+e = lend i q
+s = i
+while and lt s e eq hblank get inb s 1
+s = add s 1
+end
+x = s
+while and lt x e eq hblank get inb x 0
+x = add x 1
+end
+nt = ulong 0
+if eq sub x s 4
+nt = atkv s e 50 4
+end
+if eq nt 0
+hline s e v2
+end
+i = add e 1
+end
+end
 note unit: accept the unit at p, emit it, return where the next unit starts.
 fn unit p ulong to ulong
 q = sepat p
@@ -2782,7 +2951,9 @@ if eq get st 5 10
 put fo2 0 prof p q
 fcheck p q
 end
-if eq prof p q 1
+v = prof p q
+hscan p q v
+if eq v 1
 ret unit2 p q
 end
 fl = sigln p q
@@ -2849,7 +3020,7 @@ end
 if eq m 9
 ofa 3
 end
-if eq m 11
+if eq m 12
 ofq 6
 end
 end
diff --git a/tests/native/v2/host/hcall.c b/tests/native/v2/host/hcall.c
new file mode 100644
index 0000000..4a80f0e
--- /dev/null
+++ b/tests/native/v2/host/hcall.c
@@ -0,0 +1,39 @@
+/* hcall.c: the C oracle for hfile.om through the --host library (tests/native/v2/run.sh, section 11).
+ * hcall FILE MISSING LINK: FILE holds 5 bytes, MISSING does not exist, LINK is a symlink to FILE.
+ * Each expectation is computed here by libc, independently of the Omega unit. */
+#define _GNU_SOURCE
+#include <errno.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include "omega_native.h"
+
+static int bad;
+static void check(const char *what, int ok) {
+    printf("%s %s\n", ok ? "PASS" : "FAIL", what);
+    if (!ok) bad = 1;
+}
+
+static int64_t peek(const char *p) {
+    uint64_t r = 0;
+    if (omega2_peek(&r, (const uint8_t *)p, strlen(p)) != OMEGA_OK) return INT64_MIN;
+    return (int64_t)r;
+}
+
+int main(int argc, char **argv) {
+    if (argc != 4) { fprintf(stderr, "usage: hcall FILE MISSING LINK\n"); return 2; }
+    uint64_t r = 0;
+    uint64_t want = (uint64_t)getuid() + geteuid() + getgid() + getegid();
+    check("ids == getuid+geteuid+getgid+getegid", omega2_ids(&r) == OMEGA_OK && r == want);
+    check("peek FILE reads its 5 bytes", peek(argv[1]) == 5);
+    check("peek MISSING = -ENOENT", peek(argv[2]) == -ENOENT);
+    check("peek LINK = -ELOOP (fopen with O_NOFOLLOW)", peek(argv[3]) == -ELOOP);
+    struct stat st;
+    check("size FILE == st_size", stat(argv[1], &st) == 0 && omega2_size(&r, (const uint8_t *)argv[1], strlen(argv[1])) == OMEGA_OK
+          && (int64_t)r == (int64_t)st.st_size);
+    check("ident carries host=", strstr(omega2_ident_hfile(), " host=") != NULL
+          && strcmp(omega2_ident_hfile(), OMEGA2_IDENT_hfile) == 0);
+    return bad;
+}
diff --git a/tests/native/v2/host/hcall.rs b/tests/native/v2/host/hcall.rs
new file mode 100644
index 0000000..a4a8155
--- /dev/null
+++ b/tests/native/v2/host/hcall.rs
@@ -0,0 +1,39 @@
+// hcall.rs: the Rust oracle for hfile.om through the --host library (tests/native/v2/run.sh, section 11).
+// hcall FILE MISSING LINK, as for hcall.c; expectations come from std, independently of the unit.
+mod omega_native;
+use omega_native::*;
+use std::os::unix::fs::MetadataExt;
+use std::sync::atomic::{AtomicBool, Ordering};
+
+static BAD: AtomicBool = AtomicBool::new(false);
+fn check(what: &str, ok: bool) {
+    println!("{} {}", if ok { "PASS" } else { "FAIL" }, what);
+    if !ok {
+        BAD.store(true, Ordering::Relaxed);
+    }
+}
+
+fn peek(p: &str) -> Option<i64> {
+    let mut r: u64 = 0;
+    let s = unsafe { omega2_peek(&mut r, p.as_ptr(), p.len() as u64) };
+    if s == OMEGA_OK { Some(r as i64) } else { None }
+}
+
+fn main() {
+    let a: Vec<String> = std::env::args().collect();
+    assert!(a.len() == 4, "usage: hcall FILE MISSING LINK");
+    check("peek FILE reads its 5 bytes", peek(&a[1]) == Some(5));
+    check("peek MISSING = -ENOENT (-2)", peek(&a[2]) == Some(-2));
+    check("peek LINK = -ELOOP (-40, fopen with O_NOFOLLOW)", peek(&a[3]) == Some(-40));
+    let m = std::fs::metadata(&a[1]).expect("metadata");
+    let mut r: u64 = 0;
+    let s = unsafe { omega2_size(&mut r, a[1].as_ptr(), a[1].len() as u64) };
+    check("size FILE == metadata len", s == OMEGA_OK && r == m.size());
+    let p = std::fs::metadata("/proc/self").expect("/proc/self");
+    let s = unsafe { omega2_ids(&mut r) };
+    check("ids >= euid + egid (from /proc/self)", s == OMEGA_OK && r >= p.uid() as u64 + p.gid() as u64);
+    check("ident carries host=", OMEGA2_IDENT_hfile.contains(" host="));
+    if BAD.load(Ordering::Relaxed) {
+        std::process::exit(1);
+    }
+}
diff --git a/tests/native/v2/host/hfile.om b/tests/native/v2/host/hfile.om
new file mode 100644
index 0000000..c5735a8
--- /dev/null
+++ b/tests/native/v2/host/hfile.om
@@ -0,0 +1,51 @@
+note hfile.om: an OM-2 unit for the host-word checks of tests/native/v2/run.sh (section 11). It uses all
+note nine function-mode host words a bridged unit may use (getuid geteuid getgid getegid stat lstat fopen
+note fstat fclose) and read, so tools/native refuses it without --host and accepts it with --host.
+om2
+export fn ids to ulong
+a = ulong getuid
+b = ulong geteuid
+c = ulong getgid
+e = ulong getegid
+ret add add a b add c e
+end
+
+note peek p: lstat and stat p, open it (O_NOFOLLOW O_NONBLOCK O_CLOEXEC, 559104 on AArch64), fstat the
+note descriptor, read up to 16 bytes, close; the byte count read, or minus errno of the first failure.
+export fn peek p view uchar * to long
+s = new uchar 128 0
+r = lstat p 0 len p s 0 128
+if ne r 0
+ret r
+end
+r = stat p 0 len p s 0 128
+if ne r 0
+ret r
+end
+fd = fopen p 0 len p 559104 0
+if lt fd 0
+ret fd
+end
+b = new uchar 16 0
+k = fstat int fd s 0 128
+n = read int fd b 0 16
+z = fclose int fd
+if ne k 0
+ret k
+end
+ret n
+end
+
+note size p: the st_size field (offset 48 of the 128-byte AArch64 stat) of p, or minus errno.
+export fn size p view uchar * to long
+s = new uchar 128 0
+r = stat p 0 len p s 0 128
+if ne r 0
+ret r
+end
+x = ulong 0
+for i ulong 8
+x = or x shl ulong get s add 48 i mul i 8
+end
+ret long x
+end
diff --git a/tests/native/v2/run.sh b/tests/native/v2/run.sh
index b229954..ec7aca4 100755
--- a/tests/native/v2/run.sh
+++ b/tests/native/v2/run.sh
@@ -409,6 +409,94 @@ fi
 # out-buffer rules, threads, the trap wrapper and the copy-back-dropped mutant.
 if python3 "$T/../test_freestanding_om2.py" > "$O/fsom2.log" 2>&1; then pass "freestanding OM-2: $(grep -c '^PASS' "$O/fsom2.log") checks incl. copy-back mutant"
 else fail "freestanding OM-2"; cat "$O/fsom2.log"; fi
+# 11. Host words (docs/NATIVE-ABI.md, "Host words"). An OM-2 function unit may use the nine file and
+# identity host words (omega-mv om2 function mode) only when tools/native gets --host; native.om judges
+# the source (note lines skipped, blank and parenthesis separators), the shell only sequences.
+H=$O/host; mkdir -p "$H"; HU=$T/host/hfile.om
+hw="fclose,fopen,fstat,stat,getuid,geteuid,getgid,getegid,lstat"
+# tnat NAME WANT ARGS...: tools/native ARGS must exit WANT; a refusal must leave nothing installed (its
+# OUTDIR absent, or empty as tools/native leaves it when the generator refuses a unit).
+tnat() {
+  name=$1; want=$2; shift 2; rc=0
+  "$ROOT/tools/native" "$@" > "$H/$name.log" 2>&1 || rc=$?
+  if [ $rc != "$want" ]; then fail "tools/native $name: exit $rc, want $want"; cat "$H/$name.log"; return 1; fi
+  if [ "$want" != 0 ] && [ -n "$(ls -A "$H/$name" 2> /dev/null)" ]; then fail "tools/native $name refused but installed: $(ls -A "$H/$name")"; return 1; fi
+  pass "tools/native $name: exit $want$( [ "$want" = 0 ] || printf ' (%s)' "$(tail -n 1 "$H/$name.log")")"
+}
+tnat nohost 110 "$H/nohost" "$HU" || true
+tnat hostfs 110 --host --freestanding "$H/hostfs" "$HU" || true
+tnat hostx86 110 --target x86linux --host "$H/hostx86" "$HU" || true
+if tnat hostok 0 --host "$H/hostok" "$ROOT/tests/native/madd.om" "$HU"; then
+  want="omega-ident 1 unit=hfile abi=2 profile=OM-2 src=$(sha256sum < "$HU" | cut -d' ' -f1) omc=$(sha256sum < "$OMC2" | cut -d' ' -f1) host=$hw"
+  if grep -q -F "OMEGA2_IDENT_hfile \"$want\"" "$H/hostok/omega_native.h" && grep -q -F "\"$want\"" "$H/hostok/omega_native.c" \
+    && grep -q -F "$want path=$HU" "$H/hostok/work/ident.txt"; then pass "hfile identity names its host words: host=$hw"
+  else fail "hfile identity"; grep hfile "$H/hostok/work/ident.txt" || true; fi
+  printf 'abcde' > "$H/five"; ln -sf "$H/five" "$H/link"
+  bld host-c cc -std=gnu11 -O2 -Wall -Wextra -Werror -I "$H/hostok" "$T/host/hcall.c" -L"$H/hostok" -lomega_native -Wl,-rpath,"$H/hostok" -o "$H/hcall_c" \
+    && run host-c "$H/hcall_c" "$H/five" "$H/missing" "$H/link"
+  if command -v rustc > /dev/null; then
+    cp "$T/host/hcall.rs" "$H/hostok/omega_native.rs" "$H/"
+    bld host-rust rustc -O --edition 2021 -D warnings "$H/hcall.rs" -L "$H/hostok" -C link-arg=-Wl,-rpath,"$H/hostok" -o "$H/hcall_rs" \
+      && run host-rust "$H/hcall_rs" "$H/five" "$H/missing" "$H/link"
+  else notrun="$notrun host-rust"; fi
+fi
+# --host changes nothing for units without host words: the v2 set built with --host, every output equal.
+if tnat hostset 0 --host "$H/hostset" $units; then
+  ok=1
+  for f in omega_native.c omega_native.h omega_native.py omega_native.rs omega_native.zig omega_native.go omega_api.h omega_api_decl.h omega_api_defs.c; do
+    cmp -s "$O/$f" "$H/hostset/$f" || { ok=0; echo "DIFF $f"; }
+  done
+  if [ $ok = 1 ]; then pass "--host is inert for the v2 set (no host words): all nine generated files byte-identical"; else fail "--host changed a unit without host words"; fi
+fi
+# The scanner, fed straight to native-gen: source forms the compiler accepts (OMC2 compiles each), and
+# sources framed with a clean unit's code to reach the forms the compilers refuse (OM-1, unlink).
+# frame SRC BIN OUT: the tools/native framing, with the omega-unit line when SRC is OM-2.
+frame() {
+  { cat "$1"; printf '\0'; printf '%08d' "$(wc -c < "$2")"; cat "$2"
+    [ "$(sed -n '/^ *note\( \|$\)/d; p; q' "$1")" != om2 ] || printf 'omega-unit hu %s\n' "$(sha256sum < "$OMC2" | cut -d' ' -f1)"
+  } > "$3"
+}
+# gcase NAME SRC BIN NOHOST HOST: native-gen c on the frame, without and with host, must exit NOHOST and
+# HOST; with HOST 0, ident must carry exactly the host suffix given in HW (empty: no host= at all).
+gcase() {
+  frame "$2" "$3" "$H/$1.in"; a=0; b=0
+  "$GEN" c < "$H/$1.in" > /dev/null 2>&1 || a=$?
+  "$GEN" c host < "$H/$1.in" > /dev/null 2>&1 || b=$?
+  id=""; [ "$b" != 0 ] || [ "$(sed -n '/^ *note\( \|$\)/d; p; q' "$2")" != om2 ] || id=$("$GEN" ident host < "$H/$1.in")
+  case "$id" in *" host="*) got=${id##* host=};; *) got="";; esac
+  if [ $a = "$4" ] && [ $b = "$5" ] && [ "$got" = "$HW" ]; then pass "native-gen $1: exit $a without host, $b with host${HW:+, host=$HW}"
+  else fail "native-gen $1: exit $a/$b (want $4/$5), host=$got (want $HW)"; fi
+}
+printf 'om2\nexport fn a to ulong\nx = ulong 7\nret x\nend\n' > "$H/clean.om"; "$OMC2" < "$H/clean.om" > "$H/clean.bin"
+printf 'fn a to ulong\nx = ulong 7\nret x\nend\n' > "$H/clean1.om"; "$OMC" < "$H/clean1.om" > "$H/clean1.bin"
+HW="" gcase clean "$H/clean.om" "$H/clean.bin" 0 0
+HW="" gcase clean1 "$H/clean1.om" "$H/clean1.bin" 0 0
+for c in paren:'x = ulong (geteuid)' tab:"$(printf 'x = ulong\tgeteuid')" cr:"$(printf 'x = ulong geteuid\r')"; do
+  printf 'om2\nexport fn a to ulong\n%s\nret x\nend\n' "${c#*:}" > "$H/${c%%:*}.om"
+  if "$OMC2" < "$H/${c%%:*}.om" > "$H/${c%%:*}.bin" 2> /dev/null; then HW=geteuid gcase "${c%%:*}" "$H/${c%%:*}.om" "$H/${c%%:*}.bin" 110 0
+  else fail "OMC2 refuses the ${c%%:*} form"; fi
+done
+printf 'om2\nnote uses unlink fopen geteuid only in a note\n  note\tlstat after blanks\nexport fn a to ulong\nx = ulong 7\nret x\nend\n' > "$H/note.om"
+"$OMC2" < "$H/note.om" > "$H/note.bin"; HW="" gcase note "$H/note.om" "$H/note.bin" 0 0
+printf 'om2\nexport fn a to ulong\nx = ulong 7 (note geteuid\nret x\nend\n' > "$H/pnote.om"; HW=geteuid gcase pnote "$H/pnote.om" "$H/clean.bin" 110 0
+printf 'om2\nexport fn a to ulong\nx = unlink 7\nret x\nend\n' > "$H/unlink.om"; HW="" gcase unlink "$H/unlink.om" "$H/clean.bin" 110 110
+printf 'fn a to ulong\nx = ulong geteuid\nret x\nend\n' > "$H/om1.om"; HW="" gcase om1 "$H/om1.om" "$H/clean1.bin" 110 110
+printf 'om2\nexport fn a to ulong\nx = ulong getuidx\nret x\nend\n' > "$H/near.om"; HW="" gcase near "$H/near.om" "$H/clean.bin" 0 0
+# host is not freestanding in the generator either: outputs freest and fapic refuse it (exit 110) on the
+# clean unit they accept without it.
+for w in freest fapic; do
+  a=0; b=0; "$GEN" $w < "$H/clean.in" > /dev/null 2>&1 || a=$?; "$GEN" $w host < "$H/clean.in" > /dev/null 2>&1 || b=$?
+  if [ $a = 0 ] && [ $b = 110 ]; then pass "native-gen $w: exit 0 without host, 110 with host"
+  else fail "native-gen $w: exit $a/$b (want 0/110)"; fi
+done
+# Mutant: the scan disabled in fn unit; the paren case must then pass without host, and be caught.
+M=$O/hmut; mkdir -p "$M"
+sed '/^hscan p q v$/s/^/note /' "$ROOT/src/native.om" > "$M/native.om"
+if [ "$(diff "$ROOT/src/native.om" "$M/native.om" | grep -c '^<' || true)" = 1 ] && "$OMC" < "$M/native.om" > "$M/gen"; then
+  chmod +x "$M/gen"; rc=0; "$M/gen" c < "$H/paren.in" > /dev/null 2>&1 || rc=$?
+  if [ $rc = 0 ]; then pass "mutant hscan-off caught: paren case exits 0 without host (the check above wants 110)"
+  else fail "mutant hscan-off not caught (exit $rc)"; fi
+else fail "mutant hscan-off did not apply"; fi
 
 # 10. Cost (HOST): call overhead, stack switch, copies, small and large views.
 if [ "${1:-}" = measure ]; then
diff --git a/tests/native/x86/.crumb b/tests/native/x86/.crumb
index c638b39..b6bd2fb 100644
--- a/tests/native/x86/.crumb
+++ b/tests/native/x86/.crumb
@@ -3,14 +3,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-11-05T14:20:24Z",
+      "compiled_at": "2026-11-05T17:05:34Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:2cd8f8f7f532e3b001e135e14b00845e66062248ccc85b3752895ca94c36701a",
+      "digest": "sha256:792675ff5d5be923201b24acf07a5109699763cf3ac13835e0a08fb583d20a96",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 12,
-      "generated_at_commit": "75ab06342564c69d744c03aa939e3c21828ab3a6",
-      "source_tree": "sha256:0809d99262b73e1ff6f3c943f3a873fdc5f4ef52aa15033bd4fcf2b3c2fe15b8"
+      "generated_at_commit": "004ccc32ac1904e533486908a7157162837a46dc",
+      "source_tree": "sha256:186ace7c240990f890b4f1011130d4fb6ec719532acb50d067d9b34bf570f86e"
     }
   },
   "layer": "tests",
diff --git a/tests/native/x86/suite.py b/tests/native/x86/suite.py
index 3e79423..eaee86a 100755
--- a/tests/native/x86/suite.py
+++ b/tests/native/x86/suite.py
@@ -591,9 +591,10 @@ class Suite:
         frames = {}
         om2_frames = {"v2-set"}
         for path in sorted(N.rglob("*.om")):
+            # v2/host units use host words, which tools/native accepts only with --host on aarch64linux.
             # tests/native/macos holds #27's host-word unit, whose C output gains the intended
             # macOS #error; no baseline generator emits it, and tests/native/macos/run.sh covers it.
-            if Path(__file__).parent in path.parents or N / "macos" in path.parents:
+            if Path(__file__).parent in path.parents or N / "v2" / "host" in path.parents or N / "macos" in path.parents:
                 continue
             text = path.read_bytes()
             # A note line is one whose first word is note (a bare `note` too), as src/native.om reads it.
diff --git a/tools/native b/tools/native
index dd4e32c..d94e5f4 100755
--- a/tools/native
+++ b/tools/native
@@ -1,6 +1,6 @@
 #!/bin/sh
 # tools/native: one Omega library and its declarations for six languages, from Omega function units.
-# Usage: OMEGA_NATIVE_OMC=<seeded omc> tools/native [--target aarch64linux|x86linux] [--freestanding] OUTDIR unit.om [unit.om...]
+# Usage: OMEGA_NATIVE_OMC=<seeded omc> tools/native [--target aarch64linux|x86linux] [--freestanding] [--host] OUTDIR unit.om [unit.om...]
 # Each unit is one .om file in the native call subset (docs/NATIVE-ABI.md). An OM-1 unit (ABI v1): its
 # last function is bound as omega_<name>, earlier ones are private helpers. An OM-2 unit (its first
 # line that is not a note is exactly om2; ABI v2): each `export fn` (or, with none, its last function)
@@ -39,6 +39,10 @@
 # OM-2 out parameter is a zero-filled buffer in the entry's frame copied back only on status 0, and
 # traps return status without TLS, heap or a hosted runtime.
 # Freestanding x86 output uses the same contract with a SysV adapter (owned-stack floor 0, as on AArch64).
+# --host lets OM-2 units use the file and identity host words (fclose fopen fstat stat lstat getuid
+# geteuid getgid getegid; docs/NATIVE-ABI.md, host words); every other host word, and any host word
+# in an OM-1 unit, is still refused. An OM-2 unit's identity then ends with host=<the words it uses>.
+# --host is aarch64linux only and not freestanding; either combination is refused before OUTDIR.
 set -eu
 PIN=734f0a39319fbfa930bcc62cb30dbf06d47d78e126372b74f5baf478e6126b61
 X86_PIN=be8c51301307555254fc59e351d281aae1aa096d91521777e33a41c8b446448a
@@ -48,9 +52,11 @@ got=$(sha256sum < "$OMC" | cut -d' ' -f1)
 [ "$got" = "$PIN" ] || { echo "tools/native: omc sha256 $got, pinned $PIN" >&2; exit 1; }
 CMODE=c
 TARGET=aarch64linux
+HOST=0
 while [ $# -gt 0 ]; do
   case "$1" in
     --freestanding) CMODE=freest; shift ;;
+    --host) HOST=1; shift ;;
     --target)
       [ $# -ge 2 ] || { echo "tools/native: --target requires aarch64linux or x86linux" >&2; exit 2; }
       TARGET=$2; shift 2 ;;
@@ -59,6 +65,8 @@ while [ $# -gt 0 ]; do
     *) break ;;
   esac
 done
+[ "$HOST" = 0 ] || [ "$CMODE" != freest ] || { echo "tools/native: --host is not freestanding; nothing installed" >&2; exit 110; }
+[ "$HOST" = 0 ] || [ "$TARGET" = aarch64linux ] || { echo "tools/native: --host is supported only for aarch64linux; nothing installed" >&2; exit 110; }
 case "$TARGET" in
   aarch64linux) ;;
   x86linux)
@@ -67,7 +75,7 @@ case "$TARGET" in
     [ "$got" = "$X86_PIN" ] || { echo "tools/native: x86 omc sha256 $got, pinned $X86_PIN" >&2; exit 1; } ;;
   *) echo "tools/native: unknown target $TARGET (expected aarch64linux or x86linux)" >&2; exit 2 ;;
 esac
-[ $# -ge 2 ] || { echo "usage: OMEGA_NATIVE_OMC=<omc> tools/native [--target aarch64linux|x86linux] [--freestanding] OUTDIR unit.om [unit.om...]" >&2; exit 2; }
+[ $# -ge 2 ] || { echo "usage: OMEGA_NATIVE_OMC=<omc> tools/native [--target aarch64linux|x86linux] [--freestanding] [--host] OUTDIR unit.om [unit.om...]" >&2; exit 2; }
 OUT=$1; shift
 mkdir -p "$OUT"
 OUT=$(cd "$OUT" && pwd)
@@ -78,6 +86,8 @@ trap 'rm -rf "$W"' EXIT
 generate() {
   if [ "$TARGET" = x86linux ]; then
     "$W/work/native-gen" "$1" x86linux
+  elif [ "$HOST" = 1 ]; then
+    "$W/work/native-gen" "$1" host
   else
     "$W/work/native-gen" "$1"
   fi
@@ -121,7 +131,13 @@ for u in "$@"; do
     exit 110
   fi
   cat "$W/one.in" >> "$W/work/units.in"
-  echo "omega-ident 1 unit=$name abi=$abi profile=$prof src=$(sha256sum < "$src" | cut -d' ' -f1) omc=$pin path=$u" >> "$W/work/ident.txt"
+  if [ $abi = 2 ]; then
+    # The generator states an OM-2 unit's identity (with host= when it uses host words).
+    id=$(generate ident < "$W/one.in")
+    printf '%s path=%s\n' "$id" "$u" >> "$W/work/ident.txt"
+  else
+    echo "omega-ident 1 unit=$name abi=$abi profile=$prof src=$(sha256sum < "$src" | cut -d' ' -f1) omc=$pin path=$u" >> "$W/work/ident.txt"
+  fi
 done
 words="c h python rust zig go"; [ $v2 = 0 ] || words="$words api apih apic"
 [ "$CMODE" != freest ] || { words="freest h"; [ $v2 = 0 ] || words="$words apih fapic"; }