MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / put_policy_revision

Method put_policy_revision

crates/openshell-server/src/persistence/sqlite.rs:452–493  ·  view source on GitHub ↗
(
        &self,
        id: &str,
        sandbox_id: &str,
        version: i64,
        payload: &[u8],
        hash: &str,
    )

Source from the content-addressed store, hash-verified

450 Ok(filtered)
451 }
452 pub async fn put_policy_revision(
453 &self,
454 id: &str,
455 sandbox_id: &str,
456 version: i64,
457 payload: &[u8],
458 hash: &str,
459 ) -> PersistenceResult<()> {
460 let now_ms = current_time_ms();
461 let record = PolicyRecord {
462 id: id.to_string(),
463 sandbox_id: sandbox_id.to_string(),
464 version,
465 policy_payload: payload.to_vec(),
466 policy_hash: hash.to_string(),
467 status: "pending".to_string(),
468 load_error: None,
469 created_at_ms: now_ms,
470 loaded_at_ms: None,
471 };
472 let wrapped_payload = policy_payload_from_record(&record)?;
473
474 sqlx::query(
475 r#"
476INSERT INTO "objects" (
477 "object_type", "id", "scope", "version", "status", "payload", "created_at_ms", "updated_at_ms"
478)
479VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?7)
480"#,
481 )
482 .bind(POLICY_OBJECT_TYPE)
483 .bind(id)
484 .bind(sandbox_id)
485 .bind(version)
486 .bind("pending")
487 .bind(wrapped_payload)
488 .bind(now_ms)
489 .execute(&self.pool)
490 .await
491 .map_err(|e| map_db_error(&e))?;
492 Ok(())
493 }
494
495 pub async fn get_latest_policy(
496 &self,

Calls 3

map_db_errorFunction · 0.85
current_time_msFunction · 0.70