Cut counterfeit workspace retrieval authority

This commit is contained in:
Meta Vens 2026-07-15 22:26:13 +01:00
commit 2851f68d66
9 changed files with 71 additions and 1997 deletions

View file

@ -25,7 +25,6 @@ mod prompt_context;
mod proposal;
mod repo_model_gateway;
mod repository_body_observer;
mod retrieval;
mod runtime_spine;
mod semantic_backend;
mod semantic_projector_service;
@ -807,16 +806,6 @@ pub use proposal::EpiphanyMapProposalInput;
pub use proposal::propose_map_update;
pub use repo_model_gateway::*;
pub use repository_body_observer::*;
pub use retrieval::EPIPHANY_RETRIEVAL_DEFAULT_LIMIT;
pub use retrieval::EPIPHANY_RETRIEVAL_MAX_LIMIT;
pub use retrieval::EpiphanyRetrieveQuery;
pub use retrieval::EpiphanyRetrieveResponse;
pub use retrieval::EpiphanyRetrieveResult;
pub use retrieval::EpiphanyRetrieveResultKind;
pub use retrieval::index_workspace;
pub use retrieval::normalize_epiphany_retrieve_query;
pub use retrieval::retrieval_state_for_workspace;
pub use retrieval::retrieve_workspace;
pub use runtime_spine::COORDINATOR_RUN_RECEIPT_SCHEMA_VERSION;
pub use runtime_spine::COORDINATOR_RUN_RECEIPT_TYPE;
pub use runtime_spine::EpiphanyCoordinatorRunReceipt;

File diff suppressed because it is too large Load diff

View file

@ -5,7 +5,6 @@
//! rebuildable projection rather than canonical authority.
use anyhow::{Context, Result};
use reqwest::StatusCode;
use reqwest::blocking::{Client, ClientBuilder, Response};
use reqwest::header::{HeaderMap, HeaderValue};
use serde::de::DeserializeOwned;
@ -13,11 +12,6 @@ use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
use std::time::Duration;
pub(crate) const DEFAULT_QDRANT_URL: &str = "http://127.0.0.1:6333";
pub(crate) const DEFAULT_QDRANT_TIMEOUT_MS: u64 = 30_000;
pub(crate) const DEFAULT_OLLAMA_BASE_URL: &str = "http://127.0.0.1:11434";
pub(crate) const DEFAULT_OLLAMA_MODEL: &str = "qwen3-embedding:0.6b";
pub(crate) const DEFAULT_OLLAMA_TIMEOUT_MS: u64 = 30_000;
const POINT_BATCH_SIZE: usize = 128;
const EMBED_BATCH_SIZE: usize = 32;
@ -124,22 +118,6 @@ impl QdrantBackend {
.context("managed Qdrant collection has no compatibility metadata")
}
pub(crate) fn delete_collection(&self, name: &str) -> Result<()> {
let response = self
.client
.delete(format!("{}/collections/{name}", self.base_url))
.query(&[("timeout", self.timeout_seconds)])
.send()
.with_context(|| format!("failed to delete Qdrant collection {name}"))?;
if response.status() == StatusCode::NOT_FOUND {
return Ok(());
}
parse_response::<bool>(response).with_context(|| {
format!("failed to decode Qdrant delete-collection response for {name}")
})?;
Ok(())
}
pub(crate) fn create_collection(
&self,
name: &str,
@ -211,15 +189,6 @@ impl QdrantBackend {
Ok(())
}
pub(crate) fn query_points<P: DeserializeOwned>(
&self,
name: &str,
vector: &[f32],
limit: usize,
) -> Result<Vec<SemanticCandidate<P>>> {
self.query_points_for_scope(name, vector, limit, &[])
}
pub(crate) fn query_points_for_scope<P: DeserializeOwned>(
&self,
name: &str,

View file

@ -139,7 +139,7 @@ fn retrieval_freshness(retrieval: Option<&EpiphanyRetrievalState>) -> EpiphanyRe
let dirty_path_count = retrieval.dirty_paths.len();
let note = match retrieval.status {
EpiphanyRetrievalStatus::Ready if dirty_path_count == 0 => {
"Retrieval catalog is ready.".to_string()
"Legacy retrieval reports Ready, but has no Body-bound coverage receipt.".to_string()
}
EpiphanyRetrievalStatus::Ready => {
format!("Retrieval catalog is stale because {dirty_path_count} dirty path(s) remain.")
@ -154,7 +154,7 @@ fn retrieval_freshness(retrieval: Option<&EpiphanyRetrievalState>) -> EpiphanyRe
EpiphanyRetrievalFreshness {
status: match retrieval.status {
EpiphanyRetrievalStatus::Ready if dirty_path_count == 0 => {
EpiphanyRetrievalFreshnessStatus::Ready
EpiphanyRetrievalFreshnessStatus::Missing
}
EpiphanyRetrievalStatus::Ready => EpiphanyRetrievalFreshnessStatus::Stale,
EpiphanyRetrievalStatus::Stale => EpiphanyRetrievalFreshnessStatus::Stale,
@ -559,6 +559,32 @@ mod tests {
);
}
#[test]
fn legacy_ready_retrieval_cannot_mint_body_coverage() {
let state = EpiphanyThreadState {
retrieval: Some(EpiphanyRetrievalState {
workspace_root: PathBuf::from("E:/repo"),
status: EpiphanyRetrievalStatus::Ready,
semantic_available: true,
dirty_paths: Vec::new(),
..Default::default()
}),
..Default::default()
};
let view = derive_freshness(EpiphanyFreshnessInput {
state: Some(&state),
retrieval_override: None,
watcher: None,
});
assert_eq!(
view.retrieval.status,
EpiphanyRetrievalFreshnessStatus::Missing
);
assert!(view.retrieval.note.contains("Body-bound coverage receipt"));
}
#[test]
fn watcher_maps_changed_paths_to_graph_and_frontier() {
let state = EpiphanyThreadState {

View file

@ -210,7 +210,7 @@ fn index_job(
id: "retrieval-index".to_string(),
kind: EpiphanyJobKind::Indexing,
scope: retrieval.workspace_root.display().to_string(),
owner_role: "epiphany-core".to_string(),
owner_role: "unowned-legacy-projection".to_string(),
authority_scope: None,
runtime_job_id: None,
status: job_status_from_retrieval_status(retrieval.status),
@ -218,8 +218,12 @@ fn index_job(
items_total: None,
progress_note: Some(progress_note),
last_checkpoint_at_unix_seconds: retrieval.last_indexed_at_unix_seconds,
blocking_reason: (retrieval.status == EpiphanyRetrievalStatus::Unavailable).then(|| {
"Indexing requires a readable workspace and configured retrieval backend.".to_string()
blocking_reason: matches!(
retrieval.status,
EpiphanyRetrievalStatus::Ready | EpiphanyRetrievalStatus::Unavailable
)
.then(|| {
"No Body-bound workspace coverage owner is installed; legacy retrieval state cannot authorize readiness.".to_string()
}),
active_thread_ids: Vec::new(),
linked_subgoal_ids,
@ -229,7 +233,7 @@ fn index_job(
fn job_status_from_retrieval_status(status: EpiphanyRetrievalStatus) -> EpiphanyJobStatus {
match status {
EpiphanyRetrievalStatus::Ready => EpiphanyJobStatus::Idle,
EpiphanyRetrievalStatus::Ready => EpiphanyJobStatus::Unavailable,
EpiphanyRetrievalStatus::Stale => EpiphanyJobStatus::Needed,
EpiphanyRetrievalStatus::Indexing => EpiphanyJobStatus::Running,
EpiphanyRetrievalStatus::Unavailable => EpiphanyJobStatus::Unavailable,

View file

@ -835,5 +835,23 @@ replace either Body observation. The lossy JSON workspace manifest remains cache
coverage authority. Semantic-projector Ready remains exact query eligibility for
the admitted RepoModel projection; it does not prove repository Body coverage.
## Counterfeit workspace retrieval organ removed (2026-07-15)
The old `retrieval.rs` module was not wired to any runtime, CLI, scheduler, or
app-server caller. It stored JSON under `CODEX_HOME`, identified files by
path/size/mtime/chunk count, used different filesystem walkers for exact and
semantic search, named Qdrant collections from workspace path plus model, and
could emit `Ready` from a missing manifest or query-time BM25. It had no Body,
runtime, swarm, workspace, policy, content-root, or observed point-set binding.
The module and re-exports are deleted. Legacy `EpiphanyRetrievalState` remains
presentation-only: clean `Ready` projects Missing, and its index job is
unavailable and unowned; dirty/stale data may warn but cannot authorize coverage.
The replacement starts from an authenticated historical Body manifest,
classifies every entry under one versioned inclusion policy, verifies eligible
live bytes against Body hashes, builds a Body-root/policy/index-epoch isolated
Qdrant projection, observes its deterministic point set, and only then publishes
an immutable CultCache coverage receipt. Qdrant remains disposable.
This map must change when ownership changes. Historical scars belong in git,
evidence, or an explicitly archived note—not in the machine's Modeling state.

View file

@ -1689,6 +1689,22 @@ receipts trigger recomputation; they never replace either observation. Build
order is now typed Body-bound retrieval coverage, the Mind-owned race-safe join,
then deletion of local interpretations.
## False workspace retrieval authority cut (2026-07-15)
`retrieval.rs` was production-unwired: no runtime caller, JSON manifest
persistence, path/size/mtime/chunk identity, divergent exact/semantic walkers,
path-derived Qdrant collections, and counterfeit `Ready` from missing manifests
and query-time BM25. The module and public re-exports are deleted. Legacy thread
`EpiphanyRetrievalState` is presentation-only: clean `Ready` projects Missing
and its indexing job is unavailable/unowned; explicit dirty/stale input may warn
but cannot prove coverage. The live RepoModel semantic projector remains intact.
Next build: consume an authenticated historical Body manifest, classify every
entry under one versioned policy, verify eligible bytes against Body hashes,
project into a Body-root/policy/epoch isolated collection, observe the exact
expected point set, and publish an immutable CultCache coverage receipt. Do not
resurrect the JSON manifest as a compatibility source.
The deployment next action is unchanged and permission-bound. Do not reboot
without exact live operator approval. With that approval, run the real
reboot/logon recovery proof already specified above.

Binary file not shown.

View file

@ -2,6 +2,7 @@ experiment:
name: EpiphanyAgent
repository_body_observer: "Native Rust explicitly binds caller workspace ID to an existing validated runtime/swarm/source identity plus canonical Git root/object format/scope/policy. Bind also installs one immutable runtime-side RuntimeRepositoryBodyStoreBinding naming the canonical external Body-store locator and exact Body-binding hash; every read revalidates runtime/swarm/workspace/path/body identity and refuses a second store. Two equal sanitized temporary-index scans enumerate ignore-aware UTF-8 paths, Git modes, and nonrecursive gitlinks with global excludes disabled; raw regular bytes/lengths and non-followed symlink-target bytes are SHA-256 hashed. The domain-separated ordered raw manifest root, not the clean-filtered auxiliary tree OID, is authoritative Body identity. Every Git subprocess strips ambient repository/worktree/object/ref/index/namespace/replacement/graft/shallow and config-injection authority. Observe cannot mint identity. CultCache MessagePack atomically commits immutable manifest+observation and a manifest-root head by exact CAS. Canonical store-path checks precede writes; corrupt HEAD, sparse checkout, unsafe/unrepresentable paths, racing reads, and repo/runtime substitution fail closed. Only accepted stable observations persist; errors advance no head. Unchanged raw manifest preserves generation; status is read-pure. The observer owns bounded current-state identity, makes no historical continuity claim, and has no Ready field. The runtime route is locator authority only, not proof of model grounding."
modeling_body_grounding: "Every coordinator-owned Modeling launch observes and carries one typed RepositoryBodyObservationBasis before worker thought. The immutable launch binds runtime/swarm/workspace/scope, Body-binding hash, observation generation/id/root, and scan interval. Modeling output contract v3 requires the exact worker-authored echo; ingress reloads the immutable launch and rejects missing/swapped basis, while non-Modeling cargo is forbidden. Mind admission review v1 and receipt v5 preserve that basis; admission validates exact launch/result/review equality plus the immutable historical Body artifacts, then copies it into the CAS receipt. Admission never samples current Body as a substitute. Direct Mind plan adoption and legacy migration remain explicitly ungrounded."
workspace_retrieval_coverage: "The production-unwired retrieval.rs oracle was deleted. It wrote JSON under CODEX_HOME, compared path/size/mtime/chunk counts, used incompatible exact/semantic filesystem walkers, named Qdrant collections from workspace path+model, and could emit Ready without a manifest or from query-time BM25; no runtime called it. Legacy EpiphanyRetrievalState is presentation-only: clean Ready now projects Missing and the indexing job is Unavailable/unowned, while explicit stale/dirty input may remain a warning. The replacement must consume an authenticated historical Body manifest, classify every entry under one versioned inclusion policy, verify eligible live bytes against Body hashes, build a Body-root/policy/index-epoch-isolated Qdrant projection, observe its exact point set, and publish an immutable CultCache coverage receipt before any query or Mind readiness join can trust it."
repository_readiness_join: "Mind must own one race-bounded derived repository-readiness operation from exact authenticated authorities: freshly observe Body root R1, validate canonical RepoModel plus exact Mind admission and Body-grounding receipt, authenticated semantic projection eligibility for that admitted model, and workspace retrieval coverage bound to R1 and a named scope policy, then freshly observe R2 and require R2=R1. Its output is observed-ready-at with a truth interval ending at the second scan, not timeless Ready; later reads revalidate. A→B→A is harmless for content-addressed artifacts. Watcher/journal continuity and Hands receipts are invalidation triggers only. Legacy retrieval Ready/empty dirty paths, timestamps, watcher silence, Git OIDs, Qdrant existence, counts, and unrelated generations are forbidden substitutes."
status: active
phase: phase_6_reflection_boundary