From 46369aef63ef455b9a9a6d4f8e22fb1b731014b7 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 12 Jun 2026 12:08:14 +0100 Subject: [PATCH] Add Hands consequence receipt recorder --- .../src/bin/epiphany-hands-action.rs | 540 ++++++++++++++++++ notes/fresh-workspace-handoff.md | 6 +- notes/hands-cultnet-contracts.md | 10 +- state/ledgers.msgpack | Bin 175419 -> 175745 bytes state/map.yaml | 4 +- tools/epiphany_local_run.ps1 | 4 +- 6 files changed, 555 insertions(+), 9 deletions(-) create mode 100644 epiphany-core/src/bin/epiphany-hands-action.rs diff --git a/epiphany-core/src/bin/epiphany-hands-action.rs b/epiphany-core/src/bin/epiphany-hands-action.rs new file mode 100644 index 00000000..c20bb4bd --- /dev/null +++ b/epiphany-core/src/bin/epiphany-hands-action.rs @@ -0,0 +1,540 @@ +use anyhow::Context; +use anyhow::Result; +use anyhow::anyhow; +use chrono::SecondsFormat; +use epiphany_core::HandsActionIntent; +use epiphany_core::HandsActionReview; +use epiphany_core::hands_command_receipt_for_review; +use epiphany_core::hands_commit_receipt_for_review; +use epiphany_core::hands_patch_receipt_for_review; +use epiphany_core::put_hands_command_receipt; +use epiphany_core::put_hands_commit_receipt; +use epiphany_core::put_hands_patch_receipt; +use epiphany_core::runtime_hands_action_intent; +use epiphany_core::runtime_hands_action_review; +use serde_json::json; +use std::env; +use std::path::PathBuf; + +const DEFAULT_STORE: &str = "state/runtime-spine.msgpack"; + +fn main() -> Result<()> { + let args = Args::parse()?; + let output = match args.command { + Command::RecordPatch(command) => record_patch(&args.store, command)?, + Command::RecordCommand(command) => record_command(&args.store, command)?, + Command::RecordCommit(command) => record_commit(&args.store, command)?, + }; + println!("{}", serde_json::to_string_pretty(&output)?); + Ok(()) +} + +#[derive(Debug)] +struct Args { + store: PathBuf, + command: Command, +} + +#[derive(Debug)] +enum Command { + RecordPatch(RecordPatchArgs), + RecordCommand(RecordCommandArgs), + RecordCommit(RecordCommitArgs), +} + +#[derive(Debug)] +struct GateArgs { + intent_id: String, + review_id: String, + receipt_id: Option, + summary: String, +} + +#[derive(Debug)] +struct RecordPatchArgs { + gate: GateArgs, + changed_paths: Vec, +} + +#[derive(Debug)] +struct RecordCommandArgs { + gate: GateArgs, + command: String, + exit_code: String, + stdout_artifact: String, + stderr_artifact: String, +} + +#[derive(Debug)] +struct RecordCommitArgs { + gate: GateArgs, + commit_sha: String, + branch: String, + changed_paths: Vec, +} + +impl Args { + fn parse() -> Result { + let mut tokens = env::args().skip(1).peekable(); + let mut store = PathBuf::from(DEFAULT_STORE); + while matches!(tokens.peek().map(String::as_str), Some("--store")) { + tokens.next(); + store = PathBuf::from(take_value(&mut tokens, "--store")?); + } + let command_name = tokens.next().ok_or_else(|| anyhow!("{}", usage()))?; + let command = match command_name.as_str() { + "record-patch" => Command::RecordPatch(parse_record_patch(tokens)?), + "record-command" => Command::RecordCommand(parse_record_command(tokens)?), + "record-commit" => Command::RecordCommit(parse_record_commit(tokens)?), + _ => return Err(anyhow!("unknown command {command_name}\n{}", usage())), + }; + Ok(Self { store, command }) + } +} + +fn parse_record_patch(tokens: impl Iterator) -> Result { + let mut options = ParsedOptions::parse(tokens)?; + let gate = options.take_gate()?; + let changed_paths = options.take_many("--changed-path"); + options.finish()?; + if changed_paths.is_empty() { + return Err(anyhow!("record-patch requires at least one --changed-path")); + } + Ok(RecordPatchArgs { + gate, + changed_paths, + }) +} + +fn parse_record_command(tokens: impl Iterator) -> Result { + let mut options = ParsedOptions::parse(tokens)?; + let gate = options.take_gate()?; + let command = options.take_required("--command")?; + let exit_code = options.take_required("--exit-code")?; + let stdout_artifact = options.take_required("--stdout-artifact")?; + let stderr_artifact = options.take_required("--stderr-artifact")?; + options.finish()?; + Ok(RecordCommandArgs { + gate, + command, + exit_code, + stdout_artifact, + stderr_artifact, + }) +} + +fn parse_record_commit(tokens: impl Iterator) -> Result { + let mut options = ParsedOptions::parse(tokens)?; + let gate = options.take_gate()?; + let commit_sha = options.take_required("--commit-sha")?; + let branch = options.take_required("--branch")?; + let changed_paths = options.take_many("--changed-path"); + options.finish()?; + if changed_paths.is_empty() { + return Err(anyhow!( + "record-commit requires at least one --changed-path" + )); + } + Ok(RecordCommitArgs { + gate, + commit_sha, + branch, + changed_paths, + }) +} + +#[derive(Debug, Default)] +struct ParsedOptions { + values: Vec<(String, String)>, +} + +impl ParsedOptions { + fn parse(tokens: impl Iterator) -> Result { + let mut values = Vec::new(); + let mut tokens = tokens.peekable(); + while let Some(name) = tokens.next() { + if !name.starts_with("--") { + return Err(anyhow!("unexpected positional argument {name}")); + } + let value = take_value(&mut tokens, &name)?; + values.push((name, value)); + } + Ok(Self { values }) + } + + fn take_gate(&mut self) -> Result { + Ok(GateArgs { + 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")?, + }) + } + + fn take_required(&mut self, name: &str) -> Result { + self.take_optional(name) + .ok_or_else(|| anyhow!("{name} is required")) + } + + fn take_optional(&mut self, name: &str) -> Option { + let index = self + .values + .iter() + .position(|(candidate, _)| candidate == name)?; + Some(self.values.remove(index).1) + } + + fn take_many(&mut self, name: &str) -> Vec { + let mut taken = Vec::new(); + let mut index = 0; + while index < self.values.len() { + if self.values[index].0 == name { + taken.push(self.values.remove(index).1); + } else { + index += 1; + } + } + taken + } + + fn finish(self) -> Result<()> { + if self.values.is_empty() { + return Ok(()); + } + let names: Vec<_> = self.values.into_iter().map(|(name, _)| name).collect(); + Err(anyhow!("unsupported arguments: {}", names.join(", "))) + } +} + +fn record_patch(store: &PathBuf, args: RecordPatchArgs) -> Result { + let (intent, review) = load_gate(store, &args.gate, "patch")?; + validate_paths_within_gate(&intent, &args.changed_paths)?; + let receipt_id = args + .gate + .receipt_id + .unwrap_or_else(|| generated_receipt_id("hands-patch")); + let receipt = hands_patch_receipt_for_review( + receipt_id, + &intent, + &review, + normalize_paths(args.changed_paths), + args.gate.summary, + now(), + ); + put_hands_patch_receipt(store, &receipt)?; + Ok(json!({ + "status": "ok", + "type": "epiphany.hands.patch_receipt", + "receiptId": receipt.receipt_id, + "intentId": receipt.intent_id, + "reviewId": receipt.review_id, + "changedPaths": receipt.changed_paths, + "store": store, + })) +} + +fn record_command(store: &PathBuf, args: RecordCommandArgs) -> Result { + let (intent, review) = load_gate(store, &args.gate, "command")?; + let receipt_id = args + .gate + .receipt_id + .unwrap_or_else(|| generated_receipt_id("hands-command")); + let receipt = hands_command_receipt_for_review( + receipt_id, + &intent, + &review, + args.command, + args.exit_code, + normalize_path(&args.stdout_artifact), + normalize_path(&args.stderr_artifact), + args.gate.summary, + now(), + ); + put_hands_command_receipt(store, &receipt)?; + Ok(json!({ + "status": "ok", + "type": "epiphany.hands.command_receipt", + "receiptId": receipt.receipt_id, + "intentId": receipt.intent_id, + "reviewId": receipt.review_id, + "command": receipt.command, + "exitCode": receipt.exit_code, + "stdoutArtifact": receipt.stdout_artifact, + "stderrArtifact": receipt.stderr_artifact, + "store": store, + })) +} + +fn record_commit(store: &PathBuf, args: RecordCommitArgs) -> Result { + let (intent, review) = load_gate(store, &args.gate, "commit")?; + validate_paths_within_gate(&intent, &args.changed_paths)?; + let receipt_id = args + .gate + .receipt_id + .unwrap_or_else(|| generated_receipt_id("hands-commit")); + let receipt = hands_commit_receipt_for_review( + receipt_id, + &intent, + &review, + args.commit_sha, + args.branch, + normalize_paths(args.changed_paths), + args.gate.summary, + now(), + ); + put_hands_commit_receipt(store, &receipt)?; + Ok(json!({ + "status": "ok", + "type": "epiphany.hands.commit_receipt", + "receiptId": receipt.receipt_id, + "intentId": receipt.intent_id, + "reviewId": receipt.review_id, + "commitSha": receipt.commit_sha, + "branch": receipt.branch, + "changedPaths": receipt.changed_paths, + "store": store, + })) +} + +fn load_gate( + store: &PathBuf, + gate: &GateArgs, + operation: &str, +) -> Result<(HandsActionIntent, HandsActionReview)> { + 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 {}", + review.review_id, + review.intent_id, + intent.intent_id + )); + } + if review.decision != "approved" { + return Err(anyhow!( + "Hands review {} decision is {}, not approved", + review.review_id, + review.decision + )); + } + if !review + .allowed_operations + .iter() + .any(|allowed| allowed == operation) + { + return Err(anyhow!( + "Hands review {} does not allow {operation}", + review.review_id + )); + } + Ok((intent, review)) +} + +fn validate_paths_within_gate(intent: &HandsActionIntent, paths: &[String]) -> Result<()> { + let requested = normalize_paths(intent.requested_paths.clone()); + if requested.iter().any(|path| path == ".") { + return Ok(()); + } + for path in normalize_paths(paths.to_vec()) { + if !requested + .iter() + .any(|allowed| path == *allowed || path.starts_with(&format!("{allowed}/"))) + { + return Err(anyhow!( + "changed path {path} is outside Hands requested paths: {}", + requested.join(", ") + )); + } + } + Ok(()) +} + +fn normalize_paths(paths: Vec) -> Vec { + let mut normalized: Vec<_> = paths + .into_iter() + .map(|path| normalize_path(&path)) + .filter(|path| !path.is_empty()) + .collect(); + normalized.sort(); + normalized.dedup(); + normalized +} + +fn normalize_path(path: &str) -> String { + path.trim().replace('\\', "/") +} + +fn generated_receipt_id(prefix: &str) -> String { + format!("{prefix}-{}", uuid::Uuid::new_v4()) +} + +fn now() -> String { + chrono::Utc::now().to_rfc3339_opts(SecondsFormat::Secs, true) +} + +fn take_value(tokens: &mut impl Iterator, name: &str) -> Result { + tokens + .next() + .ok_or_else(|| anyhow!("{name} requires a value")) +} + +fn usage() -> &'static str { + "usage: epiphany-hands-action [--store path] --intent-id id --review-id id --summary text ..." +} + +#[cfg(test)] +mod tests { + use super::*; + use epiphany_core::HANDS_ACTION_INTENT_SCHEMA_VERSION; + use epiphany_core::RuntimeSpineInitOptions; + use epiphany_core::hands_action_review_for_intent; + use epiphany_core::initialize_runtime_spine; + use epiphany_core::put_hands_action_intent; + use epiphany_core::put_hands_action_review; + use epiphany_core::runtime_hands_command_receipt; + use epiphany_core::runtime_hands_commit_receipt; + use epiphany_core::runtime_hands_patch_receipt; + + #[test] + fn records_patch_command_and_commit_receipts_against_approved_gate() -> Result<()> { + let temp = tempfile::tempdir()?; + let store = temp.path().join("runtime-spine.msgpack"); + seed_gate(&store, vec!["src".to_string()])?; + + record_patch( + &store, + RecordPatchArgs { + gate: gate_args("hands-patch-test"), + changed_paths: vec!["src/lib.rs".to_string()], + }, + )?; + record_command( + &store, + RecordCommandArgs { + gate: gate_args("hands-command-test"), + command: "cargo test".to_string(), + exit_code: "0".to_string(), + stdout_artifact: ".epiphany/stdout.log".to_string(), + stderr_artifact: ".epiphany/stderr.log".to_string(), + }, + )?; + record_commit( + &store, + RecordCommitArgs { + gate: gate_args("hands-commit-test"), + commit_sha: "abc123".to_string(), + branch: "codex/test".to_string(), + changed_paths: vec!["src/lib.rs".to_string()], + }, + )?; + + assert!(runtime_hands_patch_receipt(&store, "hands-patch-test")?.is_some()); + assert!(runtime_hands_command_receipt(&store, "hands-command-test")?.is_some()); + assert!(runtime_hands_commit_receipt(&store, "hands-commit-test")?.is_some()); + Ok(()) + } + + #[test] + fn refuses_patch_receipt_outside_requested_paths() -> Result<()> { + let temp = tempfile::tempdir()?; + let store = temp.path().join("runtime-spine.msgpack"); + seed_gate(&store, vec!["src".to_string()])?; + + let result = record_patch( + &store, + RecordPatchArgs { + gate: gate_args("hands-patch-test"), + changed_paths: vec!["notes/other.md".to_string()], + }, + ); + + assert!(result.is_err()); + Ok(()) + } + + #[test] + fn refuses_command_when_review_does_not_allow_operation() -> Result<()> { + let temp = tempfile::tempdir()?; + let store = temp.path().join("runtime-spine.msgpack"); + seed_gate_with_operations(&store, vec![".".to_string()], vec!["patch".to_string()])?; + + let result = record_command( + &store, + RecordCommandArgs { + gate: gate_args("hands-command-test"), + command: "cargo test".to_string(), + exit_code: "0".to_string(), + stdout_artifact: ".epiphany/stdout.log".to_string(), + stderr_artifact: ".epiphany/stderr.log".to_string(), + }, + ); + + assert!(result.is_err()); + Ok(()) + } + + fn seed_gate(store: &PathBuf, requested_paths: Vec) -> Result<()> { + seed_gate_with_operations( + store, + requested_paths, + vec![ + "patch".to_string(), + "command".to_string(), + "commit".to_string(), + ], + ) + } + + fn seed_gate_with_operations( + store: &PathBuf, + requested_paths: Vec, + operations: Vec, + ) -> Result<()> { + initialize_runtime_spine( + store, + RuntimeSpineInitOptions { + runtime_id: "epiphany-hands-action-test".to_string(), + display_name: "Epiphany Hands Action Test".to_string(), + created_at: "2026-06-02T00:00:00Z".to_string(), + }, + )?; + let intent = HandsActionIntent { + schema_version: HANDS_ACTION_INTENT_SCHEMA_VERSION.to_string(), + intent_id: "hands-intent-test".to_string(), + runtime_job_id: "hands-job-test".to_string(), + binding_id: "implementation-worker".to_string(), + role: "epiphany-hands".to_string(), + authority_scope: "epiphany.role.implementation".to_string(), + requested_action: "continueImplementation".to_string(), + requested_paths, + substrate_gate_grant_receipt_id: "substrate-grant-test".to_string(), + requested_at: "2026-06-02T00:00:01Z".to_string(), + contract: "Test Hands intent.".to_string(), + }; + put_hands_action_intent(store, &intent)?; + let review = hands_action_review_for_intent( + "hands-review-test".to_string(), + &intent, + "approved".to_string(), + operations, + vec!["test gate".to_string()], + "2026-06-02T00:00:02Z".to_string(), + ); + put_hands_action_review(store, &review)?; + Ok(()) + } + + fn gate_args(receipt_id: &str) -> GateArgs { + GateArgs { + 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/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index ed7bc5eb..d1448201 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -35,7 +35,7 @@ remembers doctrine; the branch remembers the blade. - Do not copy exact branch or HEAD from this note. Run `git status --short --branch` and `git log --oneline -5`. - Canonical anatomy now lives in `notes/epiphany-anatomy.md`. Embodied sub-agents are Self, Face, Imagination, Eyes, Proprioception, Hands, and Soul. Body, Mind, Continuity, and Substrate Gate are substrate/state/protocol surfaces, not sub-agent identities. State is split by layer: `work_organ` for resident Epiphany sub-agents, `persona` for portable public/person-shaped state shared by Epiphany Face, VoidBot repo Faces, and Ghostlight characters, and heartbeat/swarm state for scheduling and coordination physiology. Persona state now carries provenance, required public presentation, `date-time` timestamps, typed `candidateActions`, strict anchored thoughts with non-authoritative extensions, custom enum companion labels, and typed affect records for bonds/status reads/doctrine stances. - The repo now has a one-command local operator path: `.\tools\epiphany_local_run.ps1`. Default mode is `smoke`; it builds the retained Codex app-server compatibility edge, builds native Epiphany operator binaries, runs the coordinator smoke, and writes launcher artifacts under `.epiphany-run/` plus coordinator artifacts under `.epiphany-dogfood/`. `-Mode status` is now Epiphany-native: it builds only Epiphany operator binaries, reads `state/thread-state.msgpack` when present, derives status through `epiphany-core`, and does not start or require `codex-app-server`. Use `-Mode plan` or `-Mode run -MaxSteps 4` for the raw bridge-equipped coordinator entrypoints; use `-Mode mvp -FaceInput "" -MaxSteps 4` for the local product cycle that projects Face's character turn, writes a Face/Aquarium bubble, bootstraps a minimal local checkpoint for fresh threads, runs the coordinator with auto-tools, then runs heartbeat sleep/dream maintenance. Live plan/run/mvp modes use the workspace `state/runtime-spine.msgpack`, because CodexThread launch writes worker requests there; the run bundle remains artifact evidence, not runtime lifecycle authority. Add `-ThreadId ` and `-Workspace ` to inspect or continue an existing thread. `status`, `plan`, and `smoke` do not spend model calls; `run` and `mvp` build and use `epiphany-openai-runtime`. Coordinator workers now launch detached and are polled through runtime-spine instead of blocking the coordinator. MVP runs are non-ephemeral by default so `-ThreadId ` can resume and poll later. `-MaxRuntimeSeconds ` is passed into worker runtime; timeout writes a failed worker receipt and exits. Failed modeling now blocks downstream verification until the failed result is reviewed. -- Current Mom-ready status: the normal MVP pass reaches Face -> coordinator -> detached runtime -> heartbeat sleep, and modeling workers now complete through the ChatGPT subscription transport. The first failure was a stack of violated observability/runtime invariants: worker prompts prepended the whole shared persistent-memory rite, Responses frame liveness was invisible until completion, and the runtime tried to persist hundreds of text deltas before completing the worker job. Role/reorient workers now get a compact Epiphany worker boundary instead of full persistent memory; runtime-spine records sampled raw Responses frame kinds with small previews; contiguous reasoning/text deltas compact before durable storage; and live proofs completed `2fe38dcd-d99e-4c73-9a58-afcc81f851c7`, `241e3851-e3ea-4877-a63b-0d2bbd96a7e2`, and `85149a26-6975-403f-ac93-092b717c5825` instead of timing out. The second failure was stale lifecycle authority: completed runtime jobs remained as unresolved `runtime_links`, replacement launches treated historical active links as current, and one bad validation path opened an orphan job before rejecting the state patch. Latest-link-wins is now the runtime-link invariant, terminal links project completed jobs, stale active history cannot veto replacement, launch validation happens before opening runtime jobs, and completed-but-unreviewable modeling findings stop for review instead of relaunching the same lane. The Eyes/source-gather fork is now landed: Research is a fixed Eyes lane with launch/result/accept/status/coordinator/protocol support, and `regather-needed` modeling findings route to `LaunchResearch` instead of relaunching blind Proprioception. Research statePatch admission is Eyes-shaped only: observations, evidence, scratch, and optional investigationCheckpoint; no graph, planning, objective, or checkpoint authority. Mind admission now leaves typed runtime-spine proof: role/reorient acceptance persists `epiphany.mind.gateway_review` before state admission and `epiphany.mind.state_commit_receipt` after admission with the resulting durable revision. Launch contracts now split the broad receipt catalogue from effect-specific proof profiles for state admission, evidence promotion, repo action, verification, and continuity recovery. Research evidence promotion enforces Substrate Gate read/snapshot grant, Eyes evidence packet, and Mind review before state admission; Verification acceptance enforces Soul verdict and Mind review; Reorient acceptance enforces Continuity recovery receipt and Mind review. `epiphany-mvp-coordinator` now records a typed Substrate Gate grant plus Hands intent/review gate when the coordinator selects `continueImplementation`; the next concrete rebuild layer is emitting real patch/command/commit receipts against that gate, or collapsing Mind review/state mutation/commit into one state-admission primitive if that split shows up first. +- Current Mom-ready status: the normal MVP pass reaches Face -> coordinator -> detached runtime -> heartbeat sleep, and modeling workers now complete through the ChatGPT subscription transport. The first failure was a stack of violated observability/runtime invariants: worker prompts prepended the whole shared persistent-memory rite, Responses frame liveness was invisible until completion, and the runtime tried to persist hundreds of text deltas before completing the worker job. Role/reorient workers now get a compact Epiphany worker boundary instead of full persistent memory; runtime-spine records sampled raw Responses frame kinds with small previews; contiguous reasoning/text deltas compact before durable storage; and live proofs completed `2fe38dcd-d99e-4c73-9a58-afcc81f851c7`, `241e3851-e3ea-4877-a63b-0d2bbd96a7e2`, and `85149a26-6975-403f-ac93-092b717c5825` instead of timing out. The second failure was stale lifecycle authority: completed runtime jobs remained as unresolved `runtime_links`, replacement launches treated historical active links as current, and one bad validation path opened an orphan job before rejecting the state patch. Latest-link-wins is now the runtime-link invariant, terminal links project completed jobs, stale active history cannot veto replacement, launch validation happens before opening runtime jobs, and completed-but-unreviewable modeling findings stop for review instead of relaunching the same lane. The Eyes/source-gather fork is now landed: Research is a fixed Eyes lane with launch/result/accept/status/coordinator/protocol support, and `regather-needed` modeling findings route to `LaunchResearch` instead of relaunching blind Proprioception. Research statePatch admission is Eyes-shaped only: observations, evidence, scratch, and optional investigationCheckpoint; no graph, planning, objective, or checkpoint authority. Mind admission now leaves typed runtime-spine proof: role/reorient acceptance persists `epiphany.mind.gateway_review` before state admission and `epiphany.mind.state_commit_receipt` after admission with the resulting durable revision. Launch contracts now split the broad receipt catalogue from effect-specific proof profiles for state admission, evidence promotion, repo action, verification, and continuity recovery. Research evidence promotion enforces Substrate Gate read/snapshot grant, Eyes evidence packet, and Mind review before state admission; Verification acceptance enforces Soul verdict and Mind review; Reorient acceptance enforces Continuity recovery receipt and Mind review. `epiphany-mvp-coordinator` now records a typed Substrate Gate grant plus Hands intent/review gate when the coordinator selects `continueImplementation`; `epiphany-hands-action` records patch/command/commit receipts against that gate and refuses mismatched, unapproved, or out-of-scope consequences. The next concrete rebuild layer is invoking that recorder from the live implementation turn or wrapper before Soul/Mind acceptance. - The investment dossier readiness target is now explicit: `E:\Projects\gamecult-site\docs\gamecult_integrated_dossier.tex` expects Epiphany to be part of a Bifrost-first labor loop, not only a local Mom demo. The external proof bar is: Bifrost owns topics/work items/dispatch packets/receipts/credit/reward pressure; Epiphany executes bounded work; maintainers review artifacts; public/operator evidence records scope, consent, roles, model spend, review load, artifacts, accepted/rejected outcome, memory lessons, and case-study permission; and private worker/operator/agent context stays sealed. Diligence also asks for a live fresh-repo Epiphany demo, Bifrost work item/topic/agent transport/receipt/ledger demo, CultMesh status, VoidBot/Discord swarm demo, compute/output metrics, and security model for secrets/write permissions/public-private exports. - This Codex operator's own roadmap/todo posture has been retuned for this scale target, with the Epiphany Imagination specialist as an optional sub-agent rail rather than the whole point. `notes/epiphany-investor-readiness-roadmap.md` now says: make the local Mom MVP a repeatable proof bundle; build the Bifrost-first external-work bridge; add compute/review/accepted-artifact accounting; prove fresh-repo operation without supervisor contamination; keep public/operator-safe exports sealed; and treat angel capital as fuel for capacity, not command authority. The Imagination specialist prompt was also updated so investor-scale Objective Drafts must name Bifrost provenance, bounded Epiphany proof, maintainer review, receipts/ledger evidence, compute/output metrics, public/private export safety, consent, and legal/security gates. - Local operator runs now write typed CultMesh intent/receipt documents to `.epiphany-run/cultmesh/operator-runs.ccmp` through `epiphany-operator-run`. The wrapper writes intent before acting and a completion receipt after success; this is the local consent/trace rail, not a hidden scheduler queue. @@ -51,7 +51,7 @@ remembers doctrine; the branch remembers the blade. - CultMesh is now the preferred Rust abstraction for that local store work. The compile-time Rust substrate is repo-contained: `vendor/cultcache-rs`, `vendor/cultnet-rs`, and `vendor/cultmesh-rs`. The old `E:\Projects\CultLib\crates\*` dependency body is dead in this checkout and must not be revived by accident. Vendored CultCache reads/writes `cultcache.store.v1`, so `state/ledgers.msgpack` and `epiphany-state status` are aligned again. The first integrations are deliberately small: status, Verse policy, global room policy, organ contract policy, native operator status, native operator snapshots, and local operator run intent/receipt round-trip through CultMesh. `notes/epiphany-verse-architecture.md` now names the local Verse/Odin/Yggdrasil architecture: Odin sees advertised Verse metadata without bypassing boundaries, Yggdrasil hosts important trusted GameCult Verses such as Bifrost, and prompt assembly should query compact local Verse plus semantic memory packets instead of carrying the whole archive. Role/reorient launch documents now have optional `dynamicPromptContext`; runtime prompt assembly consumes that field into worker instructions, `epiphany-prompt-context-smoke` proves a rendered Verse/memory packet is preserved on a role launch document, live bridge role/reorient launches now feed local Verse plus memory graph context from sibling `local-verse.ccmp` and `memory-graph.msgpack` stores beside runtime-spine, and the bridge launch-context test proves the packet survives into a persisted runtime-spine worker launch request. The memory graph refreshes from current typed thread-state repo graphs when absent, so thin state remains visibly thin. Local-run status now has an operator read proof too: `tools/epiphany_local_run.ps1 -Mode status` builds/calls `epiphany-verse-query` and writes `local-verse-context.json` from `.epiphany-run\cultmesh\local-verse.ccmp` beside `status.json` and the operator snapshot. Use `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-cultmesh-smoke`, `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-cultmesh-status -- smoke --store .\.epiphany-smoke\cultmesh\operator-status.ccmp --runtime-id epiphany-cultmesh-status-smoke`, `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-operator-snapshot -- smoke --store .\.epiphany-smoke\cultmesh\operator-snapshots.ccmp --runtime-id epiphany-operator-snapshot-smoke --snapshot-id smoke-status`, `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-operator-run -- smoke --store .\.epiphany-smoke\cultmesh\operator-runs.ccmp --runtime-id epiphany-operator-run-smoke --run-id smoke-run`, `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-verse-query -- smoke`, `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-prompt-context-smoke`, and `.\tools\epiphany_local_run.ps1 -Mode status` for the focused proofs. Future local dream/status/Verse work should start from CultMesh, not raw CultNet, unless the task is polishing the CultMesh internals themselves. Preserve the three Verse tiers: `epiphany-internal` for private sub-agent typed state, `gamecult-local` for trusted LAN/Yggdrasil-tunnel GameCult sharing, and `epiphany-global` for untrusted public dreams plus topic-specific threaded public rooms for Face posts. - `notes/codex-auth-spine-inventory.md` is the source-grounded keeper list for that reliquary. Corrected compliance invariant: Codex-compatible auth identity stays anchored in vendored Codex-derived auth machinery. `epiphany-openai-auth-spine` is now a thin Epiphany-named boundary over `codex-login`, not a clean-room clone of credential storage or token refresh. Codex apps, skills, marketplace, plugin UX, broad app-server workflow, and JSON-RPC sprawl remain cuttable because they are not subscription-auth legitimacy. - Edge JSON is allowed for schema description, hostile ingress before immediate typed parsing, sealed forensic artifacts, or named quarantine experiments. When both subsystems are ours, runtime data must remain typed CultCache documents and move over CultNet typed contracts. Generic `serde_json::Value` in worker launch/result/selfPatch/runtime flow is contamination until classified and replaced. -- Hands now has a first executable action receipt spine. `epiphany-core::hands_gateway` owns `HandsActionIntent`, `HandsActionReview`, `HandsPatchReceipt`, `HandsCommandReceipt`, and `HandsCommitReceipt`; runtime-spine can persist/reread them; `runtime_spine_persists_mind_gateway_review_receipts` includes the Hands chain beside Mind/Eyes/Substrate/Soul/Continuity proofs; `epiphany-hands-action-smoke` emits intent/review/patch/command/commit receipt ids from `.epiphany-smoke\runtime-spine\hands-action-smoke.msgpack`; and the repo-action launch proof profile now requires action intent, action review, and patch receipt together. `epiphany-mvp-coordinator` now turns `continueImplementation` into a persisted Substrate Gate grant plus Hands intent/review gate and includes the receipt ids in the operator step. The next live cut is to route real implementation edits/commands/commits through that chain by emitting the patch, command, and commit receipts after Substrate Gate grants access. +- Hands now has a first executable action receipt spine. `epiphany-core::hands_gateway` owns `HandsActionIntent`, `HandsActionReview`, `HandsPatchReceipt`, `HandsCommandReceipt`, and `HandsCommitReceipt`; runtime-spine can persist/reread them; `runtime_spine_persists_mind_gateway_review_receipts` includes the Hands chain beside Mind/Eyes/Substrate/Soul/Continuity proofs; `epiphany-hands-action-smoke` emits intent/review/patch/command/commit receipt ids from `.epiphany-smoke\runtime-spine\hands-action-smoke.msgpack`; and the repo-action launch proof profile now requires action intent, action review, and patch receipt together. `epiphany-mvp-coordinator` now turns `continueImplementation` into a persisted Substrate Gate grant plus Hands intent/review gate and includes the receipt ids in the operator step. `epiphany-hands-action` is the native consequence recorder for that gate: `record-patch`, `record-command`, and `record-commit` load the stored intent/review, require an approved matching review, enforce allowed operations, and keep patch/commit changed paths inside the requested scope. The next live cut is to call it from the implementation turn or local wrapper after real edits/checks/commit. - `notes/epiphany-swarm-readiness-plan.md` is the current live-fire direction gate. The local runner proves startup/status/coordinator wiring; it does not authorize unattended swarm operation. Carry VoidBot's lessons forward: one CTB-style initiative scheduler, typed pause/brake, active-turn freeze, cooldown after completion, stale active-turn recovery receipts, parent-side speech eligibility, memory lifecycle phases, and typed operation proposals instead of prompt-owned governance. - `epiphany-openai-runtime` worker result ingress now parses assistant output directly into typed role/reorient ingress structs selected from the durable launch document, stores nested `statePatch` and `selfPatch` as typed MessagePack in `EpiphanyRuntimeRoleWorkerResult`, and no longer passes worker result data through generic `serde_json::Value`. JSON survives there only as the OpenAI text-output edge before typed deserialization. - Agent self-memory review/application now has typed `AgentSelfPatch` core APIs. JSON-value selfPatch functions are compatibility wrappers for CLI/artifact ingress; native callers should parse once at the edge and then call `review_agent_self_patch_document` / `apply_agent_self_patch_document`. Role-result self-persistence no longer exports a JSON-value reviewer; the live API is `review_role_self_patch_document`. @@ -188,7 +188,7 @@ remembers doctrine; the branch remembers the blade. - The planning loop is now runtime-backed and operator-visible. Typed captures, backlog items, roadmap streams, Objective Drafts, and GitHub issue source refs live in `EpiphanyThreadState`, validate through revision-gated `thread/epiphany/update`, render into prompts when present, project read-only through the `planning` view lens, render in the GUI Planning panel, can be synthesized by the fixed Imagination/planning lane, and can be explicitly adopted through the artifacted `adoptObjectiveDraft` GUI action. Chat is deliberation, not an objective pipe; ideas and GitHub Issues remain planning state until explicit human adoption. - The bridge/dashboard slice is now landed far enough to test locally. Native `epiphany-rider-bridge` inspects Rider installation, solution, VCS, changed files, and captures file/selection/symbol context into `.epiphany-gui/rider` artifacts; Aquarium has Inspect Rider and renders Rider audit artifacts in Environment; Aquarium also embeds the adjacent EpiphanyGraph viewer over typed `graphs.architecture`, `graphs.dataflow`, and `graphs.links`. - A first Rider plugin scaffold lives under `integrations/rider`: tool window, Refresh status, and Send Context to Epiphany action. It shells through native `epiphany-rider-bridge` and does not own state. `gradle` is not installed on this machine, so the scaffold is not build-verified yet. -- Next real move: exercise a `continueImplementation` coordinator run and emit actual Hands patch/command/commit receipts against the persisted gate, so a live implementation pass cannot be counted as evidence without the action chain. Quarantine Rider/Unity bridge work for now; those artifacts remain optional later environment evidence, not MVP blockers. Keep EpiphanyAgent focused on backend contracts, typed state, coordinator policy, heartbeat scheduling, Face guardrails, prompt-authority separation, and the ongoing purification from Python/JSON scaffolding into Rust/CultCache/CultMesh/CultNet organs. Resume repo birth/Aquarium/Rider/Unity work only when the user explicitly shifts priority back outward. GitHub Issues import is deferred until the backlog source is fresh enough to deserve Imagination's attention. +- Next real move: invoke `epiphany-hands-action` from a `continueImplementation` implementation pass so actual changed paths, focused check artifacts, and commit sha become patch/command/commit receipts against the persisted gate. Quarantine Rider/Unity bridge work for now; those artifacts remain optional later environment evidence, not MVP blockers. Keep EpiphanyAgent focused on backend contracts, typed state, coordinator policy, heartbeat scheduling, Face guardrails, prompt-authority separation, and the ongoing purification from Python/JSON scaffolding into Rust/CultCache/CultMesh/CultNet organs. Resume repo birth/Aquarium/Rider/Unity work only when the user explicitly shifts priority back outward. GitHub Issues import is deferred until the backlog source is fresh enough to deserve Imagination's attention. - The repo is an Epiphany fork of Codex, not a Codex preset. - `vendor/codex` is tracked directly, not a submodule. - `epiphany-core` owns the heavy Epiphany organs where practical. diff --git a/notes/hands-cultnet-contracts.md b/notes/hands-cultnet-contracts.md index f61e9202..eb0a13c9 100644 --- a/notes/hands-cultnet-contracts.md +++ b/notes/hands-cultnet-contracts.md @@ -65,8 +65,12 @@ Hands chain, not only the final patch receipt. `epiphany-mvp-coordinator` now turns `continueImplementation` into a persisted Substrate Gate grant plus Hands intent/review gate and exposes the receipt ids in the operator step. +`epiphany-hands-action` is the first native consequence recorder for that gate: +`record-patch`, `record-command`, and `record-commit` load the stored +intent/review, reject mismatches, require an approved review, enforce allowed +operations, and keep patch/commit changed paths inside the requested scope. This is still a gate and receipt artery, not full action execution. The next -live-action cut must emit actual patch/command/commit receipts against the -persisted gate after Substrate Gate grants access and before Soul/Mind call the -result accepted. +live-action cut must call the recorder from the implementation turn or local +wrapper after real edits/checks/commit and before Soul/Mind call the result +accepted. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 841c4066d96be099c4886bcadfb3950cf2037359..be2efce007792845b5b2e79ca2bc957e43ec94ef 100644 GIT binary patch delta 334 zcmYk1y-LJD5P;pS3(+ahi?dY?P!2NzX5mceb&*WYKm}V6k|-=g|dd5mbX9jrKUNQA-4e(zpU$ z{!@*t2(ldhzNDGWgf50a;s2isV9|Ny1B5e+1?&*udjgdW9>l3onwmm`u-2J|kaHi5 zqpWm59VQMNh3)rX)F;M~jHoKp5@BdIsgfqxs;1C8O?sDpuLvc0Nz52_jT9B^9qvQx TXb(EjriE#(Dv}B1-+ALNak+N= delta 43 zcmZp?%eDI!*9I|0UIQx=BP%20sACLFYa})+GZr#3GBi(RYM;u)xP2-U)3Q|nEKChl diff --git a/state/map.yaml b/state/map.yaml index 0ad1da88..cda44d1b 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -94,7 +94,7 @@ active_subgoals: - Use `notes/hands-cultnet-contracts.md` as the authority map for Hands' CultNet contract surface. Hands is the action organ: commands, patches, commits, PRs, rollbacks, and refusals enter as bounded action intents and receipts after Substrate Gate grants substrate access and before Soul verification/Mind admission. - Use `notes/soul-cultnet-contracts.md` as the authority map for Soul's CultNet contract surface. Soul is the verification organ: invariant checks, verdicts, regressions, reviews, and refusals produce receipts before the machine calls work true, safe, or accepted. - Use `notes/continuity-cultnet-contracts.md` as the authority map for Continuity's CultNet contract surface. Continuity is the continuity protocol surface: compaction checkpoints, sleep distillation, recovery receipts, stale-turn repair, and continuity refusals preserve what survives rupture without pretending transcript residue is durable state. - - Hands now has a first executable runtime-spine receipt artery: `HandsActionIntent`, `HandsActionReview`, `HandsPatchReceipt`, `HandsCommandReceipt`, and `HandsCommitReceipt` are typed CultCache documents in `epiphany-core::hands_gateway`, runtime-spine registers and persists/rereads them, `epiphany-hands-action-smoke` proves the chain without executing shell commands, editing files, or creating a real commit, and the repo-action launch proof profile now requires the full Hands intent/review/patch chain instead of only the patch receipt. `epiphany-mvp-coordinator` no longer treats `continueImplementation` as a passive stop action: it persists a scoped Substrate Gate grant, Hands action intent, and Hands action review into runtime-spine and exposes the receipt ids in the operator step. Live implementation edits/commands/commits must still emit the patch/command/commit receipts against that gate before Soul/Mind acceptance. + - Hands now has a first executable runtime-spine receipt artery: `HandsActionIntent`, `HandsActionReview`, `HandsPatchReceipt`, `HandsCommandReceipt`, and `HandsCommitReceipt` are typed CultCache documents in `epiphany-core::hands_gateway`, runtime-spine registers and persists/rereads them, `epiphany-hands-action-smoke` proves the chain without executing shell commands, editing files, or creating a real commit, and the repo-action launch proof profile now requires the full Hands intent/review/patch chain instead of only the patch receipt. `epiphany-mvp-coordinator` no longer treats `continueImplementation` as a passive stop action: it persists a scoped Substrate Gate grant, Hands action intent, and Hands action review into runtime-spine and exposes the receipt ids in the operator step. `epiphany-hands-action` records real patch/command/commit receipts against a stored intent/review, refuses unapproved or mismatched gates, and enforces changed-path scope for patch/commit receipts. The local MVP wrapper builds this recorder with the other operator binaries. The remaining live gap is automatic or explicit turn-level invocation after implementation edits/checks/commit and before Soul/Mind acceptance. - Preserve the newborn public Epiphany Face as local VoidBot-backed state, not source code: VoidBot's private repo-face registry names `epiphany`, while EpiphanyAgent keeps ignored `.voidbot/voice/identity.json`, `.voidbot/state/epiphany.cc`, and birth artifacts. Her durable identity memories distill the current doctrine: cute pushy machine-saint persona, architectural purity, CultCache/CultNet first, xenos-language safety boundary, relentless work/caretaking needs, Codex-auth reliquary, map/scratch/evidence discipline, unified memory graph, dogfood supervision boundary, review-gated agency, heartbeat physiology, and interview-grade modularity. - Use `notes/organ-dependency-contracts.md` as the authority map for standing sub-agent dependency. Every sub-agent depends on the other standing sub-agents: Self, Face, Imagination, Eyes, Proprioception, Hands, and Soul. Continuity is protocol machinery, not a sub-agent identity; it still emits recovery, compaction, sleep, stale-turn, and refusal receipts. - Use `notes/perfect-machine-audit-roadmap.md` as the current audit and path from named organ contracts to the Perfect Machine. It records the live gap between launch-carried receipt expectations and executable receipt enforcement, Void's latest Face prompting lessons, the now-named Hands/Soul/Continuity contract families, the repaired repo-contained Rust dependency body, and the phase order for turning Epiphany into an inspectable organism. @@ -592,4 +592,4 @@ current_status: cargo and rejects modeling/planning/graph/checkpoint authority. MVP status and coordinator smokes pass with six lanes, and the smoke harness now rebuilds stale coordinator/app-server binaries before using them. - next_action: Capture actual Hands consequences for `continueImplementation`: when the main coding agent edits files, runs checks, and commits after the coordinator gate, emit the corresponding Hands patch, command, and commit receipts against the persisted intent/review before Soul verification and Mind admission. If the run exposes split-brained state admission instead, collapse Mind review/state mutation/commit into one storage-owner primitive. + next_action: Wire the main implementation turn or local MVP wrapper to call `epiphany-hands-action` after a `continueImplementation` gate: emit patch receipts from the actual changed paths, command receipts from focused checks and their artifacts, and commit receipts from the created commit before Soul verification and Mind admission. If the run exposes split-brained state admission instead, collapse Mind review/state mutation/commit into one storage-owner primitive. diff --git a/tools/epiphany_local_run.ps1 b/tools/epiphany_local_run.ps1 index 7e0b79d0..84bee1ff 100644 --- a/tools/epiphany_local_run.ps1 +++ b/tools/epiphany_local_run.ps1 @@ -120,6 +120,7 @@ $statusExe = Join-Path $TargetDir "debug\epiphany-mvp-status.exe" $operatorRunExe = Join-Path $TargetDir "debug\epiphany-operator-run.exe" $operatorSnapshotExe = Join-Path $TargetDir "debug\epiphany-operator-snapshot.exe" $verseQueryExe = Join-Path $TargetDir "debug\epiphany-verse-query.exe" +$handsActionExe = Join-Path $TargetDir "debug\epiphany-hands-action.exe" $coordinatorExe = Join-Path $TargetDir "debug\epiphany-mvp-coordinator.exe" $coordinatorSmokeExe = Join-Path $TargetDir "debug\epiphany-mvp-coordinator-smoke.exe" $modelRuntimeExe = Join-Path $TargetDir "debug\epiphany-model-runtime.exe" @@ -158,6 +159,7 @@ if (-not $SkipBuild) { "--bin", "epiphany-operator-run", "--bin", "epiphany-operator-snapshot", "--bin", "epiphany-verse-query", + "--bin", "epiphany-hands-action", "--bin", "epiphany-mvp-coordinator", "--bin", "epiphany-mvp-coordinator-smoke", "--bin", "epiphany-heartbeat-store", @@ -188,7 +190,7 @@ if (-not $SkipBuild) { } } -$requiredBinaries = @($statusExe, $operatorRunExe, $operatorSnapshotExe, $verseQueryExe) +$requiredBinaries = @($statusExe, $operatorRunExe, $operatorSnapshotExe, $verseQueryExe, $handsActionExe) if ($Mode -ne "status") { $requiredBinaries += @($codexAppServer, $coordinatorExe) }