id: audit kind: intent statement: “WHEN a lint-clean spec file with current compiled artifacts is audited against a declared evidence corpus and an optional prior report, THE audit capability SHALL classify every evidence row with exactly one class from the closed set {current, stale, unchecked, contradicted, binds_nothing, new} — reusing conform’s walk machinery and artifact gate unchanged — and SHALL report the highest evidence-backed ladder rung, never treating unchecked evidence as verified and never claiming behavioral equality.”
audit Specification
Purpose
Compute the graded-evidence discipline the toolchain already names (the ladder, evidence_scope, exploration_only) uniformly over everything that claims to constrain behavior: recorded example corpora, pack checker results, fragment/claim bindings, and prior audit reports.
Constraints
| id | kind | expr | traces_to |
|---|---|---|---|
| reuse_walk | invariant | classification reuses conform's walk machinery and artifact gate unchanged — a second trace evaluator is never introduced | [[audit]] |
| closed_classes | invariant | ∀ evidence row: exactly one audit class from {current, stale, unchecked, contradicted, binds_nothing, new}, each record also carrying the underlying conform verdict with its reason — none or two is impossible | [[audit]] |
| digest_bound_diff | invariant | --before diffing refuses labeled on a scope-digest mismatch between reports, with zero classification emitted — cross-corpus-version diffs are impossible | [[audit]] |
| contradiction_survives_diff | invariant | the prior-report overlay never retires a contradiction: a row contradicted in the current run keeps the class contradicted whatever the prior report said about it — held, graded differently, or unseen — so a currency label (current, stale, new) never replaces live contradictory evidence, so the exit predicate still fails the run | [[audit]] |
| honesty_channels | invariant | unchecked and binds_nothing ride the warnings channel and never affect the exit code — unchecked evidence is countable, never a pass, and never a failure | [[audit]] |
| binds_respect_sparse | invariant | binds_nothing requires that the fragment or claim cites no declared model element — legitimately sparse models with declared elements are never flagged | [[audit]] |
| rung_derived | invariant | the summary's ladder rung is derived at report time from evidence actually present and never exceeds it — a rung without its evidence is impossible | [[audit]] |
| read_only | invariant | audit compiles nothing, writes no artifacts, and advances no lifecycle transition — refusal on ungated inputs is labeled with a remediation hint | [[audit]] |
| row_keys_unique | invariant | the merged report carries no two rows with the same scenario_id: when a FOLDED row (bind:<owner-id>, pack:<pack_id>:<subject_id>) collides with a key already present, the folded row takes the first free ~<n> suffix (~2, ~3, …) while the oracle row keeps its corpus id verbatim; both rows survive with their own classes, so the prior diff's scenario_id lookup can never silently pick one and drop the other | [[audit]] |
| disambiguation_deterministic | invariant | folded-row disambiguation is a pure function of the corpus rows — no counter, random state, or map-iteration order — so repeated assembly over identical inputs yields identical keys and byte-identical serialization, and a renamed row keeps its class: advisory rows stay advisory and the exit contract is untouched | [[audit]] |
Model
States
gatedclassifiedmergeddiffedreported
Transitions
| id | from | to | guard |
|---|---|---|---|
| classify | gated | classified | [[audit.reuse_walk]] ∧ [[audit.closed_classes]] |
| merge | classified | merged | [[audit.row_keys_unique]] ∧ [[audit.disambiguation_deterministic]] |
| diff | merged | diffed | [[audit.digest_bound_diff]] ∧ [[audit.contradiction_survives_diff]] |
| report | diffed | reported | [[audit.rung_derived]] ∧ [[audit.honesty_channels]] ∧ [[audit.read_only]] |
Properties
| id | kind | derives_from | generator | predicate |
|---|---|---|---|---|
| p_classes | unit | [[audit.closed_classes]] | arbitrary_evidence_corpus() | every row carries exactly one class ∧ an underlying verdict |
| p_diff | unit | [[audit.digest_bound_diff]] | arbitrary_report_pair() | digest match ⇒ diff; mismatch ⇒ labeled refusal ∧ zero rows |
| p_contradiction_kept | unit | [[audit.contradiction_survives_diff]] | arbitrary_report_pair() | current contradicted ⇒ diffed contradicted (held or unseen) ∧ exit 1 |
| p_honesty | unit | [[audit.honesty_channels]] | arbitrary_row_mix() | unchecked/binds_nothing ⇒ exit 0 ∧ counts surfaced |
| p_sparse | unit | [[audit.binds_respect_sparse]] | sparse_phase_model() | declared-element model ⇒ no binds_nothing flag |
| p_rung | unit | [[audit.rung_derived]] | arbitrary_evidence_mix() | rung == highest evidence-backed rung ∧ never exceeds it |
| p_read_only | unit | [[audit.read_only]] | ungated_input() | labeled refusal ∧ corpus byte-identical ∧ zero records |
| p_walk_reuse | unit | [[audit.reuse_walk]] | arbitrary_classification_run() | audit classes match a conform-walk oracle reference run |
| p_unique_keys | unit | [[audit.row_keys_unique]] | oracle_id_spelled_like_a_bind_row_key() | the oracle row keeps the corpus id verbatim ∧ the folded row is <id>~2 ∧ no two merged rows share a scenario_id |
| p_rows_survive | unit | [[audit.row_keys_unique]] | merged_report_with_a_cross_kind_key_collision() | both rows survive with their own classes ∧ the renamed row stays advisory |
| p_deterministic | unit | [[audit.disambiguation_deterministic]] | same_corpus_folded_twice() | merged keys are equal across runs — no counter or random suffix |
Requirements
Requirement: Evidence row classification
spk audit <file> --oracle <corpus.jsonl> SHALL classify every oracle
record and pack-check result against the current compiled model with exactly
one audit class from the closed set {current, unchecked, contradicted, binds_nothing, stale, new}, each record carrying both the audit class and
the underlying conform verdict with its reason, reusing conform’s walk
machinery and artifact gate unchanged.
Scenario: Current evidence agrees
- WHEN a record’s verdict class matches its class in the prior report (or no prior report exists and the walk classifies it)
- THEN the row is
currentand names the underlying verdict
Scenario: Contradicted evidence fails the run
- WHEN the walk classifies a record
forbiddenorunsupported - THEN the row is
contradictedand the run exits 1 per the exit-code requirement — never a silent pass
Requirement: Evidence diff across reports
spk audit --before <report.json> SHALL compare per-row verdict classes
against the prior report — dropped or worsened ⇒ stale, unseen ⇒ new —
refusing labeled when the two reports carry different scope digests, and
SHALL never retire a contradiction: a row contradicted in the current run
stays contradicted whatever the prior report said about it, contradiction
outranking every currency label.
Scenario: Dropped class is stale
- WHEN a record was
currentin the prior report and isuncheckedin the current run - THEN the row is
stale, naming both classes
Scenario: Sustained contradiction is never demoted
- WHEN a record is
contradictedin the prior report andcontradictedin the current run against the same corpus - THEN the diffed row stays
contradicted— nevercurrent— the class counts include it, and the run exits 1
Scenario: Worsening into a contradiction stays contradicted
- WHEN a record was
currentin the prior report and iscontradictedin the current run - THEN the row is
contradicted, neverstale, and the run exits 1 — the currency label never displaces live contradictory evidence
Scenario: Unseen contradiction is never relabelled new
- WHEN a record is
contradictedin the current run and the prior report carries no row for it - THEN the diffed row is
contradicted, notnew, and the run exits 1
Scenario: Corpus-version mismatch refused
- WHEN the prior and current reports carry different scope digests
- THEN the run fails labeled naming the digest mismatch, with no classification emitted
Requirement: Audit honesty channels
Audit SHALL treat unchecked and binds_nothing as warnings-channel
findings that never affect the exit code, and binds_nothing SHALL require
that the fragment or claim cites no declared model element — legitimately
sparse models with declared elements are never flagged.
Scenario: Empty checked-set is unchecked
- WHEN a pack checker runs over vocabulary it activates but produces an empty checked-set
- THEN the row is
unchecked, countable in the summary — never a pass
Scenario: Unbound evidence flagged, sparsity respected
- WHEN a fragment cites no declared model element
- THEN the row is
binds_nothingon the warnings channel; a model whose declared elements are simply not exercised stays unflagged
Scenario: Unchecked never fails the run
- WHEN every row is
uncheckedorbinds_nothing - THEN the exit code is 0 with counts surfaced in both output views
Requirement: Evidence rung aggregate
Audit summaries SHALL report, per file, the highest verification-ladder rung
for which current evidence exists, derived at report time from existing
outputs — never exceeding the evidence actually present.
Scenario: Rung matches evidence
- WHEN a file is lint-clean but only model-checked, with no verify pass
- THEN its reported rung is 3, and never 4 or 5
Scenario: Rung never claims without evidence
- WHEN no audit, conform, or verify evidence exists for a file
- THEN its reported rung is 1 (lint-clean at most), stated as such
Requirement: Merged evidence row keys are unique
The merged audit report SHALL never carry two rows with the same
scenario_id: when a FOLDED row (bind:<owner-id> or
pack:<pack_id>:<subject_id>) collides with a key already present — an oracle
row whose corpus id is spelled exactly like a folded key included — the folded
row SHALL take the first free ~<n> suffix while the row already present
keeps its id, both rows SHALL survive with their own classes and counts, and
the exit contract SHALL be unchanged.
Scenario: Oracle id spelled like a bind row key
- WHEN an oracle corpus id equals a folded bind row’s key
(
bind:locked) - THEN the oracle row keeps
bind:lockedwith its oracle class, the folded row is emitted asbind:locked~2with classbinds_nothing, and both rows are present in the report
Scenario: A pack row collision follows the same rule
- WHEN a folded pack row’s key collides with a key already in the report
- THEN the pack row takes the first free
~<n>suffix and the row already present keeps its id — no row is dropped or merged
Scenario: No duplicate ids survive the merge
- WHEN any folded row collides with an existing row key
- THEN the merged report carries no duplicate
scenario_id, so the prior-report diff’sscenario_idlookup always addresses exactly one row
Requirement: Disambiguation is deterministic
Folded-row disambiguation SHALL be a pure function of the corpus rows —
no counters, random state, or map-iteration order — so repeated assembly
over identical inputs yields identical keys and byte-identical
serialization, and a --before diff keeps matching every oracle row by
its recorded corpus id.
Scenario: Same corpus merges to the same keys
- WHEN the same oracle and folded rows are merged twice
- THEN the two merged reports carry identical
scenario_idsequences
Scenario: Oracle evidence is never renamed
- WHEN a suffix is assigned in a collision
- THEN only the folded row is renamed; every oracle row keeps its corpus id, so diffing against evidence recorded in a prior report still resolves