Skip to content

migration: wave 3 — 5 integer brains (NetworkZones, Terminal, VmState, VMNetwork, VMMessageBus)#586

Merged
hyperpolymath merged 4 commits into
mainfrom
claude/cool-keller-gr5sl
Jun 14, 2026
Merged

migration: wave 3 — 5 integer brains (NetworkZones, Terminal, VmState, VMNetwork, VMMessageBus)#586
hyperpolymath merged 4 commits into
mainfrom
claude/cool-keller-gr5sl

Conversation

@hyperpolymath

@hyperpolymath hyperpolymath commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Migration wave 3 — integer brains from string-gated + de-quarantined idaptik modules

Third extraction wave. Continues the C1–C12 + waves 1/2 pattern: pure-integer "brains" extracted to .affine (compiled to wasm, verified by independent-oracle parity + assail), all string/float/async/state kept host-side. Notably includes files previously quarantined on String.startsWith — confirmed a host-side sense the brains don't touch.

Migrated — 5 kernels (verified: I re-ran every gate myself)

Kernel What Parity Assail
NetworkZones zone taxonomy (0..7) + ISP routing-class 64/64 clean
Terminal command taxonomy (0..23) + SSH-stack bounds + output ring-buffer + cursor-blink FSM + backspace clamp (16 exports) 421/421 clean
VmState flat-memory addressing/introspection (256-cell bound, validity, range guard, stack depth, port-input remaining; 8 exports) 38577/38577 clean
VMNetwork Tier-5 causal-ordering core: tick/sync/merge_timestamp/merge_register/can_undo/route_kind 251/251 clean
VMMessageBus message-routing dispatch over two enum bands (messageTarget 0..7 + coopEvent 0..6; 9 exports) 84/84 clean

VMNetwork/VMMessageBus match existing host coprocessor contracts (VMNetworkCoprocessor.res). Terminal is the standout — a 1115-LOC, ~90%-string module still yielded a clean separable integer brain (the 700-line command switch, tokenising, SSH parsing, Pixi rendering all stay ReScript).

Already-migrated / no brain

  • PortNames → already migrated in a prior session (re-verified 52/52; left untouched).
  • CoprocessorBridge, VMBridgeNO_NEW_BRAINS (pure host-side bridges; every integer transform they route to is already a migrated brain — Coprocessor_Compute/Security, VmArith/VmBitwise/VmStack/VmMemory/VmState).

Playbook by-product

VmState hit two real parse traps worth recording: a nested else { if <cond-with-subtraction> } parse-errors (flatten to early-return guards), and total is a reserved keyword (rename accumulators).

https://claude.ai/code/session_01WoKhFQePiRsAj7aqnxbG8s

claude added 4 commits June 14, 2026 02:33
The zone-routing decision brain from src/app/devices/NetworkZones.res:
8 pure-Int exports — the zone-category taxonomy (0..7 closed band:
LAN=0 .. Service=7, with -1 sentinel for out-of-band) and the ISP
routing-class core of canRouteViaISP (integer switch returning
2=tier-endpoint / 1=tier-member / 0=not-routed / -1=not-a-category,
so the host knows which access-list checks to run). All subnet-prefix
String.startsWith IP->zone matching and zone-id string lookups stay
host-side. G2 64/64, G4 clean; oracle independently reimplemented.

PortNames: ALREADY-MIGRATED (pre-existing brain re-verified 52/52).
CoprocessorBridge: NO_NEW_BRAINS (host-side terminal-command wrapper;
the integer coprocessor brains it routes to are already migrated).

https://claude.ai/code/session_01WoKhFQePiRsAj7aqnxbG8s
The separable integer brain from src/app/devices/Terminal.res (1115 LOC,
~90% host-side string parsing): 16 pure-Int exports — command taxonomy
(0..23 closed band; codes 17..23 gated by the FeaturePacks
invertible-programming flag, passed as feature_on Int), SSH-stack bounds
(top-index/empty/push/pop-depth/post-exit nested-prompt), output
ring-buffer eviction, maxLines geometry (milli-pixels), cursor-blink
accumulator state machine (milli-seconds, 0.5s->500ms), backspace clamp.
The 700-line command string-switch, tokenising (split/trim/startsWith/
slice), SSH host parsing, and Pixi rendering stay host-side. G2 421/421,
G4 clean; oracles independently re-derived from the .res line semantics.

https://claude.ai/code/session_01WoKhFQePiRsAj7aqnxbG8s
The flat-memory addressing/introspection brain from
vm/lib/ocaml/VmState.res (almost all senses: a dict<int> keyed by
underscore-prefixed strings, accessed via Dict/Option/String ops): 8
pure-Int exports — memory_size (256), max_address, is_valid_address
(-1 sentinel out-of-band), clamp_address, range_addr (start+i), range
in-region+in-bounds guard, stack materialisation depth (max(sp,0)),
unread-port count (max(count-ptr,0)). The opcode pointer/value
arithmetic was already migrated (VmStack/VmMemory/VmPort); the string
dict layout stays host-side. G2 38577/38577, G4 clean.

VMBridge: NO_NEW_BRAINS (pure bridge; every integer transform it does
is already a migrated brain - VmArith/VmBitwise/VmStack/VmMemory/VmState
- and the rest is string parsing + async coprocessor loading + state).

Two parse traps hit + worked around (worth a playbook note): a nested
`else { if cond-with-subtraction }` parse-errored -> flattened to
early-return guards; and `total` is a reserved keyword -> renamed.

https://claude.ai/code/session_01WoKhFQePiRsAj7aqnxbG8s
VMNetwork: the Tier-5 causal-ordering core (6 exports: tick, sync,
merge_timestamp, merge_register, can_undo, route_kind) — pure i32
arithmetic + causal-undo gate + last-writer-wins register reconciliation
+ channel-ordinal routing (CHANNEL band NET:0/COVERT:1/LOCAL:2, -1
sentinel). Matches the host contract in VMNetworkCoprocessor.res:41-56.
G2 251/251, G4 clean.

VMMessageBus: message-routing dispatch over two closed enum bands
(9 exports) — messageTarget band (Console..DevicePort 0..7) with
relays_to_partner / is_coop_channel / is_covert_channel, and the
coopEvent band (0..6) with event_sends_to_client (every kind except
PortData). classifyPort string parsing stays host-side; the host passes
the integer message-target ordinal. G2 84/84, G4 clean.

Both re-decomposed: drop module state (globalClock cell, output dicts),
drop async, explicit Int params, enums as integer bands, all string ops
host-side. Oracles independently reimplemented from the .res semantics.

https://claude.ai/code/session_01WoKhFQePiRsAj7aqnxbG8s
@hyperpolymath hyperpolymath changed the title migration: wave 3 integer brains (NetworkZones, Terminal, VmState) migration: wave 3 — 5 integer brains (NetworkZones, Terminal, VmState, VMNetwork, VMMessageBus) Jun 14, 2026
@github-actions

Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 40 issues detected

Severity Count
🔴 Critical 2
🟠 High 22
🟡 Medium 16

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Action denoland/setup-deno@v2 needs attention",
    "type": "unpinned_action",
    "file": "publish-jsr.yml",
    "action": "pin_sha",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in scorecard-enforcer.yml",
    "type": "scorecard_publish_with_run_step",
    "file": "scorecard-enforcer.yml",
    "action": "split_scorecard_publish_job",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Issue in instant-sync.yml",
    "type": "secret_action_without_presence_gate",
    "file": "instant-sync.yml",
    "action": "peter-evans/repository-dispatch",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Shell execution -- validate input before passing to shell (1 occurrences, CWE-78)",
    "type": "js_exec_sync",
    "file": "/home/runner/work/affinescript/affinescript/packages/affinescript-cli/mod.js",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "high"
  },
  {
    "reason": "Shell execution -- validate input before passing to shell (2 occurrences, CWE-78)",
    "type": "js_exec_sync",
    "file": "/home/runner/work/affinescript/affinescript/packages/affine-vscode/mod.js",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "high"
  },
  {
    "reason": "Shell execution -- validate input before passing to shell (1 occurrences, CWE-78)",
    "type": "js_exec_sync",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-vite/src/affine-plugin-improved.js",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "high"
  },
  {
    "reason": "expect() in hot path (32 occurrences, CWE-754)",
    "type": "expect_in_hot_path",
    "file": "/home/runner/work/affinescript/affinescript/affinescriptiser/src/codegen/wasm_gen.rs",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "medium"
  },
  {
    "reason": "expect() in hot path (29 occurrences, CWE-754)",
    "type": "expect_in_hot_path",
    "file": "/home/runner/work/affinescript/affinescript/affinescriptiser/src/codegen/affine_gen.rs",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "medium"
  },
  {
    "reason": "unsafe block -- requires SAFETY comment (2 occurrences, CWE-676)",
    "type": "unsafe_block",
    "file": "/home/runner/work/affinescript/affinescript/runtime/src/panic.rs",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "medium"
  },
  {
    "reason": "unsafe block -- requires SAFETY comment (1 occurrences, CWE-676)",
    "type": "unsafe_block",
    "file": "/home/runner/work/affinescript/affinescript/runtime/src/alloc.rs",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "medium"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

@hyperpolymath hyperpolymath marked this pull request as ready for review June 14, 2026 03:03
@hyperpolymath hyperpolymath merged commit 6880eef into main Jun 14, 2026
27 checks passed
@hyperpolymath hyperpolymath deleted the claude/cool-keller-gr5sl branch June 14, 2026 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants