Last updated: 2025-09-30
A lightweight Node.js command-line interface reads the declarative stage graph, executes the pipeline end-to-end, and provides structured feedback to contributors. This document now serves as the reference for the shipped implementation.
- Provide a single entry point (e.g.
npm run pipeline -- run full-refresh-parallel) that replaces the existing ad-hoc shell scripts. - Interpret
pipeline/stage-graph.jsonat runtime to determine stage ordering, inputs/outputs, and side-effects. - Emit structured logs and progress indicators so maintainers can trace stage execution locally and in CI.
- Persist run metadata (planned, skipped, succeeded, failed) to
.pipeline-runs/so partial runs stay auditable. - Offer composable filters (
--only,--skip, future--from/--to) that unlock partial runs without duplicating scripts. - Surface consistent pre/post hooks (e.g. schema validation, cleanup) and failure handling across all stages.
- Run the supported pipeline through the Node.js toolchain, with
parallel-processinghandling clone/enrich/analyze work andaggregate-cataloguehandling publication outputs.
- Maintainers: use the CLI locally to validate changes and regenerate artifacts.
- CI/CD: run the CLI in GitHub Actions to enforce pipeline health.
- Contributors: receive consistent feedback when running partial checks.
- Stage metadata lives in
pipeline/stage-graph.json. - Schemas for stage artifacts are bundled in
dist/schemas/*.schema.jsonand are enforced after each stage. - The CLI lives under
scripts/orchestrator/(primary entrypointindex.ts, helper modulescli-helpers.tsandcli-commands.ts) with shared utilities documented indocs/architecture.md.
-
Command Surface — Implemented with
commander, exposing thepipelineroot command and subcommands:pipeline list— enumerate available pipelines/stages from the graph.pipeline describe <stage|pipeline>— print detailed metadata for inspection.pipeline run <pipelineId>— execute stages sequentially (default:full-refresh-parallel).pipeline logs [runId|--latest]— inspect structured run metadata saved to.pipeline-runs/.pipeline doctor— check external prerequisites (Node.js version, Git availability, required env vars).pipeline benchmark— summarize persisted run durations for performance baselining.pipeline progress— summarize run outcomes, stage reliability trends, baseline median deltas, and telemetry coverage consistency.pipeline dashboard— render a compact release-check dashboard combining duration, reliability, and resource trends.
-
Execution Engine — Core runtime that:
- Loads the stage graph via
loadStageGraphand resolves an execution plan withbuildExecutionPlan. - Applies stage filters derived from
--only/--skipand validates referenced stage IDs. - Runs stages strictly sequentially (no parallel execution), prepares the environment, logs start/end, and invokes the configured command.
- Captures exit codes, stdout/stderr, and wraps failures with actionable messages before persisting result metadata.
- Loads the stage graph via
-
Stage Runner Abstraction — Normalizes execution for the Node runtime:
- All supported stages run via
node <script>. The current stage graph executescollect-metadata,parallel-processing, andaggregate-catalogue, with publication output generation separated from worker analysis.
- All supported stages run via
-
State & Artifacts — Maintains an execution ledger (
.pipeline-runs/<timestamp>_<pipeline>.json) with start/end timestamps, per-stage status (succeeded,skipped,failed,pending), durations, filters, and failure metadata, enabling future resume functionality and local auditing even when stages are filtered out.- Run records also capture resource usage snapshots (CPU usage and RSS/heap memory peak+average) for each orchestrator execution.
-
Hooks & Validation — After each stage, hooks:
- Validate declared artifacts against schemas using
validateStageFile(Ajv-based). - Leave room for future cleanup/cache hooks (e.g. restoring
modules_temp) without additional artifact drift checks beyond schema validation.
- Validate declared artifacts against schemas using
pipeline run --only <stageIds>— run only the specified stages (comma-separated) after dependency resolution.pipeline run --skip <stageIds>— omit the given stage IDs while keeping the rest of the plan.pipeline list --pipelines— limit listings to pipeline summaries.pipeline list --stages— limit listings to stage summaries.pipeline logs --latest— inspect the most recent persisted run record.pipeline benchmark --pipeline <id> --limit <n>— summarize recent matching run records.pipeline benchmark --include-filtered --include-failed --json— include non-canonical runs and print machine-readable output.pipeline progress --pipeline <id> --limit <n>— summarize recent run outcomes, stage-level success rates, and latest-vs-baseline duration/resource deltas.pipeline progress --include-filtered --json— include filtered runs and print machine-readable output.pipeline dashboard --pipeline <id> --limit <n>— show a compact dashboard for run health, duration hotspots, and resource trend signals.pipeline dashboard --include-filtered --json— include filtered runs and print machine-readable dashboard output.
Commander validates the mutually exclusive options (--only/--skip) so that unknown stage IDs or conflicting filters surface errors before execution. Skipped stages are still recorded in the run ledger so you can see exactly what was omitted.
The original exploration surfaced a few ideas that remain on the backlog:
--log-level <level>— switch between verbose and quiet output.--dry-run— show the planned execution without invoking any stages.--force— ignore any future caching optimizations and run every stage.
- Emit human-readable console output with stage numbering and duration markers, e.g.
▶︎ [1/2] collect-metadata … done in 12.4s. - Persist a structured JSON summary to
.pipeline-runs/<timestamp>_<pipeline>.jsoncapturing stage outcomes (including explicitly skipped stages), durations, applied filters, and failure metadata. - Provide
pipeline logs [runId|--latest]to inspect a stored run summary without digging into the filesystem. pipeline logsalso prints captured resource usage when present in the selected run record.
- On failure, stop further stages by default and surface:
- Exit code.
- Path to the stage log file.
- Suggested remediation (e.g. rerun with
--only stageId).
- Future enhancement: consider a
--continue-on-errorflag for exploratory batches (would run remaining stages but mark the run as degraded). - Non-zero exit codes propagate to shell/CI.
- Stage runner resolves script paths from the graph and executes them raw (no refactor needed initially).
- Shared helper for environment preparation (e.g. ensuring
modules_temprotation) remains a follow-up task and can live underscripts/lib/pipeline/when extracted.