Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help


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

idkindexprtraces_to
reuse_walkinvariantclassification reuses conform's walk machinery and artifact gate unchanged — a second trace evaluator is never introduced[[audit]]
closed_classesinvariant∀ 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_diffinvariant--before diffing refuses labeled on a scope-digest mismatch between reports, with zero classification emitted — cross-corpus-version diffs are impossible[[audit]]
contradiction_survives_diffinvariantthe 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_channelsinvariantunchecked 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_sparseinvariantbinds_nothing requires that the fragment or claim cites no declared model element — legitimately sparse models with declared elements are never flagged[[audit]]
rung_derivedinvariantthe 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_onlyinvariantaudit compiles nothing, writes no artifacts, and advances no lifecycle transition — refusal on ungated inputs is labeled with a remediation hint[[audit]]
row_keys_uniqueinvariantthe 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_deterministicinvariantfolded-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

  • gated
  • classified
  • merged
  • diffed
  • reported

Transitions

idfromtoguard
classifygatedclassified[[audit.reuse_walk]] ∧ [[audit.closed_classes]]
mergeclassifiedmerged[[audit.row_keys_unique]] ∧ [[audit.disambiguation_deterministic]]
diffmergeddiffed[[audit.digest_bound_diff]] ∧ [[audit.contradiction_survives_diff]]
reportdiffedreported[[audit.rung_derived]] ∧ [[audit.honesty_channels]] ∧ [[audit.read_only]]

Properties

idkindderives_fromgeneratorpredicate
p_classesunit[[audit.closed_classes]]arbitrary_evidence_corpus()every row carries exactly one class ∧ an underlying verdict
p_diffunit[[audit.digest_bound_diff]]arbitrary_report_pair()digest match ⇒ diff; mismatch ⇒ labeled refusal ∧ zero rows
p_contradiction_keptunit[[audit.contradiction_survives_diff]]arbitrary_report_pair()current contradicted ⇒ diffed contradicted (held or unseen) ∧ exit 1
p_honestyunit[[audit.honesty_channels]]arbitrary_row_mix()unchecked/binds_nothing ⇒ exit 0 ∧ counts surfaced
p_sparseunit[[audit.binds_respect_sparse]]sparse_phase_model()declared-element model ⇒ no binds_nothing flag
p_rungunit[[audit.rung_derived]]arbitrary_evidence_mix()rung == highest evidence-backed rung ∧ never exceeds it
p_read_onlyunit[[audit.read_only]]ungated_input()labeled refusal ∧ corpus byte-identical ∧ zero records
p_walk_reuseunit[[audit.reuse_walk]]arbitrary_classification_run()audit classes match a conform-walk oracle reference run
p_unique_keysunit[[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_surviveunit[[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_deterministicunit[[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 current and names the underlying verdict

Scenario: Contradicted evidence fails the run

  • WHEN the walk classifies a record forbidden or unsupported
  • THEN the row is contradicted and 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 current in the prior report and is unchecked in the current run
  • THEN the row is stale, naming both classes

Scenario: Sustained contradiction is never demoted

  • WHEN a record is contradicted in the prior report and contradicted in the current run against the same corpus
  • THEN the diffed row stays contradicted — never current — the class counts include it, and the run exits 1

Scenario: Worsening into a contradiction stays contradicted

  • WHEN a record was current in the prior report and is contradicted in the current run
  • THEN the row is contradicted, never stale, and the run exits 1 — the currency label never displaces live contradictory evidence

Scenario: Unseen contradiction is never relabelled new

  • WHEN a record is contradicted in the current run and the prior report carries no row for it
  • THEN the diffed row is contradicted, not new, 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_nothing on the warnings channel; a model whose declared elements are simply not exercised stays unflagged

Scenario: Unchecked never fails the run

  • WHEN every row is unchecked or binds_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:locked with its oracle class, the folded row is emitted as bind:locked~2 with class binds_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’s scenario_id lookup 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_id sequences

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