Skip to content

refactor(codegen): extract affinescript.ownership emission to lib/tw_…#347

Merged
hyperpolymath merged 2 commits into
mainfrom
claude/typed-wasm-a3-refactor
May 24, 2026
Merged

refactor(codegen): extract affinescript.ownership emission to lib/tw_…#347
hyperpolymath merged 2 commits into
mainfrom
claude/typed-wasm-a3-refactor

Conversation

@hyperpolymath
Copy link
Copy Markdown
Owner

…ownership_section.ml

Tranche A3 of docs/specs/TYPED-WASM-ROADMAP.adoc. Behaviour-preserving move; downstream callers (lib/tw_verify.ml, lib/tw_interface.ml, test/test_e2e.ml) are unaffected.

Why now: A3 was specified as a prerequisite for B1 (ADR-020 v2-parse support, now ACCEPTED + RATIFIED 2026-05-24). Putting the on-wire format in a dedicated module is cheap now and saves us editing codegen.ml inline when v2-parse + v2-emit land.

Changes:

  • NEW lib/tw_ownership_section.ml — the dedicated home for:

    • type ownership_kind (Unrestricted/Linear/SharedBorrow/ExclBorrow)
    • ownership_kind_of_param (extracts from p_ownership or type shape)
    • ownership_kind_of_ret
    • ownership_kind_byte (0..3 encoding)
    • build_section (v1 binary serialiser)
  • MOD lib/codegen.ml — re-exports preserve the [Codegen.X] surface:

    • type ownership_kind = Tw_ownership_section.ownership_kind = | ... (type equation keeps Codegen.Linear etc. resolving as constructors so open Codegen in Tw_verify / Tw_interface / Test_e2e continues to work)
    • let ownership_kind_of_param = Tw_ownership_section.… and friends — pure aliases.
    • let build_ownership_section = Tw_ownership_section.build_section — alias preserving the prior public name.

No semantic change. The v1 binary format and all enforcement (L7 aliasing + L10 linearity + L13 isolation) are unchanged. The 260+ test baseline should pass byte-for-byte; in particular the ownership-section round-trip cases
(test_ownership_section_present / _roundtrip / _entry_count) test the exact same serialisation path.

Not yet verified locally — no OCaml toolchain in this remote execution environment. CI is the verification surface; the change is mechanical and the type-equation re-export pattern is a standard OCaml idiom.

Refs ADR-020, docs/specs/TYPED-WASM-ROADMAP.adoc §"Tranche A — A3"

…ownership_section.ml

Tranche A3 of docs/specs/TYPED-WASM-ROADMAP.adoc. Behaviour-preserving
move; downstream callers (lib/tw_verify.ml, lib/tw_interface.ml,
test/test_e2e.ml) are unaffected.

Why now: A3 was specified as a prerequisite for B1 (ADR-020 v2-parse
support, now ACCEPTED + RATIFIED 2026-05-24). Putting the on-wire
format in a dedicated module is cheap now and saves us editing
codegen.ml inline when v2-parse + v2-emit land.

Changes:
- NEW lib/tw_ownership_section.ml — the dedicated home for:
    * type ownership_kind (Unrestricted/Linear/SharedBorrow/ExclBorrow)
    * ownership_kind_of_param (extracts from p_ownership or type shape)
    * ownership_kind_of_ret
    * ownership_kind_byte (0..3 encoding)
    * build_section (v1 binary serialiser)

- MOD lib/codegen.ml — re-exports preserve the [Codegen.X] surface:
    * type ownership_kind = Tw_ownership_section.ownership_kind = | ...
      (type equation keeps Codegen.Linear etc. resolving as
      constructors so `open Codegen` in Tw_verify / Tw_interface /
      Test_e2e continues to work)
    * `let ownership_kind_of_param = Tw_ownership_section.…` and
      friends — pure aliases.
    * `let build_ownership_section = Tw_ownership_section.build_section`
      — alias preserving the prior public name.

No semantic change. The v1 binary format and all enforcement (L7
aliasing + L10 linearity + L13 isolation) are unchanged. The 260+
test baseline should pass byte-for-byte; in particular the
ownership-section round-trip cases
(test_ownership_section_present / _roundtrip / _entry_count) test
the exact same serialisation path.

Not yet verified locally — no OCaml toolchain in this remote
execution environment. CI is the verification surface; the change
is mechanical and the type-equation re-export pattern is a
standard OCaml idiom.

Refs ADR-020, docs/specs/TYPED-WASM-ROADMAP.adoc §"Tranche A — A3"
@github-actions
Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 130 issues detected

Severity Count
🔴 Critical 15
🟠 High 60
🟡 Medium 55

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Stray AI.a2ml in root -- use 0-AI-MANIFEST.a2ml only",
    "type": "banned",
    "file": "AI.a2ml",
    "action": "delete",
    "rule_module": "root_hygiene",
    "severity": "high"
  },
  {
    "reason": "Superseded by 0-AI-MANIFEST.a2ml",
    "type": "banned",
    "file": "AI.djot",
    "action": "delete",
    "rule_module": "root_hygiene",
    "severity": "high"
  },
  {
    "reason": "Issue in quality.yml",
    "type": "missing_workflow",
    "file": "quality.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Issue in security-policy.yml",
    "type": "missing_workflow",
    "file": "security-policy.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Action hyperpolymath/standards/.github/workflows/governance-reusable.yml@main needs attention",
    "type": "unpinned_action",
    "file": "governance.yml",
    "action": "pin_sha",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Action actions/checkout@v6 needs attention",
    "type": "unpinned_action",
    "file": "publish-jsr.yml",
    "action": "pin_sha",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "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": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/example/smoke_driver.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/cli.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/mod.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

@hyperpolymath hyperpolymath merged commit 3d4f495 into main May 24, 2026
13 of 17 checks passed
@hyperpolymath hyperpolymath deleted the claude/typed-wasm-a3-refactor branch May 24, 2026 16:43
@github-actions
Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 130 issues detected

Severity Count
🔴 Critical 15
🟠 High 60
🟡 Medium 55

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Stray AI.a2ml in root -- use 0-AI-MANIFEST.a2ml only",
    "type": "banned",
    "file": "AI.a2ml",
    "action": "delete",
    "rule_module": "root_hygiene",
    "severity": "high"
  },
  {
    "reason": "Superseded by 0-AI-MANIFEST.a2ml",
    "type": "banned",
    "file": "AI.djot",
    "action": "delete",
    "rule_module": "root_hygiene",
    "severity": "high"
  },
  {
    "reason": "Issue in quality.yml",
    "type": "missing_workflow",
    "file": "quality.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Issue in security-policy.yml",
    "type": "missing_workflow",
    "file": "security-policy.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Action hyperpolymath/standards/.github/workflows/governance-reusable.yml@main needs attention",
    "type": "unpinned_action",
    "file": "governance.yml",
    "action": "pin_sha",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Action actions/checkout@v6 needs attention",
    "type": "unpinned_action",
    "file": "publish-jsr.yml",
    "action": "pin_sha",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "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": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/example/smoke_driver.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/cli.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/mod.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  }
]

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