Part VI · CLI · Plate 03

cns gate

On this page

Listing 6.3.1   Synopsis

cns gate [--systemone] [<soma concerns check args>...]

Description

Execute the closeout gate in a Soma-initialised repository.

Structural checks

Live rubric opt-in

The System 1 rubric sends live inference and is OFF by default: rubric: not evaluated (disabled by default). To authorize live inference for this path:

Once enabled, rubric is a requested oracle. The gate uses --systemone when supplied, or adds it after THALAMUS_URL/admin/v1/status reports a healthy System 1 member. Missing THALAMUS_URL, unreachable or invalid status, no healthy member, or exhausted budget yields rubric: not evaluated (<reason>) and exit 3, never 0.

Turn opt-in off for structural-only gating. THALAMUS_URL has no default. --systemone without opt-in exits 3 and contacts nothing.

Deterministic typecheck and tests oracles

Request them like the rubric: CNS_ORACLES=structural,typecheck,tests,rubric, or oracles = [...] in .cns/config.toml. Each requested one runs the cmd of its table from the repository root, without a shell, after axon index and before Soma:

[gate.typecheck]
cmd = ["vendor/bin/phpstan", "analyse", "--no-progress", "--error-format=json"]
diagnostics = "phpstan-json"   # optional: gate only on findings in changed files
globs = ["*.php"]          # optional: keep only matching paths
timeout_ms = 20000         # optional; always capped by the gate budget
[gate.tests]
cmd = ["vendor/bin/phpunit", "{impacted_tests}"]
require_integration_on_http_surface = true   # optional

Budget and exit status

CNS_GATE_BUDGET_MS (default 30000) covers the typecheck and tests commands, the status probe and the rubric together. A slow command or Thalamus reports not evaluated (... timed out ...) and exits 3.

Vitals

Appends a vitals.v1 row (soma/gate) with concerns_fired, oracles_requested, oracles_evaluated, evaluated_red and tree_sha256 (the digest of the evaluated working tree outside .cns, .soma, .axon and .engram); cns status prints both oracle lists and shows NOT_EVALUATED (red) when a requested oracle did not run, or FAILED when the gate exited 1 (a skipped rubric).

Harness Stop hook

cns gate --stop-hook --harness <claude|codex|agy|pi> enforces the gate at the end of an agent turn. It reads the harness's Stop payload on stdin, prints only that harness's decision JSON on stdout and always exits 0.

Fig. 6.3.1   What the gate runs

  1. Refresh
    Axon if indexed
  2. Run
    Typecheck, tests if requested
  3. Verify
    Soma maps
  4. Check
    Structural concerns
  5. Report
    Requested oracles

Table 6.3.1   Exit status & oracles

Exit Meaning
0 Every requested oracle ran and passed
1 Structural, typecheck, tests or rubric failure
3 Requested oracle not evaluated; takes precedence over 1

Requested oracles

Oracle Default When unavailable
Structural Requested Exit 3; never a pass
Typecheck, tests Disabled; configured in .cns/config.toml Exit 3 when requested but not evaluated
System 1 rubric Disabled; explicit opt-in required Exit 3 when requested but not evaluated

Where the result goes

The gate appends a soma/gate record to .cns/vitals.jsonl. Run cns status to inspect requested and evaluated oracles. A hook success does not replace this closeout verdict.

See the authoritative rubric and gate contract and the vitals record. Structural is the default; live inference requires opt-in.