Skip to content

Add weekly state machine diagram generator for agentic workflows#19682

Merged
T-Gro merged 4 commits into
mainfrom
agentics/state-machine
May 12, 2026
Merged

Add weekly state machine diagram generator for agentic workflows#19682
T-Gro merged 4 commits into
mainfrom
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
@github-project-automation github-project-automation Bot moved this from New to In Progress in F# Compiler and Tooling May 11, 2026
Copy link
Copy Markdown
Member Author

@T-Gro T-Gro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Agentic State Machine Diagram Generator

Looks good — clean, well-scoped automation workflow.

Strengths

  • Data-driven design: Rule 5 (Do not hardcode sections ... Let the data decide) ensures the generator stays correct as workflows are added/removed — no manual catalog maintenance.
  • Incremental updates via sha256 fingerprinting: Avoids unnecessary churn PRs when nothing has changed (noop path).
  • Tight output scope: allowed-files: [".github/workflows/docs/**"] prevents the agent from modifying anything outside documentation.
  • Good prompt hygiene: The <role>, <rules>, <process>, <diagram-guidelines> sections are clear and well-structured. The 75-line prompt is compact for what it does.
  • Lock file is properly compiled via gh aw compile (v0.68.3).

Minor observations (non-blocking)

  1. Cron schedule 0 0 */7 * *: This runs every 7th day-of-month (1st, 8th, 15th, 22nd, 29th), not truly "every 7 days". In months with 31 days, there will be a 3-day gap between the 29th and the 1st. A weekly cron like 0 0 * * 0 (every Sunday) would give more uniform intervals. Since this is non-critical documentation generation, this is fine as-is.

  2. min-integrity: none on the GitHub toolset: This is standard for repos/read-oriented workflows, but worth noting it means the agent can call any repo API without integrity checks. Acceptable here since allowed-files constrains the output.

  3. No checkout: block in the .md: The lock file does include actions/checkout for .github and .agents folders. The agent will need repo access to ls .github/workflows/*.md and sha256sum — this works because bash: true + checkout happen in the compiled workflow. Just noting that the .md source relies on implicit checkout behavior.

  4. Line 76 uses </output> tag: The closing tag on line 76 is </output> but the corresponding opening tag is <diagram-guidelines> — this appears to be a copy-paste artifact. It doesn't affect functionality since gh aw compile treats the content as opaque prompt text, but it's a minor inconsistency.

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

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants