Type tool request closure semantics
This commit is contained in:
parent
df08dfe3ed
commit
de58096bc6
6 changed files with 179 additions and 36 deletions
|
|
@ -6597,80 +6597,71 @@ fn closure_family_assertions(
|
|||
);
|
||||
}
|
||||
"repo.tool_request" => {
|
||||
let request = parse_repo_tool_request(&content).ok();
|
||||
push_assertion(
|
||||
&mut assertions,
|
||||
"tool-request-schema-present",
|
||||
content.contains("schema_version = \"epiphany.repo_tool_request.v0\""),
|
||||
request
|
||||
.as_ref()
|
||||
.is_some_and(RepoToolRequest::has_canonical_identity),
|
||||
"Committed tool request carries the schema version.".to_string(),
|
||||
);
|
||||
push_assertion(
|
||||
&mut assertions,
|
||||
"tool-request-family-present",
|
||||
content.contains("safe_action_family = \"repo.tool_request\""),
|
||||
request
|
||||
.as_ref()
|
||||
.is_some_and(RepoToolRequest::has_canonical_identity),
|
||||
"Committed tool request carries the safe action family.".to_string(),
|
||||
);
|
||||
push_assertion(
|
||||
&mut assertions,
|
||||
"tool-request-summary-present",
|
||||
content.contains(&compact_summary),
|
||||
request
|
||||
.as_ref()
|
||||
.is_some_and(|request| request.summary == compact_summary),
|
||||
"Committed tool request contains the accepted pressure summary.".to_string(),
|
||||
);
|
||||
push_assertion(
|
||||
&mut assertions,
|
||||
"tool-request-section-present",
|
||||
content.contains("[request]")
|
||||
&& content.contains("target_directory = \"gamecult-local/daemon-tool-directory\"")
|
||||
&& content.contains(
|
||||
"target_capability = \"daemon-tool-capability:selected-by-review\"",
|
||||
)
|
||||
&& content.contains("operation = \"submitTypedToolIntent\""),
|
||||
request
|
||||
.as_ref()
|
||||
.is_some_and(RepoToolRequest::has_request_contract),
|
||||
"Committed tool request names the daemon tool directory and typed intent operation."
|
||||
.to_string(),
|
||||
);
|
||||
push_assertion(
|
||||
&mut assertions,
|
||||
"tool-request-cultmesh-contracts",
|
||||
content.contains("[cultmesh]")
|
||||
&& content.contains(
|
||||
"intent_contract = \"epiphany.cultmesh.daemon_tool_invocation_intent.v0\"",
|
||||
)
|
||||
&& content.contains(
|
||||
"receipt_contract = \"epiphany.cultmesh.daemon_tool_invocation_receipt.v0\"",
|
||||
)
|
||||
&& content.contains("host_daemon_owns_execution = true")
|
||||
&& content.contains("requester_owns_request = false")
|
||||
&& content.contains("requires_host_liveness_ready = true")
|
||||
&& content.contains("requires_cultmesh_receipts = true"),
|
||||
request
|
||||
.as_ref()
|
||||
.is_some_and(RepoToolRequest::has_cultmesh_contract),
|
||||
"Committed tool request names typed CultMesh contracts, host liveness, and host execution ownership.".to_string(),
|
||||
);
|
||||
push_assertion(
|
||||
&mut assertions,
|
||||
"tool-request-odin-provider-ownership",
|
||||
content.contains("[odin]")
|
||||
&& content.contains("discoverable = true")
|
||||
&& content.contains("preserves_provider_ownership = true")
|
||||
&& content.contains("private_verse_passthrough = false"),
|
||||
request
|
||||
.as_ref()
|
||||
.is_some_and(RepoToolRequest::has_odin_contract),
|
||||
"Committed tool request preserves Odin discovery and provider ownership boundaries."
|
||||
.to_string(),
|
||||
);
|
||||
push_assertion(
|
||||
&mut assertions,
|
||||
"tool-request-authority-seals",
|
||||
content.contains("[authority]")
|
||||
&& content.contains("direct_tool_execution = false")
|
||||
&& content.contains("arbitrary_shell_authority = false")
|
||||
&& content.contains("hands_action_authority = false")
|
||||
&& content.contains("state_commit_authority = false")
|
||||
&& content.contains("publication_authority = false")
|
||||
&& content.contains("service_lifecycle_authority = false")
|
||||
&& content.contains("cross_body_mutation_authority = false")
|
||||
&& content.contains("private_verse_rummaging = false"),
|
||||
request
|
||||
.as_ref()
|
||||
.is_some_and(RepoToolRequest::has_authority_seals),
|
||||
"Committed tool request denies direct execution, shell, Hands, state, publication, lifecycle, cross-body, and private-rummaging authority.".to_string(),
|
||||
);
|
||||
push_assertion(
|
||||
&mut assertions,
|
||||
"tool-request-private-seal",
|
||||
content.contains("private_state_exposed = false"),
|
||||
request
|
||||
.as_ref()
|
||||
.is_some_and(|request| !request.private_state_exposed),
|
||||
"Committed tool request preserves the private-state seal.".to_string(),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,141 @@
|
|||
use anyhow::{Context, Result};
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub(super) struct RepoToolRequest {
|
||||
pub(super) schema_version: String,
|
||||
pub(super) safe_action_family: String,
|
||||
pub(super) summary: String,
|
||||
pub(super) private_state_exposed: bool,
|
||||
pub(super) request: RepoToolRequestBody,
|
||||
pub(super) cultmesh: RepoToolRequestCultMesh,
|
||||
pub(super) odin: RepoToolRequestOdin,
|
||||
pub(super) authority: RepoToolRequestAuthority,
|
||||
}
|
||||
|
||||
impl RepoToolRequest {
|
||||
pub(super) fn has_canonical_identity(&self) -> bool {
|
||||
self.schema_version == "epiphany.repo_tool_request.v0"
|
||||
&& self.safe_action_family == "repo.tool_request"
|
||||
}
|
||||
|
||||
pub(super) fn has_request_contract(&self) -> bool {
|
||||
self.request.target_directory == "gamecult-local/daemon-tool-directory"
|
||||
&& self.request.target_capability == "daemon-tool-capability:selected-by-review"
|
||||
&& self.request.operation == "submitTypedToolIntent"
|
||||
}
|
||||
|
||||
pub(super) fn has_cultmesh_contract(&self) -> bool {
|
||||
self.cultmesh.intent_contract == "epiphany.cultmesh.daemon_tool_invocation_intent.v0"
|
||||
&& self.cultmesh.receipt_contract
|
||||
== "epiphany.cultmesh.daemon_tool_invocation_receipt.v0"
|
||||
&& self.cultmesh.host_daemon_owns_execution
|
||||
&& !self.cultmesh.requester_owns_request
|
||||
&& self.cultmesh.requires_host_liveness_ready
|
||||
&& self.cultmesh.requires_cultmesh_receipts
|
||||
}
|
||||
|
||||
pub(super) fn has_odin_contract(&self) -> bool {
|
||||
self.odin.discoverable
|
||||
&& self.odin.preserves_provider_ownership
|
||||
&& !self.odin.private_verse_passthrough
|
||||
}
|
||||
|
||||
pub(super) fn has_authority_seals(&self) -> bool {
|
||||
!self.authority.direct_tool_execution
|
||||
&& !self.authority.arbitrary_shell_authority
|
||||
&& !self.authority.hands_action_authority
|
||||
&& !self.authority.state_commit_authority
|
||||
&& !self.authority.publication_authority
|
||||
&& !self.authority.service_lifecycle_authority
|
||||
&& !self.authority.cross_body_mutation_authority
|
||||
&& !self.authority.private_verse_rummaging
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub(super) struct RepoToolRequestBody {
|
||||
target_directory: String,
|
||||
target_capability: String,
|
||||
operation: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub(super) struct RepoToolRequestCultMesh {
|
||||
intent_contract: String,
|
||||
receipt_contract: String,
|
||||
host_daemon_owns_execution: bool,
|
||||
requester_owns_request: bool,
|
||||
requires_host_liveness_ready: bool,
|
||||
requires_cultmesh_receipts: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub(super) struct RepoToolRequestOdin {
|
||||
discoverable: bool,
|
||||
preserves_provider_ownership: bool,
|
||||
private_verse_passthrough: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub(super) struct RepoToolRequestAuthority {
|
||||
pub(super) direct_tool_execution: bool,
|
||||
arbitrary_shell_authority: bool,
|
||||
hands_action_authority: bool,
|
||||
state_commit_authority: bool,
|
||||
publication_authority: bool,
|
||||
service_lifecycle_authority: bool,
|
||||
cross_body_mutation_authority: bool,
|
||||
private_verse_rummaging: bool,
|
||||
}
|
||||
|
||||
pub(super) fn parse_repo_tool_request(text: &str) -> Result<RepoToolRequest> {
|
||||
toml::from_str(text).context("tool request is not valid typed TOML")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tool_request_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn comment_cannot_counterfeit_direct_execution_seal() {
|
||||
let text = r#"
|
||||
schema_version = "epiphany.repo_tool_request.v0"
|
||||
safe_action_family = "repo.tool_request"
|
||||
summary = "summary"
|
||||
private_state_exposed = false
|
||||
[request]
|
||||
target_directory = "gamecult-local/daemon-tool-directory"
|
||||
target_capability = "daemon-tool-capability:selected-by-review"
|
||||
operation = "submitTypedToolIntent"
|
||||
[cultmesh]
|
||||
intent_contract = "epiphany.cultmesh.daemon_tool_invocation_intent.v0"
|
||||
receipt_contract = "epiphany.cultmesh.daemon_tool_invocation_receipt.v0"
|
||||
host_daemon_owns_execution = true
|
||||
requester_owns_request = false
|
||||
requires_host_liveness_ready = true
|
||||
requires_cultmesh_receipts = true
|
||||
[odin]
|
||||
discoverable = true
|
||||
preserves_provider_ownership = true
|
||||
private_verse_passthrough = false
|
||||
[authority]
|
||||
# direct_tool_execution = false
|
||||
direct_tool_execution = true
|
||||
arbitrary_shell_authority = false
|
||||
hands_action_authority = false
|
||||
state_commit_authority = false
|
||||
publication_authority = false
|
||||
service_lifecycle_authority = false
|
||||
cross_body_mutation_authority = false
|
||||
private_verse_rummaging = false
|
||||
"#;
|
||||
let request = parse_repo_tool_request(text).expect("fixture is typed TOML");
|
||||
assert!(request.authority.direct_tool_execution);
|
||||
assert!(!request.has_authority_seals());
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub(super) struct RepoDeploymentConfig {
|
||||
pub(super) schema_version: String,
|
||||
|
|
|
|||
Reference in a new issue