Unified Workspace Intelligence Runner

August 9, 2026 · View on GitHub

Use one command when you want the latest answer to these questions:

  • What projects and relationships exist now?
  • What changed, and what may be affected?
  • Is the workspace healthy and ready?
  • What should developers, CI, IDEs, and AI tools read?

Run it from a Workspai workspace root or any project with a validated workspace binding:

npx workspai workspace intelligence run --for-agent generic --strict --json

generic is the vendor-neutral context surface. Replace it with codex, claude, cursor, or orca for agent-specific context. The agent-sync stage also publishes shared grounding for GitHub Copilot, VS Code, and AGENTS.md consumers.

Workspai runs the required steps in a fixed order and saves one final report. The technical contract writes that report atomically to .workspai/reports/workspace-intelligence-run-last-run.json with schema workspace-intelligence-run.v1. JSON stdout returns the same report payload. Consumers should read the persisted report when they need durable evidence and use the process exit code for the immediate automation verdict.

Execution envelope and canonical chain

The runner separates prerequisite operations from the versioned intelligence chain. sync and baseline handling are reported in preflight; they are not additional chain stages.

Execution order

sync
  -> model
  -> baseline resolution
  -> diff
  -> impact
  -> doctor-evidence
  -> contract-evidence
  -> analyze-evidence
  -> readiness-evidence
  -> verify
  -> context
  -> agent-sync
  -> explain

The report always contains exactly two ordered preflight entries:

IDExecution pointSuccessful resultPurpose
syncBefore modelsynchronizedReconcile workspace inventory and contract inputs.
baselineAfter model, before diffcreated or reusedEnsure Diff has an explicit structural baseline.

The report always contains exactly these 11 ordered stages:

OrderStageContract role
1modelBuild and persist the current workspace model.
2diffCompare the current model with the selected baseline.
3impactCalculate affected projects and transitive consequence.
4doctor-evidenceRefresh workspace and project health evidence.
5contract-evidenceVerify the workspace contract.
6analyze-evidenceRefresh structural and operational analysis.
7readiness-evidenceRefresh pre-verify release-readiness evidence.
8verifyProduce the definitive evidence-backed gate.
9contextBuild agent context from the same current evidence.
10agent-syncProject canonical context into agent and IDE surfaces.
11explainExplain the resulting release posture and blockers.

The machine-readable authority is workspace-intelligence-chain.v1.json. Commands, websites, IDEs, CI jobs, and agent instructions must not define a different order or insert sync or snapshot-baseline into stages.

Baseline semantics

On the first run, the runner creates .workspai/reports/workspace-model-snapshot.json and reports:

{
  "id": "baseline",
  "status": "passed",
  "result": "created"
}

On later runs, it reuses the existing snapshot and reports result: "reused". baselineCreated is true only when that run created the baseline.

The runner does not silently replace an existing baseline immediately before Diff. Doing so would erase the change boundary and incorrectly report no changes. Refresh or replace a baseline only through the explicit workspace snapshot workflow after the intended structural state has been accepted.

Status and exit semantics

Report statusExit codeMeaning
passed0Every operation executed and no gate blocked the run.
failed1A required operation threw or could not complete. Downstream stages are recorded as skipped.
blocked2Execution completed, but one or more evidence or verification gates rejected readiness.

The canonical mapping is passed0, failed1, and blocked2.

A blocked evidence stage does not stop the chain. Context, grounding, and Explain must still be refreshed so humans and agents receive the current blocker evidence. A hard failed stage stops execution work and every downstream canonical stage is recorded with status: "skipped", exitCode: 0, and durationMs: 0.

Stage invariants:

  • passed requires exitCode: 0;
  • blocked requires a non-zero stage exit code;
  • failed requires exitCode: 1;
  • skipped requires exitCode: 0 and durationMs: 0;
  • report status and exit code are derived from all preflight and stage results;
  • every stage artifact list must exactly match the runtime registry.

--strict promotes warning-grade readiness states such as Analyze needs-attention and Readiness warn into blocked stage verdicts. It does not turn evidence blockers into execution failures: the aggregate exit remains 2, not 1.

Report contract

The durable report contains:

{
  "schemaVersion": "workspace-intelligence-run.v1",
  "chainSchemaVersion": "workspai-workspace-intelligence-chain-v1",
  "generatedAt": "2026-07-18T00:00:00.000Z",
  "workspacePath": "/absolute/machine-local/path",
  "baselineCreated": false,
  "preflight": [],
  "status": "blocked",
  "exitCode": 2,
  "stages": [],
  "artifactPath": ".workspai/reports/workspace-intelligence-run-last-run.json"
}

The abbreviated arrays above illustrate the envelope only; conforming reports must contain exactly two preflight entries and 11 stages. The complete JSON Schema is workspace-intelligence-run.v1.json. Structural schema validation is necessary but not sufficient. Workspai also enforces stage order, registered artifacts, baseline coherence, failure propagation, and aggregate verdict semantics before writing the report.

workspacePath and some underlying evidence can contain machine-local absolute paths. Do not treat the run report as a portable workspace identity contract or publish it without applying the relevant redaction policy.

CI consumption

The simplest hard gate is:

npx workspai workspace intelligence run --for-agent generic --strict --json

Both exit 1 and exit 2 fail a normal CI step. If artifacts must be uploaded after a blocked run, allow the runner step to continue, upload with if: always(), then fail the job from the recorded step outcome. See examples/ci-agent-grounding.yml.

Automation must distinguish:

  • exit 1: repair execution, environment, permissions, corruption, or another hard runtime failure;
  • exit 2: inspect Analyze, Readiness, Verify, and Explain evidence and resolve the reported blockers;
  • exit 0: consume the newly refreshed artifacts.

Do not parse terminal prose. Read status, exitCode, preflight, stages, and their registered artifacts from the JSON report.

When Verify publishes resolutionHints, an evidence-backed step includes its exact sourceCommand and sourceArtifact. Consumers should run that producer command instead of substituting a generic Analyze refresh, then re-run Verify.

Verified engineering goals

The intelligence runner answers what is true now. A verified goal adds the durable definition of what must become true, so a person or agent can resume work without changing the success criteria between attempts.

# Prepare the whole workspace for release.
npx workspai workspace goal plan release-readiness --json

# Remove blocking dependency vulnerabilities from one registered project.
npx workspai workspace goal plan dependency-security --scope project:api --json

# Raise one project's measured coverage to at least 75%.
npx workspai workspace goal plan test-coverage --scope project:web --target 75 --json

# Re-measure the goal against current source and evidence.
npx workspai workspace goal verify <goal-id> --json

Planning writes an immutable goal definition and its current status under .workspai/goals/<goal-id>/. Verification also refreshes the canonical latest verdict at .workspai/reports/verified-goal-last-run.json. Consumers must read the JSON verdict; they must not infer success from an agent message or a source edit alone.

The three shipped goal kinds have explicit completion rules:

Goal kindCompletion boundary
release-readinessReadiness passes and Workspace Verify reports ready.
dependency-securityA fresh audit reports zero blocking vulnerabilities and required checks pass.
test-coverageRuntime-owned coverage reaches the selected percentage and required checks pass.

Goals are workspace-scoped by default. Use --scope project:<registered-name> when the requested outcome belongs to one project. Dependency goals preserve a hash baseline for recognized manifests and lockfiles across supported ecosystems. Breaking or force-based changes remain forbidden unless the goal explicitly records --allow-breaking or --allow-force; changing a manifest alone never satisfies the goal.

--no-run only reads current goal evidence. --reuse-intelligence may reuse a just-completed canonical run, but it does not waive goal-specific measurement. The goal schemas are verified-goal.v1.json and verified-goal-status.v1.json.

Relationship to other commands

workspace intelligence run is the canonical Workspace Intelligence chain. pipeline is a broader governance/release orchestrator and autopilot release is a separate release surface. Neither command may replace, reorder, extend, or silently partially execute the canonical intelligence chain.

Individual commands such as workspace model, workspace diff, and workspace verify remain useful for inspection and targeted renewal. A partial manual sequence must not be documented or treated as an equivalent replacement for the unified runner.