From a5fc72283785f51d91dc3c5c64155ab28c90f164 Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Mon, 17 Aug 2026 17:04:37 +0900 Subject: [PATCH 1/3] feat(relation): refuse a template copy as the source identity A template or pasted copy keeps a distinct identity for relation-aware splits (ADR 0003). It cannot reuse the source document identity or become a state transition. Recovery is the computed share of copy kinds that match known truth versus collapsing every copy to the source. --- ARCHITECTURE.md | 1 + CHANGELOG.md | 1 + Cargo.lock | 4 + Cargo.toml | 2 + README.md | 3 +- crates/copy_identity/Cargo.toml | 17 +++ crates/copy_identity/src/error.rs | 53 ++++++++ crates/copy_identity/src/kind.rs | 127 ++++++++++++++++++ crates/copy_identity/src/lib.rs | 22 +++ .../tests/copy_identity_contract.rs | 67 +++++++++ crates/copy_identity/tests/crate_contract.rs | 7 + docs/TRACEABILITY.md | 2 +- ...03-relational-event-multiple-membership.md | 2 +- docs/adr/README.md | 2 +- docs/research/copy-identity.md | 27 ++++ docs/research/standards-and-literature.md | 2 +- docs/validation/temporal-event-foundation.md | 1 + scripts/check_workspace_contract.py | 1 + 18 files changed, 336 insertions(+), 5 deletions(-) create mode 100644 crates/copy_identity/Cargo.toml create mode 100644 crates/copy_identity/src/error.rs create mode 100644 crates/copy_identity/src/kind.rs create mode 100644 crates/copy_identity/src/lib.rs create mode 100644 crates/copy_identity/tests/copy_identity_contract.rs create mode 100644 crates/copy_identity/tests/crate_contract.rs create mode 100644 docs/research/copy-identity.md diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index ffe514db..7a5aa5fc 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -61,6 +61,7 @@ boundaries above remain the target modular MSA architecture. | `tepp_simulation` | known-truth temporal/event data generation | | `validation_core` | RMSE, bias, coverage, graph, and Monte Carlo metrics | | `tepp_api` | versioned DTO, schema, and export contracts | +| `copy_identity` | a template copy is not the source document and not a state transition | No crate exposes placeholder production behavior in Task 1. This prevents an empty façade from becoming a de facto public API before its invariants and tests diff --git a/CHANGELOG.md b/CHANGELOG.md index f3764d25..d1a4df37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to TEPP are documented here. The format follows Keep a Chang ### Added +- `copy_identity` identity gate: a template or pasted copy cannot reuse the source document identity or become a state transition; recovered copy kinds match known truth at a higher computed rate than collapsing every copy to the source (ADR 0003). - `persistence_postgres` retention/deletion/legal-hold (migration `0007`): policy rows, legal holds that block completed deletion, evidence tombstones without raw-source restore, analysis exclusion only for `logical_revocation`/`identity_tombstone` (not `cache_export_removal`), and deletion requests bound to the cited retention policy's tenant/class/purpose. - `persistence_postgres` backup/restore integrity: restored snapshots stay unusable until tenant, canonical `SHA-256`, knowledge-cutoff eligibility, temporal window order, and append-only triggers revalidate; SQL probes raise `restore integrity failed` (ADR 0013). - `persistence_postgres` concurrent document-write stress: atomic revise `DO` block that requires exactly one open `system_to` close, SQLSTATE mapping onto `ConcurrentWriteConflict` / `DuplicateDocumentRecord`, and live multi-session insert/revise/append-only proofs. No new migration number. diff --git a/Cargo.lock b/Cargo.lock index 372a55f4..90299599 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,6 +114,10 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +[[package]] +name = "copy_identity" +version = "0.1.0" + [[package]] name = "corpus_split" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 92565940..ba6989ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ members = [ "crates/tepp_simulation", "crates/validation_core", "crates/tepp_api", + "crates/copy_identity", ] default-members = [ "crates/evidence_core", @@ -23,6 +24,7 @@ default-members = [ "crates/tepp_simulation", "crates/validation_core", "crates/tepp_api", + "crates/copy_identity", ] [workspace.package] diff --git a/README.md b/README.md index ae74015d..5b7d74f8 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ implemented in Rust. ## Current implementation state This branch establishes the Task 1 Rust workspace and quality-gate foundation. -The ten bounded crates compile independently but intentionally expose no +The eleven bounded crates compile independently but intentionally expose no placeholder production APIs. Domain behavior begins in Task 2 with immutable evidence identifiers and source records. @@ -22,6 +22,7 @@ crates/corpus_split crates/tepp_simulation crates/validation_core crates/tepp_api +crates/copy_identity ``` ## Local verification diff --git a/crates/copy_identity/Cargo.toml b/crates/copy_identity/Cargo.toml new file mode 100644 index 00000000..32352053 --- /dev/null +++ b/crates/copy_identity/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "copy_identity" +description = "A template copy is not the source document and not a state transition." +version.workspace = true +edition.workspace = true +rust-version.workspace = true +license.workspace = true +authors.workspace = true +repository.workspace = true +homepage.workspace = true +readme.workspace = true +keywords.workspace = true +categories.workspace = true +publish = false + +[lints] +workspace = true diff --git a/crates/copy_identity/src/error.rs b/crates/copy_identity/src/error.rs new file mode 100644 index 00000000..fba22b62 --- /dev/null +++ b/crates/copy_identity/src/error.rs @@ -0,0 +1,53 @@ +//! Fail-closed copy-identity errors. + +use std::fmt; + +/// A fail-closed copy-identity error. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +#[non_exhaustive] +pub enum CopyIdentityError { + /// A template copy was treated as the source document identity. + CopyIsNotSourceIdentity, + /// A template copy was treated as a state transition. + CopyIsNotTransition, + /// A recovery slice was empty or length-mismatched. + InvalidCopyPayload, +} + +impl fmt::Display for CopyIdentityError { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + let message = match self { + Self::CopyIsNotSourceIdentity => "a template copy is not the source document identity", + Self::CopyIsNotTransition => "a template copy is not a state transition", + Self::InvalidCopyPayload => "invalid copy-identity payload", + }; + formatter.write_str(message) + } +} + +impl std::error::Error for CopyIdentityError {} + +#[cfg(test)] +mod tests { + use super::CopyIdentityError; + + #[test] + fn error_messages_are_stable() { + for (error, message) in [ + ( + CopyIdentityError::CopyIsNotSourceIdentity, + "a template copy is not the source document identity", + ), + ( + CopyIdentityError::CopyIsNotTransition, + "a template copy is not a state transition", + ), + ( + CopyIdentityError::InvalidCopyPayload, + "invalid copy-identity payload", + ), + ] { + assert_eq!(error.to_string(), message); + } + } +} diff --git a/crates/copy_identity/src/kind.rs b/crates/copy_identity/src/kind.rs new file mode 100644 index 00000000..e0b7c691 --- /dev/null +++ b/crates/copy_identity/src/kind.rs @@ -0,0 +1,127 @@ +//! Template-copy identity versus the copied source document. + +use crate::CopyIdentityError; + +/// Closed vocabulary of copy-related document identities. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum CopyKind { + /// A template or pasted copy of an earlier source. + TemplateCopy, + /// The earlier source document being copied. + SourceDocument, +} + +impl CopyKind { + /// Return the stable wire kind name. + #[must_use] + pub const fn wire_name(self) -> &'static str { + match self { + Self::TemplateCopy => "template_copy_of", + Self::SourceDocument => "source_document", + } + } + + /// Parse a stable wire kind name. + /// + /// # Errors + /// + /// Returns [`CopyIdentityError::InvalidCopyPayload`] for unrecognized names. + pub fn from_wire_name(name: &str) -> Result { + match name { + "template_copy_of" => Ok(Self::TemplateCopy), + "source_document" => Ok(Self::SourceDocument), + _ => Err(CopyIdentityError::InvalidCopyPayload), + } + } +} + +/// Refuse to treat a template copy as the source document identity. +/// +/// # Errors +/// +/// Returns [`CopyIdentityError::CopyIsNotSourceIdentity`] when `kind` is +/// [`CopyKind::TemplateCopy`]. +pub fn refuse_copy_as_source_identity(kind: CopyKind) -> Result<(), CopyIdentityError> { + match kind { + CopyKind::TemplateCopy => Err(CopyIdentityError::CopyIsNotSourceIdentity), + CopyKind::SourceDocument => Ok(()), + } +} + +/// Refuse to treat a template copy as a forward state transition. +/// +/// # Errors +/// +/// Returns [`CopyIdentityError::CopyIsNotTransition`] when `kind` is +/// [`CopyKind::TemplateCopy`]. +pub fn refuse_copy_as_transition(kind: CopyKind) -> Result<(), CopyIdentityError> { + match kind { + CopyKind::TemplateCopy => Err(CopyIdentityError::CopyIsNotTransition), + CopyKind::SourceDocument => Ok(()), + } +} + +/// Fraction of recovered copy kinds that match known truth. +/// +/// # Errors +/// +/// Returns [`CopyIdentityError::InvalidCopyPayload`] when either slice is empty +/// or the lengths differ. +pub fn identity_recovery_rate( + truth: &[CopyKind], + decided: &[CopyKind], +) -> Result { + if truth.is_empty() || truth.len() != decided.len() { + return Err(CopyIdentityError::InvalidCopyPayload); + } + let mut matches = 0_u32; + for (truth_kind, decided_kind) in truth.iter().zip(decided) { + if truth_kind == decided_kind { + matches += 1; + } + } + Ok(f64::from(matches) / truth.len() as f64) +} + +#[cfg(test)] +mod tests { + use super::{ + identity_recovery_rate, refuse_copy_as_source_identity, refuse_copy_as_transition, CopyKind, + }; + use crate::CopyIdentityError; + + #[test] + fn local_branches_cover_kinds_payloads_and_wire_names() { + assert_eq!( + refuse_copy_as_source_identity(CopyKind::TemplateCopy), + Err(CopyIdentityError::CopyIsNotSourceIdentity) + ); + assert_eq!( + refuse_copy_as_transition(CopyKind::TemplateCopy), + Err(CopyIdentityError::CopyIsNotTransition) + ); + refuse_copy_as_source_identity(CopyKind::SourceDocument).expect("source"); + refuse_copy_as_transition(CopyKind::SourceDocument).expect("source"); + for kind in [CopyKind::TemplateCopy, CopyKind::SourceDocument] { + assert_eq!( + CopyKind::from_wire_name(kind.wire_name()).expect("round-trip"), + kind + ); + } + assert_eq!( + CopyKind::from_wire_name("summarizes"), + Err(CopyIdentityError::InvalidCopyPayload) + ); + let matched = identity_recovery_rate(&[CopyKind::TemplateCopy], &[CopyKind::TemplateCopy]) + .expect("rate"); + assert!((matched - 1.0).abs() < f64::EPSILON); + assert_eq!( + identity_recovery_rate(&[], &[]), + Err(CopyIdentityError::InvalidCopyPayload) + ); + assert_eq!( + identity_recovery_rate(&[CopyKind::TemplateCopy], &[]), + Err(CopyIdentityError::InvalidCopyPayload) + ); + } +} diff --git a/crates/copy_identity/src/lib.rs b/crates/copy_identity/src/lib.rs new file mode 100644 index 00000000..45bb53fd --- /dev/null +++ b/crates/copy_identity/src/lib.rs @@ -0,0 +1,22 @@ +#![forbid(unsafe_code)] +#![deny(missing_docs)] +#![allow(clippy::cast_precision_loss)] +//! A template copy is not the source document and not a state transition. +//! +//! Copy variants keep a distinct identity for relation-aware splits. They +//! never become input-process-outcome edges and never reuse the source +//! identity (ADR 0003). + +mod error; +mod kind; + +/// Fail-closed copy-identity errors. +pub use error::CopyIdentityError; +/// Fraction of recovered copy kinds that match known truth. +pub use kind::identity_recovery_rate; +/// Refuse to treat a template copy as the source document identity. +pub use kind::refuse_copy_as_source_identity; +/// Refuse to treat a template copy as a forward state transition. +pub use kind::refuse_copy_as_transition; +/// Closed vocabulary of copy-related document identities. +pub use kind::CopyKind; diff --git a/crates/copy_identity/tests/copy_identity_contract.rs b/crates/copy_identity/tests/copy_identity_contract.rs new file mode 100644 index 00000000..c047f0a3 --- /dev/null +++ b/crates/copy_identity/tests/copy_identity_contract.rs @@ -0,0 +1,67 @@ +//! A template copy is not the source document and not a state transition. + +use copy_identity::{ + identity_recovery_rate, refuse_copy_as_source_identity, refuse_copy_as_transition, + CopyIdentityError, CopyKind, +}; + +#[test] +fn a_copy_cannot_become_the_source_identity_or_a_transition() { + assert_eq!( + refuse_copy_as_source_identity(CopyKind::TemplateCopy), + Err(CopyIdentityError::CopyIsNotSourceIdentity) + ); + assert_eq!( + refuse_copy_as_transition(CopyKind::TemplateCopy), + Err(CopyIdentityError::CopyIsNotTransition) + ); + refuse_copy_as_source_identity(CopyKind::SourceDocument).expect("source"); + refuse_copy_as_transition(CopyKind::SourceDocument).expect("source"); +} + +#[test] +fn recovered_kinds_match_known_truth_better_than_a_source_collapse() { + let truth = [ + CopyKind::TemplateCopy, + CopyKind::SourceDocument, + CopyKind::TemplateCopy, + ]; + let recovered = truth; + let collapsed = [ + CopyKind::SourceDocument, + CopyKind::SourceDocument, + CopyKind::SourceDocument, + ]; + let recovered_rate = identity_recovery_rate(&truth, &recovered).expect("recovered"); + let collapsed_rate = identity_recovery_rate(&truth, &collapsed).expect("collapsed"); + let expected = { + let mut matches = 0_u32; + for (truth_kind, decided_kind) in truth.iter().zip(recovered.iter()) { + if truth_kind == decided_kind { + matches += 1; + } + } + f64::from(matches) / f64::from(u32::try_from(truth.len()).expect("len")) + }; + assert!((recovered_rate - expected).abs() < f64::EPSILON); + assert!(recovered_rate > collapsed_rate); +} + +#[test] +fn empty_or_mismatched_kind_payloads_fail_closed() { + assert_eq!( + identity_recovery_rate(&[], &[]), + Err(CopyIdentityError::InvalidCopyPayload) + ); + assert_eq!( + identity_recovery_rate(&[CopyKind::TemplateCopy], &[]), + Err(CopyIdentityError::InvalidCopyPayload) + ); + assert_eq!( + identity_recovery_rate( + &[CopyKind::TemplateCopy, CopyKind::SourceDocument], + &[CopyKind::TemplateCopy] + ), + Err(CopyIdentityError::InvalidCopyPayload) + ); +} diff --git a/crates/copy_identity/tests/crate_contract.rs b/crates/copy_identity/tests/crate_contract.rs new file mode 100644 index 00000000..d701da8e --- /dev/null +++ b/crates/copy_identity/tests/crate_contract.rs @@ -0,0 +1,7 @@ +//! Integration contract for the `copy_identity` package identity. + +#[test] +fn package_identity_is_stable() { + let observed = std::hint::black_box(env!("CARGO_PKG_NAME")); + assert_eq!(observed, "copy_identity"); +} diff --git a/docs/TRACEABILITY.md b/docs/TRACEABILITY.md index c29d9743..88d8b770 100644 --- a/docs/TRACEABILITY.md +++ b/docs/TRACEABILITY.md @@ -12,7 +12,7 @@ The full APA 7th standards/literature register remains `docs/research/standards- | Rust workspace/quality foundation | ADR 0007 | workspace/CI/repository contract | implemented-main | | six distinct clocks and uncertain intervals | PRD; ADR 0002 | PR #8 `temporal_core` on protected main; PR #5 historical only | implemented-main | | Allen relation algebra/bounded closure | ADR 0002; temporal research | PR #9 `temporal_core` path-consistency on protected main | implemented-main | -| forward-only transition subgraph | PRD; ADR 0002/0003 | `relation_graph` on protected main | implemented-main | +| forward-only transition subgraph | PRD; ADR 0002/0003 | `relation_graph` on protected main; `copy_identity` copy-versus-source identity on the active PR | partial | | event ontology/evidence mentions | PRD; ADR 0003 | `event_core` mention/instance separation on protected main; `persistence_postgres` mention SQL implemented-main refuses mention-as-instance; event-instance SQL (#39 implemented-main) refuses inverted windows; full intelligence stack remaining | partial | | time-varying cross-classified multiple membership | PRD; ADR 0003 | `membership_core` network on protected main; multilevel estimators remaining | partial | | leakage-safe availability/cutoff snapshots | PRD; ADR 0002/0013 | `corpus_split` on protected main | implemented-main | diff --git a/docs/adr/0003-relational-event-multiple-membership.md b/docs/adr/0003-relational-event-multiple-membership.md index c5b1a154..fc88ec2f 100644 --- a/docs/adr/0003-relational-event-multiple-membership.md +++ b/docs/adr/0003-relational-event-multiple-membership.md @@ -1,7 +1,7 @@ # ADR 0003 — Relational event ontology and time-varying multiple membership **Decision status:** Accepted -**Implementation maturity:** partial — membership network and event mention/instance separation implemented-main; typed relation graph with forward-only transitions active-PR; multilevel estimators and persistence remain accepted-target +**Implementation maturity:** partial — membership network and event mention/instance separation implemented-main; copy-versus-source identity in `copy_identity` on the active PR; typed relation graph with forward-only transitions active-PR; multilevel estimators and persistence remain accepted-target **Date:** 2026-08-05 **Supersedes:** None. ADR 0016 owns TDT/CHRONOS event-intelligence task semantics; this ADR remains authoritative for ontology, relation, role, and membership structure. diff --git a/docs/adr/README.md b/docs/adr/README.md index 5d3aa546..aff69637 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -8,7 +8,7 @@ Read [`ADR_POLICY.md`](ADR_POLICY.md) first. **Decision status and implementatio |---|---|---|---|---| | [0001](0001-rust-first-modular-msa.md) | Rust-first numerical core and CPU `f64` reference | Accepted | partial | ADR 0011 owns cross-service/MSA authority; 0001 retains numerical/backend authority. | | [0002](0002-six-clock-temporal-semantics.md) | Six-clock temporal semantics and fail-closed historical leakage prevention | Accepted | active-PR | Unmerged PR #8 is the canonical Task 3 replacement implementing typed clocks/intervals against the current protected-main lineage; conflicted PR #5 is superseded lineage. Later graph/split enforcement remains target work. | -| [0003](0003-relational-event-multiple-membership.md) | Relational event ontology and time-varying cross-classified multiple membership | Accepted | partial | Weighted time-varying membership network/roles are active-PR (PR #12); full multilevel estimators, graph ontology, and persistence remain accepted-target. ADR 0016 owns event-intelligence tasks. | +| [0003](0003-relational-event-multiple-membership.md) | Relational event ontology and time-varying cross-classified multiple membership | Accepted | partial | Weighted time-varying membership network/roles are implemented-main (PR #12); copy-versus-source identity is `copy_identity` on the active PR; full multilevel estimators and persistence remain accepted-target. ADR 0016 owns event-intelligence tasks. | | [0004](0004-shared-multilingual-latent-space.md) | One shared multilingual latent space with explicit invariance status | Accepted | accepted-target | ADR 0012 owns the full topic-estimator/backend/global-topic contract. | | [0005](0005-posterior-esem-dsem.md) | Posterior-aware ESEM/DSEM and valid compositional coordinates | Accepted | accepted-target | Downstream psychometric authority; upstream topic/network model is clarified by ADR 0012. | | [0006](0006-vram-gpu-nvidia-orchestration.md) | VRAM-adaptive GPU compute and model-credential boundary | Accepted | accepted-target | LLM orchestration policy superseded by ADR 0010; autonomous development authority governed by ADR 0015. | diff --git a/docs/research/copy-identity.md b/docs/research/copy-identity.md new file mode 100644 index 00000000..3a8b1440 --- /dev/null +++ b/docs/research/copy-identity.md @@ -0,0 +1,27 @@ +# A template copy is not the source document (doctoring) + +## Scope + +`copy_identity` keeps template and pasted copies out of the source +document identity and out of the forward state-transition vocabulary. +Recovery is the computed share of recovered kinds that match known truth. + +This slice does not persist the graph, allocate migration `0008`, or +replace `relation_graph`, `summarizes_edge`, or `method_effects`. + +## Authority + +### Normative TEPP contract + +- `docs/adr/0003-relational-event-multiple-membership.md` — + translation, revision, and copy variants keep distinct identities so + relation-aware splits can hold them together without collapsing them. + +### Supporting literature + +Moreau and Missier (2013) treat a derived entity as distinct from the +entity it was generated from. A template copy is a derivation, not a +reuse of the source identity and not a state transition. + +Moreau, L., & Missier, P. (Eds.). (2013). *PROV-DM: The PROV data +model*. World Wide Web Consortium. https://www.w3.org/TR/prov-dm/ diff --git a/docs/research/standards-and-literature.md b/docs/research/standards-and-literature.md index 75710ed3..89e4f8f9 100644 --- a/docs/research/standards-and-literature.md +++ b/docs/research/standards-and-literature.md @@ -94,7 +94,7 @@ Lebo, T., Sahoo, S., & McGuinness, D. (Eds.). (2013). *PROV-O: The PROV ontology Moreau, L., & Missier, P. (Eds.). (2013). *PROV-DM: The PROV data model*. World Wide Web Consortium. https://www.w3.org/TR/prov-dm/ -TEPP separates stable record identity, content equality, exact text location, wire representation, authorization, and provenance. JSON wire records are explicit versioned DTOs with unknown-field rejection and reconstruct through domain validation. `SHA-256` detects content substitution but is not treated as proof of origin, authority, or chain of custody. +TEPP separates stable record identity, content equality, exact text location, wire representation, authorization, and provenance. JSON wire records are explicit versioned DTOs with unknown-field rejection and reconstruct through domain validation. `SHA-256` detects content substitution but is not treated as proof of origin, authority, or chain of custody. A template or pasted copy is a PROV derivation of the source document, not a reuse of the source identity and not a state transition (Moreau & Missier, 2013). ## Privacy lifecycle, retention, and legal hold diff --git a/docs/validation/temporal-event-foundation.md b/docs/validation/temporal-event-foundation.md index 295fbae0..65baf754 100644 --- a/docs/validation/temporal-event-foundation.md +++ b/docs/validation/temporal-event-foundation.md @@ -18,6 +18,7 @@ This report tracks exact-head scientific and engineering evidence required befor | Event mention/instance | `event_core` | partial | — | unit + fail-closed promotion | Task 5 / PR #13 | | Multiple membership | `membership_core` | partial | — | unit + ESS weights | Task 7 / PR #12 + #25 | | Forward transition DAG | `relation_graph` | implemented-main | — | unit + cycle rejection | Task 6 / PR #14 | +| Copy-versus-source identity | `copy_identity` | accepted-target | active PR | refuse copy-as-source/transition + recovery vs source collapse | ADR 0003 | | Bitemporal persistence + live SQL port | `persistence_postgres` | partial | backup/restore integrity | migration contracts + recording transport + optional PgPool + live CI + tenant RLS + `0005`/`0006` + event relation/mention/instance + source-artifact + audit-event + concurrent-write (#37–#43 implemented-main) + restore integrity probes (active PR) | Task 8 / PR #16 + #23 + #26 + #27 + #29 + #30–#43 + restore integrity | | Leakage-safe splits | `corpus_split` | implemented-main | — | cutoff + co-partition tests | Task 9 / PR #17 | | Truth corpora / manifests | `tepp_simulation` | implemented-main | — | deterministic generator tests | Task 10 / PR #18 | diff --git a/scripts/check_workspace_contract.py b/scripts/check_workspace_contract.py index c7b1ecf5..1403153a 100644 --- a/scripts/check_workspace_contract.py +++ b/scripts/check_workspace_contract.py @@ -23,6 +23,7 @@ "tepp_simulation", "validation_core", "tepp_api", + "copy_identity", ) REQUIRED_CI_SNIPPETS: tuple[str, ...] = ( From 37d869745c5ad3020d44118808eab99716b9688c Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Fri, 21 Aug 2026 03:02:29 +0900 Subject: [PATCH 2/3] fix(copy-identity): apply repository rustfmt --- crates/copy_identity/src/kind.rs | 2 +- crates/copy_identity/src/lib.rs | 4 ++-- crates/copy_identity/tests/copy_identity_contract.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/copy_identity/src/kind.rs b/crates/copy_identity/src/kind.rs index e0b7c691..7bf976b5 100644 --- a/crates/copy_identity/src/kind.rs +++ b/crates/copy_identity/src/kind.rs @@ -86,7 +86,7 @@ pub fn identity_recovery_rate( #[cfg(test)] mod tests { use super::{ - identity_recovery_rate, refuse_copy_as_source_identity, refuse_copy_as_transition, CopyKind, + CopyKind, identity_recovery_rate, refuse_copy_as_source_identity, refuse_copy_as_transition, }; use crate::CopyIdentityError; diff --git a/crates/copy_identity/src/lib.rs b/crates/copy_identity/src/lib.rs index 45bb53fd..47243f14 100644 --- a/crates/copy_identity/src/lib.rs +++ b/crates/copy_identity/src/lib.rs @@ -12,11 +12,11 @@ mod kind; /// Fail-closed copy-identity errors. pub use error::CopyIdentityError; +/// Closed vocabulary of copy-related document identities. +pub use kind::CopyKind; /// Fraction of recovered copy kinds that match known truth. pub use kind::identity_recovery_rate; /// Refuse to treat a template copy as the source document identity. pub use kind::refuse_copy_as_source_identity; /// Refuse to treat a template copy as a forward state transition. pub use kind::refuse_copy_as_transition; -/// Closed vocabulary of copy-related document identities. -pub use kind::CopyKind; diff --git a/crates/copy_identity/tests/copy_identity_contract.rs b/crates/copy_identity/tests/copy_identity_contract.rs index c047f0a3..18bb7cfc 100644 --- a/crates/copy_identity/tests/copy_identity_contract.rs +++ b/crates/copy_identity/tests/copy_identity_contract.rs @@ -1,8 +1,8 @@ //! A template copy is not the source document and not a state transition. use copy_identity::{ - identity_recovery_rate, refuse_copy_as_source_identity, refuse_copy_as_transition, - CopyIdentityError, CopyKind, + CopyIdentityError, CopyKind, identity_recovery_rate, refuse_copy_as_source_identity, + refuse_copy_as_transition, }; #[test] From fc9dec90b191ff9282dc1536637aae25d061f47d Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Fri, 21 Aug 2026 05:26:27 +0900 Subject: [PATCH 3/3] test: derive crate contract from workspace manifest --- tests/quality/test_check_docstrings.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/quality/test_check_docstrings.py b/tests/quality/test_check_docstrings.py index 2c11f7a5..da59f799 100644 --- a/tests/quality/test_check_docstrings.py +++ b/tests/quality/test_check_docstrings.py @@ -11,6 +11,7 @@ from unittest import mock from scripts import check_docstrings as docstrings +from scripts import check_workspace_contract as workspace_contract REPOSITORY_ROOT = Path(__file__).resolve().parents[2] @@ -24,7 +25,7 @@ def test_live_repository_is_documented(self) -> None: sources = docstrings.rust_sources(REPOSITORY_ROOT) crate_roots = sorted(REPOSITORY_ROOT.glob("crates/*/src/lib.rs")) - self.assertEqual(len(crate_roots), 10) + self.assertEqual(len(crate_roots), len(workspace_contract.EXPECTED_CRATES)) self.assertTrue(set(crate_roots).issubset(sources)) self.assertGreaterEqual(len(sources), len(crate_roots)) self.assertEqual(docstrings.validate_repository(REPOSITORY_ROOT), [])