Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to TEPP are documented here. The format follows Keep a Chang

### Added

- `event_core` mention-confidence Brier score: known-truth binary outcomes recover a computed Brier of 0 for perfect forecasts and 0.25 for constant 0.5, with empty or mismatched streams failing closed.
- `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
1 change: 1 addition & 0 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ TEPP's approved PRD v0.4 and implementation plan are the primary product baselin
| Hourly NIM product-development operations | [`docs/operations/HOURLY_NIM_PRODUCT_DEVELOPMENT.md`](docs/operations/HOURLY_NIM_PRODUCT_DEVELOPMENT.md) |
| 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) |
| Mention-confidence Brier doctoring | [`docs/research/mention-confidence-brier.md`](docs/research/mention-confidence-brier.md) |
| Retention/deletion/legal-hold doctoring | [`docs/research/retention-deletion-legal-hold.md`](docs/research/retention-deletion-legal-hold.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) |
Expand Down
27 changes: 27 additions & 0 deletions crates/event_core/src/confidence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,29 @@ impl EventConfidence {
}
}

/// Mean squared error of mention probabilities against binary truth.
///
/// # Errors
///
/// Returns [`EventError::InvalidWirePayload`] when the slices are empty or
/// have unequal length.
pub fn mention_brier_score(
forecasts: &[EventConfidence],
outcomes: &[bool],
) -> Result<f64, EventError> {
if forecasts.is_empty() || forecasts.len() != outcomes.len() {
return Err(EventError::InvalidWirePayload);
}
let mut square_sum = 0.0_f64;
for (forecast, outcome) in forecasts.iter().zip(outcomes) {
let target = if *outcome { 1.0 } else { 0.0 };
let residual = forecast.value() - target;
square_sum += residual * residual;
}
#[allow(clippy::cast_precision_loss)]
Ok(square_sum / forecasts.len() as f64)
}
Comment on lines +48 to +63

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: Brier score computation is correct and fail-closed

mention_brier_score (confidence.rs) computes the mean of squared residuals against binary truth, matching the standard Brier score. It fails closed on empty or length-mismatched inputs via EventError::InvalidWirePayload, and EventConfidence already guarantees finite values in [0,1], so no NaN/overflow risk exists. The logic verified against the documented test vectors (perfect 0, constant-0.5 = 0.25).

Open in Devin Review

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


#[cfg(test)]
mod tests {
use super::EventConfidence;
Expand All @@ -56,5 +79,9 @@ mod tests {
EventConfidence::new(f64::NAN),
Err(EventError::InvalidEventConfidence)
);
let one = EventConfidence::certain().expect("certain");
assert!((one.value() - 1.0).abs() < 1e-15);
let miss = super::mention_brier_score(&[one], &[false]).expect("miss");
assert!((miss - 1.0).abs() < 1e-15);
}
}
2 changes: 2 additions & 0 deletions crates/event_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ mod role;

/// Finite confidence on the closed unit interval.
pub use confidence::EventConfidence;
/// Mean squared error of mention probabilities against binary truth.
pub use confidence::mention_brier_score;
/// Fail-closed event-ontology errors.
pub use error::EventError;
/// Opaque event-instance identifier.
Expand Down
37 changes: 37 additions & 0 deletions crates/event_core/tests/confidence_calibration_contract.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//! Mention confidence recovers known Brier scores against binary truth.

use event_core::{EventConfidence, EventError, mention_brier_score};

#[test]
fn perfectly_calibrated_forecasts_recover_zero_brier() {
let forecasts = [
EventConfidence::new(0.0).expect("0"),
EventConfidence::new(1.0).expect("1"),
EventConfidence::new(0.0).expect("0"),
EventConfidence::new(1.0).expect("1"),
];
let outcomes = [false, true, false, true];
let score = mention_brier_score(&forecasts, &outcomes).expect("brier");
assert!(score.abs() < 1e-15, "perfect Brier {score}");
}

#[test]
fn constant_half_recovers_quarter_and_mismatches_fail_closed() {
let forecasts = [
EventConfidence::new(0.5).expect("half"),
EventConfidence::new(0.5).expect("half"),
];
let outcomes = [false, true];
let score = mention_brier_score(&forecasts, &outcomes).expect("half");
let residual = score - 0.25;
let rmse = (residual * residual).sqrt();
assert!(rmse < 1e-15, "Brier RMSE {rmse}");
assert_eq!(
mention_brier_score(&forecasts, &[true]),
Err(EventError::InvalidWirePayload)
);
assert_eq!(
mention_brier_score(&[], &[]),
Err(EventError::InvalidWirePayload)
);
}
2 changes: 1 addition & 1 deletion docs/TRACEABILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The full APA 7th standards/literature register remains `docs/research/standards-
| 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 |
| 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 |
| 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; Brier calibration on the active PR; 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 |
| 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 |
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
2 changes: 1 addition & 1 deletion docs/connectors/naruon-artifact-consumer.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# naruon modular consumer contract for TEPP artifacts

**Status:** Partial — versioned DTO, HTTP interchange, and loopback live listener on the active PR; production TLS/`$PORT` remaining
**Status:** Partial — versioned DTO, HTTP interchange, and loopback live listener on the active PR; production TLS/`$PORT` remaining
**Last reviewed:** 2026-08-16

## Boundary
Expand Down
27 changes: 27 additions & 0 deletions docs/research/mention-confidence-brier.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Mention-confidence Brier score

## Scope

This note doctors the `event_core` calibration contract for fallible event mentions:

1. mention confidence is a probability on `[0, 1]`;
2. `mention_brier_score` is the mean squared error against binary truth;
3. empty or length-mismatched streams fail closed.

TDT/CHRONOS promotion remains on the event-intelligence active PR. No database migration is allocated.

## Authoritative sources

Brier, G. W. (1950). Verification of forecasts expressed in terms of probability. *Monthly Weather Review, 78*(1), 1–3. https://doi.org/10.1175/1520-0493(1950)078<0001:VOFEIT>2.0.CO;2

Gneiting, T., & Raftery, A. E. (2007). Strictly proper scoring rules, prediction, and estimation. *Journal of the American Statistical Association, 102*(477), 359–378. https://doi.org/10.1198/016214506000001437

## Application

Brier (1950) defines the mean squared error of a probability forecast. Gneiting and Raftery (2007) treat the Brier score as a strictly proper scoring rule, so a mention that is certain when true and impossible when false is uniquely optimal. TEPP therefore scores mention confidence against known binary outcomes rather than treating a high score as an event instance (Brier, 1950; Gneiting & Raftery, 2007).
Comment on lines +13 to +21

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: APA 7 reference placed in separate doctoring note, matching repo pattern

CONTRIBUTING.md states APA 7 references are recorded in docs/research/standards-and-literature.md, and the Brier/Gneiting references are NOT added there. I did not flag this because the established repo convention (e.g. docs/research/adaptive-orchestration-router.md) is per-capability doctoring notes carrying their own "Authoritative sources" section, which mention-confidence-brier.md follows, and AGENTS.md rule 13 only requires citation somewhere in docs/research/. Reviewer may still want to confirm whether the central register should be kept in sync.

Open in Devin Review

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


## Verification

- forecasts `(0,1,0,1)` against outcomes `(false,true,false,true)` recover Brier `0`;
- constant `0.5` against mixed outcomes recovers `0.25` with computed residual RMSE;
- empty and mismatched streams return `InvalidWirePayload`.
1 change: 1 addition & 0 deletions docs/validation/temporal-event-foundation.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This report tracks exact-head scientific and engineering evidence required befor
| 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 |
| Recovery metrics | `validation_core` | implemented-main | — | RMSE/bias/coverage/MC gates | Task 11 / PR #19 |
| Mention-confidence Brier score | `event_core` | active-PR | calibration vs binary truth | perfect 0 / half 0.25 RMSE | ADR 0003; `docs/research/mention-confidence-brier.md` |
| Versioned API/export contracts | `tepp_api` | implemented-main | naruon HTTP interchange | unknown-field/version/limit + naruon HTTPS interchange tests | Task 12 / PR #21; live HTTP service remaining |
| Purpose-bound provider payloads | `tepp_api` | implemented-main | provider-payload minimization | expired/not-yet-valid/inverted/cross-tenant/impossible-calendar grant, mapping refusal, audited elevated re-id replay | ADR 0009; `docs/research/provider-payload-minimization.md` |
| Adaptive orchestration router | `tepp_api` | accepted-target | active PR | mode selection, document-control denial, ablation, credential-free bind | ADR 0010; `docs/research/adaptive-orchestration-router.md` |
Expand Down
Loading