feat(docs): Add comprehensive documentation for Vexer, Vulnerability Explorer, and Zastava modules
- Introduced AGENTS.md, README.md, TASKS.md, and implementation_plan.md for Vexer, detailing mission, responsibilities, key components, and operational notes. - Established similar documentation structure for Vulnerability Explorer and Zastava modules, including their respective workflows, integrations, and observability notes. - Created risk scoring profiles documentation outlining the core workflow, factor model, governance, and deliverables. - Ensured all modules adhere to the Aggregation-Only Contract and maintain determinism and provenance in outputs.
This commit is contained in:
		
							
								
								
									
										22
									
								
								docs/modules/cli/AGENTS.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								docs/modules/cli/AGENTS.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | ||||
| # CLI agent guide | ||||
|  | ||||
| ## Mission | ||||
| The `stella` CLI is the operator-facing Swiss army knife for scans, exports, policy management, offline kit operations, and automation scripting. | ||||
|  | ||||
| ## Key docs | ||||
| - [Module README](./README.md) | ||||
| - [Architecture](./architecture.md) | ||||
| - [Implementation plan](./implementation_plan.md) | ||||
| - [Task board](./TASKS.md) | ||||
|  | ||||
| ## How to get started | ||||
| 1. Open ../../implplan/SPRINTS.md and locate the stories referencing this module. | ||||
| 2. Review ./TASKS.md for local follow-ups and confirm status transitions (TODO → DOING → DONE/BLOCKED). | ||||
| 3. Read the architecture and README for domain context before editing code or docs. | ||||
| 4. Coordinate cross-module changes in the main /AGENTS.md description and through the sprint plan. | ||||
|  | ||||
| ## Guardrails | ||||
| - Honour the Aggregation-Only Contract where applicable (see ../../ingestion/aggregation-only-contract.md). | ||||
| - Preserve determinism: sort outputs, normalise timestamps (UTC ISO-8601), and avoid machine-specific artefacts. | ||||
| - Keep Offline Kit parity in mind—document air-gapped workflows for any new feature. | ||||
| - Update runbooks/observability assets when operational characteristics change. | ||||
							
								
								
									
										40
									
								
								docs/modules/cli/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								docs/modules/cli/README.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| # StellaOps CLI | ||||
|  | ||||
| The `stella` CLI is the operator-facing Swiss army knife for scans, exports, policy management, offline kit operations, and automation scripting. | ||||
|  | ||||
| ## Responsibilities | ||||
| - Deliver deterministic verbs for scan, diff, export, policy, and observability operations. | ||||
| - Handle interactive and non-interactive authentication via Authority (device code, client credentials). | ||||
| - Support offline kit workflows including bundle verification and seed installation. | ||||
| - Expose JSON outputs suitable for CI parity and golden tests. | ||||
|  | ||||
| ## Key components | ||||
| - `StellaOps.Cli` native AOT host. | ||||
| - Shared helpers in `StellaOps.Cli.Core`. | ||||
| - Restart-time plug-ins under `StellaOps.Cli.Plugins.*`. | ||||
|  | ||||
| ## Integrations & dependencies | ||||
| - Authority for token exchange. | ||||
| - Backend APIs (Scanner, Policy, Export Center, Notify). | ||||
| - Offline kit bundles and local keychain/DPoP storage. | ||||
|  | ||||
| ## Operational notes | ||||
| - Deterministic output fixtures under `src/Cli/StellaOps.Cli.Tests`. | ||||
| - Versioned command docs in `docs/modules/cli/guides`. | ||||
| - Plugin catalogue in `plugins/cli/**` (restart-only). | ||||
|  | ||||
| ## Related resources | ||||
| - ./guides/20_REFERENCE.md | ||||
| - ./guides/cli-reference.md | ||||
| - ./guides/policy.md | ||||
|  | ||||
| ## Backlog references | ||||
| - DOCS-CLI-OBS-52-001 / DOCS-CLI-FORENSICS-53-001 in ../../TASKS.md. | ||||
| - CLI-CORE-41-001 epic in `src/Cli/StellaOps.Cli/TASKS.md`. | ||||
|  | ||||
| ## Epic alignment | ||||
| - **Epic 2 – Policy Engine & Editor:** deliver deterministic policy authoring, simulation, and explain verbs. | ||||
| - **Epic 4 – Policy Studio:** integrate registry/promotion workflows, approvals, and lint tooling. | ||||
| - **Epic 6 – Vulnerability Explorer:** surface triage and ledger operations. | ||||
| - **Epic 10 – Export Center:** orchestrate export requests, verification, and Offline Kit automation. | ||||
| - **Epic 11 – Notifications Studio:** manage notification authoring/previews from the command line. | ||||
							
								
								
									
										9
									
								
								docs/modules/cli/TASKS.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								docs/modules/cli/TASKS.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| # Task board — CLI | ||||
|  | ||||
| > Local tasks should link back to ./AGENTS.md and mirror status updates into ../../TASKS.md when applicable. | ||||
|  | ||||
| | ID | Status | Owner(s) | Description | Notes | | ||||
| |----|--------|----------|-------------|-------| | ||||
| | CLI-DOCS-0001 | TODO | Docs Guild | Validate that ./README.md aligns with the latest release notes. | See ./AGENTS.md | | ||||
| | CLI-OPS-0001 | TODO | Ops Guild | Review runbooks/observability assets after next sprint demo. | Sync outcomes back to ../../TASKS.md | | ||||
| | CLI-ENG-0001 | TODO | Module Team | Cross-check implementation plan milestones against ../../implplan/SPRINTS.md. | Update status via ./AGENTS.md workflow | | ||||
							
								
								
									
										408
									
								
								docs/modules/cli/architecture.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										408
									
								
								docs/modules/cli/architecture.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,408 @@ | ||||
| # component_architecture_cli.md — **Stella Ops CLI** (2025Q4) | ||||
|  | ||||
| > Consolidates requirements captured in the Policy Engine, Policy Studio, Vulnerability Explorer, Export Center, and Notifications implementation plans and module guides. | ||||
|  | ||||
| > **Scope.** Implementation‑ready architecture for **Stella Ops CLI**: command surface, process model, auth (Authority/DPoP), integration with Scanner/Excititor/Concelier/Signer/Attestor, Buildx plug‑in management, offline kit behavior, packaging, observability, security posture, and CI ergonomics. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 0) Mission & boundaries | ||||
|  | ||||
| **Mission.** Provide a **fast, deterministic, CI‑friendly** command‑line interface to drive Stella Ops workflows: | ||||
|  | ||||
| * Build‑time SBOM generation via **Buildx generator** orchestration. | ||||
| * Post‑build **scan/compose/diff/export** against **Scanner.WebService**. | ||||
| * **Policy** operations and **VEX/Vuln** data pulls (operator tasks). | ||||
| * **Verification** (attestation, referrers, signatures) for audits. | ||||
| * Air‑gapped/offline **kit** administration. | ||||
|  | ||||
| **Boundaries.** | ||||
|  | ||||
| * CLI **never** signs; it only calls **Signer**/**Attestor** via backend APIs when needed (e.g., `report --attest`). | ||||
| * CLI **does not** store long‑lived credentials beyond OS keychain; tokens are **short** (Authority OpToks). | ||||
| * Heavy work (scanning, merging, policy) is executed **server‑side** (Scanner/Excititor/Concelier). | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 1) Solution layout & runtime form | ||||
|  | ||||
| ``` | ||||
| src/ | ||||
|  ├─ StellaOps.Cli/                         # net10.0 (Native AOT) single binary | ||||
|  ├─ StellaOps.Cli.Core/                    # verb plumbing, config, HTTP, auth | ||||
|  ├─ StellaOps.Cli.Plugins/                 # optional verbs packaged as plugins | ||||
|  ├─ StellaOps.Cli.Tests/                   # unit + golden-output tests | ||||
|  └─ packaging/ | ||||
|      ├─ msix / msi / deb / rpm / brew formula | ||||
|      └─ scoop manifest / winget manifest | ||||
| ``` | ||||
|  | ||||
| **Language/runtime**: .NET 10 **Native AOT** for speed/startup; Linux builds use **musl** static when possible. | ||||
|  | ||||
| **Plug-in verbs.** Non-core verbs (Excititor, runtime helpers, future integrations) ship as restart-time plug-ins under `plugins/cli/**` with manifest descriptors. The launcher loads plug-ins on startup; hot reloading is intentionally unsupported. The inaugural bundle, `StellaOps.Cli.Plugins.NonCore`, packages the Excititor, runtime, and offline-kit command groups and publishes its manifest at `plugins/cli/StellaOps.Cli.Plugins.NonCore/`. | ||||
|  | ||||
| **OS targets**: linux‑x64/arm64, windows‑x64/arm64, macOS‑x64/arm64. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 2) Command surface (verbs) | ||||
|  | ||||
| > All verbs default to **JSON** output when `--json` is set (CI mode). Human output is concise, deterministic. | ||||
|  | ||||
| ### 2.1 Auth & profile | ||||
|  | ||||
| * `auth login` | ||||
|  | ||||
|   * Modes: **device‑code** (default), **client‑credentials** (service principal). | ||||
|   * Produces **Authority** access token (OpTok) + stores **DPoP** keypair in OS keychain. | ||||
| * `auth status` — show current issuer, subject, audiences, expiry. | ||||
| * `auth logout` — wipe cached tokens/keys. | ||||
|  | ||||
| ### 2.2 Build‑time SBOM (Buildx) | ||||
|  | ||||
| * `buildx install` — install/update the **StellaOps.Scanner.Sbomer.BuildXPlugin** on the host. | ||||
| * `buildx verify` — ensure generator is usable. | ||||
| * `buildx build` — thin wrapper around `docker buildx build --attest=type=sbom,generator=stellaops/sbom-indexer` with convenience flags: | ||||
|  | ||||
|   * `--attest` (request Signer/Attestor via backend post‑push) | ||||
|   * `--provenance` pass‑through (optional) | ||||
|  | ||||
| ### 2.3 Scanning & artifacts | ||||
|  | ||||
| * `scan image <ref|digest>` | ||||
|  | ||||
|   * Options: `--force`, `--wait`, `--view=inventory|usage|both`, `--format=cdx-json|cdx-pb|spdx-json`, `--attest` (ask backend to sign/log). | ||||
|   * Streams progress; exits early unless `--wait`. | ||||
| * `diff image --old <digest> --new <digest> [--view ...]` — show layer‑attributed changes. | ||||
| * `export sbom <digest> [--view ... --format ... --out file]` — download artifact. | ||||
| * `report final <digest> [--policy-revision ... --attest]` — request PASS/FAIL report from backend (policy+vex) and optional attestation. | ||||
|  | ||||
| ### 2.4 Policy & data | ||||
|  | ||||
| * `policy get/set/apply` — fetch active policy, apply staged policy, compute digest. | ||||
| * `concelier export` — trigger/export canonical JSON or Trivy DB (admin). | ||||
| * `excititor export` — trigger/export consensus/raw claims (admin). | ||||
|  | ||||
| ### 2.5 Verification | ||||
|  | ||||
| * `verify attestation --uuid <rekor-uuid> | --artifact <sha256> | --bundle <path>` — call **Attestor /verify** and print proof summary. | ||||
| * `verify referrers <digest>` — ask **Signer /verify/referrers** (is image Stella‑signed?). | ||||
| * `verify image-signature <ref|digest>` — standalone cosign verification (optional, local). | ||||
|  | ||||
| ### 2.6 Runtime (Zastava helper) | ||||
|  | ||||
| * `runtime policy test --image/-i <digest> [--file <path> --ns <name> --label key=value --json]` — ask backend `/policy/runtime` like the webhook would (accepts multiple `--image`, comma/space lists, or stdin pipelines). | ||||
|  | ||||
| ### 2.7 Offline kit | ||||
|  | ||||
| * `offline kit pull` — fetch latest **Concelier JSON + Trivy DB + Excititor exports** as a tarball from a mirror. | ||||
| * `offline kit import <tar>` — upload the kit to on‑prem services (Concelier/Excititor). | ||||
| * `offline kit status` — list current seed versions. | ||||
|  | ||||
| ### 2.8 Utilities | ||||
|  | ||||
| * `config set/get` — endpoint & defaults. | ||||
| * `whoami` — short auth display. | ||||
| * `version` — CLI + protocol versions; release channel. | ||||
|  | ||||
| ### 2.9 Aggregation-only guard helpers | ||||
|  | ||||
| * `sources ingest --dry-run --source <id> --input <path|uri> [--tenant ... --format table|json --output file]` | ||||
|  | ||||
|   * Normalises documents (handles gzip/base64), posts them to the backend `aoc/ingest/dry-run` route, and exits non-zero when guard violations are detected. | ||||
|   * Defaults to table output with ANSI colour; `--json`/`--output` produce deterministic JSON for CI pipelines. | ||||
|  | ||||
| * `aoc verify [--since <ISO8601|duration>] [--limit <count>] [--sources list] [--codes list] [--format table|json] [--export file] [--tenant id] [--no-color]` | ||||
|  | ||||
|   * Replays guard checks against stored raw documents. Maps backend `ERR_AOC_00x` codes onto deterministic exit codes so CI can block regressions. | ||||
|   * Supports pagination hints (`--limit`, `--since`), tenant scoping via `--tenant` or `STELLA_TENANT`, and JSON exports for evidence lockers. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 3) AuthN: Authority + DPoP | ||||
|  | ||||
| ### 3.1 Token acquisition | ||||
|  | ||||
| * **Device‑code**: the CLI opens an OIDC device code flow against **Authority**; the browser login is optional for service principals. | ||||
| * **Client‑credentials**: service principals use **private_key_jwt** or **mTLS** to get tokens. | ||||
|  | ||||
| ### 3.2 DPoP key management | ||||
|  | ||||
| * On first login, the CLI generates an **ephemeral JWK** (Ed25519) and stores it in the **OS keychain** (Keychain/DPAPI/KWallet/Gnome Keyring). | ||||
| * Every request to backend services includes a **DPoP proof**; CLI refreshes tokens as needed. | ||||
|  | ||||
| ### 3.3 Multi‑audience & scopes | ||||
|  | ||||
| * CLI requests **audiences** as needed per verb: | ||||
|  | ||||
|   * `scanner` for scan/export/report/diff | ||||
|   * `signer` (indirect; usually backend calls Signer) | ||||
|   * `attestor` for verify | ||||
|   * `concelier`/`excititor` for admin verbs | ||||
|  | ||||
| CLI rejects verbs if required scopes are missing. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 4) Process model & reliability | ||||
|  | ||||
| ### 4.1 HTTP client | ||||
|  | ||||
| * Single **http2** client with connection pooling, DNS pinning, retry/backoff (idempotent GET/POST marked safe). | ||||
| * **DPoP nonce** handling: on `401` with nonce challenge, CLI replays once. | ||||
|  | ||||
| ### 4.2 Streaming | ||||
|  | ||||
| * `scan` and `report` support **server‑sent JSON lines** (progress events). | ||||
| * `--json` prints machine events; human mode shows compact spinners and crucial updates only. | ||||
|  | ||||
| ### 4.3 Exit codes (CI‑safe) | ||||
|  | ||||
| | Code | Meaning                                     | | ||||
| | ---- | ------------------------------------------- | | ||||
| | 0    | Success                                     | | ||||
| | 2    | Policy fail (final report verdict=fail)     | | ||||
| | 3    | Verification failed (attestation/signature) | | ||||
| | 4    | Auth error (invalid/missing token/DPoP)     | | ||||
| | 5    | Resource not found (image/SBOM)             | | ||||
| | 6    | Rate limited / quota exceeded               | | ||||
| | 7    | Backend unavailable (retryable)             | | ||||
| | 9    | Invalid arguments                           | | ||||
| | 11–17 | Aggregation-only guard violation (`ERR_AOC_00x`) | | ||||
| | 18   | Verification truncated (increase `--limit`) | | ||||
| | 70   | Transport/authentication failure            | | ||||
| | 71   | CLI usage error (missing tenant, invalid cursor) | | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 5) Configuration model | ||||
|  | ||||
| **Precedence:** CLI flags → env vars → config file → defaults. | ||||
|  | ||||
| **Config file**: `${XDG_CONFIG_HOME}/stellaops/config.yaml` (Windows: `%APPDATA%\StellaOps\config.yaml`) | ||||
|  | ||||
| ```yaml | ||||
| cli: | ||||
|   authority: "https://authority.internal" | ||||
|   backend: | ||||
|     scanner: "https://scanner-web.internal" | ||||
|     attestor: "https://attestor.internal" | ||||
|     concelier: "https://concelier-web.internal" | ||||
|     excititor: "https://excititor-web.internal" | ||||
|   auth: | ||||
|     audienceDefault: "scanner" | ||||
|     deviceCode: true | ||||
|   output: | ||||
|     json: false | ||||
|     color: auto | ||||
|   tls: | ||||
|     caBundle: "/etc/ssl/certs/ca-bundle.crt" | ||||
|   offline: | ||||
|     kitMirror: "s3://mirror/stellaops-kit" | ||||
| ``` | ||||
|  | ||||
| Environment variables: `STELLAOPS_AUTHORITY`, `STELLAOPS_SCANNER_URL`, etc. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 6) Buildx generator orchestration | ||||
|  | ||||
| * `buildx install` locates the Docker root directory, writes the **generator** plugin manifest, and pulls `stellaops/sbom-indexer` image (pinned digest). | ||||
| * `buildx build` wrapper injects: | ||||
|  | ||||
|   * `--attest=type=sbom,generator=stellaops/sbom-indexer` | ||||
|   * `--label org.stellaops.request=sbom` | ||||
| * Post‑build: CLI optionally calls **Scanner.WebService** to **verify referrers**, **compose** image SBOMs, and **attest** via Signer/Attestor. | ||||
|  | ||||
| **Detection**: If Buildx or generator unavailable, CLI falls back to **post‑build scan** with a warning. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 7) Artifact handling | ||||
|  | ||||
| * **Downloads** (`export sbom`, `report final`): stream to file; compute sha256 on the fly; write sidecar `.sha256` and optional **verification bundle** (if `--bundle`). | ||||
| * **Uploads** (`offline kit import`): chunked upload; retry on transient errors; show progress bar (unless `--json`). | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 8) Security posture | ||||
|  | ||||
| * **DPoP private keys** stored in **OS keychain**; metadata cached in config. | ||||
| * **No plaintext tokens** on disk; short‑lived **OpToks** held in memory. | ||||
| * **TLS**: verify backend certificates; allow custom CA bundle for on‑prem. | ||||
| * **Redaction**: CLI logs remove `Authorization`, DPoP headers, PoE tokens. | ||||
| * **Supply chain**: CLI distribution binaries are **cosign‑signed**; `stellaops version --verify` checks its own signature. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 9) Observability | ||||
|  | ||||
| * `--verbose` adds request IDs, timings, and retry traces. | ||||
| * **Metrics** (optional, disabled by default): Prometheus text file exporter for local monitoring in long‑running agents. | ||||
| * **Structured logs** (`--json`): per‑event JSON lines with `ts`, `verb`, `status`, `latencyMs`. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 10) Performance targets | ||||
|  | ||||
| * Startup ≤ **20 ms** (AOT). | ||||
| * `scan image` request/response overhead ≤ **5 ms** (excluding server work). | ||||
| * Buildx wrapper overhead negligible (<1 ms). | ||||
| * Large artifact download (100 MB) sustained ≥ **80 MB/s** on local networks. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 11) Tests & golden outputs | ||||
|  | ||||
| * **Unit tests**: argument parsing, config precedence, URL resolution, DPoP proof creation. | ||||
| * **Integration tests** (Testcontainers): mock Authority/Scanner/Attestor; CI pipeline with fake registry. | ||||
| * **Golden outputs**: verb snapshots for `--json` across OSes; kept in `tests/golden/…`. | ||||
| * **Contract tests**: ensure API shapes match service OpenAPI; fail build if incompatible. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 12) Error envelopes (human + JSON) | ||||
|  | ||||
| **Human:** | ||||
|  | ||||
| ``` | ||||
| ✖ Policy FAIL: 3 high, 1 critical (VEX suppressed 12) | ||||
|   - pkg:rpm/openssl (CVE-2025-12345) — affected (vendor) — fixed in 3.0.14 | ||||
|   - pkg:npm/lodash (GHSA-xxxx) — affected — no fix | ||||
|   See: https://ui.internal/scans/sha256:... | ||||
| Exit code: 2 | ||||
| ``` | ||||
|  | ||||
| **JSON (`--json`):** | ||||
|  | ||||
| ```json | ||||
| { "event":"report", "status":"fail", "critical":1, "high":3, "url":"https://ui..." } | ||||
| ``` | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 13) Admin & advanced flags | ||||
|  | ||||
| * `--authority`, `--scanner`, `--attestor`, `--concelier`, `--excititor` override config URLs. | ||||
| * `--no-color`, `--quiet`, `--json`. | ||||
| * `--timeout`, `--retries`, `--retry-backoff-ms`. | ||||
| * `--ca-bundle`, `--insecure` (dev only; prints warning). | ||||
| * `--trace` (dump HTTP traces to file; scrubbed). | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 14) Interop with other tools | ||||
|  | ||||
| * Emits **CycloneDX Protobuf** directly to stdout when `export sbom --format cdx-pb --out -`. | ||||
| * Pipes to `jq`/`yq` cleanly in JSON mode. | ||||
| * Can act as a **credential helper** for scripts: `stellaops auth token --aud scanner` prints a one‑shot token for curl. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 15) Packaging & distribution | ||||
|  | ||||
| * **Installers**: deb/rpm (postinst registers completions), Homebrew, Scoop, Winget, MSI/MSIX. | ||||
| * **Shell completions**: bash/zsh/fish/pwsh. | ||||
| * **Update channel**: `stellaops self-update` (optional) fetches cosign‑signed release manifest; corporate environments can disable. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 16) Security hard lines | ||||
|  | ||||
| * Refuse to print token values; redact Authorization headers in verbose output. | ||||
| * Disallow `--insecure` unless `STELLAOPS_CLI_ALLOW_INSECURE=1` set (double opt‑in). | ||||
| * Enforce **short token TTL**; refresh proactively when <30 s left. | ||||
| * Device‑code cache binding to **machine** and **user** (protect against copy to other machines). | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 17) Wire sequences | ||||
|  | ||||
| **A) Scan & wait with attestation** | ||||
|  | ||||
| ```mermaid | ||||
| sequenceDiagram | ||||
|   autonumber | ||||
|   participant CLI | ||||
|   participant Auth as Authority | ||||
|   participant SW as Scanner.WebService | ||||
|   participant SG as Signer | ||||
|   participant AT as Attestor | ||||
|  | ||||
|   CLI->>Auth: device code flow (DPoP) | ||||
|   Auth-->>CLI: OpTok (aud=scanner) | ||||
|  | ||||
|   CLI->>SW: POST /scans { imageRef, attest:true } | ||||
|   SW-->>CLI: { scanId } | ||||
|   CLI->>SW: GET /scans/{id} (poll) | ||||
|   SW-->>CLI: { status: completed, artifacts, rekor? }  # if attested | ||||
|  | ||||
|   alt attestation pending | ||||
|     SW->>SG: POST /sign/dsse (server-side) | ||||
|     SG-->>SW: DSSE | ||||
|     SW->>AT: POST /rekor/entries | ||||
|     AT-->>SW: { uuid, proof } | ||||
|   end | ||||
|  | ||||
|   CLI->>SW: GET /sboms/<digest>?format=cdx-pb&view=usage | ||||
|   SW-->>CLI: bytes | ||||
| ``` | ||||
|  | ||||
| **B) Verify attestation by artifact** | ||||
|  | ||||
| ```mermaid | ||||
| sequenceDiagram | ||||
|   autonumber | ||||
|   participant CLI | ||||
|   participant AT as Attestor | ||||
|  | ||||
|   CLI->>AT: POST /rekor/verify { artifactSha256 } | ||||
|   AT-->>CLI: { ok:true, uuid, index, logURL } | ||||
| ``` | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 18) Roadmap (CLI) | ||||
|  | ||||
| * `scan fs <path>` (local filesystem tree) → upload to backend for analysis. | ||||
| * `policy test --sbom <file>` (simulate policy results offline using local policy bundle). | ||||
| * `runtime capture` (developer mode) — capture small `/proc/<pid>/maps` for troubleshooting. | ||||
| * Pluggable output renderers for SARIF/HTML (admin‑controlled). | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 19) Example CI snippets | ||||
|  | ||||
| **GitHub Actions (post‑build)** | ||||
|  | ||||
| ```yaml | ||||
| - name: Login (device code w/ OIDC broker) | ||||
|   run: stellaops auth login --json --authority ${{ secrets.AUTHORITY_URL }} | ||||
|  | ||||
| - name: Scan | ||||
|   run: stellaops scan image ${{ steps.build.outputs.digest }} --wait --json | ||||
|  | ||||
| - name: Export (usage view, protobuf) | ||||
|   run: stellaops export sbom ${{ steps.build.outputs.digest }} --view usage --format cdx-pb --out sbom.pb | ||||
|  | ||||
| - name: Verify attestation | ||||
|   run: stellaops verify attestation --artifact $(sha256sum sbom.pb | cut -d' ' -f1) --json | ||||
| ``` | ||||
|  | ||||
| **GitLab (buildx generator)** | ||||
|  | ||||
| ```yaml | ||||
| script: | ||||
|   - stellaops buildx install | ||||
|   - docker buildx build --attest=type=sbom,generator=stellaops/sbom-indexer -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA . | ||||
|   - stellaops scan image $CI_REGISTRY_IMAGE@$IMAGE_DIGEST --wait --json | ||||
| ``` | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 20) Test matrix (OS/arch) | ||||
|  | ||||
| * Linux: ubuntu‑20.04/22.04/24.04 (x64, arm64), alpine (musl). | ||||
| * macOS: 13–15 (x64, arm64). | ||||
| * Windows: 10/11, Server 2019/2022 (x64, arm64). | ||||
| * Docker engines: Docker Desktop, containerd‑based runners. | ||||
							
								
								
									
										8
									
								
								docs/modules/cli/guides/20_REFERENCE.md
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										8
									
								
								docs/modules/cli/guides/20_REFERENCE.md
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| # CLI Reference (`stella --help`) | ||||
|  | ||||
| > **Auto‑generated file — do not edit manually.**   | ||||
| > On every tagged release the CI pipeline runs   | ||||
| > `stella --help --markdown > docs/modules/cli/guides/20_REFERENCE.md`   | ||||
| > ensuring this document always matches the shipped binary. | ||||
|  | ||||
| *(The reference will appear after the first public α release.)* | ||||
							
								
								
									
										316
									
								
								docs/modules/cli/guides/cli-reference.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										316
									
								
								docs/modules/cli/guides/cli-reference.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,316 @@ | ||||
| # CLI AOC Commands Reference | ||||
|  | ||||
| > **Audience:** DevEx engineers, operators, and CI authors integrating the `stella` CLI with Aggregation-Only Contract (AOC) workflows.   | ||||
| > **Scope:** Command synopsis, options, exit codes, and offline considerations for `stella sources ingest --dry-run` and `stella aoc verify` as introduced in Sprint 19. | ||||
|  | ||||
| Both commands are designed to enforce the AOC guardrails documented in the [aggregation-only reference](../../ingestion/aggregation-only-contract.md) and the [architecture overview](../../platform/architecture-overview.md). They consume Authority-issued tokens with tenant scopes and never mutate ingestion stores. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 1 · Prerequisites | ||||
|  | ||||
| - CLI version: `stella` ≥ 0.19.0 (AOC feature gate enabled). | ||||
| - Required scopes (DPoP-bound): | ||||
|   - `advisory:read` for Concelier sources. | ||||
|   - `vex:read` for Excititor sources (optional but required for VEX checks). | ||||
|   - `aoc:verify` to invoke guard verification endpoints. | ||||
|   - `tenant:select` if your deployment uses tenant switching. | ||||
| - Connectivity: direct access to Concelier/Excititor APIs or Offline Kit snapshot (see § 4). | ||||
| - Environment: set `STELLA_AUTHORITY_URL`, `STELLA_TENANT`, and export a valid OpTok via `stella auth login` or existing token cache. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 2 · `stella sources ingest --dry-run` | ||||
|  | ||||
| ### 2.1 Synopsis | ||||
|  | ||||
| ```bash | ||||
| stella sources ingest --dry-run \ | ||||
|   --source <source-key> \ | ||||
|   --input <path-or-uri> \ | ||||
|   [--tenant <tenant-id>] \ | ||||
|   [--format json|table] \ | ||||
|   [--no-color] \ | ||||
|   [--output <file>] | ||||
| ``` | ||||
|  | ||||
| ### 2.2 Description | ||||
|  | ||||
| Previews an ingestion write without touching MongoDB. The command loads an upstream advisory or VEX document, computes the would-write payload, runs it through the `AOCWriteGuard`, and reports any forbidden fields, provenance gaps, or idempotency issues. Use it during connector development, CI validation, or while triaging incidents. | ||||
|  | ||||
| ### 2.3 Options | ||||
|  | ||||
| | Option | Description | | ||||
| |--------|-------------| | ||||
| | `--source <source-key>` | Logical source name (`redhat`, `ubuntu`, `osv`, etc.). Mirrors connector configuration. | | ||||
| | `--input <path-or-uri>` | Path to local CSAF/OSV/VEX file or HTTPS URI. CLI normalises transport (gzip/base64) before guard evaluation. | | ||||
| | `--tenant <tenant-id>` | Overrides default tenant for multi-tenant deployments. Mandatory when `STELLA_TENANT` is not set. | | ||||
| | `--format json|table` | Output format. `table` (default) prints summary with highlighted violations; `json` emits machine-readable report (see below). | | ||||
| | `--no-color` | Disables ANSI colour output for CI logs. | | ||||
| | `--output <file>` | Writes the JSON report to file while still printing human-readable summary to stdout. | | ||||
|  | ||||
| ### 2.4 Output schema (JSON) | ||||
|  | ||||
| ```json | ||||
| { | ||||
|   "source": "redhat", | ||||
|   "tenant": "default", | ||||
|   "guardVersion": "1.0.0", | ||||
|   "status": "ok", | ||||
|   "document": { | ||||
|     "contentHash": "sha256:…", | ||||
|     "supersedes": null, | ||||
|     "provenance": { | ||||
|       "signature": { "format": "pgp", "present": true } | ||||
|     } | ||||
|   }, | ||||
|   "violations": [] | ||||
| } | ||||
| ``` | ||||
|  | ||||
| When violations exist, `status` becomes `error` and `violations` contains entries with `code` (`ERR_AOC_00x`), a short `message`, and JSON Pointer `path` values indicating offending fields. | ||||
|  | ||||
| ### 2.5 Exit codes | ||||
|  | ||||
| | Exit code | Meaning | | ||||
| |-----------|---------| | ||||
| | `0` | Guard passed; would-write payload is AOC compliant. | | ||||
| | `11` | `ERR_AOC_001` – Forbidden field (`severity`, `cvss`, etc.) detected. | | ||||
| | `12` | `ERR_AOC_002` – Merge attempt (multiple upstream sources fused). | | ||||
| | `13` | `ERR_AOC_003` – Idempotency violation (duplicate without supersedes). | | ||||
| | `14` | `ERR_AOC_004` – Missing provenance fields. | | ||||
| | `15` | `ERR_AOC_005` – Signature/checksum mismatch. | | ||||
| | `16` | `ERR_AOC_006` – Effective findings present (Policy-only data). | | ||||
| | `17` | `ERR_AOC_007` – Unknown top-level fields / schema violation. | | ||||
| | `70` | Transport error (network, auth, malformed input). | | ||||
|  | ||||
| > Exit codes map directly to the `ERR_AOC_00x` table for scripting consistency. Multiple violations yield the highest-priority code (e.g., 11 takes precedence over 14). | ||||
|  | ||||
| ### 2.6 Examples | ||||
|  | ||||
| Dry-run a local CSAF file: | ||||
|  | ||||
| ```bash | ||||
| stella sources ingest --dry-run \ | ||||
|   --source redhat \ | ||||
|   --input ./fixtures/redhat/RHSA-2025-1234.json | ||||
| ``` | ||||
|  | ||||
| Stream from HTTPS and emit JSON for CI: | ||||
|  | ||||
| ```bash | ||||
| stella sources ingest --dry-run \ | ||||
|   --source osv \ | ||||
|   --input https://osv.dev/vulnerability/GHSA-aaaa-bbbb \ | ||||
|   --format json \ | ||||
|   --output artifacts/osv-dry-run.json | ||||
|  | ||||
| cat artifacts/osv-dry-run.json | jq '.violations' | ||||
| ``` | ||||
|  | ||||
| ### 2.7 Offline notes | ||||
|  | ||||
| When operating in sealed/offline mode: | ||||
|  | ||||
| - Use `--input` paths pointing to Offline Kit snapshots (`offline-kit/advisories/*.json`). | ||||
| - Provide `--tenant` explicitly if the offline bundle contains multiple tenants. | ||||
| - The command does not attempt network access when given a file path. | ||||
| - Store reports with `--output` to include in transfer packages for policy review. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 3 · `stella aoc verify` | ||||
|  | ||||
| ### 3.1 Synopsis | ||||
|  | ||||
| ```bash | ||||
| stella aoc verify \ | ||||
|   [--since <iso8601|duration>] \ | ||||
|   [--limit <count>] \ | ||||
|   [--sources <list>] \ | ||||
|   [--codes <ERR_AOC_00x,...>] \ | ||||
|   [--format table|json] \ | ||||
|   [--export <file>] \ | ||||
|   [--tenant <tenant-id>] \ | ||||
|   [--no-color] | ||||
| ``` | ||||
|  | ||||
| ### 3.2 Description | ||||
|  | ||||
| Replays the AOC guard against stored raw documents. By default it checks all advisories and VEX statements ingested in the last 24 hours for the active tenant, reporting totals, top violation codes, and sample documents. Use it in CI pipelines, scheduled verifications, or during incident response. | ||||
|  | ||||
| ### 3.3 Options | ||||
|  | ||||
| | Option | Description | | ||||
| |--------|-------------| | ||||
| | `--since <value>` | Verification window. Accepts ISO 8601 timestamp (`2025-10-25T12:00:00Z`) or duration (`48h`, `7d`). Defaults to `24h`. | | ||||
| | `--limit <count>` | Maximum number of violations to display (per code). `0` means show all. Defaults to `20`. | | ||||
| | `--sources <list>` | Comma-separated list of sources (`redhat,ubuntu,osv`). Filters both advisories and VEX entries. | | ||||
| | `--codes <list>` | Restricts output to specific `ERR_AOC_00x` codes. Useful for regression tracking. | | ||||
| | `--format table|json` | `table` (default) prints summary plus top violations; `json` outputs machine-readable report identical to the `/aoc/verify` API. | | ||||
| | `--export <file>` | Writes the JSON report to disk (useful for audits/offline uploads). | | ||||
| | `--tenant <tenant-id>` | Overrides tenant context. Required for cross-tenant verifications when run by platform operators. | | ||||
| | `--no-color` | Disables ANSI colours. | | ||||
|  | ||||
| `table` mode prints a summary showing the active tenant, evaluated window, counts of checked advisories/VEX statements, the active limit, total writes/violations, and whether the page was truncated. Status is colour-coded as `ok`, `violations`, or `truncated`. When violations exist the detail table lists the code, total occurrences, first sample document (`source` + `documentId` + `contentHash`), and JSON pointer path. | ||||
|  | ||||
| ### 3.4 Report structure (JSON) | ||||
|  | ||||
| ```json | ||||
| { | ||||
|   "tenant": "default", | ||||
|   "window": { | ||||
|     "from": "2025-10-25T12:00:00Z", | ||||
|     "to": "2025-10-26T12:00:00Z" | ||||
|   }, | ||||
|   "checked": { | ||||
|     "advisories": 482, | ||||
|     "vex": 75 | ||||
|   }, | ||||
|   "violations": [ | ||||
|     { | ||||
|       "code": "ERR_AOC_001", | ||||
|       "count": 2, | ||||
|       "examples": [ | ||||
|         { | ||||
|           "source": "redhat", | ||||
|           "documentId": "advisory_raw:redhat:RHSA-2025:1", | ||||
|           "contentHash": "sha256:…", | ||||
|           "path": "/content/raw/cvss" | ||||
|         } | ||||
|       ] | ||||
|     } | ||||
|   ], | ||||
|   "metrics": { | ||||
|     "ingestion_write_total": 557, | ||||
|     "aoc_violation_total": 2 | ||||
|   }, | ||||
|   "truncated": false | ||||
| } | ||||
| ``` | ||||
|  | ||||
| ### 3.5 Exit codes | ||||
|  | ||||
| | Exit code | Meaning | | ||||
| |-----------|---------| | ||||
| | `0` | Verification succeeded with zero violations. | | ||||
| | `11…17` | Same mapping as § 2.5 when violations are detected. Highest-priority code returned. | | ||||
| | `18` | Verification ran but results truncated (limit reached) – treat as warning; rerun with higher `--limit`. | | ||||
| | `70` | Transport/authentication error. | | ||||
| | `71` | CLI misconfiguration (missing tenant, invalid `--since`, etc.). | | ||||
|  | ||||
| ### 3.6 Examples | ||||
|  | ||||
| Daily verification across all sources: | ||||
|  | ||||
| ```bash | ||||
| stella aoc verify --since 24h --format table | ||||
| ``` | ||||
|  | ||||
| CI pipeline focusing on errant sources and exporting evidence: | ||||
|  | ||||
| ```bash | ||||
| stella aoc verify \ | ||||
|   --sources redhat,ubuntu \ | ||||
|   --codes ERR_AOC_001,ERR_AOC_004 \ | ||||
|   --format json \ | ||||
|   --limit 100 \ | ||||
|   --export artifacts/aoc-verify.json | ||||
|  | ||||
| jq '.violations[] | {code, count}' artifacts/aoc-verify.json | ||||
| ``` | ||||
|  | ||||
| Air-gapped verification using Offline Kit snapshot (example script): | ||||
|  | ||||
| ```bash | ||||
| stella aoc verify \ | ||||
|   --since 7d \ | ||||
|   --format json \ | ||||
|   --export /mnt/offline/aoc-verify-$(date +%F).json | ||||
|  | ||||
| sha256sum /mnt/offline/aoc-verify-*.json > /mnt/offline/checksums.txt | ||||
| ``` | ||||
|  | ||||
| ### 3.7 Automation tips | ||||
|  | ||||
| - Schedule with `cron` or platform scheduler and fail the job when exit code ≥ 11. | ||||
| - Pair with `stella sources ingest --dry-run` for pre-flight validation before re-enabling a paused source. | ||||
| - Push JSON exports to observability pipelines for historical tracking of violation counts. | ||||
|  | ||||
| ### 3.8 Offline notes | ||||
|  | ||||
| - Works against Offline Kit Mongo snapshots when CLI is pointed at the local API gateway included in the bundle. | ||||
| - When fully disconnected, run against exported `aoc verify` reports generated on production and replay them using `--format json --export` (automation recipe above). | ||||
| - Include verification output in compliance packages alongside Offline Kit manifests. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 4 · Global exit-code reference | ||||
|  | ||||
| | Code | Summary | | ||||
| |------|---------| | ||||
| | `0` | Success / no violations. | | ||||
| | `11` | `ERR_AOC_001` – Forbidden field present. | | ||||
| | `12` | `ERR_AOC_002` – Merge attempt detected. | | ||||
| | `13` | `ERR_AOC_003` – Idempotency violation. | | ||||
| | `14` | `ERR_AOC_004` – Missing provenance/signature metadata. | | ||||
| | `15` | `ERR_AOC_005` – Signature/checksum mismatch. | | ||||
| | `16` | `ERR_AOC_006` – Effective findings in ingestion payload. | | ||||
| | `17` | `ERR_AOC_007` – Schema violation / unknown fields. | | ||||
| | `18` | Partial verification (limit reached). | | ||||
| | `70` | Transport or HTTP failure. | | ||||
| | `71` | CLI usage error (invalid arguments, missing tenant). | | ||||
|  | ||||
| Use these codes in CI to map outcomes to build statuses or alert severities. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 4 · `stella vuln observations` (Overlay paging) | ||||
|  | ||||
| `stella vuln observations` lists raw advisory observations for downstream overlays (Graph Explorer, Policy simulations, Console). Large tenants can now page through results deterministically. | ||||
|  | ||||
| | Option | Description | | ||||
| |--------|-------------| | ||||
| | `--limit <count>` | Caps the number of observations returned in a single call. Defaults to `200`; values above `500` are clamped server-side. | | ||||
| | `--cursor <token>` | Opaque continuation token produced by the previous page (`nextCursor` in JSON output). Pass it back to resume iteration. | | ||||
|  | ||||
| Additional notes: | ||||
|  | ||||
| - Table mode prints a hint when `hasMore` is `true`:   | ||||
|   `[yellow]More observations available. Continue with --cursor <token>[/]`. | ||||
| - JSON mode returns `nextCursor` and `hasMore` alongside the observation list so automation can loop until `hasMore` is `false`. | ||||
| - Supplying a non-positive limit falls back to the default (`200`). Invalid/expired cursors yield `400 Bad Request`; restart without `--cursor` to begin a fresh iteration. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 5 · Related references | ||||
|  | ||||
| - [Aggregation-Only Contract reference](../../ingestion/aggregation-only-contract.md) | ||||
| - [Architecture overview](../../platform/architecture-overview.md) | ||||
| - [Console AOC dashboard](../../ui/console.md) | ||||
| - [Authority scopes](../../authority/architecture.md) | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 6 · Compliance checklist | ||||
|  | ||||
| - [ ] Usage documented for both table and JSON formats. | ||||
| - [ ] Exit-code mapping matches `ERR_AOC_00x` definitions and automation guidance. | ||||
| - [ ] Offline/air-gap workflow captured for both commands. | ||||
| - [ ] References to AOC architecture and console docs included. | ||||
| - [ ] Examples validated against current CLI syntax (update post-implementation). | ||||
| - [ ] Docs guild screenshot/narrative placeholder logged for release notes (pending CLI team capture). | ||||
|  | ||||
| --- | ||||
|  | ||||
| *Last updated: 2025-10-29 (Sprint 24).* | ||||
|  | ||||
| ## 13. Authority configuration quick reference | ||||
|  | ||||
| | Setting | Purpose | How to set | | ||||
| |---------|---------|------------| | ||||
| | `StellaOps:Authority:OperatorReason` | Incident/change description recorded with `orch:operate` tokens. | CLI flag `--Authority:OperatorReason=...` or env `STELLAOPS_ORCH_REASON`. | | ||||
| | `StellaOps:Authority:OperatorTicket` | Change/incident ticket reference paired with orchestrator control actions. | CLI flag `--Authority:OperatorTicket=...` or env `STELLAOPS_ORCH_TICKET`. | | ||||
|  | ||||
| > Tokens requesting `orch:operate` will fail with `invalid_request` unless both values are present. Choose concise strings (≤256 chars for reason, ≤128 chars for ticket) and avoid sensitive data. | ||||
|  | ||||
							
								
								
									
										318
									
								
								docs/modules/cli/guides/policy.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										318
									
								
								docs/modules/cli/guides/policy.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,318 @@ | ||||
| # Stella CLI — Policy Commands | ||||
|  | ||||
| > **Audience:** Policy authors, reviewers, operators, and CI engineers using the `stella` CLI to interact with Policy Engine.   | ||||
| > **Supported from:** `stella` CLI ≥ 0.20.0 (Policy Engine v2 sprint line).   | ||||
| > **Prerequisites:** Authority-issued bearer token with the scopes noted per command (export `STELLA_TOKEN` or pass `--token`). | ||||
| > **2025-10-27 scope update:** CLI/CI tokens issued prior to Sprint 23 (AUTH-POLICY-23-001) must drop `policy:write`/`policy:submit`/`policy:edit` and instead request `policy:read`, `policy:author`, `policy:review`, and `policy:simulate` (plus `policy:approve`/`policy:operate`/`policy:activate` for promotion pipelines). | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 1 · Global Options & Output Modes | ||||
|  | ||||
| All `stella policy *` commands honour the common CLI options: | ||||
|  | ||||
| | Flag | Default | Description | | ||||
| |------|---------|-------------| | ||||
| | `--server <url>` | `https://stella.local` | Policy Engine gateway root. | | ||||
| | `--tenant <id>` | token default | Override tenant for multi-tenant installs. | | ||||
| | `--format <table\|json\|yaml>` | `table` for TTY, `json` otherwise | Output format for listings/diffs. | | ||||
| | `--output <file>` | stdout | Write full JSON payload to file. | | ||||
| | `--sealed` | false | Force sealed-mode behaviour (no outbound fetch). | | ||||
| | `--trace` | false | Emit verbose timing/log correlation info. | | ||||
|  | ||||
| > **Tip:** Set `STELLA_PROFILE=policy` in CI to load saved defaults from `~/.stella/profiles/policy.toml`. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 2 · Authoring & Drafting Commands | ||||
|  | ||||
| ### 2.1 `stella policy new` | ||||
|  | ||||
| Create a draft policy from a template or scratch. | ||||
|  | ||||
| ``` | ||||
| stella policy new --policy-id P-7 --name "Default Org Policy" \ | ||||
|   --template baseline --output-path policies/P-7.stella | ||||
| ``` | ||||
|  | ||||
| Options: | ||||
|  | ||||
| | Flag | Description | | ||||
| |------|-------------| | ||||
| | `--policy-id` *(required)* | Stable identifier (e.g., `P-7`). | | ||||
| | `--name` | Friendly display name. | | ||||
| | `--template` | `baseline`, `serverless`, `blank`. | | ||||
| | `--from` | Start from existing version (`policyId@version`). | | ||||
| | `--open` | Launches `$EDITOR` after creation. | | ||||
|  | ||||
| Writes DSL to local file and registers draft version (`status=draft`). Requires `policy:write`. | ||||
|  | ||||
| ### 2.2 `stella policy edit` | ||||
|  | ||||
| Open an existing draft in the local editor. | ||||
|  | ||||
| ``` | ||||
| stella policy edit P-7 --version 4 | ||||
| ``` | ||||
|  | ||||
| - Auto-checks out latest draft if `--version` omitted. | ||||
| - Saves to temp file, uploads on editor exit (unless `--no-upload`). | ||||
| - Use `--watch` to keep command alive and re-upload on every save. | ||||
|  | ||||
| ### 2.3 `stella policy lint` | ||||
|  | ||||
| Static validation without submitting. | ||||
|  | ||||
| ``` | ||||
| stella policy lint policies/P-7.stella --format json | ||||
| ``` | ||||
|  | ||||
| Outputs diagnostics (line/column, code, message). Exit codes: | ||||
|  | ||||
| | Code | Meaning | | ||||
| |------|---------| | ||||
| | `0` | No lint errors. | | ||||
| | `10` | Syntax/compile errors (`ERR_POL_001`). | | ||||
| | `11` | Unsupported syntax version. | | ||||
|  | ||||
| ### 2.4 `stella policy compile` | ||||
|  | ||||
| Emits IR digest and rule summary. | ||||
|  | ||||
| ``` | ||||
| stella policy compile P-7 --version 4 | ||||
| ``` | ||||
|  | ||||
| Returns JSON with `digest`, `rules.count`, action counts. Exit `0` success, `10` on compile errors. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 3 · Lifecycle Workflow | ||||
|  | ||||
| ### 3.1 Submit | ||||
|  | ||||
| ``` | ||||
| stella policy submit P-7 --version 4 \ | ||||
|   --reviewer user:kay --reviewer group:sec-reviewers \ | ||||
|   --note "Simulated against golden SBOM set" \ | ||||
|   --attach sims/P-7-v4-vs-v3.json | ||||
| ``` | ||||
|  | ||||
| Requires `policy:submit`. CLI validates that lint/compile run within 24 h and bundle attachments exist. | ||||
|  | ||||
| ### 3.2 Review | ||||
|  | ||||
| ``` | ||||
| stella policy review P-7 --version 4 --approve \ | ||||
|   --note "Looks good; ensure incident playbook updated." | ||||
| ``` | ||||
|  | ||||
| - `--approve`, `--request-changes`, or `--comment`. | ||||
| - Provide `--blocking` to mark comment as blocking. | ||||
| - Requires `policy:review`. | ||||
|  | ||||
| ### 3.3 Approve | ||||
|  | ||||
| ``` | ||||
| stella policy approve P-7 --version 4 \ | ||||
|   --note "Determinism CI green; simulation diff attached." \ | ||||
|   --attach sims/P-7-v4-vs-v3.json | ||||
| ``` | ||||
|  | ||||
| Prompts for confirmation; refuses if approver == submitter. Requires `policy:approve`. | ||||
|  | ||||
| ### 3.4 Activate | ||||
|  | ||||
| ``` | ||||
| stella policy activate P-7 --version 4 --run-now --priority high | ||||
| ``` | ||||
|  | ||||
| - Optional `--scheduled-at 2025-10-27T02:00:00Z`. | ||||
| - Requires `policy:activate` and `policy:run`. | ||||
|  | ||||
| **Options** | ||||
|  | ||||
| - `--version <number>` (required) – target revision to promote. | ||||
| - `--note <text>` – record an activation note alongside the approval. | ||||
| - `--run-now` – enqueue an immediate full run after activation. | ||||
| - `--scheduled-at <timestamp>` – schedule activation for a specific UTC time (ISO-8601 format). | ||||
| - `--priority <label>` – optional scheduling priority hint (`low`, `standard`, `high`). | ||||
| - `--rollback` – mark the activation as a rollback of a previously active version. | ||||
| - `--incident <id>` – associate the activation with an incident identifier. | ||||
|  | ||||
| **Exit codes** | ||||
|  | ||||
| | Code | Meaning | | ||||
| |------|---------| | ||||
| | `0` | Activation completed (or policy already active). | | ||||
| | `75` | Activation recorded but awaiting a second approver. | | ||||
|  | ||||
| ### 3.5 Archive / Rollback | ||||
|  | ||||
| ``` | ||||
| stella policy archive P-7 --version 3 --reason "Superseded by v4" | ||||
| stella policy activate P-7 --version 3 --rollback --incident INC-2025-104 | ||||
| ``` | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 4 · Simulation & Runs | ||||
|  | ||||
| ### 4.1 Simulate | ||||
|  | ||||
| ``` | ||||
| stella policy simulate P-7 \ | ||||
|   --base 3 --candidate 4 \ | ||||
|   --sbom sbom:S-42 --sbom sbom:S-318 \ | ||||
|   --env exposure=internet --env sealed=false \ | ||||
|   --format json --output sims/P-7-v4-vs-v3.json | ||||
| ``` | ||||
|  | ||||
| Output fields (JSON): | ||||
|  | ||||
| ```json | ||||
| { | ||||
|   "diff": { | ||||
|     "added": 12, | ||||
|     "removed": 8, | ||||
|     "unchanged": 657, | ||||
|     "bySeverity": { | ||||
|       "Critical": {"up": 1, "down": 0}, | ||||
|       "High": {"up": 3, "down": 4} | ||||
|     } | ||||
|   }, | ||||
|   "explainUri": "blob://policy/P-7/simulations/2025-10-26.json" | ||||
| } | ||||
| ``` | ||||
|  | ||||
| > Schema reminder: CLI commands surface objects defined in `src/Scheduler/__Libraries/StellaOps.Scheduler.Models/docs/SCHED-MODELS-20-001-POLICY-RUNS.md`; use the samples in `samples/api/scheduler/` for contract validation when extending output parsing. | ||||
|  | ||||
| Exit codes: | ||||
|  | ||||
| | Code | Meaning | | ||||
| |------|---------| | ||||
| | `0` | Simulation succeeded; diffs informational. | | ||||
| | `20` | Blocking delta (`--fail-on-diff` triggered). | | ||||
| | `21` | Simulation input missing (`ERR_POL_003`). | | ||||
| | `22` | Determinism guard (`ERR_POL_004`). | | ||||
| | `23` | API/permission error (`ERR_POL_002`, `ERR_POL_005`). | | ||||
|  | ||||
| ### 4.2 Run | ||||
|  | ||||
| ``` | ||||
| stella policy run P-7 --mode full \ | ||||
|   --sbom sbom:S-42 --env exposure=internal-only \ | ||||
|   --wait --watch | ||||
| ``` | ||||
|  | ||||
| Options: | ||||
|  | ||||
| | Flag | Description | | ||||
| |------|-------------| | ||||
| | `--mode` | `full` or `incremental` (default incremental). | | ||||
| | `--sbom` | Explicit SBOM IDs (optional). | | ||||
| | `--priority` | `normal`, `high`, `emergency`. | | ||||
| | `--wait` | Poll run status until completion. | | ||||
| | `--watch` | Stream progress events (requires TTY). | | ||||
|  | ||||
| `stella policy run status <runId>` retrieves run metadata.   | ||||
| `stella policy run list --status failed --limit 20` returns recent runs. | ||||
|  | ||||
| ### 4.3 Replay & Cancel | ||||
|  | ||||
| ``` | ||||
| stella policy run replay run:P-7:2025-10-26:auto --output bundles/replay.tgz | ||||
| stella policy run cancel run:P-7:2025-10-26:auto | ||||
| ``` | ||||
|  | ||||
| Replay downloads sealed bundle for deterministic verification. | ||||
|  | ||||
| ### 4.4 Schema artefacts for CLI validation | ||||
|  | ||||
| - CI publishes canonical JSON Schema exports for `PolicyRunRequest`, `PolicyRunStatus`, `PolicyDiffSummary`, and `PolicyExplainTrace` as the `policy-schema-exports` artifact (see `.gitea/workflows/build-test-deploy.yml`). | ||||
| - Each run writes the files to `artifacts/policy-schemas/<commit>/` and stores a unified diff (`policy-schema-diff.patch`) comparing them with the tracked baseline in `docs/schemas/`. | ||||
| - Schema changes trigger an alert in Slack `#policy-engine` via the `POLICY_ENGINE_SCHEMA_WEBHOOK` secret so CLI maintainers know to refresh fixtures or validation rules. | ||||
| - Consume these artefacts in CLI tests to keep payload validation aligned without committing generated files into the repo. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 5 · Findings & Explainability | ||||
|  | ||||
| ### 5.1 List Findings | ||||
|  | ||||
| ``` | ||||
| stella findings ls --policy P-7 \ | ||||
|   --sbom sbom:S-42 \ | ||||
|   --status affected --severity High,Critical \ | ||||
|   --since 2025-10-01T00:00:00Z \ | ||||
|   --page 2 --page-size 100 \ | ||||
|   --format table | ||||
| ``` | ||||
|  | ||||
| Common flags: | ||||
|  | ||||
| | Flag | Description | | ||||
| |------|-------------| | ||||
| | `--sbom` | Repeatable filter for SBOM identifiers. | | ||||
| | `--status` | Repeatable filter (`affected`, `quieted`, `mitigated`, `not_affected`, etc.). | | ||||
| | `--severity` | Repeatable filter using normalized labels (`Critical`, `High`, `Medium`, `Low`, `Unknown`). | | ||||
| | `--since` | Return findings updated on/after the ISO-8601 timestamp. | | ||||
| | `--cursor` | Resume listing using the opaque token from a prior page. | | ||||
| | `--page`, `--page-size` | Page-based pagination (page >=1, size <=500; falls back to backend defaults). | | ||||
| | `--output` | Persist JSON payload to disk (implied JSON rendering). | | ||||
| | `--format` | `table` (default for TTY) or `json`. | | ||||
|  | ||||
| ### 5.2 Fetch Explain | ||||
|  | ||||
| ``` | ||||
| stella findings explain --policy P-7 \ | ||||
|   P-7:S-42:pkg:npm/lodash@4.17.21:CVE-2021-23337 \ | ||||
|   --mode verbose \ | ||||
|   --format json --output explains/lodash.json | ||||
| ``` | ||||
|  | ||||
| Outputs ordered rule hits, inputs, evidence snapshots, and sealed-mode hints. Supported `--mode` values mirror API contracts (for example `summary`, `verbose`); omit to use backend default. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 6 · Exit Codes Summary | ||||
|  | ||||
| | Exit code | Description | Typical ERR codes | | ||||
| |-----------|-------------|-------------------| | ||||
| | `0` | Success (command completed, warnings only). | — | | ||||
| | `10` | DSL syntax/compile failure. | `ERR_POL_001` | | ||||
| | `11` | Unsupported DSL version / schema mismatch. | `ERR_POL_001` | | ||||
| | `12` | Approval/rbac failure. | `ERR_POL_002`, `ERR_POL_005` | | ||||
| | `20` | Simulation diff exceeded thresholds (`--fail-on-diff`). | — | | ||||
| | `21` | Required inputs missing (SBOM/advisory/VEX). | `ERR_POL_003` | | ||||
| | `22` | Determinism guard triggered. | `ERR_POL_004` | | ||||
| | `23` | Run canceled or timed out. | `ERR_POL_006` | | ||||
| | `30` | Network/transport error (non-HTTP success). | — | | ||||
| | `64` | CLI usage error (invalid flag/argument). | — | | ||||
|  | ||||
| All non-zero exits emit structured error envelope on stderr when `--format json` or `STELLA_JSON_ERRORS=1`. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 7 · Offline & Air-Gap Usage | ||||
|  | ||||
| - Use `--sealed` to ensure commands avoid outbound calls; required for sealed enclaves. | ||||
| - `stella policy bundle export --policy P-7 --version 4 --output bundles/policy-P-7-v4.bundle` pairs with Offline Kit import. | ||||
| - Replay bundles (`run replay`) are DSSE-signed; verify with `stella offline verify`. | ||||
| - Store credentials in `~/.stella/offline.toml` for non-interactive air-gapped pipelines. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 8 · Compliance Checklist | ||||
|  | ||||
| - [ ] **Help text synced:** `stella policy --help` matches documented flags/examples (update during release pipeline). | ||||
| - [ ] **Exit codes mapped:** Table above reflects CLI implementation and CI asserts mapping for `ERR_POL_*`. | ||||
| - [ ] **JSON schemas verified:** Example payloads validated against OpenAPI/SDK contracts before publishing. (_CI now exports canonical schemas as `policy-schema-exports`; wire tests to consume them._) | ||||
| - [ ] **Scope guidance present:** Each command lists required Authority scopes. | ||||
| - [ ] **Offline guidance included:** Sealed-mode steps and bundle workflows documented. | ||||
| - [ ] **Cross-links tested:** Links to DSL, lifecycle, runs, and API docs resolve locally (`yarn docs:lint`). | ||||
| - [ ] **Examples no-op safe:** Command examples either read-only or use placeholders (no destructive defaults). | ||||
|  | ||||
| --- | ||||
|  | ||||
| *Last updated: 2025-10-27 (Sprint 20).* | ||||
							
								
								
									
										23
									
								
								docs/modules/cli/implementation_plan.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								docs/modules/cli/implementation_plan.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| # Implementation plan — CLI | ||||
|  | ||||
| ## Current objectives | ||||
| - Maintain deterministic behaviour and offline parity across releases. | ||||
| - Keep documentation, telemetry, and runbooks aligned with the latest sprint outcomes. | ||||
|  | ||||
| ## Workstreams | ||||
| - Backlog grooming: reconcile open stories in ../../TASKS.md with this module's roadmap. | ||||
| - Implementation: collaborate with service owners to land feature work defined in SPRINTS/EPIC docs. | ||||
| - Validation: extend tests/fixtures to preserve determinism and provenance requirements. | ||||
|  | ||||
| ## Epic milestones | ||||
| - **Epic 2 – Policy Engine & Editor:** deliver deterministic policy verbs, simulation, and explain outputs. | ||||
| - **Epic 4 – Policy Studio:** add registry/promotion workflows, lint tooling, and approvals UX. | ||||
| - **Epic 6 – Vulnerability Explorer:** integrate ledger/triage operations. | ||||
| - **Epic 10 – Export Center:** automate export verification and Offline Kit flows. | ||||
| - **Epic 11 – Notifications Studio:** manage rule/channel authoring and previews via CLI. | ||||
| - Track CLI-specific work (e.g., CLI-CORE-41-001, DOCS-CLI-OBS-52-001) in ../../TASKS.md and src/Cli/**/TASKS.md. | ||||
|  | ||||
| ## Coordination | ||||
| - Review ./AGENTS.md before picking up new work. | ||||
| - Sync with cross-cutting teams noted in ../../implplan/SPRINTS.md. | ||||
| - Update this plan whenever scope, dependencies, or guardrails change. | ||||
							
								
								
									
										134
									
								
								docs/modules/cli/operations/release-and-packaging.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										134
									
								
								docs/modules/cli/operations/release-and-packaging.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,134 @@ | ||||
| > **Imposed rule:** Work of this type or tasks of this type on this component must also be applied everywhere else it should be applied. | ||||
|  | ||||
| # CLI Release & Packaging Runbook | ||||
|  | ||||
| This runbook describes how to build, sign, package, and distribute the StellaOps CLI with Task Pack support. It covers connected and air-gapped workflows, SBOM generation, parity gating, and distribution artifacts required by Sprint 43 (`DEVOPS-CLI-43-001`, `DEPLOY-PACKS-43-001`). | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 1 · Release Artifacts | ||||
|  | ||||
| | Artifact | Description | Notes | | ||||
| |----------|-------------|-------| | ||||
| | `stella-<version>-linux-x64.tar.gz` | Linux binary + completions | Includes man pages, localization files. | | ||||
| | `stella-<version>-macos-universal.tar.gz` | macOS universal binary | Signed/notarized where applicable. | | ||||
| | `stella-<version>-windows-x64.zip` | Windows binary + PowerShell modules | Code-signed. | | ||||
| | `stella-cli-container:<version>` | OCI image with CLI + pack runtime | Deterministic rootfs (scratch/distroless). | | ||||
| | SBOM (`.cdx.json`) | CycloneDX SBOM per artifact | Generated via `stella sbom generate` or `syft`. | | ||||
| | Checksums (`SHA256SUMS`) | Aggregated digest list | Signed with cosign. | | ||||
| | Provenance (`.intoto.jsonl`) | DSSE attestation (SLSA L2) | Contains build metadata. | | ||||
| | Release notes | Markdown summary | Links to task packs docs, parity matrix. | | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 2 · Build Pipeline | ||||
|  | ||||
| 1. **Source checkout** – pinned commit, reproducible environment (Docker). | ||||
| 2. **Dependency lock** – `dotnet restore`, `npm ci` (for CLI frontends), ensure deterministic build flags. | ||||
| 3. **Build binaries** – cross-platform targets with reproducible timestamps. | ||||
| 4. **Run tests** – unit + integration; include `stella pack` commands (plan/run/verify) in CI. | ||||
| 5. **Generate SBOM** – `syft packages dist/stella-linux-x64 --output cyclonedx-json`. | ||||
| 6. **Bundle** – compress artifacts, include completions (`bash`, `zsh`, `fish`, PowerShell). | ||||
| 7. **Sign** – cosign signatures for binaries, checksums, container image. | ||||
| 8. **Publish** – upload to `downloads.stella-ops.org`, container registry, Packs Registry (for CLI container). | ||||
| 9. **Parity gating** – run CLI parity matrix tests vs Console features (automation in `DEVOPS-CLI-43-001`). | ||||
|  | ||||
| CI must run in isolated environment (no network beyond allowlist). Cache dependencies for offline bundling. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 3 · Versioning & Channels | ||||
|  | ||||
| - Semantic versioning (`YYYY.MM.patch`), e.g., `2025.10.0`. | ||||
| - Channels: | ||||
|   - `edge` – nightly builds, limited support. | ||||
|   - `beta` – pre-release candidates. | ||||
|   - `stable` – production-ready, after parity gating. | ||||
| - Release promotions mirror Task Pack channels; update downloads manifest (`deploy/downloads/manifest.json`). | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 4 · Signing & Verification | ||||
|  | ||||
| - Binaries signed with cosign (`cosign sign-blob`). | ||||
| - Container image signed (`cosign sign stella-cli-container:<version>`). | ||||
| - DSSE provenance includes: | ||||
|   - Build pipeline ID. | ||||
|   - Source commit and repo. | ||||
|   - Dependencies SBOM digest. | ||||
|   - Test results summary. | ||||
| - Verification command for operators: | ||||
|  | ||||
| ```bash | ||||
| cosign verify-blob \ | ||||
|   --certificate-identity https://ci.stella-ops.org \ | ||||
|   --certificate-oidc-issuer https://fulcio.sigstore.dev \ | ||||
|   --signature stella-2025.10.0-linux-x64.sig \ | ||||
|   stella-2025.10.0-linux-x64.tar.gz | ||||
| ``` | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 5 · Distribution | ||||
|  | ||||
| ### 5.1 Online | ||||
|  | ||||
| - Publish artifacts to Downloads service; update manifest with digests, SBOM URLs, attestations. | ||||
| - Update CLI parity docs (`docs/cli-vs-ui-parity.md`) and release notes. | ||||
| - Push container image to registry with SBOM + attestations referenced as OCI referrers. | ||||
| - Notify stakeholders via `#release-cli` channel and release mailing list. | ||||
|  | ||||
| ### 5.2 Offline / Air-Gap | ||||
|  | ||||
| - Bundle CLI artifacts, Task Pack samples, and registry mirror: | ||||
|  | ||||
| ```bash | ||||
| stella pack bundle export \ | ||||
|   --packs "sbom-remediation:1.3.0" \ | ||||
|   --output offline/packs-bundle-2025.10.0.tgz | ||||
|  | ||||
| stella cli bundle export \ | ||||
|   --output offline/cli-2025.10.0.tgz \ | ||||
|   --include-container \ | ||||
|   --include-sbom | ||||
| ``` | ||||
|  | ||||
| - Update Offline Kit manifest with new CLI version and pack bundle entries. | ||||
| - Provide import scripts (`ouk import`) for sealed sites. | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 6 · Parity Gating | ||||
|  | ||||
| - `stella cli parity check` compares CLI commands vs parity matrix. | ||||
| - CI fails release if any required command flagged `🟥` or `🟡` with severity > threshold. | ||||
| - Parity report uploaded to Downloads workspace and linked in docs. | ||||
| - Manual review required for new commands (ensure `man` pages and help text localized). | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 7 · Localization & Documentation | ||||
|  | ||||
| - CLI includes localization bundles; ensure `i18n.txz` packaged. | ||||
| - Update man pages (`man/stella-pack.1`) and HTML docs. | ||||
| - Sync docs: `docs/modules/cli/guides/overview.md`, pack authoring guide, release notes. | ||||
| - Document new flags/commands in `docs/modules/cli/guides/commands/pack.md` (tracked in Sprint 42 tasks). | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## 8 · Release Checklist | ||||
|  | ||||
| - [ ] All binaries built reproducibly (CI logs archived).   | ||||
| - [ ] Tests + parity matrix passing.   | ||||
| - [ ] SBOM + provenance generated and published.   | ||||
| - [ ] Cosign signatures created and verified.   | ||||
| - [ ] Downloads manifest updated (edge/beta/stable).   | ||||
| - [ ] Offline bundle exported and validated.   | ||||
| - [ ] Release notes + documentation updates merged.   | ||||
| - [ ] Notifications sent (chat/email).   | ||||
| - [ ] Imposed rule reminder present at top of document. | ||||
|  | ||||
| --- | ||||
|  | ||||
| *Last updated: 2025-10-27 (Sprint 43).*  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user