Make typed cognition causality runtime-owned
This commit is contained in:
parent
af2581b5c5
commit
b661ec4b1c
3 changed files with 247 additions and 105 deletions
|
|
@ -990,19 +990,11 @@ pub fn epiphany_imagination_consideration_output_schema() -> serde_json::Value {
|
|||
"summary": {"type": "string", "minLength": 1},
|
||||
"nextSafeMove": {"type": "string", "minLength": 1},
|
||||
"filesInspected": {"type": "array", "items": {"type": "string"}},
|
||||
"imaginationConsiderationRequestId": {"type": "string", "minLength": 1},
|
||||
"imaginationConsiderationCandidate": {
|
||||
"type": "object",
|
||||
"required": ["request_id", "feedback_id", "feedback_packet_sha256", "model_revision", "model_hash",
|
||||
"source_room_id", "source_visibility", "data_classification",
|
||||
"disposition", "title", "summary", "rationale", "option_drafts", "uncertainties", "evidence_refs",
|
||||
"recommended_review_route", "proposed_at", "contract"],
|
||||
"required": ["disposition", "title", "summary", "rationale", "option_drafts", "uncertainties",
|
||||
"evidence_refs", "recommended_review_route"],
|
||||
"properties": {
|
||||
"request_id": {"type": "string", "minLength": 1},
|
||||
"feedback_id": {"type": "string", "minLength": 1},
|
||||
"feedback_packet_sha256": {"type": "string", "minLength": 1},
|
||||
"model_revision": {"type": "integer", "minimum": 0},
|
||||
"model_hash": {"type": "string", "minLength": 1},
|
||||
"disposition": {"type": "string", "enum": ["suggest", "hold", "no_fit"]},
|
||||
"title": {"type": "string", "minLength": 1}, "summary": {"type": "string", "minLength": 1},
|
||||
"rationale": {"type": "string", "minLength": 1},
|
||||
|
|
@ -1011,18 +1003,13 @@ pub fn epiphany_imagination_consideration_output_schema() -> serde_json::Value {
|
|||
"additionalProperties": false}},
|
||||
"uncertainties": {"type": "array", "items": {"type": "string"}},
|
||||
"evidence_refs": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}},
|
||||
"source_room_id": {"type": "string", "minLength": 1},
|
||||
"source_visibility": {"type": "string", "minLength": 1},
|
||||
"data_classification": {"type": "string", "minLength": 1},
|
||||
"recommended_review_route": {"type": "string", "enum": ["modeling_review", "hold", "silence"]},
|
||||
"proposed_at": {"type": "string", "minLength": 1},
|
||||
"contract": {"const": "epiphany.imagination_consideration_candidate.v0"}
|
||||
"recommended_review_route": {"type": "string", "enum": ["modeling_review", "hold", "silence"]}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": ["roleId", "verdict", "summary", "nextSafeMove", "filesInspected",
|
||||
"imaginationConsiderationRequestId", "imaginationConsiderationCandidate"],
|
||||
"imaginationConsiderationCandidate"],
|
||||
"additionalProperties": false
|
||||
})
|
||||
}
|
||||
|
|
@ -1036,36 +1023,23 @@ pub fn epiphany_admitted_model_direction_consideration_output_schema() -> serde_
|
|||
"summary": {"type": "string", "minLength": 1},
|
||||
"nextSafeMove": {"type": "string", "minLength": 1},
|
||||
"filesInspected": {"type": "array", "items": {"type": "string"}},
|
||||
"admittedModelDirectionConsiderationRequestId": {"type": "string", "minLength": 1},
|
||||
"admittedModelDirectionConsiderationResult": {
|
||||
"type": "object",
|
||||
"required": ["request_id", "runtime_id", "thread_id", "model_revision", "model_hash",
|
||||
"model_admission_receipt_id", "disposition", "summary", "option_drafts", "uncertainties",
|
||||
"evidence_refs", "proposed_at", "contract", "proposal_only", "terminal"],
|
||||
"required": ["disposition", "summary", "option_drafts", "uncertainties", "evidence_refs"],
|
||||
"properties": {
|
||||
"request_id": {"type": "string", "minLength": 1},
|
||||
"runtime_id": {"type": "string", "minLength": 1},
|
||||
"thread_id": {"type": "string", "minLength": 1},
|
||||
"model_revision": {"type": "integer", "minimum": 0},
|
||||
"model_hash": {"type": "string", "minLength": 1},
|
||||
"model_admission_receipt_id": {"type": "string", "minLength": 1},
|
||||
"disposition": {"type": "string", "enum": ["suggest", "hold", "no_fit"]},
|
||||
"summary": {"type": "string", "minLength": 1},
|
||||
"option_drafts": {"type": "array", "items": {"type": "object", "required": ["title", "summary"],
|
||||
"properties": {"title": {"type": "string", "minLength": 1}, "summary": {"type": "string", "minLength": 1}},
|
||||
"additionalProperties": false}},
|
||||
"uncertainties": {"type": "array", "items": {"type": "string"}},
|
||||
"evidence_refs": {"type": "array", "items": {"type": "string"}},
|
||||
"proposed_at": {"type": "string", "minLength": 1},
|
||||
"contract": {"const": "epiphany.admitted_model_direction_consideration_result.v0"},
|
||||
"proposal_only": {"const": true},
|
||||
"terminal": {"const": true}
|
||||
"evidence_refs": {"type": "array", "items": {"type": "string"}}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": ["roleId", "verdict", "summary", "nextSafeMove", "filesInspected",
|
||||
"admittedModelDirectionConsiderationRequestId", "admittedModelDirectionConsiderationResult"],
|
||||
"admittedModelDirectionConsiderationResult"],
|
||||
"additionalProperties": false
|
||||
})
|
||||
}
|
||||
|
|
@ -2012,10 +1986,26 @@ mod tests {
|
|||
let schema = epiphany_imagination_consideration_output_schema();
|
||||
assert!(schema["properties"]
|
||||
.get("imaginationConsiderationRequestId")
|
||||
.is_some());
|
||||
.is_none());
|
||||
assert!(schema["properties"]
|
||||
.get("imaginationConsiderationCandidate")
|
||||
.is_some());
|
||||
for runtime_owned in [
|
||||
"request_id",
|
||||
"feedback_id",
|
||||
"feedback_packet_sha256",
|
||||
"source_room_id",
|
||||
"source_visibility",
|
||||
"data_classification",
|
||||
"model_revision",
|
||||
"model_hash",
|
||||
"proposed_at",
|
||||
"contract",
|
||||
] {
|
||||
assert!(schema["properties"]["imaginationConsiderationCandidate"]["properties"]
|
||||
.get(runtime_owned)
|
||||
.is_none());
|
||||
}
|
||||
for forbidden in [
|
||||
"statePatch",
|
||||
"selfPatch",
|
||||
|
|
|
|||
|
|
@ -11414,7 +11414,8 @@ where
|
|||
"coordinator run session already has partial terminal authority"
|
||||
));
|
||||
}
|
||||
let snapshot = cache.snapshot_envelopes();
|
||||
let expected_session = cache
|
||||
.get_required_envelope::<EpiphanyRuntimeSession>(&receipt.session_id)?;
|
||||
session.status = EpiphanyRuntimeSessionStatus::Completed;
|
||||
session.updated_at = receipt.created_at.clone();
|
||||
session.coordinator_note = completion_summary;
|
||||
|
|
@ -11427,10 +11428,10 @@ where
|
|||
];
|
||||
before_commit()?;
|
||||
if !runtime_spine_backing_store(store_path)?
|
||||
.replace_and_append_if_snapshot_unchanged(&snapshot, replacements)?
|
||||
.compare_and_swap_batch(&[expected_session], replacements)?
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"coordinator run finalization lost its full snapshot fence"
|
||||
"coordinator run finalization lost its exact session transaction"
|
||||
));
|
||||
}
|
||||
Ok(session)
|
||||
|
|
@ -17394,7 +17395,7 @@ pub(crate) mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn coordinator_run_finalization_is_atomic_idempotent_and_snapshot_fenced() -> Result<()> {
|
||||
fn coordinator_run_finalization_is_atomic_idempotent_and_identity_fenced() -> Result<()> {
|
||||
let temp = tempdir()?;
|
||||
let store = temp.path().join("runtime.msgpack");
|
||||
initialize_runtime_spine(
|
||||
|
|
@ -17510,7 +17511,7 @@ pub(crate) mod tests {
|
|||
"coordinator-receipt-race",
|
||||
"thread-race",
|
||||
);
|
||||
let race = finalize_coordinator_run_with_before_commit(&store, &raced_receipt, || {
|
||||
let raced = finalize_coordinator_run_with_before_commit(&store, &raced_receipt, || {
|
||||
append_runtime_event(
|
||||
&store,
|
||||
RuntimeSpineEventOptions {
|
||||
|
|
@ -17520,12 +17521,15 @@ pub(crate) mod tests {
|
|||
source: "test".to_string(),
|
||||
session_id: None,
|
||||
job_id: None,
|
||||
summary: "Changes the full snapshot.".to_string(),
|
||||
summary: "Must coexist with the exact terminal transaction.".to_string(),
|
||||
},
|
||||
)?;
|
||||
Ok(())
|
||||
});
|
||||
assert!(race.is_err());
|
||||
assert_eq!(
|
||||
raced?.status,
|
||||
EpiphanyRuntimeSessionStatus::Completed
|
||||
);
|
||||
let mut cache = runtime_spine_cache(&store)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
assert_eq!(
|
||||
|
|
@ -17533,19 +17537,23 @@ pub(crate) mod tests {
|
|||
.get::<EpiphanyRuntimeSession>("coordinator-thread-race")?
|
||||
.expect("raced session")
|
||||
.status,
|
||||
EpiphanyRuntimeSessionStatus::Active
|
||||
EpiphanyRuntimeSessionStatus::Completed
|
||||
);
|
||||
assert!(
|
||||
cache
|
||||
.get::<EpiphanyCoordinatorRunReceipt>(&raced_receipt.receipt_id)?
|
||||
.is_none()
|
||||
assert_eq!(
|
||||
cache.get::<EpiphanyCoordinatorRunReceipt>(&raced_receipt.receipt_id)?,
|
||||
Some(raced_receipt)
|
||||
);
|
||||
assert!(
|
||||
cache
|
||||
.get::<EpiphanyRuntimeEvent>(
|
||||
"event-session-completed-coordinator-thread-race"
|
||||
)?
|
||||
.is_none()
|
||||
.is_some()
|
||||
);
|
||||
assert!(
|
||||
cache
|
||||
.get::<EpiphanyRuntimeEvent>("unrelated-racing-event")?
|
||||
.is_some()
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue