Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
| `summarizes_edge` | a summary is not a state transition and not the source document |
| `outcome_order` | input-process-outcome edges cannot move backward in event time |
| `retrospective_edge` | retrospective reporting cannot become a transition or a translation |
| `payload_bound` | untrusted documents, records, checkpoints, and LLM outputs fail closed without identity, provenance, size, and depth |
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ All notable changes to TEPP are documented here. The format follows Keep a Chang

### Added

- `summarizes_edge` identity gate: a summary may point to earlier event time but cannot become a state transition or reuse the source document identity; recovered summary kinds match known truth at a higher computed rate than collapsing every summary 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.
- `outcome_order` identity gate: `input_to` and `process_to` cannot move backward or stay contemporaneous in event-time rank; `outcome_of` may point at an earlier producer and cannot become a state transition; recovered kinds match known truth at a higher computed rate than collapsing every kind to `input_to` (ADR 0002/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.
- `retrospective_edge` identity gate: retrospective reporting may point to earlier event time but cannot become a state transition or a translation; recovered reporting kinds match known truth at a higher computed rate than collapsing every report to a contemporaneous forward report (ADR 0002/0003).
Expand Down
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ members = [
"crates/tepp_simulation",
"crates/validation_core",
"crates/tepp_api",
"crates/summarizes_edge",
"crates/outcome_order",
"crates/retrospective_edge",
"crates/payload_bound",
Expand Down Expand Up @@ -50,6 +51,7 @@ default-members = [
"crates/tepp_simulation",
"crates/validation_core",
"crates/tepp_api",
"crates/summarizes_edge",
"crates/outcome_order",
"crates/retrospective_edge",
"crates/payload_bound",
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ crates/corpus_split
crates/tepp_simulation
crates/validation_core
crates/tepp_api
crates/summarizes_edge
crates/outcome_order
crates/retrospective_edge
crates/payload_bound
Expand Down
17 changes: 17 additions & 0 deletions crates/summarizes_edge/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "summarizes_edge"
description = "A summary is not a state transition and not the source document."
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
53 changes: 53 additions & 0 deletions crates/summarizes_edge/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//! Fail-closed summarizes-edge errors.

use std::fmt;

/// A fail-closed summarizes-edge error.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum SummarizesEdgeError {
/// A summary was treated as a state transition.
SummaryIsNotTransition,
/// A summary was treated as the source document identity.
SummaryIsNotSourceIdentity,
/// A recovery slice was empty or length-mismatched.
InvalidEdgePayload,
}

impl fmt::Display for SummarizesEdgeError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
let message = match self {
Self::SummaryIsNotTransition => "a summary is not a state transition",
Self::SummaryIsNotSourceIdentity => "a summary is not the source document identity",
Self::InvalidEdgePayload => "invalid summarizes-edge payload",
};
formatter.write_str(message)
}
}

impl std::error::Error for SummarizesEdgeError {}

#[cfg(test)]
mod tests {
use super::SummarizesEdgeError;

#[test]
fn error_messages_are_stable() {
for (error, message) in [
(
SummarizesEdgeError::SummaryIsNotTransition,
"a summary is not a state transition",
),
(
SummarizesEdgeError::SummaryIsNotSourceIdentity,
"a summary is not the source document identity",
),
(
SummarizesEdgeError::InvalidEdgePayload,
"invalid summarizes-edge payload",
),
] {
assert_eq!(error.to_string(), message);
}
}
}
130 changes: 130 additions & 0 deletions crates/summarizes_edge/src/kind.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
//! Summary provenance versus the summarized source document.

use crate::SummarizesEdgeError;

/// Closed vocabulary of summary-related document identities.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum SummarizesKind {
/// A summary of an earlier source (provenance; may point backward).
Summary,
/// The earlier source document being summarized.
SourceDocument,
}

impl SummarizesKind {
/// Return the stable wire kind name.
#[must_use]
pub const fn wire_name(self) -> &'static str {
match self {
Self::Summary => "summarizes",
Self::SourceDocument => "source_document",
}
}

/// Parse a stable wire kind name.
///
/// # Errors
///
/// Returns [`SummarizesEdgeError::InvalidEdgePayload`] for unrecognized
/// names.
pub fn from_wire_name(name: &str) -> Result<Self, SummarizesEdgeError> {
match name {
"summarizes" => Ok(Self::Summary),
"source_document" => Ok(Self::SourceDocument),
_ => Err(SummarizesEdgeError::InvalidEdgePayload),
}
}
}

/// Refuse to treat a summary as a forward state transition.
///
/// # Errors
///
/// Returns [`SummarizesEdgeError::SummaryIsNotTransition`] when `kind` is
/// [`SummarizesKind::Summary`].
pub fn refuse_summary_as_transition(kind: SummarizesKind) -> Result<(), SummarizesEdgeError> {
match kind {
SummarizesKind::Summary => Err(SummarizesEdgeError::SummaryIsNotTransition),
SummarizesKind::SourceDocument => Ok(()),
}
}

/// Refuse to treat a summary as the source document identity.
///
/// # Errors
///
/// Returns [`SummarizesEdgeError::SummaryIsNotSourceIdentity`] when `kind` is
/// [`SummarizesKind::Summary`].
pub fn refuse_summary_as_source_identity(kind: SummarizesKind) -> Result<(), SummarizesEdgeError> {
match kind {
SummarizesKind::Summary => Err(SummarizesEdgeError::SummaryIsNotSourceIdentity),
SummarizesKind::SourceDocument => Ok(()),
}
}

/// Fraction of recovered summary kinds that match known truth.
///
/// # Errors
///
/// Returns [`SummarizesEdgeError::InvalidEdgePayload`] when either slice is
/// empty or the lengths differ.
pub fn identity_recovery_rate(
truth: &[SummarizesKind],
decided: &[SummarizesKind],
) -> Result<f64, SummarizesEdgeError> {
if truth.is_empty() || truth.len() != decided.len() {
return Err(SummarizesEdgeError::InvalidEdgePayload);
}
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)
}
Comment on lines +71 to +85

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: identity_recovery_rate cast precision is intentionally allowed

identity_recovery_rate at kind.rs casts truth.len() as f64, which would normally trip clippy::cast_precision_loss under the workspace's denied pedantic lints. This is intentionally permitted via #![allow(clippy::cast_precision_loss)] in lib.rs. The empty/mismatched-length guard at line 75 ensures no division by zero, and match counting is correct.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


#[cfg(test)]
mod tests {
use super::{
SummarizesKind, identity_recovery_rate, refuse_summary_as_source_identity,
refuse_summary_as_transition,
};
use crate::SummarizesEdgeError;

#[test]
fn local_branches_cover_kinds_payloads_and_wire_names() {
assert_eq!(
refuse_summary_as_transition(SummarizesKind::Summary),
Err(SummarizesEdgeError::SummaryIsNotTransition)
);
assert_eq!(
refuse_summary_as_source_identity(SummarizesKind::Summary),
Err(SummarizesEdgeError::SummaryIsNotSourceIdentity)
);
refuse_summary_as_transition(SummarizesKind::SourceDocument).expect("source");
refuse_summary_as_source_identity(SummarizesKind::SourceDocument).expect("source");
for kind in [SummarizesKind::Summary, SummarizesKind::SourceDocument] {
assert_eq!(
SummarizesKind::from_wire_name(kind.wire_name()).expect("round-trip"),
kind
);
}
assert_eq!(
SummarizesKind::from_wire_name("references"),
Err(SummarizesEdgeError::InvalidEdgePayload)
);
let matched =
identity_recovery_rate(&[SummarizesKind::Summary], &[SummarizesKind::Summary])
.expect("rate");
assert!((matched - 1.0).abs() < f64::EPSILON);
assert_eq!(
identity_recovery_rate(&[], &[]),
Err(SummarizesEdgeError::InvalidEdgePayload)
);
assert_eq!(
identity_recovery_rate(&[SummarizesKind::Summary], &[]),
Err(SummarizesEdgeError::InvalidEdgePayload)
);
}
}
22 changes: 22 additions & 0 deletions crates/summarizes_edge/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#![forbid(unsafe_code)]
#![deny(missing_docs)]
#![allow(clippy::cast_precision_loss)]
//! A summary is not a state transition and not the source document.
//!
//! Summary provenance may point to earlier event time. It never becomes an
//! input-process-outcome edge and never reuses the source identity
//! (ADR 0003).

mod error;
mod kind;

/// Fail-closed summarizes-edge errors.
pub use error::SummarizesEdgeError;
/// Closed vocabulary of summary-related document identities.
pub use kind::SummarizesKind;
/// Fraction of recovered summary kinds that match known truth.
pub use kind::identity_recovery_rate;
/// Refuse to treat a summary as the source document identity.
pub use kind::refuse_summary_as_source_identity;
/// Refuse to treat a summary as a forward state transition.
pub use kind::refuse_summary_as_transition;
7 changes: 7 additions & 0 deletions crates/summarizes_edge/tests/crate_contract.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//! Integration contract for the `summarizes_edge` package identity.

#[test]
fn package_identity_is_stable() {
let observed = std::hint::black_box(env!("CARGO_PKG_NAME"));
assert_eq!(observed, "summarizes_edge");
}
67 changes: 67 additions & 0 deletions crates/summarizes_edge/tests/summarizes_edge_contract.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//! A summary is not a state transition and not the source document.

use summarizes_edge::{
SummarizesEdgeError, SummarizesKind, identity_recovery_rate, refuse_summary_as_source_identity,
refuse_summary_as_transition,
};

#[test]
fn a_summary_cannot_become_a_transition_or_the_source_identity() {
assert_eq!(
refuse_summary_as_transition(SummarizesKind::Summary),
Err(SummarizesEdgeError::SummaryIsNotTransition)
);
assert_eq!(
refuse_summary_as_source_identity(SummarizesKind::Summary),
Err(SummarizesEdgeError::SummaryIsNotSourceIdentity)
);
refuse_summary_as_transition(SummarizesKind::SourceDocument).expect("source");
refuse_summary_as_source_identity(SummarizesKind::SourceDocument).expect("source");
}

#[test]
fn recovered_kinds_match_known_truth_better_than_a_source_collapse() {
let truth = [
SummarizesKind::Summary,
SummarizesKind::SourceDocument,
SummarizesKind::Summary,
];
let recovered = truth;
let collapsed = [
SummarizesKind::SourceDocument,
SummarizesKind::SourceDocument,
SummarizesKind::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(SummarizesEdgeError::InvalidEdgePayload)
);
assert_eq!(
identity_recovery_rate(&[SummarizesKind::Summary], &[]),
Err(SummarizesEdgeError::InvalidEdgePayload)
);
assert_eq!(
identity_recovery_rate(
&[SummarizesKind::Summary, SummarizesKind::SourceDocument],
&[SummarizesKind::Summary]
),
Err(SummarizesEdgeError::InvalidEdgePayload)
);
}
2 changes: 1 addition & 1 deletion docs/TRACEABILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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; `system_clock` system-vs-other-clock identity on the active PR | active-PR |
| 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; `outcome_order` IPO event-time order on the active PR | partial |
| forward-only transition subgraph | PRD; ADR 0002/0003 | `relation_graph` on protected main; `summarizes_edge` summary-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; `inferred_status` inferred-versus-observed identity on the active PR; multilevel estimators remaining | partial |
| leakage-safe availability/cutoff snapshots | PRD; ADR 0002/0013 | `corpus_split` on protected main | implemented-main |
Expand Down
1 change: 1 addition & 0 deletions docs/adr/0003-relational-event-multiple-membership.md
Original file line number Diff line number Diff line change
@@ -1,6 +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; summary-versus-source identity in `summarizes_edge` on the active PR; 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; typed relation graph with forward-only transitions implemented-main; IPO event-time order in `outcome_order` on the active PR; multilevel estimators and persistence remain accepted-target
**Implementation maturity:** partial — membership network and event mention/instance separation implemented-main; retrospective-reporting identity in `retrospective_edge` on the active PR; 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; inferred-versus-observed identity in `inferred_status` on the active PR; typed relation graph with forward-only transitions active-PR; multilevel estimators and persistence remain accepted-target
Expand Down
1 change: 1 addition & 0 deletions docs/adr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Read [`ADR_POLICY.md`](ADR_POLICY.md) first. **Decision status and implementatio
| [0002](0002-six-clock-temporal-semantics.md) | Six-clock temporal semantics and fail-closed historical leakage prevention | Accepted | partial | Typed clocks/intervals are implemented-main via `temporal_core`; retrospective-reporting identity is `retrospective_edge` on the active PR. 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 implemented-main (PR #12); retrospective-reporting identity is `retrospective_edge` on the active PR; full multilevel estimators and persistence remain accepted-target. ADR 0016 owns event-intelligence tasks. |
| [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 implemented-main (PR #12); summary-versus-source identity is `summarizes_edge` on the active PR; full multilevel estimators 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); inferred-versus-observed identity is `inferred_status` on the active PR; full multilevel estimators and persistence remain accepted-target. ADR 0016 owns event-intelligence tasks. |
| [0002](0002-six-clock-temporal-semantics.md) | Six-clock temporal semantics and fail-closed historical leakage prevention | Accepted | active-PR | Evidential-vs-transition gate in `support_edge` on the active PR; remaining graph/split enforcement stays accepted-target. |
| [0003](0003-relational-event-multiple-membership.md) | Relational event ontology and time-varying cross-classified multiple membership | Accepted | partial | Evidential-vs-transition identity in `support_edge` on the active PR; membership network/roles remain implemented-main; full multilevel estimators and persistence remain accepted-target. ADR 0016 owns event-intelligence tasks. |
Expand Down
Loading
Loading