Skip to content

Add weekly state machine diagram generator for agentic workflows#19682

Open
T-Gro wants to merge 4 commits intomainfrom
agentics/state-machine
Open

Add weekly state machine diagram generator for agentic workflows#19682
T-Gro wants to merge 4 commits intomainfrom
agentics/state-machine

Conversation

@T-Gro
Copy link
Copy Markdown
Member

@T-Gro T-Gro commented May 5, 2026

Weekly workflow that reads all .github/workflows/*.md, extracts triggers/labels/handovers/actors, and renders Mermaid diagrams + tables in .github/workflows/docs/state-machine.md. Opens a PR when sources change (sha256 fingerprint). Incremental updates on subsequent runs.

75 lines. repos + bash toolset, create-pull-request output scoped to docs/** only.

Discovers lifecycle groups from data — not hardcoded to current workflows. Handles issue workflows, PR workflows, file/branch workflows, and meta-workflows without prompt changes.

T-Gro and others added 4 commits May 5, 2026 20:20
Weekly workflow that reads all .md agentic workflows in the repo,
extracts triggers, labels, safe-outputs, handovers, and conditions,
then renders a Mermaid diagram + tables in docs/state-machine.md.

Outputs:
- Summary table (workflow / trigger / reads / writes / key labels)
- Mermaid stateDiagram showing full issue + PR lifecycle
- Label dictionary (who applies, who reads, what it means)
- Handover map (workflow A → workflow B, mechanism)

Opens a PR to update the diagram. allowed-files: docs/** only.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Applied: Mermaid stateDiagram-v2 best practices (composite states,
choice nodes, direction LR, classDef styling, notes), Anthropic prompt
guide (XML tags, role, concrete examples), Peli audit-workflows pattern.

Key changes:
- Multiple diagrams by dimension (issues, PRs, labels, handovers)
  instead of one giant unreadable diagram
- Composite states for PR types (fork, non-fork, regression-test)
- Change detection via source fingerprint comment - skip if unchanged
- Diagram guidelines section teaching Mermaid techniques
- Concrete example showing Issue Lifecycle structure
- Screen-wide LR layout, max ~15 states per diagram
- Label dictionary + handover map as tables (not diagrams)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Actors: 👤 contributor, 👤 maintainer, 🤖 agent:<name>, ⚙️ CI, ⏰ scheduler
Every diagram edge shows WHO performs the transition.

CI is always present — PRs go through build/test, agents react to
CI results. Never skip the CI step in diagrams.

Incremental updates: read existing state-machine.md as starting point,
update only sections affected by workflow changes. Minimal diffs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adversarial review by Opus 4.7 + 4.6 found 6 blocking issues.
Generation test by Opus 4.7 produced excellent output but confirmed
the prompt was overfit to current 3 workflows.

Fixes applied:
- Future-proof: agent discovers lifecycle groups from data, not hardcoded
  Issue/PR sections. Handles file/branch workflows (aw-auto-update) and
  meta-workflows (itself) without prompt changes.
- Mermaid: cross-composite transitions go outside blocks (syntax fix).
  Removed broken example. No fake workflow names.
- Fingerprint: sha256 content hash instead of file size.
- Incremental: reads existing output, updates only changed sections.
- Bloat: removed <context>, actor definitions, filler sentences.
  Cut from 173 to 75 lines — same capability.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@T-Gro T-Gro added the NO_RELEASE_NOTES Label for pull requests which signals, that user opted-out of providing release notes label May 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

⚠️ Release notes required, but author opted out

Warning

Author opted out of release notes, check is disabled for this pull request.
cc @dotnet/fsharp-team-msft

@T-Gro T-Gro marked this pull request as ready for review May 5, 2026 19:48
@T-Gro T-Gro requested a review from a team as a code owner May 5, 2026 19:48
@T-Gro T-Gro requested a review from abonie May 5, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NO_RELEASE_NOTES Label for pull requests which signals, that user opted-out of providing release notes

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

1 participant