From 2027356f243189303b954122125a4b4f6682cce2 Mon Sep 17 00:00:00 2001 From: Seongho Bae <8172694+seonghobae@users.noreply.github.com> Date: Mon, 31 Aug 2026 21:58:19 +0000 Subject: [PATCH] feat(api): enumerate project histories via loopback collection GET LineageWeave operators can GET /v1/project-histories on tepp-loopback without guessing idempotency keys. Metric-free temporal_association_only identities only. tepp.scientific_acceptance.v1 never appears. Evidence text and findings stay off the page. Does not infer causality. Not project-history CLI. Stacked on protected main. --- .../project-history-collection-http.md | 1 + DOCUMENTATION.md | 1 + crates/tepp_api/src/analysis_run_live.rs | 143 ++++- crates/tepp_api/src/lib.rs | 25 + .../src/project_history_collection_http.rs | 557 ++++++++++++++++++ ...roject_history_collection_http_contract.rs | 53 ++ docs/API_CONTRACT.md | 7 + docs/TRACEABILITY.md | 1 + .../0028-project-history-collection-get.md | 68 +++ docs/adr/README.md | 2 + .../project-history-collection-http.md | 55 ++ 11 files changed, 909 insertions(+), 4 deletions(-) create mode 100644 CHANGELOG.d/project-history-collection-http.md create mode 100644 crates/tepp_api/src/project_history_collection_http.rs create mode 100644 crates/tepp_api/tests/project_history_collection_http_contract.rs create mode 100644 docs/adr/0028-project-history-collection-get.md create mode 100644 docs/research/project-history-collection-http.md diff --git a/CHANGELOG.d/project-history-collection-http.md b/CHANGELOG.d/project-history-collection-http.md new file mode 100644 index 000000000..5540b26e7 --- /dev/null +++ b/CHANGELOG.d/project-history-collection-http.md @@ -0,0 +1 @@ +- `tepp_api` loopback `GET /v1/project-histories` enumerates accepted LineageWeave project-history projections on `tepp-loopback` (ADR 0028). Metric-free `temporal_association_only` identities only. `tepp.scientific_acceptance.v1` never appears. Does not infer causality. Not project-history CLI, not analysis-run collection GET, not persistence. diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 6fa4b9683..92c4bb9d5 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -11,6 +11,7 @@ TEPP's approved PRD v0.4 and implementation plan are the primary product baselin | Architecture | [`ARCHITECTURE.md`](ARCHITECTURE.md) | | Modular/API integration contract | [`docs/API_CONTRACT.md`](docs/API_CONTRACT.md) | | naruon modular consumer contract | [`docs/connectors/naruon-artifact-consumer.md`](docs/connectors/naruon-artifact-consumer.md) | +| Project-history collection GET doctoring | [`docs/research/project-history-collection-http.md`](docs/research/project-history-collection-http.md) | | contextual-orchestrator interpretation port | [`docs/connectors/contextual-orchestrator-interpretation-port.md`](docs/connectors/contextual-orchestrator-interpretation-port.md) | | Orchestrator live HTTP doctoring | [`docs/research/orchestrator-live-http.md`](docs/research/orchestrator-live-http.md) | | UML/runtime/scientific flows | [`docs/UML.md`](docs/UML.md) | diff --git a/crates/tepp_api/src/analysis_run_live.rs b/crates/tepp_api/src/analysis_run_live.rs index 6768c6ef1..fd682d7cd 100644 --- a/crates/tepp_api/src/analysis_run_live.rs +++ b/crates/tepp_api/src/analysis_run_live.rs @@ -19,8 +19,11 @@ use crate::naruon_http::NARUON_ANALYSIS_RUN_PATH; use crate::{ AnalysisRunAccepted, AnalysisRunRequest, ApiError, DEFAULT_PROJECT_HISTORY_BYTE_LIMIT, ErrorEnvelope, NARUON_LIVE_IO_TIMEOUT, NaruonLiveResponse, PROJECT_HISTORY_PATH, - ProjectHistoryProjection, ProjectHistoryRequest, TEMPORAL_CONTEXT_PATH, TemporalContextRequest, - build_temporal_context, project_history_projection, requests_are_idempotent_matches, + ProjectHistoryCollection, ProjectHistoryCollectionItem, ProjectHistoryProjection, + ProjectHistoryRequest, TEMPORAL_CONTEXT_PATH, TemporalContextRequest, build_temporal_context, + is_project_history_collection_path, page_project_history_collection_items, + parse_project_history_collection_page_cursor, parse_project_history_collection_page_limit, + project_history_projection, requests_are_idempotent_matches, }; const MAX_LIVE_REQUEST_BODY_BYTES: usize = DEFAULT_PROJECT_HISTORY_BYTE_LIMIT; @@ -143,6 +146,10 @@ impl AnalysisRunLiveService { let (header_block, body) = split_request_with_limit(request, MAX_LIVE_REQUEST_BODY_BYTES)?; let mut lines = header_block.split("\r\n"); let (method, path) = parse_request_line(lines.next().unwrap_or(""))?; + let headers = parse_headers(&mut lines)?; + if method == "GET" { + return self.list_project_histories(path, &headers, body); + } if method != "POST" || (path != NARUON_ANALYSIS_RUN_PATH && path != TEMPORAL_CONTEXT_PATH @@ -150,7 +157,6 @@ impl AnalysisRunLiveService { { return Err(ApiError::InvalidWirePayload); } - let headers = parse_headers(&mut lines)?; let consumer = require_headers( &headers, self.bound_addr, @@ -235,6 +241,46 @@ impl AnalysisRunLiveService { Ok(json_response(200, "OK", response_body)) } + fn list_project_histories( + &self, + path: &str, + headers: &HashMap, + body: &str, + ) -> Result { + if !is_project_history_collection_path(path) { + return Err(ApiError::InvalidWirePayload); + } + if !body.is_empty() { + return Err(ApiError::InvalidWirePayload); + } + let consumer = require_headers(headers, self.bound_addr, false)?; + if consumer != LINEAGEWEAVE_CONSUMER_CODE { + return Err(ApiError::InvalidWirePayload); + } + let limit = parse_project_history_collection_page_limit( + headers.get("tepp-page-limit").map(String::as_str), + )?; + let cursor = parse_project_history_collection_page_cursor( + headers.get("tepp-page-cursor").map(String::as_str), + )?; + let items = self + .accepted_project_histories + .values() + .map(|(request, projection)| { + ProjectHistoryCollectionItem::new( + request.project_key.clone(), + request.idempotency_key.clone(), + projection.knowledge_cutoff.clone(), + projection.inference_status.clone(), + ) + }) + .collect::, _>>()?; + let (page, next_cursor) = + page_project_history_collection_items(items, cursor.as_deref(), limit); + let collection = ProjectHistoryCollection::new(page, next_cursor)?; + Ok(json_response(200, "OK", collection.to_json()?)) + } + fn response_from_error(&mut self, error: ApiError) -> NaruonLiveResponse { let request_id = format!("analysis-run-live-{}", self.next_request_serial); self.next_request_serial += 1; @@ -319,7 +365,9 @@ mod tests { ANALYSIS_RUN_CONTRACT_VERSION, AnalysisRunRequest, ApiError, DEFAULT_ANALYSIS_RUN_BYTE_LIMIT, ErrorEnvelope, LINEAGEWEAVE_CONSUMER_CODE, NARUON_ANALYSIS_RUN_PATH, NARUON_CONSUMER_CODE, NARUON_LIVE_HEADER_BYTE_LIMIT, - NARUON_LIVE_HEADER_COUNT_LIMIT, NARUON_LIVE_IO_TIMEOUT, TEMPORAL_CONTEXT_PATH, + NARUON_LIVE_HEADER_COUNT_LIMIT, NARUON_LIVE_IO_TIMEOUT, PROJECT_HISTORY_CONTRACT_VERSION, + PROJECT_HISTORY_PATH, ProjectHistoryCollection, ProjectHistoryEvent, ProjectHistoryRequest, + TEMPORAL_CONTEXT_PATH, }; fn sample_run() -> AnalysisRunRequest { @@ -938,6 +986,93 @@ mod tests { ); } + fn sample_project_history(idempotency_key: &str, project_key: &str) -> ProjectHistoryRequest { + ProjectHistoryRequest { + contract_version: PROJECT_HISTORY_CONTRACT_VERSION, + idempotency_key: idempotency_key.into(), + tenant_workspace_id: "history-tenant".into(), + project_key: project_key.into(), + project_name: "Project".into(), + knowledge_cutoff: "2026-08-19T23:59:59Z".into(), + focus_event_id: "focus".into(), + events: vec![ProjectHistoryEvent { + event_id: "focus".into(), + event_type_code: "voc_received".into(), + event_title: "VOC".into(), + occurred_at: "2026-08-19T09:00:00Z".into(), + available_at: "2026-08-19T10:00:00Z".into(), + source_post_id: "post".into(), + evidence_text: "explicit evidence".into(), + actor_ids: Vec::new(), + }], + } + } + + fn project_history_post(request: &ProjectHistoryRequest) -> String { + let body = request.to_json().expect("history json"); + format!( + "POST {PROJECT_HISTORY_PATH} HTTP/1.1\r\nHost: 127.0.0.1\r\ncontent-type: application/json\r\ntepp-consumer: {LINEAGEWEAVE_CONSUMER_CODE}\r\ntepp-contract-version: 1\r\nidempotency-key: {}\r\ncontent-length: {}\r\n\r\n{body}", + request.idempotency_key, + body.len() + ) + } + + #[test] + fn project_history_collection_get_is_metric_free_and_fail_closed() { + let mut service = AnalysisRunLiveService::new(); + let first = sample_project_history("idem-a", "project-a"); + let second = sample_project_history("idem-b", "project-b"); + assert_eq!( + service + .handle_http_request(&project_history_post(&first)) + .status_code, + 200 + ); + assert_eq!( + service + .handle_http_request(&project_history_post(&second)) + .status_code, + 200 + ); + + let list = format!( + "GET {PROJECT_HISTORY_PATH} HTTP/1.1\r\nHost: 127.0.0.1\r\ncontent-type: application/json\r\ntepp-consumer: {LINEAGEWEAVE_CONSUMER_CODE}\r\ntepp-contract-version: 1\r\ncontent-length: 0\r\n\r\n" + ); + let got = service.handle_http_request(&list); + assert_eq!(got.status_code, 200); + let page = ProjectHistoryCollection::from_json(&got.body).expect("page"); + assert_eq!(page.histories.len(), 2); + assert_eq!(page.histories[0].idempotency_key, "idem-a"); + assert_eq!(page.histories[1].project_key, "project-b"); + assert!(!got.body.contains("rmse")); + assert!(!got.body.contains("tepp.scientific_acceptance.v1")); + assert!(!got.body.contains("evidence_text")); + assert!(!got.body.contains("findings")); + assert!(!got.body.contains("causal_score")); + + let limited = format!( + "GET {PROJECT_HISTORY_PATH} HTTP/1.1\r\nHost: 127.0.0.1\r\ncontent-type: application/json\r\ntepp-consumer: {LINEAGEWEAVE_CONSUMER_CODE}\r\ntepp-contract-version: 1\r\ntepp-page-limit: 1\r\ncontent-length: 0\r\n\r\n" + ); + let limited_got = service.handle_http_request(&limited); + let limited_page = + ProjectHistoryCollection::from_json(&limited_got.body).expect("limited page"); + assert_eq!(limited_page.histories.len(), 1); + assert_eq!(limited_page.next_cursor.as_deref(), Some("idem-a")); + + let analysis_get = format!( + "GET {NARUON_ANALYSIS_RUN_PATH} HTTP/1.1\r\nHost: 127.0.0.1\r\ncontent-type: application/json\r\ntepp-consumer: {LINEAGEWEAVE_CONSUMER_CODE}\r\ntepp-contract-version: 1\r\ncontent-length: 0\r\n\r\n" + ); + assert_eq!(service.handle_http_request(&analysis_get).status_code, 400); + let naruon_list = format!( + "GET {PROJECT_HISTORY_PATH} HTTP/1.1\r\nHost: 127.0.0.1\r\ncontent-type: application/json\r\ntepp-consumer: {NARUON_CONSUMER_CODE}\r\ntepp-contract-version: 1\r\ncontent-length: 0\r\n\r\n" + ); + assert_eq!(service.handle_http_request(&naruon_list).status_code, 400); + let nonempty = format!( + "GET {PROJECT_HISTORY_PATH} HTTP/1.1\r\nHost: 127.0.0.1\r\ncontent-type: application/json\r\ntepp-consumer: {LINEAGEWEAVE_CONSUMER_CODE}\r\ntepp-contract-version: 1\r\ncontent-length: 2\r\n\r\n{{}}" + ); + assert_eq!(service.handle_http_request(&nonempty).status_code, 400); + } + struct ScriptedRead { reader: Cursor>, first_error: Option, diff --git a/crates/tepp_api/src/lib.rs b/crates/tepp_api/src/lib.rs index 876703ebc..32b5c6b48 100644 --- a/crates/tepp_api/src/lib.rs +++ b/crates/tepp_api/src/lib.rs @@ -28,6 +28,7 @@ mod naruon_http; mod naruon_live; mod orchestration; mod project_history; +mod project_history_collection_http; mod project_journey; mod provider_payload; mod temporal_context; @@ -230,6 +231,30 @@ pub use project_history::ProjectHistoryProjection; pub use project_history::ProjectHistoryRequest; /// Build a cutoff-safe project-history projection. pub use project_history::project_history_projection; +/// Maximum opaque cursor length on project-history collection GET. +pub use project_history_collection_http::PROJECT_HISTORY_COLLECTION_CURSOR_MAX_LEN; +/// Default page size for project-history collection GET. +pub use project_history_collection_http::PROJECT_HISTORY_COLLECTION_DEFAULT_LIMIT; +/// Fixed non-causal inference status on collection rows. +pub use project_history_collection_http::PROJECT_HISTORY_COLLECTION_INFERENCE_STATUS; +/// Maximum page size for project-history collection GET. +pub use project_history_collection_http::PROJECT_HISTORY_COLLECTION_MAX_LIMIT; +/// Metric-free project-history collection page. +pub use project_history_collection_http::ProjectHistoryCollection; +/// One metric-free project-history collection row. +pub use project_history_collection_http::ProjectHistoryCollectionItem; +/// Whether a path is the project-history collection resource. +pub use project_history_collection_http::is_project_history_collection_path; +/// `LineageWeave` GET exchange for project-history collection. +pub use project_history_collection_http::lineageweave_project_history_collection_exchange; +/// Page stored project-history collection rows. +pub use project_history_collection_http::page_project_history_collection_items; +/// Parse the exclusive project-history collection cursor header. +pub use project_history_collection_http::parse_project_history_collection_page_cursor; +/// Parse the project-history collection page-limit header. +pub use project_history_collection_http::parse_project_history_collection_page_limit; +/// Refuse metric, evidence, and causal-score keys on collection JSON. +pub use project_history_collection_http::refuse_metrics_on_project_history_collection_payload; /// Maximum posterior Project Journey artifact size. pub use project_journey::DEFAULT_PROJECT_JOURNEY_BYTE_LIMIT; /// Exact posterior Project Journey schema identity. diff --git a/crates/tepp_api/src/project_history_collection_http.rs b/crates/tepp_api/src/project_history_collection_http.rs new file mode 100644 index 000000000..13efec2bf --- /dev/null +++ b/crates/tepp_api/src/project_history_collection_http.rs @@ -0,0 +1,557 @@ +//! Provider-owned project-history collection GET contracts. +//! +//! GAP-003A unique slice: `GET /v1/project-histories` enumerates accepted +//! cutoff-safe project-history projections on `AnalysisRunLiveService` / +//! `tepp-loopback` so operators do not guess idempotency keys. Collection +//! bodies stay metric-free and identity-opaque. `tepp.scientific_acceptance.v1` +//! never appears. The page does not include evidence text, findings, or a +//! causal score. This module does not duplicate project-history CLI (#420), +//! temporal-context CLI (#414), export CLI (#410), export-retrieval GET (#411), +//! analysis-run collection GET (#368), GET-by-id (#359), or GAP-010 +//! Figma/export. Persistence remains GAP-003B. + +use crate::naruon_http::{NaruonHttpExchange, compose_https_target}; +use crate::wire::{ + from_json, require_byte_limit, require_contract_version, require_nonempty, to_json, +}; +use crate::{ApiError, DEFAULT_PROJECT_HISTORY_BYTE_LIMIT, PROJECT_HISTORY_PATH}; +use serde::{Deserialize, Serialize}; + +/// Supported project-history collection contract version. +pub const PROJECT_HISTORY_COLLECTION_CONTRACT_VERSION: u16 = 1; + +/// Default page size for loopback project-history collection GET. +pub const PROJECT_HISTORY_COLLECTION_DEFAULT_LIMIT: usize = 32; + +/// Maximum page size accepted on loopback project-history collection GET. +pub const PROJECT_HISTORY_COLLECTION_MAX_LIMIT: usize = 64; + +/// Maximum opaque cursor / idempotency-key length on the collection path. +pub const PROJECT_HISTORY_COLLECTION_CURSOR_MAX_LEN: usize = 128; + +/// Fixed non-causal claim boundary echoed on every collection row. +pub const PROJECT_HISTORY_COLLECTION_INFERENCE_STATUS: &str = "temporal_association_only"; + +const FORBIDDEN_COLLECTION_KEYS: [&str; 16] = [ + "rmse", + "rmse_standard_error", + "mean_bias", + "bias_standard_error", + "interval_coverage", + "coverage_wilson_lower", + "coverage_wilson_upper", + "temporal_order_accuracy", + "se_gate_accepted", + "se_gate_k", + "scientific_acceptance", + "report", + "terminal_result", + "evidence_text", + "findings", + "causal_score", +]; + +/// One metric-free collection row for an accepted project-history projection. +/// +/// The row names the durable project key and idempotency identity. It never +/// carries evidence text, findings, or scientific-acceptance artifacts. +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] +#[serde(deny_unknown_fields)] +pub struct ProjectHistoryCollectionItem { + /// Consumer-owned stable project key. + pub project_key: String, + /// Exact request idempotency key that minted the stored projection. + pub idempotency_key: String, + /// Knowledge cutoff applied to the stored projection. + pub knowledge_cutoff: String, + /// Fixed claim boundary: sequence is association, not causation. + pub inference_status: String, +} + +impl ProjectHistoryCollectionItem { + /// Construct a validated metric-free collection row. + /// + /// # Errors + /// + /// Returns a fail-closed error for empty identities, an oversized + /// idempotency key, or a causal inference status. + pub fn new( + project_key: impl Into, + idempotency_key: impl Into, + knowledge_cutoff: impl Into, + inference_status: impl Into, + ) -> Result { + let item = Self { + project_key: project_key.into(), + idempotency_key: idempotency_key.into(), + knowledge_cutoff: knowledge_cutoff.into(), + inference_status: inference_status.into(), + }; + item.validate()?; + Ok(item) + } + + fn validate(&self) -> Result<(), ApiError> { + require_nonempty(&self.project_key)?; + require_nonempty(&self.idempotency_key)?; + require_nonempty(&self.knowledge_cutoff)?; + if self.idempotency_key.len() > PROJECT_HISTORY_COLLECTION_CURSOR_MAX_LEN { + return Err(ApiError::LimitExceeded); + } + if self.inference_status != PROJECT_HISTORY_COLLECTION_INFERENCE_STATUS { + return Err(ApiError::InvalidWirePayload); + } + Ok(()) + } +} + +/// Versioned metric-free project-history collection page. +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] +#[serde(deny_unknown_fields)] +pub struct ProjectHistoryCollection { + /// Semantic contract version for this payload family. + pub contract_version: u16, + /// Bounded page of metric-free rows, sorted by `idempotency_key`. + pub histories: Vec, + /// Exclusive cursor for the next page when more rows remain. + #[serde(skip_serializing_if = "Option::is_none")] + pub next_cursor: Option, +} + +impl ProjectHistoryCollection { + /// Construct a validated collection page. + /// + /// # Errors + /// + /// Returns a fail-closed error when a row is invalid, the page exceeds the + /// maximum limit, or `next_cursor` is empty or oversized. + pub fn new( + histories: Vec, + next_cursor: Option, + ) -> Result { + let collection = Self { + contract_version: PROJECT_HISTORY_COLLECTION_CONTRACT_VERSION, + histories, + next_cursor, + }; + collection.validate()?; + Ok(collection) + } + + /// Parse and validate a collection payload with the default byte limit. + /// + /// # Errors + /// + /// Returns wire, version, limit, metric-key, or field-validation errors. + pub fn from_json(payload: &str) -> Result { + Self::from_json_with_limit(payload, DEFAULT_PROJECT_HISTORY_BYTE_LIMIT) + } + + /// Parse and validate a collection payload with a caller-supplied limit. + /// + /// # Errors + /// + /// Returns wire, version, limit, metric-key, or field-validation errors. + pub fn from_json_with_limit(payload: &str, maximum_bytes: usize) -> Result { + require_byte_limit(payload, maximum_bytes)?; + refuse_metrics_on_project_history_collection_payload(payload)?; + let collection: Self = from_json(payload)?; + collection.validate()?; + Ok(collection) + } + + /// Serialize this collection after complete validation. + /// + /// # Errors + /// + /// Returns validation or serialization errors. + pub fn to_json(&self) -> Result { + self.validate()?; + let payload = to_json(self)?; + require_byte_limit(&payload, DEFAULT_PROJECT_HISTORY_BYTE_LIMIT)?; + refuse_metrics_on_project_history_collection_payload(&payload)?; + Ok(payload) + } + + fn validate(&self) -> Result<(), ApiError> { + require_contract_version( + self.contract_version, + PROJECT_HISTORY_COLLECTION_CONTRACT_VERSION, + )?; + if self.histories.len() > PROJECT_HISTORY_COLLECTION_MAX_LIMIT { + return Err(ApiError::LimitExceeded); + } + for item in &self.histories { + item.validate()?; + } + if let Some(cursor) = &self.next_cursor { + require_nonempty(cursor)?; + if cursor.len() > PROJECT_HISTORY_COLLECTION_CURSOR_MAX_LEN { + return Err(ApiError::LimitExceeded); + } + } + Ok(()) + } +} + +/// Refuse collection JSON that already carries scientific-metric or evidence keys. +/// +/// Empty payloads fail closed as valid request bodies. Non-object JSON fails +/// closed as invalid wire when nonempty. +/// +/// # Errors +/// +/// Returns [`ApiError::InvalidWirePayload`] when a forbidden metric, evidence, +/// or causal-score key is present. +pub fn refuse_metrics_on_project_history_collection_payload(payload: &str) -> Result<(), ApiError> { + if payload.trim().is_empty() { + return Ok(()); + } + if payload.contains("tepp.scientific_acceptance.v1") { + return Err(ApiError::InvalidWirePayload); + } + let value: serde_json::Value = + serde_json::from_str(payload).map_err(|_| ApiError::InvalidWirePayload)?; + refuse_metrics_on_json(&value) +} + +fn refuse_metrics_on_json(value: &serde_json::Value) -> Result<(), ApiError> { + match value { + serde_json::Value::Object(object) => { + if FORBIDDEN_COLLECTION_KEYS + .iter() + .any(|key| object.contains_key(*key)) + { + return Err(ApiError::InvalidWirePayload); + } + for nested in object.values() { + refuse_metrics_on_json(nested)?; + } + Ok(()) + } + serde_json::Value::Array(items) => { + for nested in items { + refuse_metrics_on_json(nested)?; + } + Ok(()) + } + _ => Ok(()), + } +} + +/// Parse the optional `tepp-page-limit` header. +/// +/// Absent header uses [`PROJECT_HISTORY_COLLECTION_DEFAULT_LIMIT`]. Zero, a +/// non-integer, or a value above [`PROJECT_HISTORY_COLLECTION_MAX_LIMIT`] fail +/// closed. +/// +/// # Errors +/// +/// Returns [`ApiError::InvalidWirePayload`] for a non-integer and +/// [`ApiError::LimitExceeded`] when the requested page is larger than the +/// maximum. +pub fn parse_project_history_collection_page_limit(raw: Option<&str>) -> Result { + let Some(raw) = raw else { + return Ok(PROJECT_HISTORY_COLLECTION_DEFAULT_LIMIT); + }; + let limit: usize = raw.parse().map_err(|_| ApiError::InvalidWirePayload)?; + if limit == 0 { + return Err(ApiError::InvalidWirePayload); + } + if limit > PROJECT_HISTORY_COLLECTION_MAX_LIMIT { + return Err(ApiError::LimitExceeded); + } + Ok(limit) +} + +/// Parse the optional exclusive `tepp-page-cursor` header. +/// +/// # Errors +/// +/// Returns [`ApiError::InvalidWirePayload`] for an empty cursor and +/// [`ApiError::LimitExceeded`] when the cursor exceeds +/// [`PROJECT_HISTORY_COLLECTION_CURSOR_MAX_LEN`]. +pub fn parse_project_history_collection_page_cursor( + raw: Option<&str>, +) -> Result, ApiError> { + let Some(raw) = raw else { + return Ok(None); + }; + require_nonempty(raw)?; + if raw.len() > PROJECT_HISTORY_COLLECTION_CURSOR_MAX_LEN { + return Err(ApiError::LimitExceeded); + } + Ok(Some(raw.to_owned())) +} + +/// Return whether `path` is exactly the project-history collection resource. +#[must_use] +pub fn is_project_history_collection_path(path: &str) -> bool { + path == PROJECT_HISTORY_PATH +} + +/// Page stored rows after an exclusive cursor, sorted by idempotency key. +#[must_use] +pub fn page_project_history_collection_items( + mut items: Vec, + cursor: Option<&str>, + limit: usize, +) -> (Vec, Option) { + items.sort_by(|left, right| left.idempotency_key.cmp(&right.idempotency_key)); + if let Some(cursor) = cursor { + items.retain(|item| item.idempotency_key.as_str() > cursor); + } + let next_cursor = if items.len() > limit { + Some(items[limit - 1].idempotency_key.clone()) + } else { + None + }; + items.truncate(limit); + (items, next_cursor) +} + +/// Build a provider-owned `GET` project-history collection exchange. +/// +/// The builder refuses non-`https` origins and does not inject credentials. +/// Loopback pagination uses `tepp-page-cursor` and `tepp-page-limit` headers +/// because the shared request-line parser fails closed on query strings. +/// +/// # Errors +/// +/// Returns [`ApiError::InvalidWirePayload`] for a non-`https` origin or an +/// empty cursor, and [`ApiError::LimitExceeded`] when limit or cursor bounds +/// are exceeded. +pub fn lineageweave_project_history_collection_exchange( + origin: &str, + cursor: Option<&str>, + limit: Option<&str>, +) -> Result { + let _ = parse_project_history_collection_page_limit(limit)?; + let _ = parse_project_history_collection_page_cursor(cursor)?; + let target_url = compose_https_target(origin, PROJECT_HISTORY_PATH)?; + let mut headers = vec![ + ("content-type".into(), "application/json".into()), + ("tepp-consumer".into(), "lineageweave".into()), + ("tepp-contract-version".into(), "1".into()), + ]; + if let Some(cursor) = cursor { + headers.push(("tepp-page-cursor".into(), cursor.to_owned())); + } + if let Some(limit) = limit { + headers.push(("tepp-page-limit".into(), limit.to_owned())); + } + Ok(NaruonHttpExchange { + method: "GET", + target_url, + headers, + body: String::new(), + }) +} + +#[cfg(test)] +mod tests { + use super::{ + PROJECT_HISTORY_COLLECTION_CURSOR_MAX_LEN, PROJECT_HISTORY_COLLECTION_INFERENCE_STATUS, + PROJECT_HISTORY_COLLECTION_MAX_LIMIT, ProjectHistoryCollection, + ProjectHistoryCollectionItem, is_project_history_collection_path, + lineageweave_project_history_collection_exchange, page_project_history_collection_items, + parse_project_history_collection_page_cursor, parse_project_history_collection_page_limit, + refuse_metrics_on_project_history_collection_payload, + }; + use crate::ApiError; + + fn sample_item() -> ProjectHistoryCollectionItem { + ProjectHistoryCollectionItem::new( + "project", + "idem-1", + "2026-08-19T23:59:59Z", + PROJECT_HISTORY_COLLECTION_INFERENCE_STATUS, + ) + .expect("item") + } + + #[test] + fn collection_round_trips_and_refuses_hostile_shapes() { + let collection = ProjectHistoryCollection::new(vec![sample_item()], None).expect("page"); + let json = collection.to_json().expect("json"); + assert_eq!( + ProjectHistoryCollection::from_json(&json).expect("decode"), + collection + ); + assert!(!json.contains("rmse")); + assert!(!json.contains("scientific_acceptance")); + assert!(!json.contains("evidence_text")); + assert!(!json.contains("findings")); + assert!(!json.contains("next_cursor")); + assert!(!json.contains("causal_score")); + + assert_eq!( + ProjectHistoryCollectionItem::new( + "", + "idem-1", + "2026-08-19T23:59:59Z", + PROJECT_HISTORY_COLLECTION_INFERENCE_STATUS + ), + Err(ApiError::InvalidWirePayload) + ); + assert_eq!( + ProjectHistoryCollectionItem::new( + "project", + "", + "2026-08-19T23:59:59Z", + PROJECT_HISTORY_COLLECTION_INFERENCE_STATUS + ), + Err(ApiError::InvalidWirePayload) + ); + assert_eq!( + ProjectHistoryCollectionItem::new( + "project", + "idem-1", + "2026-08-19T23:59:59Z", + "causal_score" + ), + Err(ApiError::InvalidWirePayload) + ); + assert_eq!( + ProjectHistoryCollectionItem::new( + "project", + "a".repeat(PROJECT_HISTORY_COLLECTION_CURSOR_MAX_LEN + 1), + "2026-08-19T23:59:59Z", + PROJECT_HISTORY_COLLECTION_INFERENCE_STATUS, + ), + Err(ApiError::LimitExceeded) + ); + + let mut unsupported = collection.clone(); + unsupported.contract_version = 9; + assert_eq!( + unsupported.to_json(), + Err(ApiError::UnsupportedContractVersion) + ); + assert_eq!( + ProjectHistoryCollection::from_json(r#"{"contract_version":9,"histories":[]}"#), + Err(ApiError::UnsupportedContractVersion) + ); + assert_eq!( + ProjectHistoryCollection::from_json( + r#"{"contract_version":1,"histories":[],"extra":true}"# + ), + Err(ApiError::InvalidWirePayload) + ); + assert_eq!( + ProjectHistoryCollection::from_json_with_limit(&json, 8), + Err(ApiError::LimitExceeded) + ); + assert_eq!( + ProjectHistoryCollection::from_json("[1,2,3]"), + Err(ApiError::InvalidWirePayload) + ); + assert_eq!( + ProjectHistoryCollection::new(vec![sample_item()], Some(String::new())), + Err(ApiError::InvalidWirePayload) + ); + let oversized = vec![sample_item(); PROJECT_HISTORY_COLLECTION_MAX_LIMIT + 1]; + assert_eq!( + ProjectHistoryCollection::new(oversized, None), + Err(ApiError::LimitExceeded) + ); + } + + #[test] + fn collection_payloads_refuse_scientific_metric_and_evidence_keys() { + assert_eq!( + refuse_metrics_on_project_history_collection_payload(""), + Ok(()) + ); + assert_eq!( + refuse_metrics_on_project_history_collection_payload(r#"{"histories":[]}"#), + Ok(()) + ); + assert_eq!( + refuse_metrics_on_project_history_collection_payload(r#"{"rmse":1.0}"#), + Err(ApiError::InvalidWirePayload) + ); + assert_eq!( + refuse_metrics_on_project_history_collection_payload( + r#"{"histories":[{"evidence_text":"secret"}]}"# + ), + Err(ApiError::InvalidWirePayload) + ); + assert_eq!( + refuse_metrics_on_project_history_collection_payload(r#"{"causal_score":1}"#), + Err(ApiError::InvalidWirePayload) + ); + assert_eq!( + refuse_metrics_on_project_history_collection_payload( + r#"{"schema_version":"tepp.scientific_acceptance.v1"}"# + ), + Err(ApiError::InvalidWirePayload) + ); + assert!( + ProjectHistoryCollection::from_json( + r#"{"contract_version":1,"histories":[],"scientific_acceptance":true}"# + ) + .is_err() + ); + } + + #[test] + fn pagination_and_exchange_fail_closed() { + assert_eq!( + parse_project_history_collection_page_limit(None).expect("default"), + 32 + ); + assert_eq!( + parse_project_history_collection_page_limit(Some("0")), + Err(ApiError::InvalidWirePayload) + ); + assert_eq!( + parse_project_history_collection_page_limit(Some("65")), + Err(ApiError::LimitExceeded) + ); + assert_eq!( + parse_project_history_collection_page_cursor(Some("")), + Err(ApiError::InvalidWirePayload) + ); + assert!(is_project_history_collection_path("/v1/project-histories")); + assert!(!is_project_history_collection_path("/v1/analysis-runs")); + assert!(!is_project_history_collection_path("/v1/temporal-context")); + + let first = sample_item(); + let second = ProjectHistoryCollectionItem::new( + "project-b", + "idem-2", + "2026-08-19T23:59:59Z", + PROJECT_HISTORY_COLLECTION_INFERENCE_STATUS, + ) + .expect("second"); + let (page, cursor) = + page_project_history_collection_items(vec![second.clone(), first.clone()], None, 1); + assert_eq!(page, vec![first.clone()]); + assert_eq!(cursor.as_deref(), Some("idem-1")); + let (rest, done) = + page_project_history_collection_items(vec![second.clone(), first], Some("idem-1"), 32); + assert_eq!(rest, vec![second]); + assert_eq!(done, None); + + let exchange = lineageweave_project_history_collection_exchange( + "https://tepp.example.test", + Some("idem-1"), + Some("8"), + ) + .expect("exchange"); + assert_eq!(exchange.method, "GET"); + assert!(exchange.target_url.ends_with("/v1/project-histories")); + assert!( + !exchange + .headers + .iter() + .any(|(name, _)| name.eq_ignore_ascii_case("authorization")) + ); + assert!(exchange.body.is_empty()); + assert_eq!( + lineageweave_project_history_collection_exchange("http://insecure.example", None, None), + Err(ApiError::InvalidWirePayload) + ); + } +} diff --git a/crates/tepp_api/tests/project_history_collection_http_contract.rs b/crates/tepp_api/tests/project_history_collection_http_contract.rs new file mode 100644 index 000000000..00e0a1df4 --- /dev/null +++ b/crates/tepp_api/tests/project_history_collection_http_contract.rs @@ -0,0 +1,53 @@ +//! Contract tests for loopback `GET /v1/project-histories`. + +use tepp_api::{ + ApiError, PROJECT_HISTORY_PATH, ProjectHistoryCollection, ProjectHistoryCollectionItem, + is_project_history_collection_path, lineageweave_project_history_collection_exchange, + refuse_metrics_on_project_history_collection_payload, +}; + +#[test] +fn project_history_collection_is_metric_free_get_without_credentials() { + assert!(is_project_history_collection_path(PROJECT_HISTORY_PATH)); + let item = ProjectHistoryCollectionItem::new( + "project", + "idem-1", + "2026-08-19T23:59:59Z", + "temporal_association_only", + ) + .expect("item"); + let page = ProjectHistoryCollection::new(vec![item], None).expect("page"); + let json = page.to_json().expect("json"); + assert!(!json.contains("rmse")); + assert!(!json.contains("tepp.scientific_acceptance.v1")); + assert!(!json.contains("evidence_text")); + assert!(!json.contains("findings")); + let exchange = + lineageweave_project_history_collection_exchange("https://tepp.example.test", None, None) + .expect("exchange"); + assert_eq!(exchange.method, "GET"); + assert!(exchange.target_url.ends_with("/v1/project-histories")); + assert!( + !exchange + .headers + .iter() + .any(|(name, _)| name.eq_ignore_ascii_case("authorization")) + ); +} + +#[test] +fn project_history_collection_refuses_metrics_evidence_and_insecure_origins() { + assert_eq!( + refuse_metrics_on_project_history_collection_payload(r#"{"rmse":1.0}"#), + Err(ApiError::InvalidWirePayload) + ); + assert_eq!( + refuse_metrics_on_project_history_collection_payload(r#"{"evidence_text":"x"}"#), + Err(ApiError::InvalidWirePayload) + ); + assert_eq!( + lineageweave_project_history_collection_exchange("http://insecure.example", None, None), + Err(ApiError::InvalidWirePayload) + ); + assert!(!is_project_history_collection_path("/v1/analysis-runs")); +} diff --git a/docs/API_CONTRACT.md b/docs/API_CONTRACT.md index b76b688e1..0cdadec28 100644 --- a/docs/API_CONTRACT.md +++ b/docs/API_CONTRACT.md @@ -69,6 +69,7 @@ GET /v1/analysis-runs/{run_id} POST /v1/analysis-runs/{run_id}/cancel GET /v1/model-artifacts/{artifact_id} GET /v1/exports/{export_id} +GET /v1/project-histories ``` Long-running analysis is durable asynchronous work. `POST /v1/analysis-runs` accepts an idempotency key, immutable input snapshot identity, knowledge cutoff, versioned model contract/configuration, and requested output profile. A retry with the same principal/idempotency key and semantically identical request returns the same run identity; a conflicting body fails closed. @@ -91,6 +92,12 @@ them by event time and opaque event ID, and emits adjacent forward temporal associations plus `candidate_not_causal` transition gaps. It does not infer causality, mutate TEPP state, or return a completed psychometric result. +`GET /v1/project-histories` enumerates accepted cutoff-safe project-history +projections on `tepp-loopback`. Collection rows stay metric-free identities +(`project_key`, `idempotency_key`, `knowledge_cutoff`, +`inference_status=temporal_association_only`). `tepp.scientific_acceptance.v1`, +evidence text, findings, and causal scores never appear. + The typed status/read contract returns `accepted`, `running`, `succeeded`, or `failed`. Accepted and running statuses contain no measurement result. A terminal status contains exactly one request-bound diff --git a/docs/TRACEABILITY.md b/docs/TRACEABILITY.md index 2b783c2ab..fffa48453 100644 --- a/docs/TRACEABILITY.md +++ b/docs/TRACEABILITY.md @@ -53,6 +53,7 @@ The full APA 7th standards/literature register remains `docs/research/standards- | 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 session-affine `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 (#44 implemented-main), `revision_order` later-revision system-time ordering implemented-main, entity/project target SQL on PR #131; remaining physical ERD constraints | partial | | known-truth temporal/event simulation manifests | PRD; TRD; Test Strategy | `tepp_simulation` on protected main; recovery metrics in `validation_core` | implemented-main | | versioned service/API contracts and exports | PRD; API contract; ADR 0011/0013 | `tepp_api` analysis-run/export/JSON-LD/GraphML contracts on protected main (PR #21); request-bound terminal result active in PR #157; HTTP service remains accepted-target; the `orchestrator_live` loopback interpretation listener is on this PR | partial | +| loopback LineageWeave project-history collection GET | ADR 0028; API contract; RFC 9110; ADR 0021/0011 | `tepp_api` `GET /v1/project-histories` on `tepp-loopback`; metric-free `temporal_association_only` identities; `tepp.scientific_acceptance.v1` never appears; does not infer causality | active-PR | | executable cutoff-safe analysis-run readiness | ADR 0021; temporal research; API terminal-result contract | stacked `analysis_engine` PR on #157: availability cutoff, snapshot binding, multiple-membership aggregation, digest-bound artifact, realistic end-to-end tests | active-PR | | delayed-reporting cutoff eligibility in truth corpora | ADR 0002; research | `tepp_simulation` eligible-at-cutoff filter on the active PR | active-PR | | versioned service/API contracts and exports | PRD; API contract; ADR 0011/0013 | `tepp_api` analysis-run/export/JSON-LD/GraphML contracts on protected main (PR #21); HTTP service remaining accepted-target | partial | diff --git a/docs/adr/0028-project-history-collection-get.md b/docs/adr/0028-project-history-collection-get.md new file mode 100644 index 000000000..770886a4d --- /dev/null +++ b/docs/adr/0028-project-history-collection-get.md @@ -0,0 +1,68 @@ +# ADR 0028 — LineageWeave project-history collection GET + +**Decision status:** Accepted +**Implementation maturity:** active-PR +**Date:** 2026-08-31 +**Supersedes:** None; complements ADR 0021 and ADR 0011 for the operator-visible project-history collection. Does not supersede ADR 0014 claim-promotion authority. This ADR number is unique on protected main; other live PRs may reuse 0028 on unrelated GAP-003A stacks (lifecycle POST). + +## Context + +Protected main already stores accepted project-history projections on `AnalysisRunLiveService` after `POST /v1/project-histories`, and #420 publishes a POST CLI. Operators still cannot enumerate stored projections without guessing idempotency keys. Duplicating analysis-run collection GET (#368), GET-by-id (#359), project-history CLI (#420), temporal-context CLI (#414), export CLI (#410), export-retrieval GET (#411), Leiden, Driver p.16, or GAP-010 Figma/export would collide with live PRs. + +## Decision + +`tepp_api` publishes loopback-only `GET /v1/project-histories` on `tepp-loopback`: + +- Consumer is `lineageweave` only. Empty body. Pagination uses `tepp-page-limit` and exclusive `tepp-page-cursor` headers because the request-line parser fails closed on query strings. +- Collection rows are metric-free identities: `project_key`, `idempotency_key`, `knowledge_cutoff`, `inference_status=temporal_association_only`. +- `tepp.scientific_acceptance.v1`, RMSE, bias, coverage, SE-gate, `evidence_text`, `findings`, and `causal_score` never appear. +- The collection does not infer causality, mutate TEPP state, or return a completed psychometric result. +- GET `/v1/analysis-runs` and GET `/v1/temporal-context` stay fail-closed on this slice. +- This slice does not implement project-history collection CLI, GET-by-id, or persistence. + +## Alternatives considered + +1. **Keep POST replay as the only retrieval path** — rejected because operators still guess idempotency keys. +2. **Reuse analysis-run collection GET (#368)** — rejected; that slice is a different live PR and a different resource. +3. **Return evidence text and findings on the list** — rejected because collection bodies must stay metric-free and identity-opaque. +4. **Loopback `GET /v1/project-histories`** — accepted. + +## Consequences + +- Operators can enumerate accepted project-history projections without writing a second POST. +- Collection stdout cannot be mistaken for a succeeded scientific-acceptance result or a causal score. +- Collection success is not release evidence and is not an ADR 0014 claim. + +## Failure and recovery + +Non-`lineageweave` consumers, nonempty GET bodies, zero/oversized page limits, empty cursors, credential flags, and metric keys fail closed. The in-memory listener is not durable. + +## Security, privacy, scientific-integrity, and governance impact + +- No credential headers cross the consumer boundary. +- Evidence text and findings stay off the collection page. +- Process 200 on collection GET is not measurement evidence and is not a causal claim. + +## Compatibility and migration + +`POST /v1/project-histories`, `POST /v1/temporal-context`, `POST /v1/analysis-runs`, and `tepp-loopback` POST paths are unchanged. Project-history collection CLI remains a later slice. + +## Verification + +Falsifiable evidence: + +- GET of two accepted projections returns a metric-free page sorted by idempotency key with `temporal_association_only` and no RMSE/bias/coverage/SE-gate/`tepp.scientific_acceptance.v1`/`evidence_text`/`findings`/`causal_score` keys; +- GET `/v1/analysis-runs`, naruon consumer, nonempty body, and metric keys fail closed; +- Clippy `-D warnings`, `tepp_api` tests, rustdoc, and exact-head review remain required. + +## Rollback and supersession + +Rollback removes collection GET; POST `/v1/project-histories` remains valid. A superseding ADR is required to persist the registry, bind a public address, emit scientific-acceptance on the list, infer causality, or treat collection success as an ADR 0014 claim. + +## Related authority + +- ADR 0021 owns the LineageWeave project-history service boundary. +- ADR 0002 owns six-clock temporal eligibility. +- ADR 0011 owns standalone/modular HTTP boundaries. +- ADR 0014 owns scientific claim promotion. +- RFC 9110 owns GET semantics (Fielding, Nottingham, & Reschke, 2022). It does not authorize scientific claims. diff --git a/docs/adr/README.md b/docs/adr/README.md index 1254c8079..8e52d8394 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -30,6 +30,7 @@ Read [`ADR_POLICY.md`](ADR_POLICY.md) first. **Decision status and implementatio | [0022](0022-deterministic-analysis-run-execution.md) | Deterministic cutoff-safe analysis-run execution | Accepted | active-PR | Closes the first executable product path from accepted run to digest-bound terminal result without claiming estimator authority. | | [0024](0024-lineage-pair-criterion-and-project-journey-posterior.md) | Independent Event Lineage pair criterion and posterior Project Journey | Proposed | active-PR | Strict artifacts preserve criterion/event-time draws, branches, ties, and CPU/GPU receipts without claiming the scientific estimator is complete. | | [0025](0025-macos-native-rust-mlx-metal-boundary.md) | macOS-native Rust-owned MLX Metal execution | Accepted | accepted-target | Compose authenticates to a native host service; Linux never claims Metal, and actual backend/parity receipts fail closed. | +| [0028](0028-project-history-collection-get.md) | Loopback `GET /v1/project-histories` enumerates accepted LineageWeave projections | Accepted | active-PR | Complements ADR 0021/0011; does not supersede ADR 0014. Unique on protected main. Does not infer causality. | | [0023](0023-lineage-criterion-anchor-contract.md) | TEPP-owned Event Lineage criterion anchor | Accepted | active-PR | PR #237 publishes the strict accepted/rejected artifact and identities; estimator execution remains fail-closed future work. | | [0024](0024-independent-topic-importance-anchor.md) | Posterior topic-context producer contract | Accepted | contract-only active-PR | Strict DTO/schema only; the current estimator does not emit it. fast-mlsirm owns case-deletion influence. | | [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. | @@ -140,6 +141,7 @@ Use the narrowest owning ADR when decisions overlap: - **accepted-run execution and terminal artifact production:** ADR 0022. - **independent lineage criterion and posterior Project Journey:** ADR 0023. - **macOS-native Rust-owned MLX Metal execution:** ADR 0024. +- **LineageWeave project-history collection GET:** ADR 0028. ## Change and supersession rule diff --git a/docs/research/project-history-collection-http.md b/docs/research/project-history-collection-http.md new file mode 100644 index 000000000..7b89626a9 --- /dev/null +++ b/docs/research/project-history-collection-http.md @@ -0,0 +1,55 @@ +# Project-history collection GET (doctoring) + +## Scope + +`GET /v1/project-histories` is the operator-visible collection of accepted +cutoff-safe project-history projections on `AnalysisRunLiveService` / +`tepp-loopback`. HTTP method, path, and header semantics follow current HTTP +semantics (Fielding, Nottingham, & Reschke, 2022). Fail-closed refusal of +unpublished consumers, nonempty GET bodies, review/Copilot/GitHub credential +flags, evidence text, and scientific-authority promotion is repository +contract authority (ADR 0028; ADR 0021; ADR 0011; ADR 0014), not an RFC +inference rule. + +Collection JSON is metric-free. `inference_status` remains +`temporal_association_only`. `tepp.scientific_acceptance.v1` never appears. +A 200 collection page is not a completed temporal model, calibrated score, +theta estimate, uncertainty statement, causal inference, or scientific claim. + +## Authority + +### External standards (HTTP only) + +Fielding, R., Nottingham, M., & Reschke, J. (Eds.). (2022). *HTTP semantics* +(RFC 9110). IETF. https://doi.org/10.17487/RFC9110 + +RFC 9110 §9.3.1 describes GET as a method for retrieving the target resource. +TEPP maps that retrieval onto a bounded, cutoff-safe project-history +collection. The RFC does not define psychometric acceptance, RMSE, causality, +or claim promotion. + +### Internal contract evidence + +- `docs/adr/0028-project-history-collection-get.md` — this collection +- `docs/adr/0021-lineageweave-project-history-boundary.md` — POST boundary +- `docs/adr/0011-standalone-modular-msa-boundary.md` — modular HTTP boundary +- `docs/adr/0014-scientific-claim-promotion-and-release-evidence.md` — HTTP + 200 is not a scientific claim +- `crates/tepp_api/tests/project_history_collection_http_contract.rs` — + fail-closed collection proofs + +## Verification + +- `GET /v1/project-histories` of accepted LineageWeave projections returns + `temporal_association_only` rows without RMSE/bias/coverage/SE-gate keys, + `evidence_text`, `findings`, `causal_score`, or + `tepp.scientific_acceptance.v1`; +- GET `/v1/analysis-runs`, naruon consumer, nonempty body, and unknown verbs + fail closed. + +## Non-claims + +This slice does not implement project-history collection CLI, GET-by-id, +export CLI, analysis-run collection GET, wait CLI, lookup CLI, persistence, +production TLS, Leiden consensus, GAP-010 Figma/export, causal inference, or +an ADR 0014 scientific claim-promotion package.