State Primitive Spike: replace Projection + App.hydrate with state-agent#146
Open
taras wants to merge 1 commit into
Open
State Primitive Spike: replace Projection + App.hydrate with state-agent#146taras wants to merge 1 commit into
taras wants to merge 1 commit into
Conversation
The deterministic peer-loop example previously used a five-op `Projection`
agent purely to journal state transitions and an `App.hydrate` op that
pushed per-iteration snapshots into the browser session mirror. This
spike collapses both into a single synthetic `state-agent` agent
(`readInitialState`, `transition`) backed by an example-local authority
that fans out snapshots to subscribers (the browser session manager).
Workflow body now holds one rolling `let state: AppState` seeded via
`StateAgent().readInitialState({})` and reassigned after every accepted
transition. The host's `main.ts` reads `JOURNAL_PATH` directly via
`FileStream` and seeds the authority by folding recorded
`state-agent.transition` results, so live and replay see identical
seeded state.
Replay-bypass holds: the binding handler is never invoked for any
recorded `state-agent.transition` event during replay (verified in
`test/replay/state-replay.test.ts`).
The spike does not touch any package source; no kernel changes were
required. Full report at `notes/state-primitive-spike/report.md`.
Tests: 41 passing across 10 files in
`examples/deterministic-peer-loop` (incl. 3 new STATE-RE tests + 5
new state-authority unit tests + rebaselined 27 conformance + 2
DPL-JNL replay tests).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on PR #119. Replaces the deterministic peer-loop's
Projectionagent (5 reducer ops, journal-only) and
App.hydrateop with a singlesynthetic
state-agent(readInitialState,transition) backed by anexample-local authority. The authority is seeded at host startup by
folding recorded
state-agent.transitionresults out of the journal.The workflow body collapses 5 per-field state locals into one rolling
let state: AppState. The browser binding installs an authoritysubscription that fans out every accepted snapshot — no more
per-iteration workflow push, no
publishFinalSnapshot.The spike does not modify any source under
packages/. No kernelchanges were required to support the primitive.
Spike conclusion
The state-transition primitive can live above the kernel for this
example. Full report at
notes/state-primitive-spike/report.md.Two follow-ups escalated (neither blocking):
Get<T>collapses toEvalT<unknown>, which forced thetransitionop to return bareAppState(validated as the rightshape independently — proposal lives durably in
description.inputper PR Payload-sensitive replay: runtime + kernel implementation (PR 2 of 2) #145).workflow that uses
race+ inline children. Test reformulated touse a 1-event prefix; not a regression.
Test plan
examples/deterministic-peer-loop(5 newstate-authority unit tests + 3 new STATE-RE replay tests + 27
rebaselined conformance tests + 2 DPL-JNL replay tests + 4 misc).
pnpm run lint).pnpm run format:check).notes/state-primitive-spike/manual-smoke.md(host restart → re-attach → identical state).
Notes for review
spec work, or kernel — is taken after the report, not as part
of the spike. The recommended next step in the report is a
scoped-effects spec amendment, not direct promotion of the
example-local pattern.
examples/deterministic-peer-loop/src/.No package edits.