Make public Research sources proposal-owned
This commit is contained in:
parent
e6afc366ee
commit
17ee5eba20
12 changed files with 290 additions and 38 deletions
|
|
@ -989,8 +989,8 @@ pub fn epiphany_frontier_verdict_modeling_output_schema(
|
|||
"required": [
|
||||
"id", "migration_body", "question", "gap", "target_claim_ids",
|
||||
"source_scope", "recommended_next_organ", "adopted_plan",
|
||||
"dependency_item_ids", "status", "evidence_refs", "created_at",
|
||||
"updated_at", "retired_at", "superseded_by"
|
||||
"dependency_item_ids", "status", "evidence_refs", "public_source_refs",
|
||||
"created_at", "updated_at", "retired_at", "superseded_by"
|
||||
],
|
||||
"properties": {
|
||||
"id": {"const": item.id},
|
||||
|
|
@ -1012,6 +1012,7 @@ pub fn epiphany_frontier_verdict_modeling_output_schema(
|
|||
{"contains": {"const": request.soul_verdict_receipt_id}}
|
||||
]
|
||||
},
|
||||
"public_source_refs": {"const": item.public_source_refs},
|
||||
"created_at": {"const": created_at},
|
||||
"updated_at": {"type": "string", "minLength": 1},
|
||||
"retired_at": {"const": retired_at},
|
||||
|
|
@ -2039,6 +2040,7 @@ mod tests {
|
|||
dependency_item_ids: Vec::new(),
|
||||
status: crate::RepoFrontierStatus::Active,
|
||||
evidence_refs: vec!["prior-evidence".into()],
|
||||
public_source_refs: Vec::new(),
|
||||
created_at: Some("2026-08-07T00:00:00Z".into()),
|
||||
updated_at: Some("2026-08-07T00:00:00Z".into()),
|
||||
retired_at: None,
|
||||
|
|
@ -2073,6 +2075,10 @@ mod tests {
|
|||
["item"];
|
||||
assert_eq!(item["properties"]["id"]["const"], "frontier-exact");
|
||||
assert_eq!(item["properties"]["status"]["const"], "resolved");
|
||||
assert_eq!(
|
||||
item["properties"]["public_source_refs"]["const"],
|
||||
serde_json::json!([])
|
||||
);
|
||||
assert_eq!(
|
||||
item["properties"]["adopted_plan"]["const"]["command"],
|
||||
"cargo test"
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ fn main() -> Result<()> {
|
|||
constraints: args.constraints.clone(),
|
||||
scope_hints: args.scope_hints.clone(),
|
||||
evidence_refs: args.evidence_refs.clone(),
|
||||
public_source_refs: args.public_source_refs.clone(),
|
||||
proposed_at: args.required("--proposed-at")?,
|
||||
private_state_included: false,
|
||||
})?;
|
||||
|
|
@ -51,6 +52,7 @@ struct Args {
|
|||
constraints: Vec<String>,
|
||||
scope_hints: Vec<String>,
|
||||
evidence_refs: Vec<String>,
|
||||
public_source_refs: Vec<String>,
|
||||
}
|
||||
|
||||
impl Args {
|
||||
|
|
@ -66,6 +68,7 @@ impl Args {
|
|||
let mut constraints = Vec::new();
|
||||
let mut scope_hints = Vec::new();
|
||||
let mut evidence_refs = Vec::new();
|
||||
let mut public_source_refs = Vec::new();
|
||||
while let Some(flag) = values.next() {
|
||||
let value = values
|
||||
.next()
|
||||
|
|
@ -74,6 +77,7 @@ impl Args {
|
|||
"--constraint" => constraints.push(value),
|
||||
"--scope-hint" => scope_hints.push(value),
|
||||
"--evidence-ref" => evidence_refs.push(value),
|
||||
"--public-source-ref" => public_source_refs.push(value),
|
||||
"--store" | "--proposal-id" | "--source-actor" | "--source-ref"
|
||||
| "--repository" | "--workspace" | "--thread-id" | "--runtime-id" | "--title"
|
||||
| "--body" | "--desired-outcome" | "--proposed-at" | "--selected-at" => {
|
||||
|
|
@ -94,6 +98,7 @@ impl Args {
|
|||
constraints,
|
||||
scope_hints,
|
||||
evidence_refs,
|
||||
public_source_refs,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -125,6 +130,8 @@ mod tests {
|
|||
"src/lib.rs",
|
||||
"--evidence-ref",
|
||||
"operator:request",
|
||||
"--public-source-ref",
|
||||
"github://GameCult/Epiphany@0123456789abcdef0123456789abcdef01234567/README.md",
|
||||
]
|
||||
.into_iter()
|
||||
.map(str::to_string),
|
||||
|
|
@ -134,6 +141,7 @@ mod tests {
|
|||
assert_eq!(args.constraints, ["one", "two"]);
|
||||
assert_eq!(args.scope_hints, ["src/lib.rs"]);
|
||||
assert_eq!(args.evidence_refs, ["operator:request"]);
|
||||
assert_eq!(args.public_source_refs.len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -1121,6 +1121,7 @@ fn build_proposal_modeling_context_projection(
|
|||
constraints: proposal.constraints.clone(),
|
||||
scope_hints: proposal.scope_hints.clone(),
|
||||
evidence_refs: proposal.evidence_refs.clone(),
|
||||
public_source_refs: proposal.public_source_refs.clone(),
|
||||
private_state_included: proposal.private_state_included,
|
||||
model_revision: model.model_revision,
|
||||
model_hash: crate::memory_graph_model_hash(model)?,
|
||||
|
|
@ -1185,19 +1186,20 @@ fn validate_proposal_modeling_launch(
|
|||
.get::<crate::EpiphanyThreadStateEntry>(crate::THREAD_STATE_KEY)?
|
||||
.ok_or_else(|| anyhow!("proposal Modeling launch requires authoritative thread state"))?;
|
||||
let persisted_state_value = persisted_state.state()?;
|
||||
let content = rmp_serde::to_vec_named(&(
|
||||
let proposal_payload_sha256 = crate::repo_frontier_proposal_payload_sha256(
|
||||
&proposal.title,
|
||||
&proposal.body,
|
||||
&proposal.desired_outcome,
|
||||
&proposal.constraints,
|
||||
&proposal.scope_hints,
|
||||
&proposal.evidence_refs,
|
||||
))?;
|
||||
&proposal.public_source_refs,
|
||||
)?;
|
||||
if selection.schema_version != REPO_FRONTIER_PROPOSAL_MODELING_REQUEST_SCHEMA_VERSION
|
||||
|| selection.contract != REPO_FRONTIER_PROPOSAL_MODELING_REQUEST_CONTRACT
|
||||
|| selection.request_id != request_id
|
||||
|| selection.proposal_payload_sha256 != proposal.payload_sha256
|
||||
|| proposal.payload_sha256 != format!("{:x}", Sha256::digest(content))
|
||||
|| proposal.payload_sha256 != proposal_payload_sha256
|
||||
|| selection.runtime_id != identity.runtime_id
|
||||
|| selection.runtime_id != proposal.runtime_id
|
||||
|| selection.thread_id != proposal.thread_id
|
||||
|
|
@ -1355,6 +1357,7 @@ pub(crate) mod tests {
|
|||
constraints: vec!["No duplicate backend".into()],
|
||||
scope_hints: vec!["epiphany-core/src".into()],
|
||||
evidence_refs: vec![format!("fixture:{suffix}")],
|
||||
public_source_refs: Vec::new(),
|
||||
private_state_included: false,
|
||||
proposed_at: "2026-07-13T05:00:01Z".into(),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1373,6 +1373,7 @@ mod tests {
|
|||
constraints: vec!["No direct execution authority".to_string()],
|
||||
scope_hints: intent.requested_paths.clone(),
|
||||
evidence_refs: vec!["context-route-evidence".to_string()],
|
||||
public_source_refs: Vec::new(),
|
||||
private_state_included: false,
|
||||
proposed_at: "2026-06-12T00:00:01Z".to_string(),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -206,6 +206,32 @@ fn repo_model_patch_advances_exact_revision_and_hash() -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn repo_model_public_source_authority_is_canonical_and_eyes_owned() {
|
||||
let mut snapshot = fixture_snapshot();
|
||||
let claim_id = snapshot.nodes[0].id.clone();
|
||||
let mut item = frontier_item("frontier-public", &claim_id);
|
||||
item.public_source_refs = vec![
|
||||
"github://GameCult/Epiphany@0123456789abcdef0123456789abcdef01234567/README.md"
|
||||
.to_string(),
|
||||
];
|
||||
snapshot.frontier.push(item.clone());
|
||||
assert!(validate_memory_graph_snapshot(&snapshot).is_empty());
|
||||
|
||||
snapshot.frontier[0].recommended_next_organ = "Hands".to_string();
|
||||
assert!(validate_memory_graph_snapshot(&snapshot)
|
||||
.iter()
|
||||
.any(|error| error.path.ends_with("public_source_refs")));
|
||||
|
||||
snapshot.frontier[0] = item;
|
||||
snapshot.frontier[0].public_source_refs[0] =
|
||||
"github://GameCult/Epiphany@0123456789ABCDEF0123456789ABCDEF01234567/README.md"
|
||||
.to_string();
|
||||
assert!(validate_memory_graph_snapshot(&snapshot)
|
||||
.iter()
|
||||
.any(|error| error.path.ends_with("public_source_refs")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stale_repo_model_patch_is_rejected_without_mutation() -> Result<()> {
|
||||
let directory = tempfile::tempdir()?;
|
||||
|
|
|
|||
|
|
@ -118,6 +118,23 @@ pub fn validate_memory_graph_snapshot(
|
|||
"recommended next organ is required",
|
||||
&mut errors,
|
||||
);
|
||||
if !item.public_source_refs.is_empty() {
|
||||
if item.recommended_next_organ != "Eyes" {
|
||||
errors.push(EpiphanyMemoryGraphValidationError::new(
|
||||
format!("{path}.public_source_refs"),
|
||||
"public source authority belongs only to an Eyes frontier",
|
||||
));
|
||||
}
|
||||
match crate::ImmutableGithubSource::canonicalize_set(
|
||||
item.public_source_refs.iter().map(String::as_str),
|
||||
) {
|
||||
Ok(canonical) if canonical == item.public_source_refs => {}
|
||||
_ => errors.push(EpiphanyMemoryGraphValidationError::new(
|
||||
format!("{path}.public_source_refs"),
|
||||
"public source refs must be one canonical sorted unique immutable GitHub set",
|
||||
)),
|
||||
}
|
||||
}
|
||||
for claim_id in &item.target_claim_ids {
|
||||
if !node_ids.contains(claim_id) {
|
||||
errors.push(EpiphanyMemoryGraphValidationError::new(
|
||||
|
|
|
|||
|
|
@ -71,6 +71,21 @@ impl ImmutableGithubSource {
|
|||
pub fn repository_ref(&self) -> String {
|
||||
format!("github://{}/{}", self.owner, self.repository)
|
||||
}
|
||||
|
||||
pub fn canonicalize_set<'a>(
|
||||
source_refs: impl IntoIterator<Item = &'a str>,
|
||||
) -> Result<Vec<String>> {
|
||||
let mut canonical = source_refs
|
||||
.into_iter()
|
||||
.map(Self::parse)
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
canonical.sort();
|
||||
canonical.dedup();
|
||||
Ok(canonical
|
||||
.into_iter()
|
||||
.map(|source| source.to_string())
|
||||
.collect())
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for ImmutableGithubSource {
|
||||
|
|
@ -149,4 +164,17 @@ mod tests {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn canonicalizes_one_sorted_unique_source_set() -> Result<()> {
|
||||
let canonical = ImmutableGithubSource::canonicalize_set([
|
||||
"github://GameCult/Epiphany@ABCDEF0123456789ABCDEF0123456789ABCDEF01/src/lib.rs",
|
||||
"github://GameCult/Epiphany@abcdef0123456789abcdef0123456789abcdef01/README.md",
|
||||
"github://GameCult/Epiphany@abcdef0123456789abcdef0123456789abcdef01/README.md",
|
||||
])?;
|
||||
assert_eq!(canonical.len(), 2);
|
||||
assert!(canonical[0].ends_with("/README.md"));
|
||||
assert!(canonical[1].ends_with("/src/lib.rs"));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,8 +31,10 @@
|
|||
//! parallel route document.
|
||||
|
||||
use crate::MindGatewayDecision;
|
||||
use anyhow::Result;
|
||||
use cultcache_rs::DatabaseEntry;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
pub const REPO_MODEL_ADMISSION_REVIEW_TYPE: &str = "epiphany.mind.repo_model_admission_review";
|
||||
pub const REPO_MODEL_ADMISSION_REVIEW_SCHEMA_VERSION: &str =
|
||||
|
|
@ -306,6 +308,7 @@ pub struct RepoFrontierUserProposalInput {
|
|||
pub constraints: Vec<String>,
|
||||
pub scope_hints: Vec<String>,
|
||||
pub evidence_refs: Vec<String>,
|
||||
pub public_source_refs: Vec<String>,
|
||||
pub proposed_at: String,
|
||||
pub private_state_included: bool,
|
||||
}
|
||||
|
|
@ -354,6 +357,41 @@ pub struct RepoFrontierWorkProposal {
|
|||
pub proposed_at: String,
|
||||
#[cultcache(key = 18)]
|
||||
pub contract: String,
|
||||
#[cultcache(key = 19, default)]
|
||||
pub public_source_refs: Vec<String>,
|
||||
}
|
||||
|
||||
pub fn repo_frontier_proposal_payload_sha256(
|
||||
title: &str,
|
||||
body: &str,
|
||||
desired_outcome: &str,
|
||||
constraints: &[String],
|
||||
scope_hints: &[String],
|
||||
evidence_refs: &[String],
|
||||
public_source_refs: &[String],
|
||||
) -> Result<String> {
|
||||
let content = if public_source_refs.is_empty() {
|
||||
// Preserve the exact identity of pre-public-source v0 proposals.
|
||||
rmp_serde::to_vec_named(&(
|
||||
title,
|
||||
body,
|
||||
desired_outcome,
|
||||
constraints,
|
||||
scope_hints,
|
||||
evidence_refs,
|
||||
))?
|
||||
} else {
|
||||
rmp_serde::to_vec_named(&(
|
||||
title,
|
||||
body,
|
||||
desired_outcome,
|
||||
constraints,
|
||||
scope_hints,
|
||||
evidence_refs,
|
||||
public_source_refs,
|
||||
))?
|
||||
};
|
||||
Ok(format!("{:x}", Sha256::digest(content)))
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
|
||||
|
|
|
|||
|
|
@ -5066,15 +5066,15 @@ fn validate_proposal_modeling_worker_fulfillment(
|
|||
EpiphanyWorkerLaunchDocument::Reorient(_) => None,
|
||||
};
|
||||
let identity = require_identity(cache)?;
|
||||
let payload = rmp_serde::to_vec_named(&(
|
||||
let proposal_payload_sha256 = crate::repo_frontier_proposal_payload_sha256(
|
||||
&proposal.title,
|
||||
&proposal.body,
|
||||
&proposal.desired_outcome,
|
||||
&proposal.constraints,
|
||||
&proposal.scope_hints,
|
||||
&proposal.evidence_refs,
|
||||
))?;
|
||||
let proposal_payload_sha256 = format!("{:x}", Sha256::digest(payload));
|
||||
&proposal.public_source_refs,
|
||||
)?;
|
||||
let expected_projection = crate::RepoFrontierProposalModelingContextProjection {
|
||||
schema_version: crate::REPO_FRONTIER_PROPOSAL_MODELING_CONTEXT_SCHEMA_VERSION.into(),
|
||||
contract: crate::REPO_FRONTIER_PROPOSAL_MODELING_CONTEXT_CONTRACT.into(),
|
||||
|
|
@ -5094,6 +5094,7 @@ fn validate_proposal_modeling_worker_fulfillment(
|
|||
constraints: proposal.constraints.clone(),
|
||||
scope_hints: proposal.scope_hints.clone(),
|
||||
evidence_refs: proposal.evidence_refs.clone(),
|
||||
public_source_refs: proposal.public_source_refs.clone(),
|
||||
private_state_included: proposal.private_state_included,
|
||||
model_revision: patch.base_revision,
|
||||
model_hash: patch.base_hash.clone(),
|
||||
|
|
@ -5213,6 +5214,12 @@ fn validate_proposal_modeling_worker_fulfillment(
|
|||
.any(|id| id == &proposal.proposal_id)
|
||||
|| upserts[0].source_scope.is_empty()
|
||||
|| !safe_sorted_unique_paths(&upserts[0].source_scope)
|
||||
|| upserts[0].public_source_refs
|
||||
!= if upserts[0].recommended_next_organ == "Eyes" {
|
||||
proposal.public_source_refs.clone()
|
||||
} else {
|
||||
Vec::new()
|
||||
}
|
||||
|| upserts[0].status != crate::RepoFrontierStatus::Active
|
||||
|| !matches!(
|
||||
upserts[0].recommended_next_organ.as_str(),
|
||||
|
|
@ -5525,6 +5532,7 @@ fn validate_ordinary_modeling_frontier_transition(
|
|||
|| frontier.source_scope.is_empty()
|
||||
|| !safe_sorted_unique_paths(&frontier.source_scope)
|
||||
|| frontier.evidence_refs.is_empty()
|
||||
|| !frontier.public_source_refs.is_empty()
|
||||
|| !frontier
|
||||
.evidence_refs
|
||||
.iter()
|
||||
|
|
@ -6268,6 +6276,7 @@ pub fn commit_repo_model_admission(
|
|||
|| item.question != current_item.question
|
||||
|| item.target_claim_ids != current_item.target_claim_ids
|
||||
|| item.source_scope != current_item.source_scope
|
||||
|| item.public_source_refs != current_item.public_source_refs
|
||||
|| item.dependency_item_ids != current_item.dependency_item_ids
|
||||
|| item.created_at != current_item.created_at
|
||||
|| item.recommended_next_organ != current_item.recommended_next_organ
|
||||
|
|
@ -6395,15 +6404,22 @@ pub(crate) fn validate_repo_frontier_work_proposal(
|
|||
{
|
||||
return Err(anyhow!("invalid inert repo frontier work proposal"));
|
||||
}
|
||||
let content = rmp_serde::to_vec_named(&(
|
||||
let canonical_public_sources = crate::ImmutableGithubSource::canonicalize_set(
|
||||
proposal.public_source_refs.iter().map(String::as_str),
|
||||
)?;
|
||||
if canonical_public_sources != proposal.public_source_refs {
|
||||
return Err(anyhow!("proposal public source set is not canonical"));
|
||||
}
|
||||
let expected_payload_sha256 = crate::repo_frontier_proposal_payload_sha256(
|
||||
&proposal.title,
|
||||
&proposal.body,
|
||||
&proposal.desired_outcome,
|
||||
&proposal.constraints,
|
||||
&proposal.scope_hints,
|
||||
&proposal.evidence_refs,
|
||||
))?;
|
||||
if proposal.payload_sha256 != format!("{:x}", Sha256::digest(content)) {
|
||||
&proposal.public_source_refs,
|
||||
)?;
|
||||
if proposal.payload_sha256 != expected_payload_sha256 {
|
||||
return Err(anyhow!("proposal content hash mismatch"));
|
||||
}
|
||||
Ok(())
|
||||
|
|
@ -6636,14 +6652,18 @@ pub fn intake_user_repo_frontier_proposal(
|
|||
store_path: impl AsRef<Path>,
|
||||
input: crate::RepoFrontierUserProposalInput,
|
||||
) -> Result<RepoFrontierWorkProposal> {
|
||||
let content = rmp_serde::to_vec_named(&(
|
||||
let public_source_refs = crate::ImmutableGithubSource::canonicalize_set(
|
||||
input.public_source_refs.iter().map(String::as_str),
|
||||
)?;
|
||||
let payload_sha256 = crate::repo_frontier_proposal_payload_sha256(
|
||||
&input.title,
|
||||
&input.body,
|
||||
&input.desired_outcome,
|
||||
&input.constraints,
|
||||
&input.scope_hints,
|
||||
&input.evidence_refs,
|
||||
))?;
|
||||
&public_source_refs,
|
||||
)?;
|
||||
let proposal = RepoFrontierWorkProposal {
|
||||
schema_version: REPO_FRONTIER_WORK_PROPOSAL_SCHEMA_VERSION.into(),
|
||||
proposal_id: input.proposal_id,
|
||||
|
|
@ -6654,13 +6674,14 @@ pub fn intake_user_repo_frontier_proposal(
|
|||
workspace: input.workspace,
|
||||
thread_id: input.thread_id,
|
||||
runtime_id: input.runtime_id,
|
||||
payload_sha256: format!("{:x}", Sha256::digest(content)),
|
||||
payload_sha256,
|
||||
title: input.title,
|
||||
body: input.body,
|
||||
desired_outcome: input.desired_outcome,
|
||||
constraints: input.constraints,
|
||||
scope_hints: input.scope_hints,
|
||||
evidence_refs: input.evidence_refs,
|
||||
public_source_refs,
|
||||
private_state_included: input.private_state_included,
|
||||
proposed_at: input.proposed_at,
|
||||
contract: REPO_FRONTIER_WORK_PROPOSAL_CONTRACT.into(),
|
||||
|
|
@ -6911,15 +6932,15 @@ pub fn promote_autonomous_direction_options_for_modeling(
|
|||
),
|
||||
])
|
||||
.collect::<Vec<_>>();
|
||||
let content = rmp_serde::to_vec_named(&(
|
||||
let payload_sha256 = crate::repo_frontier_proposal_payload_sha256(
|
||||
&option.title,
|
||||
&option.summary,
|
||||
&option.summary,
|
||||
&result.uncertainties,
|
||||
&Vec::<String>::new(),
|
||||
&[],
|
||||
&evidence_refs,
|
||||
))?;
|
||||
let payload_sha256 = format!("{:x}", Sha256::digest(content));
|
||||
&[],
|
||||
)?;
|
||||
let proposal = RepoFrontierWorkProposal {
|
||||
schema_version: REPO_FRONTIER_WORK_PROPOSAL_SCHEMA_VERSION.into(),
|
||||
proposal_id: proposal_id.clone(),
|
||||
|
|
@ -6937,6 +6958,7 @@ pub fn promote_autonomous_direction_options_for_modeling(
|
|||
constraints: result.uncertainties.clone(),
|
||||
scope_hints: Vec::new(),
|
||||
evidence_refs,
|
||||
public_source_refs: Vec::new(),
|
||||
private_state_included: false,
|
||||
proposed_at: result.proposed_at.clone(),
|
||||
contract: REPO_FRONTIER_WORK_PROPOSAL_CONTRACT.into(),
|
||||
|
|
@ -8932,14 +8954,14 @@ pub fn select_and_commit_repo_frontier_research_request(
|
|||
let item = actionable_frontier_item_for_organ(&model, &challenges, "Eyes", false)
|
||||
.ok_or_else(|| anyhow!("current model has no actionable Eyes frontier"))?;
|
||||
let item_hash = format!("{:x}", Sha256::digest(rmp_serde::to_vec_named(item)?));
|
||||
let mut public_source_refs = item
|
||||
.evidence_refs
|
||||
.iter()
|
||||
.filter_map(|source_ref| crate::ImmutableGithubSource::parse(source_ref).ok())
|
||||
.map(|source| source.to_string())
|
||||
.collect::<Vec<_>>();
|
||||
public_source_refs.sort();
|
||||
public_source_refs.dedup();
|
||||
let public_source_refs = crate::ImmutableGithubSource::canonicalize_set(
|
||||
item.public_source_refs.iter().map(String::as_str),
|
||||
)?;
|
||||
if public_source_refs != item.public_source_refs {
|
||||
return Err(anyhow!(
|
||||
"frontier Research public source authority is not canonical"
|
||||
));
|
||||
}
|
||||
let request_id = crate::frontier_research_request_id(&identity.runtime_id, &model_hash, &item_hash);
|
||||
let request = RepoFrontierResearchRequest {
|
||||
schema_version: REPO_FRONTIER_RESEARCH_REQUEST_SCHEMA_VERSION.to_string(),
|
||||
|
|
@ -9048,14 +9070,14 @@ fn repo_frontier_research_request_is_current(
|
|||
return Ok(false);
|
||||
};
|
||||
let item_hash = format!("{:x}", Sha256::digest(rmp_serde::to_vec_named(item)?));
|
||||
let mut expected_public_source_refs = item
|
||||
.evidence_refs
|
||||
.iter()
|
||||
.filter_map(|source_ref| crate::ImmutableGithubSource::parse(source_ref).ok())
|
||||
.map(|source| source.to_string())
|
||||
.collect::<Vec<_>>();
|
||||
expected_public_source_refs.sort();
|
||||
expected_public_source_refs.dedup();
|
||||
let expected_public_source_refs = crate::ImmutableGithubSource::canonicalize_set(
|
||||
item.public_source_refs.iter().map(String::as_str),
|
||||
)?;
|
||||
if expected_public_source_refs != item.public_source_refs {
|
||||
return Err(anyhow!(
|
||||
"frontier Research public source authority is not canonical"
|
||||
));
|
||||
}
|
||||
let expected_request_id = crate::frontier_research_request_id(&identity.runtime_id, &model_hash, &item_hash);
|
||||
let admission_count = cache
|
||||
.get_all::<RepoModelAdmissionReceipt>()?
|
||||
|
|
@ -14741,6 +14763,24 @@ pub(crate) mod tests {
|
|||
job_id: &str,
|
||||
current: &crate::EpiphanyMemoryGraphSnapshot,
|
||||
review_id: &str,
|
||||
) -> Result<(EpiphanyRuntimeRoleWorkerResult, RepoModelAdmissionReview)> {
|
||||
repo_model_result_and_review_with_public_sources(
|
||||
store,
|
||||
result_id,
|
||||
job_id,
|
||||
current,
|
||||
review_id,
|
||||
&[],
|
||||
)
|
||||
}
|
||||
|
||||
fn repo_model_result_and_review_with_public_sources(
|
||||
store: &Path,
|
||||
result_id: &str,
|
||||
job_id: &str,
|
||||
current: &crate::EpiphanyMemoryGraphSnapshot,
|
||||
review_id: &str,
|
||||
public_source_refs: &[String],
|
||||
) -> Result<(EpiphanyRuntimeRoleWorkerResult, RepoModelAdmissionReview)> {
|
||||
let mut cache = runtime_spine_cache(store)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
|
|
@ -14768,6 +14808,7 @@ pub(crate) mod tests {
|
|||
constraints: vec!["No direct Hands authority".into()],
|
||||
scope_hints: vec!["epiphany-core/src/runtime_spine.rs".into()],
|
||||
evidence_refs: vec![format!("evidence-{result_id}")],
|
||||
public_source_refs: public_source_refs.to_vec(),
|
||||
private_state_included: false,
|
||||
proposed_at: "2026-07-13T03:59:58Z".into(),
|
||||
},
|
||||
|
|
@ -14988,6 +15029,18 @@ pub(crate) mod tests {
|
|||
PathBuf,
|
||||
EpiphanyRuntimeRoleWorkerResult,
|
||||
RepoModelAdmissionReview,
|
||||
)> {
|
||||
proposal_admission_fixture_with_public_sources(root, suffix, &[])
|
||||
}
|
||||
|
||||
fn proposal_admission_fixture_with_public_sources(
|
||||
root: &Path,
|
||||
suffix: &str,
|
||||
public_source_refs: &[String],
|
||||
) -> Result<(
|
||||
PathBuf,
|
||||
EpiphanyRuntimeRoleWorkerResult,
|
||||
RepoModelAdmissionReview,
|
||||
)> {
|
||||
let store = root.join(format!("proposal-admission-{suffix}.cc"));
|
||||
initialize_runtime_spine(
|
||||
|
|
@ -15003,12 +15056,13 @@ pub(crate) mod tests {
|
|||
let legacy = root.join(format!("proposal-{suffix}.legacy"));
|
||||
let (current, _) =
|
||||
ensure_runtime_repo_model(&store, &legacy, &bootstrap, "2026-07-13T03:30:00Z")?;
|
||||
let (result, review) = repo_model_result_and_review(
|
||||
let (result, review) = repo_model_result_and_review_with_public_sources(
|
||||
&store,
|
||||
&format!("proposal-result-{suffix}"),
|
||||
&format!("proposal-job-{suffix}"),
|
||||
¤t,
|
||||
&format!("proposal-review-{suffix}"),
|
||||
public_source_refs,
|
||||
)?;
|
||||
Ok((store, result, review))
|
||||
}
|
||||
|
|
@ -16289,6 +16343,7 @@ pub(crate) mod tests {
|
|||
constraints: vec!["No implicit selection".into()],
|
||||
scope_hints: vec!["epiphany-core/src".into()],
|
||||
evidence_refs: vec![format!("fixture:{suffix}")],
|
||||
public_source_refs: Vec::new(),
|
||||
private_state_included: false,
|
||||
proposed_at: "2026-07-13T02:01:00Z".into(),
|
||||
},
|
||||
|
|
@ -16445,6 +16500,10 @@ pub(crate) mod tests {
|
|||
constraints: vec!["bounded".into()],
|
||||
scope_hints: vec!["epiphany-core/src".into()],
|
||||
evidence_refs: vec!["message-1".into()],
|
||||
public_source_refs: vec![
|
||||
"github://GameCult/Epiphany@ABCDEF0123456789ABCDEF0123456789ABCDEF01/README.md".into(),
|
||||
"github://GameCult/Epiphany@abcdef0123456789abcdef0123456789abcdef01/README.md".into(),
|
||||
],
|
||||
private_state_included: false,
|
||||
proposed_at: "2026-07-13T01:01:00Z".into(),
|
||||
};
|
||||
|
|
@ -16452,19 +16511,40 @@ pub(crate) mod tests {
|
|||
("runtime", input.clone()),
|
||||
("thread", input.clone()),
|
||||
("private", input.clone()),
|
||||
("mutable-source", input.clone()),
|
||||
] {
|
||||
hostile.proposal_id = format!("hostile-{suffix}");
|
||||
match suffix {
|
||||
"runtime" => hostile.runtime_id = "spoofed".into(),
|
||||
"thread" => hostile.thread_id = "spoofed".into(),
|
||||
"private" => hostile.private_state_included = true,
|
||||
"mutable-source" => {
|
||||
hostile.public_source_refs =
|
||||
vec!["github://GameCult/Epiphany@main/README.md".into()]
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
let before = std::fs::read(&store)?;
|
||||
assert!(intake_user_repo_frontier_proposal(&store, hostile).is_err());
|
||||
assert_eq!(std::fs::read(&store)?, before);
|
||||
}
|
||||
intake_user_repo_frontier_proposal(&store, input)?;
|
||||
let admitted = intake_user_repo_frontier_proposal(&store, input)?;
|
||||
assert_eq!(
|
||||
admitted.public_source_refs,
|
||||
["github://GameCult/Epiphany@abcdef0123456789abcdef0123456789abcdef01/README.md"]
|
||||
);
|
||||
assert_eq!(
|
||||
admitted.payload_sha256,
|
||||
crate::repo_frontier_proposal_payload_sha256(
|
||||
&admitted.title,
|
||||
&admitted.body,
|
||||
&admitted.desired_outcome,
|
||||
&admitted.constraints,
|
||||
&admitted.scope_hints,
|
||||
&admitted.evidence_refs,
|
||||
&admitted.public_source_refs,
|
||||
)?
|
||||
);
|
||||
let selected = select_repo_frontier_work_proposal_for_modeling(
|
||||
&store,
|
||||
"intake-proposal",
|
||||
|
|
@ -16748,7 +16828,19 @@ pub(crate) mod tests {
|
|||
suffix: &str,
|
||||
next_organ: &str,
|
||||
) -> Result<(PathBuf, RepoModelClaimChallenge)> {
|
||||
let (store, result, review) = proposal_admission_fixture(root, suffix)?;
|
||||
let public_source_refs = if next_organ == "Eyes" {
|
||||
vec![
|
||||
"github://GameCult/Epiphany@0123456789abcdef0123456789abcdef01234567/README.md"
|
||||
.to_string(),
|
||||
]
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
let (store, result, review) = proposal_admission_fixture_with_public_sources(
|
||||
root,
|
||||
suffix,
|
||||
&public_source_refs,
|
||||
)?;
|
||||
let mut result = result;
|
||||
if next_organ != "Hands" {
|
||||
let mut patch: crate::RepoModelPatch =
|
||||
|
|
@ -16760,11 +16852,17 @@ pub(crate) mod tests {
|
|||
item.recommended_next_organ = next_organ.into();
|
||||
if next_organ == "Eyes" {
|
||||
item.evidence_refs.push(
|
||||
"github://GameCult/Epiphany@0123456789abcdef0123456789abcdef01234567/README.md"
|
||||
"github://GameCult/Epiphany@0123456789abcdef0123456789abcdef01234567/not-authority.md"
|
||||
.into(),
|
||||
);
|
||||
item.evidence_refs.sort();
|
||||
item.evidence_refs.dedup();
|
||||
item.public_source_refs.push(
|
||||
"github://GameCult/Epiphany@0123456789abcdef0123456789abcdef01234567/README.md"
|
||||
.into(),
|
||||
);
|
||||
item.public_source_refs.sort();
|
||||
item.public_source_refs.dedup();
|
||||
}
|
||||
let bytes = rmp_serde::to_vec_named(&patch)?;
|
||||
result.repo_model_patch_msgpack = Some(bytes.clone());
|
||||
|
|
@ -18290,6 +18388,14 @@ pub(crate) mod tests {
|
|||
let mut item = item;
|
||||
let routeable = item.status == crate::RepoFrontierStatus::Active;
|
||||
item.evidence_refs.push(proposal_id);
|
||||
if item.recommended_next_organ == "Eyes" {
|
||||
item.public_source_refs = runtime_repo_frontier_work_proposal(
|
||||
store,
|
||||
&result.evidence_ids[0],
|
||||
)?
|
||||
.expect("eligibility fixture proposal")
|
||||
.public_source_refs;
|
||||
}
|
||||
patch.operations = vec![crate::RepoModelPatchOperation::UpsertFrontier { item }];
|
||||
let bytes = rmp_serde::to_vec_named(&patch)?;
|
||||
review.patch_sha256 = format!("{:x}", Sha256::digest(&bytes));
|
||||
|
|
|
|||
|
|
@ -267,6 +267,8 @@ pub struct RepoFrontierProposalModelingContextProjection {
|
|||
pub scope_hints: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub evidence_refs: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub public_source_refs: Vec<String>,
|
||||
pub private_state_included: bool,
|
||||
pub model_revision: u64,
|
||||
pub model_hash: String,
|
||||
|
|
|
|||
|
|
@ -1849,6 +1849,11 @@ fn role_worker_result_from_ingress(
|
|||
dependency_item_ids,
|
||||
status: epiphany_core::RepoFrontierStatus::Active,
|
||||
evidence_refs,
|
||||
public_source_refs: if draft.recommended_next_organ.trim() == "Eyes" {
|
||||
context.public_source_refs.clone()
|
||||
} else {
|
||||
Vec::new()
|
||||
},
|
||||
created_at: Some(completed_at.to_string()),
|
||||
updated_at: Some(completed_at.to_string()),
|
||||
retired_at: None,
|
||||
|
|
@ -2598,6 +2603,10 @@ mod tests {
|
|||
constraints: Vec::new(),
|
||||
scope_hints: vec!["epiphany-core/src/resident_self.rs".into()],
|
||||
evidence_refs: vec!["git:source".into()],
|
||||
public_source_refs: vec![
|
||||
"github://GameCult/Epiphany@0123456789abcdef0123456789abcdef01234567/README.md"
|
||||
.into(),
|
||||
],
|
||||
private_state_included: false,
|
||||
model_revision: 41,
|
||||
model_hash: "model-hash-41".into(),
|
||||
|
|
@ -2662,6 +2671,7 @@ mod tests {
|
|||
assert_eq!(item.status, epiphany_core::RepoFrontierStatus::Active);
|
||||
assert!(item.adopted_plan.is_none());
|
||||
assert!(item.evidence_refs.contains(&"proposal-1".to_string()));
|
||||
assert_eq!(item.public_source_refs, context.public_source_refs);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -2687,6 +2697,7 @@ mod tests {
|
|||
constraints: Vec::new(),
|
||||
scope_hints: vec!["epiphany-core/src/resident_self.rs".into()],
|
||||
evidence_refs: vec!["git:source".into()],
|
||||
public_source_refs: Vec::new(),
|
||||
private_state_included: false,
|
||||
model_revision: 41,
|
||||
model_hash: "model-hash-41".into(),
|
||||
|
|
@ -3498,6 +3509,7 @@ mod tests {
|
|||
dependency_item_ids: Vec::new(),
|
||||
status: epiphany_core::RepoFrontierStatus::Active,
|
||||
evidence_refs: vec!["prior-evidence".to_string()],
|
||||
public_source_refs: Vec::new(),
|
||||
created_at: Some("2026-08-07T00:00:00Z".to_string()),
|
||||
updated_at: Some("2026-08-07T00:00:00Z".to_string()),
|
||||
retired_at: None,
|
||||
|
|
|
|||
|
|
@ -788,6 +788,11 @@ pub struct RepoFrontierItem {
|
|||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
#[ts(type = "Array<string>")]
|
||||
pub evidence_refs: Vec<String>,
|
||||
/// Exact immutable public sources selected upstream for Eyes. These are
|
||||
/// causal retrieval inputs, not evidence produced by Modeling.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
#[ts(type = "Array<string>")]
|
||||
pub public_source_refs: Vec<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(type = "string | null")]
|
||||
pub created_at: Option<String>,
|
||||
|
|
|
|||
Reference in a new issue