Skip to content

Phase 1 / Etch / Concurrency algebra (race, sync, branch, spawn)#40

Open
guysenpai wants to merge 12 commits into
mainfrom
phase-1/etch/concurrency-algebra
Open

Phase 1 / Etch / Concurrency algebra (race, sync, branch, spawn)#40
guysenpai wants to merge 12 commits into
mainfrom
phase-1/etch/concurrency-algebra

Conversation

@guysenpai

Copy link
Copy Markdown
Contributor

Closes milestone M1.0.12 — Concurrency algebra (race/sync/branch/spawn { } + cancellation + TaskHandle await). Brief: briefs/M1.0.12-concurrency-algebra.md (Status: CLOSED).

Five review gates (E1–E5), each GO'd on the pushed diff; one Claude.ai STOP round-trip recorded (E0905, §9.2 revision 2) and two in-gate STOP fixes applied (E0905 exemption removal; return-await regression tests).

Closing notes (from the brief)

  • What worked: The E1 pointer-stable pool conversion carried the whole milestone — no drive-path pointer ever needed revisiting after it (the brief's "do not attempt an index-based rewrite" note held). Drive-by-origin's index-based pass gave mid-drive child pickup and the deterministic creation-order guarantee for free, and the parent-precedes-children pool-order invariant turned out to be the load-bearing determinism argument (losers are provably canceled before their wakes can fire). The E4/E5 test batteries passed first-run once written against the documented tick timelines.
  • What deviated from the original spec: One recorded deviation (STOP round-trip 2026-07-02): the E3 "calls inside the four construct bodies count as consumed launch sites" wording was superseded by etch-resolver-types.md §9.2 revision 2 — await is the SOLE call-grain consumer of the {async} effect; the constructs relocate the suspension, their bodies are ordinary async contexts (E0905 applies recursively). See Recorded deviations.
  • What to flag explicitly in review: (1) children_any fires on "any child done OR none suspended" — the second clause realizes the all-branches-failed race passthrough (validated at the E1 GO). (2) Fix-as-you-go: return await <wake-target> silently dropped its return at resume since M1.0.11 — fixed at both resume sites, regression-tested across the three forms (E5 STOP). (3) One-tick construct latency for race/sync with >= 1 admitted branch (parent precedes children in pool order); zero-admitted constructs pass through same-tick — documented in the interleaving tests. (4) Failed tasks park .canceled (shared with explicit cancellation): not a winner, never block a join, await on them fails loud — one state, three semantics, documented on AsyncTask.state. (5) Language-audit exception: one French grammar citation lives in the brief's FROZEN SECTION (upstream-authored, not modifiable here); the two code-comment copies of it were paraphrased to English. (6) KB §9.12 swap content is Claude.ai-produced at the E5 gate (flagged in the gate signal); CLAUDE.md was updated on-branch per §3.4.
  • Final measurements: No benchmarks (interpreter milestone, per brief). Test deltas: 934 (base) → 967 tests — +1 E1 substrate, +8 E2 (1 token + 7 parser), +7 E3 types, +7 E4 interp, +9 E5 interp (incl. the 3-form return-await regression) + the §9.6 observable; full suite green debug + ReleaseSafe throughout; zig fmt --check + zig build lint green.
  • Residual risks / tech debt left intentionally: (1) Monotonic pool growth — one husk per completed task per program run (brief-accepted; Phase-2 VM has the refcounted lifecycle). (2) Heap-backed values (collections/struct handles) in child-task snapshots and in a race winner's return value share the M0.8 POD-across-suspend rule-arena caveat. (3) A branch block whose LAST item is a bare await parses that await as the block's trailing VALUE → E0904 (M1.0.11 placement, unchanged; the §9.5 pattern ends on return and is unaffected). (4) rules_matched counts once per tick per rule when ANY of its tasks drove — a coarse per-rule notion, informational only. (5) The parent link on race/sync children is lineage bookkeeping only (cancellation stays non-transitive by spec).

Validation checklist (brief step 4)

  • Every "Scope" deliverable present (E1 pool substrate; E2 keywords/AST/parse; E3 E0901/E0905/E0906/E0907 + TaskHandle typing; E4 race/sync execution; E5 branch/spawn + runtime TaskHandle)
  • No "Out of scope" drift (no bytecode lowering, no transitive cancellation, no timers/wait_unscaled, no entity_event, no value-producing spawn bodies, no pool slot reuse, structural spawn(...) untouched)
  • All "Acceptance criteria > Tests" green in debug AND ReleaseSafe (967 tests, 0 failed, 17 pre-existing skips)
  • Benchmarks: none required (interpreter milestone)
  • Observable behavior demonstrable: §9.5 timeout pattern (winner return propagates) + §9.6 parallel-preload (sync over three awaits) run in the interpreter harness with the documented emit sequences across ticks
  • zig build, zig build test (debug + ReleaseSafe), zig fmt --check, zig build lint green
  • CLAUDE.md updated on-branch (current-state table, +1 Tags row, M1.0.12 open-decisions entry incl. the §9.2-rev-2 deviation, date)
  • §3.6.1 language audit: FR function-word grep on the branch diff = clean (one exception: a French grammar citation inside the brief's FROZEN SECTION, upstream-authored — noted in Closing notes; its two code-comment copies were paraphrased to English)
  • §3.6.1 local drift audit: stale pre-M1.0.12 references patched (ast.zig spawn_struct doc, interp.zig AsyncSlot leftover, token/comment sweeps at E2/E3) — no orphans left
  • "Closing notes" filled; brief Status: CLOSED, Closed: 2026-07-03
  • Final commit docs(brief): close M1.0.12

For Guy: the KB etch-reference-part1.md §9.12 extension (multi-task realization: child tasks, drive-by-origin, WakeCond set, monotonic pool + husk parking, cancellation teardown, one-tick construct latency) is Claude.ai-produced at the E5 gate — to be swapped into the knowledge base alongside the merge + tag (v0.10.12-concurrency-algebra), per brief E5. Merge (squash) and tag are yours.

🤖 Generated with Claude Code

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