Bind public Eyes evidence to exact source authority
This commit is contained in:
parent
43dc865e0f
commit
8fb61ac236
18 changed files with 1037 additions and 35 deletions
|
|
@ -201,14 +201,48 @@ pub fn accept_coordinator_role_finding(
|
|||
let mut available = vec![MIND_GATEWAY_REVIEW_TYPE.to_string()];
|
||||
let mut prerequisites = Vec::new();
|
||||
if role_id == EpiphanyRoleResultRoleId::Research {
|
||||
let public_source_lookups = runtime_authenticated_public_source_lookups_for_worker(
|
||||
store,
|
||||
finding.runtime_job_id.as_deref().unwrap_or_default(),
|
||||
)?;
|
||||
for lookup in &public_source_lookups {
|
||||
if !finding
|
||||
.evidence_ids
|
||||
.iter()
|
||||
.any(|evidence_id| evidence_id == &lookup.receipt_id)
|
||||
|| !finding
|
||||
.files_inspected
|
||||
.iter()
|
||||
.any(|source_ref| source_ref == &lookup.source_ref)
|
||||
{
|
||||
return Err(anyhow::anyhow!(
|
||||
"Research finding did not cite its authenticated public source receipt and source ref"
|
||||
));
|
||||
}
|
||||
}
|
||||
if finding
|
||||
.evidence_ids
|
||||
.iter()
|
||||
.any(|evidence_id| evidence_id.starts_with("eyes-source-"))
|
||||
&& public_source_lookups.is_empty()
|
||||
{
|
||||
return Err(anyhow::anyhow!(
|
||||
"Research finding cited public source evidence without an authenticated lookup"
|
||||
));
|
||||
}
|
||||
let packet = eyes_evidence_packet_from_research_finding(
|
||||
format!("eyes-packet-{}", update.accepted_receipt_id),
|
||||
&finding,
|
||||
&update.applied_patch,
|
||||
&public_source_lookups,
|
||||
accepted_at.clone(),
|
||||
);
|
||||
available.push(EYES_EVIDENCE_PACKET_TYPE.to_string());
|
||||
prerequisites.push(EpiphanyAcceptancePrerequisite::Eyes(packet));
|
||||
for lookup in public_source_lookups {
|
||||
available.push(EYES_SOURCE_LOOKUP_RECEIPT_TYPE.to_string());
|
||||
prerequisites.push(EpiphanyAcceptancePrerequisite::EyesSourceLookup(lookup));
|
||||
}
|
||||
let grant_id = format!(
|
||||
"substrate-grant-{}",
|
||||
finding.runtime_job_id.as_deref().unwrap_or_default()
|
||||
|
|
@ -609,6 +643,7 @@ pub fn read_accepted_coordinator_state(
|
|||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum EpiphanyAcceptancePrerequisite {
|
||||
Eyes(EyesEvidencePacket),
|
||||
EyesSourceLookup(EyesSourceLookupReceipt),
|
||||
SubstrateGate(SubstrateGateRepoAccessGrantReceipt),
|
||||
Soul(SoulVerdictReceipt),
|
||||
Continuity(ContinuityRecoveryReceipt),
|
||||
|
|
@ -641,6 +676,19 @@ fn commit_state_with_mind_witness(
|
|||
store_path,
|
||||
expected_state,
|
||||
)?;
|
||||
for prerequisite in prerequisites {
|
||||
if let EpiphanyAcceptancePrerequisite::EyesSourceLookup(document) = prerequisite {
|
||||
let authenticated = crate::runtime_spine::authenticated_public_source_lookups_for_worker(
|
||||
&cache,
|
||||
&document.source_job_id,
|
||||
)?;
|
||||
if !authenticated.iter().any(|candidate| candidate == document) {
|
||||
return Err(anyhow::anyhow!(
|
||||
"Eyes source lookup lost its authenticated authority before Mind commit"
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
let (review_envelope, _) = cache.prepare_entry(&mind_review.gateway_id, mind_review)?;
|
||||
let (commit_envelope, _) = cache.prepare_entry(&commit_receipt.receipt_id, commit_receipt)?;
|
||||
let mut batch = vec![review_envelope, commit_envelope];
|
||||
|
|
@ -649,6 +697,9 @@ fn commit_state_with_mind_witness(
|
|||
EpiphanyAcceptancePrerequisite::Eyes(document) => {
|
||||
cache.prepare_entry(&document.packet_id, document)?.0
|
||||
}
|
||||
EpiphanyAcceptancePrerequisite::EyesSourceLookup(document) => {
|
||||
cache.prepare_entry(&document.receipt_id, document)?.0
|
||||
}
|
||||
EpiphanyAcceptancePrerequisite::SubstrateGate(document) => {
|
||||
cache.prepare_entry(&document.receipt_id, document)?.0
|
||||
}
|
||||
|
|
@ -1067,6 +1118,7 @@ mod tests {
|
|||
evidence_ids: Vec::new(),
|
||||
observation_ids: Vec::new(),
|
||||
source_refs: Vec::new(),
|
||||
source_lookup_receipt_ids: Vec::new(),
|
||||
summary: "looked".to_string(),
|
||||
uncertainty: "none".to_string(),
|
||||
emitted_at: "2026-07-11T00:00:00Z".to_string(),
|
||||
|
|
|
|||
|
|
@ -532,7 +532,12 @@ fn commit_coordinator_job_launch_in_cache(
|
|||
}
|
||||
batch.push(cache.prepare_entry(&binding.binding_record_id, &binding)?.0);
|
||||
}
|
||||
if request.binding_id == EPIPHANY_RESEARCH_ROLE_BINDING_ID {
|
||||
if matches!(
|
||||
request.binding_id.as_str(),
|
||||
EPIPHANY_RESEARCH_ROLE_BINDING_ID
|
||||
| crate::EPIPHANY_MODELING_ROLE_BINDING_ID
|
||||
| crate::EPIPHANY_VERIFICATION_ROLE_BINDING_ID
|
||||
) {
|
||||
let grant = substrate_gate_repo_access_grant_for_launch(
|
||||
format!("substrate-grant-{}", plan.backend_job_id),
|
||||
plan.backend_job_id.clone(),
|
||||
|
|
@ -3887,11 +3892,14 @@ pub(crate) mod tests {
|
|||
.get_all::<crate::RepoFrontierHandsAuthority>()?
|
||||
.is_empty()
|
||||
);
|
||||
assert!(
|
||||
cache
|
||||
.get_all::<crate::SubstrateGateRepoAccessGrantReceipt>()?
|
||||
.is_empty()
|
||||
);
|
||||
let grants = cache.get_all::<crate::SubstrateGateRepoAccessGrantReceipt>()?;
|
||||
assert_eq!(grants.len(), 1);
|
||||
assert_eq!(grants[0].binding_id, crate::EPIPHANY_MODELING_ROLE_BINDING_ID);
|
||||
assert_eq!(grants[0].granted_operations, vec!["read", "snapshot"]);
|
||||
assert!(!grants[0]
|
||||
.granted_operations
|
||||
.iter()
|
||||
.any(|operation| operation == "publicSourceRead"));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,44 @@ pub const EYES_EVIDENCE_PACKET_SCHEMA_VERSION: &str = "epiphany.eyes.evidence_pa
|
|||
pub const EYES_EVIDENCE_REFUSAL_RECEIPT_SCHEMA_VERSION: &str =
|
||||
"epiphany.eyes.evidence_refusal_receipt.v0";
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
type = "epiphany.eyes.source_lookup_receipt",
|
||||
schema = "EyesSourceLookupReceipt"
|
||||
)]
|
||||
pub struct EyesSourceLookupReceipt {
|
||||
#[cultcache(key = 0)]
|
||||
pub schema_version: String,
|
||||
#[cultcache(key = 1)]
|
||||
pub receipt_id: String,
|
||||
#[cultcache(key = 2)]
|
||||
pub source_job_id: String,
|
||||
#[cultcache(key = 3)]
|
||||
pub substrate_grant_receipt_id: String,
|
||||
#[cultcache(key = 4)]
|
||||
pub tool_intent_id: String,
|
||||
#[cultcache(key = 5)]
|
||||
pub tool_receipt_id: String,
|
||||
#[cultcache(key = 6)]
|
||||
pub provider: String,
|
||||
#[cultcache(key = 7)]
|
||||
pub repository: String,
|
||||
#[cultcache(key = 8)]
|
||||
pub revision: String,
|
||||
#[cultcache(key = 9)]
|
||||
pub path: String,
|
||||
#[cultcache(key = 10)]
|
||||
pub source_ref: String,
|
||||
#[cultcache(key = 11)]
|
||||
pub content_sha256: String,
|
||||
#[cultcache(key = 12)]
|
||||
pub byte_count: u64,
|
||||
#[cultcache(key = 13)]
|
||||
pub observed_at: String,
|
||||
#[cultcache(key = 14)]
|
||||
pub contract: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(type = "epiphany.eyes.evidence_packet", schema = "EyesEvidencePacket")]
|
||||
pub struct EyesEvidencePacket {
|
||||
|
|
@ -44,6 +82,8 @@ pub struct EyesEvidencePacket {
|
|||
pub emitted_at: String,
|
||||
#[cultcache(key = 11)]
|
||||
pub contract: String,
|
||||
#[cultcache(key = 12, default)]
|
||||
pub source_lookup_receipt_ids: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
|
|
@ -131,6 +171,7 @@ pub fn eyes_evidence_packet_from_research_finding(
|
|||
packet_id: String,
|
||||
finding: &EpiphanyRoleFindingInterpretation,
|
||||
patch: &EpiphanyRoleStatePatchDocument,
|
||||
source_lookups: &[EyesSourceLookupReceipt],
|
||||
emitted_at: String,
|
||||
) -> EyesEvidencePacket {
|
||||
let evidence_ids = patch
|
||||
|
|
@ -164,6 +205,9 @@ pub fn eyes_evidence_packet_from_research_finding(
|
|||
push_unique(&mut source_refs, rendered);
|
||||
}
|
||||
}
|
||||
for lookup in source_lookups {
|
||||
push_unique(&mut source_refs, lookup.source_ref.clone());
|
||||
}
|
||||
EyesEvidencePacket {
|
||||
schema_version: EYES_EVIDENCE_PACKET_SCHEMA_VERSION.to_string(),
|
||||
packet_id,
|
||||
|
|
@ -187,6 +231,10 @@ pub fn eyes_evidence_packet_from_research_finding(
|
|||
},
|
||||
emitted_at,
|
||||
contract: "Eyes packet emitted from a reviewed Research lane finding; it makes the source-gathering evidence claim citable before Mind admission.".to_string(),
|
||||
source_lookup_receipt_ids: source_lookups
|
||||
.iter()
|
||||
.map(|lookup| lookup.receipt_id.clone())
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -286,6 +334,7 @@ mod tests {
|
|||
"eyes-packet-1".to_string(),
|
||||
&finding,
|
||||
&patch,
|
||||
&[],
|
||||
"2026-05-30T00:00:00Z".to_string(),
|
||||
);
|
||||
assert_eq!(packet.source_role_id, "research");
|
||||
|
|
|
|||
|
|
@ -618,6 +618,7 @@ pub use eyes_gateway::EYES_SOURCE_LOOKUP_RECEIPT_SCHEMA_VERSION;
|
|||
pub use eyes_gateway::EYES_SOURCE_LOOKUP_RECEIPT_TYPE;
|
||||
pub use eyes_gateway::EyesCultNetContract;
|
||||
pub use eyes_gateway::EyesEvidencePacket;
|
||||
pub use eyes_gateway::EyesSourceLookupReceipt;
|
||||
pub use eyes_gateway::default_eyes_cultnet_contracts;
|
||||
pub use eyes_gateway::eyes_evidence_packet_from_research_finding;
|
||||
pub use hands_gateway::*;
|
||||
|
|
@ -1111,6 +1112,7 @@ pub use runtime_spine::put_runtime_reorient_worker_result;
|
|||
pub use runtime_spine::put_runtime_role_worker_result;
|
||||
pub use runtime_spine::put_runtime_tool_execution_intent;
|
||||
pub use runtime_spine::put_runtime_tool_execution_receipt;
|
||||
pub use runtime_spine::runtime_authenticated_public_source_lookups_for_worker;
|
||||
#[cfg(test)]
|
||||
pub(crate) use runtime_spine::put_soul_verdict_receipt;
|
||||
pub use runtime_spine::put_substrate_gate_repo_access_grant_receipt;
|
||||
|
|
@ -1213,6 +1215,7 @@ 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_operation_for_governed_tool;
|
||||
pub use substrate_gate::substrate_gate_repo_work_planning_grant;
|
||||
pub use surfaces::AdmittedModelDirectionConsiderationContextProjection;
|
||||
pub use surfaces::EpiphanyAcceptanceBundle;
|
||||
|
|
|
|||
|
|
@ -1195,7 +1195,8 @@ mod tests {
|
|||
"heartbeat.scheduler",
|
||||
"coordinator.run",
|
||||
"persona.public_speech",
|
||||
"daemon.tool_invocation"
|
||||
"daemon.tool_invocation",
|
||||
"daemon.lifecycle_poke"
|
||||
]
|
||||
);
|
||||
assert!(
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ use crate::eyes_gateway::EYES_EVIDENCE_REVIEW_TYPE;
|
|||
use crate::eyes_gateway::EYES_SOURCE_LOOKUP_RECEIPT_SCHEMA_VERSION;
|
||||
use crate::eyes_gateway::EYES_SOURCE_LOOKUP_RECEIPT_TYPE;
|
||||
use crate::eyes_gateway::EyesEvidencePacket;
|
||||
use crate::eyes_gateway::EyesSourceLookupReceipt;
|
||||
use crate::hands_gateway::*;
|
||||
use crate::heartbeat_state::HEARTBEAT_STATE_SCHEMA_VERSION;
|
||||
use crate::heartbeat_state::HEARTBEAT_STATE_TYPE;
|
||||
|
|
@ -358,6 +359,8 @@ pub struct EpiphanyRuntimeModelExecutionBinding {
|
|||
pub provider: String,
|
||||
#[cultcache(key = 6)]
|
||||
pub bound_at: String,
|
||||
#[cultcache(key = 7, default)]
|
||||
pub source_worker_job_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
|
||||
|
|
@ -1154,6 +1157,7 @@ pub fn runtime_spine_cache(store_path: impl AsRef<Path>) -> Result<CultCache> {
|
|||
cache.register_entry_type::<MindGatewayReview>()?;
|
||||
cache.register_entry_type::<MindStateCommitReceipt>()?;
|
||||
cache.register_entry_type::<EyesEvidencePacket>()?;
|
||||
cache.register_entry_type::<EyesSourceLookupReceipt>()?;
|
||||
cache.register_entry_type::<SubstrateGateRepoAccessGrantReceipt>()?;
|
||||
cache.register_entry_type::<HandsActionIntent>()?;
|
||||
cache.register_entry_type::<HandsActionReview>()?;
|
||||
|
|
@ -1675,6 +1679,47 @@ pub fn open_runtime_model_execution(
|
|||
require_runtime_identity_not_archived(&cache, "session", &session_options.session_id)?;
|
||||
require_runtime_identity_not_archived(&cache, "job", &job_options.job_id)?;
|
||||
require_runtime_identity_not_archived(&cache, "model-request", &model_request.request_id)?;
|
||||
let source_worker_envelopes = if let Some(worker_job_id) =
|
||||
model_request.source_worker_job_id.as_deref()
|
||||
{
|
||||
let launch = cache
|
||||
.get::<EpiphanyRuntimeWorkerLaunchRequest>(worker_job_id)?
|
||||
.ok_or_else(|| {
|
||||
anyhow!(
|
||||
"model execution source worker {worker_job_id:?} has no launch request"
|
||||
)
|
||||
})?;
|
||||
if launch.job_id != worker_job_id {
|
||||
return Err(anyhow!(
|
||||
"model execution source worker launch identity disagrees"
|
||||
));
|
||||
}
|
||||
let worker_job = cache
|
||||
.get::<EpiphanyRuntimeJob>(worker_job_id)?
|
||||
.ok_or_else(|| anyhow!("model execution source worker has no runtime job"))?;
|
||||
if worker_job.role != launch.role
|
||||
|| matches!(
|
||||
worker_job.status,
|
||||
EpiphanyRuntimeJobStatus::Completed
|
||||
| EpiphanyRuntimeJobStatus::Failed
|
||||
| EpiphanyRuntimeJobStatus::Cancelled
|
||||
)
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"model execution source worker job is foreign or terminal"
|
||||
));
|
||||
}
|
||||
vec![
|
||||
cache
|
||||
.get_envelope::<EpiphanyRuntimeJob>(worker_job_id)?
|
||||
.ok_or_else(|| anyhow!("model execution lost source worker job envelope"))?,
|
||||
cache
|
||||
.get_envelope::<EpiphanyRuntimeWorkerLaunchRequest>(worker_job_id)?
|
||||
.ok_or_else(|| anyhow!("model execution lost source worker launch envelope"))?,
|
||||
]
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
let existing_session = cache.get::<EpiphanyRuntimeSession>(&session_options.session_id)?;
|
||||
let session = existing_session
|
||||
.clone()
|
||||
|
|
@ -1763,11 +1808,13 @@ pub fn open_runtime_model_execution(
|
|||
job_id: job.job_id.clone(),
|
||||
provider: model_request.provider.clone(),
|
||||
bound_at: bound_at.to_string(),
|
||||
source_worker_job_id: model_request.source_worker_job_id.clone(),
|
||||
};
|
||||
let identity_envelope = cache
|
||||
.get_envelope::<EpiphanyRuntimeIdentity>(RUNTIME_IDENTITY_KEY)?
|
||||
.ok_or_else(|| anyhow!("model execution lost its exact runtime identity envelope"))?;
|
||||
let mut expected = vec![identity_envelope.clone()];
|
||||
expected.extend(source_worker_envelopes.iter().cloned());
|
||||
if existing_session.is_some() {
|
||||
expected.push(
|
||||
cache
|
||||
|
|
@ -1775,7 +1822,7 @@ pub fn open_runtime_model_execution(
|
|||
.ok_or_else(|| anyhow!("model execution lost its exact session envelope"))?,
|
||||
);
|
||||
}
|
||||
let replacements = vec![
|
||||
let mut replacements = vec![
|
||||
identity_envelope,
|
||||
cache.prepare_entry(&session.session_id, &session)?.0,
|
||||
cache.prepare_entry(&job.job_id, &job)?.0,
|
||||
|
|
@ -1790,6 +1837,7 @@ pub fn open_runtime_model_execution(
|
|||
.prepare_entry(&provider_request.request_id, provider_request)?
|
||||
.0,
|
||||
];
|
||||
replacements.extend(source_worker_envelopes);
|
||||
if !runtime_spine_backing_store(store_path)?.compare_and_swap_batch(&expected, replacements)? {
|
||||
return Err(anyhow!(
|
||||
"model execution request publication lost its snapshot fence"
|
||||
|
|
@ -1843,6 +1891,8 @@ pub fn put_runtime_tool_execution_intent(
|
|||
"tool execution job {job_id:?} is foreign or terminal"
|
||||
));
|
||||
}
|
||||
let governed_source_authority =
|
||||
validate_governed_source_tool_intent(&cache, job_id, intent)?;
|
||||
if cache
|
||||
.get::<EpiphanyRuntimeToolExecutionBinding>(&intent.intent_id)?
|
||||
.is_some()
|
||||
|
|
@ -1874,6 +1924,8 @@ pub fn put_runtime_tool_execution_intent(
|
|||
job_envelope.clone(),
|
||||
];
|
||||
let mut replacements = expected.clone();
|
||||
expected.extend(governed_source_authority.iter().cloned());
|
||||
replacements.extend(governed_source_authority);
|
||||
if let Some(model_request_id) = intent.model_request_id.as_deref() {
|
||||
let model_binding = cache
|
||||
.get::<EpiphanyRuntimeModelExecutionBinding>(model_request_id)?
|
||||
|
|
@ -1892,6 +1944,15 @@ pub fn put_runtime_tool_execution_intent(
|
|||
intent.intent_id
|
||||
));
|
||||
}
|
||||
let persisted_model_request = cache
|
||||
.get::<EpiphanyModelRequest>(model_request_id)?
|
||||
.ok_or_else(|| anyhow!("model-derived tool intent lost its model request"))?;
|
||||
if persisted_model_request.source_worker_job_id != model_binding.source_worker_job_id {
|
||||
return Err(anyhow!(
|
||||
"model-derived tool intent {:?} has substituted worker provenance",
|
||||
intent.intent_id
|
||||
));
|
||||
}
|
||||
for envelope in [
|
||||
cache.get_envelope::<EpiphanyRuntimeModelExecutionBinding>(model_request_id)?,
|
||||
cache.get_envelope::<EpiphanyModelRequest>(model_request_id)?,
|
||||
|
|
@ -1971,6 +2032,7 @@ pub fn require_runtime_tool_execution_binding(
|
|||
"tool execution binding {intent_id:?} has foreign or archived ownership"
|
||||
));
|
||||
}
|
||||
let _ = validate_governed_source_tool_intent(&cache, &binding.job_id, &intent)?;
|
||||
if let Some(model_request_id) = binding.model_request_id.as_deref() {
|
||||
let model_binding = cache
|
||||
.get::<EpiphanyRuntimeModelExecutionBinding>(model_request_id)?
|
||||
|
|
@ -3527,6 +3589,260 @@ pub fn runtime_worker_process_claim(
|
|||
cache.get::<EpiphanyRuntimeWorkerProcessClaim>(&worker_process_claim_id(job_id))
|
||||
}
|
||||
|
||||
pub fn runtime_authenticated_public_source_lookups_for_worker(
|
||||
store_path: impl AsRef<Path>,
|
||||
worker_job_id: &str,
|
||||
) -> Result<Vec<EyesSourceLookupReceipt>> {
|
||||
validate_non_empty(worker_job_id, "public source worker job id")?;
|
||||
let mut cache = runtime_spine_cache(store_path)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
require_identity(&cache)?;
|
||||
authenticated_public_source_lookups_for_worker(&cache, worker_job_id)
|
||||
}
|
||||
|
||||
pub(crate) fn authenticated_public_source_lookups_for_worker(
|
||||
cache: &CultCache,
|
||||
worker_job_id: &str,
|
||||
) -> Result<Vec<EyesSourceLookupReceipt>> {
|
||||
validate_non_empty(worker_job_id, "public source worker job id")?;
|
||||
require_identity(cache)?;
|
||||
let launch = cache
|
||||
.get::<EpiphanyRuntimeWorkerLaunchRequest>(worker_job_id)?
|
||||
.ok_or_else(|| anyhow!("public source worker has no launch request"))?;
|
||||
if launch.binding_id != crate::EPIPHANY_RESEARCH_ROLE_BINDING_ID
|
||||
|| launch.role != crate::EPIPHANY_RESEARCH_OWNER_ROLE
|
||||
{
|
||||
return Err(anyhow!("public source evidence is Eyes-owned"));
|
||||
}
|
||||
let grant_id = format!("substrate-grant-{worker_job_id}");
|
||||
let grant = cache
|
||||
.get::<SubstrateGateRepoAccessGrantReceipt>(&grant_id)?
|
||||
.ok_or_else(|| anyhow!("public source worker lost its launch grant"))?;
|
||||
if grant.runtime_job_id != worker_job_id
|
||||
|| grant.binding_id != launch.binding_id
|
||||
|| grant.role != launch.role
|
||||
|| grant.authority_scope != launch.authority_scope
|
||||
|| !grant
|
||||
.granted_operations
|
||||
.iter()
|
||||
.any(|operation| operation == crate::substrate_gate::SUBSTRATE_GATE_PUBLIC_SOURCE_READ_OPERATION)
|
||||
{
|
||||
return Err(anyhow!("public source worker grant is not exact"));
|
||||
}
|
||||
let model_request_ids = cache
|
||||
.get_all::<EpiphanyRuntimeModelExecutionBinding>()?
|
||||
.into_iter()
|
||||
.filter(|binding| binding.source_worker_job_id.as_deref() == Some(worker_job_id))
|
||||
.map(|binding| binding.request_id)
|
||||
.collect::<BTreeSet<_>>();
|
||||
let mut lookups = Vec::new();
|
||||
for binding in cache.get_all::<EpiphanyRuntimeToolExecutionBinding>()? {
|
||||
let Some(model_request_id) = binding.model_request_id.as_deref() else {
|
||||
continue;
|
||||
};
|
||||
if !model_request_ids.contains(model_request_id) {
|
||||
continue;
|
||||
}
|
||||
let intent = cache
|
||||
.get::<EpiphanyToolInvocationIntent>(&tool_invocation_intent_key(
|
||||
&binding.intent_id,
|
||||
))?
|
||||
.ok_or_else(|| anyhow!("public source tool binding lost its intent"))?;
|
||||
if intent.server != "epiphany_public" || intent.tool_name != "github_file" {
|
||||
continue;
|
||||
}
|
||||
let receipt = cache
|
||||
.get::<EpiphanyToolInvocationReceipt>(&tool_invocation_receipt_key(
|
||||
&intent.intent_id,
|
||||
))?
|
||||
.ok_or_else(|| anyhow!("public source tool intent has no terminal receipt"))?;
|
||||
let _ = validate_governed_source_tool_intent(&cache, &binding.job_id, &intent)?;
|
||||
if binding.intent_id != intent.intent_id
|
||||
|| intent.model_request_id.as_deref() != Some(model_request_id)
|
||||
|| receipt.intent_id != intent.intent_id
|
||||
|| receipt.adapter != intent.adapter
|
||||
|| receipt.server != intent.server
|
||||
|| receipt.tool_name != intent.tool_name
|
||||
|| receipt.status != "completed"
|
||||
|| chrono::DateTime::parse_from_rfc3339(&receipt.completed_at).is_err()
|
||||
{
|
||||
return Err(anyhow!("public source tool family is not exact and terminal"));
|
||||
}
|
||||
let arguments: serde_json::Value = serde_json::from_str(&intent.arguments_json)
|
||||
.context("public source intent arguments are invalid")?;
|
||||
let result: serde_json::Value = serde_json::from_str(
|
||||
receipt
|
||||
.result_json
|
||||
.as_deref()
|
||||
.ok_or_else(|| anyhow!("public source receipt has no result"))?,
|
||||
)
|
||||
.context("public source receipt result is invalid")?;
|
||||
let owner = public_source_json_string(&arguments, "owner")?;
|
||||
let repository_name = public_source_json_string(&arguments, "repository")?;
|
||||
let revision = public_source_json_string(&arguments, "revision")?.to_ascii_lowercase();
|
||||
let path = public_source_json_string(&arguments, "path")?;
|
||||
let content = public_source_json_string(&result, "content")?;
|
||||
let repository = format!("github://{owner}/{repository_name}");
|
||||
let source_ref = format!("{repository}@{revision}/{path}");
|
||||
let content_sha256 = format!("{:x}", Sha256::digest(content.as_bytes()));
|
||||
let byte_count = content.len() as u64;
|
||||
let lookup_receipt_id = format!("eyes-source-{}", intent.intent_id);
|
||||
if public_source_json_string(&result, "provider")? != "github"
|
||||
|| public_source_json_string(&result, "repository")? != repository
|
||||
|| public_source_json_string(&result, "revision")? != revision
|
||||
|| public_source_json_string(&result, "path")? != path
|
||||
|| public_source_json_string(&result, "sourceRef")? != source_ref
|
||||
|| public_source_json_string(&result, "contentSha256")? != content_sha256
|
||||
|| result.get("byteCount").and_then(serde_json::Value::as_u64)
|
||||
!= Some(byte_count)
|
||||
|| public_source_json_string(&result, "evidenceReceiptId")? != lookup_receipt_id
|
||||
{
|
||||
return Err(anyhow!("public source result provenance is substituted"));
|
||||
}
|
||||
lookups.push(EyesSourceLookupReceipt {
|
||||
schema_version: crate::EYES_SOURCE_LOOKUP_RECEIPT_SCHEMA_VERSION.to_string(),
|
||||
receipt_id: lookup_receipt_id,
|
||||
source_job_id: worker_job_id.to_string(),
|
||||
substrate_grant_receipt_id: grant_id.clone(),
|
||||
tool_intent_id: intent.intent_id,
|
||||
tool_receipt_id: receipt.receipt_id,
|
||||
provider: "github".to_string(),
|
||||
repository,
|
||||
revision,
|
||||
path: path.to_string(),
|
||||
source_ref,
|
||||
content_sha256,
|
||||
byte_count,
|
||||
observed_at: receipt.completed_at,
|
||||
contract: "Eyes admitted one bounded immutable public source only after authenticating its worker, model, tool, grant, provider identity, and content digest.".to_string(),
|
||||
});
|
||||
}
|
||||
lookups.sort_by(|left, right| left.receipt_id.cmp(&right.receipt_id));
|
||||
Ok(lookups)
|
||||
}
|
||||
|
||||
fn public_source_json_string<'a>(value: &'a serde_json::Value, field: &str) -> Result<&'a str> {
|
||||
value
|
||||
.get(field)
|
||||
.and_then(serde_json::Value::as_str)
|
||||
.filter(|value| !value.is_empty())
|
||||
.ok_or_else(|| anyhow!("public source cargo omitted {field:?}"))
|
||||
}
|
||||
|
||||
fn validate_governed_source_tool_intent(
|
||||
cache: &CultCache,
|
||||
job_id: &str,
|
||||
intent: &EpiphanyToolInvocationIntent,
|
||||
) -> Result<Vec<CultCacheEnvelope>> {
|
||||
let required_operation =
|
||||
crate::substrate_gate_operation_for_governed_tool(&intent.server, &intent.tool_name);
|
||||
let source_worker_job_id = match intent.model_request_id.as_deref() {
|
||||
Some(model_request_id) => {
|
||||
let model_binding = cache
|
||||
.get::<EpiphanyRuntimeModelExecutionBinding>(model_request_id)?
|
||||
.ok_or_else(|| {
|
||||
anyhow!(
|
||||
"model-derived tool intent {:?} has no execution binding",
|
||||
intent.intent_id
|
||||
)
|
||||
})?;
|
||||
match model_binding.source_worker_job_id {
|
||||
Some(worker_job_id) => Some(worker_job_id),
|
||||
None if required_operation.is_some() => {
|
||||
return Err(anyhow!(
|
||||
"governed source tool intent {:?} has no source worker authority",
|
||||
intent.intent_id
|
||||
));
|
||||
}
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
None => {
|
||||
if cache
|
||||
.get::<EpiphanyRuntimeWorkerLaunchRequest>(job_id)?
|
||||
.is_some_and(|launch| {
|
||||
matches!(
|
||||
launch.binding_id.as_str(),
|
||||
crate::EPIPHANY_RESEARCH_ROLE_BINDING_ID
|
||||
| crate::EPIPHANY_MODELING_ROLE_BINDING_ID
|
||||
| crate::EPIPHANY_VERIFICATION_ROLE_BINDING_ID
|
||||
)
|
||||
})
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"governed source worker refuses a tool intent without model-call provenance"
|
||||
));
|
||||
}
|
||||
None
|
||||
}
|
||||
};
|
||||
let Some(source_worker_job_id) = source_worker_job_id else {
|
||||
return Ok(Vec::new());
|
||||
};
|
||||
let launch = cache
|
||||
.get::<EpiphanyRuntimeWorkerLaunchRequest>(&source_worker_job_id)?
|
||||
.ok_or_else(|| anyhow!("governed source tool intent lost its source worker launch"))?;
|
||||
let source_worker_job = cache
|
||||
.get::<EpiphanyRuntimeJob>(&source_worker_job_id)?
|
||||
.ok_or_else(|| anyhow!("governed source tool intent lost its source worker job"))?;
|
||||
if !matches!(
|
||||
launch.binding_id.as_str(),
|
||||
crate::EPIPHANY_RESEARCH_ROLE_BINDING_ID
|
||||
| crate::EPIPHANY_MODELING_ROLE_BINDING_ID
|
||||
| crate::EPIPHANY_VERIFICATION_ROLE_BINDING_ID
|
||||
) {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
let required_operation = required_operation.ok_or_else(|| {
|
||||
anyhow!(
|
||||
"governed source worker rejected unknown tool {}::{}",
|
||||
intent.server,
|
||||
intent.tool_name
|
||||
)
|
||||
})?;
|
||||
let grant_id = format!("substrate-grant-{source_worker_job_id}");
|
||||
let grant = cache
|
||||
.get::<SubstrateGateRepoAccessGrantReceipt>(&grant_id)?
|
||||
.ok_or_else(|| {
|
||||
anyhow!(
|
||||
"governed source tool intent {:?} has no exact launch grant",
|
||||
intent.intent_id
|
||||
)
|
||||
})?;
|
||||
if source_worker_job.role != launch.role
|
||||
|| matches!(
|
||||
source_worker_job.status,
|
||||
EpiphanyRuntimeJobStatus::Completed
|
||||
| EpiphanyRuntimeJobStatus::Failed
|
||||
| EpiphanyRuntimeJobStatus::Cancelled
|
||||
)
|
||||
|| grant.runtime_job_id != source_worker_job_id
|
||||
|| grant.binding_id != launch.binding_id
|
||||
|| grant.role != launch.role
|
||||
|| grant.authority_scope != launch.authority_scope
|
||||
|| !grant
|
||||
.granted_operations
|
||||
.iter()
|
||||
.any(|operation| operation == required_operation)
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"governed source tool intent {:?} is outside its launch grant",
|
||||
intent.intent_id
|
||||
));
|
||||
}
|
||||
Ok(vec![
|
||||
cache
|
||||
.get_envelope::<EpiphanyRuntimeJob>(&source_worker_job_id)?
|
||||
.ok_or_else(|| anyhow!("governed source tool lost worker job envelope"))?,
|
||||
cache
|
||||
.get_envelope::<EpiphanyRuntimeWorkerLaunchRequest>(&source_worker_job_id)?
|
||||
.ok_or_else(|| anyhow!("governed source tool lost worker launch envelope"))?,
|
||||
cache
|
||||
.get_envelope::<SubstrateGateRepoAccessGrantReceipt>(&grant_id)?
|
||||
.ok_or_else(|| anyhow!("governed source tool lost launch grant envelope"))?,
|
||||
])
|
||||
}
|
||||
|
||||
pub fn runtime_worker_process_claims(
|
||||
store_path: impl AsRef<Path>,
|
||||
) -> Result<Vec<EpiphanyRuntimeWorkerProcessClaim>> {
|
||||
|
|
@ -16047,6 +16363,7 @@ pub(crate) mod tests {
|
|||
evidence_ids: vec![format!("evidence-{suffix}")],
|
||||
observation_ids: vec![format!("observation-{suffix}")],
|
||||
source_refs: vec!["epiphany-core/src/runtime_spine.rs:1".into()],
|
||||
source_lookup_receipt_ids: Vec::new(),
|
||||
summary: "The exact claim is challenged by inspected source.".into(),
|
||||
uncertainty: "Bounded to the cited source.".into(),
|
||||
emitted_at: "2026-07-13T04:01:00Z".into(),
|
||||
|
|
@ -19160,6 +19477,202 @@ pub(crate) mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn governed_public_tool_intent_requires_exact_worker_launch_grant() -> Result<()> {
|
||||
let temp = tempdir()?;
|
||||
let store = temp.path().join("runtime.msgpack");
|
||||
initialize_runtime_spine(
|
||||
&store,
|
||||
RuntimeSpineInitOptions {
|
||||
runtime_id: "epiphany-public-tool-test".to_string(),
|
||||
display_name: "Epiphany Public Tool Test".to_string(),
|
||||
created_at: "2026-08-11T00:00:00Z".to_string(),
|
||||
},
|
||||
)?;
|
||||
let state = crate::EpiphanyThreadState::default();
|
||||
let launch = crate::build_epiphany_role_launch_request(
|
||||
"thread-public-tool",
|
||||
crate::EpiphanyRoleResultRoleId::Research,
|
||||
Some(state.revision),
|
||||
Some(60),
|
||||
&state,
|
||||
)
|
||||
.map_err(anyhow::Error::msg)?;
|
||||
let plan = crate::plan_coordinator_job_launch(
|
||||
&state,
|
||||
&launch,
|
||||
&store,
|
||||
"launcher-public-tool".to_string(),
|
||||
"worker-public-tool".to_string(),
|
||||
)?;
|
||||
crate::commit_coordinator_job_launch(
|
||||
&store,
|
||||
"thread-public-tool",
|
||||
&state,
|
||||
&launch,
|
||||
&plan,
|
||||
"2026-08-11T00:00:01Z".to_string(),
|
||||
)?;
|
||||
|
||||
let mut model_request = EpiphanyModelRequest::new(
|
||||
"request-public-tool",
|
||||
"conversation-public-tool",
|
||||
"openai-codex",
|
||||
"gpt-test",
|
||||
"Read one immutable public source.",
|
||||
);
|
||||
model_request.source_worker_job_id = Some("worker-public-tool".to_string());
|
||||
let provider_request = EpiphanyOpenAiModelRequest::new(
|
||||
"request-public-tool",
|
||||
"conversation-public-tool",
|
||||
"gpt-test",
|
||||
"Read one immutable public source.",
|
||||
);
|
||||
open_runtime_model_execution(
|
||||
&store,
|
||||
RuntimeSpineSessionOptions {
|
||||
session_id: "model-session-public-tool".to_string(),
|
||||
objective: "Read one immutable public source.".to_string(),
|
||||
created_at: "2026-08-11T00:00:02Z".to_string(),
|
||||
coordinator_note: "test".to_string(),
|
||||
},
|
||||
RuntimeSpineJobOptions {
|
||||
job_id: "model-job-public-tool".to_string(),
|
||||
session_id: "model-session-public-tool".to_string(),
|
||||
role: "openai-model-adapter".to_string(),
|
||||
created_at: "2026-08-11T00:00:02Z".to_string(),
|
||||
summary: "Bound public source model turn.".to_string(),
|
||||
artifact_refs: Vec::new(),
|
||||
},
|
||||
&model_request,
|
||||
&provider_request,
|
||||
"2026-08-11T00:00:02Z",
|
||||
)?;
|
||||
let exact = EpiphanyToolInvocationIntent::new(
|
||||
"intent-public-tool-exact",
|
||||
"epiphany-tools",
|
||||
"epiphany_public",
|
||||
"github_file",
|
||||
r#"{"owner":"openai","repository":"openai-openapi","revision":"0123456789abcdef0123456789abcdef01234567","path":"openapi.yaml"}"#,
|
||||
"model-runtime",
|
||||
"Read immutable source.",
|
||||
"2026-08-11T00:00:03Z",
|
||||
)
|
||||
.with_model_call("call-public-tool-exact", "request-public-tool");
|
||||
put_runtime_tool_execution_intent(
|
||||
&store,
|
||||
"model-session-public-tool",
|
||||
"model-job-public-tool",
|
||||
&exact,
|
||||
"2026-08-11T00:00:03Z",
|
||||
)?;
|
||||
let content = "openapi: 3.1.0\n";
|
||||
let content_sha256 = format!("{:x}", Sha256::digest(content.as_bytes()));
|
||||
let mut exact_receipt = EpiphanyToolInvocationReceipt::new(
|
||||
"receipt-public-tool-exact",
|
||||
&exact.intent_id,
|
||||
&exact.adapter,
|
||||
&exact.server,
|
||||
&exact.tool_name,
|
||||
"completed",
|
||||
"2026-08-11T00:00:04Z",
|
||||
);
|
||||
exact_receipt.result_json = Some(
|
||||
serde_json::json!({
|
||||
"provider": "github",
|
||||
"repository": "github://openai/openai-openapi",
|
||||
"revision": "0123456789abcdef0123456789abcdef01234567",
|
||||
"path": "openapi.yaml",
|
||||
"sourceRef": "github://openai/openai-openapi@0123456789abcdef0123456789abcdef01234567/openapi.yaml",
|
||||
"contentSha256": content_sha256,
|
||||
"byteCount": content.len(),
|
||||
"content": content,
|
||||
"evidenceReceiptId": "eyes-source-intent-public-tool-exact"
|
||||
})
|
||||
.to_string(),
|
||||
);
|
||||
put_runtime_tool_execution_receipt(&store, &exact_receipt)?;
|
||||
let lookups = runtime_authenticated_public_source_lookups_for_worker(
|
||||
&store,
|
||||
"worker-public-tool",
|
||||
)?;
|
||||
assert_eq!(lookups.len(), 1);
|
||||
assert_eq!(
|
||||
lookups[0].receipt_id,
|
||||
"eyes-source-intent-public-tool-exact"
|
||||
);
|
||||
assert_eq!(lookups[0].content_sha256, content_sha256);
|
||||
|
||||
let mut cache = runtime_spine_cache(&store)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
let receipt_key = tool_invocation_receipt_key(&exact.intent_id);
|
||||
let mut substituted_receipt = cache
|
||||
.get::<EpiphanyToolInvocationReceipt>(&receipt_key)?
|
||||
.expect("exact public source receipt");
|
||||
let mut substituted_result: serde_json::Value = serde_json::from_str(
|
||||
substituted_receipt.result_json.as_deref().unwrap(),
|
||||
)?;
|
||||
substituted_result["byteCount"] = serde_json::json!(1);
|
||||
substituted_receipt.result_json = Some(substituted_result.to_string());
|
||||
cache.put(&receipt_key, &substituted_receipt)?;
|
||||
let before_refusal = runtime_spine_backing_store(&store)?.pull_all()?;
|
||||
assert!(
|
||||
runtime_authenticated_public_source_lookups_for_worker(
|
||||
&store,
|
||||
"worker-public-tool"
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
assert_eq!(runtime_spine_backing_store(&store)?.pull_all()?, before_refusal);
|
||||
cache.put(&receipt_key, &exact_receipt)?;
|
||||
let grant_id = "substrate-grant-worker-public-tool";
|
||||
let mut grant = cache
|
||||
.get::<SubstrateGateRepoAccessGrantReceipt>(grant_id)?
|
||||
.expect("exact worker launch grant");
|
||||
grant
|
||||
.granted_operations
|
||||
.retain(|operation| operation != "publicSourceRead");
|
||||
cache.put(grant_id, &grant)?;
|
||||
let hostile = EpiphanyToolInvocationIntent::new(
|
||||
"intent-public-tool-hostile",
|
||||
"epiphany-tools",
|
||||
"epiphany_public",
|
||||
"github_file",
|
||||
"{}",
|
||||
"model-runtime",
|
||||
"Attempt public read without operation authority.",
|
||||
"2026-08-11T00:00:04Z",
|
||||
)
|
||||
.with_model_call("call-public-tool-hostile", "request-public-tool");
|
||||
let before = runtime_spine_backing_store(&store)?.pull_all()?;
|
||||
assert!(
|
||||
put_runtime_tool_execution_intent(
|
||||
&store,
|
||||
"model-session-public-tool",
|
||||
"model-job-public-tool",
|
||||
&hostile,
|
||||
"2026-08-11T00:00:04Z",
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
assert_eq!(runtime_spine_backing_store(&store)?.pull_all()?, before);
|
||||
let mut reloaded = runtime_spine_cache(&store)?;
|
||||
reloaded.pull_all_backing_stores()?;
|
||||
assert!(
|
||||
reloaded
|
||||
.get::<EpiphanyRuntimeToolExecutionBinding>(&hostile.intent_id)?
|
||||
.is_none()
|
||||
);
|
||||
assert!(
|
||||
reloaded
|
||||
.get::<EpiphanyToolInvocationIntent>(&tool_invocation_intent_key(
|
||||
&hostile.intent_id,
|
||||
))?
|
||||
.is_none()
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn archived_model_session_is_exact_terminal_tombstone() -> Result<()> {
|
||||
let temp = tempdir()?;
|
||||
|
|
@ -19599,6 +20112,7 @@ pub(crate) mod tests {
|
|||
evidence_ids: vec!["ev-1".to_string()],
|
||||
observation_ids: vec!["obs-1".to_string()],
|
||||
source_refs: vec!["src/lib.rs:1".to_string()],
|
||||
source_lookup_receipt_ids: Vec::new(),
|
||||
summary: "Evidence packet.".to_string(),
|
||||
uncertainty: "none declared".to_string(),
|
||||
emitted_at: "2026-05-06T00:05:00Z".to_string(),
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ pub const SUBSTRATE_GATE_REPO_SNAPSHOT_RECEIPT_SCHEMA_VERSION: &str =
|
|||
"epiphany.substrate_gate.repo_snapshot_receipt.v0";
|
||||
pub const SUBSTRATE_GATE_REPO_MUTATION_RECEIPT_SCHEMA_VERSION: &str =
|
||||
"epiphany.substrate_gate.repo_mutation_receipt.v0";
|
||||
pub const SUBSTRATE_GATE_SOURCE_READ_OPERATION: &str = "read";
|
||||
pub const SUBSTRATE_GATE_PUBLIC_SOURCE_READ_OPERATION: &str = "publicSourceRead";
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
|
|
@ -143,6 +145,13 @@ pub fn substrate_gate_repo_access_grant_for_launch(
|
|||
request: &EpiphanyJobLaunchRequest,
|
||||
granted_at: String,
|
||||
) -> SubstrateGateRepoAccessGrantReceipt {
|
||||
let mut granted_operations = vec![
|
||||
SUBSTRATE_GATE_SOURCE_READ_OPERATION.to_string(),
|
||||
"snapshot".to_string(),
|
||||
];
|
||||
if request.binding_id == crate::EPIPHANY_RESEARCH_ROLE_BINDING_ID {
|
||||
granted_operations.push(SUBSTRATE_GATE_PUBLIC_SOURCE_READ_OPERATION.to_string());
|
||||
}
|
||||
SubstrateGateRepoAccessGrantReceipt {
|
||||
schema_version: SUBSTRATE_GATE_REPO_ACCESS_GRANT_RECEIPT_SCHEMA_VERSION.to_string(),
|
||||
receipt_id,
|
||||
|
|
@ -150,10 +159,29 @@ pub fn substrate_gate_repo_access_grant_for_launch(
|
|||
binding_id: request.binding_id.clone(),
|
||||
role: request.owner_role.clone(),
|
||||
authority_scope: request.authority_scope.clone(),
|
||||
granted_operations: vec!["read".to_string(), "snapshot".to_string()],
|
||||
granted_operations,
|
||||
granted_paths: vec![".".to_string()],
|
||||
granted_at,
|
||||
contract: "Substrate Gate granted scoped repository read/snapshot access for this worker launch; mutation remains forbidden without a separate mutation receipt.".to_string(),
|
||||
contract: "Substrate Gate granted the exact worker launch its named governed source operations; public-source reads are Eyes-only and mutation remains forbidden without a separate mutation receipt.".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn substrate_gate_operation_for_governed_tool(
|
||||
server: &str,
|
||||
tool_name: &str,
|
||||
) -> Option<&'static str> {
|
||||
match (server, tool_name) {
|
||||
(
|
||||
"epiphany_source",
|
||||
"read_file" | "directory_inventory" | "git_show" | "read_hands_receipt",
|
||||
)
|
||||
| ("epiphany_state", "resident_grant_lifecycle") => {
|
||||
Some(SUBSTRATE_GATE_SOURCE_READ_OPERATION)
|
||||
}
|
||||
("epiphany_public", "github_file") => {
|
||||
Some(SUBSTRATE_GATE_PUBLIC_SOURCE_READ_OPERATION)
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -294,10 +322,31 @@ mod tests {
|
|||
"2026-05-30T00:00:00Z".to_string(),
|
||||
);
|
||||
assert!(grant.granted_operations.contains(&"read".to_string()));
|
||||
assert!(
|
||||
grant
|
||||
.granted_operations
|
||||
.contains(&"publicSourceRead".to_string())
|
||||
);
|
||||
assert!(!grant.granted_operations.contains(&"write".to_string()));
|
||||
assert!(grant.contract.contains("mutation remains forbidden"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn governed_tools_map_to_fixed_grant_operations() {
|
||||
assert_eq!(
|
||||
substrate_gate_operation_for_governed_tool("epiphany_source", "read_file"),
|
||||
Some("read")
|
||||
);
|
||||
assert_eq!(
|
||||
substrate_gate_operation_for_governed_tool("epiphany_public", "github_file"),
|
||||
Some("publicSourceRead")
|
||||
);
|
||||
assert_eq!(
|
||||
substrate_gate_operation_for_governed_tool("epiphany_public", "arbitrary_url"),
|
||||
None
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn repo_work_and_implementation_grants_have_fixed_policies() {
|
||||
let planning = substrate_gate_repo_work_planning_grant(
|
||||
|
|
|
|||
Reference in a new issue