Architecture

Architecture

Playwright CodeGraph is a deterministic local and CI data plane. It converts repository evidence into a canonical test plan, executes that plan, and produces portable quality artifacts.

Component Flow

Git diff ───────────────┐
Rush workspace graph ──┤
Source code graph ──────┼──> Deterministic planner ──> plan.json
Scenario registry ──────┤              │
Test inventory ─────────┘              ├──> Unit runner
                                       ├──> Playwright runner
                                       └──> HTML quality report

Graph Layers

LayerEvidencePurpose
Git graphmerge base, committed, staged, unstaged, and untracked changesEstablish the exact change set
Workspace graphRush projects, dependencies, and reverse dependentsExpand package-level impact
Source graphimports and file reachability from CodeGraphFind statically affected tests
Scenario graphjourneys, scenario dependencies, code paths, and testsExpress business impact
Runtime graphoptional LCOV or V8 observationsDistinguish declared coverage from observed execution
History graphshadow and replay recordsMeasure fallback and missed-failure behavior

Deterministic Boundary

The selector uses only versioned, inspectable inputs:

  • Git references and working-tree state
  • Strict configuration
  • Rush manifests and package manifests
  • CodeGraph protocol output
  • Scenario YAML and test annotations
  • Test file inventory

Identical inputs produce a byte-stable plan. Timestamps and durations belong to execution records, not selection plans.

Fail-Open Safety

The planner expands to a full run when it cannot prove selective execution is safe. Examples include:

  • Missing, stale, incompatible, or failed graph operations
  • Incomplete Git history
  • Unknown repository files
  • Global configuration triggers
  • Scenario coverage gaps
  • Selection or command-length limits
  • Invalid configuration

AI can explain or recommend work, but it is never the sole reason to skip a test.

Public Contracts

The TypeScript API and CLI share versioned contracts for:

  • Changed files
  • Workspace projects
  • Selection reasons
  • Full-run reasons
  • Selection plans
  • Scenario coverage
  • Execution, shadow, and replay artifacts

Repository-derived values are escaped before entering the standalone report, and its Content Security Policy blocks external scripts, styles, and resources.

Cross-Platform Execution

The CLI does not use a command shell to run CodeGraph, Vitest, Jest, or Playwright. It resolves local package binaries and launches their JavaScript entry points through Node.js. CI validates Node.js 20 and 22 on Windows and Ubuntu.