Bind Persona cognition to disclosure bridge
This commit is contained in:
parent
9fdbfc8a2a
commit
af2581b5c5
4 changed files with 81 additions and 10 deletions
|
|
@ -277,19 +277,20 @@ fn cycle(
|
|||
) -> Result<ResidentSelfOutcome> {
|
||||
let now = Utc::now().timestamp_millis().max(0) as u64;
|
||||
let brake_engaged = ports.brake_engaged()?;
|
||||
let cognitive_runtime_id = ports.cognitive_runtime_id().to_string();
|
||||
run_feedback_import_if_released(brake_engaged || shutdown_requested, || {
|
||||
import_bifrost_persona_feedback_deliveries(
|
||||
&args.persona_feedback_source_store,
|
||||
&args.persona_feedback_store,
|
||||
&args.bifrost_feedback_trust_anchor,
|
||||
&args.policy.release_runtime_id,
|
||||
&cognitive_runtime_id,
|
||||
&args.feedback_target_repository,
|
||||
&args.feedback_target_persona,
|
||||
)?;
|
||||
bridge_admitted_persona_feedback_to_heartbeat(
|
||||
&args.persona_feedback_store,
|
||||
&args.heartbeat_store,
|
||||
&args.policy.release_runtime_id,
|
||||
&cognitive_runtime_id,
|
||||
&args.policy.model_provider,
|
||||
&args.persona_model_allowed_data_classifications,
|
||||
)?;
|
||||
|
|
@ -305,7 +306,7 @@ fn cycle(
|
|||
&args.state_store,
|
||||
&args.policy.runtime_store,
|
||||
&args.persona_feedback_store,
|
||||
&args.policy.release_runtime_id,
|
||||
&cognitive_runtime_id,
|
||||
&args.feedback_target_repository,
|
||||
&args.policy.workspace.display().to_string(),
|
||||
now,
|
||||
|
|
@ -630,6 +631,10 @@ impl<'a> NativePorts<'a> {
|
|||
children: BTreeMap::new(),
|
||||
})
|
||||
}
|
||||
|
||||
fn cognitive_runtime_id(&self) -> &str {
|
||||
&self.cognitive_runtime_id
|
||||
}
|
||||
}
|
||||
|
||||
impl ResidentSelfPorts for NativePorts<'_> {
|
||||
|
|
@ -796,7 +801,7 @@ mod brake_tests {
|
|||
};
|
||||
|
||||
let mut ports = NativePorts::new(&policy)?;
|
||||
assert_eq!(ports.cognitive_runtime_id, "cognitive-runtime");
|
||||
assert_eq!(ports.cognitive_runtime_id(), "cognitive-runtime");
|
||||
assert!(ports.brake_engaged()?);
|
||||
assert!(!resident_self_brake_engaged(
|
||||
&policy.local_verse_store,
|
||||
|
|
|
|||
|
|
@ -923,6 +923,7 @@ pub use persona_feedback_admission::{
|
|||
PERSONA_FEEDBACK_HEARTBEAT_BRIDGE_SCHEMA_VERSION, PersonaFeedbackHeartbeatBridgeReceipt,
|
||||
PersonaFeedbackPacket, admit_bifrost_persona_feedback, admitted_persona_feedback,
|
||||
apply_bifrost_persona_feedback_snapshot, bridge_admitted_persona_feedback_to_heartbeat,
|
||||
bridged_persona_feedback_ready_for_cognition,
|
||||
import_bifrost_persona_feedback_deliveries, persona_feedback_admission_signing_payload,
|
||||
persona_feedback_admission_signing_purpose, persona_feedback_packet_sha256,
|
||||
validate_bifrost_persona_feedback_source, validate_persona_feedback_store_separation,
|
||||
|
|
|
|||
|
|
@ -468,6 +468,46 @@ pub fn admitted_persona_feedback(
|
|||
Ok(feedback)
|
||||
}
|
||||
|
||||
/// Returns only admitted feedback whose exact Heartbeat bridge receipt proves
|
||||
/// that the configured provider disclosure policy allowed it to enter
|
||||
/// cognition. Admission authenticates transport; it does not grant disclosure.
|
||||
pub fn bridged_persona_feedback_ready_for_cognition(
|
||||
path: &Path,
|
||||
runtime_id: &str,
|
||||
) -> Result<Vec<LocalAdmittedPersonaFeedback>> {
|
||||
let mut ready = Vec::new();
|
||||
for feedback in admitted_persona_feedback(path, runtime_id)? {
|
||||
if feedback.target_runtime_id != runtime_id {
|
||||
bail!("admitted Persona feedback escaped its target runtime");
|
||||
}
|
||||
let receipt_id = format!("persona-feedback-heartbeat:{}", feedback.feedback_id);
|
||||
let Some((receipt, _)) = load_persona_feedback_bridge_receipt(path, &receipt_id)? else {
|
||||
continue;
|
||||
};
|
||||
let expected_mention_id = format!("bifrost-feedback:{}", feedback.feedback_id);
|
||||
if receipt.schema_version != PERSONA_FEEDBACK_HEARTBEAT_BRIDGE_SCHEMA_VERSION
|
||||
|| receipt.receipt_id != receipt_id
|
||||
|| receipt.feedback_id != feedback.feedback_id
|
||||
|| receipt.admission_id != feedback.admission_id
|
||||
|| receipt.packet_sha256 != feedback.packet_sha256
|
||||
|| receipt.heartbeat_mention_id != expected_mention_id
|
||||
|| receipt.discord_channel_id != feedback.discord_channel_id
|
||||
|| receipt.discord_message_id != feedback.discord_message_id
|
||||
|| receipt.private_state_exposed
|
||||
{
|
||||
bail!("Persona feedback cognition bridge receipt is not exact");
|
||||
}
|
||||
if receipt.status == "pending" {
|
||||
continue;
|
||||
}
|
||||
if receipt.status != "queued" {
|
||||
bail!("Persona feedback cognition bridge receipt has invalid status");
|
||||
}
|
||||
ready.push(feedback);
|
||||
}
|
||||
Ok(ready)
|
||||
}
|
||||
|
||||
pub fn import_bifrost_persona_feedback_deliveries(
|
||||
source_store: &Path,
|
||||
feedback_store: &Path,
|
||||
|
|
@ -932,6 +972,13 @@ mod tests {
|
|||
private_state_exposed: false,
|
||||
};
|
||||
insert_pending_persona_feedback_bridge_receipt(&feedback_store, &pending)?;
|
||||
assert!(
|
||||
bridged_persona_feedback_ready_for_cognition(
|
||||
&feedback_store,
|
||||
"epiphany-yggdrasil"
|
||||
)?
|
||||
.is_empty()
|
||||
);
|
||||
|
||||
let recovered = bridge_admitted_persona_feedback_to_heartbeat(
|
||||
&feedback_store,
|
||||
|
|
@ -942,6 +989,13 @@ mod tests {
|
|||
)?;
|
||||
assert_eq!(recovered.len(), 1);
|
||||
assert_eq!(recovered[0].status, "queued");
|
||||
assert_eq!(
|
||||
bridged_persona_feedback_ready_for_cognition(
|
||||
&feedback_store,
|
||||
"epiphany-yggdrasil"
|
||||
)?,
|
||||
vec![admitted]
|
||||
);
|
||||
let state = crate::load_heartbeat_state_entry(&heartbeat_store)?.expect("heartbeat state");
|
||||
assert_eq!(state.pending_mentions.len(), 1);
|
||||
assert_eq!(state.pending_mentions[0].source_surface, "bifrost-discord");
|
||||
|
|
@ -1010,6 +1064,13 @@ mod tests {
|
|||
private_state_exposed: false,
|
||||
},
|
||||
)?;
|
||||
assert!(
|
||||
bridged_persona_feedback_ready_for_cognition(
|
||||
&feedback_store,
|
||||
"epiphany-yggdrasil"
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
assert!(
|
||||
bridge_admitted_persona_feedback_to_heartbeat(
|
||||
&feedback_store,
|
||||
|
|
@ -1063,6 +1124,13 @@ mod tests {
|
|||
admitted_persona_feedback(&feedback_store, "epiphany-yggdrasil")?.len(),
|
||||
1
|
||||
);
|
||||
assert!(
|
||||
bridged_persona_feedback_ready_for_cognition(
|
||||
&feedback_store,
|
||||
"epiphany-yggdrasil"
|
||||
)?
|
||||
.is_empty()
|
||||
);
|
||||
assert!(
|
||||
crate::load_heartbeat_state_entry(&heartbeat_store)?
|
||||
.expect("heartbeat state")
|
||||
|
|
|
|||
|
|
@ -1083,12 +1083,9 @@ pub fn ingest_resident_self_domain_pressure(
|
|||
},
|
||||
)?);
|
||||
}
|
||||
for feedback in crate::admitted_persona_feedback(persona_feedback_store, runtime_id)? {
|
||||
if feedback.target_runtime_id != runtime_id {
|
||||
return Err(anyhow!(
|
||||
"admitted Persona feedback escaped its target runtime"
|
||||
));
|
||||
}
|
||||
for feedback in
|
||||
crate::bridged_persona_feedback_ready_for_cognition(persona_feedback_store, runtime_id)?
|
||||
{
|
||||
let Some(request) = crate::commit_imagination_consideration_request(
|
||||
runtime_store,
|
||||
persona_feedback_store,
|
||||
|
|
|
|||
Reference in a new issue