Skip to content

migrate(C2 wave 2a): VmMulDiv scalar multiply/divide, 4-gate green#539

Merged
hyperpolymath merged 1 commit into
mainfrom
claude/cool-keller-gr5sl
Jun 5, 2026
Merged

migrate(C2 wave 2a): VmMulDiv scalar multiply/divide, 4-gate green#539
hyperpolymath merged 1 commit into
mainfrom
claude/cool-keller-gr5sl

Conversation

@hyperpolymath
Copy link
Copy Markdown
Owner

C2 wave 2a — scalar multiply/divide

Mul and Div turned out to be pure scalar value-transforms, not memory opcodes, so they need no array/linear-memory ABI — split out of "C2 wave 2" and landed ahead of the memory-bound wave 2b.

VmMulDiv (11 exports) re-decomposed per the brain/senses split — the register-name dict stays host-side, the brain is the scalar-int value transform. Reversibility migrated as headline exports:

  • mul_roundtrip — Bennett ancilla (c := c + a*b, inverse c := c - a*b), invert∘execute == id.
  • div_reconstructq*b + r == a for all b (incl. divide-by-zero, where r holds the original a).

The intentional-flaw in-place/simple variants are migrated as value transforms with no roundtrip==id claim (the source ships them to demonstrate where in-place multiply / simple divide break reversibility).

Four gates green

Gate Result
G1 compile 1/1 (WASM, validates; 11 exports)
G2 parity 3322/3322 (mul reversibility + div reconstruction + every guard)
G3 boundary n/a (numeric transform — no value↔integer encoding table)
G4 assail 1/1 clean

Two new i32 ABI facts surfaced and handled

  1. JS a*b loses precision above 2^53 → the parity oracle uses Math.imul to stay i32-exact against i32.mul (a naive (a*b)|0 oracle would mismatch at the domain extremes, e.g. INT_MAX*INT_MAX).
  2. i32.div_s TRAPS on b==0 and INT_MIN/-1 (ReScript wraps the latter), and i32.rem_s TRAPS on b==0 → the brain guards both (nested-if, avoiding the unverified && codegen path) so the wasm is a total function matching ReScript's observable output — never a trap.

Ledger + migration-map.json updated: C2 wave 2a DONE; wave 2b (memory/control opcodes + structural VM) correctly scoped as needing the array/linear-memory ABI (the next real unblocker, also feeds the string wall).

Staged-only under proposals/idaptik/migrated/ — idaptik write-gate honoured.

https://claude.ai/code/session_01WoKhFQePiRsAj7aqnxbG8s


Generated by Claude Code

Mul and Div turned out to be pure scalar value-transforms, not memory
opcodes, so they need no array/linear-memory ABI -- split out of "C2
wave 2" and landed ahead of the memory-bound wave 2b.

VmMulDiv (11 exports) re-decomposed per the brain/senses split: the
register-name dict stays host-side, the brain is the scalar-int value
transform. Reversibility migrated as headline exports -- mul_roundtrip
(Bennett ancilla c:=c+a*b, inverse c:=c-a*b) and div_reconstruct
(q*b+r==a for all b, incl. divide-by-zero where r holds the original a).
The intentional-flaw in-place/simple variants are migrated as value
transforms with no roundtrip==id claim.

Four gates green: 1/1 compile, 3322/3322 parity (mul reversibility +
div reconstruction + every guard), G3 n/a (numeric transform), 1/1
assail-clean.

Two new i32 ABI facts surfaced and handled:
- JS a*b loses precision above 2^53, so the parity oracle uses Math.imul
  to stay i32-exact against i32.mul (a naive (a*b)|0 oracle would mismatch
  at the domain extremes).
- i32.div_s TRAPS on b==0 and INT_MIN/-1 (ReScript wraps the latter), and
  i32.rem_s TRAPS on b==0; the brain guards both (nested-if, to avoid the
  unverified && codegen path) so the wasm is a total function matching
  ReScript's observable output.

Ledger + migration-map updated: C2 wave 2a DONE; wave 2b (memory/control
opcodes + structural VM) correctly scoped as needing the array ABI.

https://claude.ai/code/session_01WoKhFQePiRsAj7aqnxbG8s
@hyperpolymath hyperpolymath merged commit de546e2 into main Jun 5, 2026
25 checks passed
@hyperpolymath hyperpolymath deleted the claude/cool-keller-gr5sl branch June 5, 2026 14:16
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

🔍 Hypatia Security Scan

Findings: 87 issues detected

Severity Count
🔴 Critical 2
🟠 High 15
🟡 Medium 70

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Action perpolymath/standards/.github/workflows/governance-reusable.yml@main\n needs attention",
    "type": "unpinned_action",
    "file": "governance.yml",
    "action": "pin_sha",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Action ons/checkout@v6\n    needs attention",
    "type": "unpinned_action",
    "file": "publish-jsr.yml",
    "action": "pin_sha",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Action land/setup-deno@v2\n    needs attention",
    "type": "unpinned_action",
    "file": "publish-jsr.yml",
    "action": "pin_sha",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in affine-vscode-publish.yml",
    "type": "missing_timeout_minutes",
    "file": "affine-vscode-publish.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in casket-pages.yml",
    "type": "missing_timeout_minutes",
    "file": "casket-pages.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in casket-pages.yml",
    "type": "missing_timeout_minutes",
    "file": "casket-pages.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in casket-pages.yml",
    "type": "missing_timeout_minutes",
    "file": "casket-pages.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in ci.yml",
    "type": "missing_timeout_minutes",
    "file": "ci.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in ci.yml",
    "type": "missing_timeout_minutes",
    "file": "ci.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in ci.yml",
    "type": "missing_timeout_minutes",
    "file": "ci.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

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