Skip to content

feat(media): add brand-agnostic flow_diagram core template#2898

Merged
chubes4 merged 2 commits into
mainfrom
feat/core-generic-diagram-template
Jul 13, 2026
Merged

feat(media): add brand-agnostic flow_diagram core template#2898
chubes4 merged 2 commits into
mainfrom
feat/core-generic-diagram-template

Conversation

@chubes4

@chubes4 chubes4 commented Jul 13, 2026

Copy link
Copy Markdown
Member

Summary

Adds a generic, spec-driven flow diagram template to core, rendered server-side via the existing GDRenderer. Describe a graph as { nodes, edges } and get a deterministic PNG/JPEG back — no external services, no AI, no per-token cost.

It registers on the core datamachine/image_generation/templates filter, so it's composable for free through the existing datamachine/render-image-template ability across every surface:

wp datamachine image render --template_id=flow_diagram \
  --data='{"title":"...","nodes":[{"id":"a","label":"A"},{"id":"b","label":"B"}],"edges":[{"from":"a","to":"b","label":"next"}]}'

Any consumer of Data Machine (CLI, REST, MCP, PHP) now gets programmatic PHP diagram generation with zero extra wiring.

Design: generic templates in core, domain templates downstream

The GD engine (GDRenderer + TemplateInterface + TemplateRegistry) has always lived in core, but core shipped zero templates by the original "core provides the engine, downstream brings the templates" rule (PR #449). That rule was written for domain-specific graphics (event cards, quote cards). A flow_diagram is different: it's a domain-agnostic structural primitive, same abstraction level as PlatformPresets, BrandTokens, and GDRenderer::get_chart_palette() that core already ships. So it belongs in core; domain templates still stay downstream.

Features

  • Node shapes: box (default), diamond, oval
  • Per-node color (hex) override; auto-shrink + wrap for long/unbreakable labels
  • Directional arrows with optional labelled chips
  • horizontal (default) or vertical layout
  • Canvas sizes to content

Bonus fix

GDRenderer::draw_rounded_rect() called imagefilledroundedrectangle() unconditionally — but that builtin is PHP 8.4+, while the plugin requires PHP 8.0. Rounded nodes fataled on 8.0–8.3. Added a manual rounded-rect fallback (rects + corner ellipses).

Test plan

  • New self-contained smoke test tests/flow-diagram-template-smoke.php — renders a spec, asserts a valid PNG, exercises box/diamond/oval + edge labels + empty-nodes guard + the rounded-rect polyfill path. All 13 assertions pass locally on PHP 8.3.6.
  • Verified visually: rendered a real 4-node OAuth-flow diagram (attached in the PR discussion).

Notes

  • render() returns string[] per the TemplateInterface contract.
  • No breaking changes; purely additive plus one latent-bug fix.

Adds a generic, spec-driven flow diagram template rendered server-side
via GDRenderer. Describe a graph as { nodes, edges } and get a
deterministic PNG/JPEG back — box/diamond/oval node shapes, directional
arrows, optional edge labels, horizontal or vertical layout, auto-fit
labels. Registered on the core datamachine/image_generation/templates
filter, so it's composable for free through the existing
datamachine/render-image-template ability (CLI, REST, MCP, PHP).

Core intentionally ships only generic structural templates; domain
templates (event cards, quote cards) remain downstream.

Also fixes a latent GDRenderer bug: draw_rounded_rect() called
imagefilledroundedrectangle() unconditionally, but that builtin is
PHP 8.4+. The plugin requires PHP 8.0, so rounded nodes fataled on
8.0-8.3. Added a manual rounded-rect fallback.

Includes a self-contained smoke test (renders a spec, asserts a valid
PNG, exercises the polyfill path).
@homeboy-ci

homeboy-ci Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Homeboy Results — data-machine

Lint

review lint — passed

ℹ️ Full options: homeboy self docs commands/lint
Deep dive: homeboy review lint data-machine --changed-since d112d3c

Artifacts and drill-down
  • CI results artifact: homeboy-ci-results-data-machine-review-lint-quality-Linux-node24 contains immediate command JSON for this action invocation.
  • Observation artifact: homeboy-observations-data-machine-review-lint-quality-Linux-node24 contains exported Homeboy run history for deeper queries.
  • Drill-down: download the observation artifact, then run homeboy runs import <dir>, homeboy runs list, and homeboy runs findings <run-id>.
  • Artifacts are attached to the workflow run: https://github.com/Extra-Chill/data-machine/actions/runs/29283366308

Test

review test — passed

ℹ️ Auto-fix lint issues: homeboy refactor data-machine --from lint --write
ℹ️ Collect coverage: homeboy test data-machine --coverage
ℹ️ Pass args to test runner: homeboy test -- [args]
ℹ️ Full options: homeboy self docs commands/test
Deep dive: homeboy review test data-machine --changed-since d112d3c

Artifacts and drill-down
  • CI results artifact: homeboy-ci-results-data-machine-review-test-quality-Linux-node24 contains immediate command JSON for this action invocation.
  • Observation artifact: homeboy-observations-data-machine-review-test-quality-Linux-node24 contains exported Homeboy run history for deeper queries.
  • Drill-down: download the observation artifact, then run homeboy runs import <dir>, homeboy runs list, and homeboy runs findings <run-id>.
  • Artifacts are attached to the workflow run: https://github.com/Extra-Chill/data-machine/actions/runs/29283366308

Audit

review audit — passed

  • audit — 5 finding(s)
  • Total: 5 finding(s)

Deep dive: homeboy review audit data-machine --changed-since d112d3c

Artifacts and drill-down
  • CI results artifact: homeboy-ci-results-data-machine-review-audit-quality-Linux-node24 contains immediate command JSON for this action invocation.
  • Observation artifact: homeboy-observations-data-machine-review-audit-quality-Linux-node24 contains exported Homeboy run history for deeper queries.
  • Drill-down: download the observation artifact, then run homeboy runs import <dir>, homeboy runs list, and homeboy runs findings <run-id>.
  • Artifacts are attached to the workflow run: https://github.com/Extra-Chill/data-machine/actions/runs/29283366308
Tooling versions
  • Homeboy CLI: homeboy 0.283.1+10b6335515eb+1b9b5338
  • Extension: wordpress from https://github.com/Extra-Chill/homeboy-extensions
  • Extension revision: 40f77e42
  • Action: unknown@unknown

Fixes 25 WordPress.Arrays.MultipleStatementAlignment warnings flagged by
the release lint gate. Whitespace-only; no logic change.
@chubes4 chubes4 merged commit f52c748 into main Jul 13, 2026
5 checks passed
@chubes4 chubes4 deleted the feat/core-generic-diagram-template branch July 13, 2026 20:44
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