diff --git a/epiphany-core/src/bin/epiphany-hands-action.rs b/epiphany-core/src/bin/epiphany-hands-action.rs index f0ca5557..4707cdbb 100644 --- a/epiphany-core/src/bin/epiphany-hands-action.rs +++ b/epiphany-core/src/bin/epiphany-hands-action.rs @@ -15,7 +15,6 @@ use epiphany_core::runtime_hands_action_intent; use epiphany_core::runtime_hands_action_review; use serde_json::json; use std::env; -use std::fs; use std::path::PathBuf; const DEFAULT_STORE: &str = "state/runtime-spine.msgpack"; @@ -50,9 +49,8 @@ enum Command { #[derive(Debug, Clone)] struct GateArgs { - intent_id: Option, - review_id: Option, - gate_summary: Option, + intent_id: String, + review_id: String, receipt_id: Option, summary: String, } @@ -236,23 +234,9 @@ impl ParsedOptions { } fn take_gate(&mut self) -> Result { - let intent_id = self.take_optional("--intent-id"); - let review_id = self.take_optional("--review-id"); - let gate_summary = self.take_optional("--gate-summary").map(PathBuf::from); - if gate_summary.is_none() && (intent_id.is_none() || review_id.is_none()) { - return Err(anyhow!( - "gate requires either --gate-summary or both --intent-id and --review-id" - )); - } - if gate_summary.is_some() && (intent_id.is_some() || review_id.is_some()) { - return Err(anyhow!( - "use either --gate-summary or explicit --intent-id/--review-id, not both" - )); - } Ok(GateArgs { - intent_id, - review_id, - gate_summary, + intent_id: self.take_required("--intent-id")?, + review_id: self.take_required("--review-id")?, receipt_id: self.take_optional("--receipt-id"), summary: self.take_required("--summary")?, }) @@ -426,15 +410,14 @@ fn record_pass(store: &PathBuf, args: RecordPassArgs) -> Result Result { - let resolved = resolve_gate(&args.gate)?; let receipt_id = args .gate .receipt_id .unwrap_or_else(|| generated_receipt_id("hands-refusal")); let receipt = relinquish_repo_frontier_hands_route( store, - &resolved.intent_id, - &resolved.review_id, + &args.gate.intent_id, + &args.gate.review_id, &receipt_id, normalize_paths(args.missing_required_paths), args.gate.summary, @@ -467,13 +450,12 @@ fn load_gate( gate: &GateArgs, operation: &str, ) -> Result<(HandsActionIntent, HandsActionReview)> { - let resolved = resolve_gate(gate)?; - let intent = runtime_hands_action_intent(store, &resolved.intent_id) - .with_context(|| format!("failed to load Hands intent {}", resolved.intent_id))? - .ok_or_else(|| anyhow!("Hands intent {} was not found", resolved.intent_id))?; - let review = runtime_hands_action_review(store, &resolved.review_id) - .with_context(|| format!("failed to load Hands review {}", resolved.review_id))? - .ok_or_else(|| anyhow!("Hands review {} was not found", resolved.review_id))?; + let intent = runtime_hands_action_intent(store, &gate.intent_id) + .with_context(|| format!("failed to load Hands intent {}", gate.intent_id))? + .ok_or_else(|| anyhow!("Hands intent {} was not found", gate.intent_id))?; + let review = runtime_hands_action_review(store, &gate.review_id) + .with_context(|| format!("failed to load Hands review {}", gate.review_id))? + .ok_or_else(|| anyhow!("Hands review {} was not found", gate.review_id))?; if review.intent_id != intent.intent_id { return Err(anyhow!( "Hands review {} belongs to intent {}, not {}", @@ -502,56 +484,6 @@ fn load_gate( Ok((intent, review)) } -#[derive(Debug)] -struct ResolvedGate { - intent_id: String, - review_id: String, -} - -fn resolve_gate(gate: &GateArgs) -> Result { - if let Some(summary_path) = &gate.gate_summary { - return resolve_gate_from_summary(summary_path); - } - Ok(ResolvedGate { - intent_id: gate - .intent_id - .clone() - .ok_or_else(|| anyhow!("--intent-id is required"))?, - review_id: gate - .review_id - .clone() - .ok_or_else(|| anyhow!("--review-id is required"))?, - }) -} - -fn resolve_gate_from_summary(path: &PathBuf) -> Result { - let text = fs::read_to_string(path) - .with_context(|| format!("failed to read coordinator summary {}", path.display()))?; - let value: serde_json::Value = serde_json::from_str(&text) - .with_context(|| format!("failed to parse coordinator summary {}", path.display()))?; - let gate = value - .pointer("/finalAction/handsActionGate") - .or_else(|| value.pointer("/handsActionGate")) - .ok_or_else(|| { - anyhow!( - "{} does not contain finalAction.handsActionGate", - path.display() - ) - })?; - let intent_id = gate - .get("intentId") - .and_then(serde_json::Value::as_str) - .ok_or_else(|| anyhow!("handsActionGate is missing intentId"))?; - let review_id = gate - .get("reviewId") - .and_then(serde_json::Value::as_str) - .ok_or_else(|| anyhow!("handsActionGate is missing reviewId"))?; - Ok(ResolvedGate { - intent_id: intent_id.to_string(), - review_id: review_id.to_string(), - }) -} - fn validate_paths_within_gate(intent: &HandsActionIntent, paths: &[String]) -> Result<()> { let requested = normalize_paths(intent.requested_paths.clone()); if requested.iter().any(|path| path == ".") { @@ -626,7 +558,7 @@ fn take_value(tokens: &mut impl Iterator, name: &str) -> Result &'static str { - "usage: epiphany-hands-action [--store path] (--gate-summary path | --intent-id id --review-id id) --summary text ..." + "usage: epiphany-hands-action [--store path] --intent-id id --review-id id --summary text ..." } #[cfg(test)] @@ -649,7 +581,6 @@ mod tests { use epiphany_core::runtime_hands_command_receipt; use epiphany_core::runtime_hands_commit_receipt; use epiphany_core::runtime_hands_patch_receipt; - use epiphany_core::runtime_latest_hands_receipt_chain_after; use epiphany_core::select_and_commit_repo_frontier_route; use epiphany_state_model::EpiphanyMemoryDomain; use epiphany_state_model::EpiphanyMemoryLifecycle; @@ -701,81 +632,6 @@ mod tests { Ok(()) } - #[test] - fn record_pass_can_load_gate_from_coordinator_summary() -> Result<()> { - let temp = tempfile::tempdir()?; - let store = temp.path().join("runtime-spine.msgpack"); - seed_gate(&store, vec!["src".to_string()])?; - let summary_path = temp.path().join("coordinator-summary.json"); - fs::write( - &summary_path, - serde_json::to_string_pretty(&json!({ - "finalAction": { - "handsActionGate": { - "intentId": "hands-intent-test", - "reviewId": "hands-review-test" - } - } - }))?, - )?; - - let result = record_pass( - &store, - RecordPassArgs { - gate: GateArgs { - intent_id: None, - review_id: None, - gate_summary: Some(summary_path), - receipt_id: None, - summary: "implementation pass".to_string(), - }, - command: "cargo test".to_string(), - exit_code: "0".to_string(), - stdout_artifact: ".epiphany/stdout.log".to_string(), - stderr_artifact: ".epiphany/stderr.log".to_string(), - commit_sha: "def456".to_string(), - branch: "codex/test".to_string(), - changed_paths: vec!["src/lib.rs".to_string()], - validate_commit_sha: false, - }, - )?; - - let patch_id = result - .pointer("/patch/receiptId") - .and_then(serde_json::Value::as_str) - .expect("record-pass should emit patch receipt id"); - let command_id = result - .pointer("/command/receiptId") - .and_then(serde_json::Value::as_str) - .expect("record-pass should emit command receipt id"); - let commit_id = result - .pointer("/commit/receiptId") - .and_then(serde_json::Value::as_str) - .expect("record-pass should emit commit receipt id"); - assert!(runtime_hands_patch_receipt(&store, patch_id)?.is_some()); - assert!(runtime_hands_command_receipt(&store, command_id)?.is_some()); - assert!(runtime_hands_commit_receipt(&store, commit_id)?.is_some()); - - let chain = runtime_latest_hands_receipt_chain_after(&store, "2026-06-02T00:00:02Z")? - .expect("record-pass should produce a complete Hands receipt chain"); - assert_eq!(chain.patch_receipt_id, patch_id); - assert_eq!(chain.command_receipt_id, command_id); - assert_eq!(chain.commit_receipt_id, commit_id); - assert_eq!(chain.intent_id, "hands-intent-test"); - assert_eq!(chain.review_id, "hands-review-test"); - assert_eq!(chain.runtime_job_id, "hands-job-test"); - assert_eq!( - chain.substrate_gate_grant_receipt_id, - "substrate-grant-test" - ); - assert_eq!(chain.command, "cargo test"); - assert_eq!(chain.exit_code, "0"); - assert_eq!(chain.commit_sha, "def456"); - assert_eq!(chain.changed_paths, vec!["src/lib.rs".to_string()]); - - Ok(()) - } - #[test] fn refuses_commit_receipt_for_unknown_git_sha() -> Result<()> { let temp = tempfile::tempdir()?; @@ -845,7 +701,6 @@ mod tests { "patch".to_string(), "command".to_string(), "commit".to_string(), - "pr".to_string(), ], ) } @@ -868,8 +723,8 @@ mod tests { .ok_or_else(|| anyhow!("Hands test store has no fixture root"))?; let body_store = fixture_root.join("body.cc"); let repo = fixture_root.join("workspace"); - fs::create_dir_all(repo.join("src"))?; - fs::write(repo.join("src/lib.rs"), "pub fn fixture() {}\n")?; + std::fs::create_dir_all(repo.join("src"))?; + std::fs::write(repo.join("src/lib.rs"), "pub fn fixture() {}\n")?; let git = ProcessCommand::new("git") .args(["init", "-q"]) .current_dir(&repo) @@ -1020,9 +875,8 @@ mod tests { fn gate_args(receipt_id: &str) -> GateArgs { GateArgs { - intent_id: Some("hands-intent-test".to_string()), - review_id: Some("hands-review-test".to_string()), - gate_summary: None, + intent_id: "hands-intent-test".to_string(), + review_id: "hands-review-test".to_string(), receipt_id: Some(receipt_id.to_string()), summary: "test receipt".to_string(), } diff --git a/epiphany-core/src/bin/epiphany-mvp-coordinator.rs b/epiphany-core/src/bin/epiphany-mvp-coordinator.rs index 4fa56ab0..14c112d6 100644 --- a/epiphany-core/src/bin/epiphany-mvp-coordinator.rs +++ b/epiphany-core/src/bin/epiphany-mvp-coordinator.rs @@ -998,7 +998,6 @@ fn run_coordinator(args: &Args) -> Result { "continueImplementation" => { let gate = record_hands_implementation_gate( &runtime_store, - &artifact_dir, &thread_id, index, &status, @@ -1590,7 +1589,6 @@ fn resolve_model_runtime_bin(root: &Path, configured: &Path) -> Result fn record_hands_implementation_gate( runtime_store: &Path, - artifact_dir: &Path, thread_id: &str, step_index: usize, _status: &Value, @@ -1706,14 +1704,20 @@ fn record_hands_implementation_gate( "plannedStopConditions": route.adopted_plan.as_ref().map(|plan| plan.stop_conditions.as_slice()), "plannedRollbackSteps": route.adopted_plan.as_ref().map(|plan| plan.rollback_steps.as_slice()), "plannedCommitMessage": route.adopted_plan.as_ref().map(|plan| plan.commit_message.as_str()), - "recordPassCommand": hands_record_pass_command(runtime_store, artifact_dir, route.adopted_plan.as_ref()), + "recordPassCommand": hands_record_pass_command( + runtime_store, + &intent.intent_id, + &review.review_id, + route.adopted_plan.as_ref(), + ), "store": runtime_store, })) } fn hands_record_pass_command( runtime_store: &Path, - artifact_dir: &Path, + intent_id: &str, + review_id: &str, adopted_plan: Option<&epiphany_core::RepoFrontierAdoptedPlan>, ) -> Value { json!({ @@ -1722,8 +1726,10 @@ fn hands_record_pass_command( "--store", runtime_store, "record-pass", - "--gate-summary", - artifact_dir.join("coordinator-summary.json"), + "--intent-id", + intent_id, + "--review-id", + review_id, "--summary", "", "--changed-path", diff --git a/epiphany-core/src/hands_gateway.rs b/epiphany-core/src/hands_gateway.rs index 9f019787..68c3e6e7 100644 --- a/epiphany-core/src/hands_gateway.rs +++ b/epiphany-core/src/hands_gateway.rs @@ -5,14 +5,12 @@ pub const HANDS_ACTION_REVIEW_TYPE: &str = "epiphany.hands.action_review"; pub const HANDS_COMMAND_RECEIPT_TYPE: &str = "epiphany.hands.command_receipt"; pub const HANDS_PATCH_RECEIPT_TYPE: &str = "epiphany.hands.patch_receipt"; pub const HANDS_COMMIT_RECEIPT_TYPE: &str = "epiphany.hands.commit_receipt"; -pub const HANDS_ROLLBACK_RECEIPT_TYPE: &str = "epiphany.hands.rollback_receipt"; pub const HANDS_ACTION_REFUSAL_RECEIPT_TYPE: &str = "epiphany.hands.action_refusal_receipt"; pub const HANDS_ACTION_INTENT_SCHEMA_VERSION: &str = "epiphany.hands.action_intent.v1"; pub const HANDS_ACTION_REVIEW_SCHEMA_VERSION: &str = "epiphany.hands.action_review.v0"; pub const HANDS_COMMAND_RECEIPT_SCHEMA_VERSION: &str = "epiphany.hands.command_receipt.v0"; pub const HANDS_PATCH_RECEIPT_SCHEMA_VERSION: &str = "epiphany.hands.patch_receipt.v0"; pub const HANDS_COMMIT_RECEIPT_SCHEMA_VERSION: &str = "epiphany.hands.commit_receipt.v0"; -pub const HANDS_ROLLBACK_RECEIPT_SCHEMA_VERSION: &str = "epiphany.hands.rollback_receipt.v0"; pub const HANDS_ACTION_REFUSAL_RECEIPT_SCHEMA_VERSION: &str = "epiphany.hands.action_refusal_receipt.v1"; pub const HANDS_ACTION_REFUSAL_RECEIPT_CONTRACT: &str = "epiphany.hands.action_refusal.v1"; diff --git a/epiphany-core/src/runtime_spine.rs b/epiphany-core/src/runtime_spine.rs index 2063bf17..5ca3aeed 100644 --- a/epiphany-core/src/runtime_spine.rs +++ b/epiphany-core/src/runtime_spine.rs @@ -13286,7 +13286,6 @@ fn epiphany_mutation_contracts() -> Vec { HANDS_COMMAND_RECEIPT_TYPE, HANDS_PATCH_RECEIPT_TYPE, HANDS_COMMIT_RECEIPT_TYPE, - HANDS_ROLLBACK_RECEIPT_TYPE, HANDS_ACTION_REFUSAL_RECEIPT_TYPE, ], vec![ @@ -13342,18 +13341,6 @@ fn epiphany_mutation_contracts() -> Vec { vec![], vec!["Commit receipts preserve repository consequences after verification."], ), - mutation_contract( - HANDS_ROLLBACK_RECEIPT_TYPE, - HANDS_ROLLBACK_RECEIPT_SCHEMA_VERSION, - vec![ - CultNetDocumentOperation::Snapshot, - CultNetDocumentOperation::ReceiptWatch, - ], - CultNetMutationAuthority::ReadOnly, - vec![], - vec![], - vec!["Rollback receipts prove failed action was unwound instead of hidden."], - ), mutation_contract( HANDS_ACTION_REFUSAL_RECEIPT_TYPE, HANDS_ACTION_REFUSAL_RECEIPT_SCHEMA_VERSION, diff --git a/notes/hands-cultnet-contracts.md b/notes/hands-cultnet-contracts.md index 9b3b97c6..7c7a8ccd 100644 --- a/notes/hands-cultnet-contracts.md +++ b/notes/hands-cultnet-contracts.md @@ -1,8 +1,8 @@ # Hands CultNet Contracts -Objective: make Hands the action organ. Commands, patches, commits, and -rollbacks are consequences, not thoughts. They enter as bounded action intents -and leave receipts that can be verified, refused, or admitted into Mind state. +Objective: make Hands the action organ. Commands, patches, and commits are +consequences, not thoughts. They enter as bounded action intents and leave +receipts that can be verified or admitted into Mind state. ## Authority Map @@ -11,15 +11,15 @@ and leave receipts that can be verified, refused, or admitted into Mind state. patches, current repo policy, Soul verification requirements, and coordinator authority. - Outputs: Hands action reviews, command receipts, patch receipts, commit - receipts, rollback receipts, and action refusal receipts. -- Derived state: diffs, command logs, commits, and rollback notes are - action receipts. They are not durable Mind state until Mind admits them. + receipts, and action refusal receipts. +- Derived state: diffs, command logs, and commits are action receipts. They are + not durable Mind state until Mind admits them. - Forbidden writers: raw workers, Persona, Eyes, Imagination, Self, compatibility JSON-RPC routes, and bridge tools must not execute repo-affecting commands, - edit files, commit, publish, or roll back without the Hands path after Body + edit files, commit, or publish without the Hands path after Body access. -- Shared path: file edits, shell commands, commits, and rollbacks should - share Hands action intent/review/receipt semantics. +- Shared path: file edits, shell commands, and commits share Hands action + intent/review/receipt semantics. - Deletion line: Substrate Gate grants access; it does not execute. Soul verifies; it does not execute. Mind records durable state; it does not execute. @@ -30,14 +30,15 @@ and leave receipts that can be verified, refused, or admitted into Mind state. - `epiphany.hands.command_receipt`: proof of command execution. - `epiphany.hands.patch_receipt`: proof of file mutation. - `epiphany.hands.commit_receipt`: proof of commit creation. -- `epiphany.hands.rollback_receipt`: proof that failed action was unwound. - `epiphany.hands.action_refusal_receipt`: proof that Hands refused to act. ## Neighboring Gates -Substrate Gate grants substrate access before Hands touches the repo. Eyes packages -evidence for action reasoning. Soul verifies action results and invariants. -Mind admits durable state after the action and verification receipts exist. +Substrate Gate grants substrate access before Hands touches the repo. Hands +consumes the adopted plan and exact current route directly. Eyes is requested +only when that reasoning needs evidence outside the Body. Soul verifies action +results and invariants. Mind admits durable state after the action and +verification receipts exist. Hands is not a permission organ. It is the actuator. The wrench does not bless itself.