diff --git a/CHANGELOG.md b/CHANGELOG.md index 062a69412..0b4368656 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,8 @@ All notable changes to TEPP are documented here. The format follows Keep a Chang ## [Unreleased] +- **Role-contradiction analysis-run profile**: `analysis_engine` binds existing `role_contradiction::ContextualRole`, `refuse_contradictory_roles`, and `refuse_role_as_entity_class` to cutoff-safe `role_contradiction_v1` (`tepp.role_contradiction.v1`) with inference status `customer_competitor_cannot_share_group_role_is_not_entity_class`. `identity_recovery_rate` stays library-side. Not subevent-containment, not inferred-status, not episode-membership, not relation-absence, not outcome-order, not membership-target, not location-membership, not membership-posterior ICC, not copied-text, not copy-identity, not citation-edge, not GPU, not MCMC, and not topic birth/split/merge. + - `event_core` adds bounded Allen interval-consistency classification, atomic path-consistency closure, contradiction/resource refusals, and an explicit dependency-error fallback without claiming unrestricted global satisfiability. - `psychometric_core` recovers the Driver, Oud, and Voelkle (2017, Table 2, p. 12 `MANIFESTTRAITVAR`; §7.1, p. 19; p. 16 `MANIFESTTRAITVARstd`; footnote 4; 2017-era ctsem `summary.ctsemFit.R`; JSS PDF re-opened 2026-08-27T14:20Z from https://www.jstatsoft.org/index.php/jss/article/download/v077i05/1104) scalar standardised manifest-trait variance on current main after `0ce16e8` dropped the pre-consolidation code while research notes already named the map (register items 83–84). Table 2 names `MANIFESTTRAITVAR` `Ψ_τ` the additional time-invariant variance-covariance on the measurement level and sets it `NULL` when there is no manifest trait. Equation 5 writes `Γ ~ N(τ, Ψ)` and names that covariance the manifest traits. Section 7.1 names manifest traits stable individual differences in indicator levels, distinct from process-level `TRAITVAR` `φ_ξ`. Page 16 prints standardised matrices with the suffix `std` when appropriate. The printed example on p. 16 is `discreteDRIFTstd`, not `MANIFESTTRAITVARstd`. Footnote 4 standardises using only the relevant variance, not the total. The relevant variance for that named indicator-level correlation is `MANIFESTTRAITVAR`, not process-level `TRAITVAR` and not residual `MANIFESTVAR` `θ`. The 2017-era source forms `MANIFESTTRAITVARstd` only when `MANIFESTTRAITVAR != 0`, as `solve(sqrt(diag(MANIFESTTRAITVAR) + ridging)) %&% MANIFESTTRAITVAR` when `verbose = TRUE`. OpenMx `%&%` is `t(A) %*% B %*% A`. Unlike `TRAITVARstd`, that formation adds `diag(c(ridging), n.manifest)`. The default `ridging = FALSE` adds 0, not `0.0001`; that ridge is a numerical hack and is not this exact map. The scalar correlation is `ψ / ψ = 1` after strictly positive `MANIFESTTRAITVAR`. Form strictly positive `ψ` first, then `1 / √ψ`, then `(1 / √ψ) ψ (1 / √ψ)`. Unstandardised `MANIFESTTRAITVAR` is defined for a zero trait; standardised `MANIFESTTRAITVAR` is not. Zero `MANIFESTTRAITVAR` skips forming `MANIFESTTRAITVARstd` in the 2017-era source and fails closed here. Indicator-level trait variance is an event-time structural quantity, so a non-event clock fails closed. `MANIFESTTRAITVAR` does not require stable `a < 0`. Distinct positive `ψ` recover the same 1. `trait / trait = 1` is `TRAITVARstd` and recovers the same number and remains a distinct named quantity. `θ` is `MANIFESTVAR` and is measurement error, not this correlation. Meredith (1993) remains unread (web search 2026-08-27T14:20Z: Springer/Cambridge Core paywalled; Unpaywall historically `is_oa: false`; Springer `content/pdf` is an HTML stub). Mislevy (1991, *Psychometrika, 56*, 177–196) remains unread on the same terms (DOI `10.1007/bf02294457`). Still not a Kalman filter, not a matrix `expm`, not ESEM estimation, not DSEM, and not ctsem estimation. diff --git a/Cargo.lock b/Cargo.lock index 454a7d612..5ce450b55 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -75,6 +75,7 @@ dependencies = [ "event_core", "membership_core", "relation_graph", + "role_contradiction", "serde", "serde_json", "sha2", diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 6fa4b9683..a06a061ec 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -71,6 +71,7 @@ TEPP's approved PRD v0.4 and implementation plan are the primary product baselin | Hourly NIM OpenCode doctoring | [`docs/doctoring/hourly-nim-opencode-development.md`](docs/doctoring/hourly-nim-opencode-development.md) | | Analysis engine v1 doctoring | [`docs/doctoring/analysis-engine-v1.md`](docs/doctoring/analysis-engine-v1.md) | | Analysis engine gap-closure doctoring | [`docs/doctoring/analysis-engine-gap-closure.md`](docs/doctoring/analysis-engine-gap-closure.md) | +| Role-contradiction analysis-run doctoring | [`docs/doctoring/role-contradiction-analysis-run.md`](docs/doctoring/role-contradiction-analysis-run.md) | | Corpus-split leakage-audit wire doctoring | [`docs/research/corpus-split-manifest-wire.md`](docs/research/corpus-split-manifest-wire.md) | | Unicode canonical-identity doctoring | [`docs/research/unicode-canonical-identity.md`](docs/research/unicode-canonical-identity.md) | | Change history | [`CHANGELOG.md`](CHANGELOG.md) | diff --git a/crates/analysis_engine/Cargo.toml b/crates/analysis_engine/Cargo.toml index 7322212b2..c73dcfcdb 100644 --- a/crates/analysis_engine/Cargo.toml +++ b/crates/analysis_engine/Cargo.toml @@ -15,6 +15,7 @@ publish = false [dependencies] event_core = { path = "../event_core", version = "0.2.0" } +role_contradiction = { path = "../role_contradiction", version = "0.2.0" } serde = { workspace = true } serde_json = { workspace = true } sha2 = { workspace = true } diff --git a/crates/analysis_engine/src/lib.rs b/crates/analysis_engine/src/lib.rs index 72bd5854c..312e4bc71 100644 --- a/crates/analysis_engine/src/lib.rs +++ b/crates/analysis_engine/src/lib.rs @@ -12,6 +12,7 @@ mod case_deletion_refit; mod lineage_criterion; +mod role_contradiction_artifact; mod topic_context_posterior; mod topic_lineage_artifact; @@ -46,6 +47,13 @@ pub use lineage_criterion::{ LineageCriterionFit, LineageCriterionFitError, LineageCriterionObservation, fit_lineage_criterion_posteriors, }; +/// Role-contradiction artifact and execution contracts from this engine. +pub use role_contradiction_artifact::{ + ROLE_CONTRADICTION_ARTIFACT_BYTE_LIMIT, ROLE_CONTRADICTION_ARTIFACT_SCHEMA_VERSION, + ROLE_CONTRADICTION_MODEL_CONTRACT_VERSION, ROLE_CONTRADICTION_OUTPUT_PROFILE, + RoleContradictionArtifact, RoleContradictionAssignment, RoleContradictionExecution, + execute_role_contradiction_run, +}; /// Bounded posterior topic-context producer contract and record types. pub use topic_context_posterior::{ TOPIC_CONTEXT_POSTERIOR_BYTE_LIMIT, TOPIC_CONTEXT_POSTERIOR_SCHEMA_VERSION, @@ -248,6 +256,8 @@ pub enum AnalysisEngineError { TopicMeasurement(TopicMeasurementError), /// A topic-lineage artifact violated its bounded schema or count invariants. InvalidTopicLineageArtifact, + /// A role-contradiction artifact violated its bounded schema or count invariants. + InvalidRoleContradictionArtifact, } impl fmt::Display for AnalysisEngineError { @@ -262,6 +272,7 @@ impl fmt::Display for AnalysisEngineError { Self::LimitExceeded => "analysis corpus exceeded its execution bound", Self::TopicMeasurement(error) => return error.fmt(formatter), Self::InvalidTopicLineageArtifact => "invalid topic lineage artifact", + Self::InvalidRoleContradictionArtifact => "invalid role-contradiction artifact", }; formatter.write_str(message) } @@ -681,6 +692,10 @@ mod tests { AnalysisEngineError::InvalidTopicLineageArtifact, "invalid topic lineage artifact", ), + ( + AnalysisEngineError::InvalidRoleContradictionArtifact, + "invalid role-contradiction artifact", + ), ]; for (error, message) in messages { assert_eq!(error.to_string(), message); diff --git a/crates/analysis_engine/src/role_contradiction_artifact.rs b/crates/analysis_engine/src/role_contradiction_artifact.rs new file mode 100644 index 000000000..570a4761b --- /dev/null +++ b/crates/analysis_engine/src/role_contradiction_artifact.rs @@ -0,0 +1,510 @@ +//! Digest-bound role-contradiction refusals as an analysis-run profile. + +use std::collections::{BTreeMap, BTreeSet}; + +use role_contradiction::{ + ContextualRole, RoleContradictionError, refuse_contradictory_roles, refuse_role_as_entity_class, +}; +use serde::{Deserialize, Serialize}; +use sha2::{Digest, Sha256}; +use temporal_core::{AvailableTime, KnowledgeCutoff}; +use tepp_api::{ + AnalysisResultSummary, AnalysisRunAccepted, AnalysisRunRequest, AnalysisRunTerminalResult, +}; + +use crate::{ + AnalysisEngineError, MAX_EVIDENCE_UNITS, format_digest, require_receipt_identity, + valid_identifier, +}; + +/// Versioned schema for a completed role-contradiction artifact. +pub const ROLE_CONTRADICTION_ARTIFACT_SCHEMA_VERSION: &str = "tepp.role_contradiction.v1"; +/// Model contract required by the role-contradiction execution path. +pub const ROLE_CONTRADICTION_MODEL_CONTRACT_VERSION: &str = "role_contradiction_v1"; +/// Analysis-run output profile required for a role-contradiction artifact. +pub const ROLE_CONTRADICTION_OUTPUT_PROFILE: &str = "role_contradiction_v1"; +/// Maximum canonical artifact JSON size. +pub const ROLE_CONTRADICTION_ARTIFACT_BYTE_LIMIT: usize = 256 * 1024; +const ROLE_CONTRADICTION_INFERENCE_STATUS: &str = + "customer_competitor_cannot_share_group_role_is_not_entity_class"; + +/// One cutoff-admitted contextual-role assignment. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct RoleContradictionAssignment { + assignment_id: String, + group_id: String, + role: ContextualRole, + available_time: AvailableTime, +} + +impl RoleContradictionAssignment { + /// Construct a bounded role assignment. + /// + /// # Errors + /// + /// Returns [`AnalysisEngineError::InvalidEvidence`] when the assignment or + /// group identity is empty or oversized. + pub fn new( + assignment_id: impl Into, + group_id: impl Into, + role: ContextualRole, + available_time: AvailableTime, + ) -> Result { + let assignment_id = assignment_id.into(); + let group_id = group_id.into(); + if !valid_identifier(&assignment_id) || !valid_identifier(&group_id) { + return Err(AnalysisEngineError::InvalidEvidence); + } + Ok(Self { + assignment_id, + group_id, + role, + available_time, + }) + } + + /// Return the opaque assignment identity. + #[must_use] + pub fn assignment_id(&self) -> &str { + &self.assignment_id + } + + /// Return the opaque group identity. + #[must_use] + pub fn group_id(&self) -> &str { + &self.group_id + } + + /// Return the closed contextual role. + #[must_use] + pub const fn role(&self) -> ContextualRole { + self.role + } + + /// Return the availability time used for cutoff eligibility. + #[must_use] + pub const fn available_time(&self) -> AvailableTime { + self.available_time + } +} + +/// Completed, bounded role-contradiction census for analysis-run clients. +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] +#[serde(deny_unknown_fields)] +pub struct RoleContradictionArtifact { + /// Exact versioned schema identity. + pub schema_version: String, + /// Opaque accepted-run identity. + pub run_id: String, + /// Immutable source snapshot identity. + pub snapshot_id: String, + /// Historical evidence cutoff used to admit assignments. + pub knowledge_cutoff: String, + /// Number of assignments admitted at the cutoff. + pub assignment_count: u64, + /// Customer-role assignments admitted at the cutoff. + pub customer_count: u64, + /// Partner-role assignments admitted at the cutoff. + pub partner_count: u64, + /// Competitor-role assignments admitted at the cutoff. + pub competitor_count: u64, + /// Assignments refused as a permanent entity class. + pub refused_as_entity_class_count: u64, + /// Customer/competitor pairs refused inside one group. + pub refused_contradictory_pair_count: u64, + /// Compatible unique-role pairs counted inside groups. + pub compatible_pair_count: u64, + /// Fixed claim boundary for consumer copy. + pub inference_status: String, +} + +impl RoleContradictionArtifact { + /// Parse and fully validate a bounded artifact JSON payload. + /// + /// # Errors + /// + /// Returns [`AnalysisEngineError::InvalidRoleContradictionArtifact`] when + /// the schema, identifiers, counts, or claim boundary fail. + pub fn from_json(payload: &str) -> Result { + if payload.len() > ROLE_CONTRADICTION_ARTIFACT_BYTE_LIMIT { + return Err(AnalysisEngineError::LimitExceeded); + } + let artifact: Self = serde_json::from_str(payload) + .map_err(|_| AnalysisEngineError::InvalidRoleContradictionArtifact)?; + artifact.validate()?; + Ok(artifact) + } + + /// Serialize canonical validated artifact JSON. + /// + /// # Errors + /// + /// Returns a typed validation, serialization, or size failure. + pub fn to_json(&self) -> Result { + self.validate()?; + let payload = + serde_json::to_string(self).map_err(|_| AnalysisEngineError::SerializationFailure)?; + if payload.len() > ROLE_CONTRADICTION_ARTIFACT_BYTE_LIMIT { + return Err(AnalysisEngineError::LimitExceeded); + } + Ok(payload) + } + + /// Return the lowercase SHA-256 digest of canonical artifact JSON. + /// + /// # Errors + /// + /// Returns a typed validation or serialization failure. + pub fn sha256(&self) -> Result { + self.to_json() + .map(|json| format_digest(Sha256::digest(json.into_bytes()))) + } + + fn validate(&self) -> Result<(), AnalysisEngineError> { + let role_sum = self + .customer_count + .checked_add(self.partner_count) + .and_then(|value| value.checked_add(self.competitor_count)); + if self.schema_version != ROLE_CONTRADICTION_ARTIFACT_SCHEMA_VERSION + || !valid_identifier(&self.run_id) + || !valid_identifier(&self.snapshot_id) + || KnowledgeCutoff::parse_rfc3339(&self.knowledge_cutoff).is_err() + || self.assignment_count < 3 + || self.assignment_count > MAX_EVIDENCE_UNITS as u64 + || self.customer_count == 0 + || self.partner_count == 0 + || self.competitor_count == 0 + || role_sum != Some(self.assignment_count) + || self.refused_as_entity_class_count != self.assignment_count + || self.refused_contradictory_pair_count == 0 + || self.compatible_pair_count == 0 + || self.inference_status != ROLE_CONTRADICTION_INFERENCE_STATUS + { + return Err(AnalysisEngineError::InvalidRoleContradictionArtifact); + } + Ok(()) + } +} + +/// One completed role-contradiction artifact and its terminal result. +#[derive(Clone, Debug, PartialEq)] +pub struct RoleContradictionExecution { + /// Digest-bound completed role-contradiction census. + pub artifact: RoleContradictionArtifact, + /// Terminal result carrying the artifact identity, digest, and schema. + pub terminal_result: AnalysisRunTerminalResult, +} + +/// Execute cutoff-safe role-contradiction refusals as one analysis-run profile. +/// +/// The executor invokes [`refuse_contradictory_roles`] and +/// [`refuse_role_as_entity_class`] already on protected main. Customer and +/// competitor cannot share a group. A contextual role is never a permanent +/// entity class. It does not emit `identity_recovery_rate`, a +/// `scientific_acceptance` inspect metric, GPU kernels, MCMC, or topic +/// birth/split/merge events. +/// +/// # Errors +/// +/// Returns a request/receipt/snapshot/cutoff/profile error, empty or +/// single-class corpus, missing contradiction or compatible pair, duplicate +/// assignment identity, oversized corpus, or invalid artifact error. +pub fn execute_role_contradiction_run( + request: &AnalysisRunRequest, + accepted: &AnalysisRunAccepted, + snapshot_id: &str, + knowledge_cutoff: KnowledgeCutoff, + assignments: &[RoleContradictionAssignment], + completed_at: impl Into, +) -> Result { + request.to_json()?; + accepted.to_json()?; + require_receipt_identity(request, accepted)?; + if request.snapshot_id != snapshot_id { + return Err(AnalysisEngineError::SnapshotMismatch); + } + let request_cutoff = KnowledgeCutoff::parse_rfc3339(&request.knowledge_cutoff) + .map_err(|_| AnalysisEngineError::InvalidEvidence)?; + if request_cutoff.instant() != knowledge_cutoff.instant() + || request.model_contract_version != ROLE_CONTRADICTION_MODEL_CONTRACT_VERSION + || request.output_profile != ROLE_CONTRADICTION_OUTPUT_PROFILE + { + return Err(AnalysisEngineError::InvalidEvidence); + } + if assignments.len() > MAX_EVIDENCE_UNITS { + return Err(AnalysisEngineError::LimitExceeded); + } + + let census = census_admitted_assignments(assignments, knowledge_cutoff)?; + let artifact = RoleContradictionArtifact { + schema_version: ROLE_CONTRADICTION_ARTIFACT_SCHEMA_VERSION.into(), + run_id: accepted.run_id.clone(), + snapshot_id: snapshot_id.to_owned(), + knowledge_cutoff: knowledge_cutoff.to_rfc3339(), + assignment_count: census.assignment_count, + customer_count: census.customer_count, + partner_count: census.partner_count, + competitor_count: census.competitor_count, + refused_as_entity_class_count: census.refused_as_entity_class_count, + refused_contradictory_pair_count: census.refused_contradictory_pair_count, + compatible_pair_count: census.compatible_pair_count, + inference_status: ROLE_CONTRADICTION_INFERENCE_STATUS.into(), + }; + let digest = artifact.sha256()?; + let summary = AnalysisResultSummary::new( + "role_contradiction", + census.assignment_count, + 4, + "validated", + )?; + let terminal_result = AnalysisRunTerminalResult::succeeded( + request, + accepted, + format!("role_contradiction_artifact_{}", &digest[..16]), + digest, + ROLE_CONTRADICTION_ARTIFACT_SCHEMA_VERSION, + completed_at, + summary, + )?; + Ok(RoleContradictionExecution { + artifact, + terminal_result, + }) +} + +#[allow(clippy::struct_field_names)] +struct RoleContradictionCensus { + assignment_count: u64, + customer_count: u64, + partner_count: u64, + competitor_count: u64, + refused_as_entity_class_count: u64, + refused_contradictory_pair_count: u64, + compatible_pair_count: u64, +} + +fn census_admitted_assignments( + assignments: &[RoleContradictionAssignment], + knowledge_cutoff: KnowledgeCutoff, +) -> Result { + let mut seen = BTreeSet::new(); + let mut groups: BTreeMap<&str, BTreeSet<&'static str>> = BTreeMap::new(); + let mut customer_count = 0_u64; + let mut partner_count = 0_u64; + let mut competitor_count = 0_u64; + let mut refused_as_entity_class_count = 0_u64; + for assignment in assignments { + if assignment.available_time().instant() > knowledge_cutoff.instant() { + continue; + } + if !seen.insert(assignment.assignment_id()) { + return Err(AnalysisEngineError::DuplicateEvidence); + } + match refuse_role_as_entity_class(assignment.role()) { + Err(RoleContradictionError::RoleIsNotEntityClass) => { + refused_as_entity_class_count = increment(refused_as_entity_class_count)?; + } + Ok(()) | Err(_) => return Err(AnalysisEngineError::InvalidEvidence), + } + match assignment.role() { + ContextualRole::Customer => customer_count = increment(customer_count)?, + ContextualRole::Partner => partner_count = increment(partner_count)?, + ContextualRole::Competitor => competitor_count = increment(competitor_count)?, + } + groups + .entry(assignment.group_id()) + .or_default() + .insert(assignment.role().wire_name()); + } + + let (refused_contradictory_pair_count, compatible_pair_count) = count_group_pairs(&groups)?; + let assignment_count = customer_count + .checked_add(partner_count) + .and_then(|value| value.checked_add(competitor_count)) + .ok_or(AnalysisEngineError::ArithmeticOverflow)?; + if assignment_count < 3 + || customer_count == 0 + || partner_count == 0 + || competitor_count == 0 + || refused_as_entity_class_count != assignment_count + || refused_contradictory_pair_count == 0 + || compatible_pair_count == 0 + { + return Err(AnalysisEngineError::InvalidEvidence); + } + Ok(RoleContradictionCensus { + assignment_count, + customer_count, + partner_count, + competitor_count, + refused_as_entity_class_count, + refused_contradictory_pair_count, + compatible_pair_count, + }) +} + +fn count_group_pairs( + groups: &BTreeMap<&str, BTreeSet<&'static str>>, +) -> Result<(u64, u64), AnalysisEngineError> { + let mut refused_contradictory_pair_count = 0_u64; + let mut compatible_pair_count = 0_u64; + for role_names in groups.values() { + let roles: Result, AnalysisEngineError> = role_names + .iter() + .map(|name| { + ContextualRole::from_wire_name(name) + .map_err(|_| AnalysisEngineError::InvalidEvidence) + }) + .collect(); + let roles = roles?; + for left_index in 0..roles.len() { + for right in roles.iter().skip(left_index + 1) { + match refuse_contradictory_roles(roles[left_index], *right) { + Err(RoleContradictionError::CustomerCompetitorOverlap) => { + refused_contradictory_pair_count = + increment(refused_contradictory_pair_count)?; + } + Ok(()) => compatible_pair_count = increment(compatible_pair_count)?, + Err(_) => return Err(AnalysisEngineError::InvalidEvidence), + } + } + } + } + Ok((refused_contradictory_pair_count, compatible_pair_count)) +} + +fn increment(count: u64) -> Result { + count + .checked_add(1) + .ok_or(AnalysisEngineError::ArithmeticOverflow) +} + +#[cfg(test)] +mod tests { + use super::{ + ROLE_CONTRADICTION_ARTIFACT_BYTE_LIMIT, ROLE_CONTRADICTION_ARTIFACT_SCHEMA_VERSION, + ROLE_CONTRADICTION_INFERENCE_STATUS, RoleContradictionArtifact, + }; + use crate::AnalysisEngineError; + + fn artifact() -> RoleContradictionArtifact { + RoleContradictionArtifact { + schema_version: ROLE_CONTRADICTION_ARTIFACT_SCHEMA_VERSION.into(), + run_id: "run-1".into(), + snapshot_id: "snapshot-1".into(), + knowledge_cutoff: "2026-08-01T00:00:00Z".into(), + assignment_count: 3, + customer_count: 1, + partner_count: 1, + competitor_count: 1, + refused_as_entity_class_count: 3, + refused_contradictory_pair_count: 1, + compatible_pair_count: 2, + inference_status: ROLE_CONTRADICTION_INFERENCE_STATUS.into(), + } + } + + fn assert_invalid(artifact: &RoleContradictionArtifact) { + assert_eq!( + artifact.to_json(), + Err(AnalysisEngineError::InvalidRoleContradictionArtifact) + ); + } + + #[test] + fn artifact_round_trip_and_size_bounds_fail_closed() { + let artifact = artifact(); + let payload = artifact.to_json().expect("json"); + assert_eq!( + RoleContradictionArtifact::from_json(&payload), + Ok(artifact.clone()) + ); + assert_eq!(artifact.sha256().expect("digest").len(), 64); + assert_eq!( + RoleContradictionArtifact::from_json("{}"), + Err(AnalysisEngineError::InvalidRoleContradictionArtifact) + ); + assert_eq!( + RoleContradictionArtifact::from_json( + &"x".repeat(ROLE_CONTRADICTION_ARTIFACT_BYTE_LIMIT + 1) + ), + Err(AnalysisEngineError::LimitExceeded) + ); + } + + #[test] + fn artifact_metadata_tampering_fails_closed() { + let artifact = artifact(); + let invalid_artifacts = [ + { + let mut value = artifact.clone(); + value.schema_version.clear(); + value + }, + { + let mut value = artifact.clone(); + value.run_id.clear(); + value + }, + { + let mut value = artifact.clone(); + value.snapshot_id.clear(); + value + }, + { + let mut value = artifact.clone(); + value.knowledge_cutoff = "invalid".into(); + value + }, + { + let mut value = artifact.clone(); + value.assignment_count = 2; + value + }, + { + let mut value = artifact.clone(); + value.customer_count = 0; + value.assignment_count = 2; + value.refused_as_entity_class_count = 2; + value + }, + { + let mut value = artifact.clone(); + value.partner_count = 0; + value.assignment_count = 2; + value.refused_as_entity_class_count = 2; + value + }, + { + let mut value = artifact.clone(); + value.competitor_count = 0; + value.assignment_count = 2; + value.refused_as_entity_class_count = 2; + value + }, + { + let mut value = artifact.clone(); + value.refused_as_entity_class_count = 0; + value + }, + { + let mut value = artifact.clone(); + value.refused_contradictory_pair_count = 0; + value + }, + { + let mut value = artifact.clone(); + value.compatible_pair_count = 0; + value + }, + { + let mut value = artifact.clone(); + value.inference_status.clear(); + value + }, + ]; + for invalid in invalid_artifacts { + assert_invalid(&invalid); + } + } +} diff --git a/crates/analysis_engine/tests/role_contradiction_cutoff_semantics_contract.rs b/crates/analysis_engine/tests/role_contradiction_cutoff_semantics_contract.rs new file mode 100644 index 000000000..5c446d72b --- /dev/null +++ b/crates/analysis_engine/tests/role_contradiction_cutoff_semantics_contract.rs @@ -0,0 +1,59 @@ +//! Regression contract for semantic knowledge-cutoff equality in role-contradiction runs. + +use analysis_engine::{ + ROLE_CONTRADICTION_MODEL_CONTRACT_VERSION, ROLE_CONTRADICTION_OUTPUT_PROFILE, + RoleContradictionAssignment, execute_role_contradiction_run, +}; +use role_contradiction::ContextualRole; +use temporal_core::{AvailableTime, KnowledgeCutoff}; +use tepp_api::{AnalysisRunAccepted, AnalysisRunRequest}; + +fn available() -> AvailableTime { + AvailableTime::parse_rfc3339("2026-07-01T00:00:00Z").expect("available time") +} + +fn assignment(assignment_id: &str, role: ContextualRole) -> RoleContradictionAssignment { + RoleContradictionAssignment::new(assignment_id, "group-mixed", role, available()) + .expect("assignment") +} + +#[test] +fn equivalent_rfc3339_cutoff_offsets_are_admitted() { + let request = AnalysisRunRequest { + contract_version: 1, + idempotency_key: "role-contradiction-equivalent-cutoff".into(), + tenant_workspace_id: "tenant-workspace".into(), + snapshot_id: "snapshot-role-contradiction".into(), + knowledge_cutoff: "2026-08-01T09:00:00+09:00".into(), + model_contract_version: ROLE_CONTRADICTION_MODEL_CONTRACT_VERSION.into(), + output_profile: ROLE_CONTRADICTION_OUTPUT_PROFILE.into(), + }; + let accepted = AnalysisRunAccepted::new( + "run-role-contradiction", + "accepted", + &request.idempotency_key, + ) + .expect("accepted"); + let execution_cutoff = + KnowledgeCutoff::parse_rfc3339("2026-08-01T00:00:00Z").expect("execution cutoff"); + let assignments = vec![ + assignment("customer-mixed", ContextualRole::Customer), + assignment("competitor-mixed", ContextualRole::Competitor), + assignment("partner-mixed", ContextualRole::Partner), + ]; + + let execution = execute_role_contradiction_run( + &request, + &accepted, + "snapshot-role-contradiction", + execution_cutoff, + &assignments, + "2026-08-02T00:00:00Z", + ) + .expect("equivalent RFC 3339 spellings denote the same cutoff instant"); + + assert_eq!( + execution.artifact.knowledge_cutoff, + execution_cutoff.to_rfc3339() + ); +} diff --git a/crates/analysis_engine/tests/role_contradiction_execution_contract.rs b/crates/analysis_engine/tests/role_contradiction_execution_contract.rs new file mode 100644 index 000000000..1d0c097d7 --- /dev/null +++ b/crates/analysis_engine/tests/role_contradiction_execution_contract.rs @@ -0,0 +1,357 @@ +//! End-to-end contract for cutoff-safe role-contradiction refusals. + +use analysis_engine::{ + AnalysisEngineError, MAX_EVIDENCE_UNITS, ROLE_CONTRADICTION_ARTIFACT_SCHEMA_VERSION, + ROLE_CONTRADICTION_MODEL_CONTRACT_VERSION, ROLE_CONTRADICTION_OUTPUT_PROFILE, + RoleContradictionArtifact, RoleContradictionAssignment, execute_role_contradiction_run, +}; +use role_contradiction::ContextualRole; +use temporal_core::{AvailableTime, KnowledgeCutoff}; +use tepp_api::{AnalysisRunAccepted, AnalysisRunRequest, AnalysisRunTerminalState}; + +fn cutoff() -> KnowledgeCutoff { + KnowledgeCutoff::parse_rfc3339("2026-08-01T00:00:00Z").expect("cutoff") +} + +fn available(stamp: &str) -> AvailableTime { + AvailableTime::parse_rfc3339(stamp).expect("available") +} + +fn request() -> AnalysisRunRequest { + AnalysisRunRequest { + contract_version: 1, + idempotency_key: "role-contradiction-idem".into(), + tenant_workspace_id: "tenant-workspace".into(), + snapshot_id: "snapshot-role-contradiction".into(), + knowledge_cutoff: "2026-08-01T00:00:00Z".into(), + model_contract_version: ROLE_CONTRADICTION_MODEL_CONTRACT_VERSION.into(), + output_profile: ROLE_CONTRADICTION_OUTPUT_PROFILE.into(), + } +} + +fn accepted(request: &AnalysisRunRequest) -> AnalysisRunAccepted { + AnalysisRunAccepted::new( + "run-role-contradiction", + "accepted", + &request.idempotency_key, + ) + .expect("accepted") +} + +fn assignment( + assignment_id: &str, + group_id: &str, + role: ContextualRole, + stamp: &str, +) -> RoleContradictionAssignment { + RoleContradictionAssignment::new(assignment_id, group_id, role, available(stamp)) + .expect("assignment") +} + +fn mixed_assignments() -> Vec { + vec![ + assignment( + "customer-mixed", + "group-mixed", + ContextualRole::Customer, + "2026-07-01T00:00:00Z", + ), + assignment( + "competitor-mixed", + "group-mixed", + ContextualRole::Competitor, + "2026-07-02T00:00:00Z", + ), + assignment( + "partner-mixed", + "group-mixed", + ContextualRole::Partner, + "2026-07-03T00:00:00Z", + ), + ] +} + +fn execute( + request: &AnalysisRunRequest, + assignments: &[RoleContradictionAssignment], +) -> Result { + execute_role_contradiction_run( + request, + &accepted(request), + "snapshot-role-contradiction", + cutoff(), + assignments, + "2026-08-02T00:00:00Z", + ) +} + +#[test] +fn mixed_roles_emit_digest_bound_refusals_without_recovery_metric() { + let request = request(); + let execution = execute(&request, &mixed_assignments()).expect("execution"); + assert_eq!( + execution.artifact.schema_version, + ROLE_CONTRADICTION_ARTIFACT_SCHEMA_VERSION + ); + assert_eq!(execution.artifact.assignment_count, 3); + assert_eq!(execution.artifact.customer_count, 1); + assert_eq!(execution.artifact.partner_count, 1); + assert_eq!(execution.artifact.competitor_count, 1); + assert_eq!(execution.artifact.refused_as_entity_class_count, 3); + assert_eq!(execution.artifact.refused_contradictory_pair_count, 1); + assert_eq!(execution.artifact.compatible_pair_count, 2); + assert_eq!( + execution.artifact.inference_status, + "customer_competitor_cannot_share_group_role_is_not_entity_class" + ); + let payload = execution.artifact.to_json().expect("json"); + assert!(!payload.contains("identity_recovery_rate")); + assert!(!payload.contains("scientific_acceptance")); + assert!(!payload.contains("permanent_entity")); + assert_eq!( + execution.terminal_result.run_state, + AnalysisRunTerminalState::Succeeded + ); + assert_eq!( + execution + .terminal_result + .summary + .as_ref() + .expect("summary") + .validation_status, + "validated" + ); + assert_eq!( + execution.terminal_result.result_sha256.as_deref(), + Some(execution.artifact.sha256().expect("digest").as_str()) + ); + assert_eq!( + execution.terminal_result.result_schema_version.as_deref(), + Some(ROLE_CONTRADICTION_ARTIFACT_SCHEMA_VERSION) + ); +} + +#[test] +fn compact_oversized_artifact_counts_fail_closed() { + let assignment_count = MAX_EVIDENCE_UNITS as u64 + 1; + let artifact = RoleContradictionArtifact { + schema_version: ROLE_CONTRADICTION_ARTIFACT_SCHEMA_VERSION.into(), + run_id: "run-compact-oversize".into(), + snapshot_id: "snapshot-compact-oversize".into(), + knowledge_cutoff: "2026-08-01T00:00:00Z".into(), + assignment_count, + customer_count: 1, + partner_count: 1, + competitor_count: assignment_count - 2, + refused_as_entity_class_count: assignment_count, + refused_contradictory_pair_count: 1, + compatible_pair_count: 1, + inference_status: "customer_competitor_cannot_share_group_role_is_not_entity_class".into(), + }; + let raw_payload = serde_json::to_string(&artifact).expect("raw json"); + assert_eq!( + artifact.to_json(), + Err(AnalysisEngineError::InvalidRoleContradictionArtifact) + ); + assert_eq!( + RoleContradictionArtifact::from_json(&raw_payload), + Err(AnalysisEngineError::InvalidRoleContradictionArtifact) + ); +} + +#[test] +fn future_available_assignments_are_excluded() { + let request = request(); + let mut with_future = mixed_assignments(); + with_future.push(assignment( + "future-customer", + "group-future", + ContextualRole::Customer, + "2026-08-02T00:00:00Z", + )); + let execution = execute(&request, &with_future).expect("cutoff"); + assert_eq!(execution.artifact.assignment_count, 3); + assert_eq!(execution.artifact.customer_count, 1); +} + +#[test] +fn future_duplicate_identity_cannot_change_a_historical_cutoff_result() { + let request = request(); + let mut with_future_duplicate = mixed_assignments(); + with_future_duplicate.push(assignment( + "customer-mixed", + "group-future", + ContextualRole::Competitor, + "2026-08-02T00:00:00Z", + )); + + let execution = execute(&request, &with_future_duplicate) + .expect("future-unavailable evidence must not affect the historical run"); + assert_eq!(execution.artifact.assignment_count, 3); + assert_eq!(execution.artifact.customer_count, 1); + assert_eq!(execution.artifact.partner_count, 1); + assert_eq!(execution.artifact.competitor_count, 1); +} + +#[test] +fn empty_or_single_class_and_duplicate_fail_closed() { + let request = request(); + let stamp = "2026-07-01T00:00:00Z"; + assert_eq!( + execute(&request, &[]), + Err(AnalysisEngineError::InvalidEvidence) + ); + let customers_only = vec![ + assignment("customer-a", "group-a", ContextualRole::Customer, stamp), + assignment("customer-b", "group-b", ContextualRole::Customer, stamp), + assignment("customer-c", "group-c", ContextualRole::Customer, stamp), + ]; + assert_eq!( + execute(&request, &customers_only), + Err(AnalysisEngineError::InvalidEvidence) + ); + let no_competitor = vec![ + assignment( + "customer-a", + "group-compat", + ContextualRole::Customer, + stamp, + ), + assignment("partner-b", "group-compat", ContextualRole::Partner, stamp), + assignment("partner-c", "group-other", ContextualRole::Partner, stamp), + ]; + assert_eq!( + execute(&request, &no_competitor), + Err(AnalysisEngineError::InvalidEvidence) + ); + let no_partner = vec![ + assignment( + "customer-a", + "group-conflict", + ContextualRole::Customer, + stamp, + ), + assignment( + "competitor-b", + "group-conflict", + ContextualRole::Competitor, + stamp, + ), + assignment( + "competitor-c", + "group-other", + ContextualRole::Competitor, + stamp, + ), + ]; + assert_eq!( + execute(&request, &no_partner), + Err(AnalysisEngineError::InvalidEvidence) + ); + let duplicates = vec![ + assignment("same", "group-mixed", ContextualRole::Customer, stamp), + assignment("same", "group-mixed", ContextualRole::Competitor, stamp), + ]; + assert_eq!( + execute(&request, &duplicates), + Err(AnalysisEngineError::DuplicateEvidence) + ); + assert_eq!( + RoleContradictionAssignment::new("", "group-a", ContextualRole::Customer, available(stamp)), + Err(AnalysisEngineError::InvalidEvidence) + ); + assert_eq!( + RoleContradictionAssignment::new( + "assignment-a", + "", + ContextualRole::Customer, + available(stamp) + ), + Err(AnalysisEngineError::InvalidEvidence) + ); +} + +#[test] +fn execution_refuses_snapshot_profile_cutoff_mismatch_and_oversize() { + let request = request(); + let assignments = mixed_assignments(); + assert_eq!( + execute_role_contradiction_run( + &request, + &accepted(&request), + "other-snapshot", + cutoff(), + &assignments, + "2026-08-02T00:00:00Z", + ), + Err(AnalysisEngineError::SnapshotMismatch) + ); + let mut mismatched = request.clone(); + mismatched.knowledge_cutoff = "2026-07-01T00:00:00Z".into(); + assert_eq!( + execute_role_contradiction_run( + &mismatched, + &accepted(&mismatched), + "snapshot-role-contradiction", + cutoff(), + &assignments, + "2026-08-02T00:00:00Z", + ), + Err(AnalysisEngineError::InvalidEvidence) + ); + for profile in [ + "trsl_topic_lineage_v1", + "fitted_candidate_k_v1", + "pareto_candidate_k_v1", + "joint_posterior_draws_v1", + "method_effects_v1", + "copy_identity_v1", + "style_source_v1", + "prompt_source_v1", + "modality_source_v1", + "corpus_background_v1", + "citation_edge_v1", + "copied_text_v1", + "lineage_criterion_v1", + "composed_fitted_lineage_v1", + "case_deletion_refit_v1", + "topic_activity_v1", + "location_membership_v1", + "topic_context_posterior_v1", + "membership_posterior_icc_v1", + "membership_target_v1", + "outcome_order_v1", + "relation_absence_v1", + "subevent_containment_v1", + "episode_membership_v1", + "inferred_status_v1", + ] { + let mut reused = request.clone(); + reused.output_profile = profile.into(); + assert_eq!( + execute_role_contradiction_run( + &reused, + &accepted(&reused), + "snapshot-role-contradiction", + cutoff(), + &assignments, + "2026-08-02T00:00:00Z", + ), + Err(AnalysisEngineError::InvalidEvidence) + ); + } + let oversized: Vec = (0..=MAX_EVIDENCE_UNITS) + .map(|index| { + assignment( + &format!("assignment-{index}"), + "group-mixed", + ContextualRole::Customer, + "2026-07-01T00:00:00Z", + ) + }) + .collect(); + assert_eq!( + execute(&request, &oversized), + Err(AnalysisEngineError::LimitExceeded) + ); +} diff --git a/docs/TRACEABILITY.md b/docs/TRACEABILITY.md index 2b783c2ab..dfdcfcdfe 100644 --- a/docs/TRACEABILITY.md +++ b/docs/TRACEABILITY.md @@ -58,6 +58,7 @@ The full APA 7th standards/literature register remains `docs/research/standards- | versioned service/API contracts and exports | PRD; API contract; ADR 0011/0013 | `tepp_api` analysis-run/export/JSON-LD/GraphML contracts on protected main (PR #21); HTTP service remaining accepted-target | partial | | versioned service/API contracts and exports | PRD; API contract; ADR 0011/0013 | `tepp_api` analysis-run/export/JSON-LD/GraphML contracts on protected main (PR #21); LineageWeave loopback contracts and request-bound terminal result are composed on the active product branch; production TLS remaining | partial | | executable cutoff-safe analysis runs | ADR 0012/0022; temporal research; API terminal-result contract | `analysis_engine` availability cutoff, snapshot binding, multiple-membership aggregation, digest-bound readiness artifact, and `tepp.trsl_topic_lineage.v1` execution through `topic_measurement`; synthetic recovery plus tamper/non-convergence tests and exact coverage on the active product branch | active-PR | +| role-contradiction analysis-run profile | ADR 0003/0022/0075; customer/competitor cannot share a group; role is not an entity class | `analysis_engine` `role_contradiction_v1` binds `refuse_contradictory_roles` and `refuse_role_as_entity_class`; digest-bound refusals, not `identity_recovery_rate` inspect metric, not subevent-containment, not inferred-status, not episode-membership, not relation-absence, not GPU, not MCMC, not topic birth/split/merge; not implemented-main | active-PR | | immutable split/run/reproducibility manifests | ADR 0013; ERD | `tepp_api` reproducibility manifest contract on protected main; `persistence_postgres` append-only SQL insert/lookup for `reproducibility_manifest`, `corpus_split_manifest`, `model_run`, and `model_artifact` (migration `0003`); full physical ERD constraints remaining | partial | | multilingual shared latent semantic space | PRD; ADR 0004; ADR 0020 | `semantic_core` span-grounded units (active-PR); concept dictionary and shared latent estimator remaining | active-PR | | TRSL-TM temporal/relational topic posterior and backend compatibility | ADR 0012; ADR 0004 | `topic_measurement` stable ALR/ILR coordinates and bounded CPU `f64` reference estimator on protected main; `model_selection` fitted candidate-`K` scoring on this PR; calibrated posterior promotion, method effects, persistence, and accelerated backends remaining | partial | diff --git a/docs/adr/0075-role-contradiction-analysis-run.md b/docs/adr/0075-role-contradiction-analysis-run.md new file mode 100644 index 000000000..6ef5b8789 --- /dev/null +++ b/docs/adr/0075-role-contradiction-analysis-run.md @@ -0,0 +1,108 @@ +# ADR 0075 — Role-contradiction refusals as an analysis-run output profile + +**Decision status:** Accepted +**Implementation maturity:** active-PR — composed on this branch; not implemented-main +**Date:** 2026-09-02 +**Supersedes:** None; complements ADR 0003 (customer/competitor cannot occupy the same group; roles are not entity classes) and ADR 0022 (cutoff-safe analysis-run execution). Does not reuse ADR 0074 (subevent-containment), ADR 0073 (inferred-status), ADR 0072 (episode-membership), ADR 0071 (relation-absence), ADR 0070 (outcome-order), ADR 0069 (membership-target), ADR 0066 (location-membership), ADR 0065 (copied-text residue), ADR 0064 (provenance-is-not-transition / citation-edge), or ADR 0058 (copy-identity / template-copy). +**Figma File ID:** N/A — this increment changes a Rust service crate and has no user-interface surface. +**Storybook inventory:** N/A — no reusable web object or interaction changed. + +## Context + +Protected main already refuses a customer/competitor pair in one group and +refuses to treat a contextual role as a permanent entity class, via +`role_contradiction::ContextualRole`, `refuse_contradictory_roles`, and +`refuse_role_as_entity_class`. Operators still cannot request that census +as a digest-bound analysis-run output. + +Subevent-containment (#478 / ADR 0074) binds parent/child interval +containment. Inferred-status (#473) binds observed-versus-inferred +evidence. Episode-membership (#461 / ADR 0072) binds membership windows. +Relation-absence (#460 / ADR 0071) binds observation status. +Outcome-order (#458 / ADR 0070) binds IPO event-time order. +Membership-target (#434 / ADR 0069) binds `MembershipTargetKind`. +Location-membership (#430 / ADR 0066) binds geographic/market assignment. +Copied-text (#427 / ADR 0065) binds unique-content/stopword vocabulary. +Copy-identity (#416 / ADR 0058) binds template-copy identity. + +`identity_recovery_rate` stays library-side. This slice does not put a +`scientific_acceptance` metric on inspect payloads. + +GPU kernels, MCMC, and topic birth/split/merge remain later GAP-004 work +and are not this slice. + +## Decision + +Add the `role_contradiction_v1` analysis-run output profile to +`analysis_engine`. The executor: + +- consumes already-validated `RoleContradictionAssignment` rows with closed + `ContextualRole` values, group identity, and availability time; +- requires the request snapshot and knowledge cutoff to match the offered + input construction, comparing cutoffs as typed `KnowledgeCutoff::instant()` + values rather than strings; +- excludes assignments whose availability is later than the knowledge cutoff; +- invokes `refuse_role_as_entity_class` and `refuse_contradictory_roles` + without reimplementing the customer/partner/competitor vocabulary; +- requires a mixed census of at least one customer, one partner, and one + competitor after cutoff exclusion, with at least one contradictory pair + and one compatible pair; +- emits a canonical SHA-256-digested `tepp.role_contradiction.v1` artifact + with per-role counts, matching entity-class refusal counts, contradictory + and compatible pair counts, and inference status + `customer_competitor_cannot_share_group_role_is_not_entity_class`; +- applies `MAX_EVIDENCE_UNITS` to both execution admission and artifact + validation; +- does not emit `identity_recovery_rate`, invent MCMC, select GPU backends, + or emit topic birth/split/merge events. + +## Alternatives considered + +1. Duplicate subevent-containment (#478 / ADR 0074) — rejected because that + profile binds parent/child interval containment, not commercial roles. +2. Duplicate inferred-status (#473) — rejected because that profile binds + observed-versus-inferred evidence, not customer/competitor overlap. +3. Duplicate episode-membership (#461 / ADR 0072) — rejected because that + profile binds membership windows, not role contradiction. +4. Duplicate relation-absence (#460 / ADR 0071) — rejected because that + profile binds `ObservationStatus`, not contextual roles. +5. Duplicate membership-target (#434 / ADR 0069) — rejected because that + profile binds `MembershipTargetKind`, not customer/competitor overlap. +6. Put `identity_recovery_rate` on the operator artifact — rejected because + inspect payloads stay metric-free and `tepp.scientific_acceptance.v1` + never appears. +7. Bind the existing role-contradiction refusals to ADR 0022's analysis-run + profile — accepted. + +## Consequences + +Operators can request cutoff-safe role-contradiction refusals as a +digest-bound terminal result. The artifact does not claim MCMC, GPU +parity, subevent-containment, inferred-status, episode-membership, +relation-absence, outcome-order, membership-target, location-membership, +membership-posterior ICC, copied-text, copy-identity, citation-edge, +corpus-background, method-effect estimation, or topic birth/split/merge. +Snapshot / profile / cutoff mismatch, empty or single-class corpora, +duplicate assignment identities, and oversized corpora fail closed. + +## Verification + +The PR includes Rust unit and integration tests for mixed +customer / partner / competitor corpora, cutoff exclusion, equivalent +RFC 3339 cutoff instants, empty/single-class/duplicate refusal, snapshot / +profile / cutoff mismatch, oversize, compact census claims above +`MAX_EVIDENCE_UNITS`, and artifact tampering. Run: + +```text +cargo fmt --all -- --check +cargo test -p analysis_engine +cargo clippy -p analysis_engine --all-targets -- -D warnings +python3 scripts/validate_documentation.py +``` + +## Rollback and supersession + +Rollback removes the `role_contradiction_v1` profile. No persisted schema +migration is introduced. Supersede only with an ADR that keeps customer +and competitor from sharing a group, keeps roles out of the entity-class +vocabulary, and keeps `identity_recovery_rate` off inspect payloads. diff --git a/docs/adr/README.md b/docs/adr/README.md index 1254c8079..e1ccccc38 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -28,6 +28,7 @@ Read [`ADR_POLICY.md`](ADR_POLICY.md) first. **Decision status and implementatio | [0020](0020-span-grounded-semantic-units.md) | Span-grounded semantic units; language tags are not identity | Accepted | active-PR | First ADR 0004 production slice; concept alignment, invariance, and topic estimation are not claimed. | | [0021](0021-lineageweave-project-history-boundary.md) | LineageWeave project-history service boundary | Accepted | active-PR | Credential-free bounded project-history API preserves LineageWeave authorization ownership. | | [0022](0022-deterministic-analysis-run-execution.md) | Deterministic cutoff-safe analysis-run execution | Accepted | active-PR | Closes the first executable product path from accepted run to digest-bound terminal result without claiming estimator authority. | +| [0075](0075-role-contradiction-analysis-run.md) | Role-contradiction refusals as an analysis-run profile | Accepted | active-PR | Complements ADR 0003/0022; `ContextualRole` + `refuse_contradictory_roles` / `refuse_role_as_entity_class`, not subevent-containment, not relation-absence. | | [0024](0024-lineage-pair-criterion-and-project-journey-posterior.md) | Independent Event Lineage pair criterion and posterior Project Journey | Proposed | active-PR | Strict artifacts preserve criterion/event-time draws, branches, ties, and CPU/GPU receipts without claiming the scientific estimator is complete. | | [0025](0025-macos-native-rust-mlx-metal-boundary.md) | macOS-native Rust-owned MLX Metal execution | Accepted | accepted-target | Compose authenticates to a native host service; Linux never claims Metal, and actual backend/parity receipts fail closed. | | [0023](0023-lineage-criterion-anchor-contract.md) | TEPP-owned Event Lineage criterion anchor | Accepted | active-PR | PR #237 publishes the strict accepted/rejected artifact and identities; estimator execution remains fail-closed future work. | @@ -138,6 +139,7 @@ Use the narrowest owning ADR when decisions overlap: - **project-history wire-size symmetry:** ADR 0019. - **LineageWeave project-history service boundary:** ADR 0021. - **accepted-run execution and terminal artifact production:** ADR 0022. +- **role-contradiction analysis-run profile:** ADR 0075. - **independent lineage criterion and posterior Project Journey:** ADR 0023. - **macOS-native Rust-owned MLX Metal execution:** ADR 0024. diff --git a/docs/doctoring/role-contradiction-analysis-run.md b/docs/doctoring/role-contradiction-analysis-run.md new file mode 100644 index 000000000..aa7983302 --- /dev/null +++ b/docs/doctoring/role-contradiction-analysis-run.md @@ -0,0 +1,19 @@ +# Role-contradiction analysis-run composition + +**Active slice:** ADR 0075 / `role_contradiction_v1` +**Protected-main status:** not implemented-main + +`role_contradiction` already refuses a customer/competitor pair in one +group and refuses to treat a contextual role as a permanent entity class. +This slice binds `ContextualRole`, `refuse_contradictory_roles`, and +`refuse_role_as_entity_class` to a cutoff-safe analysis-run profile so +operators can request a digest-bound identity artifact. + +The artifact inference status is +`customer_competitor_cannot_share_group_role_is_not_entity_class`. +`identity_recovery_rate` stays library-side. This is not +subevent-containment, not inferred-status, not episode-membership, not +relation-absence, not outcome-order, not membership-target, not +location-membership, not membership-posterior ICC, not copied-text, not +copy-identity, not citation-edge, not GPU, not MCMC, and not topic +birth/split/merge.