Move workspace projection authority out of Body

This commit is contained in:
Meta Vens 2026-07-17 10:32:29 +01:00
commit e23330b415
10 changed files with 3061 additions and 556 deletions

View file

@ -70,8 +70,8 @@ use epiphany_core::{
write_workspace_coverage_process_termination_observation,
};
use epiphany_core::{
authenticate_current_workspace_coverage_advancement,
authenticate_current_workspace_coverage_terminal_authority,
authenticate_current_workspace_coverage_advancement_sight,
authenticate_current_workspace_coverage_terminal_sight,
};
use epiphany_core::{
epiphany_packaged_release_binary_path, epiphany_packaged_release_witness_sha256,
@ -898,7 +898,21 @@ fn publish_managed_service_iteration_health(
continue;
}
};
match authenticate_current_workspace_coverage_terminal_authority(runtime_store) {
let host = match open_default_host_identity() {
Ok(host) => host,
Err(error) => {
contradictions.push(format!(
"workspace health cannot authenticate host: {error:#}"
));
continue;
}
};
match authenticate_current_workspace_coverage_terminal_sight(
runtime_store,
&args.store,
&args.runtime_id,
host.entry(),
) {
Ok(Some(authority)) => {
terminal_current += 1;
workspace_evidence = Some(format!(
@ -910,15 +924,6 @@ fn publish_managed_service_iteration_health(
));
}
Ok(None) => {
let host = match open_default_host_identity() {
Ok(host) => host,
Err(error) => {
contradictions.push(format!(
"workspace health cannot authenticate host: {error:#}"
));
continue;
}
};
let launch = match load_latest_workspace_coverage_managed_process_launch(
&args.store,
args.runtime_id.clone(),
@ -932,26 +937,30 @@ fn publish_managed_service_iteration_health(
continue;
}
};
match authenticate_current_workspace_coverage_advancement(
match authenticate_current_workspace_coverage_advancement_sight(
runtime_store,
&args.store,
&args.runtime_id,
&launch.launch_id,
host.entry(),
Utc::now(),
Duration::seconds(WORKSPACE_PROGRESS_NO_ADVANCE_LEASE_SECONDS),
) {
Ok(Some(authority)) => {
warming += 1;
workspace_evidence = Some(format!(
"workspaceProgressId={} workspaceCheckpointId={} workspacePlanId={} workspaceCompletedUnits={} workspaceTotalUnits={} workspaceLastAdvancedAt={}",
authority.progress_id,
authority.checkpoint_id,
authority.plan_id,
authority.completed_units,
authority.total_units,
authority.last_advanced_at_utc
));
let advanced =
DateTime::parse_from_rfc3339(&authority.last_advanced_at_utc)
.map(|time| time.with_timezone(&Utc));
match advanced {
Ok(advanced) if Utc::now().signed_duration_since(advanced) >= Duration::zero()
&& Utc::now().signed_duration_since(advanced) <= Duration::seconds(WORKSPACE_PROGRESS_NO_ADVANCE_LEASE_SECONDS) => {
warming += 1;
workspace_evidence = Some(format!(
"workspaceProgressId={} workspaceCheckpointId={} workspacePlanId={} workspaceCompletedUnits={} workspaceTotalUnits={} workspaceLastAdvancedAt={}",
authority.progress_id, authority.checkpoint_id, authority.plan_id,
authority.completed_units, authority.total_units, authority.last_advanced_at_utc
));
}
Ok(_) => contradictions.push("workspace advancement sight exceeded the supervisor no-advance lease".into()),
Err(error) => contradictions.push(format!("workspace advancement sight time is invalid: {error:#}")),
}
}
Ok(None) => {}
Err(error) => contradictions.push(format!(
@ -4032,6 +4041,30 @@ mod semantic_projector_authority_tests {
assert!(source.contains("WindowsIdentity]::GetCurrent().User.Value"));
}
#[test]
fn workspace_health_reads_signed_sight_and_never_opens_owned_coverage_store() {
let source = include_str!("epiphany-daemon-supervisor.rs");
let start = source
.find("fn publish_managed_service_iteration_health")
.unwrap();
let tail = &source[start..];
let end = tail.find("\nfn ").unwrap();
let body = &tail[..end];
let terminal = body
.find("authenticate_current_workspace_coverage_terminal_sight")
.unwrap();
let advancement = body
.find("authenticate_current_workspace_coverage_advancement_sight")
.unwrap();
assert!(
terminal < advancement,
"terminal sight must be preferred before warming sight"
);
assert!(!body.contains("open_workspace_coverage_authority"));
assert!(!body.contains("authenticate_current_workspace_coverage_terminal_authority"));
assert!(!body.contains("authenticate_current_workspace_coverage_advancement("));
}
#[test]
fn windows_argv_quoting_preserves_paths_and_escapes_parser_boundaries() {
assert_eq!(

View file

@ -5,8 +5,9 @@ use epiphany_core::{
EpiphanyMemoryLifecycle, EpiphanyMemoryNode, EpiphanyMemoryNodeKind, EpiphanyMemoryProfile,
MEMORY_GRAPH_SCHEMA_VERSION, ObserveOutcome, RuntimeSpineInitOptions,
admit_legacy_agent_memory_generation, bind_repository_body, bind_runtime_to_agent_memory_swarm,
ensure_agent_memory_swarm_identity, ensure_runtime_repo_model, initialize_runtime_spine,
load_repository_body_status, observe_repository_body,
bind_runtime_workspace_coverage_store, ensure_agent_memory_swarm_identity,
ensure_runtime_repo_model, initialize_runtime_spine, load_repository_body_status,
observe_repository_body,
};
use std::path::PathBuf;
@ -21,6 +22,8 @@ fn main() -> Result<()> {
let store = PathBuf::from(required(&args, "--store")?);
let runtime_store = PathBuf::from(required(&args, "--runtime-store")?);
let agent_store = PathBuf::from(required(&args, "--agent-store")?);
let workspace_coverage_store =
PathBuf::from(required(&args, "--workspace-coverage-store")?);
let workspace_id = required(&args, "--workspace-id")?;
let runtime_id = required(&args, "--runtime-id")?;
let swarm_id = required(&args, "--swarm-id")?;
@ -37,6 +40,7 @@ fn main() -> Result<()> {
admit_legacy_agent_memory_generation(&agent_store)?;
bind_runtime_to_agent_memory_swarm(&runtime_store, &agent_store, &at)?;
let binding = bind_repository_body(&repo, &store, &runtime_store, workspace_id)?;
bind_runtime_workspace_coverage_store(&runtime_store, &workspace_coverage_store, &at)?;
observe_repository_body(&repo, &store, &runtime_store)?;
let bootstrap = EpiphanyMemoryGraphSnapshot {
schema_version: Some(MEMORY_GRAPH_SCHEMA_VERSION.to_string()),
@ -163,7 +167,7 @@ fn required<'a>(args: &'a [String], name: &str) -> Result<&'a str> {
}
fn usage<T>() -> Result<T> {
bail!(
"usage: epiphany-repository-body bootstrap --repo PATH --store PATH --runtime-store PATH --agent-store PATH --workspace-id ID --runtime-id ID --swarm-id ID | bind --repo PATH --store PATH --runtime-store PATH --workspace-id ID | observe --repo PATH --store PATH --runtime-store PATH | status --store PATH | smoke"
"usage: epiphany-repository-body bootstrap --repo PATH --store PATH --runtime-store PATH --agent-store PATH --workspace-coverage-store PATH --workspace-id ID --runtime-id ID --swarm-id ID | 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<()> {
@ -174,6 +178,7 @@ fn smoke() -> Result<()> {
));
let runtime_store = store.with_extension("runtime.cc");
let agent_store = store.with_extension("agents.cc");
let workspace_coverage_store = store.with_extension("workspace-coverage.cc");
initialize_runtime_spine(
&runtime_store,
RuntimeSpineInitOptions {
@ -190,12 +195,19 @@ fn smoke() -> Result<()> {
&runtime_store,
"epiphany-repository-body-smoke",
)?;
bind_runtime_workspace_coverage_store(
&runtime_store,
&workspace_coverage_store,
"2026-07-15T00:00:02Z",
)?;
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)?;
std::fs::remove_file(&workspace_coverage_store)?;
let _ = std::fs::remove_file(workspace_coverage_store.with_extension("cc.lock"));
let generation = match outcome {
ObserveOutcome::Created(value) | ObserveOutcome::Unchanged(value) => value.generation,
};