Skip to content

Bump zwasm v1.6.1 → v1.7.2#1

Merged
chaploud merged 1 commit into
mainfrom
develop/bump-zwasm-v1.7.2
Apr 21, 2026
Merged

Bump zwasm v1.6.1 → v1.7.2#1
chaploud merged 1 commit into
mainfrom
develop/bump-zwasm-v1.7.2

Conversation

@chaploud
Copy link
Copy Markdown
Contributor

Summary

  • Bumps the zwasm dependency from v1.6.1 to v1.7.2.
  • v1.7.2 fixes an ARM64 JIT remainder bug (`rd == rs2` aliasing) that surfaces in `02_tinygo_test` — TinyGo's `gcd` lowers to IR `r3 = r0 % r3`, and after JIT compilation (HOT_THRESHOLD=3) the loop produced wrong remainders and spun for minutes.
  • Also picks up v1.7.1 (invoke() settings persistence + build options + spec bump) and v1.7.0 (SIMD JIT, memory64 fix, FD-based WASI, JIT correctness sweep).

Test plan

  • `bash test/run_all.sh`: zig test, ReleaseSafe build, `cljw test` (83 namespaces, 0 failures), e2e wasm, deps.edn e2e — all PASS
  • Binary size: 4.76 MB (≤ 5.0 MB)
  • Startup: 4.5 ms ± 0.6 ms (≤ 6 ms)
  • RSS: 7.65 MB (≤ 10 MB)
  • `bash bench/wasm_bench.sh --quick`: gcd completes in 66.2 ms (was hanging on v1.7.0/v1.7.1)

Regression context

Investigated at the zwasm side: the prior fix for rem aliasing (zwasm v1.7.1) covered only `rd == rs1`. The register allocator can also assign the destination to the same physical register as the divisor; in that case UDIV clobbered the divisor before MSUB could use it. zwasm v1.7.2 now preserves whichever operand the destination aliases and adds a regression test.

Picks up:
- ARM64 JIT remainder fix (rd == rs2 aliasing). Surfaced here via
  02_tinygo_test: TinyGo's gcd lowered to IR `r3 = r0 % r3` produced
  wrong remainders after HOT_THRESHOLD JIT compilation, causing the
  loop to spin for minutes.
- Preserve caller-set vm.* settings across invoke() (v1.7.1).
- -Dpic / -Dcompiler-rt build options (v1.7.1).
- Spec testsuite bumped to f9c743a (v1.7.1).
- v1.7.0 contents (SIMD JIT, memory64 fix, FD-based WASI config,
  JIT correctness sweep) previously inaccessible due to the rem bug.

Commit Gate (Mac):
- run_all.sh: zig test, ReleaseSafe build, cljw test (83 ns),
  e2e wasm, deps.edn e2e — all PASS
- Binary 4.76 MB (≤ 5 MB), startup 4.5 ms (≤ 6 ms), RSS 7.65 MB (≤ 10 MB)
- wasm_bench.sh --quick: gcd 66.2 ms (was hanging on v1.7.0/v1.7.1)
@chaploud chaploud merged commit 4b7437f into main Apr 21, 2026
6 checks passed
@chaploud chaploud deleted the develop/bump-zwasm-v1.7.2 branch April 24, 2026 12:55
chaploud added a commit that referenced this pull request Apr 26, 2026
Self-review against the strategic-review notes and reference projects
flagged 7 files as high rot risk (empty stubs / aspirational tables /
premature deep-dives). Removed and listed in ROADMAP §15.2 with templates
so they can be created on demand later without losing the format.

Removed:
- .dev/handover.md           (memo files rot; recreate when actual session
                              state needs to outlive a chat thread)
- .dev/known_issues.md       (empty stub; create when first issue arises)
- .dev/compat_tiers.yaml     (aspirational; create at Phase 10 when first
                              src/lang/clj/ namespace lands)
- .dev/concurrency_design.md (premature; Phase-15 reality may diverge —
                              kept the summary in ROADMAP §7)
- .dev/wasm_strategy.md      (same; summary stays in ROADMAP §8)
- .claude/rules/compat_tiers.md  (auto-loads on src/lang/** which does not
                              exist yet; recreate at Phase 10)
- docs/README.md             (single placeholder line; redundant with the
                              main README and docs/ja/README.md)

Reworked the learning-doc gate (`scripts/check_learning_doc.sh`) so the
doc is the COMMIT THAT IMMEDIATELY FOLLOWS each source commit, not in the
same commit. This lets the doc's `commit:` front-matter cite the actual
SHA of the source commit it documents — no "TBD then patch" cycle.

- Rule 1: a doc commit must not contain source-bearing files (mixing
  defeats the SHA pairing).
- Rule 2: a commit following an unpaired source commit must be the doc.
- "Source-bearing" tightened to exclude `.dev/decisions/README.md` and
  `.dev/decisions/0000-template.md` (meta-metadata, not real ADRs).

Patched docs/ja/0001 and 0002 front-matter `commit:` to actual SHAs
(116b874, ac2e2b9). Updated ROADMAP §11.6 #1, §12.2, §15.1, §15.2,
§17 history; updated SKILL.md, .dev/README.md, .dev/decisions/README.md,
CLAUDE.md to reflect the new flow.
chaploud added a commit that referenced this pull request May 23, 2026
…e field

Final cycle of §9.6 / 4.5. All seven Phase-1/2 special forms now
compile to bytecode.

tree_walk.Function gains an optional `bytecode: ?*const
BytecodeChunk = null` field — `null` keeps the existing TreeWalk
Node-body semantics; non-null routes the VM dispatcher (task 4.6)
to the compiled chunk while the `body` Node stays available for
error frames. Smallest-diff design — single heap type for both
backends, no new HeapTag, no zone reshuffle.

compiler.zig fn_node arm: a fresh sub-Compiler compiles the body,
the BytecodeChunk is arena-pinned (lifetime matches `body` /
`params` already referenced by Function), tree_walk's new
`allocFunctionWithBytecode` allocates the Function up-front, and
op_make_fn <idx> just reads the pre-built Function constant.
Closure-less only (slot_base == 0); slot_base > 0 returns
error.NotImplemented because op_make_fn's single-constant-index
operand cannot encode the capture snapshot — task 4.7 widens
that.

Two new Layer-1 unit tests: closure-less fn* allocation
verifying the nested chunk shape, and the NotImplemented guard
for slot_base > 0.

ROADMAP §9.6 row 4.5 flips to [x]. Mac (9/9) + OrbStack Ubuntu
x86_64 (8/8) green.

Note on prior handover framing: the previous commit (538f89e)
stopped the autonomous loop citing condition 2 (ADR-level
decision). On re-reading, design #1 was explicitly "no ADR amend
needed" and therefore self-decidable; the stop was inflated and
the loop continued.
chaploud added a commit that referenced this pull request May 23, 2026
…, ADR self-accept

Three converging issues with the last autonomous loop session (the
loop stopped at §9.6 / 4.5 fn_node citing "ADR-level decision"; the
choice was self-decidable, design #1 was explicitly "no ADR amend
needed"; separately, 7 commits accumulated unpushed because
"push free after green gate" left room for a "should I push?"
decision the closed stop list does not authorise):

- Closed stop list shrinks to 2 conditions (user explicit / physical
  block). The ADR-level condition is removed; ADR-level designs are
  handled inline (CLAUDE.md § "ADR-level designs are handled inline,
  not as a stop"). The AI drafts the ADR with
  Status: Proposed → Accepted in the same cycle and lands it
  alongside the source change. Rationale survives in ADR history; no
  external accept gate.
- Step 6 becomes atomic commit + push. Local commits never
  accumulate on cw-from-scratch. Push to main remains forbidden;
  push to cw-from-scratch is automatic and not deferred.
- Phrases "this needs human judgement" / "cannot be self-decided"
  / "user touchpoint required" / "ADR-level decision" (as a stop
  reason) / "user 確認待ち" become forbidden framings in
  handover.md (handover_framing.md table + grep). They map to the
  same anti-pattern the b09b54e commit identified
  (prohibition-list failure mode) and reframe self-decidable
  choices as stops.

Affected files:

- CLAUDE.md
  - Working agreement bullets: branch + push wording become atomic.
  - Step 6: split into "commit + push" with explicit
    `git push origin cw-from-scratch` after each commit. Depth 2-4
    becomes "draft + accept ADR inline".
  - "Stop only when": list shrinks from 3 to 2 conditions.
    Adds explicit "ADR-level designs are handled inline" section
    with the forbidden-phrase list.
- .dev/ROADMAP.md
  - §12.4 rewritten: 7-step table (was 8-step with /compact gate),
    stop discipline matches CLAUDE.md, push wording matches.
  - §13 forbidden actions: "Pushing without user approval" replaced
    with "Pushing to main" + "Leaving local commits unpushed".
- .dev/principle.md
  - Four-depths table footer adds: "All four depths proceed within
    the loop. Deeper depths land conclusion in a separate commit
    before the source commit, then continue. AI drafts + accepts
    the ADR itself."
- .dev/decisions/README.md
  - Lifecycle Add bullet: AI drafts ADR with Proposed → Accepted in
    the same cycle. "Reject after debate" → "Reject after
    consideration" (debate implied human-AI exchange).
- .claude/rules/handover_framing.md
  - "Legitimate stop framing" rewritten to the 2-condition list;
    ADR-level example removed. Forbidden-phrase table extends with
    cannot-be-self-decided / human-judgement / user-touchpoint /
    ADR-level-as-stop / awaiting-user-confirmation rows. Grep
    enforcement command updated.
- .claude/skills/continue/SKILL.md
  - "closed 3-condition" → "closed 2-condition" in two places.

Gate green on both Mac (9/9) and OrbStack Ubuntu x86_64 (8/8).
chaploud added a commit that referenced this pull request May 24, 2026
§9.7 task 5.0 closer. Encodes the survey at
private/notes/phase5-skeleton-audit.md (676 lines, gitignored) as
a tracked decision so §9.7 rows 5.1-5.16 execute against a fixed
activation classification map without re-deriving from the
survey.

Two load-bearing decisions:

  §1 Classification of the 8 Phase-4 skeletons:
       4.13 io_interface           matches FF  (Phase 14, ADR-0015 a2)
       4.17 type_descriptor        restructure (5.11)
       4.18 protocol               restructure (Phase 7, D-040)
       4.19 ObjectHeader           matches FF  (5.3)
       4.20 host/_host_api         matches FF  (Phase 6 host wave)
       4.22 binding_stack          reverted    (6a48e90 — terminal)
       4.23 numeric/big_int        restructure (5.2 + 5.9)
       4.24 lazy_seq               restructure (5.7)
       4.25 dispatch/method_table  matches FF  (Phase 7, D-040)

  §2 Critical-path activations for 5.16 exit smoke:
       5.2 → 5.3 → 5.4-5.6 → 5.7 → 5.8 → 5.9-5.10 → 5.11 → 5.12
       → 5.15 (build_options flip, mechanical after 5.12)
       → 5.16 (exit smoke).
       Parallel-safe: 5.13 (analyzer split), 5.14 (host placeholder
       doc).

Devil's-advocate subagent forked with fresh context per CLAUDE.md
§ "ADR-level designs are handled inline" / principle.md
"Devil's-advocate subagent is mandatory at depth ≥ 2". Subagent
output reflected verbatim into Alternatives considered (Alt 1
smallest-diff / Alt 2 finished-form-clean split / Alt 3 wildcard
pattern-ADR). Subagent recommendation: Alt 1.

Main loop disposition: Alt 1 applied with §3 reduced to a
pointer (not deleted entirely — the link to the survey's "5.1
input bullets" stays so future readers find them without
re-discovering); §4 removed entirely per the subagent's
accurate F-003-overlap observation; subagent's omitted-
constraints #1 (per-row OrbStack gate) and #2 (5.15 in critical
path) reflected into §2. Omitted-constraint #3 moot now that §3
is a pointer.

ROADMAP §9.7 row 5.0 flipped to [x] in-place with the survey
SHA / row count + the Alt 1 disposition recorded so future
audits can reconstruct the deferral choice from the row text.

Smell-audited: 1: Devil's-advocate alternative Alt 1 applied
(structural ADR shrink — depth-2 amendment of the draft before
Accepted). The original draft carried the 8 constraint bullets
verbatim; the subagent surfaced the duplication-with-5.1
concern accurately and proposed three alternatives within the
F-NNN envelope. None violated F-001..F-008. F-003 (decision-
deferral) is the active constraint here: ADR-0026 should not
pre-commit decisions the survey only surfaces — 5.1's ADR-0027
/ ADR-0028 cluster owns the bullets at the moment they bind.
chaploud added a commit that referenced this pull request May 24, 2026
… first/rest/meta

Smell-audited: 1: second per-type migration. Cons → extern struct
(declaration-ordered, HeapHeader at offset 0). consHeap body
switches rt.gpa.create + trackHeap → rt.gc.alloc(Cons); freeCons
removed. The arena-based `cons(alloc, ...)` path stays (per-eval
arena lifetime); only consHeap (long-lived) migrates.

traceGc fn registered into tag_ops.tag_trace_table[.list]: walks
first / rest / meta and calls mark_sweep.mark on each heap-tagged
child so the mark phase reaches Cons-rooted lists. No finaliser
needed (Cons has no owned non-GC resources — first/rest/meta are
Values, count is u32).

Mixed-lifetime caveat: a long-lived (GC) list may reference a
short-lived (arena) sub-tail; the arena.deinit at eval-end leaves
the GC-managed parent's `rest` pointing at freed memory. Boundary
copy lands at a later sub-step (analogous to cw v0's D100 #1 fix)
once analyzer-arena ownership boundaries are explicit.

Gate: Mac 13/13 + OrbStack Ubuntu x86_64 12/12 green (first-try).
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.

1 participant