Vai al contenuto principale
BlueForge
Inizia gratis

The federation

Federation-wide architecture graph

Every service in the federation and the edges between them — who issues identity, who gates merges, where state lives.

Rendered from docs/federation-architecture.mdrelease v0.2.0Edit on forge-git

Status: design as of 2026-09-20. Implementation in flight across multiple repos. Spec authority: docs/plans/2026-09-20-architecture-sdk-v1.md.

This is the single doc that ties the federation-wide artifact graph together: every repo's architecture, every app's lifecycle, every test's coverage. The hub-and-spoke model, end-to-end.

Why this exists

Before the federation-wide artifact graph, each repo reconstructed its own architecture in isolation:

  • forge-dev had markdown diagrams that drifted from the code.
  • forge-biz Mission Engine observers had no federation-wide view of what user-flows existed or which had coverage.
  • forge-marketplace had no way to surface "which apps consume this signed template" because the dependency graph was implicit.
  • taskmaster rendered feature/task trees without knowing what architecture they lived in.

The federation-wide artifact graph solves this by treating every artifact as a node and every relationship as a typed edge, persisted in forge-control as the hub, and consumable by all the consumers.

The hub-and-spoke model

                ┌─────────────────────────────────────────┐
                │            forge-control                │
                │  /api/architecture-graphs/ingest        │
                │  /api/architecture/edges/*              │
                │  /api/architecture/join                 │
                │  /api/architecture/coverage/:appId      │
                │  /api/architecture/lifecycle/:appId     │
                │           (the hub)                     │
                └──────────┬──────────────────────────────┘
                           │
        ┌──────────────────┼──────────────────┬─────────────┐
        │                  │                  │             │
        ▼                  ▼                  ▼             ▼
   architecture-sdk   taskmaster        forge-biz     forge-dev
   (every repo)       (graph view)      (Mission       (feature-
                                         Engine         test-
                                         observers)     reporter)
                           │
                           ▼
                    forge-marketplace
                    (declared package
                     consumers)
                           │
                           ▼
                    packr-registry
                    (per-package
                     metadata)
  • Hub: forge-control stores the canonical federation graph. Each repo's graph — the registerArch(...) chain's output, or a ts-morph/sidecar scan — is POSTed to /api/architecture-graphs/ingest (e.g. forge arch-graph push, Bearer AUDIT_UPLOAD_KEY). The hub persists the graph + computes content hashes and exposes graph reads (GET /api/architecture-graphs/...).
  • Spokes: every consumer reads from the hub via the JOIN API. No spoke talks to another spoke directly.
  • Source-of-truth surface: each repo's architecture is declared via registerArch(...) calls (runtime) + sidecar V3 YAML (intent). The hub reconciles the two and computes lifecycle state from signals.

Data flow — end to end

The path from a developer's chain declaration to a rendered lifecycle badge in taskmaster:

1. Declare (in the repo)

// server/src/main.ts
import { registerArch, arch } from "@blueforge-studio/architecture-sdk";

registerArch({ id: "lq-cards", name: "Quest Cards" })
  .process("lq-cards/api", { variant: "hono", port: 3410 })
  .app("lq-cards-api", { port: 4000, runtime: "node22", packages: ["@blueforge-studio/auth"] })
  .feature("build-deck", { refsFlow: "build-deck" })
  .flow("build-deck", "user-flows/build-deck.flow.json", { risk: "high" })
  .done();

The chain emits an ArchitectureGraph with the v0.2.0 enum set (process, app, feature, flow, etc.) via the wire format reused from @blueforge-studio/arch-graph.

2. Emit (codegen or runtime)

Two paths to produce the wire-format JSON:

Runtime (server boot):

  • App calls memoizeArchGraph(graph); GET /internal/architecture returns it when ARCH_SDK_DUMP=1.

Codegen (CI / on-demand):

  • arch-sdk codegen --graph ./blueforge.architecture.yml --target forge-control-graph produces arch-graph.json.
  • arch-sdk codegen --source server/src/main.ts --target forge-control-graph walks the source AST (no YAML needed).

3. POST to hub

  • arch-sdk codegen --target forge-control-graph produces arch-graph.json (there is no arch-sdk ingest command).
  • The arch-graph CLI (forge arch-graph push [--sidecars]) POSTs it to POST /api/architecture-graphs/ingest with Authorization: Bearer <AUDIT_UPLOAD_KEY> — the ingest route's audit token (requireAuditToken), not a deploy token.

forge-control validates the wire format against @blueforge-studio/arch-graph (v0.2.0 enum set: 19 NODE_KINDS, 11 EDGE_KINDS). On success, the graph is upserted into the arch-graph table with (app_id, graph_version) keyed.

4. Reconcile (drift detection)

forge-control runs the three-way drift comparison per artifact:

Source What it says Where it lives
YAML intent What we meant to build Sidecar V3 YAML (blueforge.app.yml, blueforge.feature.yml, etc.)
Runtime fact What actually exists in code registerArch(...) chain, emitted at codegen or runtime
Inferred state What the lifecycle detector computes Derived from deploy log + test runs + code presence

Three drift channels surface inconsistencies:

  • CI gate (arch-sdk check --drift) — exits non-zero on ⚠️ rows.
  • Drift report (.forge/architecture.drift.yml) — written on every codegen pass.
  • Dashboard (taskmaster overlay) — yellow badges on ⚠️ rows.

5. Consume

Consumers read via the JOIN API:

GET /api/architecture/join?productId=quest-cards&include=apps,packages,tests,user-flows,data-flows

Returns a single JSON document with all artifacts in the product's graph, joined by id and extends. Each consumer projects the shape it cares about:

  • taskmaster — renders the product/epic/feature/task tree with an architecture overlay (route-groups that implement the feature, user-flows / data-flows the feature touches, tests that verify it, lifecycle state + coverage %).
  • forge-biz Mission Engine — observers register which user-flows they cover; the JOIN surfaces uncovered flows as a coverage report.
  • forge-dev feature-test-reporter — enriches test reports with architecture_coverage (fraction of routes / tables / workers with tests attached) + lifecycle_state per artifact + drift_warnings surfaced from the three-way comparison.
  • forge-marketplace — declared consumedBy on package sidecars joins with deployed_apps to surface "which apps consume this signed template".
  • packr-registry — consumes the per-package sidecar (exports[], consumedBy[]) to surface the public surface area + declared consumers in its UI.

Drift-free lifecycle (the heart of it)

Per the operator-ratified spec (docs/plans/2026-09-20-architecture-sdk-v1.md § "Lifecycle states"):

registerArch, verifies, and underTest carry no status field. Lifecycle is a derived property, computed from signals — never manually set on the hot path.

State machine

stub → planned → in-progress → verified → shipped → deprecated

Detection is signal-driven:

State Detection signal
stub Declared in sidecar YAML, no code anchor (no registerArch node matches)
planned Sidecar YAML status: planned (operator override; no code yet)
in-progress Code anchor exists, ≥1 verifies edge resolves, latest run did NOT pass
verified Code anchor + all verifies edges resolve AND latest run passed
shipped verified + deploy log shows recent successful deploy
deprecated Sidecar YAML status: deprecated, OR no incoming verifies for 90+ days

What's manual, what's computed

Only two status values are accepted on sidecar YAML:

  • planned — "we intend to build this but haven't started"
  • deprecated — "stop using this"

Both are intent. All other states (in-progress, verified, shipped) are computed from signals. Sidecar YAML is the single editable surface for intent; runtime chains emit only facts.

Why this is the lowest-drift design

Any field that could be inferred but is expected to be edited by humans is a drift source. status flips based on deploys, test runs, and code presence — not on what the author was thinking when they wrote the chain. Forcing humans to remember to update status: planned → in-progress → verified → shipped is the same anti-pattern as writing your own cron instead of using a heartbeat.

Sidecar V3 mental model

Three new sidecar surfaces ship with v0.2.0:

# apps/api/blueforge.app.yml
id: lq-cards-api
type: app
extends: ../../../blueforge.product.yml     # tsconfig-style file inheritance
runtime: node22
port: 4000
dependsOn:
  - lq-cards-db
packages:                                  # declared (detected via `pnpm detect:edges`)
  - "@blueforge-studio/auth"
status: planned                            # or 'deprecated' — ONLY these two accepted
description: Quest Cards API — owns all user-facing routes.
# packages/auth/blueforge.package.yml
id: "@blueforge-studio/auth"
type: package
extends: ../../blueforge.product.yml
version: 0.5.0
exports: [core, session]
consumedBy:                                # declared consumer app ids
  - forge-dev
  - lq-cards
# apps/api/blueforge.tests.yml
id: lq-cards-api-tests
type: tests
extends: ../../../blueforge.product.yml
suite:
  - file: tests/build-deck.spec.ts
    underTest: user-flow.build-deck
    verifies:
      - user-flow.build-deck
      - data-flow.deck.persist
    framework: playwright

Inheritance semantics (mirrors tsconfig)

  • extends is a path or array of paths (searched left-to-right)
  • Last-wins on scalar conflicts
  • Deep-merge on object fields
  • Cyclic-detect fails the build (arch-sdk validate --strict-extends)
  • Federation rule: deepest-path wins. The sidecar at the deepest path is the source of truth; the root only fills gaps.

The merge function lives in @blueforge-studio/blueforge-sidecar-schemas@0.5.0 (mergeExtends(target, parents)); the file I/O lives in the architecture-sdk CLI.

Test module + verification graph

The @blueforge-studio/architecture-sdk/test subpath emits verifies and underTest edges from test files:

// tests/build-deck.spec.ts
import { underTest, verifies } from "@blueforge-studio/architecture-sdk/test";

describe("build-deck", () => {
  underTest({ id: "user-flow.build-deck" });

  it("renders the wizard", async () => {
    verifies({ id: "user-flow.build-deck", type: "user-flow" });
    // ...
  });
});

Wire your test runner's setup file (full examples at architecture-sdk/examples/):

  • examples/vitest.setup.example.ts — Vitest setup wiring setCurrentTest / setCurrentTestFile / clearTestGraph.
  • examples/playwright.global-setup.example.ts — Playwright global setup; auto-installs when Playwright's test global is available.

After the suite runs, getTestGraph() returns the collected edges. A custom reporter POSTs to /api/architecture/edges/test-graph on forge-control. The hub reconciles against the sidecar's declared verifies[] and surfaces drift (tests/ files declare verifies that don't exist at runtime or runtime tests verify artifacts not declared in sidecar).

Federation-wide node kinds

The full v0.2.0 + v0.3.0 surface:

NODE KINDS (24 total)
├── v0.1.0 scan-based extractors
│   ├── file, class, function, page, component, route, table, job
│
├── v0.2.0 semantic kinds (architecture-sdk fluent API)
│   ├── process            — deployable process within an app
│   ├── route-group        — Hono router factory output
│   ├── column            — table column
│   ├── integration        — external service (Stripe / forge-auth / etc.)
│   ├── secret            — env-var name
│   ├── worker             — in-process background loop
│   ├── migrations         — logical grouping of SQL files
│   ├── feature            — cross-ref to blueforge.features.yaml#features[].id
│   ├── flow               — user-flow (cross-ref to user-flows/<id>.flow.json)
│   ├── domain-rule        — invariant / policy
│   └── middleware         — request-handling middleware
│
└── v0.2.0 P1 federation-wide (architecture-sdk v0.2.0)
    ├── app                — deployable registered with forge-control
    ├── package            — @blueforge-studio/* package on packr
    ├── product            — blueforge catalog product (joins deployed_apps)
    ├── test               — test case (e2e Playwright or unit Vitest)
    ├── data-flow          — peer to flow (state-mutation sequence)
    └── user-flow          — alias for flow (clarity when paired with data-flow)
EDGE KINDS (15 total)
├── v0.1.0 scan-based
│   └── imports, extends, implements, calls, owns, references, renders
│
├── v0.2.0 semantic
│   ├── partOf             — child → parent
│   ├── contains           — parent → child
│   ├── linksTo            — integration → integration
│   └── inheritsFrom      — DEPRECATED → see basedOn
│
└── v0.2.0 P1 federation-wide
    ├── verifies           — test → artifact
    ├── underTest          — test scope → artifact
    ├── uses               — app → package (declared + detected)
    └── basedOn            — semantic rename of inheritsFrom (additive-only)

The inheritance-from edge kind remains in the arch-graph enum for backward compat (old graphs still validate). New graphs emit basedOn. The arch-sdk migrate-v0.2-to-v0.3 helper rewrites existing graphs idempotently.

Hub endpoints (P5 — to be implemented)

forge-control exposes:

Endpoint Purpose Auth
POST /api/architecture-graphs/ingest (existing) ingest runtime graph audit token (AUDIT_UPLOAD_KEY)
GET /api/architecture-graphs/apps/:appId/latest (existing) latest graph for an app tenant auth
GET /api/architecture/edges/imports detected edges (all apps) org token
GET /api/architecture/edges/links JOIN declared + detected org token
GET /api/architecture/edges/declared sidecar-declared edges org token
GET /api/architecture/edges/detected import-scan-detected edges org token
POST /api/architecture/edges/refresh trigger pnpm detect:edges webhook deploy token
GET /api/architecture/coverage/:appId coverage per user-flow / data-flow org token
GET /api/architecture/lifecycle/:appId lifecycle state per artifact org token
GET /api/architecture/join JOIN query across products/apps/packages/tests/flows org token

Auth gates on forge-auth Phase 9 orgs (FORGE_AUTH_ORGANIZATIONS).

Concrete example — lq-cards

The pilot consumer for everything in this doc:

lq-cards/
├── blueforge.product.yml                 # catalog product (lives at repo root)
├── apps/
│   ├── web/
│   │   ├── blueforge.app.yml             # per-app sidecar (Sidecar V3)
│   │   └── src/main.ts
│   │       └── registerArch(...)         # runtime chain
│   ├── api/
│   │   ├── blueforge.app.yml
│   │   ├── blueforge.tests.yml           # test surface declaration
│   │   └── src/main.ts
│   │       └── registerArch(...)         # runtime chain
│   └── ...
├── packages/                            # @blueforge-studio/* (consumed)
│   ├── auth/blueforge.package.yml
│   ├── user-flows/blueforge.package.yml
│   └── ...
├── tests/
│   ├── build-deck.spec.ts                # underTest + verifies
│   └── billing.spec.ts                   # underTest + verifies
├── docs/user-flows/
│   ├── build-deck.flow.json               # JSON Schema 2020-12
│   └── billing.flow.json
└── .forge/
    ├── arch-graph.json                    # codegen output
    ├── edges.detected.json                # `pnpm detect:edges` output
    └── architecture.drift.yml             # three-way comparison output

End-to-end flow:

  1. Developer adds a new route group. registerArch() chain emits the new route-group node + contains edge.
  2. CI runs arch-sdk codegen --source server/src/main.ts → produces arch-graph.json.
  3. CI POSTs arch-graph.json to forge-control. Hub validates wire format + upserts.
  4. CI runs pnpm detect:edges → produces edges.detected.json. Compares against packages: in blueforge.app.yml. Surfaces drift (declared missing detected, or vice versa).
  5. CI runs arch-sdk check --drift → compares YAML intent, runtime fact, inferred state. Exits non-zero on ⚠️ rows.
  6. Test suite runs. verifies(...) calls inside test bodies emit edges. Custom reporter POSTs to /api/architecture/edges/test-graph.
  7. Hub reconciles test edges against blueforge.tests.yml declarations. Surfaces drift (tests/ files declare verifies that don't exist at runtime).
  8. Lifecycle state computed: build-deck.spec.ts declares user-flow.build-deck; if the latest run passed → verified. If verified + deploy log shows recent deploy → shipped.
  9. taskmaster pulls GET /api/architecture/coverage/lq-cards-api, renders the lq-cards features with lifecycle badges, drills into the architecture graph on click.

Rollout

The federation-wide artifact graph ships across multiple repos in phases:

Phase Repo Status
P0 blueforge (this doc + spec) ✅ landed 2026-09-20
P1 blueforge-org (architecture-sdk) ✅ merged 2026-09-20
P1.5 blueforge-org (sidecar V3 schemas + migrate helper) ✅ branch up, awaiting operator force-merge
P2 blueforge-org (sidecar V3 schemas) ✅ branch up
P3 forge-control (arch-graph v0.3.0) ⏸ #1389 v0.2.0 widening awaiting CI
P5 forge-control (hub endpoints) ⏸ spec only, awaiting #3
P7 taskmaster (graph view) ⏸ spec only
P8 lq-cards (first consumer) ⏸ awaiting P1-P7

Reference

  • Spec: docs/plans/2026-09-20-architecture-sdk-v1.md
  • Architecture-sdk: @blueforge-studio/architecture-sdk@0.2.0+
  • Sidecar schemas: @blueforge-studio/blueforge-sidecar-schemas@0.5.0+
  • User-flows: @blueforge-studio/user-flows@0.1.0+
  • Wire format: @blueforge-studio/arch-graph@0.2.0+

Resta aggiornato

Note di rilascio e accesso anticipato

Una sola email quando esce qualcosa: nuove funzionalità della piattaforma, nuove app e inviti ai lanci. Iscriviti alla lista d'attesa per ottenere l'accesso anticipato alla registrazione self-service e ai siti promozionali.

Nessuno spam. Puoi annullare l'iscrizione con un clic.