Skip to content

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

Merged
guysenpai merged 13 commits into
mainfrom
phase-1/etch/concurrency-algebra
Jul 3, 2026
Merged

Phase 1 / Etch / Concurrency algebra (race, sync, branch, spawn)#40
guysenpai merged 13 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

guysenpai added a commit that referenced this pull request Jul 3, 2026
Fix the fossilized Zig build cache that has been canceling the required
build-and-test (windows-2025, ReleaseSafe) check since M1.0.11 and blocks
the M1.0.12 merge (PR #40).

CI: the monolithic actions/cache@v5 step never re-saved on an exact-key
hit, and its key (os-mode-zigver-zonhash) had no per-commit component —
under a stable build.zig.zon the cache froze at its first save while the
M1.0.x milestones drifted the sources, until the near-cold windows-2025
ReleaseSafe recompile blew the 40-min job budget; the timeout also
skipped the post-job save, locking the loop. Replaced with an explicit
restore/save split: per-sha primary key (never exact-hits on a fresh
commit, so every run refreshes from the most recent prior state; GitHub
LRU retires old entries), three-level prefix fallback (exact sha ->
newest under this zon -> newest under this os/mode/zig), a mid-job save
right after zig build (a run killed during zig build test still leaves a
fresh build cache — timeout immunity), and a final if: always() save
(red test legs still save). Timing report now records cache_matched_key
(which fallback level seeded the run). ReleaseSafe budget 40 -> 55 min
(near-cold headroom on the slowest runner; Debug stays 20). Whitelist
note: actions/cache/restore@v5 and save@v5 are sub-actions of the
already-whitelisted actions/cache@v5. Bench and docs cache sites
untouched.

CI: full required-check set green on the PR head.

Notable: all three fallback levels observed in real runs, plus the
rescue path — a red attempt's final save was exact-hit by its rerun
(1 m 47 s). One recorded deviation: commit type chore(ci) instead of the
prompt's ci(...), which the section 4.3 whitelist and the commit hook
reject. Warm-lineage variance observed (a matched key does not guarantee
a short build; the budget is the protection, not the key ladder).

Measures: windows-2025 ReleaseSafe near-cold 35 m 27 s (build 419 s /
test 1652 s, first non-NA test_seconds since M1.0.11) vs exact-hit
build 2 s / test 20 s; ubuntu ReleaseSafe warm zon-prefix 1 m 13 s.

Closes the CI cache refresh chore.
Brief: briefs/chore-ci-cache-refresh.md
@guysenpai guysenpai merged commit 94928fe into main Jul 3, 2026
10 checks passed
@guysenpai guysenpai deleted the phase-1/etch/concurrency-algebra branch July 3, 2026 16:15
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