Move grant policy into Substrate Gate

This commit is contained in:
Meta Vens 2026-07-12 23:39:58 +01:00
commit 22d8422ea3
8 changed files with 101 additions and 36 deletions

View file

@ -13,8 +13,6 @@ use epiphany_core::HandsActionIntent;
use epiphany_core::RuntimeSpineEventOptions;
use epiphany_core::RuntimeSpineInitOptions;
use epiphany_core::RuntimeSpineSessionOptions;
use epiphany_core::SUBSTRATE_GATE_REPO_ACCESS_GRANT_RECEIPT_SCHEMA_VERSION;
use epiphany_core::SubstrateGateRepoAccessGrantReceipt;
use epiphany_core::append_runtime_event;
use epiphany_core::create_runtime_session;
use epiphany_core::hands_action_review_for_intent;
@ -25,6 +23,7 @@ use epiphany_core::put_hands_action_intent;
use epiphany_core::put_hands_action_review;
use epiphany_core::put_substrate_gate_repo_access_grant_receipt;
use epiphany_core::runtime_spine_status;
use epiphany_core::substrate_gate_coordinator_implementation_grant;
use serde_json::Value;
use serde_json::json;
use std::collections::BTreeMap;
@ -816,25 +815,12 @@ fn record_hands_implementation_gate(
let grant_id = format!("substrate-grant-{runtime_job_id}");
let requested_paths = implementation_requested_paths(status);
let substrate_grant = SubstrateGateRepoAccessGrantReceipt {
schema_version: SUBSTRATE_GATE_REPO_ACCESS_GRANT_RECEIPT_SCHEMA_VERSION.to_string(),
receipt_id: grant_id.clone(),
runtime_job_id: runtime_job_id.clone(),
binding_id: "implementation-worker".to_string(),
role: "epiphany-hands".to_string(),
authority_scope: "epiphany.role.implementation".to_string(),
granted_operations: vec![
"read".to_string(),
"snapshot".to_string(),
"patch".to_string(),
"command".to_string(),
"commit".to_string(),
],
granted_paths: requested_paths.clone(),
granted_at: requested_at.clone(),
contract: "Substrate Gate grants the main Hands agent scoped repository access for the coordinator-approved implementation continuation; every mutation still needs Hands receipts."
.to_string(),
};
let substrate_grant = substrate_gate_coordinator_implementation_grant(
grant_id.clone(),
runtime_job_id.clone(),
requested_paths.clone(),
requested_at.clone(),
);
put_substrate_gate_repo_access_grant_receipt(runtime_store, &substrate_grant)?;
let intent = HandsActionIntent {

View file

@ -36,9 +36,7 @@ use epiphany_core::RepoWorkModelingRoute;
use epiphany_core::RuntimeSpineHeartbeatJobOptions;
use epiphany_core::RuntimeSpineInitOptions;
use epiphany_core::SOUL_VERDICT_RECEIPT_SCHEMA_VERSION;
use epiphany_core::SUBSTRATE_GATE_REPO_ACCESS_GRANT_RECEIPT_SCHEMA_VERSION;
use epiphany_core::SoulVerdictReceipt;
use epiphany_core::SubstrateGateRepoAccessGrantReceipt;
use epiphany_core::WeksaInterlinguaInput;
use epiphany_core::WeksaSpeakerContext;
use epiphany_core::advance_repo_work_modeling_route;
@ -81,6 +79,7 @@ use epiphany_core::runtime_repo_work_map_entry;
use epiphany_core::runtime_repo_work_modeling_finding;
use epiphany_core::runtime_repo_work_modeling_request;
use epiphany_core::runtime_repo_work_modeling_route;
use epiphany_core::substrate_gate_repo_work_planning_grant;
use epiphany_core::write_epiphany_cultmesh_repo_work_map_entry;
use epiphany_core::write_epiphany_cultmesh_repo_work_overview;
use epiphany_core::write_epiphany_cultmesh_repo_work_public_proof;
@ -1886,18 +1885,12 @@ fn run_work(args: RunArgs) -> Result<Value> {
let intent_id = format!("{run_id}-hands-intent");
let review_id = format!("{run_id}-hands-review");
let substrate_grant = SubstrateGateRepoAccessGrantReceipt {
schema_version: SUBSTRATE_GATE_REPO_ACCESS_GRANT_RECEIPT_SCHEMA_VERSION.to_string(),
receipt_id: substrate_grant_id.clone(),
runtime_job_id: runtime_job_id.clone(),
binding_id: "repo-work-runner".to_string(),
role: "epiphany-hands".to_string(),
authority_scope: "repo.branch_local_work".to_string(),
granted_operations: vec!["read".to_string(), "snapshot".to_string()],
granted_paths: requested_paths.clone(),
granted_at: now.clone(),
contract: "Substrate Gate grants read/snapshot access for work-run planning only; mutation awaits an approved Hands review.".to_string(),
};
let substrate_grant = substrate_gate_repo_work_planning_grant(
substrate_grant_id.clone(),
runtime_job_id.clone(),
requested_paths.clone(),
now.clone(),
);
put_substrate_gate_repo_access_grant_receipt(&runtime_store, &substrate_grant)?;
let intent = HandsActionIntent {

View file

@ -890,7 +890,9 @@ pub use substrate_gate::SUBSTRATE_GATE_REPO_SNAPSHOT_RECEIPT_TYPE;
pub use substrate_gate::SubstrateGateCultNetContract;
pub use substrate_gate::SubstrateGateRepoAccessGrantReceipt;
pub use substrate_gate::default_substrate_gate_cultnet_contracts;
pub use substrate_gate::substrate_gate_coordinator_implementation_grant;
pub use substrate_gate::substrate_gate_repo_access_grant_for_launch;
pub use substrate_gate::substrate_gate_repo_work_planning_grant;
pub use surfaces::EpiphanyAcceptanceBundle;
pub use surfaces::EpiphanyContext;
pub use surfaces::EpiphanyContextMissing;

View file

@ -33,6 +33,7 @@ pub const SUBSTRATE_GATE_REPO_MUTATION_RECEIPT_SCHEMA_VERSION: &str =
type = "epiphany.substrate_gate.repo_access_grant_receipt",
schema = "SubstrateGateRepoAccessGrantReceipt"
)]
#[non_exhaustive]
pub struct SubstrateGateRepoAccessGrantReceipt {
#[cultcache(key = 0)]
pub schema_version: String,
@ -156,6 +157,52 @@ pub fn substrate_gate_repo_access_grant_for_launch(
}
}
pub fn substrate_gate_repo_work_planning_grant(
receipt_id: String,
runtime_job_id: String,
granted_paths: Vec<String>,
granted_at: String,
) -> SubstrateGateRepoAccessGrantReceipt {
SubstrateGateRepoAccessGrantReceipt {
schema_version: SUBSTRATE_GATE_REPO_ACCESS_GRANT_RECEIPT_SCHEMA_VERSION.to_string(),
receipt_id,
runtime_job_id,
binding_id: "repo-work-runner".to_string(),
role: "epiphany-hands".to_string(),
authority_scope: "repo.branch_local_work".to_string(),
granted_operations: vec!["read".to_string(), "snapshot".to_string()],
granted_paths,
granted_at,
contract: "Substrate Gate grants read/snapshot access for repo-work planning only; mutation awaits an approved Hands review.".to_string(),
}
}
pub fn substrate_gate_coordinator_implementation_grant(
receipt_id: String,
runtime_job_id: String,
granted_paths: Vec<String>,
granted_at: String,
) -> SubstrateGateRepoAccessGrantReceipt {
SubstrateGateRepoAccessGrantReceipt {
schema_version: SUBSTRATE_GATE_REPO_ACCESS_GRANT_RECEIPT_SCHEMA_VERSION.to_string(),
receipt_id,
runtime_job_id,
binding_id: "implementation-worker".to_string(),
role: "epiphany-hands".to_string(),
authority_scope: "epiphany.role.implementation".to_string(),
granted_operations: vec![
"read".to_string(),
"snapshot".to_string(),
"patch".to_string(),
"command".to_string(),
"commit".to_string(),
],
granted_paths,
granted_at,
contract: "Substrate Gate grants scoped repository access for a coordinator-approved implementation continuation; every mutation still needs Hands receipts.".to_string(),
}
}
#[cfg(test)]
mod tests {
use super::*;
@ -235,4 +282,28 @@ mod tests {
assert!(!grant.granted_operations.contains(&"write".to_string()));
assert!(grant.contract.contains("mutation remains forbidden"));
}
#[test]
fn repo_work_and_implementation_grants_have_fixed_policies() {
let planning = substrate_gate_repo_work_planning_grant(
"planning-grant".to_string(),
"planning-job".to_string(),
vec!["README.md".to_string()],
"2026-07-12T00:00:00Z".to_string(),
);
assert_eq!(planning.binding_id, "repo-work-runner");
assert_eq!(planning.granted_operations, vec!["read", "snapshot"]);
let implementation = substrate_gate_coordinator_implementation_grant(
"implementation-grant".to_string(),
"implementation-job".to_string(),
vec!["src".to_string()],
"2026-07-12T00:00:00Z".to_string(),
);
assert_eq!(implementation.binding_id, "implementation-worker");
assert_eq!(
implementation.granted_operations,
vec!["read", "snapshot", "patch", "command", "commit"]
);
}
}

View file

@ -401,3 +401,13 @@ map entry. Both flags and fields are deleted. Soul derives its summary from the
actual failed/passed invariant, and initial Mind admission deterministically
uses revision zero; subsequent evolution is represented by the typed Modeling
route generation rather than a decorative caller number.
## Hands binaries constructing their own Substrate Gate grants
Repo-work and MVP-coordinator Hands paths assembled grant receipt literals
inline, then persisted the badge they had just awarded themselves. Grant
records are now non-exhaustive outside the library, and the `substrate_gate`
module owns narrow fixed-policy constructors for repo-work planning and
coordinator-approved implementation. Production binaries no longer choose the
binding, role, authority scope, operation set, schema, or contract prose field
by field.

View file

@ -100,6 +100,9 @@ The confirmed conceptual substitutions have been cut:
- callers cannot overwrite Soul verdict narration or choose Mind's immutable
admission revision. Soul derives the explanation; initial map admission is
revision zero and later evolution uses typed Modeling route generations.
- Hands binaries no longer construct Substrate Gate grant structs inline.
Grants are non-exhaustive externally and come from narrow fixed-policy
constructors owned by the `substrate_gate` module.
The presentation boundary is now plain: `swarm overview` is a generic compact read-only projection. Gjallar is a downstream TUI application on Nightwing and is not an Epiphany organ, provider, owner, runtime, or architectural dependency. Eve/CultUI graphs may be lowered or composited downstream without Epiphany caring which presentation client does it.

Binary file not shown.

View file

@ -660,4 +660,4 @@ current_status:
- Service lifecycle receipt history is now event-only: `load_epiphany_cultmesh_daemon_service_lifecycle_receipts` filters out the `epiphany-local/daemon-service-lifecycle-receipt/latest` mirror, while `load_latest_epiphany_cultmesh_daemon_service_lifecycle_receipt` remains the latest-state reader. Focused unit test `service_lifecycle_receipt_history_excludes_latest_mirror` proves two per-receipt writes return exactly two history records and latest points at the second. Fresh smoke `verse-query-lifecycle-history-filter-smoke` and live overview/triage `local-20260618-145632-497-efac6f0d` / `local-20260618-145632-321-867947af` prove compact swarm sights still expose service lifecycle attention plus the present elevated runbook artifact without daemon pokes or service mutation. Do not use a broad unscoped cargo test filter for this check on Windows; it fans out across bin harnesses and hit a broken pipe during this pass.
- `epiphany-verse-query seed-compact` is the compact seed receipt for wrappers and read-only rites. The older `seed` command still prints the full local Verse context for explicit debugging, but compact wrapper modes now avoid full `seed`/final `query` readback after the combined overview proof exposed Windows debug stack overflow from full-context serialization pressure.
last_completed_repo_swarm_cut: Huginn live-fire has crossed the first real repo Body from Persona pressure to branch-local Hands commit and Soul/Mind closure, and now has repeatable closure and redacted-public-proof mouths. On `E:\Projects\Huginn` branch `epiphany/huginn/first-awakening`, `tools/epiphany_local_run.ps1 -Mode repo-persona-intake` accepted item `huginn-inspection-readback-livefire`, Weksa/Persona intake remained sealed, and `epiphany-work derive-plan` lowered it to model-authored safe family `repo.status_section` for `README.md` only. `tools/epiphany_local_run.ps1 -Mode repo-swarm-run` advanced four bounded pulses: run-from-plan, adopt-from-plan, execute-from-plan, and close-from-execute. Huginn commit `e9b07c38fceabbdc89ea35c2156326c80c0393a2` updated only `README.md`; closure receipt `.epiphany\work\work-close-huginn-inspection-readback-livefire.json` records status `closed`, Soul verdict `passed`, Mind state commit `repo-work-close-huginn-inspection-readback-livefire-mind-commit`, safe family `repo.status_section`, path scope `README.md`, Bifrost publication gate, and `privateStateExposed=false`. Verification also ran Huginn's TypeScript compiler through concrete Node path: `C:\Program Files\nodejs\node.exe E:\Projects\Huginn\node_modules\typescript\bin\tsc -p tsconfig.json` passed. Native verifier `epiphany-repo-livefire-closure-smoke --workspace E:\Projects\Huginn --item huginn-inspection-readback-livefire --expected-path README.md --expected-family repo.status_section --expected-gate awaiting-publication --expected-blocker bifrost-publication-missing` checks closure receipt, Mind map entry, overview gate/blocker, authority seals, and `git show` changed paths, returning `status=ok`, `soulVerdict=passed`, `publicationGate=Bifrost`, and `privateStateExposed=false`. Wrapper `tools/epiphany_local_run.ps1 -Mode repo-livefire-closure -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exposes the same read-only proof through the local operator mouth; artifact `local-20260621-190156-803-2f85ba15` printed commit, path, gate, blocker, Soul verdict, Mind commit receipt, and `privateStateExposed=False` without push, merge, publication, or target mutation. New wrapper `tools/epiphany_local_run.ps1 -Mode repo-work-public-proof -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exports the redacted proof bundle and repo-local Verse index without publishing; artifact `local-20260621-190645-345-4555b1dc` wrote `.epiphany\public\proof-bundles\repo-work-public-proof-huginn-inspection-readback-livefire.json`, proof id `repo-work-public-proof-huginn-inspection-readback-livefire`, SHA-256 `857545b199f3e37eb06c2e757e5cfc201958e46667bb1f8403fd333a22620f63`, nine artifact rows, zero publication rows, and `privateStateExposed=False`. swarm overview readback `local-20260621-190701-140-b9519ec6` sees the `REPO-WORK-PUBLIC-PROOF` row and action row from Huginn's repo-local Verse with the same SHA-256 while Bifrost publication remains missing. Launcher compact modes are now named compact operator-context modes instead of read-only modes, and `bifrost-public-proof` summaries print item, target public Verse, room, proof SHA-256, review receipts, and credit receipts so publication receipts are auditable without claiming upstream sync.
next_action: Continue the conceptual-substitution modeling pass beyond receipt writers. Publication/PR/provider authority is sealed; closure reads immutable Modeling truth; Soul owns verification and narration; Mind initial admission revision is derived while later evolution uses typed Modeling generations. Audit remaining public receipt writers by named owner, especially Substrate/Hands runtime writers and daemon lifecycle paths, then inventory projections, caches, adapters, schedulers, coordinators, and compatibility surfaces that assert facts owned elsewhere.
next_action: Continue the conceptual-substitution modeling pass beyond receipt writers. Publication/PR/provider authority is sealed; Modeling/Soul/Mind closure is single-sourced; Hands binaries no longer self-assemble Substrate grants, which now come from narrow non-exhaustive module-owned policies. Audit persistence so Hands intents and receipts resolve and match the actual grant rather than merely naming its id, then inspect daemon lifecycle writers and remaining projections/caches/adapters for substituted authority.