Enforce Epiphany compatibility route boundaries

This commit is contained in:
Meta Vens 2026-07-12 06:18:28 +01:00
commit a3b5cb6ec1
9 changed files with 82 additions and 164 deletions

View file

@ -1,11 +1,9 @@
use epiphany_core::EPIPHANY_IMAGINATION_OWNER_ROLE;
use epiphany_core::EPIPHANY_IMAGINATION_ROLE_BINDING_ID;
use epiphany_core::EPIPHANY_MODELING_ROLE_BINDING_ID;
use epiphany_core::EPIPHANY_REORIENT_LAUNCH_BINDING_ID;
use epiphany_core::EPIPHANY_REORIENT_OWNER_ROLE;
use epiphany_core::EPIPHANY_RESEARCH_ROLE_BINDING_ID;
use epiphany_core::EPIPHANY_VERIFICATION_ROLE_BINDING_ID;
use epiphany_core::EpiphanyCoordinatorAutomationAction as CoreEpiphanyCoordinatorAutomationAction;
use epiphany_core::EpiphanyCoordinatorDecision as CoreEpiphanyCoordinatorDecision;
use epiphany_core::EpiphanyCoordinatorRoleResultStatus as CoreEpiphanyCoordinatorRoleResultStatus;
use epiphany_core::EpiphanyCoordinatorStatus as CoreEpiphanyCoordinatorStatus;
@ -16,7 +14,6 @@ use epiphany_core::EpiphanyCrrcRecommendation as CoreEpiphanyCrrcRecommendation;
use epiphany_core::EpiphanyCrrcReorientAction as CoreEpiphanyCrrcReorientAction;
use epiphany_core::EpiphanyCrrcResultStatus as CoreEpiphanyCrrcResultStatus;
use epiphany_core::EpiphanyCrrcStateStatus as CoreEpiphanyCrrcStateStatus;
use epiphany_core::EpiphanyJobLaunchRequest;
use epiphany_core::EpiphanyJobStatus as CoreEpiphanyJobStatus;
use epiphany_core::EpiphanyJobView;
use epiphany_core::EpiphanyReorientAction as CoreEpiphanyReorientAction;
@ -30,27 +27,15 @@ use epiphany_core::EpiphanyRoleBoardJobStatus;
use epiphany_core::EpiphanyRoleBoardLane;
use epiphany_core::EpiphanyRoleBoardPlanningSummary;
use epiphany_core::EpiphanyRoleResultRoleId;
use epiphany_core::EpiphanyTokenUsageSnapshot;
use epiphany_core::build_epiphany_reorient_launch_request_with_dynamic_context;
use epiphany_core::derive_coordinator_finding_signals;
use epiphany_core::derive_coordinator_status;
use epiphany_core::derive_role_board;
use epiphany_core::recommend_crrc_action;
use epiphany_core::render_epiphany_coordinator_note;
use epiphany_core::render_role_board_note;
use epiphany_core::reorient_finding_already_accepted;
use epiphany_core::runtime_hands_receipt_chain_after;
use epiphany_core::select_coordinator_automation_action;
use epiphany_state_model::EpiphanyRetrievalState;
use epiphany_state_model::EpiphanyThreadState;
use crate::launch_context::render_launch_dynamic_prompt_context;
use crate::launch_context::reorient_launch_context_focus;
use crate::pressure::derive_epiphany_pressure;
use crate::reorient::EpiphanyFreshnessWatcherSnapshot;
use crate::reorient::derive_epiphany_freshness_view;
use crate::reorient::derive_epiphany_reorient;
use crate::runtime_results::load_core_epiphany_reorient_result_snapshot;
use crate::runtime_results::load_core_epiphany_role_result_snapshot;
use std::path::Path;
@ -245,139 +230,6 @@ fn runtime_hands_receipts_after_verification(
runtime_hands_receipt_chain_after(runtime_store_path, accepted_at).unwrap_or(false)
}
pub type EpiphanyCoordinatorAutomationAction = CoreEpiphanyCoordinatorAutomationAction;
pub struct EpiphanyCoordinatorAutomationInput<'a> {
pub thread_id: &'a str,
pub state: &'a EpiphanyThreadState,
pub retrieval_override: &'a EpiphanyRetrievalState,
pub watcher_snapshot: EpiphanyFreshnessWatcherSnapshot<'a>,
pub token_usage_info: Option<&'a EpiphanyTokenUsageSnapshot>,
pub runtime_store_path: &'a Path,
pub force_checkpoint_compaction: bool,
}
pub struct EpiphanyCoordinatorAutomationVerdict {
pub action: EpiphanyCoordinatorAutomationAction,
pub launch_request: Option<EpiphanyJobLaunchRequest>,
}
pub async fn select_epiphany_coordinator_automation(
input: EpiphanyCoordinatorAutomationInput<'_>,
) -> EpiphanyCoordinatorAutomationVerdict {
let core_freshness = derive_epiphany_freshness_view(
Some(input.state),
Some(input.retrieval_override),
Some(input.watcher_snapshot),
);
let core_pressure = derive_epiphany_pressure(input.token_usage_info);
let (state_status, reorient_decision) = derive_epiphany_reorient(
Some(input.state),
&core_pressure,
&core_freshness.retrieval,
&core_freshness.graph,
&core_freshness.watcher,
);
if state_status != CoreEpiphanyReorientStateStatus::Ready {
return EpiphanyCoordinatorAutomationVerdict {
action: EpiphanyCoordinatorAutomationAction::None,
launch_request: None,
};
}
let jobs = crate::jobs::map_epiphany_jobs(Some(input.state), Some(input.retrieval_override));
let reorient_job = jobs
.iter()
.find(|job| job.id == EPIPHANY_REORIENT_LAUNCH_BINDING_ID)
.cloned();
let reorient_result = load_core_epiphany_reorient_result_snapshot(
Some(input.state),
Some(input.runtime_store_path),
EPIPHANY_REORIENT_LAUNCH_BINDING_ID,
)
.await;
let reorient_finding_accepted = reorient_result
.finding
.as_ref()
.is_some_and(|finding| reorient_finding_already_accepted(input.state, finding));
let crrc_recommendation = map_epiphany_crrc_recommendation(
true,
state_status,
&core_pressure,
&reorient_decision,
reorient_result.status,
input.state.investigation_checkpoint.as_ref().is_some(),
reorient_result.finding.is_some(),
reorient_finding_accepted,
);
let roles = map_epiphany_roles(
Some(input.state),
&jobs,
&reorient_decision,
&core_pressure,
&crrc_recommendation,
reorient_result.status,
reorient_job.as_ref(),
);
let coordinator = derive_epiphany_coordinator_status(
Some(input.state),
Some(input.runtime_store_path),
state_status,
&core_pressure,
&crrc_recommendation,
roles.roles,
Some(&reorient_decision),
reorient_result.status,
reorient_result.finding.as_ref(),
input.state.investigation_checkpoint.as_ref().is_some(),
)
.await;
let action = select_coordinator_automation_action(
&coordinator.core.decision,
input.force_checkpoint_compaction,
);
let launch_request = match action {
EpiphanyCoordinatorAutomationAction::LaunchReorientWorker => input
.state
.investigation_checkpoint
.as_ref()
.map(|checkpoint| {
let dynamic_prompt_context = render_launch_dynamic_prompt_context(
input.runtime_store_path,
input.state,
reorient_launch_context_focus(input.state, &reorient_decision.next_action),
)
.ok();
build_epiphany_reorient_launch_request_with_dynamic_context(
input.thread_id,
Some(input.state.revision),
None,
input.state,
checkpoint,
&reorient_decision,
dynamic_prompt_context,
)
}),
EpiphanyCoordinatorAutomationAction::None
| EpiphanyCoordinatorAutomationAction::CompactRehydrateReorient => None,
};
let action = if matches!(
action,
EpiphanyCoordinatorAutomationAction::LaunchReorientWorker
) && launch_request.is_none()
{
EpiphanyCoordinatorAutomationAction::None
} else {
action
};
EpiphanyCoordinatorAutomationVerdict {
action,
launch_request,
}
}
#[derive(Debug, Clone)]
pub struct EpiphanyRoleBoardStatus {
pub roles: Vec<EpiphanyRoleBoardLane>,

View file

@ -34,5 +34,4 @@ pub use epiphany_core::epiphany_role_owner;
pub use epiphany_core::epiphany_specialist_prompt_config;
pub use epiphany_core::epiphany_worker_prompt;
pub use epiphany_core::render_epiphany_coordinator_note;
pub use epiphany_core::render_epiphany_pre_compaction_checkpoint_intervention;
pub use epiphany_core::unique_strings;

View file

@ -1,20 +1,7 @@
use epiphany_core::EpiphanyPressure;
use epiphany_core::EpiphanyPressureStatus as CoreEpiphanyPressureStatus;
pub use epiphany_core::EpiphanyTokenUsageSnapshot;
use epiphany_core::derive_pressure_view;
pub fn derive_epiphany_pressure(snapshot: Option<&EpiphanyTokenUsageSnapshot>) -> EpiphanyPressure {
derive_pressure_view(snapshot)
}
pub fn should_run_epiphany_pre_compaction_checkpoint_intervention(
pressure: &EpiphanyPressure,
) -> bool {
pressure.status == CoreEpiphanyPressureStatus::Ready && pressure.should_prepare_compaction
}
pub fn render_epiphany_pre_compaction_checkpoint_intervention(
pressure: &EpiphanyPressure,
) -> String {
epiphany_core::render_epiphany_pre_compaction_checkpoint_intervention(pressure)
}

View file

@ -1942,7 +1942,13 @@ gone: Codex no longer auto-compacts, launches reorientation workers, or steers
checkpoint prompts from turn/token events, and its per-thread checkpoint state
is deleted. Native physiology owns those decisions. Next classify each
remaining Epiphany app-server route/module and cut any route-local policy or
implicit trigger while preserving explicit delegated client compatibility.
implicit trigger while preserving explicit delegated client compatibility. The
classification is now a source-enforced architecture: mutation handlers require
nine named delegates and forbid local state/scheduler/prompt authority; read
handlers forbid every actuator family; implicit event triggers remain absent.
Dead bridge automation and checkpoint-pressure wrappers were deleted too. Next
audit real client consumers of each `ThreadEpiphany*` route and delete any
compatibility API with no named living client.
## Immediate Re-entry Instruction

View file

@ -363,3 +363,14 @@ state are gone. Native coordinator/heartbeat/Continuity organs own scheduling,
launch, pressure, and recovery; app-server retains explicit compatibility
routes, notifications, and read projection only. A source guard rejects renewed
automation authority in the event loop, processor module list, or thread state.
The remaining app-server surface is now mechanically classified and guarded.
Mutation routes must call one of nine explicit bridge delegates for role launch,
role acceptance, reorientation launch/acceptance, indexing, promotion, update,
job launch, or interruption; forbidden local receipt/binding/runtime writes,
prompt steering, compaction submission, and automation selection fail the
source test. Read routes reject every mutation, launch, interruption, indexing,
prompt-steering, compaction, or scheduler symbol. Migration, read projection,
notification projection, and explicit delegated actuation are the only allowed
categories. The deleted event-loop reflex also left dead bridge automation and
checkpoint-pressure wrappers; those zero-caller exports and imports are gone.

Binary file not shown.

View file

@ -659,4 +659,4 @@ current_status:
- Service lifecycle receipt history is now event-only: `load_epiphany_cultmesh_daemon_service_lifecycle_receipts` filters out the `epiphany-local/daemon-service-lifecycle-receipt/latest` mirror, while `load_latest_epiphany_cultmesh_daemon_service_lifecycle_receipt` remains the latest-state reader. Focused unit test `service_lifecycle_receipt_history_excludes_latest_mirror` proves two per-receipt writes return exactly two history records and latest points at the second. Fresh smoke `verse-query-lifecycle-history-filter-smoke` and live overview/triage `local-20260618-145632-497-efac6f0d` / `local-20260618-145632-321-867947af` prove compact swarm sights still expose service lifecycle attention plus the present elevated runbook artifact without daemon pokes or service mutation. Do not use a broad unscoped cargo test filter for this check on Windows; it fans out across bin harnesses and hit a broken pipe during this pass.
- `epiphany-verse-query seed-compact` is the compact seed receipt for wrappers and read-only rites. The older `seed` command still prints the full local Verse context for explicit debugging, but compact wrapper modes now avoid full `seed`/final `query` readback after the combined overview proof exposed Windows debug stack overflow from full-context serialization pressure.
last_completed_repo_swarm_cut: Huginn live-fire has crossed the first real repo Body from Persona pressure to branch-local Hands commit and Soul/Mind closure, and now has repeatable closure and redacted-public-proof mouths. On `E:\Projects\Huginn` branch `epiphany/huginn/first-awakening`, `tools/epiphany_local_run.ps1 -Mode repo-persona-intake` accepted item `huginn-inspection-readback-livefire`, Weksa/Persona intake remained sealed, and `epiphany-work derive-plan` lowered it to model-authored safe family `repo.status_section` for `README.md` only. `tools/epiphany_local_run.ps1 -Mode repo-swarm-run` advanced four bounded pulses: run-from-plan, adopt-from-plan, execute-from-plan, and close-from-execute. Huginn commit `e9b07c38fceabbdc89ea35c2156326c80c0393a2` updated only `README.md`; closure receipt `.epiphany\work\work-close-huginn-inspection-readback-livefire.json` records status `closed`, Soul verdict `passed`, Mind state commit `repo-work-close-huginn-inspection-readback-livefire-mind-commit`, safe family `repo.status_section`, path scope `README.md`, Bifrost publication gate, and `privateStateExposed=false`. Verification also ran Huginn's TypeScript compiler through concrete Node path: `C:\Program Files\nodejs\node.exe E:\Projects\Huginn\node_modules\typescript\bin\tsc -p tsconfig.json` passed. Native verifier `epiphany-repo-livefire-closure-smoke --workspace E:\Projects\Huginn --item huginn-inspection-readback-livefire --expected-path README.md --expected-family repo.status_section --expected-gate awaiting-publication --expected-blocker bifrost-publication-missing` checks closure receipt, Mind map entry, overview gate/blocker, authority seals, and `git show` changed paths, returning `status=ok`, `soulVerdict=passed`, `publicationGate=Bifrost`, and `privateStateExposed=false`. Wrapper `tools/epiphany_local_run.ps1 -Mode repo-livefire-closure -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exposes the same read-only proof through the local operator mouth; artifact `local-20260621-190156-803-2f85ba15` printed commit, path, gate, blocker, Soul verdict, Mind commit receipt, and `privateStateExposed=False` without push, merge, publication, or target mutation. New wrapper `tools/epiphany_local_run.ps1 -Mode repo-work-public-proof -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exports the redacted proof bundle and repo-local Verse index without publishing; artifact `local-20260621-190645-345-4555b1dc` wrote `.epiphany\public\proof-bundles\repo-work-public-proof-huginn-inspection-readback-livefire.json`, proof id `repo-work-public-proof-huginn-inspection-readback-livefire`, SHA-256 `857545b199f3e37eb06c2e757e5cfc201958e46667bb1f8403fd333a22620f63`, nine artifact rows, zero publication rows, and `privateStateExposed=False`. Gjallar readback `local-20260621-190701-140-b9519ec6` sees the `REPO-WORK-PUBLIC-PROOF` row and action row from Huginn's repo-local Verse with the same SHA-256 while Bifrost publication remains missing. Launcher compact modes are now named compact operator-context modes instead of read-only modes, and `bifrost-public-proof` summaries print item, target public Verse, room, proof SHA-256, review receipts, and credit receipts so publication receipts are auditable without claiming upstream sync.
next_action: Classify every remaining Epiphany app-server module and JSON-RPC route as explicit compatibility projection, explicit compatibility actuation delegated to native owners, migration quarantine, or obsolete authority. Delete any route-local policy/decision logic or implicit trigger; preserve only named external client contracts that delegate directly to native services.
next_action: Audit actual client consumers of the remaining `ThreadEpiphany*` app-server routes. Preserve routes only where a named Codex/Aquarium client contract still exists; mark unconsumed routes for deletion rather than keeping an immortal compatibility API. For retained routes, verify request-to-native-delegate-to-projection flow end to end without route-local policy.

View file

@ -4,6 +4,8 @@ mod command_routes;
mod epiphany_mutation_routes;
mod epiphany_read_routes;
mod epiphany_thread_host;
#[cfg(test)]
mod epiphany_compatibility_architecture;
mod listener_lifecycle;
mod legacy_epiphany_rollout;
mod mcp_routes;

View file

@ -0,0 +1,61 @@
#[test]
fn mutation_routes_are_explicit_compatibility_delegates() {
let source = include_str!("epiphany_mutation_routes.rs");
for delegate in [
"launch_thread_epiphany_role(",
"apply_thread_epiphany_role_accept(",
"launch_thread_epiphany_reorient(",
"apply_thread_epiphany_reorient_accept(",
"index_epiphany_retrieval_for_paths(",
"apply_thread_epiphany_promote(",
"apply_thread_epiphany_update(",
"launch_thread_epiphany_job(",
"interrupt_thread_epiphany_job(",
] {
assert!(source.contains(delegate), "missing compatibility delegate {delegate}");
}
for forbidden in [
"apply_epiphany_state_update_to_state(",
"acceptance_receipts.push(",
"job_bindings.push(",
"runtime_links.push(",
".steer_input(",
".submit(Op::Compact)",
"select_epiphany_coordinator_automation(",
] {
assert!(
!source.contains(forbidden),
"compatibility route regained local authority through {forbidden}"
);
}
}
#[test]
fn read_routes_have_no_mutation_or_scheduler_authority() {
let source = include_str!("epiphany_read_routes.rs");
for forbidden in [
"apply_thread_epiphany_",
"launch_thread_epiphany_",
"interrupt_thread_epiphany_",
"index_epiphany_retrieval_for_paths(",
".steer_input(",
".submit(Op::Compact)",
"select_epiphany_coordinator_automation(",
] {
assert!(
!source.contains(forbidden),
"read route regained actuator authority through {forbidden}"
);
}
}
#[test]
fn compatibility_surface_has_no_implicit_event_loop_trigger() {
let processor = include_str!("../codex_message_processor.rs");
let event_loop = include_str!("../bespoke_event_handling.rs");
let thread_state = include_str!("../thread_state.rs");
assert!(!processor.contains("mod epiphany_automation"));
assert!(!event_loop.contains("maybe_run_epiphany"));
assert!(!thread_state.contains("epiphany_checkpoint_intervention"));
}