Add repo work execution gate

This commit is contained in:
Meta Vens 2026-06-19 22:59:28 +01:00
commit 3885f3fa1c
5 changed files with 461 additions and 9 deletions

View file

@ -12,10 +12,16 @@ 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_command_receipt_for_review;
use epiphany_core::hands_commit_receipt_for_review;
use epiphany_core::hands_patch_receipt_for_review;
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_command_receipt;
use epiphany_core::put_hands_commit_receipt;
use epiphany_core::put_hands_patch_receipt;
use epiphany_core::put_hands_pr_receipt;
use epiphany_core::put_substrate_gate_repo_access_grant_receipt;
use epiphany_core::runtime_hands_action_intent;
@ -40,6 +46,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)?),
"execute" | "exec" => run_execute(parse_execute_args(args)?),
"publish" => run_publish(parse_publish_args(args)?),
other => Err(anyhow!("unknown epiphany-work command {other:?}")),
}?;
@ -87,6 +94,20 @@ struct AdoptArgs {
adoption_evidence_refs: Vec<String>,
}
#[derive(Clone, Debug)]
struct ExecuteArgs {
workspace: PathBuf,
epiphany_root: PathBuf,
item: Option<String>,
adopt_receipt: Option<PathBuf>,
runtime_store: Option<PathBuf>,
artifact_dir: Option<PathBuf>,
command: String,
changed_paths: Vec<String>,
commit_message: String,
summary: Option<String>,
}
#[derive(Clone, Debug)]
struct PublishArgs {
workspace: PathBuf,
@ -263,6 +284,58 @@ fn parse_adopt_args(args: impl Iterator<Item = String>) -> Result<AdoptArgs> {
})
}
fn parse_execute_args(args: impl Iterator<Item = String>) -> Result<ExecuteArgs> {
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 artifact_dir = None;
let mut command = None;
let mut changed_paths = Vec::new();
let mut commit_message = None;
let mut summary = 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")?),
"--artifact-dir" => artifact_dir = Some(take_path(&mut args, "--artifact-dir")?),
"--command" => command = Some(take_string(&mut args, "--command")?),
"--changed-path" | "--path" => {
changed_paths.push(take_string(&mut args, "--changed-path")?);
}
"--commit-message" => {
commit_message = Some(take_string(&mut args, "--commit-message")?)
}
"--summary" => summary = Some(take_string(&mut args, "--summary")?),
other => return Err(anyhow!("unexpected execute argument {other:?}")),
}
}
if changed_paths.is_empty() {
return Err(anyhow!(
"execute requires at least one --changed-path scoped by the approved Hands gate"
));
}
Ok(ExecuteArgs {
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,
artifact_dir,
command: command.context("missing --command")?,
changed_paths,
commit_message: commit_message.context("missing --commit-message")?,
summary,
})
}
fn parse_publish_args(args: impl Iterator<Item = String>) -> Result<PublishArgs> {
let mut workspace = None;
let mut epiphany_root = None;
@ -850,6 +923,206 @@ fn run_adopt(args: AdoptArgs) -> Result<Value> {
}))
}
fn run_execute(args: ExecuteArgs) -> Result<Value> {
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 adopt_receipt_path =
resolve_adopt_receipt(&workspace, args.item.as_deref(), args.adopt_receipt)?;
let adopt_receipt = read_json(&adopt_receipt_path)?;
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 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}"))?;
ensure_hands_review_allows(&intent, &review, "patch")?;
ensure_hands_review_allows(&intent, &review, "command")?;
ensure_hands_review_allows(&intent, &review, "commit")?;
validate_paths_within_gate(&intent, &args.changed_paths)?;
let branch = git_output(&workspace, &["branch", "--show-current"])?;
if !branch.starts_with("epiphany/") {
return Err(anyhow!(
"execute requires an epiphany/* work branch; current branch is {branch:?}"
));
}
let item = adopt_receipt
.get("item")
.and_then(Value::as_str)
.unwrap_or("work-item")
.to_string();
let item_slug = sanitize(&item);
let stdout_artifact = artifact_dir.join(format!("work-execute-{item_slug}.stdout.log"));
let stderr_artifact = artifact_dir.join(format!("work-execute-{item_slug}.stderr.log"));
let execution = Command::new("powershell")
.arg("-NoProfile")
.arg("-Command")
.arg(&args.command)
.current_dir(&workspace)
.output()
.with_context(|| format!("failed to execute command in {}", workspace.display()))?;
fs::write(&stdout_artifact, &execution.stdout)
.with_context(|| format!("failed to write {}", stdout_artifact.display()))?;
fs::write(&stderr_artifact, &execution.stderr)
.with_context(|| format!("failed to write {}", stderr_artifact.display()))?;
let exit_code = execution
.status
.code()
.map(|code| code.to_string())
.unwrap_or_else(|| "terminated-by-signal".to_string());
let now = Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
let summary = args
.summary
.unwrap_or_else(|| format!("Executed approved repo work item {item} on branch {branch}."));
let command_receipt_id = format!("repo-work-execute-{item_slug}-hands-command");
let command_receipt = hands_command_receipt_for_review(
command_receipt_id,
&intent,
&review,
args.command.clone(),
exit_code.clone(),
normalize_path_for_receipt(&stdout_artifact),
normalize_path_for_receipt(&stderr_artifact),
summary.clone(),
now.clone(),
);
put_hands_command_receipt(&runtime_store, &command_receipt)?;
if !execution.status.success() {
let failed_receipt = json!({
"schemaVersion": "epiphany.repo_work_execute_receipt.v0",
"createdAt": now,
"workspace": workspace,
"runtimeStore": runtime_store,
"adoptReceiptPath": adopt_receipt_path,
"item": item,
"status": "command-failed",
"branch": branch,
"changedPaths": args.changed_paths,
"commandReceiptId": command_receipt.receipt_id,
"exitCode": command_receipt.exit_code,
"stdoutArtifact": command_receipt.stdout_artifact,
"stderrArtifact": command_receipt.stderr_artifact,
"privateStateExposed": false,
});
let receipt_path = artifact_dir.join(format!("work-execute-{item_slug}.json"));
write_json(&receipt_path, &failed_receipt)?;
return Ok(json!({
"schemaVersion": "epiphany.repo_work_execute.v0",
"status": failed_receipt["status"],
"workspace": failed_receipt["workspace"],
"receiptPath": receipt_path,
"item": failed_receipt["item"],
"handsReceipts": {
"commandReceiptId": failed_receipt["commandReceiptId"]
},
"privateStateExposed": false,
"nextSafeMove": "Inspect command artifacts and either rerun execution after a new adoption review or record a failure review."
}));
}
let normalized_paths = normalize_paths(args.changed_paths.clone());
let patch_receipt_id = format!("repo-work-execute-{item_slug}-hands-patch");
let patch_receipt = hands_patch_receipt_for_review(
patch_receipt_id,
&intent,
&review,
normalized_paths.clone(),
summary.clone(),
now.clone(),
);
put_hands_patch_receipt(&runtime_store, &patch_receipt)?;
git_add_paths(&workspace, &normalized_paths)?;
ensure_staged_changes(&workspace)?;
git_commit(&workspace, &args.commit_message)?;
let commit_sha = git_output(&workspace, &["rev-parse", "HEAD"])?;
let commit_receipt_id = format!("repo-work-execute-{item_slug}-hands-commit");
let commit_receipt = hands_commit_receipt_for_review(
commit_receipt_id,
&intent,
&review,
commit_sha,
branch.clone(),
normalized_paths.clone(),
summary.clone(),
Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true),
);
put_hands_commit_receipt(&runtime_store, &commit_receipt)?;
let execute_receipt = json!({
"schemaVersion": "epiphany.repo_work_execute_receipt.v0",
"createdAt": now,
"workspace": workspace,
"runtimeStore": runtime_store,
"adoptReceiptPath": adopt_receipt_path,
"item": item,
"status": "branch-local-commit-recorded",
"branch": branch,
"changedPaths": normalized_paths,
"command": command_receipt.command,
"exitCode": command_receipt.exit_code,
"stdoutArtifact": command_receipt.stdout_artifact,
"stderrArtifact": command_receipt.stderr_artifact,
"handsReceipts": {
"patchReceiptId": patch_receipt.receipt_id,
"commandReceiptId": command_receipt.receipt_id,
"commitReceiptId": commit_receipt.receipt_id,
"commitSha": commit_receipt.commit_sha
},
"authority": {
"branchLocalCommitCreated": true,
"publicationAuthorized": false,
"durableStateAdmitted": false,
"privateStateExposed": false
},
"nextSafeMove": "Route Soul verification and Mind review before publication; use epiphany-work publish only after review receipts exist."
});
let receipt_path = artifact_dir.join(format!("work-execute-{item_slug}.json"));
write_json(&receipt_path, &execute_receipt)?;
Ok(json!({
"schemaVersion": "epiphany.repo_work_execute.v0",
"status": execute_receipt["status"],
"workspace": execute_receipt["workspace"],
"runtimeStore": execute_receipt["runtimeStore"],
"receiptPath": receipt_path,
"item": execute_receipt["item"],
"branch": execute_receipt["branch"],
"changedPaths": execute_receipt["changedPaths"],
"handsReceipts": execute_receipt["handsReceipts"],
"authority": execute_receipt["authority"],
"privateStateExposed": false,
"nextSafeMove": execute_receipt["nextSafeMove"],
}))
}
fn run_publish(args: PublishArgs) -> Result<Value> {
let workspace = args
.workspace
@ -1237,6 +1510,148 @@ fn latest_receipt_in(work_dir: &Path, prefix: &str) -> Option<PathBuf> {
candidates.pop().map(|(_modified, path)| path)
}
fn ensure_hands_review_allows(
intent: &HandsActionIntent,
review: &epiphany_core::HandsActionReview,
operation: &str,
) -> Result<()> {
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
));
}
if !review
.allowed_operations
.iter()
.any(|allowed| allowed == operation)
{
return Err(anyhow!(
"Hands review {} does not allow {operation}",
review.review_id
));
}
Ok(())
}
fn validate_paths_within_gate(intent: &HandsActionIntent, paths: &[String]) -> Result<()> {
let requested = normalize_paths(intent.requested_paths.clone());
for path in paths {
let normalized = normalize_path(path);
if requested.iter().any(|allowed| {
allowed == "."
|| normalized == *allowed
|| normalized.starts_with(&format!("{}/", allowed.trim_end_matches('/')))
}) {
continue;
}
return Err(anyhow!(
"changed path {normalized:?} is outside approved Hands path scope {:?}",
requested
));
}
Ok(())
}
fn normalize_paths(paths: Vec<String>) -> Vec<String> {
paths
.into_iter()
.map(|path| normalize_path(&path))
.collect()
}
fn normalize_path(path: &str) -> String {
let normalized = path.replace('\\', "/");
let trimmed = normalized.trim();
if trimmed.is_empty() {
".".to_string()
} else {
trimmed.trim_start_matches("./").to_string()
}
}
fn normalize_path_for_receipt(path: &Path) -> String {
path.display().to_string().replace('\\', "/")
}
fn git_output(workspace: &Path, args: &[&str]) -> Result<String> {
let output = Command::new("git")
.arg("-C")
.arg(workspace)
.args(args)
.output()
.with_context(|| format!("failed to run git {}", args.join(" ")))?;
if !output.status.success() {
return Err(anyhow!(
"git {} failed: {}",
args.join(" "),
String::from_utf8_lossy(&output.stderr)
));
}
Ok(String::from_utf8_lossy(&output.stdout).trim().to_string())
}
fn git_add_paths(workspace: &Path, paths: &[String]) -> Result<()> {
let mut command = Command::new("git");
command.arg("-C").arg(workspace).arg("add").arg("--");
for path in paths {
command.arg(path);
}
let output = command
.output()
.with_context(|| format!("failed to run git add in {}", workspace.display()))?;
if output.status.success() {
Ok(())
} else {
Err(anyhow!(
"git add failed: {}",
String::from_utf8_lossy(&output.stderr)
))
}
}
fn ensure_staged_changes(workspace: &Path) -> Result<()> {
let output = Command::new("git")
.arg("-C")
.arg(workspace)
.args(["diff", "--cached", "--quiet"])
.output()
.with_context(|| format!("failed to inspect staged diff in {}", workspace.display()))?;
if output.status.success() {
Err(anyhow!(
"execute staged no changed paths; refusing empty commit"
))
} else {
Ok(())
}
}
fn git_commit(workspace: &Path, message: &str) -> Result<()> {
let output = Command::new("git")
.arg("-C")
.arg(workspace)
.args(["commit", "-m", message])
.output()
.with_context(|| format!("failed to run git commit in {}", workspace.display()))?;
if output.status.success() {
Ok(())
} else {
Err(anyhow!(
"git commit failed: {}",
String::from_utf8_lossy(&output.stderr)
))
}
}
fn cargo_json(manifest_path: &Path, bin_name: &str, args: &[String]) -> Result<Value> {
let output = Command::new("cargo")
.arg("run")

View file

@ -132,6 +132,7 @@ epiphany-swarm online --workspace <repo>
epiphany-work accept --workspace <repo> --from persona-or-bifrost --item <id>
epiphany-work run --workspace <repo>
epiphany-work adopt --workspace <repo> --item <id> --plan-summary <text> --adoption-evidence-ref <ref>
epiphany-work execute --workspace <repo> --item <id> --command <command> --changed-path <path> --commit-message <text>
epiphany-work publish --workspace <repo>
```
@ -280,10 +281,45 @@ 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.
### Landed Work Publication Gate
### Landed Work Execution Gate
The sixth front door exists as native Rust:
```powershell
cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-work -- execute --workspace <repo> --item <id> --command <command> --changed-path <path> --commit-message <text>
```
It reads the named or latest work-adopt receipt, requires an approved Hands
gate that allows `patch`, `command`, and `commit`, verifies the declared changed
paths are inside the Hands intent path scope, requires the repo to be on an
`epiphany/*` branch, runs the command inside the repo Body, captures stdout and
stderr artifacts, stages only the declared changed paths, creates a branch-local
git commit, and writes the typed Hands patch, command, and commit receipts.
This is the first native executor for repo-swarm work. It removes the smoke
recorder from the normal branch-local execution path. It still does not verify
the consequence, admit durable state, authorize publication, merge, or claim
upstream main is synced.
The first smoke proved:
```powershell
epiphany-repo init --workspace <repo> --switch-branch
epiphany-swarm online --workspace <repo>
epiphany-work accept --workspace <repo> --from persona --item first-request
epiphany-work run --workspace <repo> --item first-request --requested-path README.md
epiphany-work adopt --workspace <repo> --item first-request --plan-summary '...' --adoption-evidence-ref 'imagination-consensus:repo-work-consensus-first-request'
epiphany-work execute --workspace <repo> --item first-request --command "Add-Content -Path README.md -Value '...'" --changed-path README.md --commit-message 'Execute approved repo work'
```
The execute receipt produced a real branch-local commit on
`epiphany/smoke/execute`, Hands patch/command/commit receipts,
`publicationAuthorized=false`, and `privateStateExposed=false`.
### Landed Work Publication Gate
The seventh front door exists as native Rust:
```powershell
cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-work -- publish --workspace <repo> --item <id> --change-summary <text> --justification <text> --verification-receipt <ref> --review-receipt <ref> --ledger-entry-id <id> --pull-request-url <url> --pull-request-title <text>
```
@ -300,7 +336,7 @@ This is publication routing, not merge authority:
`mergeAuthorized=false`. Upstream main is not considered synced until a later
merge/sync receipt proves it.
The first smoke proved the six-command sequence:
The first smoke proved the publication sequence:
```powershell
epiphany-repo init --workspace <repo>
@ -308,15 +344,16 @@ epiphany-swarm online --workspace <repo>
epiphany-work accept --workspace <repo> --from persona --item first-request
epiphany-work run --workspace <repo> --item first-request
epiphany-work adopt --workspace <repo> --item first-request --plan-summary '...' --adoption-evidence-ref 'imagination-consensus:repo-work-consensus-first-request'
epiphany-work execute --workspace <repo> --item first-request --command '...' --changed-path README.md --commit-message '...'
epiphany-work publish --workspace <repo> --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.
`upstreamMainSynced=false` guard. The next cut is a merge/sync gate that can
prove upstream main actually matches the accepted publication, plus a less
manual planner/executor bridge that supplies executable commands from
Imagination/Self rather than operator CLI arguments.
## Migration Implication

View file

@ -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. Six native repo-swarm front doors are now live: `epiphany-repo init --workspace <repo>` writes the repo-swarm init receipt and branch workbench plan; `epiphany-swarm online --workspace <repo>` 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 <repo> --from persona-or-bifrost --item <id>` routes a Persona/Bifrost item through CultMesh collaboration feedback into Imagination consensus discovery and writes `.epiphany/work/work-accept-<item>.json` with no Hands, durable-state, or publication authority granted; `epiphany-work run --workspace <repo> [--item <id>]` 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 <repo> --item <id> --plan-summary <text> --adoption-evidence-ref <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 <repo> --item <id> ...` 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.
- `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. Seven native repo-swarm front doors are now live: `epiphany-repo init --workspace <repo>` writes the repo-swarm init receipt and branch workbench plan; `epiphany-swarm online --workspace <repo>` 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 <repo> --from persona-or-bifrost --item <id>` routes a Persona/Bifrost item through CultMesh collaboration feedback into Imagination consensus discovery and writes `.epiphany/work/work-accept-<item>.json` with no Hands, durable-state, or publication authority granted; `epiphany-work run --workspace <repo> [--item <id>]` 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 <repo> --item <id> --plan-summary <text> --adoption-evidence-ref <ref>` requires explicit Imagination/Self/Mind adoption evidence and promotes that queued review to an approved branch-local Hands gate; `epiphany-work execute --workspace <repo> --item <id> --command <command> --changed-path <path> --commit-message <text>` consumes the approved gate on an `epiphany/*` branch, runs the command in the repo Body, captures stdout/stderr artifacts, stages only declared paths, commits, and records Hands patch/command/commit receipts; `epiphany-work publish --workspace <repo> --item <id> ...` 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, execute, and publish with `privateStateExposed=false`; pre-adoption gates still refuse record-pass. Next missing organ: a merge/sync gate that proves upstream main is actually synced after publication, plus a less-manual planner/executor bridge that supplies executable commands from Imagination/Self rather than operator CLI arguments.
- `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.

Binary file not shown.

View file

@ -88,7 +88,7 @@ active_subgoals:
- Keep the landed Phase 6 coordinator, limited safe-boundary CRRC automation, and pre-compaction checkpoint intervention ready for the next bridge-equipped dogfood run.
- Preserve the Ghostlight-derived heartbeat initiative seam: every lane, including coordinator/Self and Persona, has a organ-state record and competes for heartbeat slots through readiness/reaction timing; initiative heat can raise or cool global, group, arena, role, and agent tempo through typed heartbeat policy; active thinking freezes initiative until completion, so heat never queues a lane already mid-turn; idle winners ruminate instead of inventing project work, and sleep windows distill the accumulated thought pressure into reviewed self-memory or doctrine.
- Use `notes/epiphany-swarm-readiness-plan.md` as the live-fire direction gate. The local run path is a compass, not launch clearance: before unattended swarm operation, Epiphany needs typed pause/brake enforcement, one initiative scheduler, completion-gated cooldown, stale active-turn recovery receipts, parent-side Persona speech eligibility, memory lifecycle operations, and CultNet-first operator snapshots/intents/receipts. The local Verse brake document exists, `epiphany-verse-query swarm-brake` can engage/release it, `tools/epiphany_local_run.ps1` refuses live `plan`/`run`/`mvp` modes when the brake is engaged while leaving `status` readable, `epiphany-mvp-coordinator` checks the local Verse brake before app-server startup, and `epiphany-heartbeat-store` guards tick/pump/heat/queue-mention/routine when given `--local-verse-store`. Daemon liveness is now a typed local Verse authority: `epiphany-verse-query daemon-status` writes one daemon status without repainting the table, local Verse seeding preserves existing daemon statuses and swarm brakes, `invoke-tool` refuses when the host daemon is not ready or lacks `submitTypedToolIntent`, and both daemon tool invocation and lifecycle poke fail closed under an engaged matching brake. `epiphany-daemon-supervisor policy` writes durable per-daemon restart policy with command/args/cwd/cooldown/backoff/attempt state plus reconcile cadence and stale-heartbeat threshold; `epiphany-daemon-supervisor reconcile` loads that policy when no override command is supplied, refuses under a matching lifecycle brake, refuses during cooldown/backoff, writes daemon poke intent/receipt, updates daemon status, and updates policy attempt state; `epiphany-daemon-supervisor tick` is an explicit scheduler pulse that scans durable policies, records ready/noop pulses, skips before the configured reconcile interval, marks stale heartbeat status degraded, routes restarts through the same brake/cooldown/poke receipt path, and writes a latest `epiphany.cultmesh.daemon_scheduler_receipt.v0`; `epiphany-daemon-supervisor serve` runs that same pulse on a configurable cadence with bounded `--max-iterations` proof mode or unbounded service mode. `epiphany-daemon-supervisor service-plan`/`install-service` now writes a planned `epiphany.cultmesh.daemon_service_lifecycle_receipt.v0` for the `serve` command, while `service-launch`/`start-service` spawns that `serve` loop through the current executable or `--service-command`, can `--wait-child` for bounded proof, and records command/args/cwd, scheduler id, daemon selector, pid/exit/status, artifact ref, and private-state guard. `service-runbook`, `windows-service-install`/`service-install-plan`, `windows-service-status`, `windows-service-reconcile`, `windows-service-execution-readiness`, and `windows-service-start`/`stop` now record service lifecycle receipts through the same local Verse; the read-only status path has been proved against the real Windows `EventLog` service with receipt `daemon-service-lifecycle-receipt-windows-eventlog-proof-windows-service-status`, status `running`, exit code `0`, and `privateStateExposed=false`; the read-only service-policy reconciliation path has been proved for missing service, real-service drift against `EventLog`, lifecycle-brake refusal, and wrapper/local-Verse receipt `daemon-service-lifecycle-receipt-windows-eventlog-reconcile-proof-windows-service-reconcile`; execution readiness has been proved as a non-mutating `not-elevated` receipt through direct and wrapper paths; start/stop now produce non-mutating `start-planned`/`stop-planned` receipts unless `--execute-control`/`--execute-service-control` is passed, and wrapper `service-start-plan`/`service-stop-plan` proves those receipts against `EventLog`; explicit install/control execution now refuses as `execution-refused-not-elevated` with `executed=false` when the shell lacks Windows administrator authority, and wrapper `service-install-execute`, `service-start-execute`, and `service-stop-execute` prove those refusal receipts without mutation. Service lifecycle actions check the local Verse swarm brake before process launch, artifact writes, service-manager queries, service-policy reconciliation, execution-readiness checks, control planning, elevation-gated execution, or start/stop execution. The local wrapper builds/checks this binary.
- 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 <repo>` writes the repo-swarm init receipt and branch workbench plan; `epiphany-swarm online --workspace <repo>` 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 <repo> --from persona-or-bifrost --item <id>` routes a Persona/Bifrost item through CultMesh collaboration feedback into Imagination consensus discovery and writes `.epiphany/work/work-accept-<item>.json` with no Hands, durable-state, or publication authority granted; `epiphany-work run --workspace <repo> [--item <id>]` 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 <repo> --item <id> --plan-summary <text> --adoption-evidence-ref <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 <repo> --item <id> ...` 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.
- 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. Seven native repo-swarm front doors are live: `epiphany-repo init --workspace <repo>` writes the repo-swarm init receipt and branch workbench plan; `epiphany-swarm online --workspace <repo>` 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 <repo> --from persona-or-bifrost --item <id>` routes a Persona/Bifrost item through CultMesh collaboration feedback into Imagination consensus discovery and writes `.epiphany/work/work-accept-<item>.json` with no Hands, durable-state, or publication authority granted; `epiphany-work run --workspace <repo> [--item <id>]` 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 <repo> --item <id> --plan-summary <text> --adoption-evidence-ref <ref>` requires explicit Imagination/Self/Mind adoption evidence and promotes that queued review to an approved branch-local Hands gate; `epiphany-work execute --workspace <repo> --item <id> --command <command> --changed-path <path> --commit-message <text>` consumes the approved gate on an `epiphany/*` branch, runs the command in the repo Body, captures stdout/stderr artifacts, stages only declared paths, commits, and records Hands patch/command/commit receipts; `epiphany-work publish --workspace <repo> --item <id> ...` 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, execute, and publish with `privateStateExposed=false`; pre-adoption gates still refuse record-pass. Next missing organ is a merge/sync gate that proves upstream main is actually synced after publication, plus a less-manual planner/executor bridge that supplies executable commands from Imagination/Self rather than operator CLI arguments.
- 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 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.
next_action: Continue repo-swarm MVP work from the seven live front doors. The current native chain proves `epiphany-repo init`, `epiphany-swarm online`, `epiphany-work accept`, `epiphany-work run`, `epiphany-work adopt`, `epiphany-work execute`, and `epiphany-work publish` through branch-local Hands receipts and Bifrost/GitHub publication receipts with private state sealed and `upstreamMainSynced=false`. Next build either a merge/sync gate that proves upstream main actually matches the accepted Bifrost publication, or a less-manual planner/executor bridge that supplies executable commands from Imagination/Self rather than operator CLI arguments. 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.