Stella CLI — Policy Commands
Audience: Policy authors, reviewers, operators and CI engineers. Lifecycle source verified:
05534daa6eb60609d9b716f7a7c1db38adb74551(2026-08-31). CLI parser/client existence is not backend availability. The registered Engine lifecycle is documented in the Policy lifecycle guide. Governance requirement: Real review, lint, coverage, shadow/determinism and trusted publication evidence remain required. The current CLI/Engine does not provide the advertised Registry workflow; do not manufacture attachments or successful transitions. Scope correction: Engine pack metadata/bundle operations requirepolicy:edit, reads requirepolicy:read, activation requirespolicy:activate. Do not removepolicy:editbased on the superseded scope guidance. Use the existing configured Authority credential flow for the intended tenant; tenant headers are not an authorization override.
This refresh verifies local authoring and lifecycle parser/client boundaries only. Other command and run-system examples remain reference material requiring their own source/runtime checks.
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=policyin CI to load saved defaults from~/.stella/profiles/policy.toml.
2 · Authoring & Drafting Commands
2.1 stella policy new
Create a local DSL file; this does not register a durable Engine Draft.
stella policy new my-policy --template baseline --output policies/my-policy.stella --fixtures
The parser takes a positional name, --template, --output, optional --description, repeatable --tag, --shadow, --fixtures and optional --git-init. The template’s shadow setting is not a successful live shadow run. Do not initialize a repository or overwrite an existing file unless that local authoring action is intended.
2.2 stella policy edit
Edit a local file:
stella policy edit policies/my-policy.stella
The supported options are --commit, --version <semver>, --message and --no-validate. These concern local validation/Git authoring, not an Engine integer revision, automatic upload or reviewer approval. Committing remains a separate authorized Git operation.
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
The parser accepts a local DSL file, not a policy id with an Engine revision:
stella policy compile policies/my-policy.stella
This local compilation is not a durable bundle upload or an approval. Use the canonical Engine procedure for Draft metadata and bundle storage.
3 · Lifecycle Workflow
3.1 Registry commands: parsed, but no registered Engine workflow
The current parser contains the following forms. They are client syntax references, not instructions for a working Engine review/publication sequence:
| Parser form | Boundary |
|---|---|
stella policy submit <id> --version <n> --reviewer <id> --message <text> | Client sends api/policy/{id}/submit; the Registry workflow is not registered in Engine. No --attach or --note submission gate is implemented by this parser. |
stella policy review approve <id> --review-id <id> --comment <text> | Nested review command; not standalone policy approve or review --approve. Backend targets Registry review paths, not Approved pack metadata. |
stella policy publish <id> --version <n> --sign --note <text> | Client targets api/policy/{id}/versions/{n}/publish; parser flags are not --reason/--ticket, and the Engine workflow is unavailable. |
stella policy rollback <id> --target-version <n> | Registry client operation, not an Engine archive transition or proof of restored consumer state. |
Reviewer quorum/separation, shadow/coverage and reason/ticket/signature requirements remain governance obligations. Do not infer their enforcement from command names or provide invented evidence to make an unavailable workflow appear complete.
3.2 Activation client mismatch
The parser accepts stella policy activate <id> --version <n> --note <text> and also --run-now, --scheduled-at, --priority, --rollback and --incident. However, BackendOperationsClient.ActivatePolicyRevisionAsync sends POST api/policy/policies/{id}/versions/{n}:activate. The Engine and Gateway map POST /api/policy/packs/{packId}/revisions/{version}:activate, not that client route.
Do not use the current CLI activation command as the Engine acceptance procedure. Use the canonical HTTP lifecycle with its exact scopes, Approved state and persisted actor requirement. The Engine body only consumes comment; it does not implement the client’s scheduling/run/rollback fields as effects.
The CLI maps pending_second_approval to exit 75 and other returned status strings to exit 0. That mapping is not proof of successful activation; verify the actual response and the consumer. There is no policy archive command in this parser or archive transition in the pack API.
3.3 Source re-verification
From the repository root, inspect the enclosing methods after these searches:
rg -n 'new Command\("(new|edit|lint|compile|submit|review|approve|publish|activate|rollback)"' src/Cli/StellaOps.Cli/Commands/CommandFactory.cs
rg -n 'ActivatePolicyRevisionAsync|SubmitPolicyForReviewAsync|ApprovePolicyReviewAsync|PublishPolicyAsync|api/policy/policies/' src/Cli/StellaOps.Cli/Services/BackendOperationsClient.cs
rg -n 'MapPost|RequireStellaOpsScopes|ActivatePolicyRevisionRequest' src/Policy/StellaOps.Policy.Engine/Endpoints/PolicyPackEndpoints.cs
No CLI build, command execution or live mutation is claimed by this documentation verification.
4 · Simulation & Runs
4.1 Simulate — not Registry lifecycle acceptance
The example below is historical run-system reference, not proof of an available Registry simulation/shadow backend. Check GET /policy/capabilities; do not run this sequence expecting a durable review or shadow receipt while that capability is unavailable.
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):
{
"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 indocs/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 — historical orchestration reference
These run examples are not part of the registered Engine pack lifecycle and are not executed by activation. Verify a mapped run owner and current parser before operational use; do not treat --run-now as delivered orchestration.
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 History
stella policy history P-7 --limit 20 --format table
The current parser describes run history, with --tenant, --from, --to, --status, --limit, --cursor and --format. It is not a Registry reviewer/approval history or a --runs lifecycle receipt.
4.4 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.5 Schema artefacts for CLI validation
- CI publishes canonical JSON Schema exports for
PolicyRunRequest,PolicyRunStatus,PolicyDiffSummary, andPolicyExplainTraceas thepolicy-schema-exportsartifact (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 indocs/modules/policy/schemas/. - Schema changes trigger an alert in Slack
#policy-enginevia thePOLICY_ENGINE_SCHEMA_WEBHOOKsecret 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
The following bundle/replay examples are historical distribution guidance, not an available Registry approval/export workflow. Verify the current command and real signed artifact before use; offline flags do not supply missing review, shadow or publication evidence.
- Use
--sealedto ensure commands avoid outbound calls; required for sealed enclaves. stella policy bundle export --policy P-7 --version 4 --output bundles/policy-P-7-v4.bundlepairs with Offline Kit import.- Replay bundles (
run replay) are DSSE-signed; verify withstella offline verify. - Store credentials in
~/.stella/offline.tomlfor non-interactive air-gapped pipelines.
8 · Compliance Checklist
- [ ] Help text synced:
stella policy --helpmatches 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).
9 · See Also
- CLI overview and quick start — orientation and installation.
stella policycommand reference — generated flag/field reference.- Output formats and exit codes — shared exit-code contract.
- Parity matrix — how policy commands map to Policy Engine APIs and offline behaviour.
Last updated: 2025-11-26 (Sprint 307).
