Skip to content

Commit 7faec55

Browse files
committed
Add filesystem-state branch findings to app graph design
- Link orphan branch pattern to GitHub Actions Workspace design - Document gitstate package reuse opportunity - Detail run-time graph persistence via rad shutdown - Expand alternatives table with cache/artifacts options - Update open question on rad shutdown integration
1 parent 12bf106 commit 7faec55

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

‎eng/design-notes/resources/2026-04-app-graph.md‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Radius should provide a way to access all three kinds of graph.
6060
| Deployment Graph | An application graph constructed by querying the Radius control plane for the live resources of a deployed application. |
6161
| Simulated Deployment Graph | An application graph that represents what would be deployed if an application definition were applied to a specific environment. |
6262
| Graph Artifact | The serialized JSON file (`app.json`) containing a `StaticGraphArtifact` stored on the orphan branch. |
63-
| Orphan Branch | A Git branch with no common history to `main`, used to store graph artifacts (default: `radius-graph`). |
63+
| Orphan Branch | A Git branch with no common history to `main`, used to store graph artifacts (default: `radius-graph`). The same pattern is used by the [GitHub Actions Workspace](../2026-03-github-workspace-design.md) feature for state persistence (`radius-state` orphan branch). |
6464
| DiffHash | A stable BLAKE2b hash of a resource's review-relevant properties, used to detect modifications between branches. |
6565
| rootScope | The current UCP scope (e.g., `/planes/radius/local/resourceGroups/default`). |
6666
| codeReference | An optional resource property providing a repo-relative file path to the source code implementing the resource. |
@@ -515,13 +515,29 @@ The graph is constructed in-memory but must be persisted so it remains accessibl
515515
| Graph type | Persisted where | Written when |
516516
|---|---|---|
517517
| Static graph | `{branch}/app.json` on `radius-graph` orphan branch | CI runs `rad graph build` on push/PR |
518-
| Run-time graph | `graphs/{app}.json` on `radius-state` orphan branch | `rad shutdown` serializes after deploy (future) |
518+
| Run-time graph | `graphs/{app}.json` on `radius-state` orphan branch | `rad shutdown` serializes after deploy |
519519

520520
**Why orphan branches?**
521521
- No interference with application code history.
522522
- GitHub Contents API provides easy access without local checkout.
523523
- Natural per-branch organization (`main/app.json`, `feature-branch/app.json`).
524524
- PR diff visualization naturally flows from comparing base vs head artifacts.
525+
- Zero additional infrastructure — git is already available with `actions/checkout` credentials.
526+
- Atomic commit+push semantics for consistent state.
527+
528+
**Relationship to the GitHub Actions Workspace feature:**
529+
530+
The orphan branch persistence pattern is shared with the [GitHub Actions Workspace](../2026-03-github-workspace-design.md) feature (`filesystem-state` branch). That feature uses a `radius-state` orphan branch to persist PostgreSQL database backups across ephemeral CI runs. The app graph feature uses a separate `radius-graph` orphan branch for graph artifacts. Both use the same underlying technique:
531+
532+
- `git worktree add` in `/tmp/` for isolated operations
533+
- Sentinel files for lifecycle state (the workspace feature uses `.lock`, `.backup-ok`, `.deploy-lock`)
534+
- Atomic commit+push with the `GITHUB_TOKEN` from `actions/checkout`
535+
536+
The `gitstate` package from the workspace feature (`pkg/cli/gitstate/`) provides reusable primitives for orphan branch management (create, checkout, commit, push) that the graph builder's orphan branch logic could adopt to avoid duplicating git plumbing code.
537+
538+
**Run-time graph persistence via `rad shutdown`:**
539+
540+
The `rad shutdown` command (from the `filesystem-state` branch) backs up PostgreSQL state and tears down the k3d cluster. A natural extension is to call `getGraph` for each deployed application during shutdown and write the graph JSON to the `radius-state` orphan branch alongside the SQL dumps. This would make run-time graphs available for visualization even after the cluster is destroyed — enabling the browser extension to show deployed infrastructure topology from the last known state.
525541

526542
---
527543

@@ -678,7 +694,7 @@ The browser extension is tested manually:
678694

679695
4. **`codeReference` adoption:** Who sets the `codeReference` property — the developer manually, or should tooling (e.g., Copilot skills) populate it automatically?
680696

681-
5. **Run-time graph persistence:** The design mentions storing run-time graphs on a `radius-state` orphan branch via `rad shutdown`. Should this be implemented in this iteration or deferred?
697+
5. **Run-time graph persistence:** The `filesystem-state` branch implements `rad shutdown` with PostgreSQL backup to a `radius-state` orphan branch. Adding a `getGraph` call during shutdown to persist the run-time graph JSON alongside the SQL dumps would enable deployed graph visualization after cluster teardown. Should this be integrated in this iteration or deferred?
682698

683699
6. **Cloud provider navigation:** For deployed graphs, clicking a resource should navigate to the cloud provider console (AWS, Azure). How should provider-specific URLs be constructed?
684700

@@ -703,8 +719,10 @@ The browser extension is tested manually:
703719
| File in repo (e.g., `.radius/graph.json`) | Simple, visible in PRs | Clutters commit history, merge conflicts |
704720
| Orphan branch | Clean separation, no history interference | Requires git operations, less discoverable |
705721
| External storage (S3, Azure Blob) | Scalable | Extra infrastructure, auth complexity |
722+
| GitHub Actions cache | No extra infra | Unpredictable eviction (7-day TTL, LRU) |
723+
| GitHub Actions artifacts | Cross-run accessible | Retention limits, complex download logic |
706724

707-
**Chosen approach:** Orphan branch. Clean separation from application code, natural per-branch organization, accessible via GitHub API.
725+
**Chosen approach:** Orphan branch. Clean separation from application code, natural per-branch organization, accessible via GitHub API. This is consistent with the `filesystem-state` branch's choice of orphan branches for PostgreSQL state persistence, validated by the same analysis (see [GitHub Actions Workspace](../2026-03-github-workspace-design.md) alternatives considered).
708726

709727
### Browser extension vs GitHub App/Action with Markdown
710728

0 commit comments

Comments
 (0)