MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / validate_vault_entity

Method validate_vault_entity

libatomic/src/daemon/services_agent.rs:2394–2503  ·  view source on GitHub ↗
(
        &self,
        request: Request<ValidateVaultEntityRequest>,
    )

Source from the content-addressed store, hash-verified

2392 }
2393
2394 async fn validate_vault_entity(
2395 &self,
2396 request: Request<ValidateVaultEntityRequest>,
2397 ) -> Result<Response<ValidateVaultEntityResponse>, Status> {
2398 let request = request.into_inner();
2399 let kind = Kind::try_from(request.kind)
2400 .map_err(|_| domain_status(ErrorCode::InvalidArgument, "unknown vault entity kind"))?;
2401 let handle = self.state.resolve(request.repository.as_ref().unwrap())?;
2402 self.state.log_rpc("ValidateVaultEntity", Some(&handle));
2403 let gate_handle = handle.clone();
2404 let _gate = gate_handle.exclusive().await;
2405 let subject = request.subject.ok_or_else(|| {
2406 domain_status(ErrorCode::InvalidArgument, "validate subject is required")
2407 })?;
2408 let response = tokio::task::spawn_blocking(move || {
2409 // A query: read-only open with the read-concurrency wait.
2410 let repo = handle.repository_readonly()?;
2411 let id = match subject {
2412 validate_vault_entity_request::Subject::Id(id) => id,
2413 validate_vault_entity_request::Subject::Document(_) => {
2414 return Err(domain_status(
2415 ErrorCode::InvalidArgument,
2416 "document-bytes validation lands with its slice",
2417 ))
2418 }
2419 };
2420 let issues = match kind {
2421 Kind::Intent => {
2422 let entry = repo.vault_intent_show(&id).map_err(repository_error)?;
2423 let frontmatter = parse_frontmatter(&entry)?;
2424 // Consult the stored attestation exactly like the CLI
2425 // bridge: a fresh attested node validates as itself; a
2426 // raw (unattested or stale) node validates as-is.
2427 let raw_node =
2428 lift_intent(&frontmatter, &body_of(&entry)).map_err(|error| {
2429 domain_status(
2430 ErrorCode::InvalidArgument,
2431 format!("could not lift intent: {error}"),
2432 )
2433 })?;
2434 let node = fresh_attested_intent(&repo, &id, &frontmatter, &body_of(&entry))
2435 .unwrap_or(raw_node);
2436 let report = validate_intent(&node);
2437 report
2438 .results
2439 .iter()
2440 .map(|violation| {
2441 format!(
2442 "[{}] {}{}: {}",
2443 violation.shape,
2444 violation.focus_node,
2445 violation
2446 .path
2447 .as_ref()
2448 .map(|p| format!(" ({p})"))
2449 .unwrap_or_default(),
2450 violation.message
2451 )

Callers

nothing calls this directly

Calls 15

domain_statusFunction · 0.85
parse_frontmatterFunction · 0.85
lift_intentFunction · 0.85
body_ofFunction · 0.85
fresh_attested_intentFunction · 0.85
validate_intentFunction · 0.85
lift_memoryFunction · 0.85
fresh_attested_memoryFunction · 0.85
validate_memoryFunction · 0.85
as_refMethod · 0.80
log_rpcMethod · 0.80
exclusiveMethod · 0.80

Tested by

no test coverage detected