Policy Runs & Orchestration

Audience: Policy Engine operators, Scheduler team, DevOps, and tooling engineers planning CI integrations.
Scope: Run modes (full, incremental, simulate), orchestration pipeline, cursor management, replay/determinism guarantees, monitoring, and recovery procedures.

Policies only deliver value when they execute deterministically against current SBOM, advisory, and VEX inputs. This guide explains how runs are triggered, how the orchestrator scopes work, and what artefacts to expect at each stage. For the authoring-to-archival flow that precedes a run, see the Policy Lifecycle & Approvals guide.


1 · Run Modes at a Glance

ModeTrigger sourcesScopePersistencePrimary use
FullManual CLI (stella policy run), Console “Run now”, scheduled nightly jobEntire tenant (all registered SBOMs)Writes effective_finding_{policyId} and policy_runs recordBaseline after policy approval, quarterly attestation, post-incident rechecks
IncrementalChange streams (Concelier advisories, Excititor VEX, SBOM imports), orchestrator cronOnly affected (sbom, advisory) tuplesWrites diffs to effective findings and run recordContinuous upkeep meeting ≤ 5 min SLA from input change
SimulateConsole review workspace, CLI (stella policy simulate), CI pipelineSelected SBOM sample set (provided or golden set)No materialisation; captures diff summary + explain tracesAuthoring validation, regression safeguards, sealed-mode rehearsals

All modes record their status in policy_runs with deterministic metadata:

{
  "_id": "run:P-7:2025-10-26T14:05:11Z:3f9a",
  "policy_id": "P-7",
  "policy_version": 4,
  "mode": "incremental",
  "status": "succeeded",     // queued | running | succeeded | failed | canceled | replay_pending
  "inputs": {
    "sbom_set": ["sbom:S-42","sbom:S-318"],
    "advisory_cursor": "2025-10-26T13:59:00Z",
    "vex_cursor": "2025-10-26T13:58:30Z",
    "env": {"exposure":"internet"}
  },
  "stats": {
    "components": 1742,
    "rules_fired": 68023,
    "findings_written": 4321,
    "vex_overrides": 210
  },
  "determinism_hash": "sha256:…",
  "started_at": "2025-10-26T14:05:11Z",
  "finished_at": "2025-10-26T14:06:01Z",
  "tenant": "default"
}

Schemas & samples: see src/Scheduler/__Libraries/StellaOps.Scheduler.Models/docs/SCHED-MODELS-20-001-POLICY-RUNS.md and the fixtures in docs/samples/api/scheduler/policy-*.json (including policy-simulation-status.json) for canonical payloads consumed by CLI/UI/worker integrations. Cloned simulations append metadata.retry-of=<sourceRunId> so operators can trace retries without losing provenance.


2 · Pipeline Overview

sequenceDiagram
    autonumber
    participant Trigger as Trigger (CLI / Console / Change Stream)
    participant Orchestrator as Policy Orchestrator
    participant Queue as Scheduler Queue (PostgreSQL/NATS)
    participant Engine as Policy Engine Workers
    participant Concelier as Concelier Service
    participant Excititor as Excititor Service
    participant SBOM as SBOM Service
    participant Store as PostgreSQL (policy_runs & effective_finding_*)
    participant Observability as Metrics/Events

    Trigger->>Orchestrator: Run request (mode, scope, env)
    Orchestrator->>Queue: Enqueue PolicyRunRequest (idempotent key)
    Queue->>Engine: Lease job (fairness window)
    Engine->>Concelier: Fetch advisories + linksets (cursor-aware)
    Engine->>Excititor: Fetch VEX statements (cursor-aware)
    Engine->>SBOM: Fetch SBOM segments / BOM-Index
    Engine->>Engine: Evaluate policy (deterministic batches)
    Engine->>Store: Upsert effective findings + append history
    Engine->>Store: Persist policy_runs record + determinism hash
    Engine->>Observability: Emit metrics, traces, rule-hit logs
    Engine->>Orchestrator: Ack completion / failure
    Orchestrator->>Trigger: Notify (webhook, CLI, Console update)

3 · Input Scoping & Cursors

3.1 Advisory & VEX Cursors

3.2 SBOM Selection

3.3 Environment Metadata


4 · Execution Semantics

  1. Preparation: Worker loads compiled IR for target policy version (cached by digest).
  2. Batching: Candidate tuples are grouped by SBOM, then by advisory to maintain deterministic order; page size defaults to 1024 tuples.
  3. Evaluation: Rules execute with first-match semantics; results captured as PolicyVerdict.
  4. Materialisation:
    • Upserts into effective_finding_{policyId} using {policyId, sbomId, findingKey}.
    • Previous versions stored in effective_finding_{policyId}_history.
  5. Explain storage: Full explain trees stored in blob store when captureExplain=true; incremental runs keep sampled traces (configurable).
  6. Completion: Worker writes final status, stats, determinism hash (combination of policy digest + ordered input digests), and emits policy.run.completed event.

5 · Retry, Replay & Determinism


6 · Trigger Sources & Scheduling

SourceDescriptionSLAs
Nightly full runDefault schedule per tenant; ensures baseline alignment.Finish before 07:00 UTC
Change streamConcelier (advisory_raw), Excititor (vex_raw), SBOM imports emit policy.trigger.delta events.Start within 60 s; complete within 5 min
Manual CLI/ConsoleOperators run ad-hoc evaluations.No SLA; warns if warm path > target
CIstella policy simulate runs in pipelines referencing golden SBOMs.Must complete under 10 min to avoid pipeline timeout

The orchestrator enforces max concurrency per tenant (maxActiveRuns), queue depth alarms, and fairness (round-robin per policy).


7 · Monitoring & Alerts


8 · Failure Handling & Rollback


9 · Offline / Sealed Mode


10 · Compliance Checklist


Last updated: 2025-10-26 (Sprint 20).