Delete the unconstructable identity cluster and pin the two live refusals
Soul's Cut 4 pass found one rule no test could reach and two with no test left
standing over them. F1 is the sharp one: `validate_pipeline_write_envelope`
raised `ForeignEpoch` for an identity envelope, but `EpiphanyPipelineIdentity`
had no constructor anywhere in the repo, so no test could build one to reach the
branch. Replacing the guard with `if false {` left all 168 tests passing. Code
that cannot be constructed cannot be tested, and testing it would have meant
writing the constructor the organ is going to own anyway.
So it goes, rather than growing a test to justify it. Deleted: the epoch branch
and the `ForeignEpoch` variant, `EpiphanyPipelineIdentity`,
`EpiphanyPipelineProvenance`, `PipelineProvenance`, `Faculty`, and
`PIPELINE_SCHEMA_EPOCH`, whose only reader was the deleted branch. D2 already
assigns admission, identity and the epoch refusal to `huginn-mind`; Cut 8 writes
them there against a store its tests can construct. Carrying about fifteen
unreachable lines across two repos costs more than re-adding them where they
work. Every one of the four types was checked for a live producer first: none
has one, in code, test, schema file or `index.json`.
What stays is what is reachable: `validate_pipeline_write_envelope` keeps its
bounds, formats and key recomputation, and `PipelineRefusal` keeps four variants,
each with a raiser.
Two tests for the two rules that survived Cut 4 untested. F2:
`decode_refuses_an_envelope_of_a_foreign_type` pins the `ForeignStore` refusal
against a commit receipt — a type a pipeline store may legitimately hold, and
still not a document. The existing round-trip test pinned only the positive
match. F4: `runtime_spine_cache_refuses_a_pipeline_store` restores coverage that
died with `pipeline_store.rs`, against the surviving mechanism in
`runtime_spine.rs`. It asserts first that `validate_runtime_store_epoch` passes
a pipeline store, because every neighbouring test is epoch-based and the epoch
checks cannot see this: the registry is the only thing refusing.
`register_pipeline_document_types` is now `#[cfg(test)]` instead of a live path
wearing `expect(dead_code)`. Its only callers are tests, and saying so is
honest; the organ registers its own types in Cut 8.
Builds: `cargo test -p epiphany-core --lib`, 170 passed, 0 failed, 0 warnings.
`cargo check -p epiphany-release-bundle --bin epiphany-state` clean. Mutations
for both new rules land with the next commit.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
592b79cabd
commit
43a08baa3c
2 changed files with 73 additions and 41 deletions
|
|
@ -21,18 +21,16 @@ use cultcache_rs::{CultCache, CultCacheEnvelope, DatabaseEntry};
|
|||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub const PIPELINE_SCHEMA_EPOCH: &str = "epiphany.pipeline.epoch.v1";
|
||||
|
||||
/// Typed refusals of the pipeline documents. Bounds, formats and key identity
|
||||
/// are the document half (D2); `ForeignEpoch` and `ForeignStore` are raised by
|
||||
/// the decode and envelope-validation paths that still live here, and D2 hands
|
||||
/// them to the organ when admission moves there.
|
||||
/// are the document half (D2); `ForeignStore` is raised by the decode path that
|
||||
/// still lives here, and D2 hands it to the organ when admission moves there.
|
||||
/// Identity, the schema epoch and the `ForeignEpoch` refusal are the organ's
|
||||
/// (D2), and Cut 8 writes them there against a store a test can construct.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum PipelineRefusal {
|
||||
FieldBound { field: String, limit: u32, actual: u32 },
|
||||
InvalidFormat { field: String, value: String },
|
||||
InvalidIdentity { kind: PipelineKind, key: String, expected: String },
|
||||
ForeignEpoch { found: String, expected: String },
|
||||
ForeignStore { r#type: String },
|
||||
}
|
||||
|
||||
|
|
@ -244,7 +242,6 @@ macro_rules! unit_enums {
|
|||
|
||||
unit_enums! {
|
||||
EvidenceKind { Command, Test, Mutation, Probe, SourceRead, Capture }
|
||||
Faculty { SelfFaculty, Imagination, Hands, Soul, MindSteward, Eyes, Operator }
|
||||
ClaimOutcome { Holds, Falsified, Unproven }
|
||||
FindingConfidence { Confirmed, Plausible }
|
||||
FindingSeverity { Blocker, High, Medium, Low }
|
||||
|
|
@ -328,9 +325,6 @@ value_types! {
|
|||
item: Line, why_it_can_wait: Line, owner: Short,
|
||||
}
|
||||
pub struct PipelineResolution { subject: PipelineRef, outcome: ResolutionOutcome, rationale: Para, resolved_on: Date }
|
||||
|
||||
/// Who declared an admission. Attribution only; no rule trusts it (D4).
|
||||
pub struct PipelineProvenance { faculty: Faculty, agent: Short, session: Short, tool: Short }
|
||||
}
|
||||
|
||||
/// A reference to another document. The id is parsed as a full pipeline id of
|
||||
|
|
@ -439,13 +433,13 @@ macro_rules! pipeline_kinds {
|
|||
}
|
||||
}
|
||||
|
||||
/// Registers every type a pipeline store may hold: the ten kinds, the
|
||||
/// store identity, admission provenance, and the commit receipt.
|
||||
#[cfg_attr(not(test), expect(dead_code, reason = "the organ registers its mind's types through this"))]
|
||||
/// Registers every type the document tests put in a cache: the ten
|
||||
/// kinds and the commit receipt. Test scaffolding until the organ
|
||||
/// registers its mind's types (Cut 8), which is why it is `cfg(test)`
|
||||
/// rather than a live path wearing a dead-code waiver.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn register_pipeline_document_types(cache: &mut CultCache) -> Result<()> {
|
||||
$(cache.register_entry_type::<$document>()?;)*
|
||||
cache.register_entry_type::<EpiphanyPipelineIdentity>()?;
|
||||
cache.register_entry_type::<EpiphanyPipelineProvenance>()?;
|
||||
cache.register_entry_type::<crate::EpiphanyMindCommitReceipt>()?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -475,21 +469,6 @@ pipeline_kinds! {
|
|||
"epiphany.pipeline.resolution.v1", "EpiphanyPipelineResolutionDocument";
|
||||
}
|
||||
|
||||
/// The store's schema identity, keyed by its epoch string (D2).
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(type = "epiphany.pipeline.identity.v1", schema = "EpiphanyPipelineIdentity")]
|
||||
pub(crate) struct EpiphanyPipelineIdentity {
|
||||
#[cultcache(key = 0)]
|
||||
pub(crate) schema_epoch: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(type = "epiphany.pipeline.provenance.v1", schema = "EpiphanyPipelineProvenance")]
|
||||
pub(crate) struct EpiphanyPipelineProvenance {
|
||||
#[cultcache(key = 0)]
|
||||
pub(crate) value: PipelineProvenance,
|
||||
}
|
||||
|
||||
/// Parses a full document id. `<campaign>:<kind>:<local>` for every kind but
|
||||
/// `campaign`, which is keyed by its slug alone. The segment count is exact,
|
||||
/// the kind segment must match `kind`, and both the campaign and the local
|
||||
|
|
@ -597,17 +576,6 @@ pub fn pipeline_key(document: &PipelineDocument) -> Result<String, PipelineRefus
|
|||
/// admission rules belong to the organ's admission path.
|
||||
#[cfg_attr(not(test), expect(dead_code, reason = "the organ's admission validates every write through this"))]
|
||||
fn validate_pipeline_write_envelope(envelope: &CultCacheEnvelope) -> Result<()> {
|
||||
if envelope.r#type == EpiphanyPipelineIdentity::TYPE {
|
||||
let identity: EpiphanyPipelineIdentity = rmp_serde::from_slice(&envelope.payload)?;
|
||||
if identity.schema_epoch != PIPELINE_SCHEMA_EPOCH || envelope.key != identity.schema_epoch {
|
||||
return Err(PipelineRefusal::ForeignEpoch {
|
||||
found: identity.schema_epoch,
|
||||
expected: PIPELINE_SCHEMA_EPOCH.into(),
|
||||
}
|
||||
.into());
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
let document = PipelineDocument::decode(envelope)?;
|
||||
document.validate()?;
|
||||
let expected = pipeline_key(&document)?;
|
||||
|
|
@ -821,6 +789,26 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Soul F2: a decode is type-matched in both directions. The round-trip
|
||||
/// test above pins the positive match; this pins the refusal, so an
|
||||
/// envelope belonging to another kind can never be decoded as whichever
|
||||
/// pipeline kind happens to parse its payload. The commit receipt is the
|
||||
/// sharp case: a pipeline store may legitimately hold one, and it is still
|
||||
/// not a document.
|
||||
#[test]
|
||||
fn decode_refuses_an_envelope_of_a_foreign_type() -> Result<()> {
|
||||
let cache = schema_cache()?;
|
||||
let foreign = <crate::EpiphanyMindCommitReceipt as DatabaseEntry>::TYPE;
|
||||
assert!(!foreign.starts_with("epiphany.pipeline."), "{foreign} is a foreign type id");
|
||||
let mut envelope = campaign_sample().prepare(&cache)?;
|
||||
envelope.r#type = foreign.into();
|
||||
assert_eq!(
|
||||
PipelineDocument::decode(&envelope),
|
||||
Err(PipelineRefusal::ForeignStore { r#type: foreign.into() })
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bounds_refuse_in_utf8_bytes() {
|
||||
let PipelineDocument::Campaign(mut campaign) = campaign_sample() else { unreachable!() };
|
||||
|
|
|
|||
|
|
@ -8751,6 +8751,50 @@ pub(crate) mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Soul F4: the spine store and a pipeline store are different stores, and
|
||||
/// the spine cache refuses the latter *by type* — it registers its own
|
||||
/// types and nothing else. The epoch checks beside this one cannot stand in
|
||||
/// for it: a pipeline store carries no runtime or Mind identity at all, so
|
||||
/// `validate_runtime_store_epoch` returns `Ok` and the registry is the only
|
||||
/// thing left refusing.
|
||||
#[test]
|
||||
fn runtime_spine_cache_refuses_a_pipeline_store() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
let store = temp.path().join("pipeline.cc");
|
||||
let mut pipeline = CultCache::new();
|
||||
crate::pipeline_documents::register_pipeline_document_types(&mut pipeline)?;
|
||||
let campaign = crate::PipelineDocument::Campaign(crate::PipelineCampaign {
|
||||
slug: "eureka-state".into(),
|
||||
title: "Eureka pipeline state".into(),
|
||||
repos: vec!["GameCult/Epiphany".into()],
|
||||
working_branch: "codex/eureka-pipeline-state".into(),
|
||||
target_doc: crate::DocRef {
|
||||
path: "notes/eureka-pipeline-state-target.md".into(),
|
||||
start_line: 1,
|
||||
end_line: 9,
|
||||
commit: "5f98228d".into(),
|
||||
},
|
||||
});
|
||||
let envelope = campaign.prepare(&pipeline)?;
|
||||
assert!(
|
||||
envelope.r#type.starts_with("epiphany.pipeline."),
|
||||
"the sample is a pipeline document: {}",
|
||||
envelope.r#type
|
||||
);
|
||||
let mut backing = runtime_spine_backing_store(&store)?;
|
||||
backing.push(&envelope)?;
|
||||
|
||||
assert!(
|
||||
validate_runtime_store_epoch(&runtime_spine_backing_store(&store)?.pull_all()?).is_ok(),
|
||||
"the epoch check passes a pipeline store, so only the registry refuses it"
|
||||
);
|
||||
let error = runtime_spine_cache(&store)
|
||||
.and_then(|mut runtime| runtime.pull_all_backing_stores())
|
||||
.unwrap_err();
|
||||
assert!(error.to_string().contains("epiphany.pipeline."), "{error:#}");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn coordinator_terminal_receipts_preserve_exact_immutable_run_basis() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
|
|
|
|||
Reference in a new issue