Skip to content
Open
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 |
| `inferred_status` | inferred relations cannot be promoted to observed evidence or transitions |

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
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

- `inferred_status` identity gate: inferred relations cannot be promoted to observed evidence or to state transitions; recovered observed/inferred labels match known truth at a higher computed rate than treating every status as observed (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.
- `tepp_api` adaptive orchestration router (ADR 0010): versioned `direct`/`verify`/`committee`/`conductor`/`abstain` selection from CPU `f64` risk, ambiguity, evidence, and token-budget inputs; recorded stages, recursion, decomposition, access lists, and role-specific reasoning effort; fail-closed document-controlled policy/access/credentials; LLM plans remain proposals under deterministic statistical authority; comparable-budget ablation requires a direct baseline; credential-free contextual-orchestrator binding. Live NIM HTTP remains accepted-target.
- `tepp_api` purpose-bound provider-payload minimization: time-bounded `PurposeGrant` evaluation, fail-closed expired/not-yet-valid/inverted/cross-tenant/impossible-calendar denial, semantic UTC calendar validation, refusal to copy identity mappings into model-provider payloads or ordinary logs, preservation of opaque analytical identifiers and membership roles (no blanket PII mask), a separately authorized scientific re-identification path, and an internally bound FIPS 180-4 SHA-256 audit digest appended through `ReidentificationAuditSink` before disclosure.
- `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).
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/inferred_status",
]
default-members = [
"crates/evidence_core",
Expand All @@ -23,6 +24,7 @@ default-members = [
"crates/tepp_simulation",
"crates/validation_core",
"crates/tepp_api",
"crates/inferred_status",
]

[workspace.package]
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -22,6 +22,7 @@ crates/corpus_split
crates/tepp_simulation
crates/validation_core
crates/tepp_api
crates/inferred_status
```

## Local verification
Expand Down
17 changes: 17 additions & 0 deletions crates/inferred_status/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "inferred_status"
description = "Inferred relations cannot be promoted to observed evidence or transitions."
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/inferred_status/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//! Fail-closed inferred-status errors.

use std::fmt;

/// A fail-closed inferred-status error.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum InferredStatusError {
/// An inferred relation was treated as observed evidence.
InferredIsNotObserved,
/// An inferred relation was treated as a state transition.
InferredIsNotTransition,
/// A recovery slice was empty or length-mismatched.
InvalidStatusPayload,
}

impl fmt::Display for InferredStatusError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
let message = match self {
Self::InferredIsNotObserved => "inferred relation is not observed evidence",
Self::InferredIsNotTransition => "inferred relation is not a state transition",
Self::InvalidStatusPayload => "invalid inferred-status payload",
};
formatter.write_str(message)
}
}

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

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

#[test]
fn error_messages_are_stable() {
for (error, message) in [
(
InferredStatusError::InferredIsNotObserved,
"inferred relation is not observed evidence",
),
(
InferredStatusError::InferredIsNotTransition,
"inferred relation is not a state transition",
),
(
InferredStatusError::InvalidStatusPayload,
"invalid inferred-status payload",
),
] {
assert_eq!(error.to_string(), message);
}
}
}
23 changes: 23 additions & 0 deletions crates/inferred_status/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#![forbid(unsafe_code)]
#![deny(missing_docs)]
#![allow(clippy::cast_precision_loss)]
//! Inferred relations cannot be promoted to observed evidence or transitions.
//!
//! LLM, reasoner, and heuristic proposals stay inferred until deterministic
//! schema, evidence, and scientific validation promote them (ADR 0003).

mod error;
mod status;

/// Fail-closed inferred-status errors.
pub use error::InferredStatusError;
/// Closed vocabulary of presence evidence that is not yet a transition.
pub use status::EvidenceStatus;
/// Fraction of recovered evidence statuses that match known truth.
pub use status::identity_recovery_rate;
/// Refuse to treat an inferred relation as observed evidence.
pub use status::refuse_inferred_as_observed;
/// Refuse to treat an inferred relation as a state transition.
pub use status::refuse_inferred_as_transition;
/// Return whether a status is observed evidence.
pub use status::status_is_observed;
143 changes: 143 additions & 0 deletions crates/inferred_status/src/status.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
//! Observed versus inferred relation evidence status.

use crate::InferredStatusError;

/// Closed vocabulary of presence evidence that is not yet a transition.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum EvidenceStatus {
/// Directly observed in source documents or authoritative systems.
Observed,
/// Derived by a model, reasoner, or heuristic and not yet promoted.
Inferred,
}

impl EvidenceStatus {
/// Return the stable wire status name.
#[must_use]
pub const fn wire_name(self) -> &'static str {
match self {
Self::Observed => "observed",
Self::Inferred => "inferred",
}
}

/// Parse a stable wire status name.
///
/// # Errors
///
/// Returns [`InferredStatusError::InvalidStatusPayload`] for unrecognized
/// names.
pub fn from_wire_name(name: &str) -> Result<Self, InferredStatusError> {
match name {
"observed" => Ok(Self::Observed),
"inferred" => Ok(Self::Inferred),
_ => Err(InferredStatusError::InvalidStatusPayload),
}
}
}

/// Return whether a status is observed evidence.
///
/// # Errors
///
/// This function is infallible for the closed vocabulary and exists to keep
/// the public comparison surface explicit.
#[allow(clippy::unnecessary_wraps)]
pub fn status_is_observed(status: EvidenceStatus) -> Result<bool, InferredStatusError> {
Ok(matches!(status, EvidenceStatus::Observed))
}

/// Refuse to treat an inferred relation as observed evidence.
///
/// # Errors
///
/// Returns [`InferredStatusError::InferredIsNotObserved`] when `status` is
/// [`EvidenceStatus::Inferred`].
pub fn refuse_inferred_as_observed(status: EvidenceStatus) -> Result<(), InferredStatusError> {
match status {
EvidenceStatus::Inferred => Err(InferredStatusError::InferredIsNotObserved),
EvidenceStatus::Observed => Ok(()),
}
}

/// Refuse to treat an inferred relation as a state transition.
///
/// # Errors
///
/// Returns [`InferredStatusError::InferredIsNotTransition`] when `status` is
/// [`EvidenceStatus::Inferred`].
pub fn refuse_inferred_as_transition(status: EvidenceStatus) -> Result<(), InferredStatusError> {
match status {
EvidenceStatus::Inferred => Err(InferredStatusError::InferredIsNotTransition),
EvidenceStatus::Observed => Ok(()),
}
}

/// Fraction of recovered evidence statuses that match known truth.
///
/// # Errors
///
/// Returns [`InferredStatusError::InvalidStatusPayload`] when either slice is
/// empty or the lengths differ.
pub fn identity_recovery_rate(
truth: &[EvidenceStatus],
decided: &[EvidenceStatus],
) -> Result<f64, InferredStatusError> {
if truth.is_empty() || truth.len() != decided.len() {
return Err(InferredStatusError::InvalidStatusPayload);
}
let mut matches = 0_u32;
for (truth_status, decided_status) in truth.iter().zip(decided) {
if truth_status == decided_status {
matches += 1;
}
}
Ok(f64::from(matches) / truth.len() as f64)
}

#[cfg(test)]
mod tests {
use super::{
EvidenceStatus, identity_recovery_rate, refuse_inferred_as_observed,
refuse_inferred_as_transition, status_is_observed,
};
use crate::InferredStatusError;

#[test]
fn local_branches_cover_statuses_payloads_and_wire_names() {
assert_eq!(
refuse_inferred_as_observed(EvidenceStatus::Inferred),
Err(InferredStatusError::InferredIsNotObserved)
);
assert_eq!(
refuse_inferred_as_transition(EvidenceStatus::Inferred),
Err(InferredStatusError::InferredIsNotTransition)
);
refuse_inferred_as_observed(EvidenceStatus::Observed).expect("observed");
refuse_inferred_as_transition(EvidenceStatus::Observed).expect("observed");
assert!(status_is_observed(EvidenceStatus::Observed).expect("observed"));
assert!(!status_is_observed(EvidenceStatus::Inferred).expect("inferred"));
for status in [EvidenceStatus::Observed, EvidenceStatus::Inferred] {
assert_eq!(
EvidenceStatus::from_wire_name(status.wire_name()).expect("round-trip"),
status
);
}
assert_eq!(
EvidenceStatus::from_wire_name("promoted"),
Err(InferredStatusError::InvalidStatusPayload)
);
let matched =
identity_recovery_rate(&[EvidenceStatus::Inferred], &[EvidenceStatus::Inferred])
.expect("rate");
assert!((matched - 1.0).abs() < f64::EPSILON);
assert_eq!(
identity_recovery_rate(&[], &[]),
Err(InferredStatusError::InvalidStatusPayload)
);
assert_eq!(
identity_recovery_rate(&[EvidenceStatus::Inferred], &[]),
Err(InferredStatusError::InvalidStatusPayload)
);
}
}
7 changes: 7 additions & 0 deletions crates/inferred_status/tests/crate_contract.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//! Integration contract for the `inferred_status` package identity.

#[test]
fn package_identity_is_stable() {
let observed = std::hint::black_box(env!("CARGO_PKG_NAME"));
assert_eq!(observed, "inferred_status");
}
70 changes: 70 additions & 0 deletions crates/inferred_status/tests/inferred_status_contract.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//! Inferred relations cannot be promoted to observed evidence or transitions.

use inferred_status::{
EvidenceStatus, InferredStatusError, identity_recovery_rate, refuse_inferred_as_observed,
refuse_inferred_as_transition, status_is_observed,
};

#[test]
fn inferred_status_cannot_become_observed_or_a_transition() {
assert_eq!(
refuse_inferred_as_observed(EvidenceStatus::Inferred),
Err(InferredStatusError::InferredIsNotObserved)
);
assert_eq!(
refuse_inferred_as_transition(EvidenceStatus::Inferred),
Err(InferredStatusError::InferredIsNotTransition)
);
refuse_inferred_as_observed(EvidenceStatus::Observed).expect("observed stays observed");
refuse_inferred_as_transition(EvidenceStatus::Observed)
.expect("observed may be considered for promotion elsewhere");
assert!(status_is_observed(EvidenceStatus::Observed).expect("observed"));
assert!(!status_is_observed(EvidenceStatus::Inferred).expect("inferred"));
}

#[test]
fn recovered_statuses_match_known_truth_better_than_an_observed_collapse() {
let truth = [
EvidenceStatus::Observed,
EvidenceStatus::Inferred,
EvidenceStatus::Inferred,
];
let recovered = truth;
let collapsed = [
EvidenceStatus::Observed,
EvidenceStatus::Observed,
EvidenceStatus::Observed,
];
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_status, decided_status) in truth.iter().zip(recovered.iter()) {
if truth_status == decided_status {
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_status_payloads_fail_closed() {
assert_eq!(
identity_recovery_rate(&[], &[]),
Err(InferredStatusError::InvalidStatusPayload)
);
assert_eq!(
identity_recovery_rate(&[EvidenceStatus::Inferred], &[]),
Err(InferredStatusError::InvalidStatusPayload)
);
assert_eq!(
identity_recovery_rate(
&[EvidenceStatus::Observed, EvidenceStatus::Inferred],
&[EvidenceStatus::Observed]
),
Err(InferredStatusError::InvalidStatusPayload)
);
}
2 changes: 1 addition & 1 deletion docs/TRACEABILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The full APA 7th standards/literature register remains `docs/research/standards-
| 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 |
| 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 |
| 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 |
| recovery metrics (RMSE, bias, coverage, graph, temporal order, Monte Carlo SE gates) | PRD; Test Strategy; ADR 0007/0014 | `validation_core` on protected main (PR #19); SE-aware Monte Carlo gates included | implemented-main |
| PostgreSQL bitemporal/lineage persistence | ADR 0013; Architecture/ERD | `persistence_postgres` migration contracts, in-memory adapters, live SQL session/document SQL port, tenant RLS (`0002` + session GUC/role helpers), `DATABASE_URL` SQLx gate, optional `live-sqlx` `PgPool` driver, exact-head live PostgreSQL CI with isolation proof, append-only immutability triggers (`0004`), temporal interval ordering CHECKs (`0005`), typed membership assignment (`0006` implemented-main), event-relation/mention/instance SQL (#37–#39 implemented-main), source-artifact SQL (#40 implemented-main), audit-event SQL (#41 implemented-main), concurrent document-write stress (#43 implemented-main), backup/restore integrity revalidation (active PR); remaining physical ERD constraints | partial |
Expand Down
2 changes: 1 addition & 1 deletion docs/adr/0003-relational-event-multiple-membership.md
Original file line number Diff line number Diff line change
@@ -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; 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
**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.

Expand Down
Loading
Loading