diff --git a/_pkgdown.yml b/_pkgdown.yml index 061b553..96a131b 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -340,3 +340,4 @@ articles: - articles/devlog-2026-11-23-p3-cs14-segments-witness - articles/devlog-2026-11-23-p3-cs15-refdb-witness - articles/devlog-2026-11-23-p3-cs16-ard-witness + - articles/devlog-2026-11-23-p3-cs17-catalog-witness diff --git a/bench/scenarios/out/cs17_degenerates.tsv b/bench/scenarios/out/cs17_degenerates.tsv new file mode 100644 index 0000000..df606b8 --- /dev/null +++ b/bench/scenarios/out/cs17_degenerates.tsv @@ -0,0 +1,9 @@ +pair side arm mode cls msg +empty-boundary hi empty-queue-hi accept s7:msuiter::MsCatalog msuiter::MsCatalog|4|0|double|TRUE|FALSE|d3b77a574c1e6afda429f0e14afcf4d1| CS17T: 4 channels x 0 samples +empty-boundary lo zero-channels-lo reject msuiter_error_catalog counts must carry both channel labels (rownames) and sample labels (colnames) | labels are the only legal matching key (never position) | rownames missing: TRUE; colnames missing: FALSE | name the matrix dimensions before constructing MsCatalog +rowlaw-split hi rowlabel-uniqueness-hi reject msuiter_error_catalog channel and sample labels must be unique | duplicated labels make label matching ambiguous | duplicated channel labels: 'CH1'; duplicated sample labels: (none) | de-duplicate or rename labels +rowlaw-split lo rownames-missing-lo reject msuiter_error_catalog counts must carry both channel labels (rownames) and sample labels (colnames) | labels are the only legal matching key (never position) | rownames missing: TRUE; colnames missing: FALSE | name the matrix dimensions before constructing MsCatalog +minimal-vs-empty hi minimal-1x1-hi accept s7:msuiter::MsCatalog msuiter::MsCatalog|1|1|double|TRUE|TRUE|e10fea09c4590dfbcf05149c6d3157db| CS17T: 1 channels x 1 samples +minimal-vs-empty lo empty-4x0-lo accept s7:msuiter::MsCatalog msuiter::MsCatalog|4|0|double|TRUE|FALSE|d3b77a574c1e6afda429f0e14afcf4d1| CS17T: 4 channels x 0 samples +skipped-tail hi skipped-tail-hi accept s7:msuiter::MsCatalog msuiter::MsCatalog|4|2|double|TRUE|TRUE|d3b77a574c1e6afda429f0e14afcf4d1| CS17T: 4 channels x 2 samples; skipped 7/42 variants +skipped-tail lo core-nontail-lo accept s7:msuiter::MsCatalog msuiter::MsCatalog|4|2|double|TRUE|TRUE|d3b77a574c1e6afda429f0e14afcf4d1| CS17T: 4 channels x 2 samples diff --git a/bench/scenarios/out/cs17_laws.tsv b/bench/scenarios/out/cs17_laws.tsv new file mode 100644 index 0000000..1918433 --- /dev/null +++ b/bench/scenarios/out/cs17_laws.tsv @@ -0,0 +1,43 @@ +arm mode cls msg +G1-channels-nonlist reject simpleError object properties are invalid: | - @channels must be , not +G2-samples-noncharacter reject simpleError object properties are invalid: | - @samples must be , not +G3-provenance-nonlist reject simpleError object properties are invalid: | - @provenance must be , not +V1-counts-vector reject msuiter_error_catalog counts must be a numeric matrix (channels x samples) | MsCatalog stores one count per channel and sample | received: numeric | tally variants with ms_tally() to obtain a count matrix +V1b-counts-character-matrix reject msuiter_error_catalog counts must be a numeric matrix (channels x samples) | MsCatalog stores one count per channel and sample | received: matrix | tally variants with ms_tally() to obtain a count matrix +V2-rownames-missing reject msuiter_error_catalog counts must carry both channel labels (rownames) and sample labels (colnames) | labels are the only legal matching key (never position) | rownames missing: TRUE; colnames missing: FALSE | name the matrix dimensions before constructing MsCatalog +V2b-colnames-missing reject msuiter_error_catalog counts must carry both channel labels (rownames) and sample labels (colnames) | labels are the only legal matching key (never position) | rownames missing: FALSE; colnames missing: TRUE | name the matrix dimensions before constructing MsCatalog +V3-rowlabels-dup reject msuiter_error_catalog channel and sample labels must be unique | duplicated labels make label matching ambiguous | duplicated channel labels: 'CH1'; duplicated sample labels: (none) | de-duplicate or rename labels +V3b-collabels-dup reject msuiter_error_catalog channel and sample labels must be unique | duplicated labels make label matching ambiguous | duplicated channel labels: (none); duplicated sample labels: 'S1' | de-duplicate or rename labels +V4-count-NA reject msuiter_error_catalog counts must not contain NA or non-finite values | the FFI contract rejects NA; the catalog layer adds no pseudo-counts | offending cells: '2' | fix the upstream tally output +V4b-count-Inf reject msuiter_error_catalog counts must not contain NA or non-finite values | the FFI contract rejects NA; the catalog layer adds no pseudo-counts | offending cells: '7' | fix the upstream tally output +V4c-count-NaN reject msuiter_error_catalog counts must not contain NA or non-finite values | the FFI contract rejects NA; the catalog layer adds no pseudo-counts | offending cells: '4' | fix the upstream tally output +V5-count-negative reject msuiter_error_catalog counts must be non-negative | negative mutation counts are impossible | offending cells: '5' | check the tally pipeline for subtraction errors +V6-snap-missing-hash reject msuiter_error_catalog the channel snapshot must be a list with fields name, labels, hash | the snapshot keeps the registry's canonical labels and their digest | received fields: 'name', 'labels' | construct the catalog through ms_catalog(), which slices the snapshot +V6b-snap-missing-name reject msuiter_error_catalog the channel snapshot must be a list with fields name, labels, hash | the snapshot keeps the registry's canonical labels and their digest | received fields: 'labels', 'hash' | construct the catalog through ms_catalog(), which slices the snapshot +V6c-snap-extra-field reject msuiter_error_catalog the channel snapshot must be a list with fields name, labels, hash | the snapshot keeps the registry's canonical labels and their digest | received fields: 'name', 'labels', 'hash', 'extra' | construct the catalog through ms_catalog(), which slices the snapshot +V6d-snap-empty-list reject msuiter_error_catalog the channel snapshot must be a list with fields name, labels, hash | the snapshot keeps the registry's canonical labels and their digest | received fields: (none) | construct the catalog through ms_catalog(), which slices the snapshot +V7-name-empty reject msuiter_error_catalog the channel snapshot field 'name' must be a single non-empty string | the table name identifies the channel set (e.g. SBS96) | received: '' | pass the registry table name, e.g. name = "SBS96" +V7b-name-NA reject msuiter_error_catalog the channel snapshot field 'name' must be a single non-empty string | the table name identifies the channel set (e.g. SBS96) | received: 'NA' | pass the registry table name, e.g. name = "SBS96" +V7c-name-noncharacter reject msuiter_error_catalog the channel snapshot field 'name' must be a single non-empty string | the table name identifies the channel set (e.g. SBS96) | received: '5' | pass the registry table name, e.g. name = "SBS96" +V8-labels-NA-handhash reject msuiter_error_catalog channel labels in the snapshot must be a character vector without NA | channel labels are canonical identities | received: character of length 4 with anyNA = TRUE | pass the canonical labels from the channel registry +V8b-labels-numeric reject msuiter_error_catalog channel labels in the snapshot must be a character vector without NA | channel labels are canonical identities | received: integer of length 4 with anyNA = FALSE | pass the canonical labels from the channel registry +V8c-label-empty-string reject msuiter_error_catalog channel labels in the snapshot must be a character vector without NA | channel labels are canonical identities | received: character of length 4 with anyNA = FALSE | pass the canonical labels from the channel registry +V9-snap-labels-dup reject msuiter_error_catalog channel labels in the snapshot must be unique | duplicated channel labels are not canonical order | duplicated: 'CH1' | use the canonical registry ordering +V13-hash-nonhex reject msuiter_error_catalog the channel snapshot field 'hash' must be an md5 hex digest | the digest pins the channel table inside snapshot summaries (A5) | received: 'ZZzz0000000000000000000000000000' | let ms_catalog() compute the hash; do not set it by hand +V13b-hash-noncharacter reject msuiter_error_catalog the channel snapshot field 'hash' must be an md5 hex digest | the digest pins the channel table inside snapshot summaries (A5) | received: '42' | let ms_catalog() compute the hash; do not set it by hand +V13c-hash-NA reject msuiter_error_catalog the channel snapshot field 'hash' must be an md5 hex digest | the digest pins the channel table inside snapshot summaries (A5) | received: 'NA' | let ms_catalog() compute the hash; do not set it by hand +V13d-hash-short-hex reject msuiter_error_catalog the channel snapshot field 'hash' must be an md5 hex digest | the digest pins the channel table inside snapshot summaries (A5) | received: 'd3b77a574c1e6afda429f0e14afcf4d' | let ms_catalog() compute the hash; do not set it by hand +V14-hash-foreign reject msuiter_error_catalog the stored channel hash does not match the stored labels | snapshot hashes must be derived, not asserted | stored: 2b947f5f7703ed9896680aa8bbe27a7a | rebuild the catalog with ms_catalog() +V10-nrow-vs-labels reject msuiter_error_catalog counts dimensions disagree with the registry snapshot or the samples | counts is channels x samples | nrow = 3 vs 4 labels; ncol = 2 vs 2 samples | align the count matrix with the registry labels and sample ids +V10b-ncol-vs-samples reject msuiter_error_catalog counts dimensions disagree with the registry snapshot or the samples | counts is channels x samples | nrow = 4 vs 4 labels; ncol = 3 vs 2 samples | align the count matrix with the registry labels and sample ids +V11-rowlabel-decoy-permuted reject msuiter_error_catalog channel labels of counts do not match the registry snapshot | matching is by label, element by element, never by position | first offending labels: 'CH2', 'CH1' | reorder or rename counts rows to the canonical registry labels +V12-colnames-vs-samples reject msuiter_error_catalog sample labels of counts do not match the samples property | matching is by label, element by element, never by position | first offending labels: 'SX' | align colnames(counts) with the samples vector +V15-sample-empty reject msuiter_error_catalog sample labels must be non-empty strings without NA | sample ids are identities matched by label | offending labels: '' | provide one non-empty id per sample +V15b-sample-NA reject msuiter_error_catalog sample labels must be non-empty strings without NA | sample ids are identities matched by label | offending labels: 'NA' | provide one non-empty id per sample +V16-prov-unnamed reject msuiter_error_catalog catalog provenance must be a named list | provenance carries the genome build and tally context | received: list | provide at least genome = "" +V16b-prov-emptyname reject msuiter_error_catalog catalog provenance must be a named list | provenance carries the genome build and tally context | received: list | provide at least genome = "" +V17-genome-missing reject msuiter_error_catalog catalog provenance must carry the genome build as 'genome' | the build is required to query reference signatures | received: (none) | record the build, e.g. provenance = list(genome = "GRCh38") +V17b-genome-empty reject msuiter_error_catalog catalog provenance must carry the genome build as 'genome' | the build is required to query reference signatures | received: '' | record the build, e.g. provenance = list(genome = "GRCh38") +X1-errorinput-autohash-NAlabels reject msuiter_error_input channel labels to hash must be a character vector without NA | the label digest is only defined for plain label vectors | received: character with anyNA = TRUE | pass the canonical channel labels (character, NA free) +E2-NAinteger-label-trap reject msuiter_error_input channel labels to hash must be a character vector without NA | the label digest is only defined for plain label vectors | received: character with anyNA = TRUE | pass the canonical channel labels (character, NA free) +U1-hashhelper-via-factory-listlabels reject msuiter_error_catalog counts dimensions disagree with the registry snapshot or the samples | counts is channels x samples | nrow = 4 vs 2 labels; ncol = 2 vs 2 samples | align the count matrix with the registry labels and sample ids diff --git a/bench/scenarios/out/cs17_precedence.tsv b/bench/scenarios/out/cs17_precedence.tsv new file mode 100644 index 0000000..8d98654 --- /dev/null +++ b/bench/scenarios/out/cs17_precedence.tsv @@ -0,0 +1,11 @@ +arm mode cls msg fires_ok anti_ok +PR1-anchor-gate-over-validator reject simpleError object properties are invalid: | - @samples must be , not TRUE TRUE +PR1-anti-validator-alone reject msuiter_error_catalog counts must be a numeric matrix (channels x samples) | MsCatalog stores one count per channel and sample | received: numeric | tally variants with ms_tally() to obtain a count matrix TRUE TRUE +PR2-anchor-dims-over-labelmatch reject msuiter_error_catalog counts dimensions disagree with the registry snapshot or the samples | counts is channels x samples | nrow = 3 vs 4 labels; ncol = 2 vs 2 samples | align the count matrix with the registry labels and sample ids TRUE TRUE +PR2b-anchor-uniqueness-over-dims reject msuiter_error_catalog channel and sample labels must be unique | duplicated labels make label matching ambiguous | duplicated channel labels: 'CH1'; duplicated sample labels: (none) | de-duplicate or rename labels TRUE TRUE +PR3-anchor-uniqueness-over-finiteness reject msuiter_error_catalog channel and sample labels must be unique | duplicated labels make label matching ambiguous | duplicated channel labels: 'CH1'; duplicated sample labels: (none) | de-duplicate or rename labels TRUE TRUE +PR4-anchor-hashshape-over-truth reject msuiter_error_catalog the channel snapshot field 'hash' must be an md5 hex digest | the digest pins the channel table inside snapshot summaries (A5) | received: 'nothex00000000000000000000000000' | let ms_catalog() compute the hash; do not set it by hand TRUE TRUE +PR5-anchor-namedlaw-over-genomelaw reject msuiter_error_catalog catalog provenance must be a named list | provenance carries the genome build and tally context | received: list | provide at least genome = "" TRUE TRUE +PR5-anti-genomelaw-alone reject msuiter_error_catalog catalog provenance must carry the genome build as 'genome' | the build is required to query reference signatures | received: (none) | record the build, e.g. provenance = list(genome = "GRCh38") TRUE TRUE +PR6-anchor-collabel-mismatch-over-samplesanity reject msuiter_error_catalog sample labels of counts do not match the samples property | matching is by label, element by element, never by position | first offending labels: 'NA' | align colnames(counts) with the samples vector TRUE TRUE +PR6-anti-samplesanity-alone reject msuiter_error_catalog sample labels must be non-empty strings without NA | sample ids are identities matched by label | offending labels: 'NA' | provide one non-empty id per sample TRUE TRUE diff --git a/bench/scenarios/out/cs17_scalars.tsv b/bench/scenarios/out/cs17_scalars.tsv new file mode 100644 index 0000000..3f16982 --- /dev/null +++ b/bench/scenarios/out/cs17_scalars.tsv @@ -0,0 +1,11 @@ +key value +gate-class simpleError +storage-double double +storage-integer integer +hash-canonical d3b77a574c1e6afda429f0e14afcf4d1 +hash-minimal e10fea09c4590dfbcf05149c6d3157db +format-core CS17T: 4 channels x 2 samples +tail-int CS17T: 4 channels x 2 samples; skipped 7/42 variants +tail-dbl CS17T: 4 channels x 2 samples; skipped 7/42 variants +rng-before FALSE +rng-after FALSE diff --git a/bench/scenarios/out/cs17_specs.tsv b/bench/scenarios/out/cs17_specs.tsv new file mode 100644 index 0000000..00d05ec --- /dev/null +++ b/bench/scenarios/out/cs17_specs.tsv @@ -0,0 +1,7 @@ +arm mode cls msg +A1-accept-core accept s7:msuiter::MsCatalog msuiter::MsCatalog|4|2|double|TRUE|TRUE|d3b77a574c1e6afda429f0e14afcf4d1| CS17T: 4 channels x 2 samples +A2-accept-skipped-tail-int accept s7:msuiter::MsCatalog msuiter::MsCatalog|4|2|double|TRUE|TRUE|d3b77a574c1e6afda429f0e14afcf4d1| CS17T: 4 channels x 2 samples; skipped 7/42 variants +A3-accept-skipped-tail-dbl accept s7:msuiter::MsCatalog msuiter::MsCatalog|4|2|double|TRUE|TRUE|d3b77a574c1e6afda429f0e14afcf4d1| CS17T: 4 channels x 2 samples; skipped 7/42 variants +A5-accept-1x1-minimal accept s7:msuiter::MsCatalog msuiter::MsCatalog|1|1|double|TRUE|TRUE|e10fea09c4590dfbcf05149c6d3157db| CS17T: 1 channels x 1 samples +A4-accept-int-plant accept s7:msuiter::MsCatalog msuiter::MsCatalog|4|2|integer|TRUE|TRUE|d3b77a574c1e6afda429f0e14afcf4d1| CS17T: 4 channels x 2 samples +sp-replay-identity accept s7:character msuiter::MsCatalog|4|2|double|TRUE|TRUE|d3b77a574c1e6afda429f0e14afcf4d1| CS17T: 4 channels x 2 samples==msuiter::MsCatalog|4|2|double|TRUE|TRUE|d3b77a574c1e6afda429f0e14afcf4d1| CS17T: 4 channels x 2 samples diff --git a/bench/scenarios/run_catalog_witness.R b/bench/scenarios/run_catalog_witness.R new file mode 100644 index 0000000..1c47579 --- /dev/null +++ b/bench/scenarios/run_catalog_witness.R @@ -0,0 +1,744 @@ +# run_catalog_witness.R -- the CS-17 catalog-witness scenario (pillar 3). +# +# Mandate: plant synthetic governance-container calls (the D3 law: zero +# COSMIC numeric matrices, zero real-data bytes, zero downloads -- the +# catalog rides only as shape) and adjudicate the EXPORTED ms_catalog()/ +# MsCatalog face: the S7 property-gate split against the validator, the +# seventeen-arm "catalog" validator, the second error class the shared +# label digest reaches, the precedence discriminators with their anti +# anchors, the boundary contrast pairs and the acceptance specs. Every arm +# is driven through the exported faces alone; the accepted returns, the +# abort classes and the fired clauses are the face's own. The scenario +# consumes no RNG, no network and no clock at the adjudication core; the +# benchmark runner and the DECLINED calibration family are never invoked +# here. +# +# Framing law: DECISION RECORD only. The witnesses under out/ are the +# committed verdict of what the shipped face SAID on planted truth. Float +# posture (D11): integer, label, logical, class and clause bytes are +# byte-committed; the face produces no float payload columns (counts +# storage mode rides as a glyph, the label digest is hex), so no float +# glyph rides any witness. +# +# Rails: this runner carries the same frozen block as the law file +# (tests/testthat/test-scenario-catalog-witness.R), injected byte-identically +# from one minted source; every observed class, clause, shape and +# precedence order is rail-checked AS WE GO -- a drift fails the run +# before any witness is written. The witness bytes are written only after +# every payload census speaks; a byte-rerun must reproduce them identically. + +.script_dir <- local({ + a <- grep("^--file=(.*)$", commandArgs(FALSE), perl = TRUE, value = TRUE) + if (length(a) == 0L) return(getwd()) + f <- sub("^--file=", "", a[1L]) + if (!grepl("/", f, fixed = TRUE)) return(getwd()) + dirname(f) +}) +ROOT <- normalizePath(file.path(.script_dir, "..", ".."), mustWork = TRUE) +OUT <- file.path(ROOT, "bench", "scenarios", "out") + +if (requireNamespace("pkgload", quietly = TRUE) && + file.exists(file.path(ROOT, "DESCRIPTION"))) { + suppressWarnings(suppressMessages( + pkgload::load_all(ROOT, quiet = TRUE, export_all = TRUE))) +} else { + library(msuiter) +} +stopif <- function(cond, msg) if (isTRUE(cond)) stop(msg, call. = FALSE) +## RNG-STATE-RAIL: the adjudication core must never seed or consume RNG; +## the purity verdict rides the scalars witness (committed bytes below). +rng0 <- exists(".Random.seed", envir = globalenv(), inherits = TRUE) +## <> (minted mechanically from the audited ledger +## 2026-11-24; DO NOT hand-edit: regenerate via gen-frozen.cs17.R) ## +.CS17_LAW_ARMS <- c("G1-channels-nonlist", "G2-samples-noncharacter", "G3-provenance-nonlist", "V1-counts-vector", "V1b-counts-character-matrix", "V2-rownames-missing", "V2b-colnames-missing", "V3-rowlabels-dup", "V3b-collabels-dup", "V4-count-NA", "V4b-count-Inf", "V4c-count-NaN", "V5-count-negative", "V6-snap-missing-hash", "V6b-snap-missing-name", "V6c-snap-extra-field", "V6d-snap-empty-list", "V7-name-empty", "V7b-name-NA", "V7c-name-noncharacter", "V8-labels-NA-handhash", "V8b-labels-numeric", "V8c-label-empty-string", "V9-snap-labels-dup", "V13-hash-nonhex", "V13b-hash-noncharacter", "V13c-hash-NA", "V13d-hash-short-hex", "V14-hash-foreign", "V10-nrow-vs-labels", "V10b-ncol-vs-samples", "V11-rowlabel-decoy-permuted", "V12-colnames-vs-samples", "V15-sample-empty", "V15b-sample-NA", "V16-prov-unnamed", "V16b-prov-emptyname", "V17-genome-missing", "V17b-genome-empty", "X1-errorinput-autohash-NAlabels", "E2-NAinteger-label-trap", "U1-hashhelper-via-factory-listlabels") +.CS17_LAW_CLS <- c("simpleError", "simpleError", "simpleError", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_input", "msuiter_error_input", "msuiter_error_catalog") +.CS17_LAW_CLAUSES <- list() +.CS17_LAW_CLAUSES[["G1-channels-nonlist"]] <- paste0(" object properties are inval", + "id: | - @channels must be , not ") +.CS17_LAW_CLAUSES[["G2-samples-noncharacter"]] <- paste0(" object properties are inval", + "id: | - @samples must be , not ") +.CS17_LAW_CLAUSES[["G3-provenance-nonlist"]] <- paste0(" object properties are inval", + "id: | - @provenance must be , not ") +.CS17_LAW_CLAUSES[["V1-counts-vector"]] <- paste0("counts must be a numeric matrix (channels x samp", + "les) | MsCatalog stores one count per channel an", + "d sample | received: numeric | tally variants wi", + "th ms_tally() to obtain a count matrix") +.CS17_LAW_CLAUSES[["V1b-counts-character-matrix"]] <- paste0("counts must be a numeric matrix (channels x samp", + "les) | MsCatalog stores one count per channel an", + "d sample | received: matrix | tally variants wit", + "h ms_tally() to obtain a count matrix") +.CS17_LAW_CLAUSES[["V2-rownames-missing"]] <- paste0("counts must carry both channel labels (rownames)", + " and sample labels (colnames) | labels are the o", + "nly legal matching key (never position) | rownam", + "es missing: TRUE; colnames missing: FALSE | name", + " the matrix dimensions before constructing MsCat", + "alog") +.CS17_LAW_CLAUSES[["V2b-colnames-missing"]] <- paste0("counts must carry both channel labels (rownames)", + " and sample labels (colnames) | labels are the o", + "nly legal matching key (never position) | rownam", + "es missing: FALSE; colnames missing: TRUE | name", + " the matrix dimensions before constructing MsCat", + "alog") +.CS17_LAW_CLAUSES[["V3-rowlabels-dup"]] <- paste0("channel and sample labels must be unique | dupli", + "cated labels make label matching ambiguous | dup", + "licated channel labels: 'CH1'; duplicated sample", + " labels: (none) | de-duplicate or rename labels") +.CS17_LAW_CLAUSES[["V3b-collabels-dup"]] <- paste0("channel and sample labels must be unique | dupli", + "cated labels make label matching ambiguous | dup", + "licated channel labels: (none); duplicated sampl", + "e labels: 'S1' | de-duplicate or rename labels") +.CS17_LAW_CLAUSES[["V4-count-NA"]] <- paste0("counts must not contain NA or non-finite values ", + "| the FFI contract rejects NA; the catalog layer", + " adds no pseudo-counts | offending cells: '2' | ", + "fix the upstream tally output") +.CS17_LAW_CLAUSES[["V4b-count-Inf"]] <- paste0("counts must not contain NA or non-finite values ", + "| the FFI contract rejects NA; the catalog layer", + " adds no pseudo-counts | offending cells: '7' | ", + "fix the upstream tally output") +.CS17_LAW_CLAUSES[["V4c-count-NaN"]] <- paste0("counts must not contain NA or non-finite values ", + "| the FFI contract rejects NA; the catalog layer", + " adds no pseudo-counts | offending cells: '4' | ", + "fix the upstream tally output") +.CS17_LAW_CLAUSES[["V5-count-negative"]] <- paste0("counts must be non-negative | negative mutation ", + "counts are impossible | offending cells: '5' | c", + "heck the tally pipeline for subtraction errors") +.CS17_LAW_CLAUSES[["V6-snap-missing-hash"]] <- paste0("the channel snapshot must be a list with fields ", + "name, labels, hash | the snapshot keeps the regi", + "stry's canonical labels and their digest | recei", + "ved fields: 'name', 'labels' | construct the cat", + "alog through ms_catalog(), which slices the snap", + "shot") +.CS17_LAW_CLAUSES[["V6b-snap-missing-name"]] <- paste0("the channel snapshot must be a list with fields ", + "name, labels, hash | the snapshot keeps the regi", + "stry's canonical labels and their digest | recei", + "ved fields: 'labels', 'hash' | construct the cat", + "alog through ms_catalog(), which slices the snap", + "shot") +.CS17_LAW_CLAUSES[["V6c-snap-extra-field"]] <- paste0("the channel snapshot must be a list with fields ", + "name, labels, hash | the snapshot keeps the regi", + "stry's canonical labels and their digest | recei", + "ved fields: 'name', 'labels', 'hash', 'extra' | ", + "construct the catalog through ms_catalog(), whic", + "h slices the snapshot") +.CS17_LAW_CLAUSES[["V6d-snap-empty-list"]] <- paste0("the channel snapshot must be a list with fields ", + "name, labels, hash | the snapshot keeps the regi", + "stry's canonical labels and their digest | recei", + "ved fields: (none) | construct the catalog throu", + "gh ms_catalog(), which slices the snapshot") +.CS17_LAW_CLAUSES[["V7-name-empty"]] <- paste0("the channel snapshot field 'name' must be a sing", + "le non-empty string | the table name identifies ", + "the channel set (e.g. SBS96) | received: '' | pa", + "ss the registry table name, e.g. name = \"SBS96\"") +.CS17_LAW_CLAUSES[["V7b-name-NA"]] <- paste0("the channel snapshot field 'name' must be a sing", + "le non-empty string | the table name identifies ", + "the channel set (e.g. SBS96) | received: 'NA' | ", + "pass the registry table name, e.g. name = \"SBS96", + "\"") +.CS17_LAW_CLAUSES[["V7c-name-noncharacter"]] <- paste0("the channel snapshot field 'name' must be a sing", + "le non-empty string | the table name identifies ", + "the channel set (e.g. SBS96) | received: '5' | p", + "ass the registry table name, e.g. name = \"SBS96\"") +.CS17_LAW_CLAUSES[["V8-labels-NA-handhash"]] <- paste0("channel labels in the snapshot must be a charact", + "er vector without NA | channel labels are canoni", + "cal identities | received: character of length 4", + " with anyNA = TRUE | pass the canonical labels f", + "rom the channel registry") +.CS17_LAW_CLAUSES[["V8b-labels-numeric"]] <- paste0("channel labels in the snapshot must be a charact", + "er vector without NA | channel labels are canoni", + "cal identities | received: integer of length 4 w", + "ith anyNA = FALSE | pass the canonical labels fr", + "om the channel registry") +.CS17_LAW_CLAUSES[["V8c-label-empty-string"]] <- paste0("channel labels in the snapshot must be a charact", + "er vector without NA | channel labels are canoni", + "cal identities | received: character of length 4", + " with anyNA = FALSE | pass the canonical labels ", + "from the channel registry") +.CS17_LAW_CLAUSES[["V9-snap-labels-dup"]] <- paste0("channel labels in the snapshot must be unique | ", + "duplicated channel labels are not canonical orde", + "r | duplicated: 'CH1' | use the canonical regist", + "ry ordering") +.CS17_LAW_CLAUSES[["V13-hash-nonhex"]] <- paste0("the channel snapshot field 'hash' must be an md5", + " hex digest | the digest pins the channel table ", + "inside snapshot summaries (A5) | received: 'ZZzz", + "0000000000000000000000000000' | let ms_catalog()", + " compute the hash; do not set it by hand") +.CS17_LAW_CLAUSES[["V13b-hash-noncharacter"]] <- paste0("the channel snapshot field 'hash' must be an md5", + " hex digest | the digest pins the channel table ", + "inside snapshot summaries (A5) | received: '42' ", + "| let ms_catalog() compute the hash; do not set ", + "it by hand") +.CS17_LAW_CLAUSES[["V13c-hash-NA"]] <- paste0("the channel snapshot field 'hash' must be an md5", + " hex digest | the digest pins the channel table ", + "inside snapshot summaries (A5) | received: 'NA' ", + "| let ms_catalog() compute the hash; do not set ", + "it by hand") +.CS17_LAW_CLAUSES[["V13d-hash-short-hex"]] <- paste0("the channel snapshot field 'hash' must be an md5", + " hex digest | the digest pins the channel table ", + "inside snapshot summaries (A5) | received: 'd3b7", + "7a574c1e6afda429f0e14afcf4d' | let ms_catalog() ", + "compute the hash; do not set it by hand") +.CS17_LAW_CLAUSES[["V14-hash-foreign"]] <- paste0("the stored channel hash does not match the store", + "d labels | snapshot hashes must be derived, not ", + "asserted | stored: 2b947f5f7703ed9896680aa8bbe27", + "a7a | rebuild the catalog with ms_catalog()") +.CS17_LAW_CLAUSES[["V10-nrow-vs-labels"]] <- paste0("counts dimensions disagree with the registry sna", + "pshot or the samples | counts is channels x samp", + "les | nrow = 3 vs 4 labels; ncol = 2 vs 2 sample", + "s | align the count matrix with the registry lab", + "els and sample ids") +.CS17_LAW_CLAUSES[["V10b-ncol-vs-samples"]] <- paste0("counts dimensions disagree with the registry sna", + "pshot or the samples | counts is channels x samp", + "les | nrow = 4 vs 4 labels; ncol = 3 vs 2 sample", + "s | align the count matrix with the registry lab", + "els and sample ids") +.CS17_LAW_CLAUSES[["V11-rowlabel-decoy-permuted"]] <- paste0("channel labels of counts do not match the regist", + "ry snapshot | matching is by label, element by e", + "lement, never by position | first offending labe", + "ls: 'CH2', 'CH1' | reorder or rename counts rows", + " to the canonical registry labels") +.CS17_LAW_CLAUSES[["V12-colnames-vs-samples"]] <- paste0("sample labels of counts do not match the samples", + " property | matching is by label, element by ele", + "ment, never by position | first offending labels", + ": 'SX' | align colnames(counts) with the samples", + " vector") +.CS17_LAW_CLAUSES[["V15-sample-empty"]] <- paste0("sample labels must be non-empty strings without ", + "NA | sample ids are identities matched by label ", + "| offending labels: '' | provide one non-empty i", + "d per sample") +.CS17_LAW_CLAUSES[["V15b-sample-NA"]] <- paste0("sample labels must be non-empty strings without ", + "NA | sample ids are identities matched by label ", + "| offending labels: 'NA' | provide one non-empty", + " id per sample") +.CS17_LAW_CLAUSES[["V16-prov-unnamed"]] <- paste0("catalog provenance must be a named list | proven", + "ance carries the genome build and tally context ", + "| received: list | provide at least genome = \"\"") +.CS17_LAW_CLAUSES[["V16b-prov-emptyname"]] <- paste0("catalog provenance must be a named list | proven", + "ance carries the genome build and tally context ", + "| received: list | provide at least genome = \"\"") +.CS17_LAW_CLAUSES[["V17-genome-missing"]] <- paste0("catalog provenance must carry the genome build a", + "s 'genome' | the build is required to query refe", + "rence signatures | received: (none) | record the", + " build, e.g. provenance = list(genome = \"GRCh38\"", + ")") +.CS17_LAW_CLAUSES[["V17b-genome-empty"]] <- paste0("catalog provenance must carry the genome build a", + "s 'genome' | the build is required to query refe", + "rence signatures | received: '' | record the bui", + "ld, e.g. provenance = list(genome = \"GRCh38\")") +.CS17_LAW_CLAUSES[["X1-errorinput-autohash-NAlabels"]] <- paste0("channel labels to hash must be a character vecto", + "r without NA | the label digest is only defined ", + "for plain label vectors | received: character wi", + "th anyNA = TRUE | pass the canonical channel lab", + "els (character, NA free)") +.CS17_LAW_CLAUSES[["E2-NAinteger-label-trap"]] <- paste0("channel labels to hash must be a character vecto", + "r without NA | the label digest is only defined ", + "for plain label vectors | received: character wi", + "th anyNA = TRUE | pass the canonical channel lab", + "els (character, NA free)") +.CS17_LAW_CLAUSES[["U1-hashhelper-via-factory-listlabels"]] <- paste0("counts dimensions disagree with the registry sna", + "pshot or the samples | counts is channels x samp", + "les | nrow = 4 vs 2 labels; ncol = 2 vs 2 sample", + "s | align the count matrix with the registry lab", + "els and sample ids") +.CS17_SPEC_ARMS <- c("A1-accept-core", "A2-accept-skipped-tail-int", "A3-accept-skipped-tail-dbl", "A5-accept-1x1-minimal", "A4-accept-int-plant", "sp-replay-identity") +.CS17_SPEC_CLS <- c("s7:msuiter::MsCatalog", "s7:msuiter::MsCatalog", "s7:msuiter::MsCatalog", "s7:msuiter::MsCatalog", "s7:msuiter::MsCatalog", "s7:character") +.CS17_SPEC_DETAILS <- list() +.CS17_SPEC_DETAILS[["A1-accept-core"]] <- paste0("msuiter::MsCatalog|4|2|double|TRUE|TRUE|d3b77a57", + "4c1e6afda429f0e14afcf4d1| CS17T: 4 ch", + "annels x 2 samples") +.CS17_SPEC_DETAILS[["A2-accept-skipped-tail-int"]] <- paste0("msuiter::MsCatalog|4|2|double|TRUE|TRUE|d3b77a57", + "4c1e6afda429f0e14afcf4d1| CS17T: 4 ch", + "annels x 2 samples; skipped 7/42 variants") +.CS17_SPEC_DETAILS[["A3-accept-skipped-tail-dbl"]] <- paste0("msuiter::MsCatalog|4|2|double|TRUE|TRUE|d3b77a57", + "4c1e6afda429f0e14afcf4d1| CS17T: 4 ch", + "annels x 2 samples; skipped 7/42 variants") +.CS17_SPEC_DETAILS[["A5-accept-1x1-minimal"]] <- paste0("msuiter::MsCatalog|1|1|double|TRUE|TRUE|e10fea09", + "c4590dfbcf05149c6d3157db| CS17T: 1 ch", + "annels x 1 samples") +.CS17_SPEC_DETAILS[["A4-accept-int-plant"]] <- paste0("msuiter::MsCatalog|4|2|integer|TRUE|TRUE|d3b77a5", + "74c1e6afda429f0e14afcf4d1| CS17T: 4 c", + "hannels x 2 samples") +.CS17_SPEC_DETAILS[["sp-replay-identity"]] <- paste0("msuiter::MsCatalog|4|2|double|TRUE|TRUE|d3b77a57", + "4c1e6afda429f0e14afcf4d1| CS17T: 4 ch", + "annels x 2 samples==msuiter::MsCatalog|4|2|doubl", + "e|TRUE|TRUE|d3b77a574c1e6afda429f0e14afcf4d1| CS17T: 4 channels x 2 samples") +.CS17_PREC_ARMS <- c("PR1-anchor-gate-over-validator", "PR1-anti-validator-alone", "PR2-anchor-dims-over-labelmatch", "PR2b-anchor-uniqueness-over-dims", "PR3-anchor-uniqueness-over-finiteness", "PR4-anchor-hashshape-over-truth", "PR5-anchor-namedlaw-over-genomelaw", "PR5-anti-genomelaw-alone", "PR6-anchor-collabel-mismatch-over-samplesanity", "PR6-anti-samplesanity-alone") +.CS17_PREC_CLS <- c("simpleError", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog") +.CS17_PREC_FIRES <- c("- @samples must be , not ", "counts must be a numeric matrix (channels x samples)", "counts dimensions disagree with the registry snapshot or the samples", "channel and sample labels must be unique", "channel and sample labels must be unique", "the channel snapshot field 'hash' must be an md5 hex digest", "catalog provenance must be a named list", "catalog provenance must carry the genome build as 'genome'", "sample labels of counts do not match the samples property", "sample labels must be non-empty strings without NA") +.CS17_PREC_ANTI <- c("counts must be a numeric matrix (channels x samples)", " object properties are invalid:", "channel and sample labels must be unique", "counts dimensions disagree with the registry snapshot or the samples", "counts must not contain NA or non-finite values", "the stored channel hash does not match the stored labels", "catalog provenance must carry the genome build as 'genome'", "catalog provenance must be a named list", "sample labels must be non-empty strings without NA", "sample labels of counts do not match the samples property") +.CS17_DEGEN_PAIR <- c("empty-boundary", "empty-boundary", "rowlaw-split", "rowlaw-split", "minimal-vs-empty", "minimal-vs-empty", "skipped-tail", "skipped-tail") +.CS17_DEGEN_SIDE <- c("hi", "lo", "hi", "lo", "hi", "lo", "hi", "lo") +.CS17_DEGEN_ARMS <- c("empty-queue-hi", "zero-channels-lo", "rowlabel-uniqueness-hi", "rownames-missing-lo", "minimal-1x1-hi", "empty-4x0-lo", "skipped-tail-hi", "core-nontail-lo") +.CS17_DEGEN_MODE <- c("accept", "reject", "reject", "reject", "accept", "accept", "accept", "accept") +.CS17_DEGEN_CLS <- c("s7:msuiter::MsCatalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "s7:msuiter::MsCatalog", "s7:msuiter::MsCatalog", "s7:msuiter::MsCatalog", "s7:msuiter::MsCatalog") +.CS17_DEGEN_MSG <- list() +.CS17_DEGEN_MSG[["empty-queue-hi"]] <- paste0("msuiter::MsCatalog|4|0|double|TRUE|FALSE|d3b77a5", + "74c1e6afda429f0e14afcf4d1| CS17T: 4 c", + "hannels x 0 samples") +.CS17_DEGEN_MSG[["zero-channels-lo"]] <- paste0("counts must carry both channel labels (rownames)", + " and sample labels (colnames) | labels are the o", + "nly legal matching key (never position) | rownam", + "es missing: TRUE; colnames missing: FALSE | name", + " the matrix dimensions before constructing MsCat", + "alog") +.CS17_DEGEN_MSG[["rowlabel-uniqueness-hi"]] <- paste0("channel and sample labels must be unique | dupli", + "cated labels make label matching ambiguous | dup", + "licated channel labels: 'CH1'; duplicated sample", + " labels: (none) | de-duplicate or rename labels") +.CS17_DEGEN_MSG[["rownames-missing-lo"]] <- paste0("counts must carry both channel labels (rownames)", + " and sample labels (colnames) | labels are the o", + "nly legal matching key (never position) | rownam", + "es missing: TRUE; colnames missing: FALSE | name", + " the matrix dimensions before constructing MsCat", + "alog") +.CS17_DEGEN_MSG[["minimal-1x1-hi"]] <- paste0("msuiter::MsCatalog|1|1|double|TRUE|TRUE|e10fea09", + "c4590dfbcf05149c6d3157db| CS17T: 1 ch", + "annels x 1 samples") +.CS17_DEGEN_MSG[["empty-4x0-lo"]] <- paste0("msuiter::MsCatalog|4|0|double|TRUE|FALSE|d3b77a5", + "74c1e6afda429f0e14afcf4d1| CS17T: 4 c", + "hannels x 0 samples") +.CS17_DEGEN_MSG[["skipped-tail-hi"]] <- paste0("msuiter::MsCatalog|4|2|double|TRUE|TRUE|d3b77a57", + "4c1e6afda429f0e14afcf4d1| CS17T: 4 ch", + "annels x 2 samples; skipped 7/42 variants") +.CS17_DEGEN_MSG[["core-nontail-lo"]] <- paste0("msuiter::MsCatalog|4|2|double|TRUE|TRUE|d3b77a57", + "4c1e6afda429f0e14afcf4d1| CS17T: 4 ch", + "annels x 2 samples") +.CS17_SCAL_KEYS <- c("gate-class", "storage-double", "storage-integer", "hash-canonical", "hash-minimal", "format-core", "tail-int", "tail-dbl", "rng-before", "rng-after") +.CS17_SCAL_VALS <- list() +.CS17_SCAL_VALS[["gate-class"]] <- "simpleError" +.CS17_SCAL_VALS[["storage-double"]] <- "double" +.CS17_SCAL_VALS[["storage-integer"]] <- "integer" +.CS17_SCAL_VALS[["hash-canonical"]] <- "d3b77a574c1e6afda429f0e14afcf4d1" +.CS17_SCAL_VALS[["hash-minimal"]] <- "e10fea09c4590dfbcf05149c6d3157db" +.CS17_SCAL_VALS[["format-core"]] <- " CS17T: 4 channels x 2 samples" +.CS17_SCAL_VALS[["tail-int"]] <- paste0(" CS17T: 4 channels x 2 samples; skipp", + "ed 7/42 variants") +.CS17_SCAL_VALS[["tail-dbl"]] <- paste0(" CS17T: 4 channels x 2 samples; skipp", + "ed 7/42 variants") +.CS17_SCAL_VALS[["rng-before"]] <- "FALSE" +.CS17_SCAL_VALS[["rng-after"]] <- "FALSE" +.CS17_SCAL_REFIRE <- list( + +"gate-class" = "MsCatalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = 1:2, provenance = .CS17_PROV)", + +"storage-double" = "storage.mode(.cs17_counts())", + +"storage-integer" = "storage.mode(.cs17_counts(int = TRUE))", + +"hash-canonical" = "msuiter_hash_labels(.CS17_LBL)", + +"hash-minimal" = "msuiter_hash_labels(\"CH1\")", + +"format-core" = "format(ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV))", + +"tail-int" = "format(ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = {p <- .CS17_PROV; p$n_skipped <- 7L; p$n_variants <- 42L; p}))", + +"tail-dbl" = "format(ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = {p <- .CS17_PROV; p$n_skipped <- 7; p$n_variants <- 42; p}))" +) +.CS17_ARM <- list( + +"G1-channels-nonlist" = "MsCatalog(counts = .cs17_counts(), channels = \"SBS\", samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"G2-samples-noncharacter" = "MsCatalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = 1:2, provenance = .CS17_PROV)", + +"G3-provenance-nonlist" = "MsCatalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = \"GRCh38\")", + +"V1-counts-vector" = "ms_catalog(counts = as.numeric(1:8), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V1b-counts-character-matrix" = "ms_catalog(counts = matrix(c(\"a\", \"b\", \"c\", \"d\"), 2L, 2L, dimnames = list(.CS17_LBL[1:2], .CS17_SAMP)), channels = .cs17_snap(labels = .CS17_LBL[1:2]), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V2-rownames-missing" = "ms_catalog(counts = matrix(as.numeric(1:8), 4L, 2L, dimnames = list(NULL, .CS17_SAMP)), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V2b-colnames-missing" = "ms_catalog(counts = matrix(as.numeric(1:8), 4L, 2L, dimnames = list(.CS17_LBL, NULL)), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V3-rowlabels-dup" = "ms_catalog(counts = .cs17_counts(lab = c(.CS17_LBL[1], .CS17_LBL[1:3])), channels = .cs17_snap(labels = c(.CS17_LBL[1], .CS17_LBL[1:3])), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V3b-collabels-dup" = "ms_catalog(counts = matrix(as.numeric(1:8), 4L, 2L, dimnames = list(.CS17_LBL, c(\"S1\", \"S1\"))), channels = .cs17_snap(), samples = c(\"S1\", \"S1\"), provenance = .CS17_PROV)", + +"V4-count-NA" = "ms_catalog(counts = {m <- .cs17_counts(); m[2, 1] <- NA; m}, channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V4b-count-Inf" = "ms_catalog(counts = {m <- .cs17_counts(); m[3, 2] <- Inf; m}, channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V4c-count-NaN" = "ms_catalog(counts = {m <- .cs17_counts(); m[4, 1] <- NaN; m}, channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V5-count-negative" = "ms_catalog(counts = {m <- .cs17_counts(); m[1, 2] <- -7; m}, channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V6-snap-missing-hash" = "MsCatalog(counts = .cs17_counts(), channels = list(name = .CS17_TAB, labels = .CS17_LBL), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V6b-snap-missing-name" = "MsCatalog(counts = .cs17_counts(), channels = list(labels = .CS17_LBL, hash = msuiter_hash_labels(.CS17_LBL)), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V6c-snap-extra-field" = "MsCatalog(counts = .cs17_counts(), channels = c(.cs17_snap(), list(extra = 1)), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V6d-snap-empty-list" = "MsCatalog(counts = .cs17_counts(), channels = list(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V7-name-empty" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$name <- \"\"; s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V7b-name-NA" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$name <- NA_character_; s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V7c-name-noncharacter" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$name <- 5; s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V8-labels-NA-handhash" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(labels = c(.CS17_LBL[1:3], NA_character_), hash = .cs17_zero32()); s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"X1-errorinput-autohash-NAlabels" = "MsCatalog(counts = .cs17_counts(), channels = .cs17_snap(labels = c(.CS17_LBL[1:3], NA_character_)), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V8b-labels-numeric" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$labels <- 1:4; s$hash <- msuiter_hash_labels(as.character(1:4)); s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V8c-label-empty-string" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$labels <- c(.CS17_LBL[1:3], \"\"); s$hash <- msuiter_hash_labels(c(.CS17_LBL[1:3], \"\")); s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V9-snap-labels-dup" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(labels = .CS17_LBL, hash = .cs17_zero32()); s$labels <- c(.CS17_LBL[1:3], .CS17_LBL[1]); s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V13-hash-nonhex" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$hash <- \"ZZzz0000000000000000000000000000\"; s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V13b-hash-noncharacter" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$hash <- 42; s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V13c-hash-NA" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$hash <- NA_character_; s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V13d-hash-short-hex" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$hash <- substr(s$hash, 1L, 31L); s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V14-hash-foreign" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$hash <- msuiter_hash_labels(paste0(\"X\", 1:4)); s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V10-nrow-vs-labels" = "ms_catalog(counts = .cs17_counts(lab = .CS17_LBL[1:3]), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V10b-ncol-vs-samples" = "ms_catalog(counts = matrix(as.numeric(1:12), 4L, 3L, dimnames = list(.CS17_LBL, paste0(\"S\", 1:3))), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V11-rowlabel-decoy-permuted" = "ms_catalog(counts = .cs17_counts(lab = c(.CS17_LBL[2], .CS17_LBL[1], .CS17_LBL[3:4])), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V12-colnames-vs-samples" = "ms_catalog(counts = matrix(as.numeric(1:8), 4L, 2L, dimnames = list(.CS17_LBL, c(\"S1\", \"SX\"))), channels = .cs17_snap(), samples = c(\"S1\", \"S2\"), provenance = .CS17_PROV)", + +"V15-sample-empty" = "ms_catalog(counts = matrix(as.numeric(1:8), 4L, 2L, dimnames = list(.CS17_LBL, c(\"S1\", \"\"))), channels = .cs17_snap(), samples = c(\"S1\", \"\"), provenance = .CS17_PROV)", + +"V15b-sample-NA" = "ms_catalog(counts = matrix(as.numeric(1:8), 4L, 2L, dimnames = list(.CS17_LBL, c(\"S1\", NA_character_))), channels = .cs17_snap(), samples = c(\"S1\", NA_character_), provenance = .CS17_PROV)", + +"V16-prov-unnamed" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = list(\"GRCh38\"))", + +"V16b-prov-emptyname" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = {p <- list(\"GRCh38\"); names(p) <- \"\"; p})", + +"V17-genome-missing" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = list(build = \"GRCh38\"))", + +"V17b-genome-empty" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = list(genome = \"\"))", + +"E1-empty-legal-queue" = "ms_catalog(counts = matrix(numeric(0), length(.CS17_LBL), 0L, dimnames = list(.CS17_LBL, NULL)), channels = .cs17_snap(), samples = character(0), provenance = .CS17_PROV)", + +"E1b-zero-channels" = "ms_catalog(counts = matrix(numeric(0), 0L, 0L, dimnames = list(NULL, NULL)), channels = list(name = .CS17_TAB, labels = NULL), samples = character(0), provenance = .CS17_PROV)", + +"E2-NAinteger-label-trap" = "ms_catalog(counts = .cs17_counts(lab = c(\"NA\", .CS17_LBL[1:3])), channels = list(name = .CS17_TAB, labels = c(NA_integer_, .CS17_LBL[1:3])), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"PR1-anchor-gate-over-validator" = "MsCatalog(counts = as.numeric(1:8), channels = .cs17_snap(), samples = 1:2, provenance = .CS17_PROV)", + +"PR1-anti-validator-alone" = "ms_catalog(counts = as.numeric(1:8), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"PR2-anchor-dims-over-labelmatch" = "ms_catalog(counts = .cs17_counts(lab = c(.CS17_LBL[2], .CS17_LBL[1], .CS17_LBL[3])), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"PR2b-anchor-uniqueness-over-dims" = "ms_catalog(counts = .cs17_counts(lab = c(.CS17_LBL[1], .CS17_LBL[1], .CS17_LBL[2])), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"PR3-anchor-uniqueness-over-finiteness" = "ms_catalog(counts = {m <- .cs17_counts(lab = c(.CS17_LBL[1], .CS17_LBL[1:3])); m[1, 1] <- NA; m}, channels = .cs17_snap(labels = c(.CS17_LBL[1], .CS17_LBL[1:3])), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"PR4-anchor-hashshape-over-truth" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$hash <- \"nothex00000000000000000000000000\"; s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"PR5-anchor-namedlaw-over-genomelaw" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = list(\"GRCh38\"))", + +"PR5-anti-genomelaw-alone" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = list(build = \"GRCh38\"))", + +"PR6-anchor-collabel-mismatch-over-samplesanity" = "ms_catalog(counts = matrix(as.numeric(1:8), 4L, 2L, dimnames = list(.CS17_LBL, c(\"S1\", \"SX\"))), channels = .cs17_snap(), samples = c(\"S1\", NA_character_), provenance = .CS17_PROV)", + +"PR6-anti-samplesanity-alone" = "ms_catalog(counts = matrix(as.numeric(1:8), 4L, 2L, dimnames = list(.CS17_LBL, c(\"S1\", NA_character_))), channels = .cs17_snap(), samples = c(\"S1\", NA_character_), provenance = .CS17_PROV)", + +"A1-accept-core" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"A2-accept-skipped-tail-int" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = {p <- .CS17_PROV; p$n_skipped <- 7L; p$n_variants <- 42L; p})", + +"A3-accept-skipped-tail-dbl" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = {p <- .CS17_PROV; p$n_skipped <- 7; p$n_variants <- 42; p})", + +"A5-accept-1x1-minimal" = "ms_catalog(counts = matrix(1, 1L, 1L, dimnames = list(\"CH1\", \"S1\")), channels = list(name = \"CS17T\", labels = \"CH1\"), samples = \"S1\", provenance = .CS17_PROV)", + +"A4-accept-int-plant" = "ms_catalog(counts = {mm <- matrix(1:8, 4L, 2L, dimnames = list(.CS17_LBL, .CS17_SAMP)); mm}, channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"sp-replay-identity" = "paste0(.cs17_render(ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)), \"==\", .cs17_render(ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)))", + +"U1-hashhelper-via-factory-listlabels" = "ms_catalog(counts = .cs17_counts(), channels = list(name = .CS17_TAB, labels = list(1, 2)), samples = .CS17_SAMP, provenance = .CS17_PROV)" +, +"empty-queue-hi" = "ms_catalog(counts = matrix(numeric(0), length(.CS17_LBL), 0L, dimnames = list(.CS17_LBL, NULL)), channels = .cs17_snap(), samples = character(0), provenance = .CS17_PROV)" +, +"zero-channels-lo" = "ms_catalog(counts = matrix(numeric(0), 0L, 0L, dimnames = list(NULL, NULL)), channels = list(name = .CS17_TAB, labels = NULL), samples = character(0), provenance = .CS17_PROV)" +, +"rowlabel-uniqueness-hi" = "ms_catalog(counts = .cs17_counts(lab = c(.CS17_LBL[1], .CS17_LBL[1:3])), channels = .cs17_snap(labels = c(.CS17_LBL[1], .CS17_LBL[1:3])), samples = .CS17_SAMP, provenance = .CS17_PROV)" +, +"rownames-missing-lo" = "ms_catalog(counts = matrix(as.numeric(1:8), 4L, 2L, dimnames = list(NULL, .CS17_SAMP)), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)" +, +"minimal-1x1-hi" = "ms_catalog(counts = matrix(1, 1L, 1L, dimnames = list(\"CH1\", \"S1\")), channels = list(name = \"CS17T\", labels = \"CH1\"), samples = \"S1\", provenance = .CS17_PROV)" +, +"empty-4x0-lo" = "ms_catalog(counts = matrix(numeric(0), length(.CS17_LBL), 0L, dimnames = list(.CS17_LBL, NULL)), channels = .cs17_snap(), samples = character(0), provenance = .CS17_PROV)" +, +"skipped-tail-hi" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = {p <- .CS17_PROV; p$n_skipped <- 7L; p$n_variants <- 42L; p})" +, +"core-nontail-lo" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)" +) +.CS17_CENSUS <- c("msuiter_error_catalog=49", "msuiter_error_input=2", "s7:character=1", "s7:msuiter::MsCatalog=10", "simpleError=4") +## <> ## + +## <> (single source: injected byte-identically into +## the law file and the runner; edit /tmp/p6gate/cs17-shared.R and +## re-splice via splice-cs17.R -- never hand-edit in place) +## cs17-shared.R -- single source of the CS-17 catalog-witness shared block. +## Injected byte-identically into tests/testthat/test-scenario-catalog-witness.R +## and bench/scenarios/run_catalog_witness.R between the SHARED markers. +## Pure, deterministic, no RNG, no clock, no network: the condition-message +## pipeline plus the exported-face verdict render and the plant builders the +## frozen ARM texts call. +.cs17_describe <- function(e) trimws(gsub("\n", " | ", + paste(as.character(conditionMessage(e)), collapse = " | "), fixed = TRUE)) +.cs17_strip <- function(s) { + for (b in c("ℹ ", "i ")) s <- gsub(b, "", s, fixed = TRUE) + s +} +.cs17_render <- function(x) paste0(c( + paste0(class(x)[1L]), + paste0(nrow(x@counts)), paste0(ncol(x@counts)), + storage.mode(x@counts), + paste0(identical(rownames(x@counts), x@channels$labels)), + paste0(identical(colnames(x@counts), x@samples)), + x@channels$hash, + format(x)), collapse = "|") +.cs17_eval1 <- function(txt, tag) { + if (is.na(txt) || !nzchar(txt)) stop(".cs17_eval1: no text for ", tag) + ex <- parse(text = txt) + if (length(ex) != 1L) { + stop(".cs17_eval1: ", tag, " is not a single expression") + } + tryCatch(list(ok = TRUE, v = eval(ex[[1L]])), error = identity) +} +.cs17_verdict <- function(arm, r) { + if (inherits(r, "error")) { + list(arm = arm, mode = "reject", cls = class(r)[1L], + msg = gsub("\t", " ", .cs17_strip(.cs17_describe(r)), fixed = TRUE)) + } else { + rendered <- if (is.character(r)) r else .cs17_render(r) + list(arm = arm, mode = "accept", cls = paste0("s7:", class(r)[1L]), + msg = gsub("\t", " ", rendered, fixed = TRUE)) + } +} +.cs17_fire <- function(arm) { + r <- .cs17_eval1(.CS17_ARM[[arm]], arm) + .cs17_verdict(arm, if (inherits(r, "error")) r else r$v) +} +.cs17_clean <- function(df) { + ## witness bytes round-trip nameless through read.csv; strip any vapply + ## residue names so identical() compares columns byte-true + for (cnm in names(df)) attr(df[[cnm]], "names") <- NULL + df +} +.cs17_rows <- function(arms) { + vs <- lapply(arms, function(a) .cs17_fire(a)) + .cs17_clean(data.frame(arm = arms, + mode = vapply(vs, function(z) z$mode, character(1L)), + cls = vapply(vs, function(z) z$cls, character(1L)), + msg = vapply(vs, function(z) z$msg, character(1L)), + stringsAsFactors = FALSE)) +} +.cs17_lawrows <- function() .cs17_rows(.CS17_LAW_ARMS) +.cs17_specrows <- function() .cs17_rows(.CS17_SPEC_ARMS) +.cs17_precrows <- function() { + base <- .cs17_rows(.CS17_PREC_ARMS) + base$fires_ok <- unname(vapply(seq_along(base$arm), function(i) { + paste0(grepl(.CS17_PREC_FIRES[i], base$msg[i], fixed = TRUE)) + }, character(1L))) + base$anti_ok <- unname(vapply(seq_along(base$arm), function(i) { + paste0(!grepl(.CS17_PREC_ANTI[i], base$msg[i], fixed = TRUE)) + }, character(1L))) + base +} +.cs17_degenrows <- function() { + vs <- lapply(.CS17_DEGEN_ARMS, function(a) .cs17_fire(a)) + .cs17_clean(data.frame(pair = .CS17_DEGEN_PAIR, side = .CS17_DEGEN_SIDE, + arm = .CS17_DEGEN_ARMS, + mode = vapply(vs, function(z) z$mode, character(1L)), + cls = vapply(vs, function(z) z$cls, character(1L)), + msg = vapply(vs, function(z) z$msg, character(1L)), + stringsAsFactors = FALSE)) +} +.cs17_scalval <- function(k) { + txt <- .CS17_SCAL_REFIRE[[k]] + if (is.null(txt)) return(NA_character_) + res <- .cs17_eval1(txt, k) + if (inherits(res, "error")) { + if (identical(k, "gate-class")) return(paste0(class(res)[1L])) + return(.cs17_strip(.cs17_describe(res))) + } + paste0(res$v) +} +.cs17_scalref_keys <- function() names(.CS17_SCAL_REFIRE) +.cs17_plant_text <- function() { + ord <- c(.CS17_LAW_ARMS, .CS17_SPEC_ARMS, .CS17_PREC_ARMS, .CS17_DEGEN_ARMS) + paste0(vapply(ord, function(a) + paste0(a, "=", .CS17_ARM[[a]]), character(1L)), collapse = ";") +} +.cs17_spec_text <- function() paste0(.CS17_SPEC_ARMS, collapse = ";") +## ---- deterministic plant builders (no RNG, no clock, no network) ---------- +.CS17_TAB <- "CS17T" +.CS17_LBL <- c("CH1", "CH2", "CH3", "CH4") +.CS17_SAMP <- c("S1", "S2") +.CS17_PROV <- list(genome = "GRCh38") +.cs17_counts <- function(lab = .CS17_LBL, smp = .CS17_SAMP, int = FALSE) { + nr <- length(lab); nc <- length(smp) + vals <- if (nr * nc == 0L) { + if (int) integer(0L) else numeric(0L) + } else if (int) { + seq_len(nr * nc) + } else { + as.numeric(seq_len(nr * nc)) + } + matrix(vals, nr, nc, + dimnames = list(if (nr) lab else NULL, if (nc) smp else NULL)) +} +.cs17_snap <- function(name = .CS17_TAB, labels = .CS17_LBL, hash = NULL) { + if (is.null(hash)) hash <- msuiter_hash_labels(as.character(labels)) + list(name = name, labels = labels, hash = hash) +} +.cs17_zero32 <- function() paste0(rep_len("0", 32L), collapse = "") +## <> (do not hand-edit in place: edit the source and +## re-splice) ## + + +## --------------------------------------------------------------------------- +## writers, census and the dual-kernel hash rail +## --------------------------------------------------------------------------- +.wtab <- function(nm, df) { + con <- file(file.path(OUT, nm), open = "wb") + on.exit(close(con)) + write.table(df, con, sep = "\t", quote = FALSE, row.names = FALSE, na = "") + invisible(nm) +} +.census <- function(nm, df, want.rows, key.col = 1L) { + stopif(nrow(df) != want.rows, paste0("census ", nm, ": rows ", nrow(df))) + stopif(any(duplicated(df[[key.col]])), paste0("census ", nm, ": duplicate keys")) + for (cnm in names(df)) { + col <- df[[cnm]] + bad <- !is.character(col) || any(is.na(col)) || any(!nzchar(col)) || + any(grepl("\t", col, fixed = TRUE)) + stopif(bad, paste0("census ", nm, ".", cnm, ": non-character/NA/empty/tab")) + } + invisible(TRUE) +} +.ck <- function(bytes, tag) { + a <- .ms_fit_sha256(bytes) + b <- digest::digest(bytes, algo = "sha256", serialize = FALSE) + stopif(!identical(a, b), paste0("ck: kernel disagreement on ", tag)) + stopif(!grepl("^[0-9a-f]{64}$", a), paste0("ck: hex policy on ", tag)) + stopif(nchar(a) != 64L, paste0("ck: length on ", tag)) + a +} +.file.sha <- function(nm) { + p <- file.path(OUT, nm) + con <- file(p, open = "rb") + on.exit(close(con)) + bytes <- readBin(con, what = raw(), n = file.size(p)) + .ck(bytes, nm) +} + +## --------------------------------------------------------------------------- +## build the five witness tables, rail-checked against the frozen block +## --------------------------------------------------------------------------- +dir.create(OUT, showWarnings = FALSE, recursive = TRUE) + +laws <- .cs17_lawrows() +stopif(!identical(laws$arm, .CS17_LAW_ARMS), "laws: roster drift") +stopif(!identical(laws$mode, rep("reject", 42L)), "laws: a mode drift") +stopif(!identical(laws$cls, .CS17_LAW_CLS), "laws: a class drift") +stopif(!identical(laws$msg, unname(vapply(.CS17_LAW_ARMS, + function(a) .CS17_LAW_CLAUSES[[a]], character(1L)))), "laws: clause byte drift") +.census("laws", laws, 42L) + +specs <- .cs17_specrows() +stopif(!identical(specs$arm, .CS17_SPEC_ARMS), "specs: roster drift") +stopif(!identical(specs$mode, rep("accept", 6L)), "specs: a mode drift") +stopif(!identical(specs$cls, .CS17_SPEC_CLS), "specs: a class drift") +stopif(!identical(specs$msg, unname(vapply(.CS17_SPEC_ARMS, + function(a) .CS17_SPEC_DETAILS[[a]], character(1L)))), "specs: detail byte drift") +stopif(!identical(specs$msg[match("A2-accept-skipped-tail-int", specs$arm)], + specs$msg[match("A3-accept-skipped-tail-dbl", specs$arm)]), + "specs: dual-kernel tail disagreement") +stopif(!grepl("|integer|", specs$msg[match("A4-accept-int-plant", specs$arm)], + fixed = TRUE), "specs: the integer plant lost its storage glyph") +.census("specs", specs, 6L) + +prec <- .cs17_precrows() +stopif(!identical(prec$arm, .CS17_PREC_ARMS), "prec: roster drift") +stopif(!identical(prec$mode, rep("reject", 10L)), "prec: a mode drift") +stopif(!identical(prec$cls, .CS17_PREC_CLS), "prec: a class drift") +stopif(!all(prec$fires_ok == "TRUE"), "prec: a fired anchor missing") +stopif(!all(prec$anti_ok == "TRUE"), "prec: an anti anchor present") +for (i in seq_len(10L)) { + stopif(!grepl(.CS17_PREC_FIRES[i], prec$msg[i], fixed = TRUE), + paste0("prec: fire anchor absent in ", .CS17_PREC_ARMS[i])) + stopif(grepl(.CS17_PREC_ANTI[i], prec$msg[i], fixed = TRUE), + paste0("prec: anti anchor present in ", .CS17_PREC_ARMS[i])) +} +.census("prec", prec, 10L) + +degen <- .cs17_degenrows() +stopif(!identical(degen$pair, .CS17_DEGEN_PAIR), "degen: pair drift") +stopif(!identical(degen$side, .CS17_DEGEN_SIDE), "degen: side drift") +stopif(!identical(degen$arm, .CS17_DEGEN_ARMS), "degen: arm drift") +stopif(!identical(degen$mode, .CS17_DEGEN_MODE), "degen: mode drift") +stopif(!identical(degen$cls, .CS17_DEGEN_CLS), "degen: class drift") +stopif(!identical(degen$msg, unname(vapply(.CS17_DEGEN_ARMS, + function(a) .CS17_DEGEN_MSG[[a]], character(1L)))), "degen: msg byte drift") +.w <- function(arm) degen$msg[match(arm, degen$arm)] +stopif(!grepl("; skipped 7/42 variants", .w("skipped-tail-hi"), fixed = TRUE), + "degen: the skipped tail fell off the hi side") +stopif(grepl("; skipped 7/42 variants", .w("core-nontail-lo"), fixed = TRUE), + "degen: the skipped tail rode the lo side") +stopif(!grepl("|4|0|", .w("empty-queue-hi"), fixed = TRUE), + "degen: the legal empty queue lost its shape") +stopif(!grepl("|4|0|double|TRUE|FALSE|", .w("empty-4x0-lo"), fixed = TRUE), + "degen: the zero-column identity bit moved") +.census("degen", degen, 8L, key.col = 3L) + +rng1 <- exists(".Random.seed", envir = globalenv(), inherits = TRUE) +scal.vals <- vapply(.CS17_SCAL_KEYS, function(k) { + if (identical(k, "rng-before")) return(format(rng0)) + if (identical(k, "rng-after")) return(format(rng1)) + v <- .cs17_scalval(k) + stopif(is.na(v) || !nzchar(v), paste0("scalars: empty re-fire for ", k)) + stopif(!identical(v, .CS17_SCAL_VALS[[k]]), paste0("scalars: drift for ", k)) + v +}, character(1L)) +scalars <- data.frame(key = .CS17_SCAL_KEYS, value = unname(scal.vals), + stringsAsFactors = FALSE) +stopif(!identical(scalars$value[match("rng-before", .CS17_SCAL_KEYS)], + .CS17_SCAL_VALS[["rng-before"]]), "scalars: rng-before drift") +stopif(!identical(scalars$value[match("rng-after", .CS17_SCAL_KEYS)], + .CS17_SCAL_VALS[["rng-after"]]), "scalars: rng-after drift") +stopif(!identical(scalars$value[match("tail-int", .CS17_SCAL_KEYS)], + scalars$value[match("tail-dbl", .CS17_SCAL_KEYS)]), + "scalars: the dual-kernel tails disagree") +.census("scalars", scalars, 10L) + +## dual-kernel hashes over the frozen corpora (written nowhere, attested) +plant.sha <- .ck(charToRaw(.cs17_plant_text()), "plant-corpus") +spec.sha <- .ck(charToRaw(.cs17_spec_text()), "spec-corpus") + +## --------------------------------------------------------------------------- +## all censuses spoke: commit the five witnesses +## --------------------------------------------------------------------------- +.wtab("cs17_laws.tsv", laws) +.wtab("cs17_specs.tsv", specs) +.wtab("cs17_precedence.tsv", prec) +.wtab("cs17_degenerates.tsv", degen) +.wtab("cs17_scalars.tsv", scalars) + +cat("[attest] at=", format(Sys.time(), "%Y-%m-%dT%H:%M:%OS3Z", tz = "UTC"), + " out=", OUT, "\n", sep = "") +for (nm in c("cs17_laws.tsv", "cs17_specs.tsv", "cs17_precedence.tsv", + "cs17_degenerates.tsv", "cs17_scalars.tsv")) { + cat("[attest] sha256 ", nm, "=", .file.sha(nm), "\n", sep = "") +} +cat("[attest] plant_sha256=", plant.sha, " spec_sha256=", spec.sha, + " files=", length(list.files(OUT, pattern = "^cs17_")), "\n", sep = "") +cat("OVERALL PASS\n") +quit(save = "no", status = 0L) diff --git a/tests/testthat/test-scenario-catalog-witness.R b/tests/testthat/test-scenario-catalog-witness.R new file mode 100644 index 0000000..d6dae4b --- /dev/null +++ b/tests/testthat/test-scenario-catalog-witness.R @@ -0,0 +1,869 @@ +# test-scenario-catalog-witness.R -- the CS-17 catalog-witness law units +# (pillar 3). The scenario plants synthetic governance-container calls (the +# D3 law: zero COSMIC numeric matrices, zero real-data bytes, zero downloads +# -- the catalog rides only as shape) and adjudicates the EXPORTED +# ms_catalog()/MsCatalog face: the S7 property gates (class_any counts, +# class_list channels, class_character samples, class_list provenance), the +# seventeen-arm "catalog" validator, the second error class the shared label +# digest reaches (msuiter_error_input via msuiter_hash_labels), the +# precedence discriminators with their anti anchors, the boundary contrast +# pairs and the acceptance specs. The witness bytes under +# bench/scenarios/out/ (cs17_laws.tsv, cs17_specs.tsv, cs17_precedence.tsv, +# cs17_degenerates.tsv, cs17_scalars.tsv) are the committed verdict: a drift +# in a fired clause, an observed error class, an accepted shape or the +# precedence order reddens here before print. The plants are synthetic -- no +# RNG consumption, no network, no COSMIC bytes; the lane NEVER calls the +# benchmark driver, the declined calibration family, the registry face or +# any validator internal (banned words, grepped over the runner source). +# Framing law: DECISION RECORD only. What the face says on planted truth -- +# the accepted shapes, the abort classes, the fired clauses -- is an +# OBSERVED, COMMITTED record, never a fidelity claim beyond what was +# measured. Cross-platform posture (D11): integer, label, logical, class +# and clause bytes are byte-committed; the face produces no float payload +# columns (counts storage mode rides as a glyph, the hash is hex), so no +# float glyph rides any witness. +# The frozen block and the shared code block below are MINTED mechanically +# from the audited probe ledger (gen-frozen.cs17.R / cs17-shared.R); neither +# is ever hand-edited in place. + +.rs_out17 <- function(fname) { + file.path(.ms_root, "bench", "scenarios", "out", fname) +} + +# The committed tables are written quote-free; quote = "" keeps every +# double quote inside the clauses literal on read. +.rs_tsv17 <- function(fname) { + read.csv(.rs_out17(fname), header = TRUE, sep = "\t", + stringsAsFactors = FALSE, na.strings = "", colClasses = "character", + quote = "") +} + +## <> (minted mechanically from the audited ledger +## 2026-11-24; DO NOT hand-edit: regenerate via gen-frozen.cs17.R) ## +.CS17_LAW_ARMS <- c("G1-channels-nonlist", "G2-samples-noncharacter", "G3-provenance-nonlist", "V1-counts-vector", "V1b-counts-character-matrix", "V2-rownames-missing", "V2b-colnames-missing", "V3-rowlabels-dup", "V3b-collabels-dup", "V4-count-NA", "V4b-count-Inf", "V4c-count-NaN", "V5-count-negative", "V6-snap-missing-hash", "V6b-snap-missing-name", "V6c-snap-extra-field", "V6d-snap-empty-list", "V7-name-empty", "V7b-name-NA", "V7c-name-noncharacter", "V8-labels-NA-handhash", "V8b-labels-numeric", "V8c-label-empty-string", "V9-snap-labels-dup", "V13-hash-nonhex", "V13b-hash-noncharacter", "V13c-hash-NA", "V13d-hash-short-hex", "V14-hash-foreign", "V10-nrow-vs-labels", "V10b-ncol-vs-samples", "V11-rowlabel-decoy-permuted", "V12-colnames-vs-samples", "V15-sample-empty", "V15b-sample-NA", "V16-prov-unnamed", "V16b-prov-emptyname", "V17-genome-missing", "V17b-genome-empty", "X1-errorinput-autohash-NAlabels", "E2-NAinteger-label-trap", "U1-hashhelper-via-factory-listlabels") +.CS17_LAW_CLS <- c("simpleError", "simpleError", "simpleError", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_input", "msuiter_error_input", "msuiter_error_catalog") +.CS17_LAW_CLAUSES <- list() +.CS17_LAW_CLAUSES[["G1-channels-nonlist"]] <- paste0(" object properties are inval", + "id: | - @channels must be , not ") +.CS17_LAW_CLAUSES[["G2-samples-noncharacter"]] <- paste0(" object properties are inval", + "id: | - @samples must be , not ") +.CS17_LAW_CLAUSES[["G3-provenance-nonlist"]] <- paste0(" object properties are inval", + "id: | - @provenance must be , not ") +.CS17_LAW_CLAUSES[["V1-counts-vector"]] <- paste0("counts must be a numeric matrix (channels x samp", + "les) | MsCatalog stores one count per channel an", + "d sample | received: numeric | tally variants wi", + "th ms_tally() to obtain a count matrix") +.CS17_LAW_CLAUSES[["V1b-counts-character-matrix"]] <- paste0("counts must be a numeric matrix (channels x samp", + "les) | MsCatalog stores one count per channel an", + "d sample | received: matrix | tally variants wit", + "h ms_tally() to obtain a count matrix") +.CS17_LAW_CLAUSES[["V2-rownames-missing"]] <- paste0("counts must carry both channel labels (rownames)", + " and sample labels (colnames) | labels are the o", + "nly legal matching key (never position) | rownam", + "es missing: TRUE; colnames missing: FALSE | name", + " the matrix dimensions before constructing MsCat", + "alog") +.CS17_LAW_CLAUSES[["V2b-colnames-missing"]] <- paste0("counts must carry both channel labels (rownames)", + " and sample labels (colnames) | labels are the o", + "nly legal matching key (never position) | rownam", + "es missing: FALSE; colnames missing: TRUE | name", + " the matrix dimensions before constructing MsCat", + "alog") +.CS17_LAW_CLAUSES[["V3-rowlabels-dup"]] <- paste0("channel and sample labels must be unique | dupli", + "cated labels make label matching ambiguous | dup", + "licated channel labels: 'CH1'; duplicated sample", + " labels: (none) | de-duplicate or rename labels") +.CS17_LAW_CLAUSES[["V3b-collabels-dup"]] <- paste0("channel and sample labels must be unique | dupli", + "cated labels make label matching ambiguous | dup", + "licated channel labels: (none); duplicated sampl", + "e labels: 'S1' | de-duplicate or rename labels") +.CS17_LAW_CLAUSES[["V4-count-NA"]] <- paste0("counts must not contain NA or non-finite values ", + "| the FFI contract rejects NA; the catalog layer", + " adds no pseudo-counts | offending cells: '2' | ", + "fix the upstream tally output") +.CS17_LAW_CLAUSES[["V4b-count-Inf"]] <- paste0("counts must not contain NA or non-finite values ", + "| the FFI contract rejects NA; the catalog layer", + " adds no pseudo-counts | offending cells: '7' | ", + "fix the upstream tally output") +.CS17_LAW_CLAUSES[["V4c-count-NaN"]] <- paste0("counts must not contain NA or non-finite values ", + "| the FFI contract rejects NA; the catalog layer", + " adds no pseudo-counts | offending cells: '4' | ", + "fix the upstream tally output") +.CS17_LAW_CLAUSES[["V5-count-negative"]] <- paste0("counts must be non-negative | negative mutation ", + "counts are impossible | offending cells: '5' | c", + "heck the tally pipeline for subtraction errors") +.CS17_LAW_CLAUSES[["V6-snap-missing-hash"]] <- paste0("the channel snapshot must be a list with fields ", + "name, labels, hash | the snapshot keeps the regi", + "stry's canonical labels and their digest | recei", + "ved fields: 'name', 'labels' | construct the cat", + "alog through ms_catalog(), which slices the snap", + "shot") +.CS17_LAW_CLAUSES[["V6b-snap-missing-name"]] <- paste0("the channel snapshot must be a list with fields ", + "name, labels, hash | the snapshot keeps the regi", + "stry's canonical labels and their digest | recei", + "ved fields: 'labels', 'hash' | construct the cat", + "alog through ms_catalog(), which slices the snap", + "shot") +.CS17_LAW_CLAUSES[["V6c-snap-extra-field"]] <- paste0("the channel snapshot must be a list with fields ", + "name, labels, hash | the snapshot keeps the regi", + "stry's canonical labels and their digest | recei", + "ved fields: 'name', 'labels', 'hash', 'extra' | ", + "construct the catalog through ms_catalog(), whic", + "h slices the snapshot") +.CS17_LAW_CLAUSES[["V6d-snap-empty-list"]] <- paste0("the channel snapshot must be a list with fields ", + "name, labels, hash | the snapshot keeps the regi", + "stry's canonical labels and their digest | recei", + "ved fields: (none) | construct the catalog throu", + "gh ms_catalog(), which slices the snapshot") +.CS17_LAW_CLAUSES[["V7-name-empty"]] <- paste0("the channel snapshot field 'name' must be a sing", + "le non-empty string | the table name identifies ", + "the channel set (e.g. SBS96) | received: '' | pa", + "ss the registry table name, e.g. name = \"SBS96\"") +.CS17_LAW_CLAUSES[["V7b-name-NA"]] <- paste0("the channel snapshot field 'name' must be a sing", + "le non-empty string | the table name identifies ", + "the channel set (e.g. SBS96) | received: 'NA' | ", + "pass the registry table name, e.g. name = \"SBS96", + "\"") +.CS17_LAW_CLAUSES[["V7c-name-noncharacter"]] <- paste0("the channel snapshot field 'name' must be a sing", + "le non-empty string | the table name identifies ", + "the channel set (e.g. SBS96) | received: '5' | p", + "ass the registry table name, e.g. name = \"SBS96\"") +.CS17_LAW_CLAUSES[["V8-labels-NA-handhash"]] <- paste0("channel labels in the snapshot must be a charact", + "er vector without NA | channel labels are canoni", + "cal identities | received: character of length 4", + " with anyNA = TRUE | pass the canonical labels f", + "rom the channel registry") +.CS17_LAW_CLAUSES[["V8b-labels-numeric"]] <- paste0("channel labels in the snapshot must be a charact", + "er vector without NA | channel labels are canoni", + "cal identities | received: integer of length 4 w", + "ith anyNA = FALSE | pass the canonical labels fr", + "om the channel registry") +.CS17_LAW_CLAUSES[["V8c-label-empty-string"]] <- paste0("channel labels in the snapshot must be a charact", + "er vector without NA | channel labels are canoni", + "cal identities | received: character of length 4", + " with anyNA = FALSE | pass the canonical labels ", + "from the channel registry") +.CS17_LAW_CLAUSES[["V9-snap-labels-dup"]] <- paste0("channel labels in the snapshot must be unique | ", + "duplicated channel labels are not canonical orde", + "r | duplicated: 'CH1' | use the canonical regist", + "ry ordering") +.CS17_LAW_CLAUSES[["V13-hash-nonhex"]] <- paste0("the channel snapshot field 'hash' must be an md5", + " hex digest | the digest pins the channel table ", + "inside snapshot summaries (A5) | received: 'ZZzz", + "0000000000000000000000000000' | let ms_catalog()", + " compute the hash; do not set it by hand") +.CS17_LAW_CLAUSES[["V13b-hash-noncharacter"]] <- paste0("the channel snapshot field 'hash' must be an md5", + " hex digest | the digest pins the channel table ", + "inside snapshot summaries (A5) | received: '42' ", + "| let ms_catalog() compute the hash; do not set ", + "it by hand") +.CS17_LAW_CLAUSES[["V13c-hash-NA"]] <- paste0("the channel snapshot field 'hash' must be an md5", + " hex digest | the digest pins the channel table ", + "inside snapshot summaries (A5) | received: 'NA' ", + "| let ms_catalog() compute the hash; do not set ", + "it by hand") +.CS17_LAW_CLAUSES[["V13d-hash-short-hex"]] <- paste0("the channel snapshot field 'hash' must be an md5", + " hex digest | the digest pins the channel table ", + "inside snapshot summaries (A5) | received: 'd3b7", + "7a574c1e6afda429f0e14afcf4d' | let ms_catalog() ", + "compute the hash; do not set it by hand") +.CS17_LAW_CLAUSES[["V14-hash-foreign"]] <- paste0("the stored channel hash does not match the store", + "d labels | snapshot hashes must be derived, not ", + "asserted | stored: 2b947f5f7703ed9896680aa8bbe27", + "a7a | rebuild the catalog with ms_catalog()") +.CS17_LAW_CLAUSES[["V10-nrow-vs-labels"]] <- paste0("counts dimensions disagree with the registry sna", + "pshot or the samples | counts is channels x samp", + "les | nrow = 3 vs 4 labels; ncol = 2 vs 2 sample", + "s | align the count matrix with the registry lab", + "els and sample ids") +.CS17_LAW_CLAUSES[["V10b-ncol-vs-samples"]] <- paste0("counts dimensions disagree with the registry sna", + "pshot or the samples | counts is channels x samp", + "les | nrow = 4 vs 4 labels; ncol = 3 vs 2 sample", + "s | align the count matrix with the registry lab", + "els and sample ids") +.CS17_LAW_CLAUSES[["V11-rowlabel-decoy-permuted"]] <- paste0("channel labels of counts do not match the regist", + "ry snapshot | matching is by label, element by e", + "lement, never by position | first offending labe", + "ls: 'CH2', 'CH1' | reorder or rename counts rows", + " to the canonical registry labels") +.CS17_LAW_CLAUSES[["V12-colnames-vs-samples"]] <- paste0("sample labels of counts do not match the samples", + " property | matching is by label, element by ele", + "ment, never by position | first offending labels", + ": 'SX' | align colnames(counts) with the samples", + " vector") +.CS17_LAW_CLAUSES[["V15-sample-empty"]] <- paste0("sample labels must be non-empty strings without ", + "NA | sample ids are identities matched by label ", + "| offending labels: '' | provide one non-empty i", + "d per sample") +.CS17_LAW_CLAUSES[["V15b-sample-NA"]] <- paste0("sample labels must be non-empty strings without ", + "NA | sample ids are identities matched by label ", + "| offending labels: 'NA' | provide one non-empty", + " id per sample") +.CS17_LAW_CLAUSES[["V16-prov-unnamed"]] <- paste0("catalog provenance must be a named list | proven", + "ance carries the genome build and tally context ", + "| received: list | provide at least genome = \"\"") +.CS17_LAW_CLAUSES[["V16b-prov-emptyname"]] <- paste0("catalog provenance must be a named list | proven", + "ance carries the genome build and tally context ", + "| received: list | provide at least genome = \"\"") +.CS17_LAW_CLAUSES[["V17-genome-missing"]] <- paste0("catalog provenance must carry the genome build a", + "s 'genome' | the build is required to query refe", + "rence signatures | received: (none) | record the", + " build, e.g. provenance = list(genome = \"GRCh38\"", + ")") +.CS17_LAW_CLAUSES[["V17b-genome-empty"]] <- paste0("catalog provenance must carry the genome build a", + "s 'genome' | the build is required to query refe", + "rence signatures | received: '' | record the bui", + "ld, e.g. provenance = list(genome = \"GRCh38\")") +.CS17_LAW_CLAUSES[["X1-errorinput-autohash-NAlabels"]] <- paste0("channel labels to hash must be a character vecto", + "r without NA | the label digest is only defined ", + "for plain label vectors | received: character wi", + "th anyNA = TRUE | pass the canonical channel lab", + "els (character, NA free)") +.CS17_LAW_CLAUSES[["E2-NAinteger-label-trap"]] <- paste0("channel labels to hash must be a character vecto", + "r without NA | the label digest is only defined ", + "for plain label vectors | received: character wi", + "th anyNA = TRUE | pass the canonical channel lab", + "els (character, NA free)") +.CS17_LAW_CLAUSES[["U1-hashhelper-via-factory-listlabels"]] <- paste0("counts dimensions disagree with the registry sna", + "pshot or the samples | counts is channels x samp", + "les | nrow = 4 vs 2 labels; ncol = 2 vs 2 sample", + "s | align the count matrix with the registry lab", + "els and sample ids") +.CS17_SPEC_ARMS <- c("A1-accept-core", "A2-accept-skipped-tail-int", "A3-accept-skipped-tail-dbl", "A5-accept-1x1-minimal", "A4-accept-int-plant", "sp-replay-identity") +.CS17_SPEC_CLS <- c("s7:msuiter::MsCatalog", "s7:msuiter::MsCatalog", "s7:msuiter::MsCatalog", "s7:msuiter::MsCatalog", "s7:msuiter::MsCatalog", "s7:character") +.CS17_SPEC_DETAILS <- list() +.CS17_SPEC_DETAILS[["A1-accept-core"]] <- paste0("msuiter::MsCatalog|4|2|double|TRUE|TRUE|d3b77a57", + "4c1e6afda429f0e14afcf4d1| CS17T: 4 ch", + "annels x 2 samples") +.CS17_SPEC_DETAILS[["A2-accept-skipped-tail-int"]] <- paste0("msuiter::MsCatalog|4|2|double|TRUE|TRUE|d3b77a57", + "4c1e6afda429f0e14afcf4d1| CS17T: 4 ch", + "annels x 2 samples; skipped 7/42 variants") +.CS17_SPEC_DETAILS[["A3-accept-skipped-tail-dbl"]] <- paste0("msuiter::MsCatalog|4|2|double|TRUE|TRUE|d3b77a57", + "4c1e6afda429f0e14afcf4d1| CS17T: 4 ch", + "annels x 2 samples; skipped 7/42 variants") +.CS17_SPEC_DETAILS[["A5-accept-1x1-minimal"]] <- paste0("msuiter::MsCatalog|1|1|double|TRUE|TRUE|e10fea09", + "c4590dfbcf05149c6d3157db| CS17T: 1 ch", + "annels x 1 samples") +.CS17_SPEC_DETAILS[["A4-accept-int-plant"]] <- paste0("msuiter::MsCatalog|4|2|integer|TRUE|TRUE|d3b77a5", + "74c1e6afda429f0e14afcf4d1| CS17T: 4 c", + "hannels x 2 samples") +.CS17_SPEC_DETAILS[["sp-replay-identity"]] <- paste0("msuiter::MsCatalog|4|2|double|TRUE|TRUE|d3b77a57", + "4c1e6afda429f0e14afcf4d1| CS17T: 4 ch", + "annels x 2 samples==msuiter::MsCatalog|4|2|doubl", + "e|TRUE|TRUE|d3b77a574c1e6afda429f0e14afcf4d1| CS17T: 4 channels x 2 samples") +.CS17_PREC_ARMS <- c("PR1-anchor-gate-over-validator", "PR1-anti-validator-alone", "PR2-anchor-dims-over-labelmatch", "PR2b-anchor-uniqueness-over-dims", "PR3-anchor-uniqueness-over-finiteness", "PR4-anchor-hashshape-over-truth", "PR5-anchor-namedlaw-over-genomelaw", "PR5-anti-genomelaw-alone", "PR6-anchor-collabel-mismatch-over-samplesanity", "PR6-anti-samplesanity-alone") +.CS17_PREC_CLS <- c("simpleError", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog") +.CS17_PREC_FIRES <- c("- @samples must be , not ", "counts must be a numeric matrix (channels x samples)", "counts dimensions disagree with the registry snapshot or the samples", "channel and sample labels must be unique", "channel and sample labels must be unique", "the channel snapshot field 'hash' must be an md5 hex digest", "catalog provenance must be a named list", "catalog provenance must carry the genome build as 'genome'", "sample labels of counts do not match the samples property", "sample labels must be non-empty strings without NA") +.CS17_PREC_ANTI <- c("counts must be a numeric matrix (channels x samples)", " object properties are invalid:", "channel and sample labels must be unique", "counts dimensions disagree with the registry snapshot or the samples", "counts must not contain NA or non-finite values", "the stored channel hash does not match the stored labels", "catalog provenance must carry the genome build as 'genome'", "catalog provenance must be a named list", "sample labels must be non-empty strings without NA", "sample labels of counts do not match the samples property") +.CS17_DEGEN_PAIR <- c("empty-boundary", "empty-boundary", "rowlaw-split", "rowlaw-split", "minimal-vs-empty", "minimal-vs-empty", "skipped-tail", "skipped-tail") +.CS17_DEGEN_SIDE <- c("hi", "lo", "hi", "lo", "hi", "lo", "hi", "lo") +.CS17_DEGEN_ARMS <- c("empty-queue-hi", "zero-channels-lo", "rowlabel-uniqueness-hi", "rownames-missing-lo", "minimal-1x1-hi", "empty-4x0-lo", "skipped-tail-hi", "core-nontail-lo") +.CS17_DEGEN_MODE <- c("accept", "reject", "reject", "reject", "accept", "accept", "accept", "accept") +.CS17_DEGEN_CLS <- c("s7:msuiter::MsCatalog", "msuiter_error_catalog", "msuiter_error_catalog", "msuiter_error_catalog", "s7:msuiter::MsCatalog", "s7:msuiter::MsCatalog", "s7:msuiter::MsCatalog", "s7:msuiter::MsCatalog") +.CS17_DEGEN_MSG <- list() +.CS17_DEGEN_MSG[["empty-queue-hi"]] <- paste0("msuiter::MsCatalog|4|0|double|TRUE|FALSE|d3b77a5", + "74c1e6afda429f0e14afcf4d1| CS17T: 4 c", + "hannels x 0 samples") +.CS17_DEGEN_MSG[["zero-channels-lo"]] <- paste0("counts must carry both channel labels (rownames)", + " and sample labels (colnames) | labels are the o", + "nly legal matching key (never position) | rownam", + "es missing: TRUE; colnames missing: FALSE | name", + " the matrix dimensions before constructing MsCat", + "alog") +.CS17_DEGEN_MSG[["rowlabel-uniqueness-hi"]] <- paste0("channel and sample labels must be unique | dupli", + "cated labels make label matching ambiguous | dup", + "licated channel labels: 'CH1'; duplicated sample", + " labels: (none) | de-duplicate or rename labels") +.CS17_DEGEN_MSG[["rownames-missing-lo"]] <- paste0("counts must carry both channel labels (rownames)", + " and sample labels (colnames) | labels are the o", + "nly legal matching key (never position) | rownam", + "es missing: TRUE; colnames missing: FALSE | name", + " the matrix dimensions before constructing MsCat", + "alog") +.CS17_DEGEN_MSG[["minimal-1x1-hi"]] <- paste0("msuiter::MsCatalog|1|1|double|TRUE|TRUE|e10fea09", + "c4590dfbcf05149c6d3157db| CS17T: 1 ch", + "annels x 1 samples") +.CS17_DEGEN_MSG[["empty-4x0-lo"]] <- paste0("msuiter::MsCatalog|4|0|double|TRUE|FALSE|d3b77a5", + "74c1e6afda429f0e14afcf4d1| CS17T: 4 c", + "hannels x 0 samples") +.CS17_DEGEN_MSG[["skipped-tail-hi"]] <- paste0("msuiter::MsCatalog|4|2|double|TRUE|TRUE|d3b77a57", + "4c1e6afda429f0e14afcf4d1| CS17T: 4 ch", + "annels x 2 samples; skipped 7/42 variants") +.CS17_DEGEN_MSG[["core-nontail-lo"]] <- paste0("msuiter::MsCatalog|4|2|double|TRUE|TRUE|d3b77a57", + "4c1e6afda429f0e14afcf4d1| CS17T: 4 ch", + "annels x 2 samples") +.CS17_SCAL_KEYS <- c("gate-class", "storage-double", "storage-integer", "hash-canonical", "hash-minimal", "format-core", "tail-int", "tail-dbl", "rng-before", "rng-after") +.CS17_SCAL_VALS <- list() +.CS17_SCAL_VALS[["gate-class"]] <- "simpleError" +.CS17_SCAL_VALS[["storage-double"]] <- "double" +.CS17_SCAL_VALS[["storage-integer"]] <- "integer" +.CS17_SCAL_VALS[["hash-canonical"]] <- "d3b77a574c1e6afda429f0e14afcf4d1" +.CS17_SCAL_VALS[["hash-minimal"]] <- "e10fea09c4590dfbcf05149c6d3157db" +.CS17_SCAL_VALS[["format-core"]] <- " CS17T: 4 channels x 2 samples" +.CS17_SCAL_VALS[["tail-int"]] <- paste0(" CS17T: 4 channels x 2 samples; skipp", + "ed 7/42 variants") +.CS17_SCAL_VALS[["tail-dbl"]] <- paste0(" CS17T: 4 channels x 2 samples; skipp", + "ed 7/42 variants") +.CS17_SCAL_VALS[["rng-before"]] <- "FALSE" +.CS17_SCAL_VALS[["rng-after"]] <- "FALSE" +.CS17_SCAL_REFIRE <- list( + +"gate-class" = "MsCatalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = 1:2, provenance = .CS17_PROV)", + +"storage-double" = "storage.mode(.cs17_counts())", + +"storage-integer" = "storage.mode(.cs17_counts(int = TRUE))", + +"hash-canonical" = "msuiter_hash_labels(.CS17_LBL)", + +"hash-minimal" = "msuiter_hash_labels(\"CH1\")", + +"format-core" = "format(ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV))", + +"tail-int" = "format(ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = {p <- .CS17_PROV; p$n_skipped <- 7L; p$n_variants <- 42L; p}))", + +"tail-dbl" = "format(ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = {p <- .CS17_PROV; p$n_skipped <- 7; p$n_variants <- 42; p}))" +) +.CS17_ARM <- list( + +"G1-channels-nonlist" = "MsCatalog(counts = .cs17_counts(), channels = \"SBS\", samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"G2-samples-noncharacter" = "MsCatalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = 1:2, provenance = .CS17_PROV)", + +"G3-provenance-nonlist" = "MsCatalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = \"GRCh38\")", + +"V1-counts-vector" = "ms_catalog(counts = as.numeric(1:8), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V1b-counts-character-matrix" = "ms_catalog(counts = matrix(c(\"a\", \"b\", \"c\", \"d\"), 2L, 2L, dimnames = list(.CS17_LBL[1:2], .CS17_SAMP)), channels = .cs17_snap(labels = .CS17_LBL[1:2]), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V2-rownames-missing" = "ms_catalog(counts = matrix(as.numeric(1:8), 4L, 2L, dimnames = list(NULL, .CS17_SAMP)), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V2b-colnames-missing" = "ms_catalog(counts = matrix(as.numeric(1:8), 4L, 2L, dimnames = list(.CS17_LBL, NULL)), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V3-rowlabels-dup" = "ms_catalog(counts = .cs17_counts(lab = c(.CS17_LBL[1], .CS17_LBL[1:3])), channels = .cs17_snap(labels = c(.CS17_LBL[1], .CS17_LBL[1:3])), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V3b-collabels-dup" = "ms_catalog(counts = matrix(as.numeric(1:8), 4L, 2L, dimnames = list(.CS17_LBL, c(\"S1\", \"S1\"))), channels = .cs17_snap(), samples = c(\"S1\", \"S1\"), provenance = .CS17_PROV)", + +"V4-count-NA" = "ms_catalog(counts = {m <- .cs17_counts(); m[2, 1] <- NA; m}, channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V4b-count-Inf" = "ms_catalog(counts = {m <- .cs17_counts(); m[3, 2] <- Inf; m}, channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V4c-count-NaN" = "ms_catalog(counts = {m <- .cs17_counts(); m[4, 1] <- NaN; m}, channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V5-count-negative" = "ms_catalog(counts = {m <- .cs17_counts(); m[1, 2] <- -7; m}, channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V6-snap-missing-hash" = "MsCatalog(counts = .cs17_counts(), channels = list(name = .CS17_TAB, labels = .CS17_LBL), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V6b-snap-missing-name" = "MsCatalog(counts = .cs17_counts(), channels = list(labels = .CS17_LBL, hash = msuiter_hash_labels(.CS17_LBL)), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V6c-snap-extra-field" = "MsCatalog(counts = .cs17_counts(), channels = c(.cs17_snap(), list(extra = 1)), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V6d-snap-empty-list" = "MsCatalog(counts = .cs17_counts(), channels = list(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V7-name-empty" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$name <- \"\"; s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V7b-name-NA" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$name <- NA_character_; s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V7c-name-noncharacter" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$name <- 5; s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V8-labels-NA-handhash" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(labels = c(.CS17_LBL[1:3], NA_character_), hash = .cs17_zero32()); s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"X1-errorinput-autohash-NAlabels" = "MsCatalog(counts = .cs17_counts(), channels = .cs17_snap(labels = c(.CS17_LBL[1:3], NA_character_)), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V8b-labels-numeric" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$labels <- 1:4; s$hash <- msuiter_hash_labels(as.character(1:4)); s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V8c-label-empty-string" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$labels <- c(.CS17_LBL[1:3], \"\"); s$hash <- msuiter_hash_labels(c(.CS17_LBL[1:3], \"\")); s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V9-snap-labels-dup" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(labels = .CS17_LBL, hash = .cs17_zero32()); s$labels <- c(.CS17_LBL[1:3], .CS17_LBL[1]); s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V13-hash-nonhex" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$hash <- \"ZZzz0000000000000000000000000000\"; s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V13b-hash-noncharacter" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$hash <- 42; s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V13c-hash-NA" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$hash <- NA_character_; s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V13d-hash-short-hex" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$hash <- substr(s$hash, 1L, 31L); s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V14-hash-foreign" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$hash <- msuiter_hash_labels(paste0(\"X\", 1:4)); s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V10-nrow-vs-labels" = "ms_catalog(counts = .cs17_counts(lab = .CS17_LBL[1:3]), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V10b-ncol-vs-samples" = "ms_catalog(counts = matrix(as.numeric(1:12), 4L, 3L, dimnames = list(.CS17_LBL, paste0(\"S\", 1:3))), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V11-rowlabel-decoy-permuted" = "ms_catalog(counts = .cs17_counts(lab = c(.CS17_LBL[2], .CS17_LBL[1], .CS17_LBL[3:4])), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"V12-colnames-vs-samples" = "ms_catalog(counts = matrix(as.numeric(1:8), 4L, 2L, dimnames = list(.CS17_LBL, c(\"S1\", \"SX\"))), channels = .cs17_snap(), samples = c(\"S1\", \"S2\"), provenance = .CS17_PROV)", + +"V15-sample-empty" = "ms_catalog(counts = matrix(as.numeric(1:8), 4L, 2L, dimnames = list(.CS17_LBL, c(\"S1\", \"\"))), channels = .cs17_snap(), samples = c(\"S1\", \"\"), provenance = .CS17_PROV)", + +"V15b-sample-NA" = "ms_catalog(counts = matrix(as.numeric(1:8), 4L, 2L, dimnames = list(.CS17_LBL, c(\"S1\", NA_character_))), channels = .cs17_snap(), samples = c(\"S1\", NA_character_), provenance = .CS17_PROV)", + +"V16-prov-unnamed" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = list(\"GRCh38\"))", + +"V16b-prov-emptyname" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = {p <- list(\"GRCh38\"); names(p) <- \"\"; p})", + +"V17-genome-missing" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = list(build = \"GRCh38\"))", + +"V17b-genome-empty" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = list(genome = \"\"))", + +"E1-empty-legal-queue" = "ms_catalog(counts = matrix(numeric(0), length(.CS17_LBL), 0L, dimnames = list(.CS17_LBL, NULL)), channels = .cs17_snap(), samples = character(0), provenance = .CS17_PROV)", + +"E1b-zero-channels" = "ms_catalog(counts = matrix(numeric(0), 0L, 0L, dimnames = list(NULL, NULL)), channels = list(name = .CS17_TAB, labels = NULL), samples = character(0), provenance = .CS17_PROV)", + +"E2-NAinteger-label-trap" = "ms_catalog(counts = .cs17_counts(lab = c(\"NA\", .CS17_LBL[1:3])), channels = list(name = .CS17_TAB, labels = c(NA_integer_, .CS17_LBL[1:3])), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"PR1-anchor-gate-over-validator" = "MsCatalog(counts = as.numeric(1:8), channels = .cs17_snap(), samples = 1:2, provenance = .CS17_PROV)", + +"PR1-anti-validator-alone" = "ms_catalog(counts = as.numeric(1:8), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"PR2-anchor-dims-over-labelmatch" = "ms_catalog(counts = .cs17_counts(lab = c(.CS17_LBL[2], .CS17_LBL[1], .CS17_LBL[3])), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"PR2b-anchor-uniqueness-over-dims" = "ms_catalog(counts = .cs17_counts(lab = c(.CS17_LBL[1], .CS17_LBL[1], .CS17_LBL[2])), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"PR3-anchor-uniqueness-over-finiteness" = "ms_catalog(counts = {m <- .cs17_counts(lab = c(.CS17_LBL[1], .CS17_LBL[1:3])); m[1, 1] <- NA; m}, channels = .cs17_snap(labels = c(.CS17_LBL[1], .CS17_LBL[1:3])), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"PR4-anchor-hashshape-over-truth" = "MsCatalog(counts = .cs17_counts(), channels = {s <- .cs17_snap(); s$hash <- \"nothex00000000000000000000000000\"; s}, samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"PR5-anchor-namedlaw-over-genomelaw" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = list(\"GRCh38\"))", + +"PR5-anti-genomelaw-alone" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = list(build = \"GRCh38\"))", + +"PR6-anchor-collabel-mismatch-over-samplesanity" = "ms_catalog(counts = matrix(as.numeric(1:8), 4L, 2L, dimnames = list(.CS17_LBL, c(\"S1\", \"SX\"))), channels = .cs17_snap(), samples = c(\"S1\", NA_character_), provenance = .CS17_PROV)", + +"PR6-anti-samplesanity-alone" = "ms_catalog(counts = matrix(as.numeric(1:8), 4L, 2L, dimnames = list(.CS17_LBL, c(\"S1\", NA_character_))), channels = .cs17_snap(), samples = c(\"S1\", NA_character_), provenance = .CS17_PROV)", + +"A1-accept-core" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"A2-accept-skipped-tail-int" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = {p <- .CS17_PROV; p$n_skipped <- 7L; p$n_variants <- 42L; p})", + +"A3-accept-skipped-tail-dbl" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = {p <- .CS17_PROV; p$n_skipped <- 7; p$n_variants <- 42; p})", + +"A5-accept-1x1-minimal" = "ms_catalog(counts = matrix(1, 1L, 1L, dimnames = list(\"CH1\", \"S1\")), channels = list(name = \"CS17T\", labels = \"CH1\"), samples = \"S1\", provenance = .CS17_PROV)", + +"A4-accept-int-plant" = "ms_catalog(counts = {mm <- matrix(1:8, 4L, 2L, dimnames = list(.CS17_LBL, .CS17_SAMP)); mm}, channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)", + +"sp-replay-identity" = "paste0(.cs17_render(ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)), \"==\", .cs17_render(ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)))", + +"U1-hashhelper-via-factory-listlabels" = "ms_catalog(counts = .cs17_counts(), channels = list(name = .CS17_TAB, labels = list(1, 2)), samples = .CS17_SAMP, provenance = .CS17_PROV)" +, +"empty-queue-hi" = "ms_catalog(counts = matrix(numeric(0), length(.CS17_LBL), 0L, dimnames = list(.CS17_LBL, NULL)), channels = .cs17_snap(), samples = character(0), provenance = .CS17_PROV)" +, +"zero-channels-lo" = "ms_catalog(counts = matrix(numeric(0), 0L, 0L, dimnames = list(NULL, NULL)), channels = list(name = .CS17_TAB, labels = NULL), samples = character(0), provenance = .CS17_PROV)" +, +"rowlabel-uniqueness-hi" = "ms_catalog(counts = .cs17_counts(lab = c(.CS17_LBL[1], .CS17_LBL[1:3])), channels = .cs17_snap(labels = c(.CS17_LBL[1], .CS17_LBL[1:3])), samples = .CS17_SAMP, provenance = .CS17_PROV)" +, +"rownames-missing-lo" = "ms_catalog(counts = matrix(as.numeric(1:8), 4L, 2L, dimnames = list(NULL, .CS17_SAMP)), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)" +, +"minimal-1x1-hi" = "ms_catalog(counts = matrix(1, 1L, 1L, dimnames = list(\"CH1\", \"S1\")), channels = list(name = \"CS17T\", labels = \"CH1\"), samples = \"S1\", provenance = .CS17_PROV)" +, +"empty-4x0-lo" = "ms_catalog(counts = matrix(numeric(0), length(.CS17_LBL), 0L, dimnames = list(.CS17_LBL, NULL)), channels = .cs17_snap(), samples = character(0), provenance = .CS17_PROV)" +, +"skipped-tail-hi" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = {p <- .CS17_PROV; p$n_skipped <- 7L; p$n_variants <- 42L; p})" +, +"core-nontail-lo" = "ms_catalog(counts = .cs17_counts(), channels = .cs17_snap(), samples = .CS17_SAMP, provenance = .CS17_PROV)" +) +.CS17_CENSUS <- c("msuiter_error_catalog=49", "msuiter_error_input=2", "s7:character=1", "s7:msuiter::MsCatalog=10", "simpleError=4") +## <> ## + +## <> (single source: injected byte-identically into +## the law file and the runner; edit /tmp/p6gate/cs17-shared.R and +## re-splice via splice-cs17.R -- never hand-edit in place) +## cs17-shared.R -- single source of the CS-17 catalog-witness shared block. +## Injected byte-identically into tests/testthat/test-scenario-catalog-witness.R +## and bench/scenarios/run_catalog_witness.R between the SHARED markers. +## Pure, deterministic, no RNG, no clock, no network: the condition-message +## pipeline plus the exported-face verdict render and the plant builders the +## frozen ARM texts call. +.cs17_describe <- function(e) trimws(gsub("\n", " | ", + paste(as.character(conditionMessage(e)), collapse = " | "), fixed = TRUE)) +.cs17_strip <- function(s) { + for (b in c("ℹ ", "i ")) s <- gsub(b, "", s, fixed = TRUE) + s +} +.cs17_render <- function(x) paste0(c( + paste0(class(x)[1L]), + paste0(nrow(x@counts)), paste0(ncol(x@counts)), + storage.mode(x@counts), + paste0(identical(rownames(x@counts), x@channels$labels)), + paste0(identical(colnames(x@counts), x@samples)), + x@channels$hash, + format(x)), collapse = "|") +.cs17_eval1 <- function(txt, tag) { + if (is.na(txt) || !nzchar(txt)) stop(".cs17_eval1: no text for ", tag) + ex <- parse(text = txt) + if (length(ex) != 1L) { + stop(".cs17_eval1: ", tag, " is not a single expression") + } + tryCatch(list(ok = TRUE, v = eval(ex[[1L]])), error = identity) +} +.cs17_verdict <- function(arm, r) { + if (inherits(r, "error")) { + list(arm = arm, mode = "reject", cls = class(r)[1L], + msg = gsub("\t", " ", .cs17_strip(.cs17_describe(r)), fixed = TRUE)) + } else { + rendered <- if (is.character(r)) r else .cs17_render(r) + list(arm = arm, mode = "accept", cls = paste0("s7:", class(r)[1L]), + msg = gsub("\t", " ", rendered, fixed = TRUE)) + } +} +.cs17_fire <- function(arm) { + r <- .cs17_eval1(.CS17_ARM[[arm]], arm) + .cs17_verdict(arm, if (inherits(r, "error")) r else r$v) +} +.cs17_clean <- function(df) { + ## witness bytes round-trip nameless through read.csv; strip any vapply + ## residue names so identical() compares columns byte-true + for (cnm in names(df)) attr(df[[cnm]], "names") <- NULL + df +} +.cs17_rows <- function(arms) { + vs <- lapply(arms, function(a) .cs17_fire(a)) + .cs17_clean(data.frame(arm = arms, + mode = vapply(vs, function(z) z$mode, character(1L)), + cls = vapply(vs, function(z) z$cls, character(1L)), + msg = vapply(vs, function(z) z$msg, character(1L)), + stringsAsFactors = FALSE)) +} +.cs17_lawrows <- function() .cs17_rows(.CS17_LAW_ARMS) +.cs17_specrows <- function() .cs17_rows(.CS17_SPEC_ARMS) +.cs17_precrows <- function() { + base <- .cs17_rows(.CS17_PREC_ARMS) + base$fires_ok <- unname(vapply(seq_along(base$arm), function(i) { + paste0(grepl(.CS17_PREC_FIRES[i], base$msg[i], fixed = TRUE)) + }, character(1L))) + base$anti_ok <- unname(vapply(seq_along(base$arm), function(i) { + paste0(!grepl(.CS17_PREC_ANTI[i], base$msg[i], fixed = TRUE)) + }, character(1L))) + base +} +.cs17_degenrows <- function() { + vs <- lapply(.CS17_DEGEN_ARMS, function(a) .cs17_fire(a)) + .cs17_clean(data.frame(pair = .CS17_DEGEN_PAIR, side = .CS17_DEGEN_SIDE, + arm = .CS17_DEGEN_ARMS, + mode = vapply(vs, function(z) z$mode, character(1L)), + cls = vapply(vs, function(z) z$cls, character(1L)), + msg = vapply(vs, function(z) z$msg, character(1L)), + stringsAsFactors = FALSE)) +} +.cs17_scalval <- function(k) { + txt <- .CS17_SCAL_REFIRE[[k]] + if (is.null(txt)) return(NA_character_) + res <- .cs17_eval1(txt, k) + if (inherits(res, "error")) { + if (identical(k, "gate-class")) return(paste0(class(res)[1L])) + return(.cs17_strip(.cs17_describe(res))) + } + paste0(res$v) +} +.cs17_scalref_keys <- function() names(.CS17_SCAL_REFIRE) +.cs17_plant_text <- function() { + ord <- c(.CS17_LAW_ARMS, .CS17_SPEC_ARMS, .CS17_PREC_ARMS, .CS17_DEGEN_ARMS) + paste0(vapply(ord, function(a) + paste0(a, "=", .CS17_ARM[[a]]), character(1L)), collapse = ";") +} +.cs17_spec_text <- function() paste0(.CS17_SPEC_ARMS, collapse = ";") +## ---- deterministic plant builders (no RNG, no clock, no network) ---------- +.CS17_TAB <- "CS17T" +.CS17_LBL <- c("CH1", "CH2", "CH3", "CH4") +.CS17_SAMP <- c("S1", "S2") +.CS17_PROV <- list(genome = "GRCh38") +.cs17_counts <- function(lab = .CS17_LBL, smp = .CS17_SAMP, int = FALSE) { + nr <- length(lab); nc <- length(smp) + vals <- if (nr * nc == 0L) { + if (int) integer(0L) else numeric(0L) + } else if (int) { + seq_len(nr * nc) + } else { + as.numeric(seq_len(nr * nc)) + } + matrix(vals, nr, nc, + dimnames = list(if (nr) lab else NULL, if (nc) smp else NULL)) +} +.cs17_snap <- function(name = .CS17_TAB, labels = .CS17_LBL, hash = NULL) { + if (is.null(hash)) hash <- msuiter_hash_labels(as.character(labels)) + list(name = name, labels = labels, hash = hash) +} +.cs17_zero32 <- function() paste0(rep_len("0", 32L), collapse = "") +## <> (do not hand-edit in place: edit the source and +## re-splice) ## + + +# =========================================================================== +# U1 -- rails: the runner exists and speaks the exported face, never an +# internal (banned-word grep over its full source). +# =========================================================================== +test_that("runner speaks the exported-face rails", { + if (is.na(.ms_root)) skip("repository checkout not locatable (R CMD check context)") + runner <- file.path(.ms_root, "bench", "scenarios", "run_catalog_witness.R") + expect_true(file.exists(runner)) + src <- paste(readLines(runner, warn = FALSE), collapse = "\n") + for (need in c("--file=", "[attest]", "OVERALL PASS", "ms_catalog(", "cs17_", + "commandArgs", "digest::digest", "serialize = FALSE", + "charToRaw", "open = \"wb\"", "na = \"\"", "quote = FALSE", + "row.names = FALSE", "RNG-STATE-RAIL", ".ms_fit_sha256")) { + expect_true(grepl(need, src, fixed = TRUE), info = need) + } + ## The bans govern the hand-written region: the minted frozen block is + ## OBSERVED DATA and legitimately quotes the face's own bytes (the + ## input-class clause names msuiter_hash_labels and the gate clauses + ## quote the S7 message). Slice the two injected regions out before the + ## absence scan; marker integrity itself is rail-checked here. + lines <- strsplit(src, "\n", fixed = TRUE)[[1L]] + .region <- function(beg, end) { + b <- which(vapply(lines, function(l) grepl(beg, l, fixed = TRUE), logical(1L))) + e <- which(vapply(lines, function(l) grepl(end, l, fixed = TRUE), logical(1L))) + expect_identical(length(b), 1L, info = beg) + expect_identical(length(e), 1L, info = end) + c(b, e) + } + drop <- c(seq(.region("## < 626: the CS-17 scenario row +# (test-scenario-catalog-witness.R, 1 s integer weight, 265 expects) joined +# the T0 roster; witness: local run nb=265 failed=0 error=0 warning=0, measured +# manifest sum 626 (generator refusal witnessed at the pre-seal re-mint +# attempt, the verbatim DEFECT line naming 626 against the sealed 625). key value note -t0-measured 625 measured 2026-11-23 (integer manifest seconds, tier T0; 2026-11-23 seal 624 superseded by the CS-16 row) +t0-measured 626 measured 2026-11-24 (integer manifest seconds, tier T0; 2026-11-24 seal 625 superseded by the CS-17 row) t0-ceiling 800 t0-measured + one drift class; re-seal deliberately with a witness diff --git a/tools/ci/shard-manifest.tsv b/tools/ci/shard-manifest.tsv index 0b136fc..80d1520 100644 --- a/tools/ci/shard-manifest.tsv +++ b/tools/ci/shard-manifest.tsv @@ -11,101 +11,102 @@ shard file seconds tier 4 test-pkgdown-coherence.R 1 T0 4 test-refdb.R 373 T1 4 test-scenario-calibration-verdict.R 1 T0 -4 test-scenario-downsample.R 1 T0 -4 test-scenario-qc-artifacts.R 1 T0 -4 test-scenario-segments-witness.R 1 T0 -4 test-scenarios-gallery.R 1 T0 +4 test-scenario-currency-witness.R 1 T0 +4 test-scenario-hrd.R 0 T0 +4 test-scenario-io-interop-witness.R 1 T0 +4 test-scenario-refdb-witness.R 1 T0 +4 test-scenario-stratify.R 1 T0 4 test-site-deploy-bundle.R 3 T0 4 test-viz-batch2.R 2 T0 4 test-viz-first-batch.R 11 T0 4 test-xval-sigminer.R 10 T0 5 test-calibrate-real.R 1 T0 +5 test-calibrate.R 0 T0 +5 test-capability-matrix-truth.R 0 T0 +5 test-catalog-tally.R 0 T0 +5 test-channels-reference.R 0 T0 +5 test-channels-structure.R 0 T0 +5 test-channels-sync.R 0 T0 +5 test-check-layout-sim-gen.R 0 T0 +5 test-check-layout-sim-sdkroot.R 0 T0 5 test-check-layout-sim.R 15 T0 +5 test-classes-benchmark.R 0 T0 +5 test-classes-catalog.R 0 T0 +5 test-classes-engines.R 0 T0 +5 test-classes-fit.R 0 T0 +5 test-classes-refdb.R 0 T0 +5 test-classes-roundtrip.R 0 T0 +5 test-classes-signature.R 0 T0 +5 test-classes-utils.R 0 T0 +5 test-classes-variants.R 0 T0 5 test-docs-extending-surface.R 1 T0 +5 test-docs-sync.R 0 T0 5 test-docs-tour-executable.R 10 T0 +5 test-engines-registry.R 0 T0 +5 test-extend-contract.R 0 T0 5 test-extract.R 16 T0 +5 test-ffi-probes.R 0 T0 +5 test-ffi-surface-drift.R 0 T0 +5 test-ffi-tally.R 0 T0 +5 test-fit.R 0 T0 +5 test-gitignore-hygiene.R 0 T0 5 test-hrd-independent.R 0 T0 +5 test-hrd-reference.R 0 T0 +5 test-hrd-report.R 0 T0 +5 test-io-segments.R 0 T0 +5 test-io-sv.R 0 T0 +5 test-io-variants.R 0 T0 +5 test-islam-xval.R 0 T0 +5 test-kernel-cli.R 0 T0 +5 test-kernel-gate-evidence.R 0 T0 +5 test-kernel-pipeline-batch.R 0 T0 5 test-kernel-pipeline-farm.R 5 T0 +5 test-kernel-pipeline-parse.R 0 T0 +5 test-kernel-pipeline-status.R 0 T0 5 test-kernel-trace-shape.R 1 T0 +5 test-ms-cluster.R 0 T0 5 test-ms-compare.R 9 T0 +5 test-ms-convert.R 0 T0 5 test-ms-downsample-io.R 36 T0 5 test-ms-embed.R 2 T0 +5 test-ms-exposure-test.R 0 T0 5 test-ms-qc-report.R 112 T0 5 test-ms-qc-sentries.R 280 T1 +5 test-ms-simulate.R 0 T0 +5 test-pkgdown-citation.R 0 T0 +5 test-pkgdown-reference-map.R 0 T0 +5 test-r-floor-ops.R 0 T0 +5 test-release-materials.R 0 T0 +5 test-reproduce-link.R 0 T0 +5 test-rng-hygiene.R 0 T0 5 test-scenario-ard-witness.R 1 T0 5 test-scenario-atlas.R 2 T0 -5 test-scenario-currency-witness.R 1 T0 -5 test-scenario-hrd.R 0 T0 -5 test-scenario-io-interop-witness.R 1 T0 -5 test-scenario-refdb-witness.R 1 T0 -5 test-scenario-stratify.R 1 T0 +5 test-scenario-cluster-witness.R 1 T0 +5 test-scenario-exposure-witness.R 1 T0 +5 test-scenario-hrd-baselines.R 0 T0 +5 test-scenario-reconstruction.R 1 T0 +5 test-scenario-sparse-spec-witness.R 1 T0 +5 test-sitrep.R 0 T0 +5 test-stratify.R 0 T0 +5 test-vendor-gate-law.R 0 T0 +5 test-viz-bootstrap.R 0 T0 +5 test-viz-kselect.R 0 T0 6 test-calibrate-plot.R 1 T0 -6 test-calibrate.R 0 T0 -6 test-capability-matrix-truth.R 0 T0 -6 test-catalog-tally.R 0 T0 -6 test-channels-reference.R 0 T0 -6 test-channels-structure.R 0 T0 -6 test-channels-sync.R 0 T0 -6 test-check-layout-sim-gen.R 0 T0 -6 test-check-layout-sim-sdkroot.R 0 T0 6 test-ci-shard-map.R 8 T0 6 test-cjk-census.R 9 T0 -6 test-classes-benchmark.R 0 T0 -6 test-classes-catalog.R 0 T0 -6 test-classes-engines.R 0 T0 -6 test-classes-fit.R 0 T0 -6 test-classes-refdb.R 0 T0 -6 test-classes-roundtrip.R 0 T0 -6 test-classes-signature.R 0 T0 -6 test-classes-utils.R 0 T0 -6 test-classes-variants.R 0 T0 6 test-docs-bridge.R 1 T0 -6 test-docs-sync.R 0 T0 -6 test-engines-registry.R 0 T0 -6 test-extend-contract.R 0 T0 -6 test-ffi-probes.R 0 T0 -6 test-ffi-surface-drift.R 0 T0 -6 test-ffi-tally.R 0 T0 -6 test-fit.R 0 T0 -6 test-gitignore-hygiene.R 0 T0 -6 test-hrd-reference.R 0 T0 -6 test-hrd-report.R 0 T0 -6 test-io-segments.R 0 T0 -6 test-io-sv.R 0 T0 -6 test-io-variants.R 0 T0 -6 test-islam-xval.R 0 T0 6 test-kernel-attest-route.R 1 T0 6 test-kernel-batch-bridge.R 172 T0 -6 test-kernel-cli.R 0 T0 -6 test-kernel-gate-evidence.R 0 T0 -6 test-kernel-pipeline-batch.R 0 T0 -6 test-kernel-pipeline-parse.R 0 T0 -6 test-kernel-pipeline-status.R 0 T0 6 test-kselect.R 28 T0 6 test-m2-e2e.R 2 T0 6 test-ms-benchmark-driver.R 208 T1 -6 test-ms-cluster.R 0 T0 6 test-ms-compare-boundary.R 2 T0 -6 test-ms-convert.R 0 T0 -6 test-ms-exposure-test.R 0 T0 -6 test-ms-simulate.R 0 T0 6 test-peer-evidence.R 3 T0 -6 test-pkgdown-citation.R 0 T0 6 test-pkgdown-msu-map.R 1 T0 -6 test-pkgdown-reference-map.R 0 T0 -6 test-r-floor-ops.R 0 T0 -6 test-release-materials.R 0 T0 -6 test-reproduce-link.R 0 T0 -6 test-rng-hygiene.R 0 T0 -6 test-scenario-cluster-witness.R 1 T0 -6 test-scenario-exposure-witness.R 1 T0 -6 test-scenario-hrd-baselines.R 0 T0 -6 test-scenario-reconstruction.R 1 T0 -6 test-scenario-sparse-spec-witness.R 1 T0 +6 test-scenario-catalog-witness.R 1 T0 +6 test-scenario-downsample.R 1 T0 +6 test-scenario-qc-artifacts.R 1 T0 +6 test-scenario-segments-witness.R 1 T0 +6 test-scenarios-gallery.R 1 T0 6 test-site-claim-gate.R 42 T0 -6 test-sitrep.R 0 T0 -6 test-stratify.R 0 T0 6 test-treatment-report.R 13 T0 -6 test-vendor-gate-law.R 0 T0 -6 test-viz-bootstrap.R 0 T0 -6 test-viz-kselect.R 0 T0 diff --git a/tools/ci/shard-weights.tsv b/tools/ci/shard-weights.tsv index e6047cc..f002790 100644 --- a/tools/ci/shard-weights.tsv +++ b/tools/ci/shard-weights.tsv @@ -123,3 +123,4 @@ test-scenario-sparse-spec-witness.R 1 323 T0 test-scenario-segments-witness.R 1 1704 T0 test-scenario-refdb-witness.R 1 273 T0 test-scenario-ard-witness.R 1 246 T0 +test-scenario-catalog-witness.R 1 265 T0 diff --git a/vignettes/articles/devlog-2026-11-23-p3-cs17-catalog-witness.qmd b/vignettes/articles/devlog-2026-11-23-p3-cs17-catalog-witness.qmd new file mode 100644 index 0000000..623e75c --- /dev/null +++ b/vignettes/articles/devlog-2026-11-23-p3-cs17-catalog-witness.qmd @@ -0,0 +1,204 @@ +--- +title: "P3-CS-17 catalog-witness: the shipped governance-container face adjudicated over planted catalog calls" +format: html-vignette +--- + +## Decision record: what the governance-container face promises, and what its receipts look like + +::: {.callout .callout-note} +**Decision.** CS-17 is a witness, not a specification: it freezes what the +exported `ms_catalog()` factory and the `MsCatalog` constructor actually +adjudicate over planted calls, so future drift speaks immediately. It +commits only machine-stable facts: the error CLASS always, and the message +CLAUSES verbatim -- every one of them. The container is pure R -- no file +path, clock or RNG touches its verdicts, and the label digest is hex -- +so the ledger was DET-proved byte-stable across probe reruns, and no arm +needed the `stable3` bullet-subset posture that CS-13/CS-14 required for +their file paths or the payload-census posture that CS-6 required for its +ill-conditioned floats. The lane also refuses its own sketches: the +census and ordering claims below are read from the committed witnesses, +not from the build plan -- three times this page's draft numbers were +corrected against the committed bytes (37/2/3 not 39/1/3; five accepted +boundary rows not four) before anything was burned. +::: + +### The face + +`ms_catalog(counts, channels, samples, provenance)` is the exported +constructor of the governance container: an S7 class (four properties -- +`counts`, `channels`, `samples`, `provenance`) behind TWO admission gates +-- the S7 property gates, then the seventeen-arm `msuiter_validate_catalog` +validator -- with a second error class, `msuiter_error_input`, reachable +only through the shared label-digest helper the snapshot path consults. +CS-17 fires 60 observation arms at it plus eight boundary-pair rows: 42 +law arms, 6 acceptance specs, 10 precedence discriminators, 8 degenerate +rows (4 pairs), 10 scalars. The committed lane replays every arm live: +the law file adjudicates 265 expectations across 10 units (0 failed, 0 +errors, 0 warnings) and the runner rails every row against the frozen +block before any witness byte is written. + +### The double gate -- measured at its true boundary + +The property-gate/validator split is committed as measured, and the +measurement moved the boundary once: three arms (`channels`, `samples`, +`provenance` with the wrong type) die as `simpleError` at the property +gates -- ` object properties are invalid: | - @channels +must be , not ` and its two siblings -- before any +validator arm runs. The fourth property, `counts`, is gated +`class_any`: a character matrix and a bare numeric vector both REACH the +validator and are refused there as `msuiter_error_catalog` ("counts must +be a numeric matrix (channels x samples)"). The lane caught the planned +expectation mid-build: a scalar-count gate arm had been drafted as a +fourth `simpleError`, and the live fire refused that claim -- the gate +accepts, the validator speaks. It was committed as the measured 42-arm +census 37 validator + 3 property-gate + 2 shared-digest-input instead. The +two +`msuiter_error_input` arms are the discovery worth naming: the CS-13-era +fixture trick of feeding the label field as `as.character(NA_integer_)` +REVERSES on this face. The real typed NA survives `as.character`, rides +into the factory's auto-hash path, and the shared digest helper refuses +it -- "channel labels to hash must be a character vector without NA". +The face keeps the old trap as a live acceptance; the witness commits +both halves (the accepting twin and the refusing twin) side by side. + +### The laws the face demonstrates + +- **The snapshot law.** The channel snapshot must be a list with exactly + the fields `name`, `labels`, `hash`; an empty list, a missing field and + an extra field each refuse with their own bullet ("received fields: + ..." names what arrived). The stored `hash` is checked against the + stored `labels` -- "snapshot hashes must be derived, not asserted" -- + so a foreign digest cannot impersonate canonical labels. +- **The digest law.** The label digest is the same + `msuiter_hash_labels` the registry face (CS-15) commits: the witness + carries its two canonical digests as scalars (`d3b77a57...` for the + four-label plant, `e10fea09...` for the 1x1 minimal) and a hand-hash + arm proves the shape-vs-truth ordering (a non-hex string dies on + shape before a foreign hex dies on truth). +- **The identity laws.** Row names must exist, be unique and match the + label roster in order (a permutation of the labels is a decoy, refused + by its own clause); column names must equal the `samples` roster; + counts must be finite, non-negative, integral-valued cells (NA, Inf, + NaN, negative each refused with its received-shape bullet). +- **Precedence.** Ten discriminators, each with its fires anchor pinned + PRESENT and its anti anchor pinned ABSENT in the same live message -- + gate before validator, dimensions before label-match, uniqueness before + dimensions and before finiteness, hash-shape before hash-truth, the + named-snapshot law before the genome law. One ordering was committed + against the lane's own plan: with BOTH a mismatched colnames roster and + an NA sample planted, the column-vs-samples law fires first and the + sample-sanity clause never surfaces -- the plan had expected the + reverse, and the measurement outranks the expectation. +- **The acceptance specs.** The canonical 4x2 double container renders + its full identity line (`msuiter::MsCatalog|4|2|double|TRUE|TRUE|| + `) -- the boolean pair committing that row names match + labels and colnames match samples; the skipped tail (`n_skipped` 7 of + `n_variants` 42) renders in the format line IDENTICALLY under an + integer and a double provenance payload (the dual-kernel tail rail); + the integer plant commits its storage-mode glyph (`|integer|`) exactly + where a silent coercion would erase it; and replaying the committed + spec through `ms_catalog()` reproduces it byte-for-byte -- the + replay-identity spec welds two renders with `==`. + +### The receipts + +| receipt | committed bytes | +|---|---| +| `cs17_specs.tsv` | 6 accepted arms: class token `s7:msuiter::MsCatalog` plus the full identity rendering (shape, storage glyph, both identity bits, digest, format line), and the `s7:character` replay identity | +| `cs17_laws.tsv` | 42 arms: class census MEASURED 37 validator + 3 property-gate + 2 shared-digest-input, every clause verbatim, every mode `reject` | +| `cs17_precedence.tsv` | 10 discriminators, each with its fires anchor PRESENT and its anti anchor ABSENT in the live message | +| `cs17_degenerates.tsv` | 4 boundary pairs (8 rows): the legal 4x0 empty queue against the zero-channel container, the row-uniqueness law against the row-existence law, the 1x1 minimal against the empty queue, the skipped tail against its absence -- hi and lo committed side by side | +| `cs17_scalars.tsv` | 10 keys: the gate-boundary class token, both storage glyphs, the two canonical digests, the format line, the dual-kernel tail pair, and both RNG-purity rails (the adjudication core never seeds) | + +The 66-row class census (`msuiter_error_catalog=49`, +`msuiter_error_input=2`, `simpleError=4`, `s7:character=1`, +`s7:msuiter::MsCatalog=10`, over the four committing rosters) is +recomputed from the frozen vectors inside the law file -- a silent class +shift reddens the lane, not the reader. All five witnesses byte-reproduce +on consecutive runner invocations, the plant and spec corpora hash +identically under BOTH governed SHA-256 kernels (`.ms_fit_sha256` and +digest), and the lane never touches the RNG, the network, the benchmark +driver, the declined calibration family, or any unexported internal +(banned-word rails over the hand-written region, marker-scoped and +grepped). + +### The single-source build, and the audit that became the minter + +Both hosts -- law file and runner -- carry one byte-identical frozen +block and one byte-identical shared code block, each injected from a +single source between BEGIN/END markers; the splice rail demands the +exact marker counts (the law file legitimately quotes each marker three +times, twice inside its own runtime region-scan literals) and compares +the two regions across the files byte for byte. The minter IS the audit: +every one of the 60 roster plants and the 8 text-twins is re-fired LIVE +through the canonical pipeline against the audited probe ledger +(60 rows, 53 rejects / 7 accepts, DET across two probe runs); each of +the 22 precedence-path arms carries an explicit decision-record path +whose FIRES/ANTI alignment is asserted order-invariantly; every scalar is +re-fireable and re-fired; and a final RE-AUDIT re-sources the EMITTED +block into a cleared namespace and re-compares every committed literal +against the ledger -- so emitter drift, chunking drift and quoting drift +all die at mint time, not at read time. The committed clause bytes in +this page are read from the committed witnesses, never re-typed from +plan. + +### What the lane-building itself caught (the honest section) + +The live replay killed a whole family of would-be-innocent bugs before +one witness byte was trusted. (1) The base's `vapply` is `sapply`: it +attaches value-names to a character result, and the frozen-block +comparisons then failed on an ATTRIBUTE that no printed byte showed -- +identical() reddled while both sides looked the same in every dump; the +comparands now strip. (2) The base's `read.csv` is camelCase-gated: +`stringsasfactors`/`colclasses` in the committed idiom died as +"unused argument"; the ledger's first mint carried a phantom sixth +column before the arg casing was fixed -- and the 5-column census was +already on the wall to catch it. (3) The rail needle for the +zero-column-identity pair had been drafted from the plan sketch +(`|4|0|TRUE|FALSE|`) and the measurement put the storage-mode glyph INSIDE +the pair (`|4|0|double|TRUE|FALSE|`); the runner rail and the law +assertion were both corrected against the measured bytes, not the +sketch. (4) `R --slave -f` does not inject `--file=` the way `Rscript` +does (the CLI-face law again): the runner's self-located ROOT silently +fell back to the working directory, the provisioning probe missed +DESCRIPTION, and the `library(msuiter)` fallback loaded a stale +installed build -- whose counts gate was a DIFFERENT face (a +`simpleError` where the tree's face speaks `msuiter_error_catalog`). A +provisioning drift was minutes from being committed as a finding about +the face; the fix is invocation discipline (`Rscript`, sanctioned form), +and the incident is why the provisioning block and its rails ride the +runner verbatim from the CS-16 idiom. (5) The minter's chunker index +math truncated committed clauses (33 committed bytes against a 99-byte +message) while every visible comparison passed -- the emitted-bytes +re-audit now sources the produced file itself and re-verifies every +literal, so a truncation cannot survive the mint. (6) The compiler-tool +probe (a darwin-27 CLT gap, banked law) reddened the local install +path; the C inputs were attested unchanged against the built `.so` +before its timestamp was advanced to restore the skip path -- the +provisioning-trust law honored, not evaded. + +### Provenance + +The frozen block and the shared code block in both hosts are minted +mechanically from the audited probe ledger (audit green: 60 arms +byte-exact on live re-fire, 8 degen twins, 10/10 fires-and-anti anchors, +10 scalars re-fired); neither is ever hand-edited in place. The plants' +canonical texts hash to the committed dual-kernel checksum +(`plant_sha256=e9e9de78eb43ec9d...`, `spec_sha256=57c4e33e01cea364...`); +reifying the lane reproduces every witness byte for byte. Differentiation +from CS-15 (the reference-container face): CS-15 adjudicated the factory +with its registry-file and cache-path rails; CS-17 adjudicates the +plain in-memory governance container -- its 17-arm validator, the +property-gate boundary MEASURED at three, the digest law shared with the +registry, and the input-class law the snapshot path reaches. + +### Gate forensics + +The scenarios leg for this lane (the sixteenth) was render-verified +STANDALONE before the full local burn -- the CS-16 lesson applied as +procedure, its columns read off committed bytes only, its adjudication +lines printed TRUE for the record. The T0 seal moved 625 -> 626 with +the generator's refusal witnessed verbatim (the DEFECT line naming 626 +against the sealed 625) before the deliberate re-seal, per the budget +law; the reified manifest carries 110 files, the new law file on shard +4, byte-deterministic on re-mint. diff --git a/vignettes/articles/paper-draft.qmd b/vignettes/articles/paper-draft.qmd index c1d8bfc..d858aa5 100644 --- a/vignettes/articles/paper-draft.qmd +++ b/vignettes/articles/paper-draft.qmd @@ -594,6 +594,36 @@ contract behavior on planted truth -- no extraction, benchmark or kernel-execution claim. Zero new machinery. Authority: vignettes/articles/devlog-2026-11-23-p3-cs16-ard-witness.qmd. +- **CS-17 catalog-witness, decision record** (`bench/scenarios/run_catalog_witness.R`): +the exported governance-container face `ms_catalog()`/`MsCatalog` -- the +in-memory count matrix plus channel snapshot, samples roster and provenance +list behind the S7 property gates and the seventeen-arm catalog validator -- +adjudicated over planted catalog calls. The double-gate boundary is committed +AS MEASURED (3 property-gate arms die as `simpleError` before any validator +runs; 37 speak the validator's `msuiter_error_catalog` and 2 the shared +digest's `msuiter_error_input`), and the `counts` +property is measured gated `class_any`: a character matrix and a bare vector +REACH the validator and are refused there, a planned fourth gate arm was +refused by the live fire and committed as the measurement instead. The +CS-13-era `as.character(NA_integer_)` fixture trap REVERSES on this face: +the real typed NA survives `as.character`, rides the factory's auto-hash +path, and the shared label digest refuses it as the SECOND error class +`msuiter_error_input` (both twins committed). The snapshot law (fields +`name`/`labels`/`hash`, extras and absences each named), the derived-hash +law ("snapshot hashes must be derived, not asserted"), the +labels-vs-rownames and samples-vs-colnames identity laws, and the finiteness +laws each commit their clauses verbatim; ten precedence discriminators each +pinned fires-anchor-present/anti-anchor-absent (one ordering committed +against the lane's own plan: the colnames-vs-samples law outranks the +sample-sanity law); the skipped tail renders byte-identically under integer +and double provenance payloads, the integer plant keeps its storage-mode +glyph, and the replay identity welds two renders of the committed spec with +`==` (265 expectations across 10 units, rerun byte-identical 5/5, zero +failures/errors/warnings). Decision-record posture: the container's +contract behavior on planted truth -- no extraction, benchmark or +reference-content claim. Zero new machinery. Authority: +vignettes/articles/devlog-2026-11-23-p3-cs17-catalog-witness.qmd. + [FILLED — three-in-one selection] Of the three editor-offered paths that turn the case studies from decorative to forceful (vignettes/articles/review-05-nature-editor.qmd §5: (a) a treatment-history cohort with real treatment-record concordance; (b) an @@ -797,7 +827,7 @@ the reference database reaches users through the governed mirror path only | Fig. 2 | Architecture block diagram (two-tier core, FFI shell, kernel CLI boundary) | to be drawn from vignettes/articles/architecture.qmd §2 by the controller's illustrator; DRY law: no new claims | | Fig. 3 | Table 1 as a visual verdict board (MEASURED-false rows shown as such) | data FILLED §3.3 | | Fig. 4 | O5 census heat strip (8 faces x 21 classes = 168 cells, color=cpu-ratio) | data FILLED §3.3 Table 2 (log banked) | -| Fig. 5 | Scenario adjudication panels (CS-1 atlas, CS-2 dual-oracle, CS-3 treatment, CS-4 artifact forensics, CS-5 stratification decision, CS-6 downsample frontier, CS-7 reconstruction witness, CS-8 cluster witness, CS-9 currency witness, CS-10 exposure witness, CS-11 calibration witness, CS-12 sparse-spec witness, CS-13 io-interop witness, CS-14 segments-witness, CS-15 refdb-witness, CS-16 ard-witness) | data FILLED §3.4, outputs bench/scenarios/out/* | +| Fig. 5 | Scenario adjudication panels (CS-1 atlas, CS-2 dual-oracle, CS-3 treatment, CS-4 artifact forensics, CS-5 stratification decision, CS-6 downsample frontier, CS-7 reconstruction witness, CS-8 cluster witness, CS-9 currency witness, CS-10 exposure witness, CS-11 calibration witness, CS-12 sparse-spec witness, CS-13 io-interop witness, CS-14 segments-witness, CS-15 refdb-witness, CS-16 ard-witness, CS-17 catalog-witness) | data FILLED §3.4, outputs bench/scenarios/out/* | | Suppl. | Calibration curves 198-cell; reproduction protocol; law-family inventories | committed faces cited §4.5, §3.5 | ## 9. Bibliography diff --git a/vignettes/docs-bridge.Rmd b/vignettes/docs-bridge.Rmd index 9e13a02..f251000 100644 --- a/vignettes/docs-bridge.Rmd +++ b/vignettes/docs-bridge.Rmd @@ -167,3 +167,4 @@ guides), start at [Get started](get-started.html) and the [tour](tour.html). | [CS-14 segments-witness — the shipped segment face adjudicated over planted TSV bytes: the caller-routed column law, the declared-role law, the mutation_type legality law, the Battenberg block law, the Sequenza sum law, and four precedence discriminators (reified, paper-grade)](devlog-2026-11-23-p3-cs14-segments-witness.html) | `devlog-2026-11-23-p3-cs14-segments-witness` | | [CS-15 refdb-witness — the shipped reference-container factory adjudicated over planted R objects: the label-key law, the FFI no-NA ban, the first-matrix channel authority, the A13 cross-field clause, the lowercase-only digest policy, and four precedence discriminators (reified, paper-grade)](devlog-2026-11-23-p3-cs15-refdb-witness.html) | `devlog-2026-11-23-p3-cs15-refdb-witness` | | [CS-16 ard-witness — the shipped ARD engine descriptor adjudicated over planted constructor calls: the double-gate split as measured, the discovered abort-plumbing class, the (named)-params permissiveness, the welded seed domain, and eight precedence discriminators (reified, paper-grade)](devlog-2026-11-23-p3-cs16-ard-witness.html) | `devlog-2026-11-23-p3-cs16-ard-witness` | +| [CS-17 catalog-witness — the shipped governance-container face adjudicated over planted catalog calls: the double-gate boundary measured at three, the class-any counts rail, the derived-hash law, the reversed typed-NA fixture trap, and ten precedence discriminators (reified, paper-grade)](devlog-2026-11-23-p3-cs17-catalog-witness.html) | `devlog-2026-11-23-p3-cs17-catalog-witness` | diff --git a/vignettes/scenarios.Rmd b/vignettes/scenarios.Rmd index 6cb4f9c..422bbc4 100644 --- a/vignettes/scenarios.Rmd +++ b/vignettes/scenarios.Rmd @@ -43,7 +43,7 @@ knitr::opts_chunk$set(collapse = TRUE, comment = "#>") msuiter's paper pillar 3 is the application-scenario layer: end-to-end workflows that adjudicate against planted truth or an independent oracle and -persist their evidence tables. The sixteen executable drivers live under +persist their evidence tables. The seventeen executable drivers live under `bench/scenarios/` (`run_atlas.R`, `run_hrd.R`, `run_treatment.R`, `run_qc_artifacts.R`, `run_stratify.R`, `run_downsample.R`, `run_reconstruction.R`, `run_cluster_witness.R`, @@ -51,7 +51,8 @@ persist their evidence tables. The sixteen executable drivers live under `run_calibration_verdict.R`, `run_sparse_spec_witness.R`, `run_io_interop_witness.R`, `run_segments_witness.R`, `run_refdb_witness.R`, -`run_ard_witness.R`; committed +`run_ard_witness.R`, +`run_catalog_witness.R`; committed evidence under `bench/scenarios/out/`, each driver ends in its own OVERALL PASS or OVERALL FAIL verdict line). This page runs one reduced, runnable snippet of each against the same committed fixture generators the @@ -990,6 +991,95 @@ contract on the exported surface and the declined-scope rails -- are the manual pages (`?ms_ard`) and the scenario devlog under `vignettes/articles/devlog-*-p3-cs16-*.qmd`. +## The governance container as a governed witness + +The sixteenth scenario adjudicates the EXPORTED `ms_catalog()` face -- the +in-memory governance container behind the count matrix, channel snapshot, +samples roster and provenance list -- over synthetic catalog plants: the +seventeen-arm catalog validator (numeric-matrix counts, existing and unique +row labels matching the snapshot labels, colnames matching samples, finite +non-negative cells, the exact `name`/`labels`/`hash` snapshot shape, the +derived-hash law, the named-provenance and genome laws), with the +property-gate boundary MEASURED at three `simpleError` deaths against 37 +validator `msuiter_error_catalog` refusals and the two shared-digest +`msuiter_error_input` refusals -- the `counts` property is +gated `class_any`, so wrong-shape counts reach the validator and are +refused there -- plus the second voice the snapshot path reaches: the +shared label digest refusing NA-bearing labels as `msuiter_error_input`, +with the CS-13-era `as.character(NA_integer_)` trap REVERSED on this face +(a real typed NA now survives into the auto-hash path and is refused +there). Ten precedence discriminators with fires-anchor-present / +anti-anchor-absent rails and four degenerate boundary pairs complete the +census. + +```{r catalog-witness, message = FALSE} +out <- file.path(PKG, "bench", "scenarios", "out") +if (dir.exists(out)) { + rd <- function(f) read.table(file.path(out, f), header = TRUE, sep = "\t", + quote = "", colClasses = "character", + na.strings = "", stringsAsFactors = FALSE) + lw <- rd("cs17_laws.tsv"); sp <- rd("cs17_specs.tsv") + pc <- rd("cs17_precedence.tsv"); dg <- rd("cs17_degenerates.tsv") + sc <- rd("cs17_scalars.tsv") + sv <- setNames(as.character(sc$value), as.character(sc$key)) + cnt <- tabulate(match(lw$cls, c("msuiter_error_catalog", + "msuiter_error_input", "simpleError"))) + split_ok <- identical(as.integer(cnt), c(37L, 2L, 3L)) && + nrow(lw) == 42L && all(lw$mode == "reject") + roster_ok <- grepl("object properties are invalid", + lw$msg[lw$arm == "G1-channels-nonlist"], fixed = TRUE) && + grepl("hashes must be derived, not asserted", + lw$msg[lw$arm == "V14-hash-foreign"], fixed = TRUE) && + grepl("must be unique", lw$msg[lw$arm == "V9-snap-labels-dup"], + fixed = TRUE) && + grepl("without NA", lw$msg[lw$arm == "E2-NAinteger-label-trap"], + fixed = TRUE) && + identical(sv[["storage-integer"]], "integer") + pr <- pc[pc$arm == "PR3-anchor-uniqueness-over-finiteness", ] + sh <- lw$msg[lw$arm == "V3-rowlabels-dup"] + prec_ok <- nrow(pc) == 10L && all(pc$fires_ok == "TRUE") && + all(pc$anti_ok == "TRUE") && length(sh) == 1L && length(pr$msg) == 1L && + identical(pr$msg, sh) && + grepl("must be unique", sh, fixed = TRUE) && + !grepl("finite", sh, fixed = TRUE) + dg_ok <- nrow(dg) == 8L && sum(dg$mode == "accept") == 5L && + identical(dg$mode[dg$arm == "empty-queue-hi"], "accept") && + identical(dg$mode[dg$arm == "zero-channels-lo"], "reject") && + grepl("; skipped 7/42 variants", + dg$msg[dg$arm == "skipped-tail-hi"], fixed = TRUE) && + !grepl("; skipped 7/42 variants", + dg$msg[dg$arm == "core-nontail-lo"], fixed = TRUE) + core <- sp$msg[sp$arm == "A1-accept-core"] + rep1 <- sp$msg[sp$arm == "sp-replay-identity"] + intp <- sp$msg[sp$arm == "A4-accept-int-plant"] + ti <- sv[["tail-int"]]; td <- sv[["tail-dbl"]] + spec_ok <- nrow(sp) == 6L && length(core) == 1L && length(rep1) == 1L && + grepl("|4|2|double|TRUE|TRUE|", core, fixed = TRUE) && + grepl("==", rep1, fixed = TRUE) && + grepl("|integer|", intp, fixed = TRUE) && + grepl("; skipped 7/42 variants", ti, fixed = TRUE) && + identical(ti, td) + rng_ok <- identical(sv[["rng-before"]], "FALSE") && + identical(sv[["rng-after"]], "FALSE") + cat("the 42-law class census splits 37/2/3 between validator, the shared", + "digest class and the property gate exactly as committed:", + split_ok, "| the gate, derived-hash, uniqueness and digest clauses", + "speak verbatim and the integer plant keeps its glyph:", + roster_ok, "\n") + cat("the precedence row cannot trade clauses under both anchors:", prec_ok, + "| the four boundary pairs stand (5 accepted, 3 refused):", dg_ok, + "| the canonical rendering, replay identity and dual-kernel tail hold:", + spec_ok, "| the adjudication core is RNG-free:", rng_ok, "\n") +} +``` + +The committed tables for this leg: `bench/scenarios/out/cs17_specs.tsv`, +`cs17_laws.tsv`, `cs17_precedence.tsv`, `cs17_degenerates.tsv` and +`cs17_scalars.tsv`. The certified backing -- the face's documented +contract on the exported surface and the declined-scope rails -- are the +manual pages (`?ms_catalog`) and the scenario devlog under +`vignettes/articles/devlog-*-p3-cs17-*.qmd`. + ## Reproducing the full verdicts Each driver prints its own adjudication lines and exits zero only on @@ -1012,4 +1102,5 @@ Rscript bench/scenarios/run_io_interop_witness.R Rscript bench/scenarios/run_segments_witness.R Rscript bench/scenarios/run_refdb_witness.R Rscript bench/scenarios/run_ard_witness.R +Rscript bench/scenarios/run_catalog_witness.R ```