Skip to content

feat(cesar): turn-state reducer + sequential effect driver (Phase 0c … - #268

Merged
cukas merged 2 commits into
mainfrom
feat/turn-runtime-phase0
Jul 17, 2026
Merged

feat(cesar): turn-state reducer + sequential effect driver (Phase 0c …#268
cukas merged 2 commits into
mainfrom
feat/turn-runtime-phase0

Conversation

@cukas

@cukas cukas commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

…spike)

Phase 0c of the cesar-turn-runtime program: proves the tribunal-mandated shape — KERN machine generates the pure throwing transition layer; a TOTAL reducer (attemptTurnStep converts illegal transitions to no-ops) emits declarative effect intents; a promise-tail driver applies events strictly in order. NOT wired into brain.kern yet — Phase 3 migrates the real flags onto this skeleton after the Phase-0 gate re-review.

Guarantees pinned by tests (12):

  • a captured ask can NEVER be barreled past by an auto-continue, and an ask parked during commit is re-surfaced at committed (never-lose)
  • illegal/duplicate events no-op instead of crashing (3-engine review: the first draft called throwing transitions unguarded)
  • fail is legal from asking — an engine error mid-ask surfaces the real reason instead of throwing
  • awaiting dispatch() means THAT event was applied, including for non-tail-owning callers (review: early-resolve bug in the queue+pump draft); a throwing effect becomes engine-errored, never a wedged tail
  • terminal states absorb zombie chunks from abandoned generators

Self-coverage gate shaped the code: no switch statements, no closure try (attemptTurnStep is a module-level fn), no void expression stmts.

Resolves the spec's OPEN question: machine CAN express the pure transition layer — no KERN-GAP needed.

⚔️ Forged by Agon

…spike)

Phase 0c of the cesar-turn-runtime program: proves the tribunal-mandated
shape — KERN `machine` generates the pure throwing transition layer; a
TOTAL reducer (attemptTurnStep converts illegal transitions to no-ops)
emits declarative effect intents; a promise-tail driver applies events
strictly in order. NOT wired into brain.kern yet — Phase 3 migrates the
real flags onto this skeleton after the Phase-0 gate re-review.

Guarantees pinned by tests (12):
- a captured ask can NEVER be barreled past by an auto-continue, and an
  ask parked during commit is re-surfaced at `committed` (never-lose)
- illegal/duplicate events no-op instead of crashing (3-engine review:
  the first draft called throwing transitions unguarded)
- fail is legal from `asking` — an engine error mid-ask surfaces the
  real reason instead of throwing
- awaiting dispatch() means THAT event was applied, including for
  non-tail-owning callers (review: early-resolve bug in the queue+pump
  draft); a throwing effect becomes engine-errored, never a wedged tail
- terminal states absorb zombie chunks from abandoned generators

Self-coverage gate shaped the code: no switch statements, no closure
try (attemptTurnStep is a module-level fn), no void expression stmts.

Resolves the spec's OPEN question: `machine` CAN express the pure
transition layer — no KERN-GAP needed.

⚔️ Forged by [Agon](https://github.com/KERNlang/agon)

Co-Authored-By: agon (KERN) <292465531+KERN-Agon@users.noreply.github.com>
…d clean

kern-guard's undefined-reference rule does not register the machine
primitive's DERIVED codegen names (per-transition fns + <Machine>StateError),
so the reducer's references to them failed CI despite compiling and testing
green (KERN-GAP: review/undefined-reference should learn machine-derived
bindings). Split the file: turn-state.kern keeps the declarative layer
(machine + TurnEvent/TurnEffect unions + TurnSnapshot), the new
turn-reducer.kern holds initialTurnSnapshot/attemptTurnStep/reduceTurn/
TurnDriver and imports the machine's generated fns explicitly — every
reference is now a guard-visible declaration, and the machine's generated
surface is documented at the import site. No behavior change; 12/12 spike
tests unchanged, full gate green.

⚔️ Forged by [Agon](https://github.com/KERNlang/agon)

Co-Authored-By: agon (KERN) <292465531+KERN-Agon@users.noreply.github.com>
@cukas
cukas merged commit a470086 into main Jul 17, 2026
2 of 3 checks passed
@cukas
cukas deleted the feat/turn-runtime-phase0 branch July 17, 2026 14:32
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