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 |
| `stopword_deletion` | default stopword deletion is not a valid method for repeated report language |

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

- `stopword_deletion` method gate: a default or global stopword list cannot erase repeated report language; recovered deletion kinds match known truth at a higher computed rate than collapsing every token treatment to stopword deletion (ADR 0004/0012).
- `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` naruon live loopback HTTP/1.1 listener: `serve_one` installs a read/write deadline, requires a loopback `Host`, refuses `Transfer-Encoding` and NIM/proxy credential headers, parses `knowledge_cutoff` as RFC 3339 and refuses a future cutoff, keys analysis-run idempotency by tenant plus key, and proves both analysis-run and export POSTs over a real `TcpStream`. Not a production TLS/`$PORT` service (ADR 0011).
- `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.
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/stopword_deletion",
]
default-members = [
"crates/evidence_core",
Expand All @@ -23,6 +24,7 @@ default-members = [
"crates/tepp_simulation",
"crates/validation_core",
"crates/tepp_api",
"crates/stopword_deletion",
]

[workspace.package]
Expand Down
1 change: 1 addition & 0 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ TEPP's approved PRD v0.4 and implementation plan are the primary product baselin
| Actions workflow fleet audit | [`docs/operations/ACTIONS_WORKFLOW_FLEET.md`](docs/operations/ACTIONS_WORKFLOW_FLEET.md) |
| Actions fleet research doctoring | [`docs/research/actions-workflow-fleet.md`](docs/research/actions-workflow-fleet.md) |
| Retention/deletion/legal-hold doctoring | [`docs/research/retention-deletion-legal-hold.md`](docs/research/retention-deletion-legal-hold.md) |
| Stopword-deletion doctoring | [`docs/research/stopword-deletion.md`](docs/research/stopword-deletion.md) |
| Provider-payload minimization doctoring | [`docs/research/provider-payload-minimization.md`](docs/research/provider-payload-minimization.md) |
| Adaptive orchestration router doctoring | [`docs/research/adaptive-orchestration-router.md`](docs/research/adaptive-orchestration-router.md) |
| Hourly NIM OpenCode doctoring | [`docs/doctoring/hourly-nim-opencode-development.md`](docs/doctoring/hourly-nim-opencode-development.md) |
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/stopword_deletion
```

## Local verification
Expand Down
17 changes: 17 additions & 0 deletions crates/stopword_deletion/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "stopword_deletion"
description = "Default stopword deletion is not a valid method for repeated report language."
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
48 changes: 48 additions & 0 deletions crates/stopword_deletion/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//! Fail-closed stopword-deletion errors.

use std::fmt;

/// A fail-closed stopword-deletion error.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum StopwordDeletionError {
/// A default or global stopword list was used as deletion.
DefaultStopwordDeletion,
/// A recovery slice was empty or length-mismatched.
InvalidDeletionPayload,
}

impl fmt::Display for StopwordDeletionError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
let message = match self {
Self::DefaultStopwordDeletion => {
"default stopword deletion is not a valid method for repeated report language"
}
Self::InvalidDeletionPayload => "invalid stopword-deletion payload",
};
formatter.write_str(message)
}
}

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

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

#[test]
fn error_messages_are_stable() {
for (error, message) in [
(
StopwordDeletionError::DefaultStopwordDeletion,
"default stopword deletion is not a valid method for repeated report language",
),
(
StopwordDeletionError::InvalidDeletionPayload,
"invalid stopword-deletion payload",
),
] {
assert_eq!(error.to_string(), message);
}
}
}
114 changes: 114 additions & 0 deletions crates/stopword_deletion/src/kind.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
//! Deletion methods that cannot silently erase repeated report language.

use crate::StopwordDeletionError;

/// Closed vocabulary of deletion versus explicit method-source treatments.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum DeletionKind {
/// A default or global stopword list applied as deletion.
DefaultStopwordList,
/// Repeated language kept as explicit method/background structure.
ExplicitMethodSource,
}

impl DeletionKind {
/// Return the stable wire kind name.
#[must_use]
pub const fn wire_name(self) -> &'static str {
match self {
Self::DefaultStopwordList => "default_stopword_list",
Self::ExplicitMethodSource => "explicit_method_source",
}
}

/// Parse a stable wire kind name.
///
/// # Errors
///
/// Returns [`StopwordDeletionError::InvalidDeletionPayload`] for unrecognized
/// names.
pub fn from_wire_name(name: &str) -> Result<Self, StopwordDeletionError> {
match name {
"default_stopword_list" => Ok(Self::DefaultStopwordList),
"explicit_method_source" => Ok(Self::ExplicitMethodSource),
_ => Err(StopwordDeletionError::InvalidDeletionPayload),
}
}
}

/// Refuse to treat a default stopword list as a valid deletion method.
///
/// # Errors
///
/// Returns [`StopwordDeletionError::DefaultStopwordDeletion`] when `kind` is
/// [`DeletionKind::DefaultStopwordList`].
pub fn refuse_default_stopword_deletion(kind: DeletionKind) -> Result<(), StopwordDeletionError> {
match kind {
DeletionKind::DefaultStopwordList => Err(StopwordDeletionError::DefaultStopwordDeletion),
DeletionKind::ExplicitMethodSource => Ok(()),
}
}

/// Fraction of recovered deletion kinds that match known truth.
///
/// # Errors
///
/// Returns [`StopwordDeletionError::InvalidDeletionPayload`] when either slice
/// is empty or the lengths differ.
pub fn identity_recovery_rate(
truth: &[DeletionKind],
decided: &[DeletionKind],
) -> Result<f64, StopwordDeletionError> {
if truth.is_empty() || truth.len() != decided.len() {
return Err(StopwordDeletionError::InvalidDeletionPayload);
}
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::{DeletionKind, identity_recovery_rate, refuse_default_stopword_deletion};
use crate::StopwordDeletionError;

#[test]
fn local_branches_cover_kinds_payloads_and_wire_names() {
assert_eq!(
refuse_default_stopword_deletion(DeletionKind::DefaultStopwordList),
Err(StopwordDeletionError::DefaultStopwordDeletion)
);
refuse_default_stopword_deletion(DeletionKind::ExplicitMethodSource).expect("source");
for kind in [
DeletionKind::DefaultStopwordList,
DeletionKind::ExplicitMethodSource,
] {
assert_eq!(
DeletionKind::from_wire_name(kind.wire_name()).expect("round-trip"),
kind
);
}
assert_eq!(
DeletionKind::from_wire_name("tfidf_weight"),
Err(StopwordDeletionError::InvalidDeletionPayload)
);
let matched = identity_recovery_rate(
&[DeletionKind::ExplicitMethodSource],
&[DeletionKind::ExplicitMethodSource],
)
.expect("rate");
assert!((matched - 1.0).abs() < f64::EPSILON);
assert_eq!(
identity_recovery_rate(&[], &[]),
Err(StopwordDeletionError::InvalidDeletionPayload)
);
assert_eq!(
identity_recovery_rate(&[DeletionKind::DefaultStopwordList], &[]),
Err(StopwordDeletionError::InvalidDeletionPayload)
);
}
}
20 changes: 20 additions & 0 deletions crates/stopword_deletion/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#![forbid(unsafe_code)]
#![deny(missing_docs)]
#![allow(clippy::cast_precision_loss)]
//! Default stopword deletion is not a valid method for repeated report language.
//!
//! A global stopword list cannot erase boilerplate. Repeated template, section,
//! copied-text, style, modality, and corpus-background wording stays explicit
//! method/background structure (ADR 0004/0012).

mod error;
mod kind;

/// Fail-closed stopword-deletion errors.
pub use error::StopwordDeletionError;
/// Closed vocabulary of deletion versus explicit method-source treatments.
pub use kind::DeletionKind;
/// Fraction of recovered deletion kinds that match known truth.
pub use kind::identity_recovery_rate;
/// Refuse to treat a default stopword list as a valid deletion method.
pub use kind::refuse_default_stopword_deletion;
7 changes: 7 additions & 0 deletions crates/stopword_deletion/tests/crate_contract.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//! Integration contract for the `stopword_deletion` package identity.

#[test]
fn package_identity_is_stable() {
let observed = std::hint::black_box(env!("CARGO_PKG_NAME"));
assert_eq!(observed, "stopword_deletion");
}
64 changes: 64 additions & 0 deletions crates/stopword_deletion/tests/stopword_deletion_contract.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//! Default stopword deletion cannot erase repeated report language.

use stopword_deletion::{
DeletionKind, StopwordDeletionError, identity_recovery_rate, refuse_default_stopword_deletion,
};

#[test]
fn a_default_stopword_list_cannot_delete_repeated_report_language() {
assert_eq!(
refuse_default_stopword_deletion(DeletionKind::DefaultStopwordList),
Err(StopwordDeletionError::DefaultStopwordDeletion)
);
refuse_default_stopword_deletion(DeletionKind::ExplicitMethodSource).expect("source");
}

#[test]
fn recovered_kinds_match_known_truth_better_than_a_stopword_collapse() {
let truth = [
DeletionKind::ExplicitMethodSource,
DeletionKind::ExplicitMethodSource,
DeletionKind::DefaultStopwordList,
];
let recovered = truth;
let collapsed = [
DeletionKind::DefaultStopwordList,
DeletionKind::DefaultStopwordList,
DeletionKind::DefaultStopwordList,
];
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(StopwordDeletionError::InvalidDeletionPayload)
);
assert_eq!(
identity_recovery_rate(&[DeletionKind::DefaultStopwordList], &[]),
Err(StopwordDeletionError::InvalidDeletionPayload)
);
assert_eq!(
identity_recovery_rate(
&[
DeletionKind::DefaultStopwordList,
DeletionKind::ExplicitMethodSource
],
&[DeletionKind::DefaultStopwordList]
),
Err(StopwordDeletionError::InvalidDeletionPayload)
);
}
2 changes: 1 addition & 1 deletion docs/TRACEABILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The full APA 7th standards/literature register remains `docs/research/standards-
| multilingual shared latent semantic space | PRD; ADR 0004 | future semantic/concept/topic crates | accepted-target |
| TRSL-TM temporal/relational topic posterior and backend compatibility | ADR 0012; ADR 0004 | future `topic_measurement` | accepted-target |
| global P0 topic identity with activity/dormancy/reactivation | ADR 0012 | future topic lineage/activity state | accepted-target |
| no default stopword deletion / no TF-IDF-BM25 inferential weighting | ADR 0004/0012; PRD/TRD | future semantic/method-source model | accepted-target |
| no default stopword deletion / no TF-IDF-BM25 inferential weighting | ADR 0004/0012; PRD/TRD | `stopword_deletion` default-list refusal on the active PR; TF-IDF/BM25 inferential-weight refusal remains accepted-target | partial |
| report template/section/copied/style/modality method effects | ADR 0004/0012; PRD/TRD | simulation truth factors implemented; estimator-side method model remains future | partial |
| candidate K statistical/Pareto gates + blinded LLM review | ADR 0012; research | future `model_selection` | accepted-target |
| compositional topic correlation / stable clustering | ADR 0005/0012; research | future `network_analysis` | accepted-target |
Expand Down
2 changes: 1 addition & 1 deletion docs/adr/0004-shared-multilingual-latent-space.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ADR 0004 — Shared multilingual latent semantic space

**Decision status:** Accepted
**Implementation maturity:** accepted-target
**Implementation maturity:** partial — default stopword-deletion refusal is `stopword_deletion` on the active PR; shared-space estimators, language profiles, and TF-IDF/BM25 inferential-weight refusal remain accepted-target
**Date:** 2026-08-05
**Supersedes:** None. ADR 0012 governs the complete topic-estimator/backend/global-topic contract built on this multilingual measurement decision.

Expand Down
2 changes: 1 addition & 1 deletion docs/adr/0011-standalone-modular-msa-boundary.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ADR 0011 — Standalone operation and modular CWL MSA boundary

**Decision status:** Accepted
**Implementation maturity:** partial — Rust crates are independently usable; naruon HTTP interchange and loopback live listener (`POST /v1/analysis-runs` and `/v1/exports`, fail-closed table-access, NIM/proxy headers, RFC 3339 cutoff, stream deadline) are on the active PR (not implemented-main); production TLS/`$PORT` and remaining persistence integrations remain accepted-target
**Implementation maturity:** partial — Rust crates are independently usable; naruon HTTP interchange and loopback live listener (`POST /v1/analysis-runs` and `/v1/exports`, fail-closed table-access, NIM/proxy headers, RFC 3339 cutoff, stream deadline) are on the active PR (not implemented-main); production TLS/`$PORT` and remaining persistence integrations remain accepted-target
**Date:** 2026-08-10
**Supersedes:** The broad cross-service ownership wording in ADR 0001. ADR 0001 remains authoritative for Rust-first numerical architecture.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ADR 0012 — Temporal Relational Shared-Latent Topic Measurement

**Decision status:** Accepted
**Implementation maturity:** accepted-target
**Implementation maturity:** partial — default stopword-deletion refusal is `stopword_deletion` on the active PR; topic estimator, global topic identity, method-effect model, and TF-IDF/BM25 inferential-weight refusal remain accepted-target
**Date:** 2026-08-12
**Supersedes:** None; refines ADR 0004 and ADR 0005 without replacing their multilingual and psychometric authorities.

Expand Down
Loading