Reuse repository Body scan index

This commit is contained in:
Meta Vens 2026-08-09 01:08:43 +01:00
commit 217dd4b967
5 changed files with 151 additions and 52 deletions

View file

@ -744,8 +744,9 @@ fn scan_repository(
}
let head = resolve_head(&top_path)?;
let started = chrono::Utc::now().to_rfc3339();
let first = scan_tree(&top_path, head.is_some(), binding)?;
let second = scan_tree(&top_path, head.is_some(), binding)?;
let mut scanner = IsolatedTreeScanner::new(&top_path, head.is_some())?;
let first = scanner.scan(binding)?;
let second = scanner.scan(binding)?;
let finished = chrono::Utc::now().to_rfc3339();
if first != second {
bail!("repository changed across isolated Git index and raw-content scans");
@ -794,50 +795,75 @@ struct RawTreeScan {
entries: Vec<RepositoryBodyManifestEntry>,
}
fn scan_tree(repo: &Path, has_head: bool, binding: &RepositoryBodyBinding) -> Result<RawTreeScan> {
let temp = std::env::temp_dir().join(format!("epiphany-body-index-{}", Uuid::new_v4()));
create_private_scan_directory(&temp)?;
let index = temp.join("index");
let object_directory = temp.join("objects");
std::fs::create_dir(&object_directory)?;
struct Remove(PathBuf);
impl Drop for Remove {
fn drop(&mut self) {
let _ = std::fs::remove_dir_all(&self.0);
struct IsolatedTreeScanner<'a> {
repo: &'a Path,
temp: PathBuf,
index: String,
object_directory: String,
body_object_directory: String,
}
impl<'a> IsolatedTreeScanner<'a> {
fn new(repo: &'a Path, has_head: bool) -> Result<Self> {
let temp = std::env::temp_dir().join(format!("epiphany-body-index-{}", Uuid::new_v4()));
create_private_scan_directory(&temp)?;
let index = temp.join("index");
let object_directory = temp.join("objects");
std::fs::create_dir(&object_directory)?;
let index_text = index.to_string_lossy().into_owned();
let object_directory_text = object_directory.to_string_lossy().into_owned();
let body_object_directory = repository_object_directory(repo)?;
let body_object_directory_text = encode_git_path_list_entry(&body_object_directory);
let scanner = Self {
repo,
temp,
index: index_text,
object_directory: object_directory_text,
body_object_directory: body_object_directory_text,
};
let env = scanner.env();
if has_head {
git(repo, &env, &["read-tree", "HEAD"])?;
} else {
git(repo, &env, &["read-tree", "--empty"])?;
}
Ok(scanner)
}
let _remove = Remove(temp);
let index_text = index.to_string_lossy().into_owned();
let object_directory_text = object_directory.to_string_lossy().into_owned();
let body_object_directory = repository_object_directory(repo)?;
let body_object_directory_text = encode_git_path_list_entry(&body_object_directory);
let env = [
("GIT_INDEX_FILE", index_text.as_str()),
("GIT_OBJECT_DIRECTORY", object_directory_text.as_str()),
(
"GIT_ALTERNATE_OBJECT_DIRECTORIES",
body_object_directory_text.as_str(),
),
];
if has_head {
git(repo, &env, &["read-tree", "HEAD"])?;
} else {
git(repo, &env, &["read-tree", "--empty"])?;
fn env(&self) -> [(&str, &str); 3] {
[
("GIT_INDEX_FILE", self.index.as_str()),
("GIT_OBJECT_DIRECTORY", self.object_directory.as_str()),
(
"GIT_ALTERNATE_OBJECT_DIRECTORIES",
self.body_object_directory.as_str(),
),
]
}
fn scan(&mut self, binding: &RepositoryBodyBinding) -> Result<RawTreeScan> {
let env = self.env();
git(
self.repo,
&env,
&["-c", "core.excludesFile=", "add", "--all", "--", "."],
)?;
let tree_oid = git(self.repo, &env, &["write-tree"])?.trim().to_string();
let index = git_bytes(self.repo, &env, &["ls-files", "--stage", "-z"])?;
let entries = raw_manifest_entries(self.repo, &index)?;
let manifest_root_sha256 = manifest_root(binding, &entries)?;
Ok(RawTreeScan {
tree_oid,
manifest_root_sha256,
entries,
})
}
}
impl Drop for IsolatedTreeScanner<'_> {
fn drop(&mut self) {
let _ = std::fs::remove_dir_all(&self.temp);
}
git(
repo,
&env,
&["-c", "core.excludesFile=", "add", "--all", "--", "."],
)?;
let tree_oid = git(repo, &env, &["write-tree"])?.trim().to_string();
let index = git_bytes(repo, &env, &["ls-files", "--stage", "-z"])?;
let entries = raw_manifest_entries(repo, &index)?;
let manifest_root_sha256 = manifest_root(binding, &entries)?;
Ok(RawTreeScan {
tree_oid,
manifest_root_sha256,
entries,
})
}
#[cfg(unix)]
@ -1609,6 +1635,32 @@ mod tests {
Ok(())
}
#[test]
fn equality_scans_share_one_private_index_session_and_remove_it() -> Result<()> {
let d = repo()?;
let state = tempfile::tempdir()?;
let (store, _) = bound(d.path(), state.path(), "workspace", "runtime", "swarm")?;
write(&d.path().join("tracked.txt"), "one")?;
run(d.path(), &["add", "."])?;
run(d.path(), &["commit", "-m", "seed"])?;
let opening = load_body_envelopes(&store)?;
let binding: RepositoryBodyBinding = decode(
find(&opening, BODY_BINDING_TYPE, BODY_BINDING_KEY)
.ok_or_else(|| anyhow!("test Body binding missing"))?,
)?;
let mut scanner = IsolatedTreeScanner::new(d.path(), true)?;
let temp = scanner.temp.clone();
let index = scanner.index.clone();
let first = scanner.scan(&binding)?;
assert!(Path::new(&index).is_file());
let second = scanner.scan(&binding)?;
assert_eq!(scanner.index, index);
assert_eq!(first, second);
drop(scanner);
assert!(!temp.exists());
Ok(())
}
#[test]
fn persisted_current_basis_load_is_read_only_and_does_not_scan() -> Result<()> {
let d = repo()?;
let state = tempfile::tempdir()?;

View file

@ -867,8 +867,13 @@ authority is present and current, Unknown is the truthful result.
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
identity. One observation-owned disposable index/object quarantine is initialized
with `read-tree`; two complete `git add --all -- .`/`write-tree`/staged-entry/
raw-byte manifest scans against that same private index must agree. The second
scan may reuse Git's verified index stat cache, but it still enumerates the whole
Body and cannot publish unless its tree and raw manifest exactly equal the first.
The index is deleted with the observation session and never becomes durable
truth. CultCache MessagePack persists immutable
generations and an exact-CAS current head; unchanged raw manifest preserves the
generation. The observer makes no historical continuity claim and has no Ready field.
Sparse checkout fails closed, submodules are gitlink-only, and RepoModel/

View file

@ -1,5 +1,45 @@
# Fresh workspace handoff
## Linux Eyes-to-Modeling acceptance and Body observation speed cut — 2026-08-09
The fresh tool-enabled resident circuit under `/state/eyes-tools` completed its
causal organ chain. Eyes job `eaf25324-3d4c-49c1-a93d-65f16b080806` used three
governed native read-only source tools, emitted typed result
`result-worker-eaf25324-3d4c-49c1-a93d-65f16b080806`, and was accepted as
`ev-research-856fb6d1-17eb-4d71-bafc-774277e9b64e`. Self then derived
`launchModeling` because accepted Research was newer than Modeling. Modeling job
`3333e537-7451-4cfd-92bf-b69030b2ab4f` used three governed read-only tool rounds,
emitted `result-worker-3333e537-7451-4cfd-92bf-b69030b2ab4f`, and was accepted as
`ev-modeling-11da531d-3403-41a1-93c3-7224d364364a`. Typed status now reports both
`modelingResultAccepted` and `modelingResultAcceptedAfterResearch` true, so the
single-use route was consumed. The next action is `startFrontierPlanning` for
Imagination. No external consequence occurred.
The Modeling circuit peaked at 109,887,488 bytes over 2,025 cgroup samples.
Its launch receipt measured `jobCommit=160183ms`; process inspection showed the
time inside the first of two full `git add --all` Repository Body scans. The
observer formerly created a brand-new private index and object quarantine for
each equality scan. The current source cut gives one observation session sole
ownership of one private index/object quarantine, initializes it from HEAD once,
and runs both full scans against it. Scan two still performs `git add --all`,
`write-tree`, staged-entry enumeration, and raw-byte manifest hashing, so the
stable-equality invariant remains intact while Git may reuse its verified stat
cache. All 25 focused `repository_body_observer` tests pass, including explicit
proof that both scans share one private index and that session teardown removes
it. The live-worktree mechanism benchmark measured cold scans at 2,176ms and
1,656ms versus a shared
session at 1,414ms and 123ms: 3,832ms fell to 1,537ms, a 2,295ms / 60% pair
reduction. The ignored receipt is `body-index-benchmark.stdout.log`. This is
mechanism evidence, not yet packaged coordinator evidence; package once and
remeasure exact `jobCommit` before claiming the 160-second live wound closed.
Two attempted detached launches were refused before state mutation. The first
used a nonexistent container path. The next two reached the artifact cleanup
guard from `/`, so the guard correctly rejected `/workspace/.epiphany-smoke` as
outside its process-relative safety roots. The successful launch explicitly
used Docker working directory `/workspace`. Preserve these as operator
intervention receipts; they prove the guard rather than runtime corruption.
## Linux resident coordination phase boundary — 2026-08-09
Exact pushed source `c0055772750a7dd7335f65baa88307cf9e28c1e1` is packaged for Linux as

Binary file not shown.

View file

@ -35,7 +35,8 @@ invariants:
- Evidence and git retain history; this map retains only state that changes future decisions.
current_status:
summary: Epiphany is a supervised engineering alpha on Starfire, not deployment-ready. Live v53 remains a closed complete internal circuit. The native Persona crossing is deployed and its unique permit path is proven, but Yggdrasil still lacks the Discord credential needed for one completed public consequence. Exact authenticated 100d8854 packages 22 binaries including runtime-spine; its actuator closed all four v28 replay sessions, replayed idempotently, and refused post-close work. Typed live retention reduced heartbeat artifacts from 12,511 directories and 706.5 MB through 191 typed receipts while protecting current cognition. Authenticated 42bc665a restored restart sequence continuity and automatic hysteresis retention. Source-cache worktree identity is repaired; warm exact Windows packaging measures 1m12s stable plus 6.56s coordinator. Digest-pinned Linux runtime-spine passed a disposable Yggdrasil CultCache/Continuity smoke at 4.35 MiB peak RSS. Exact Linux model-runtime sha256-c72f33ed completed two native Codex Responses turns on Starfire at 20 MiB peak RSS. Exact c0055772 package sha256-b4faf572 now proves Linux heartbeat -> Self -> plan-coordinator coordination and a resident Self+coordinator+model-worker peak of 59.7 MiB. The first execute attempt exposed that detached workers die when a one-shot container owns PID 1; exact-job replay then failed closed against the surviving inner job. Resident Eyes reached a real zero-consequence model request, but failed its typed result because native read-only source tools were advertised while the tool loop was disabled. No tool invocation or external consequence was admitted. Coordinated Linux transport is proven; successful coordinated role-result admission remains open. The root and epiphany-core lock graphs remain version-skewed cache owners. Log ownership, endurance, successful Linux organ cognition, the Persona consequence, and stable Starfire firewall ownership remain open.
summary: Epiphany is a supervised engineering alpha on Starfire, not deployment-ready. A persistent exact-c005 Linux body now proves heartbeat and Self coordination plus accepted governed Eyes-to-Modeling cognition with native read-only tools, typed Mind admission, causal next-organ routing, and no external consequence. The resident Modeling circuit peaked at 109887488 bytes. Yggdrasil remains the small public crossing body and is not a release forge; its Epiphany service contract is repaired but uninstalled, and one completed Persona consequence still lacks the required Discord credential. Continuity and retention have bounded Windows and disposable Linux proofs, while resident crash/restart, long-duration plateau, log ownership, Imagination frontier continuation, and stable Starfire firewall ownership remain open. Iteration is constrained by split Cargo lock owners and Repository Body observation; the current shared-private-index cut preserves two-scan equality and has focused tests plus mechanism benchmark evidence, but still needs exact packaged coordinator timing.
latest_phase: Fresh resident Eyes result eaf25324 and causal Modeling result 3333e537 both completed governed native read-only tool loops and were accepted without external consequence. modelingResultAcceptedAfterResearch is true, consuming the single-use route; startFrontierPlanning is next. Modeling peaked at 109887488 bytes and measured 160183ms in Repository Body job commit before cognition. A shared-private-index observer cut retains both equality scans; 25 focused tests pass, including index reuse and teardown. A live-worktree mechanism benchmark reduced the scan pair from 3832ms cold to 1537ms shared, with scan two at 123ms; packaged coordinator timing remains required.
operational_state:
local_worktree: clean_at_live_retention_restart_proof
operator_wireguard: restored
@ -63,11 +64,12 @@ current_status:
starfire_linux_model_cognition: exact_a0d56f94_model_runtime_sha256_c72f33ed_two_turns_passed_20_mib_peak_rss
starfire_linux_resident_coordination: exact_c0055772_heartbeat_self_plan_coordinator_passed
starfire_linux_resident_peak: 62590976_bytes_self_plus_coordinator_plus_model_worker
starfire_linux_role_cognition: transport_proven_result_admission_failed_zero_consequence
starfire_linux_role_cognition: eyes_and_modeling_tools_results_and_acceptance_proven_zero_consequence
starfire_linux_modeling_peak: 109887488_bytes_resident_body_plus_modeling_circuit
yggdrasil_epiphany_service_contract: repaired_in_gamecult_ops_812b427_not_installed
resident_physiology: heartbeat_42bc665a_pid_19928_and_self_running
unresolved_authority: Repository Body bootstrap still performs two authenticated full-tree Git index/manifest passes and took 5m16s over the exact disposable workspace. The successful resident plan circuit required an explicitly bootstrapped local Verse. Execute-mode coordinator workers require a persistent process body; a one-shot container cannot own detached worker lifetime. Native Eyes source tools are advertised independently of coordinator auto-tool execution, so a zero-tool Eyes run selects tools then produces no typed assistant result. Keyed storage has not earned live migration. One completed Discord consequence remains blocked by the absent Yggdrasil credential, and Windows' stable path-independent permit rule remains unapplied. Resident stdout/stderr logs remain a separate unbounded supervisor-owned surface. Root and epiphany-core Cargo lock graphs independently own version-skewed dependency caches.
next_action: Build a fresh typed-objective Linux circuit for Eyes with its native read-only source tools enabled inside the persistent resident body; prove tool receipts, typed role-result admission, failure review, and the next routed organ without external consequence. Preserve the c005 zero-tool circuit as sealed evidence. The Yggdrasil service contract is repaired in gamecult-ops 812b427 but remains uninstalled; do not deploy from this evidence alone. Continue endurance/log-owner work. Optimize Body authentication only after profiling confirms which of its two full passes can share verified work without weakening the equality invariant.
unresolved_authority: Repository Body observation still performs two authenticated full-tree Git index/manifest passes; accepted Modeling measured 160.183 seconds in job commit before cognition. Both scans rebuild unrelated cold indexes in the packaged c005 release. The source cut shares one private index within a single observation while retaining two full equality scans; a live-worktree mechanism benchmark reduced 3832ms to 1537ms, but packaged coordinator timing remains unproven. The successful resident plan circuit required an explicitly bootstrapped local Verse. Execute-mode coordinator workers require a persistent process body; a one-shot container cannot own detached worker lifetime. Keyed storage has not earned live migration. One completed Discord consequence remains blocked by the absent Yggdrasil credential, and Windows' stable path-independent permit rule remains unapplied. Resident stdout/stderr logs remain a separate unbounded supervisor-owned surface. Root and epiphany-core Cargo lock graphs independently own version-skewed dependency caches.
next_action: Complete and benchmark the shared-isolated-index Repository Body observation cut, package it once, and prove the same live Modeling launch basis with materially lower job-commit time. Then follow the accepted Modeling result's typed startFrontierPlanning action into Imagination without external consequence. Preserve all c005 circuit artifacts as sealed evidence. The Yggdrasil service contract is repaired in gamecult-ops 812b427 but remains uninstalled; do not deploy from this evidence alone. Continue endurance/log-owner work.
active_subgoals:
- Prove Persona, Self, Eyes, Modeling, Imagination, Hands, Soul, Mind, Continuity, and nervous-system behavior individually.
@ -78,14 +80,14 @@ active_subgoals:
organ_readiness:
persona: partial; cross-host request/receipt/permit organs, distinct identities, exact release admission, unique permit completion, signed failure/unknown receipts, and no-repost behavior are live. Exact Bifrost cb3239aa fixes positional permit bodies and binds the Discord bridge command receipt to the signed request. A completed public consequence remains unproven because Yggdrasil has no Discord bot credential.
self: partial; proposal recovery, Mind admission, current-model Hands routing, Soul lifecycle precedence, verdict incorporation, proposal preemption, challenge-aware Eyes routing, in-process status ownership, and causal Research/Soul-to-Modeling routing are live. Broader autonomous frontier turnover remains open.
eyes: proven for one bounded Windows challenged-claim circuit. Linux resident Eyes reached real model transport under exact c0055772 and advertised three native read-only source tools, but the zero-tool circuit intentionally disabled the tool loop and therefore failed typed result admission; the failure is superseded with a typed review receipt. Successful Linux Eyes tool/result coordination remains open.
modeling: proven for the current bounded circuit; proposal-bound source inspection, Mind admission, exact routed identity preservation, and first-valid verdict incorporation completed without retry churn. Broader Body-map coverage remains open.
eyes: proven for one bounded Windows challenged-claim circuit and one coordinated Linux resident circuit. Linux Eyes job eaf25324 invoked exactly three governed native read-only source tools, completed a typed role result, and was accepted as evidence ev-research-856fb6d1 with no external consequence. Broader source coverage remains open.
modeling: proven for the current bounded Windows circuit and the causal Linux resident Eyes-to-Modeling route. Modeling job 3333e537 invoked three governed read-only tool rounds, completed typed result result-worker-3333e537, and was accepted as ev-modeling-11da531d. Modeling acceptance is newer than Research and modelingResultAcceptedAfterResearch is true, proving the single-use causal route was consumed. Broader Body-map coverage remains open.
imagination: proven for two bounded live circuits; the current c35272c9 circuit was caused by fresh Modeling, selected the typed frontier over stale manual-regather display state, completed Imagination job 2a5701fe, and committed a dedicated Mind request without adopting the candidate. Broader option generation remains open.
hands: proven for bounded consequences; native patch, command, commit, push, and typed receipts bind reviewed path ceilings to exact changed-path subsets.
soul: proven for the current bounded route-chain consequence; exact d3bfbda0 launched Verification through typed plan-decision provenance, result f23fe2b6 was accepted at revision 57, and Self then derived Modeling before any repeated Hands authority.
mind: partial; RepoModel admission, thread-state admission, gateway review, state commit, first-valid verdict incorporation, bounded supervisor acceptance correction, and dedicated frontier-plan review requests are live. The current plan candidate awaits Mind adjudication.
continuity: partial; authenticated 55660d78 terminalized the copied v28 dead worker once and refused duplicate restart, while sealed v28 remained unchanged. Exact 100d8854 Continuity closes only all-terminal sessions, emits one deterministic event, refuses post-close jobs, and moved the disposable v28 copy from four active sessions to zero. Exact 42bc665a proves bounded retention and restart sequence recovery. A digest-pinned Linux runtime-spine at b5140288 independently repeated open-job closure refusal, terminal completion, idempotent session closure, and post-close refusal on Yggdrasil. Long-duration plateau and full resident crash/restart behavior remain open.
nervous_system: partial; detached scheduling, runtime jobs, typed feedback, ordinary Windows coverage-store identity, and operator projection work. Exact c0055772 proves Linux heartbeat acknowledgement/regrant, Self single-consumption launch, authenticated plan coordinator completion, and a persistent resident body. It also proves detached model workers cannot survive a one-shot container PID 1 exit. Resident Self plus coordinator/model worker peaked at 62,590,976 bytes. Repository Body bootstrap took 5m16s and visibly performed two full-tree git-add/authentication passes. Authenticated d910158f isolates Self policy behind one root-graph optional coordinator feature; warm policy invalidation is 6.02s. Root Linux packaging is 12m33s cold and 9.08s warm with persistent caches. Long-duration pressure and resource plateau remain open. Yggdrasil is not a release forge at its current memory budget.
nervous_system: partial; detached scheduling, runtime jobs, typed feedback, ordinary Windows coverage-store identity, and operator projection work. Exact c0055772 proves Linux heartbeat acknowledgement/regrant, Self single-consumption launch, authenticated plan coordinator completion, and a persistent resident body. It also proves detached model workers cannot survive a one-shot container PID 1 exit. The accepted Linux Eyes-to-Modeling circuit proves detached role workers, native read-only tool loops, typed admission, and causal next-organ routing at a measured 109887488-byte peak. Modeling job commit spent 160183ms in two cold Repository Body scans. A source cut now reuses one private index across both equality scans; 25 focused observer tests pass and a live-worktree mechanism benchmark reduced the pair from 3832ms to 1537ms. Packaged coordinator timing remains open. Authenticated d910158f isolates Self policy behind one root-graph optional coordinator feature; warm policy invalidation is 6.02s. Root Linux packaging is 12m33s cold and 9.08s warm with persistent caches. Long-duration pressure and resource plateau remain open. Yggdrasil is not a release forge at its current memory budget.
forbidden_actions:
- Do not issue a speculative deployment grant.