From a7c43a83f002d99cd09c0446438a21a8dbf09463 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 19 Jun 2026 22:51:29 +0100 Subject: [PATCH] Add repo work publication gate --- epiphany-core/src/bin/epiphany-work.rs | 483 +++++++++++++++++++++- notes/epiphany-repo-swarm-mvp-contract.md | 42 +- notes/fresh-workspace-handoff.md | 2 +- state/ledgers.msgpack | Bin 300698 -> 301196 bytes state/map.yaml | 4 +- 5 files changed, 523 insertions(+), 8 deletions(-) diff --git a/epiphany-core/src/bin/epiphany-work.rs b/epiphany-core/src/bin/epiphany-work.rs index 57539bf3..b29889f5 100644 --- a/epiphany-core/src/bin/epiphany-work.rs +++ b/epiphany-core/src/bin/epiphany-work.rs @@ -6,17 +6,22 @@ use epiphany_core::HANDS_ACTION_INTENT_SCHEMA_VERSION; use epiphany_core::HANDS_COMMAND_RECEIPT_TYPE; use epiphany_core::HANDS_COMMIT_RECEIPT_TYPE; use epiphany_core::HANDS_PATCH_RECEIPT_TYPE; +use epiphany_core::HANDS_PR_RECEIPT_TYPE; use epiphany_core::HandsActionIntent; use epiphany_core::RuntimeSpineInitOptions; use epiphany_core::SUBSTRATE_GATE_REPO_ACCESS_GRANT_RECEIPT_SCHEMA_VERSION; use epiphany_core::SubstrateGateRepoAccessGrantReceipt; use epiphany_core::hands_action_review_for_intent; +use epiphany_core::hands_pr_receipt_for_review; use epiphany_core::initialize_runtime_spine; use epiphany_core::put_hands_action_intent; use epiphany_core::put_hands_action_review; +use epiphany_core::put_hands_pr_receipt; use epiphany_core::put_substrate_gate_repo_access_grant_receipt; use epiphany_core::runtime_hands_action_intent; use epiphany_core::runtime_hands_action_review; +use epiphany_core::runtime_hands_commit_receipt; +use epiphany_core::runtime_latest_hands_receipt_chain_after; use serde_json::Value; use serde_json::json; use std::env; @@ -35,6 +40,7 @@ fn main() -> Result<()> { "accept" => run_accept(parse_accept_args(args)?), "run" => run_work(parse_run_args(args)?), "adopt" | "promote" => run_adopt(parse_adopt_args(args)?), + "publish" => run_publish(parse_publish_args(args)?), other => Err(anyhow!("unknown epiphany-work command {other:?}")), }?; println!("{}", serde_json::to_string_pretty(&result)?); @@ -81,6 +87,32 @@ struct AdoptArgs { adoption_evidence_refs: Vec, } +#[derive(Clone, Debug)] +struct PublishArgs { + workspace: PathBuf, + epiphany_root: PathBuf, + item: Option, + adopt_receipt: Option, + runtime_store: Option, + local_verse_store: Option, + artifact_dir: Option, + commit_receipt_id: Option, + hands_pr_receipt_id: Option, + target_branch: Option, + change_summary: String, + justification: String, + verification_receipts: Vec, + review_receipts: Vec, + author_agents: Vec, + credit_subjects: Vec, + credit_receipt_ids: Option>, + ledger_entry_id: String, + pull_request_url: String, + pull_request_number: String, + pull_request_title: String, + publication_status: String, +} + fn parse_accept_args(args: impl Iterator) -> Result { let mut workspace = None; let mut epiphany_root = None; @@ -231,6 +263,132 @@ fn parse_adopt_args(args: impl Iterator) -> Result { }) } +fn parse_publish_args(args: impl Iterator) -> Result { + let mut workspace = None; + let mut epiphany_root = None; + let mut item = None; + let mut adopt_receipt = None; + let mut runtime_store = None; + let mut local_verse_store = None; + let mut artifact_dir = None; + let mut commit_receipt_id = None; + let mut hands_pr_receipt_id = None; + let mut target_branch = None; + let mut change_summary = None; + let mut justification = None; + let mut verification_receipts = Vec::new(); + let mut review_receipts = Vec::new(); + let mut author_agents = Vec::new(); + let mut credit_subjects = Vec::new(); + let mut credit_receipt_ids = Vec::new(); + let mut ledger_entry_id = None; + let mut pull_request_url = None; + let mut pull_request_number = None; + let mut pull_request_title = None; + let mut publication_status = None; + + let mut args = args.peekable(); + while let Some(arg) = args.next() { + match arg.as_str() { + "--workspace" => workspace = Some(take_path(&mut args, "--workspace")?), + "--epiphany-root" => epiphany_root = Some(take_path(&mut args, "--epiphany-root")?), + "--item" => item = Some(take_string(&mut args, "--item")?), + "--adopt-receipt" => adopt_receipt = Some(take_path(&mut args, "--adopt-receipt")?), + "--runtime-store" => runtime_store = Some(take_path(&mut args, "--runtime-store")?), + "--local-verse-store" | "--store" => { + local_verse_store = Some(take_path(&mut args, "--local-verse-store")?); + } + "--artifact-dir" => artifact_dir = Some(take_path(&mut args, "--artifact-dir")?), + "--commit-receipt-id" => { + commit_receipt_id = Some(take_string(&mut args, "--commit-receipt-id")?); + } + "--hands-pr-receipt-id" => { + hands_pr_receipt_id = Some(take_string(&mut args, "--hands-pr-receipt-id")?); + } + "--target-branch" => target_branch = Some(take_string(&mut args, "--target-branch")?), + "--change-summary" => { + change_summary = Some(take_string(&mut args, "--change-summary")?) + } + "--justification" => justification = Some(take_string(&mut args, "--justification")?), + "--verification-receipt" | "--soul-receipt" => { + verification_receipts.push(take_string(&mut args, "--verification-receipt")?); + } + "--review-receipt" | "--mind-review-receipt" => { + review_receipts.push(take_string(&mut args, "--review-receipt")?); + } + "--author-agent" => author_agents.push(take_string(&mut args, "--author-agent")?), + "--credit-subject" => credit_subjects.push(take_string(&mut args, "--credit-subject")?), + "--credit-receipt-id" => { + credit_receipt_ids.push(take_string(&mut args, "--credit-receipt-id")?); + } + "--ledger-entry-id" => { + ledger_entry_id = Some(take_string(&mut args, "--ledger-entry-id")?); + } + "--pull-request-url" | "--publication-url" => { + pull_request_url = Some(take_string(&mut args, "--pull-request-url")?); + } + "--pull-request-number" => { + pull_request_number = Some(take_string(&mut args, "--pull-request-number")?); + } + "--pull-request-title" => { + pull_request_title = Some(take_string(&mut args, "--pull-request-title")?); + } + "--publication-status" => { + publication_status = Some(take_string(&mut args, "--publication-status")?); + } + other => return Err(anyhow!("unexpected publish argument {other:?}")), + } + } + if verification_receipts.is_empty() { + return Err(anyhow!( + "publish requires at least one --verification-receipt from Soul" + )); + } + if review_receipts.is_empty() { + return Err(anyhow!( + "publish requires at least one --review-receipt from Mind or maintainer review" + )); + } + Ok(PublishArgs { + workspace: workspace.context("missing --workspace")?, + epiphany_root: epiphany_root + .unwrap_or(env::current_dir().context("failed to resolve current directory")?), + item, + adopt_receipt, + runtime_store, + local_verse_store, + artifact_dir, + commit_receipt_id, + hands_pr_receipt_id, + target_branch, + change_summary: change_summary.context("missing --change-summary")?, + justification: justification.context("missing --justification")?, + verification_receipts, + review_receipts, + author_agents: if author_agents.is_empty() { + vec!["epiphany.Hands".to_string()] + } else { + author_agents + }, + credit_subjects: if credit_subjects.is_empty() { + vec!["epiphany.Hands".to_string()] + } else { + credit_subjects + }, + credit_receipt_ids: if credit_receipt_ids.is_empty() { + None + } else { + Some(credit_receipt_ids) + }, + ledger_entry_id: ledger_entry_id.context("missing --ledger-entry-id")?, + pull_request_url: pull_request_url.context("missing --pull-request-url")?, + pull_request_number: pull_request_number.unwrap_or_else(|| "unknown".to_string()), + pull_request_title: pull_request_title.context("missing --pull-request-title")?, + publication_status: publication_status + .unwrap_or_else(|| "accepted-for-github-publication".to_string()), + }) +} + fn run_accept(args: AcceptArgs) -> Result { let workspace = args .workspace @@ -692,6 +850,307 @@ fn run_adopt(args: AdoptArgs) -> Result { })) } +fn run_publish(args: PublishArgs) -> Result { + let workspace = args + .workspace + .canonicalize() + .with_context(|| format!("failed to resolve {}", args.workspace.display()))?; + ensure_git_repo(&workspace)?; + let epiphany_root = args + .epiphany_root + .canonicalize() + .with_context(|| format!("failed to resolve {}", args.epiphany_root.display()))?; + let manifest_path = epiphany_root.join("epiphany-core").join("Cargo.toml"); + if !manifest_path.exists() { + return Err(anyhow!( + "could not find epiphany-core manifest at {}", + manifest_path.display() + )); + } + let adopt_receipt_path = + resolve_adopt_receipt(&workspace, args.item.as_deref(), args.adopt_receipt)?; + let adopt_receipt = read_json(&adopt_receipt_path)?; + let run_receipt_path = path_from_json(&adopt_receipt, &["runReceiptPath"]) + .ok_or_else(|| anyhow!("adopt receipt has no runReceiptPath"))?; + let run_receipt = read_json(&run_receipt_path)?; + let online_receipt_path = path_from_json(&run_receipt, &["onlineReceiptPath"]) + .ok_or_else(|| anyhow!("run receipt has no onlineReceiptPath"))?; + let online_receipt = read_json(&online_receipt_path)?; + let runtime_id = string_from_json(&adopt_receipt, &["runtimeId"]) + .or_else(|| string_from_json(&run_receipt, &["runtimeId"])) + .or_else(|| string_from_json(&online_receipt, &["runtimeId"])) + .unwrap_or_else(|| "repo-swarm-local".to_string()); + let runtime_store = args.runtime_store.unwrap_or_else(|| { + path_from_json(&adopt_receipt, &["runtimeStore"]).unwrap_or_else(|| { + workspace + .join(".epiphany") + .join("state") + .join("runtime-spine.msgpack") + }) + }); + let local_verse_store = args.local_verse_store.unwrap_or_else(|| { + path_from_json(&online_receipt, &["localVerseStore"]) + .unwrap_or_else(|| workspace.join(".epiphany").join("local-verse.ccmp")) + }); + let artifact_dir = args + .artifact_dir + .unwrap_or_else(|| workspace.join(".epiphany").join("work")); + fs::create_dir_all(&artifact_dir) + .with_context(|| format!("failed to create {}", artifact_dir.display()))?; + + let gate = adopt_receipt + .get("handsActionGate") + .ok_or_else(|| anyhow!("adopt receipt has no handsActionGate"))?; + let intent_id = gate + .get("intentId") + .and_then(Value::as_str) + .ok_or_else(|| anyhow!("adopt receipt handsActionGate has no intentId"))?; + let review_id = gate + .get("reviewId") + .and_then(Value::as_str) + .ok_or_else(|| anyhow!("adopt receipt handsActionGate has no reviewId"))?; + let intent = runtime_hands_action_intent(&runtime_store, intent_id)? + .ok_or_else(|| anyhow!("runtime-spine has no Hands intent {intent_id}"))?; + let review = runtime_hands_action_review(&runtime_store, review_id)? + .ok_or_else(|| anyhow!("runtime-spine has no Hands review {review_id}"))?; + if review.intent_id != intent.intent_id { + return Err(anyhow!( + "Hands review {} belongs to {}, 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 + )); + } + + let commit_receipt = if let Some(commit_receipt_id) = args.commit_receipt_id.clone() { + runtime_hands_commit_receipt(&runtime_store, &commit_receipt_id)? + .ok_or_else(|| anyhow!("Hands commit receipt {commit_receipt_id} was not found"))? + } else { + let lower_bound = adopt_receipt + .get("createdAt") + .and_then(Value::as_str) + .ok_or_else(|| anyhow!("adopt receipt has no createdAt timestamp"))?; + let chain = runtime_latest_hands_receipt_chain_after(&runtime_store, lower_bound)? + .ok_or_else(|| anyhow!("no complete Hands patch/command/commit chain after adoption; pass --commit-receipt-id after recording branch-local work"))?; + runtime_hands_commit_receipt(&runtime_store, &chain.commit_receipt_id)?.ok_or_else( + || { + anyhow!( + "Hands commit receipt {} was not found", + chain.commit_receipt_id + ) + }, + )? + }; + if commit_receipt.intent_id != intent.intent_id || commit_receipt.review_id != review.review_id + { + return Err(anyhow!( + "Hands commit receipt {} belongs to intent {}/review {}, not {}/{}", + commit_receipt.receipt_id, + commit_receipt.intent_id, + commit_receipt.review_id, + intent.intent_id, + review.review_id + )); + } + + let now = Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true); + let mut publication_review = review.clone(); + if !publication_review + .allowed_operations + .iter() + .any(|operation| operation == "pr") + { + publication_review.allowed_operations.push("pr".to_string()); + } + if !publication_review + .required_receipts + .iter() + .any(|receipt| receipt == HANDS_PR_RECEIPT_TYPE) + { + publication_review + .required_receipts + .push(HANDS_PR_RECEIPT_TYPE.to_string()); + } + publication_review.reviewed_at = now.clone(); + publication_review.reasons.push(format!( + "Bifrost publication routing approved after verification refs [{}] and review refs [{}].", + args.verification_receipts.join(", "), + args.review_receipts.join(", ") + )); + put_hands_action_review(&runtime_store, &publication_review)?; + + let item = adopt_receipt + .get("item") + .and_then(Value::as_str) + .unwrap_or("work-item") + .to_string(); + let item_slug = sanitize(&item); + let hands_pr_receipt_id = args + .hands_pr_receipt_id + .clone() + .unwrap_or_else(|| format!("repo-work-publish-{item_slug}-hands-pr")); + let bifrost_intent_id = format!("repo-work-publish-{item_slug}-bifrost-intent"); + let bifrost_publication_receipt_id = + format!("repo-work-publish-{item_slug}-bifrost-publication"); + let github_publication_receipt_id = format!("repo-work-publish-{item_slug}-github"); + let target_branch = args + .target_branch + .clone() + .unwrap_or_else(|| commit_receipt.branch.clone()); + let target_repository = format!("repo:{}", workspace.display()); + let body_domain = target_repository.clone(); + + let mut verse_args = vec![ + "bifrost-publication".to_string(), + "--store".to_string(), + local_verse_store.display().to_string(), + "--runtime-id".to_string(), + runtime_id.clone(), + "--intent-id".to_string(), + bifrost_intent_id.clone(), + "--receipt-id".to_string(), + bifrost_publication_receipt_id.clone(), + "--github-receipt-id".to_string(), + github_publication_receipt_id.clone(), + "--target-repository".to_string(), + target_repository.clone(), + "--target-branch".to_string(), + target_branch.clone(), + "--change-summary".to_string(), + args.change_summary.clone(), + "--justification".to_string(), + args.justification.clone(), + "--ledger-entry-id".to_string(), + args.ledger_entry_id.clone(), + "--hands-pr-receipt-id".to_string(), + hands_pr_receipt_id.clone(), + "--publication-url".to_string(), + args.pull_request_url.clone(), + "--pull-request-number".to_string(), + args.pull_request_number.clone(), + "--commit-sha".to_string(), + commit_receipt.commit_sha.clone(), + "--source-cluster-id".to_string(), + "epiphany.cluster.hands".to_string(), + "--source-agent-id".to_string(), + "epiphany.Hands".to_string(), + "--body-domain".to_string(), + body_domain, + "--receipt-status".to_string(), + args.publication_status.clone(), + ]; + for path in &commit_receipt.changed_paths { + verse_args.extend(["--changed-path".to_string(), path.clone()]); + } + for receipt in &args.verification_receipts { + verse_args.extend(["--verification-receipt".to_string(), receipt.clone()]); + } + for receipt in &args.review_receipts { + verse_args.extend(["--review-receipt".to_string(), receipt.clone()]); + } + for author in &args.author_agents { + verse_args.extend(["--author-agent".to_string(), author.clone()]); + } + for subject in &args.credit_subjects { + verse_args.extend(["--credit-subject".to_string(), subject.clone()]); + } + if let Some(credit_receipts) = &args.credit_receipt_ids { + for receipt in credit_receipts { + verse_args.extend(["--credit-receipt".to_string(), receipt.clone()]); + } + } + let bifrost = cargo_json(&manifest_path, "epiphany-verse-query", &verse_args)?; + + let pr_receipt = hands_pr_receipt_for_review( + hands_pr_receipt_id.clone(), + &intent, + &publication_review, + &commit_receipt, + args.pull_request_url.clone(), + args.pull_request_number.clone(), + args.pull_request_title.clone(), + bifrost_publication_receipt_id.clone(), + format!("Published repo work item {item} through Bifrost receipts."), + now.clone(), + ); + put_hands_pr_receipt(&runtime_store, &pr_receipt)?; + + let publish_receipt = json!({ + "schemaVersion": "epiphany.repo_work_publish_receipt.v0", + "createdAt": now, + "workspace": workspace, + "runtimeId": runtime_id, + "runtimeStore": runtime_store, + "localVerseStore": local_verse_store, + "adoptReceiptPath": adopt_receipt_path, + "runReceiptPath": run_receipt_path, + "onlineReceiptPath": online_receipt_path, + "item": item, + "status": "publication-receipts-recorded", + "targetRepository": target_repository, + "targetBranch": target_branch, + "changedPaths": commit_receipt.changed_paths, + "handsActionGate": { + "intentId": intent.intent_id, + "reviewId": publication_review.review_id, + "decision": publication_review.decision, + "allowedOperations": publication_review.allowed_operations, + "requiredReceipts": publication_review.required_receipts + }, + "handsReceipts": { + "commitReceiptId": commit_receipt.receipt_id, + "commitSha": commit_receipt.commit_sha, + "branch": commit_receipt.branch, + "prReceiptId": pr_receipt.receipt_id, + "pullRequestUrl": pr_receipt.pull_request_url, + "pullRequestNumber": pr_receipt.pull_request_number, + "pullRequestTitle": pr_receipt.pull_request_title + }, + "bifrost": { + "intentId": bifrost["intentId"], + "publicationReceiptId": bifrost["publicationReceiptId"], + "githubPublicationReceiptId": bifrost["githubPublicationReceiptId"], + "ledgerEntryId": bifrost["ledgerEntryId"], + "creditReceiptIds": bifrost["creditReceiptIds"], + "pullRequestUrl": bifrost["pullRequestUrl"] + }, + "verificationReceipts": args.verification_receipts, + "reviewReceipts": args.review_receipts, + "authority": { + "publicationAuthorized": true, + "upstreamMainSynced": false, + "mergeAuthorized": false, + "mergeGate": "maintainer_or_bifrost_merge_receipt", + "privateStateExposed": false + }, + "nextSafeMove": "Maintain the PR/publication receipt chain; do not claim upstream main is synced until a merge/sync receipt exists." + }); + let receipt_path = artifact_dir.join(format!("work-publish-{item_slug}.json")); + write_json(&receipt_path, &publish_receipt)?; + Ok(json!({ + "schemaVersion": "epiphany.repo_work_publish.v0", + "status": publish_receipt["status"], + "workspace": publish_receipt["workspace"], + "runtimeId": publish_receipt["runtimeId"], + "runtimeStore": publish_receipt["runtimeStore"], + "localVerseStore": publish_receipt["localVerseStore"], + "receiptPath": receipt_path, + "item": publish_receipt["item"], + "handsReceipts": publish_receipt["handsReceipts"], + "bifrost": publish_receipt["bifrost"], + "authority": publish_receipt["authority"], + "privateStateExposed": false, + "nextSafeMove": publish_receipt["nextSafeMove"], + })) +} + fn resolve_accept_receipt( workspace: &Path, item: Option<&str>, @@ -742,6 +1201,25 @@ fn resolve_run_receipt( }) } +fn resolve_adopt_receipt( + workspace: &Path, + item: Option<&str>, + explicit: Option, +) -> Result { + if let Some(path) = explicit { + return Ok(path); + } + let work_dir = workspace.join(".epiphany").join("work"); + if let Some(item) = item { + return Ok(work_dir.join(format!("work-adopt-{}.json", sanitize(item)))); + } + latest_receipt_in(&work_dir, "work-adopt-").ok_or_else(|| { + anyhow!( + "no work adopt receipt found; run epiphany-work adopt first or pass --adopt-receipt" + ) + }) +} + fn latest_receipt_in(work_dir: &Path, prefix: &str) -> Option { let mut candidates = Vec::new(); if work_dir.exists() { @@ -859,9 +1337,10 @@ fn sanitize(value: &str) -> String { fn print_usage() { eprintln!( - "usage: epiphany-work ...\n\ + "usage: epiphany-work ...\n\ accept --workspace --from --item [--summary ] [--topic ] [--store ] [--runtime-id ] [--online-receipt ] [--public-discussion-ref ] [--candidate-action-ref ]\n\ run --workspace [--item ] [--accept-receipt ] [--runtime-store ] [--requested-path ]\n\ - adopt --workspace [--item ] [--run-receipt ] --plan-summary --adoption-evidence-ref " + adopt --workspace [--item ] [--run-receipt ] --plan-summary --adoption-evidence-ref \n\ + publish --workspace [--item ] --change-summary --justification --verification-receipt --review-receipt --ledger-entry-id --pull-request-url --pull-request-title " ); } diff --git a/notes/epiphany-repo-swarm-mvp-contract.md b/notes/epiphany-repo-swarm-mvp-contract.md index be5fa359..14df6e4b 100644 --- a/notes/epiphany-repo-swarm-mvp-contract.md +++ b/notes/epiphany-repo-swarm-mvp-contract.md @@ -278,9 +278,45 @@ epiphany-work adopt --workspace --item first-request --plan-summary '...' After adoption, `epiphany-hands-action record-pass` successfully consumed the approved gate and emitted the Hands receipt triplet. The same action recorder -still refuses queued or mismatched gates. The next cut is the publication step: -`epiphany-work publish --workspace ` must route reviewed body changes -through Soul/Mind/Bifrost receipts before upstream-facing work is allowed. +still refuses queued or mismatched gates. + +### Landed Work Publication Gate + +The sixth front door exists as native Rust: + +```powershell +cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-work -- publish --workspace --item --change-summary --justification --verification-receipt --review-receipt --ledger-entry-id --pull-request-url --pull-request-title +``` + +It reads the named or latest work-adopt receipt, requires the Hands review to +be approved, finds or accepts a Hands commit receipt for the adopted gate, then +requires Soul verification refs and Mind or maintainer review refs before +routing publication through Bifrost. The command writes Bifrost body-change +publication intent, Bifrost publication receipt, Bifrost GitHub publication +receipt, and a matching Hands PR receipt into the repo-local stores. + +This is publication routing, not merge authority: +`publicationAuthorized=true`, `upstreamMainSynced=false`, and +`mergeAuthorized=false`. Upstream main is not considered synced until a later +merge/sync receipt proves it. + +The first smoke proved the six-command sequence: + +```powershell +epiphany-repo init --workspace +epiphany-swarm online --workspace +epiphany-work accept --workspace --from persona --item first-request +epiphany-work run --workspace --item first-request +epiphany-work adopt --workspace --item first-request --plan-summary '...' --adoption-evidence-ref 'imagination-consensus:repo-work-consensus-first-request' +epiphany-work publish --workspace --item first-request --change-summary '...' --justification '...' --verification-receipt 'soul-verdict:...' --review-receipt 'mind-review:...' --ledger-entry-id 'bifrost-ledger:...' --pull-request-url 'https://...' --pull-request-title '...' +``` + +The publish receipt produced a Hands PR receipt, Bifrost publication receipt, +GitHub publication receipt, `privateStateExposed=false`, and an explicit +`upstreamMainSynced=false` guard. The next cut is either a real autonomous +executor that consumes approved gates without a smoke recorder, or a +merge/sync gate that can prove upstream main actually matches the accepted +publication. ## Migration Implication diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index e83f5d4f..13417502 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -102,7 +102,7 @@ remembers doctrine; the branch remembers the blade. - 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 and proves the post-timestamp Hands receipt-chain detector; `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`, `record-commit`, and turn-level `record-pass` load the stored intent/review or `finalAction.handsActionGate` from `coordinator-summary.json`, require an approved matching review, enforce allowed operations, and keep patch/commit changed paths inside the requested scope. `epiphany-mvp-coordinator-smoke` includes the deterministic Hands pass proof. The coordinator now treats a complete Hands receipt chain after an accepted Soul result as new implementation evidence, launches Soul again, and routes a passing accepted Soul result to Modeling/modeling before another Hands turn. Work-loop telemetry is now typed internal CultMesh state: Verification role launches write `epiphany.cultmesh.work_loop_telemetry.v0` beside runtime-spine, render that packet for Soul with resolved receipt bodies, commit diff preview, source proof notes, verification assertions, and stdout/stderr previews, and Modeling launches read/enrich the latest packet with Soul acceptance receipt ids before Modeling updates the map. Local Verse prompt context now exposes only a sealed `latest_work_loop_summary` digest with telemetry id, Hands receipt ids, path/source/assertion counts, and Soul receipt ids; receipt payload previews, artifact previews, and commit diff previews remain internal telemetry and are leak-guarded by tests plus `epiphany-verse-query -- smoke`. - `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-verse-query swarm-brake --brake-status engaged|released` can now write the local Verse brake document, and `tools/epiphany_local_run.ps1` refuses live `plan`/`run`/`mvp` modes when that brake is engaged while keeping `status` readable. `epiphany-mvp-coordinator` also checks `--local-verse-store` before app-server startup, and `epiphany-heartbeat-store` guards tick/pump/heat/queue-mention/routine when passed `--local-verse-store`. Daemon tool invocation, daemon lifecycle poke, and `epiphany-daemon-supervisor` restart/tick/serve/service-plan/service-launch/service-runbook/windows-service-install/windows-service-status/windows-service-reconcile/windows-service-execution-readiness/start/stop attempts now fail closed under a matching engaged brake; supervisor restart now has durable per-daemon policy with cooldown/backoff, explicit scheduled tick pulses, latest scheduler receipts, typed service lifecycle plan/launch/runbook/install/status/reconcile/readiness/start/stop receipts, and local operator wrapper modes that write runbook/install/status/reconcile/readiness/control-plan/execution artifacts plus operator run receipts. The installed-service read path, read-only service-policy reconciliation path, execution-readiness path, non-mutating start/stop control-plan path, and non-elevated execution refusal path have been proved against real Windows `EventLog` service-manager state or safe missing-service targets through local Verse receipts, including explicit wrapper install/start/stop execution modes. The next cut is actual elevated install/start/stop execution proof under operator authority. -- `notes/epiphany-repo-swarm-mvp-contract.md` corrects the repo-swarm MVP authority boundary: autonomous branch-local work inside the owned repo Body is in scope and desired; Bifrost gates publication/merge/escalation, not every local edit. Five native repo-swarm front doors are now live: `epiphany-repo init --workspace ` writes the repo-swarm init receipt and branch workbench plan; `epiphany-swarm online --workspace ` seeds repo-local `.epiphany/local-verse.ccmp`, standing-faculty SoA, topology/liveness/tool/overview proof, and `.epiphany/swarm-online/repo-swarm-online-receipt.json`; `epiphany-work accept --workspace --from persona-or-bifrost --item ` routes a Persona/Bifrost item through CultMesh collaboration feedback into Imagination consensus discovery and writes `.epiphany/work/work-accept-.json` with no Hands, durable-state, or publication authority granted; `epiphany-work run --workspace [--item ]` persists a repo-local runtime-spine Substrate Gate read/snapshot grant, Hands intent, and Hands review with `decision=queued-for-adoption`; `epiphany-work adopt --workspace --item --plan-summary --adoption-evidence-ref ` requires explicit Imagination/Self/Mind adoption evidence and promotes that queued review to an approved branch-local Hands gate requiring patch/command/commit receipts. Fresh-repo smokes proved init, online, accept, run, adopt, and post-adoption `epiphany-hands-action record-pass` with `privateStateExposed=false`; pre-adoption gates still refuse record-pass. Next missing organ: `epiphany-work publish --workspace ` for Soul/Mind/Bifrost-gated upstream-facing publication, plus a real autonomous executor that consumes the approved gate instead of a smoke recorder. +- `notes/epiphany-repo-swarm-mvp-contract.md` corrects the repo-swarm MVP authority boundary: autonomous branch-local work inside the owned repo Body is in scope and desired; Bifrost gates publication/merge/escalation, not every local edit. Six native repo-swarm front doors are now live: `epiphany-repo init --workspace ` writes the repo-swarm init receipt and branch workbench plan; `epiphany-swarm online --workspace ` seeds repo-local `.epiphany/local-verse.ccmp`, standing-faculty SoA, topology/liveness/tool/overview proof, and `.epiphany/swarm-online/repo-swarm-online-receipt.json`; `epiphany-work accept --workspace --from persona-or-bifrost --item ` routes a Persona/Bifrost item through CultMesh collaboration feedback into Imagination consensus discovery and writes `.epiphany/work/work-accept-.json` with no Hands, durable-state, or publication authority granted; `epiphany-work run --workspace [--item ]` persists a repo-local runtime-spine Substrate Gate read/snapshot grant, Hands intent, and Hands review with `decision=queued-for-adoption`; `epiphany-work adopt --workspace --item --plan-summary --adoption-evidence-ref ` requires explicit Imagination/Self/Mind adoption evidence and promotes that queued review to an approved branch-local Hands gate requiring patch/command/commit receipts; `epiphany-work publish --workspace --item ...` requires Hands commit proof plus Soul verification and Mind/review refs, routes Bifrost publication/GitHub publication receipts, records a Hands PR receipt, and keeps `upstreamMainSynced=false` / `mergeAuthorized=false`. Fresh-repo smokes proved init, online, accept, run, adopt, post-adoption `epiphany-hands-action record-pass`, and publish with `privateStateExposed=false`; pre-adoption gates still refuse record-pass. Next missing organ: a real autonomous executor that consumes approved gates instead of a smoke recorder, or a merge/sync gate that proves upstream main is actually synced after publication. - `service-execution-runbook` makes that next cut repeatable: it generates the exact elevated wrapper command sequence without mutating the service manager, continues after per-step failure to preserve more receipts, runs `service-execution-audit` in `finally`, exits nonzero if any step failed, and seals a typed runbook lifecycle receipt. Run the generated artifact only with explicit operator authority. - `service-execution-audit` is the non-mutating acceptance proof after the elevated rite: it reports `complete` only when typed lifecycle receipts prove the runbook witness plus expected elevated chain, and otherwise reports the missing/failed sealed checks. - `service-tick` is the non-elevated scheduler pulse proof: it writes the latest daemon scheduler receipt through durable policy ownership and local wrapper receipts. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 434480b4d7d266140dd1baeaf4e89ccd59e1e8ac..7f24bfaac25ae6b67d6f727fd0fdacc6a145fc12 100644 GIT binary patch delta 483 zcmXv~y>1gh5at|HQDF%w1;t3TcRt4uOIV_Sf+SKRMKKlK=623E%H8c|cFvAzTu`J* z8OsvyfJ8)r(o*mObUXkrLBlwRB>%d;z{WFDVpY0!V=n=t>G;^ezcg!xiN0YSDJbT{sf0TsFiQz*y&3 zY=_DoU~B~A%{_BfMKTA^&gC(TTvNgXnR3dEkgJs=4>6ojZBxbx;dFz%BNYn*CE77^ znlV}us8EbGVq%ywi7IcuJvd)erUxX4&G|aa8k#F` writes the repo-swarm init receipt and branch workbench plan; `epiphany-swarm online --workspace ` seeds repo-local `.epiphany/local-verse.ccmp`, standing-faculty SoA, topology/liveness/tool/overview proof, and `.epiphany/swarm-online/repo-swarm-online-receipt.json`; `epiphany-work accept --workspace --from persona-or-bifrost --item ` routes a Persona/Bifrost item through CultMesh collaboration feedback into Imagination consensus discovery and writes `.epiphany/work/work-accept-.json` with no Hands, durable-state, or publication authority granted; `epiphany-work run --workspace [--item ]` persists a repo-local runtime-spine Substrate Gate read/snapshot grant, Hands intent, and Hands review with `decision=queued-for-adoption`; `epiphany-work adopt --workspace --item --plan-summary --adoption-evidence-ref ` requires explicit Imagination/Self/Mind adoption evidence and promotes that queued review to an approved branch-local Hands gate requiring patch/command/commit receipts. Fresh-repo smokes proved init, online, accept, run, adopt, and post-adoption `epiphany-hands-action record-pass` with `privateStateExposed=false`; pre-adoption gates still refuse record-pass. Next missing organ is `epiphany-work publish --workspace ` for Soul/Mind/Bifrost-gated upstream-facing publication, plus a real autonomous executor that consumes the approved gate instead of a smoke recorder. + - Use `notes/epiphany-repo-swarm-mvp-contract.md` as the authority correction for repo-swarm autonomy. Autonomous branch-local work inside an Epiphany-owned Body is in scope and is the desired operating mode; the safety boundary is typed authority, branch containment, interruptibility, receipts, private-state sealing, and Bifrost-gated publication/merge/escalation, not asking a human before every local edit. Six native repo-swarm front doors are live: `epiphany-repo init --workspace ` writes the repo-swarm init receipt and branch workbench plan; `epiphany-swarm online --workspace ` seeds repo-local `.epiphany/local-verse.ccmp`, standing-faculty SoA, topology/liveness/tool/overview proof, and `.epiphany/swarm-online/repo-swarm-online-receipt.json`; `epiphany-work accept --workspace --from persona-or-bifrost --item ` routes a Persona/Bifrost item through CultMesh collaboration feedback into Imagination consensus discovery and writes `.epiphany/work/work-accept-.json` with no Hands, durable-state, or publication authority granted; `epiphany-work run --workspace [--item ]` persists a repo-local runtime-spine Substrate Gate read/snapshot grant, Hands intent, and Hands review with `decision=queued-for-adoption`; `epiphany-work adopt --workspace --item --plan-summary --adoption-evidence-ref ` requires explicit Imagination/Self/Mind adoption evidence and promotes that queued review to an approved branch-local Hands gate requiring patch/command/commit receipts; `epiphany-work publish --workspace --item ...` requires Hands commit proof plus Soul verification and Mind/review refs, routes Bifrost publication/GitHub publication receipts, records a Hands PR receipt, and keeps `upstreamMainSynced=false` / `mergeAuthorized=false`. Fresh-repo smokes proved init, online, accept, run, adopt, post-adoption `epiphany-hands-action record-pass`, and publish with `privateStateExposed=false`; pre-adoption gates still refuse record-pass. Next missing organ is a real autonomous executor that consumes approved gates instead of a smoke recorder, or a merge/sync gate that proves upstream main is actually synced after publication. - Agent memory lifecycle now has a first typed v0 operation surface in `epiphany-core::agent_memory`: `AgentMemoryLifecycleOperation` can revise, retire, crystallize, prune, and merge bounded memory records after role/agent review, and `epiphany-agent-memory-store review-lifecycle|apply-lifecycle` exposes the path at the operator edge. This closes the first explicit lifecycle-operation slice from the swarm-readiness gate; it does not yet make sleep silently mutate identity or project truth. - Persona public speech now has a parent-side eligibility receipt at the Discord/Aquarium mouth edge. `epiphany.persona_speech_audit.v0` records action kind, content fingerprint, opening/topic keys, recent-window counts, repeated opening/topic counts, channel saturation, and allow/block reasons. `epiphany-persona-discord post` blocks repeated public openings before token/webhook work; draft and bubble still emit audit receipts for operator inspection. The compatibility JSON artifact remains for display, but the durable witness is now `epiphany.cultmesh.persona_speech_audit.v0` in CultMesh with latest-key projection through local Verse context. Local MVP Persona bubbles now write that durable witness to `.epiphany-run/cultmesh/local-verse.ccmp`, not a separate mouth-side store. This is posting-edge policy, not a Persona prompt wish. - Grow the VoidBot repo-Persona pattern into Epiphany's product direction: each Epiphany owns one or more repos, has one or more Personas, and exposes project-native conversation through Aquarium, Discord, voice/WebRTC, stream surfaces, CLI, and CultNet clients so humans can talk to projects instead of pre-authoring complete implementation briefs. Persona is special because Imagination acts as Projector, turning typed state into narrative context before the Persona thinks, and Mind acts as Interpreter, turning natural Persona output into reviewed state/side-effect intents after the Persona thinks. @@ -633,4 +633,4 @@ current_status: - `tools/epiphany_local_run.ps1 -Mode swarm-online-runbook` now emits an explicit Idunn preflight summary before the operator elevation boundary. Its JSON and one-line summary report `preflightStatus`, child artifact present/hash-verified/mismatch/missing counts, aggregate service execution failed/missing check counts, child preflight rows with expected/actual SHA-256s, and private-state exposure. Live proof `local-20260619-025627-410-9724e2f6` generated the non-mutating parent artifact with `preflightStatus=ready-for-elevated-operator`, two child runbooks present, two hashes verified, zero mismatches, zero missing artifacts, eleven failed sealed service checks, zero missing checks, explicit aftercare audits, and `privateStateExposed=false`. The remaining scar is still explicit elevated operator execution followed by complete Idunn audits, not missing parent/child artifact readiness. - 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. - next_action: Continue the swarm-readiness cuts toward elevated operator install/start execution and completed audit/readiness for the seven installed services. Run generated service execution/install/control runbooks only when the operator grants that authority. The current local Verse proves liveness readiness, scheduler-policy coverage, daemon-body invocation, per-organ launch artifact generation, per-organ install-plan generation, non-elevated install/start/stop execution refusal, read-only installed-service audit, cluster-wide service control planning, service-lifecycle attention surfacing, and cluster execution audit acceptance criteria: `swarm-overview` now reports `status=attention`, `livenessStatus=ready`, `recoveryStatus=attention`, `recommendedWrapperMode=swarm-online-runbook`, and `recommendedWrapperCommand=tools/epiphany_local_run.ps1 -Mode swarm-online-runbook`; `service-tick` can refresh all seven daemon heartbeats through sealed scheduler receipts; `cluster-service-runbook` writes seven explicit `epiphany-cluster-daemon serve` commands with `privateStateExposed=false`; `cluster-service-install-plan` writes seven distinct Windows service install commands with `privateStateExposed=false`; `cluster-service-install-execute`, `cluster-service-start-execute`, and `cluster-service-stop-execute` refuse as `execution-refused-not-elevated` with `executed=false` when the shell lacks service authority; `cluster-service-start-plan` and `cluster-service-stop-plan` emit seven non-mutating planned rows; `cluster-service-audit` currently reports `incomplete` with seven missing services in this non-installed environment; `service-execution-runbook` and `cluster-service-execution-runbook` write elevated wrapper sequences that continue after per-step failure, run final audits in `finally`, exit nonzero after audit when any step failed, and seal typed runbook receipts with aftercare args (`stepFailurePolicy`, `continueAfterStepFailure`, `nonzeroExitFailsStep`, `exitsNonzeroAfterFinalAudit`); and `service-execution-audit` plus `cluster-service-execution-audit` now require those runbook witnesses before considering elevated-ready/install/start/audit/status/reconcile/stop effect receipts. Preserve the existing typed local Verse surfaces: `service-plan`, `service-launch`, `service-runbook`, `cluster-service-runbook`, `cluster-service-install-plan`, `cluster-service-install-execute`, `cluster-service-audit`, `cluster-service-start-plan`, `cluster-service-stop-plan`, `cluster-service-start-execute`, `cluster-service-stop-execute`, `cluster-service-execution-readiness`, `cluster-service-execution-runbook`, `cluster-service-execution-audit`, `service-execution-runbook`, `service-execution-audit`, `service-tick`, `service-policy-directory`, `agent-state-soa`, `swarm-status`, `swarm-poke-down`, `swarm-triage`, `cluster-topology`, `eve-surfaces`, `eve-connect`, `collaboration-feedback`, `bifrost-publication`, `bifrost-ledger`, `receipt-directory`, `tool-directory`, `tool-invoke`, `swarm-overview`, `swarm-online-runbook`, `seed-compact`, service manager status/reconcile/readiness/control wrappers, compact daemon scheduler/policy receipt rows, daemon liveness-gated tool routing, Bifrost/Imagination chains, coordinator-run receipts, Hands gates, role review mirrors, and sealed agent-state SoA summary. Keep the seven-standing-faculty SoA, stale-turn repair, memory lifecycle, shared local Verse witnesses, and typed CultMesh Persona speech gate intact. + next_action: Continue repo-swarm MVP work from the six live front doors. The current native chain proves `epiphany-repo init`, `epiphany-swarm online`, `epiphany-work accept`, `epiphany-work run`, `epiphany-work adopt`, post-adoption `epiphany-hands-action record-pass`, and `epiphany-work publish` through Bifrost/GitHub publication receipts with private state sealed and `upstreamMainSynced=false`. Next build either a real autonomous executor that consumes approved Hands gates without a smoke recorder, or a merge/sync gate that proves upstream main actually matches the accepted Bifrost publication. Preserve Idunn service lifecycle surfaces and the existing CultMesh/Odin/Eve tool directories while doing so; service install/start execution still requires explicit elevated operator authority.