Skip to content

Journey flow diagrams in /map (Mermaid, crawler-generated)#8

Open
roobottom wants to merge 4 commits into
mainfrom
flow-diagrams
Open

Journey flow diagrams in /map (Mermaid, crawler-generated)#8
roobottom wants to merge 4 commits into
mainfrom
flow-diagrams

Conversation

@roobottom

Copy link
Copy Markdown
Collaborator

Adds a flow diagram per journey to /map, generated deterministically by crawling the running prototype — so developers can see how screens connect (logic, branches, decisions), not just the screenshots.

How it works

  • npm run flow:crawl drives the live app (Playwright, reusing the screenshot harness): seeds entry state once via the preview-data query param, submits each screen's own rendered form (valid by construction) or follows "Change X" hub links, follows the real redirects, maps URLs back to map.json step ids, and writes app/journeys/<version>/<journey>/flow.mmd. Deterministic (fixed fixtures + the today override), committed like the screenshots.
  • Multi-seed decisions: it crawls once per distinct variant data seed and emits a decision_* diamond where the entry routes to different first screens across seeds (state-driven, e.g. cancel → affected-bookings vs check-answers).
  • Live versions only ("live": true in app/map/versions.json, currently v4); historic screenshot-only versions show no Flow tab.
  • npm run flow:validate: node id = step id (clickable), errors on unknown step nodes, warns on coverage gaps.
  • UI: a header Board ↔ Flow toggle on the journey page; nodes are clickable → jump to that step's detail.
  • /flow-annotate (.github/prompts/): an agent reads the routes to label decision diamonds and add change-driven branches the crawler can't reach — refining, never redrawing, the crawled diagram. Documented in AGENTS.md §12.

What crawls

9 of 11 v4 journeys render flows: create-* (linear), change-single-clinic / change-clinic-series / sites (hub-and-spoke), cancel-* (with the affected-bookings decision diamond).

Known limits (by design)

  • Edit-flow affected-bookings is change-driven (recomputed from an edit, not seed state) so it isn't crawlable — add it via /flow-annotate. flow:validate warns it's missing for change-* journeys.
  • change-clinic-that-is-part-of-a-clinic-series enters via a stale today-relative session id (redirects to /clinics/week) so it's flowless — a fixture-drift issue, not the crawler.
  • clinics is a browse area (no sequential flow).

Verify

npm start (Node 22), open /map/v4/cancel-single-clinic → Flow tab shows the decision diamond; /map/v4/change-single-clinic shows the hub-and-spoke flow; click a node to jump to its step. npm run flow:validate passes.

🤖 Generated with Claude Code

roobottom and others added 4 commits June 29, 2026 23:29
Per-journey flow diagrams generated deterministically by crawling the live app.

- scripts/flow-crawl.js: drives the running prototype (Playwright), seeds entry
  state once via the preview-data query param, submits each screen's rendered
  form, follows redirects, maps URLs to step ids, and writes flow.mmd. Live
  versions only (versions.json `live` flag).
- scripts/flow-validate.js: node-id = step-id checks + coverage warnings.
- API: buildJourneyModel serves flow:{mermaid}|null + flowExpected.
- Frontend: mermaid dep + FlowDiagram (clickable step nodes -> step detail);
  JourneyPage gains a header Board/Flow tab toggle.

Crawls linear Continue-flows cleanly (create-*, cancel-a-date-range). Hub-and-
spoke change-* journeys and branch decisions are Phase 2.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The crawler now explores via re-seed + replay: a screen with a submit button is
submitted; a screen without one (an edit summary hub) has its in-journey "Change
X" links followed. A trailing /success URL with no map.json step maps to a
synthetic ext_success terminal node (fixes the cancel cross-journey handoff).

Now crawls change-single-clinic (summary -> date/times/services -> check-answers
-> success), change-clinic-series and sites in addition to the linear flows.
Remaining: affected-bookings decision branch (needs multi-state seeding),
change-one-off entry redirect, and a couple of coverage gaps.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Crawls each journey once per distinct variant `data` seed and merges the graphs.
When the entry lands on different first screens across seeds (a state-driven
decision, e.g. cancel routes to affected-bookings when the clinic has bookings,
else check-answers), a decision_start diamond is emitted. Optional map.json
`flowEntry` lets a journey start at a redirecting URL.

Cancel journeys now render the affected-bookings decision diamond; create-clinic
-series picks up the conditional closures step. Change-flow affected-bookings is
change-driven (recomputed from an edit) and is left for /flow-annotate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- .github/prompts/flow-annotate.prompt.md: an agent reads the routes to label
  decision diamonds and add change-driven branches the crawler can't reach,
  refining (never redrawing) the crawled flow.mmd, then runs flow:validate.
- AGENTS.md §12 documents the flow.mmd artifact, the live-only rule, the
  node-id = step-id convention, flow:crawl/flow:validate, and the golden rule
  to regenerate from the app rather than hand-draw structure.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.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