Retire the lowerer source pin: one prompt pin over context, split and lower

Deletes LOWERER_SOURCE_DIGEST, DriftOf::Lowerer, RunRecord key 7 and
RoundRecord key 3 (retired, never reused). PROMPT_SOURCE_DIGEST now covers
lower.rs, which the lowering prompt will read. Schemas regenerated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Weksa 2026-11-10 09:10:56 +00:00
commit 3b7a6803bc
4 changed files with 25 additions and 55 deletions

View file

@ -40,16 +40,16 @@ use crate::store::{CorpusStore, EntityStore, InventoryStore, PacketStore, open_c
/// The digest of the prompt builder's source: `context.rs`, then `split.rs`,
/// whose scheme and digest function decide which lines the prompt holds as
/// Train and name every prompt. Each file enters the digest behind its length,
/// so the pair cannot be re-cut into another pair with the same digest. Any
/// edit to either, comments included, ends a run; code outside those files is
/// not covered.
pub const PROMPT_SOURCE_DIGEST: u64 =
fnv1a64_of(&[include_bytes!("context.rs"), include_bytes!("split.rs")]);
/// The digest of the lowerer's source. Any edit to `lower.rs`, comments
/// included, ends a run; code outside that file is not covered.
pub const LOWERER_SOURCE_DIGEST: u64 = fnv1a64(include_bytes!("lower.rs"));
/// Train and name every prompt, then `lower.rs`, whose `TARGET_LANGUAGE` and
/// `EntityForms` port the lowering prompt reads. Each file enters the digest
/// behind its length, so the parts cannot be re-cut into other parts with the
/// same digest. Any edit to any of them, comments included, ends a run; code
/// outside those files is not covered.
pub const PROMPT_SOURCE_DIGEST: u64 = fnv1a64_of(&[
include_bytes!("context.rs"),
include_bytes!("split.rs"),
include_bytes!("lower.rs"),
]);
/// The least composite gain an edit must show over item noise to be kept, and
/// the grid the editor's one held-out number is rounded to. A run releases at
@ -81,8 +81,8 @@ pub struct RunRecord {
pub entity_digest: String,
#[cultcache(key = 6)]
pub prompt_digest: String,
#[cultcache(key = 7)]
pub lowerer_digest: String,
// Key 7 is retired and never reused: a run.cc from before is a scratch run
// off git and does not open.
/// The answering model.
#[cultcache(key = 8)]
pub model: String,
@ -151,7 +151,6 @@ pub struct RefusalCounts {
/// n: 1,
/// inventory_rev: 1,
/// prompt_digest: String::new(),
/// lowerer_digest: String::new(),
/// corpus_digest: String::new(),
/// entity_digest: String::new(),
/// model: String::new(),
@ -178,8 +177,7 @@ pub struct RoundRecord {
inventory_rev: u32,
#[cultcache(key = 2)]
prompt_digest: String,
#[cultcache(key = 3)]
lowerer_digest: String,
// Key 3 is retired and never reused.
#[cultcache(key = 4)]
corpus_digest: String,
#[cultcache(key = 5)]
@ -227,9 +225,6 @@ impl RoundRecord {
pub fn prompt_digest(&self) -> &str {
&self.prompt_digest
}
pub fn lowerer_digest(&self) -> &str {
&self.lowerer_digest
}
pub fn corpus_digest(&self) -> &str {
&self.corpus_digest
}
@ -314,7 +309,6 @@ pub enum DriftOf {
Corpus,
Entities,
Prompts,
Lowerer,
Model,
Embedder,
/// The run's own head inventory file.
@ -512,7 +506,6 @@ impl RunStores {
corpus_digest: String::new(),
entity_digest: String::new(),
prompt_digest: hex16(PROMPT_SOURCE_DIGEST),
lowerer_digest: hex16(LOWERER_SOURCE_DIGEST),
model: model.to_string(),
embedder: embedder.to_string(),
chrf_version: CHRF_VERSION.to_string(),
@ -565,9 +558,6 @@ impl RunStores {
if record.prompt_digest != hex16(PROMPT_SOURCE_DIGEST) {
return Err(RunError::Drift(DriftOf::Prompts));
}
if record.lowerer_digest != hex16(LOWERER_SOURCE_DIGEST) {
return Err(RunError::Drift(DriftOf::Lowerer));
}
check_pins(&cache, root, &record)?;
between();
let run = Self::with(root, cache, record)?;
@ -913,7 +903,6 @@ fn score_round<M: ModelPort, E: Embedder>(
n,
inventory_rev: rev,
prompt_digest: run.record.prompt_digest.clone(),
lowerer_digest: run.record.lowerer_digest.clone(),
corpus_digest: run.record.corpus_digest.clone(),
entity_digest: run.record.entity_digest.clone(),
model: run.record.model.clone(),
@ -1346,7 +1335,6 @@ mod tests {
n: 1,
inventory_rev: 1,
prompt_digest: String::new(),
lowerer_digest: String::new(),
corpus_digest: String::new(),
entity_digest: String::new(),
model: String::new(),
@ -1558,7 +1546,6 @@ mod tests {
n,
inventory_rev: 1,
prompt_digest: String::new(),
lowerer_digest: String::new(),
corpus_digest: String::new(),
entity_digest: String::new(),
model: String::new(),
@ -1589,7 +1576,6 @@ mod tests {
corpus_digest: String::new(),
entity_digest: String::new(),
prompt_digest: String::new(),
lowerer_digest: String::new(),
model: String::new(),
embedder: String::new(),
chrf_version: String::new(),

View file

@ -108,10 +108,6 @@ fn open_checks_each_pin_by_name() {
drift(&|r| r.prompt_digest = "0".repeat(16)),
Some(RunError::Drift(DriftOf::Prompts))
);
assert_eq!(
drift(&|r| r.lowerer_digest = "0".repeat(16)),
Some(RunError::Drift(DriftOf::Lowerer))
);
assert_eq!(
drift(&|r| r.corpus_digest = "0".repeat(16)),
Some(RunError::Drift(DriftOf::Corpus))
@ -339,7 +335,7 @@ fn a_run_from_before_the_copy_does_not_open() {
corpus_digest: current.corpus_digest,
entity_digest: current.entity_digest,
prompt_digest: current.prompt_digest,
lowerer_digest: current.lowerer_digest,
lowerer_digest: String::new(),
model: current.model,
embedder: current.embedder,
chrf_version: current.chrf_version,
@ -459,24 +455,26 @@ fn a_head_inventory_changed_between_its_digest_and_its_open_is_drift() {
#[test]
fn source_digests_cover_their_files() {
let src = Path::new(env!("CARGO_MANIFEST_DIR")).join("src");
let digest = |name: &str| fnv1a64(&std::fs::read(src.join(name)).unwrap());
// The prompt's partition and names come from split.rs: it is covered too.
let (context, split) = (
std::fs::read(src.join("context.rs")).unwrap(),
std::fs::read(src.join("split.rs")).unwrap(),
);
// Each file enters behind its length, so the pair has one framing.
let read = |name: &str| std::fs::read(src.join(name)).unwrap();
let digest = |name: &str| fnv1a64(&read(name));
// The prompt's partition and names come from split.rs, and the lowering
// prompt reads lower.rs's target language and entity port: all three are
// covered.
let (context, split, lower) = (read("context.rs"), read("split.rs"), read("lower.rs"));
// Each file enters behind its length, so the parts have one framing.
let framed = [
(context.len() as u64).to_le_bytes().as_slice(),
&context,
(split.len() as u64).to_le_bytes().as_slice(),
&split,
(lower.len() as u64).to_le_bytes().as_slice(),
&lower,
]
.concat();
assert_eq!(weksa::run::PROMPT_SOURCE_DIGEST, fnv1a64(&framed));
assert_ne!(
weksa::run::PROMPT_SOURCE_DIGEST,
fnv1a64(&[context.clone(), split.clone()].concat()),
fnv1a64(&[context.clone(), split.clone(), lower.clone()].concat()),
"bare concatenation is not the digest"
);
// Moving the boundary between the parts moves the digest.
@ -485,11 +483,6 @@ fn source_digests_cover_their_files() {
weksa::split::fnv1a64_of(&[b"a", b"bc"])
);
assert_ne!(weksa::run::PROMPT_SOURCE_DIGEST, digest("context.rs"));
assert_eq!(weksa::run::LOWERER_SOURCE_DIGEST, digest("lower.rs"));
assert_ne!(
weksa::run::PROMPT_SOURCE_DIGEST,
weksa::run::LOWERER_SOURCE_DIGEST
);
}
/// The encode prompt of `item:nibu:1` over `world()` at revision 4.
@ -860,7 +853,6 @@ fn round_over_the_dao_stores_scores_train_and_validation() {
// The record carries the run's pins.
assert_eq!(r.prompt_digest(), pinned.prompt_digest);
assert_eq!(r.lowerer_digest(), pinned.lowerer_digest);
assert_eq!(r.corpus_digest(), pinned.corpus_digest);
assert_eq!(r.entity_digest(), pinned.entity_digest);
assert_eq!(r.model(), "fake-model");

View file

@ -1,7 +1,7 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "RoundRecord",
"description": "One scored round. It holds no text and no Test reading: per-item rows for\nTrain only, Validation only as means and refusal counts by stage. Only\n`run::round` builds one.\n\n```\nfn f(r: &weksa::run::RoundRecord) -> u32 { r.n() }\n```\n\nEvery field is given, so the literal below fails only on privacy; its twin\nis the same literal in the unit test `a_round_record_literal_compiles_in_the_lib`.\n\n```compile_fail,E0451\nuse weksa::run::{RefusalCounts, RoundRecord};\nuse weksa::score::SplitMean;\nfn f() -> RoundRecord {\n RoundRecord {\n n: 1,\n inventory_rev: 1,\n prompt_digest: String::new(),\n lowerer_digest: String::new(),\n corpus_digest: String::new(),\n entity_digest: String::new(),\n model: String::new(),\n embedder: String::new(),\n chrf_version: String::new(),\n calls: vec![],\n train: vec![],\n train_mean: SplitMean::default(),\n train_scored: 0,\n validation_mean: SplitMean::default(),\n validation_scored: 0,\n validation_refused: RefusalCounts::default(),\n inventory_digest: String::new(),\n cycle: None,\n }\n}\n```",
"description": "One scored round. It holds no text and no Test reading: per-item rows for\nTrain only, Validation only as means and refusal counts by stage. Only\n`run::round` builds one.\n\n```\nfn f(r: &weksa::run::RoundRecord) -> u32 { r.n() }\n```\n\nEvery field is given, so the literal below fails only on privacy; its twin\nis the same literal in the unit test `a_round_record_literal_compiles_in_the_lib`.\n\n```compile_fail,E0451\nuse weksa::run::{RefusalCounts, RoundRecord};\nuse weksa::score::SplitMean;\nfn f() -> RoundRecord {\n RoundRecord {\n n: 1,\n inventory_rev: 1,\n prompt_digest: String::new(),\n corpus_digest: String::new(),\n entity_digest: String::new(),\n model: String::new(),\n embedder: String::new(),\n chrf_version: String::new(),\n calls: vec![],\n train: vec![],\n train_mean: SplitMean::default(),\n train_scored: 0,\n validation_mean: SplitMean::default(),\n validation_scored: 0,\n validation_refused: RefusalCounts::default(),\n inventory_digest: String::new(),\n cycle: None,\n }\n}\n```",
"type": "object",
"properties": {
"calls": {
@ -40,9 +40,6 @@
"format": "uint32",
"minimum": 0
},
"lowerer_digest": {
"type": "string"
},
"model": {
"type": "string"
},
@ -86,7 +83,6 @@
"n",
"inventory_rev",
"prompt_digest",
"lowerer_digest",
"corpus_digest",
"entity_digest",
"model",

View file

@ -36,9 +36,6 @@
"label": {
"type": "string"
},
"lowerer_digest": {
"type": "string"
},
"model": {
"description": "The answering model.",
"type": "string"
@ -55,7 +52,6 @@
"corpus_digest",
"entity_digest",
"prompt_digest",
"lowerer_digest",
"model",
"embedder",
"chrf_version",