Skip to content

Prototype: Services as composable state machines - #190

Draft
kyleve wants to merge 1 commit into
cursor/prototype-post-write-reconcile-planfrom
cursor/prototype-services-state-machines
Draft

Prototype: Services as composable state machines#190
kyleve wants to merge 1 commit into
cursor/prototype-post-write-reconcile-planfrom
cursor/prototype-services-state-machines

Conversation

@kyleve

@kyleve kyleve commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Look-only prototype — not wired into production.

What this is

An exploratory sketch of redefining WhereServices coordination as composable state machines:

ServicesSnapshot     ← whole-system state at a glance
ServicesEvent        ← commands + effect completions
ServiceEffect        ← scheduled side effects
ServicesMachine      ← top-level reduce()
Machines/            ← one reducer per TLA spec slice
ServicesMachineReplay ← scenario tests

Sub-machines (TLA-aligned)

Machine Spec
TrackingMachine TrackingReconciliation
PostWriteMachine PostWriteReconcile
IngestorMachine IngestorQuiesce
LaunchMachine LaunchLifecycle
ResetMachine WhereServices.reset() ordering

Plain actors (ReportReader, backup export, recent activity, …) stay out of scope.

How to read it

  1. Start at Where/WhereCore/Sources/Prototype/ServicesStateMachine/ServicesSnapshot.swift
  2. Then ServicesMachine.reduce — one event in, snapshot + effects out
  3. Pick any Machines/*.swift — maps 1:1 to an existing TLA README
  4. Run ServicesStateMachineTests — replays Coalesced.cfg / Current.cfg scenarios

Docs: Where/WhereCore/Prototype/ServicesStateMachine/README.md

Stacked on

If this were real

A production runner would replace ad-hoc Task loops in WhereSession / DayJournal incrementally — one protocol at a time — not a big-bang rewrite.

Open in Web Open in Cursor 

Add an exploratory ServicesStateMachine layer under WhereCore/Prototype
that models five TLA-aligned protocol slices (tracking, post-write,
ingestor quiesce, launch, reset) as pure reducers over a composite
ServicesSnapshot. Includes scenario replay tests and a README — not
wired into production WhereServices.

Co-authored-by: Cursor <cursoragent@cursor.com>
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