Use XState machines for designing and explaining complex state
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- node.js, typescript
- Lĩnh vực
- developer-experience
Hướng nghiên cứu
Start by reading the architect, interrogate, how, and teach entry points and the repository’s existing reference files. Then resolve the listed questions about Stately login, privacy, sketch format, and tooling before drafting state-machines.md and updating the relevant phases. Done means the guidance and edits cover the agreed workflow and its fallback; the issue does not name tests to run.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
When agents design or explain parts of a system, everything comes back as prose. Lifecycle and protocol state (auth flows, sync, retry/cancel/timeout, wizards, connection handling) is hard to review that way. Impossible states hide in boolean flags, and nobody can check that the code still matches the agreed design.
Idea
Use XState machines as the notation for complex state. An agent writes the machine as code, the human reviews it as a diagram, and the same machine yields a test plan and a check for drift. Use the Stately CLI (statelyai) for the tooling.
Draft placement:
| Where | What |
|---|---|
New state-machines.md reference |
When to reach for XState: lifecycle or protocol state, async flows with cancel/retry/timeout, or several booleans that can combine into impossible states. When not to: simple toggles and plain data transforms. |
architect Phase A |
statelyai scan --json to find existing machines while grounding. |
architect Phase B |
For state-heavy work, the sketch includes a machine next to the types. |
architect Phase C |
At a checkpoint, statelyai open gives the human an editable diagram. |
architect Phase D |
statelyai diff checks the implementation against the agreed machine. @xstate/graph paths become the test plan for tdd. |
interrogate |
statelyai diff against the base when a diff touches a machine. |
how / teach |
Offer open when a subsystem already has a machine. |
Default to using the machine as a design document: the sketch lives outside the project's source, and the project gains no dependency. Adding xstate to the app is a separate architect candidate. It's labelled as adding a dependency and goes ahead only on approval, or when scan shows the project already uses xstate.
Tldraw is out of scope for now. It would need its own bridge into Claude Code, and the Stately CLI already covers the state-machine case.
Findings (tested 2026-10-22)
Probes ran in throwaway folders with no package.json or node_modules.
- The CLI needs no xstate in the target project. It reads the source as text and never imports xstate.
scan --jsonfound the machines with no config and no login.diff a.ts b.ts --fail-on-changesworks on two local files. It reportedAdded edges: root.closed->SLAM->root.open, exiting1when the machines differ and0when they match.
[email protected](latest) doesn't install. It depends on@statelyai/[email protected], which isn't on npm (404).0.14.3works. Pin an exact version.- A JSON machine compares equal to the same machine in TS.
diff door.machine.ts door.jsonreported no changes. A plain.jsonsketch would avoid the problem of animport 'xstate'line breaking the project's typecheck.scanonly listed the.tsfile, though. diffcan't read Mermaid. It fails on.mmdwith a JSON parse error, even though the CLI's file pattern includes.mmd/.mermaid.openneeds a Stately account. The CLI starts a local server, but the editor is an iframe fromeditor.stately.ai. Its access endpoint (/api/editor-sync/access) returns401 AUTH_INVALID: A valid Stately credential is required for editor syncwithout a credential. Write-back to the source file is not verified.- Path generation works outside the project.
@xstate/[email protected]with[email protected]andtsx, installed in a scratch folder, produced shortest paths as event sequences. Example:FETCH → REJECT → RETRY → RESOLVE. - Sketches with stubbed actions give misleading paths. In a retry machine whose
bumpRetriesaction was named but not implemented, the retry count never changed, andgaveUpwas never reached. WithbumpRetriesimplemented as anassign, it was reached viaFETCH, REJECT, RETRY, REJECT, RETRY, REJECT, RETRY, along with 13 paths in all. Implementing the action also showed thatCANCELdoesn't reset the retry count. That's the kind of design gap this approach should surface.
Open questions
- Stately account. Is a login acceptable for the visual part, and does the free tier cover editor sync? Without one, gstack gets
scan,diffand test paths, but no diagram editing. - Privacy. With
open, the machine is shown in a page hosted by Stately. Does the machine content leave the machine (i.e. reach Stately's servers)? Is that OK for private repos? - Write-back. Once logged in, do edits in
openland cleanly in a.tssketch? What about a.jsonone? And what does--source-update preserve|rewritedo to formatting? - Fallback diagram. Without an account, what do we show? Options: a Mermaid
stateDiagramwritten by the agent, or one generated from the machine. - Sketch format and location.
.ts(scan finds it, but it imports xstate) or.json(no import,diffworks,scandoesn't list it)? Scratchpad or a committed planning folder? - Stubbed implementations. Should
architectrequire realassigns for context the guards read? Or should paths only be generated from an implemented machine? - Path explosion. Context values multiply the states the path search explores. What limits do we set before we feed the paths to
tdd? - Tooling dependency. gstack would need Node, npx and network access to fetch pinned packages. Is that acceptable for a skill, and what's the fallback when they're missing?
- Trigger. How does
architectdecide that work is "state-heavy" without asking every time?
Next step
Grill the open questions, starting with the Stately account and privacy questions. Then write state-machines.md and the architect edits.
- Ngôn ngữ chính
- TypeScript
- Star
- 0
- Fork
- 0
- Merge trung bình
- 3 giờ 33 phút
- Pull request đã merge (30 ngày)
- 13
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của gregogun/gstack
-
ready-for-agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ready-for-agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ready-for-human
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 43/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ready-for-agent
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 56/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của gregogun/gstack
Issue tương tự
-
area: image-engine bug priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
snapotter-hq/SnapOtter#3885 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Mend: dependency security vulnerability
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 3 ngày
-
pending triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug P3 UI/UX
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
openclaw/openclaw#182077 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày