Add typed repository Body observations
This commit is contained in:
parent
cd1a16669b
commit
917d20e2cc
8 changed files with 1535 additions and 0 deletions
125
epiphany-core/src/bin/epiphany-repository-body.rs
Normal file
125
epiphany-core/src/bin/epiphany-repository-body.rs
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
use anyhow::{Result, bail};
|
||||
use epiphany_core::{
|
||||
ObserveOutcome, RuntimeSpineInitOptions, bind_repository_body,
|
||||
bind_runtime_to_agent_memory_swarm, ensure_agent_memory_swarm_identity,
|
||||
initialize_runtime_spine, load_repository_body_status, observe_repository_body,
|
||||
};
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let args = std::env::args().skip(1).collect::<Vec<_>>();
|
||||
let Some(command) = args.first().map(String::as_str) else {
|
||||
return usage();
|
||||
};
|
||||
match command {
|
||||
"bind" => {
|
||||
let binding = bind_repository_body(
|
||||
&PathBuf::from(required(&args, "--repo")?),
|
||||
&PathBuf::from(required(&args, "--store")?),
|
||||
&PathBuf::from(required(&args, "--runtime-store")?),
|
||||
required(&args, "--workspace-id")?,
|
||||
)?;
|
||||
println!(
|
||||
"bound workspace={} swarm={} runtime={} scope={} root={}",
|
||||
binding.workspace_id,
|
||||
binding.swarm_id,
|
||||
binding.runtime_id,
|
||||
binding.scope,
|
||||
binding.git_top_level
|
||||
);
|
||||
}
|
||||
"observe" => {
|
||||
let repo = required(&args, "--repo")?;
|
||||
let store = required(&args, "--store")?;
|
||||
let runtime_store = required(&args, "--runtime-store")?;
|
||||
match observe_repository_body(
|
||||
&PathBuf::from(repo),
|
||||
&PathBuf::from(store),
|
||||
&PathBuf::from(runtime_store),
|
||||
)? {
|
||||
ObserveOutcome::Created(value) => println!(
|
||||
"created generation={} tree={} continuity={}",
|
||||
value.generation, value.tree_oid, value.continuity_status
|
||||
),
|
||||
ObserveOutcome::Unchanged(value) => println!(
|
||||
"unchanged generation={} tree={} continuity={}",
|
||||
value.generation, value.tree_oid, value.continuity_status
|
||||
),
|
||||
}
|
||||
}
|
||||
"status" => {
|
||||
let store = PathBuf::from(required(&args, "--store")?);
|
||||
match load_repository_body_status(&store)? {
|
||||
None => println!("missing"),
|
||||
Some((binding, value)) => println!(
|
||||
"observed workspace={} swarm={} runtime={} scope={} generation={} tree={} head={} continuity={}",
|
||||
binding.workspace_id,
|
||||
binding.swarm_id,
|
||||
binding.runtime_id,
|
||||
binding.scope,
|
||||
value.generation,
|
||||
value.tree_oid,
|
||||
value.head_oid.as_deref().unwrap_or("unborn"),
|
||||
value.continuity_status
|
||||
),
|
||||
}
|
||||
}
|
||||
"smoke" => smoke()?,
|
||||
_ => return usage(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn required<'a>(args: &'a [String], name: &str) -> Result<&'a str> {
|
||||
let index = args
|
||||
.iter()
|
||||
.position(|arg| arg == name)
|
||||
.ok_or_else(|| anyhow::anyhow!("missing {name}"))?;
|
||||
args.get(index + 1)
|
||||
.map(String::as_str)
|
||||
.ok_or_else(|| anyhow::anyhow!("missing value for {name}"))
|
||||
}
|
||||
fn usage<T>() -> Result<T> {
|
||||
bail!(
|
||||
"usage: epiphany-repository-body bind --repo PATH --store PATH --runtime-store PATH --workspace-id ID | observe --repo PATH --store PATH --runtime-store PATH | status --store PATH | smoke"
|
||||
)
|
||||
}
|
||||
fn smoke() -> Result<()> {
|
||||
let root = std::env::current_dir()?;
|
||||
let store = std::env::temp_dir().join(format!(
|
||||
"epiphany-repository-body-smoke-{}.cc",
|
||||
uuid::Uuid::new_v4()
|
||||
));
|
||||
let runtime_store = store.with_extension("runtime.cc");
|
||||
let agent_store = store.with_extension("agents.cc");
|
||||
initialize_runtime_spine(
|
||||
&runtime_store,
|
||||
RuntimeSpineInitOptions {
|
||||
runtime_id: "epiphany-smoke-runtime".into(),
|
||||
display_name: "Repository Body smoke".into(),
|
||||
created_at: "2026-07-15T00:00:00Z".into(),
|
||||
},
|
||||
)?;
|
||||
ensure_agent_memory_swarm_identity(&agent_store, "epiphany-smoke-swarm")?;
|
||||
bind_runtime_to_agent_memory_swarm(&runtime_store, &agent_store, "2026-07-15T00:00:01Z")?;
|
||||
bind_repository_body(
|
||||
&root,
|
||||
&store,
|
||||
&runtime_store,
|
||||
"epiphany-repository-body-smoke",
|
||||
)?;
|
||||
let outcome = observe_repository_body(&root, &store, &runtime_store)?;
|
||||
let observed = load_repository_body_status(&store)?
|
||||
.ok_or_else(|| anyhow::anyhow!("smoke observation missing after commit"))?;
|
||||
std::fs::remove_file(&store)?;
|
||||
std::fs::remove_file(&runtime_store)?;
|
||||
std::fs::remove_file(&agent_store)?;
|
||||
let generation = match outcome {
|
||||
ObserveOutcome::Created(value) | ObserveOutcome::Unchanged(value) => value.generation,
|
||||
};
|
||||
println!(
|
||||
"repository-body-smoke=ok generation={} tree={} continuity={}",
|
||||
generation, observed.1.tree_oid, observed.1.continuity_status
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -24,6 +24,7 @@ mod promotion;
|
|||
mod prompt_context;
|
||||
mod proposal;
|
||||
mod repo_model_gateway;
|
||||
mod repository_body_observer;
|
||||
mod retrieval;
|
||||
mod runtime_spine;
|
||||
mod semantic_backend;
|
||||
|
|
@ -805,6 +806,7 @@ pub use proposal::EpiphanyMapProposal;
|
|||
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;
|
||||
|
|
|
|||
1337
epiphany-core/src/repository_body_observer.rs
Normal file
1337
epiphany-core/src/repository_body_observer.rs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1822,3 +1822,25 @@ RepoModel revision/hash plus matching Mind admission, joined to a separate
|
|||
continuity-bearing Body observation and retrieval coverage for the same source
|
||||
generation. Modeling cannot certify its own freshness; Mind derives readiness
|
||||
from the joined authorities.
|
||||
|
||||
### Repository Body observation boundary
|
||||
|
||||
The bounded repository Body observer supplies only raw `git_worktree` tree state
|
||||
from two equal temporary-index scans. A separate bind step consumes the real
|
||||
runtime swarm binding and pins workspace, source hash, canonical root, object
|
||||
format, scope, and policy; observe has no identity-authoring arguments. It explicitly
|
||||
says continuity unproven and has no Ready field, preventing another freshness
|
||||
oracle before continuity and same-generation retrieval coverage exist. Sparse
|
||||
worktrees fail closed; submodules contribute gitlinks only; integration is
|
||||
deliberately absent.
|
||||
Global excludes are neutralized. Corrupt HEAD and path/runtime/repository
|
||||
substitution fail closed. Only accepted stable observations persist; errors
|
||||
advance no head.
|
||||
One shared Git-command sanitizer removes ambient repository, worktree, object,
|
||||
ref, index, namespace, replacement/graft/shallow, and config-injection variables
|
||||
from every probe and scan.
|
||||
The clean-filtered Git tree OID is explicitly auxiliary. Authoritative Body
|
||||
identity is a domain-separated raw-content manifest root over workspace/scope/
|
||||
policy plus ordered UTF-8 paths, modes/kinds, byte lengths, raw SHA-256 hashes,
|
||||
non-followed symlink-target hashes, and nonrecursive gitlink OIDs. Manifest and
|
||||
manifest-root head share the observation CAS.
|
||||
|
|
|
|||
|
|
@ -767,5 +767,30 @@ revision. Generic thread patches, watcher silence, snapshot source metadata,
|
|||
and unrelated thread revisions are forbidden readiness writers. Until every
|
||||
authority is present and current, Unknown is the truthful result.
|
||||
|
||||
## Repository Body observation substrate (2026-07-15)
|
||||
|
||||
`repository_body_observer.rs` owns bounded `git_worktree` observation. A
|
||||
separate bind command consumes the existing validated runtime swarm binding and
|
||||
pins a caller-supplied workspace ID, exact runtime/swarm/source-identity hash,
|
||||
canonical Git root, object format, scope, and ignore policy; observe cannot mint
|
||||
identity. Two disposable-index `read-tree`/`git add --all -- .`/
|
||||
`write-tree` scans must agree. CultCache MessagePack persists immutable
|
||||
generations and an exact-CAS current head; unchanged raw manifest preserves the
|
||||
generation. `continuity_status` is always `unproven`; there is no Ready field.
|
||||
Sparse checkout fails closed, submodules are gitlink-only, and RepoModel/
|
||||
retrieval/scheduler/Mind integration is absent. The CultCache store must remain
|
||||
outside the observed worktree so observer writes cannot become observed input.
|
||||
Machine-global excludes are disabled during observation. Only accepted stable
|
||||
observations persist; failed/unstable attempts return errors and advance no
|
||||
head. HEAD absence counts as unborn only when a symbolic ref is proven absent.
|
||||
Every Git subprocess strips ambient repository, worktree, object, ref,
|
||||
namespace, index, shallow/graft, and injected-config environment authority.
|
||||
The index owns ignore-aware UTF-8 path, Git mode, and gitlink enumeration; its
|
||||
clean-filtered tree OID is auxiliary. Raw regular-file bytes and lengths, or
|
||||
non-followed symlink-target bytes, feed ordered typed entries. A domain-separated
|
||||
SHA-256 root over workspace, scope policy, and those entries is authoritative
|
||||
Body identity. Manifest, observation, and manifest-root head land in one CAS.
|
||||
Gitlinks remain nonrecursive. Unsafe or unrepresentable paths fail closed.
|
||||
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -1630,6 +1630,29 @@ retrieval coverage bound to the same source generation; Mind derives the joined
|
|||
readiness projection. No current artifact proves that Body head. Do not build a
|
||||
bridge from snapshot metadata, watcher silence, or timestamps.
|
||||
|
||||
## Repository Body substrate landed (2026-07-15)
|
||||
|
||||
Native `repository_body_observer.rs` and `epiphany-repository-body` expose an
|
||||
explicit runtime-bound bind step, observe, pure status, and smoke for
|
||||
`git_worktree` state. Bind pins caller workspace ID to the existing validated
|
||||
runtime/swarm/source identity plus canonical Git root and policy. Two equal
|
||||
isolated Git-index scans feed immutable CultCache observations/current-head CAS.
|
||||
Unchanged raw manifest does not advance generation; missing status creates no
|
||||
store. Continuity remains unproven with no Ready field. Sparse checkout is
|
||||
rejected, submodules are gitlink-only, and downstream joins remain absent.
|
||||
The CultCache store is required to live outside the observed worktree.
|
||||
Canonical path checks run before any bind/store write, global excludes are
|
||||
disabled, and corrupt/non-commit HEAD fails closed. This slice persists accepted
|
||||
stable observations only; failed attempts advance no head.
|
||||
All Git calls share one sanitizer that removes ambient Git repository/object/
|
||||
ref/index/namespace and injected-config authority before applying explicit
|
||||
observation policy.
|
||||
The isolated index enumerates ignore-aware UTF-8 paths/modes/gitlinks, but its
|
||||
clean-filtered tree OID is auxiliary. Raw file bytes (or non-followed symlink
|
||||
target bytes) feed an ordered manifest whose domain-separated SHA-256 root is
|
||||
the authoritative Body identity. Manifest, observation, and manifest-root head
|
||||
commit atomically. Gitlinks are nonrecursive; unrepresentable paths fail closed.
|
||||
|
||||
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.
|
|
@ -1,5 +1,6 @@
|
|||
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. 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. Continuity remains unproven; no Ready field or downstream integration exists."
|
||||
status: active
|
||||
phase: phase_6_reflection_boundary
|
||||
premise: >
|
||||
|
|
|
|||
Reference in a new issue