Expand description
The rule surface shared by ct-rules (say what the rules are) and
ct-check (verify them): the .ct/rules.jsonc store model, upward
discovery, def expansion, the probe gate, the external-tool bridge,
and the expect outcome adapters.
A rule is one recorded, framed observation: an id, the question it
answers, the probe (an argv vector, never a shell) that answers it by
scanning for known violations, and the why behind it. Defs are the
store’s named vocabulary, expanded as {def:NAME} inside probe argvs.
Probes are gated to the suite’s fixed read-only set plus the compiled-in
BRIDGE of known read-only invocations of established Rust tools — a
store entry selects from the gate and can never extend it.
The full specification is docs/specs/rules.md.
Structs§
- Bridge
Entry - One compiled-in external invocation rules may leverage. The table is immutable: a store entry selects from it and can never extend it.
- Rule
- One recorded rule.
- Store
- The parsed store.
Enums§
- Adapter
- How a probe’s outcome is read as a verdict. Observers speak the suite’s
exit contract (
Exit); bridge tools need an adapter. - Def
- A def: the store’s named vocabulary. Untyped — a string expands in place; a list expands to multiple argv elements.
- Gated
- What the gate resolved a probe to.
- Probe
Outcome - A probe’s classified outcome (before lane mapping).
- Severity
- Rule severity: whether a violation reddens the exit status.
Constants§
- BRIDGE
- The compiled-in bridge: known read-only invocations of established Rust
tools. See
docs/specs/rules.md§5. - STORE_
FILE - The store’s path relative to the
.ctdirectory.
Functions§
- bridge_
argv - The argv actually launched for a bridge probe: the rule’s argv plus the
entry’s enforced flags and hermetic flag (skipping flags already present).
networkdrops the hermetic flag only where the entry deems it meaningful. - classify
- Classify a finished probe through its adapter.
codeis the exit code (Nonefor a signal death — broken). Returns the outcome and a one-line reason. Timeouts are handled by the caller (always broken). - discover_
root - Walk upward from
startto the nearest directory containing.ct, git-style. Returns that project root, orNonewhen no.ctexists up to the filesystem root. - expand_
defs - Expand
{def:NAME}tokens in a probe argv. An element that is exactly one{def:NAME}token whose def is a list splices to multiple elements; a string def expands inside elements. A list def referenced inside a larger element, or an unknown def, is an error (the rule is broken). - gate_
probe - Gate a (def-expanded) probe argv. Returns how it may run, or a refusal naming the reason. The gate is fail-closed and compiled in.
- parse_
store - Parse and validate the JSONC store text.
- probe_
root - The directory probes run from: store paths are root-relative, so a
probe’s working directory is the project root (the parent of the
.ctdirectory holding the store), regardless of where the tool was invoked. For a--fileoutside a.ctdirectory, the file’s own directory. - run_
probe - Run one gated, def-expanded probe to completion and classify it. The
probe runs from
root— store paths are root-relative, so rules behave identically wherever the tool was invoked. Launch failures (e.g. a bridge binary not installed) and timeouts are broken, never errors: a defective probe is a maintenance signal the caller reports, not a crash. - store_
path - The store path under a project root.