1#![allow(dead_code)]
14
15use crate::value::Value;
16use std::collections::BTreeMap;
17#[path = "capability_schema/geo_geodesy_entries.rs"]
18pub mod geo_geodesy_entries;
19#[path = "capability_schema/geo_terrain_node_entries.rs"]
20pub mod geo_terrain_node_entries;
21#[path = "capability_schema/geo_geomorph_strata_entries.rs"]
22pub mod geo_geomorph_strata_entries;
23#[path = "capability_schema/geo_gis_io_entries.rs"]
24pub mod geo_gis_io_entries;
25#[path = "capability_schema/geo_sparql_deontic_entries.rs"]
26pub mod geo_sparql_deontic_entries;
27#[path = "capability_schema/geo_vector_gp_entries.rs"]
28pub mod geo_vector_gp_entries;
29#[path = "capability_schema/geo_spatial_stats_algebra_entries.rs"]
30pub mod geo_spatial_stats_algebra_entries;
31#[path = "capability_schema/geo_wgsl_forge_entries.rs"]
32pub mod geo_wgsl_forge_entries;
33#[path = "capability_schema/geo_cartography_poet_entries.rs"]
34pub mod geo_cartography_poet_entries;
35#[path = "capability_schema/geo_viewport_entries.rs"]
36pub mod geo_viewport_entries;
37#[path = "capability_schema/etalon_vibe_entries.rs"]
38pub mod etalon_vibe_entries;
39#[path = "capability_schema/runtime_entries.rs"]
40mod runtime_entries;
41
42#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
44pub enum EffectClass {
45 Pure,
47 Read,
49 Write,
51 External,
53}
54
55impl EffectClass {
56 pub fn as_str(&self) -> &'static str {
58 match self {
59 Self::Pure => "pure",
60 Self::Read => "read",
61 Self::Write => "write",
62 Self::External => "external",
63 }
64 }
65}
66
67#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
69pub enum HonestyLabel {
70 Always,
72 CapabilityLease,
74 FailClosed,
76 Deprecated,
78}
79
80impl HonestyLabel {
81 pub fn as_str(&self) -> &'static str {
83 match self {
84 Self::Always => "always",
85 Self::CapabilityLease => "capability_lease",
86 Self::FailClosed => "fail_closed",
87 Self::Deprecated => "deprecated",
88 }
89 }
90}
91
92#[derive(Debug, Clone, PartialEq)]
94pub struct SchemaArg {
95 pub name: String,
97 pub ty: String,
99 pub required: bool,
101 pub description: String,
103}
104
105impl SchemaArg {
106 pub fn new(name: &str, ty: &str, required: bool) -> Self {
108 Self {
109 name: name.into(),
110 ty: ty.into(),
111 required,
112 description: String::new(),
113 }
114 }
115
116 pub fn with_description(mut self, desc: &str) -> Self {
118 self.description = desc.into();
119 self
120 }
121
122 pub fn to_value(&self) -> Value {
124 let mut rec = BTreeMap::new();
125 rec.insert("name".into(), Value::String(self.name.clone()));
126 rec.insert("type".into(), Value::String(self.ty.clone()));
127 rec.insert("required".into(), Value::Bool(self.required));
128 if !self.description.is_empty() {
129 rec.insert(
130 "description".into(),
131 Value::String(self.description.clone()),
132 );
133 }
134 Value::Record(rec)
135 }
136}
137
138#[derive(Debug, Clone, PartialEq)]
140pub struct SchemaEntry {
141 pub id: String,
143 pub effect: EffectClass,
145 pub honesty: HonestyLabel,
147 pub args: Vec<SchemaArg>,
149 pub returns: String,
151 pub description: String,
153}
154
155impl SchemaEntry {
156 pub fn new(id: &str, effect: EffectClass, honesty: HonestyLabel, returns: &str) -> Self {
158 Self {
159 id: id.into(),
160 effect,
161 honesty,
162 args: Vec::new(),
163 returns: returns.into(),
164 description: String::new(),
165 }
166 }
167
168 pub fn with_arg(mut self, arg: SchemaArg) -> Self {
170 self.args.push(arg);
171 self
172 }
173
174 pub fn with_description(mut self, desc: &str) -> Self {
176 self.description = desc.into();
177 self
178 }
179
180 pub fn to_value(&self) -> Value {
182 let mut rec = BTreeMap::new();
183 rec.insert("id".into(), Value::String(self.id.clone()));
184 rec.insert("effect".into(), Value::String(self.effect.as_str().into()));
185 rec.insert(
186 "honesty".into(),
187 Value::String(self.honesty.as_str().into()),
188 );
189 rec.insert(
190 "args".into(),
191 Value::List(self.args.iter().map(|a| a.to_value()).collect()),
192 );
193 rec.insert("returns".into(), Value::String(self.returns.clone()));
194 if !self.description.is_empty() {
195 rec.insert(
196 "description".into(),
197 Value::String(self.description.clone()),
198 );
199 }
200 Value::Record(rec)
201 }
202}
203
204pub fn all_schemas() -> Vec<SchemaEntry> {
210 let mut schemas = vec![
211 SchemaEntry::new(
213 "graph.query",
214 EffectClass::Read,
215 HonestyLabel::CapabilityLease,
216 "Value",
217 )
218 .with_arg(SchemaArg::new("query", "string", true))
219 .with_description("Query the graph with a SPARQL-like pattern"),
220 SchemaEntry::new(
221 "graph.stage",
222 EffectClass::Write,
223 HonestyLabel::CapabilityLease,
224 "Value",
225 )
226 .with_arg(SchemaArg::new("term", "Value", true))
227 .with_description("Stage a term for later commit"),
228 SchemaEntry::new(
229 "graph.commit",
230 EffectClass::Write,
231 HonestyLabel::CapabilityLease,
232 "Value",
233 )
234 .with_description("Commit staged terms to the graph"),
235 SchemaEntry::new(
236 "graph.snapshot",
237 EffectClass::Read,
238 HonestyLabel::CapabilityLease,
239 "Value",
240 )
241 .with_description("Take a snapshot of the current graph state"),
242 SchemaEntry::new(
244 "pulse.publish",
245 EffectClass::External,
246 HonestyLabel::CapabilityLease,
247 "Value",
248 )
249 .with_arg(SchemaArg::new("topic", "string", true))
250 .with_arg(SchemaArg::new("payload", "Value", false))
251 .with_description("Publish a payload to a pulse topic"),
252 SchemaEntry::new(
254 "time.now",
255 EffectClass::Read,
256 HonestyLabel::FailClosed,
257 "Instant",
258 )
259 .with_description(
260 "Primary time primitive — returns Instant with nanosecond resolution (X6)",
261 ),
262 SchemaEntry::new(
263 "time.unix",
264 EffectClass::Read,
265 HonestyLabel::Deprecated,
266 "i64",
267 )
268 .with_description("DEPRECATED (X6) — use time.now + instant.to_unix_secs"),
269 SchemaEntry::new(
270 "time.unix_nanos",
271 EffectClass::Read,
272 HonestyLabel::Deprecated,
273 "Record",
274 )
275 .with_description("DEPRECATED (X6) — use time.now"),
276 SchemaEntry::new(
277 "time.monotonic_nanos",
278 EffectClass::Read,
279 HonestyLabel::FailClosed,
280 "u64",
281 )
282 .with_description("Monotonic nanos for frame timing and physics dt"),
283 SchemaEntry::new(
284 "time.proper_time",
285 EffectClass::Read,
286 HonestyLabel::FailClosed,
287 "Value",
288 )
289 .with_arg(SchemaArg::new("worldline_id", "u64", true))
290 .with_description("Proper time along a worldline"),
291 SchemaEntry::new(
293 "instant.to_unix_secs",
294 EffectClass::Pure,
295 HonestyLabel::Always,
296 "i64",
297 )
298 .with_arg(SchemaArg::new("instant", "Instant", true))
299 .with_description("Project an Instant to Unix seconds (X6)"),
300 SchemaEntry::new(
301 "instant.to_unix_nanos",
302 EffectClass::Pure,
303 HonestyLabel::Always,
304 "u64",
305 )
306 .with_arg(SchemaArg::new("instant", "Instant", true))
307 .with_description("Project an Instant to Unix nanoseconds (X6)"),
308 SchemaEntry::new(
310 "host.version",
311 EffectClass::Pure,
312 HonestyLabel::Always,
313 "string",
314 )
315 .with_description("Get the host version string"),
316 SchemaEntry::new(
318 "capability.resolve",
319 EffectClass::Read,
320 HonestyLabel::CapabilityLease,
321 "Value",
322 )
323 .with_arg(SchemaArg::new("id", "string", true))
324 .with_description("Resolve a capability id to its metadata"),
325 SchemaEntry::new(
326 "capability.invoke",
327 EffectClass::External,
328 HonestyLabel::CapabilityLease,
329 "Value",
330 )
331 .with_arg(SchemaArg::new("id", "string", true))
332 .with_arg(SchemaArg::new("payload", "Value", false))
333 .with_description("Invoke a capability by id"),
334 SchemaEntry::new(
336 "conservation.check",
337 EffectClass::Pure,
338 HonestyLabel::FailClosed,
339 "ConservationResult",
340 )
341 .with_arg(SchemaArg::new("quantity", "string", true))
342 .with_arg(SchemaArg::new("before", "f64", true))
343 .with_arg(SchemaArg::new("after", "f64", true))
344 .with_arg(SchemaArg::new("tolerance", "f64", false))
345 .with_description("Check if a transformation preserves a conserved quantity (T34)"),
346 SchemaEntry::new(
348 "causal.relation",
349 EffectClass::Pure,
350 HonestyLabel::FailClosed,
351 "CausalRelation",
352 )
353 .with_arg(SchemaArg::new("event_a", "Value", true))
354 .with_arg(SchemaArg::new("event_b", "Value", true))
355 .with_description("Determine the causal relation between two events (T35)"),
356 SchemaEntry::new(
358 "dag.execute",
359 EffectClass::External,
360 HonestyLabel::CapabilityLease,
361 "Value",
362 )
363 .with_arg(SchemaArg::new("pipeline", "Value", true))
364 .with_description("Execute a DAG pipeline in topological order (T24)"),
365 SchemaEntry::new(
366 "dag.validate",
367 EffectClass::Pure,
368 HonestyLabel::CapabilityLease,
369 "Value",
370 )
371 .with_arg(SchemaArg::new("pipeline", "Value", true))
372 .with_description("Validate a DAG pipeline without executing (T24)"),
373 SchemaEntry::new(
375 "deontic.check",
376 EffectClass::Pure,
377 HonestyLabel::FailClosed,
378 "Value",
379 )
380 .with_arg(SchemaArg::new("capability", "string", true))
381 .with_arg(SchemaArg::new("phase", "string", true))
382 .with_description("Check if a capability is permitted in a deontic phase (T25)"),
383 SchemaEntry::new(
385 "hid.poll",
386 EffectClass::External,
387 HonestyLabel::FailClosed,
388 "Value",
389 )
390 .with_description("Poll for HID events (T42)"),
391 SchemaEntry::new(
392 "hid.wait",
393 EffectClass::External,
394 HonestyLabel::FailClosed,
395 "Value",
396 )
397 .with_arg(SchemaArg::new("timeout_ms", "u64", false))
398 .with_description("Wait for HID events with optional timeout (T42)"),
399 SchemaEntry::new(
401 "cue.post",
402 EffectClass::External,
403 HonestyLabel::FailClosed,
404 "Value",
405 )
406 .with_arg(SchemaArg::new("cue_id", "string", true))
407 .with_arg(SchemaArg::new("payload", "Value", false))
408 .with_description("Post an outbound cue (haptic/audio/visual/accessibility) (T45)"),
409 SchemaEntry::new(
411 "crypto.sha256",
412 EffectClass::Pure,
413 HonestyLabel::FailClosed,
414 "HashResult",
415 )
416 .with_arg(SchemaArg::new("data", "bytes", true))
417 .with_description("SHA-256 hash"),
418 SchemaEntry::new(
419 "crypto.sha512",
420 EffectClass::Pure,
421 HonestyLabel::FailClosed,
422 "HashResult",
423 )
424 .with_arg(SchemaArg::new("data", "bytes", true))
425 .with_description("SHA-512 hash"),
426 SchemaEntry::new(
427 "crypto.blake3",
428 EffectClass::Pure,
429 HonestyLabel::FailClosed,
430 "HashResult",
431 )
432 .with_arg(SchemaArg::new("data", "bytes", true))
433 .with_description("BLAKE3 hash"),
434 SchemaEntry::new(
435 "crypto.hkdf_sha256",
436 EffectClass::Pure,
437 HonestyLabel::FailClosed,
438 "bytes",
439 )
440 .with_arg(SchemaArg::new("ikm", "bytes", true))
441 .with_arg(SchemaArg::new("info", "bytes", false))
442 .with_arg(SchemaArg::new("len", "u64", true))
443 .with_description("HKDF-SHA256 key derivation"),
444 SchemaEntry::new(
445 "crypto.aead_encrypt",
446 EffectClass::Pure,
447 HonestyLabel::FailClosed,
448 "EncryptedData",
449 )
450 .with_arg(SchemaArg::new("algorithm", "string", true))
451 .with_arg(SchemaArg::new("key", "bytes", true))
452 .with_arg(SchemaArg::new("nonce", "bytes", true))
453 .with_arg(SchemaArg::new("plaintext", "bytes", true))
454 .with_arg(SchemaArg::new("aad", "bytes", false))
455 .with_description("AEAD encrypt (AES-256-GCM, ChaCha20-Poly1305, XChaCha20-Poly1305)"),
456 SchemaEntry::new(
457 "crypto.aead_decrypt",
458 EffectClass::Pure,
459 HonestyLabel::FailClosed,
460 "bytes",
461 )
462 .with_arg(SchemaArg::new("algorithm", "string", true))
463 .with_arg(SchemaArg::new("key", "bytes", true))
464 .with_arg(SchemaArg::new("nonce", "bytes", true))
465 .with_arg(SchemaArg::new("ciphertext", "bytes", true))
466 .with_arg(SchemaArg::new("tag", "bytes", true))
467 .with_arg(SchemaArg::new("aad", "bytes", false))
468 .with_description("AEAD decrypt"),
469 SchemaEntry::new(
470 "crypto.sign",
471 EffectClass::Pure,
472 HonestyLabel::FailClosed,
473 "Signature",
474 )
475 .with_arg(SchemaArg::new("key_id", "string", true))
476 .with_arg(SchemaArg::new("data", "bytes", true))
477 .with_description("Sign data (fail-closed: key vault not wired)"),
478 SchemaEntry::new(
479 "crypto.verify",
480 EffectClass::Pure,
481 HonestyLabel::FailClosed,
482 "bool",
483 )
484 .with_arg(SchemaArg::new("key_id", "string", true))
485 .with_arg(SchemaArg::new("data", "bytes", true))
486 .with_arg(SchemaArg::new("signature", "bytes", true))
487 .with_description("Verify a signature (fail-closed: key vault not wired)"),
488 SchemaEntry::new(
489 "crypto.generate_key",
490 EffectClass::Pure,
491 HonestyLabel::FailClosed,
492 "CryptoKey",
493 )
494 .with_arg(SchemaArg::new("algorithm", "string", true))
495 .with_description("Generate a cryptographic key (fail-closed: key vault not wired)"),
496 SchemaEntry::new(
498 "zk.prove_threshold",
499 EffectClass::Pure,
500 HonestyLabel::FailClosed,
501 "ZkProof",
502 )
503 .with_arg(SchemaArg::new("value", "f64", true))
504 .with_arg(SchemaArg::new("threshold", "f64", true))
505 .with_description("Prove value >= threshold (Groth16/BLS12-381)"),
506 SchemaEntry::new(
507 "zk.verify_threshold",
508 EffectClass::Pure,
509 HonestyLabel::FailClosed,
510 "ZkVerification",
511 )
512 .with_arg(SchemaArg::new("proof_hex", "string", true))
513 .with_arg(SchemaArg::new("vk_hex", "string", true))
514 .with_arg(SchemaArg::new("threshold", "f64", true))
515 .with_description("Verify a threshold proof"),
516 SchemaEntry::new(
517 "zk.prove_range",
518 EffectClass::Pure,
519 HonestyLabel::FailClosed,
520 "ZkProof",
521 )
522 .with_arg(SchemaArg::new("value", "f64", true))
523 .with_arg(SchemaArg::new("lo", "f64", true))
524 .with_arg(SchemaArg::new("hi", "f64", true))
525 .with_description("Prove lo <= value <= hi"),
526 SchemaEntry::new(
527 "zk.verify_range",
528 EffectClass::Pure,
529 HonestyLabel::FailClosed,
530 "ZkVerification",
531 )
532 .with_arg(SchemaArg::new("proof_hex", "string", true))
533 .with_arg(SchemaArg::new("vk_hex", "string", true))
534 .with_arg(SchemaArg::new("lo", "f64", true))
535 .with_arg(SchemaArg::new("hi", "f64", true))
536 .with_description("Verify a range proof"),
537 SchemaEntry::new(
538 "zk.prove_matmul",
539 EffectClass::Pure,
540 HonestyLabel::FailClosed,
541 "ZkMatmulResult",
542 )
543 .with_arg(SchemaArg::new("m", "u64", true))
544 .with_arg(SchemaArg::new("k", "u64", true))
545 .with_arg(SchemaArg::new("n", "u64", true))
546 .with_arg(SchemaArg::new("a", "List<f64>", true))
547 .with_arg(SchemaArg::new("b", "List<f64>", true))
548 .with_description("Prove matrix multiplication result"),
549 SchemaEntry::new(
550 "zk.list_circuits",
551 EffectClass::Pure,
552 HonestyLabel::Always,
553 "List<string>",
554 )
555 .with_description("List available ZK circuits"),
556 SchemaEntry::new(
557 "Conditioning.validate",
558 EffectClass::Pure,
559 HonestyLabel::Always,
560 "Record",
561 )
562 .with_arg(
563 SchemaArg::new("profile", "Record", true)
564 .with_description("Conditioning profile or spec record"),
565 )
566 .with_description("Validate one profile and return structured violations"),
567 SchemaEntry::new(
568 "Conditioning.compile",
569 EffectClass::Read,
570 HonestyLabel::Always,
571 "Record",
572 )
573 .with_arg(
574 SchemaArg::new("spec", "Record", true).with_description("Conditioning specification"),
575 )
576 .with_arg(
577 SchemaArg::new("capabilities", "Record", false)
578 .with_description("Target backend capabilities"),
579 )
580 .with_arg(
581 SchemaArg::new("authority", "Record", false)
582 .with_description("Authority view and graph scopes"),
583 )
584 .with_description("Compile conditioning contract against capabilities and authority"),
585 SchemaEntry::new(
586 "Conditioning.inspect",
587 EffectClass::Read,
588 HonestyLabel::Always,
589 "Record",
590 )
591 .with_arg(
592 SchemaArg::new("spec", "Record", true)
593 .with_description("Conditioning spec or plan summary"),
594 )
595 .with_description("Return a redacted requirement, token, and evidence trace"),
596 SchemaEntry::new(
597 "Conditioning.evaluate",
598 EffectClass::External,
599 HonestyLabel::CapabilityLease,
600 "Record",
601 )
602 .with_arg(
603 SchemaArg::new("split", "string", true)
604 .with_description("Evaluation split: search, dev, test"),
605 )
606 .with_description("Start a bounded evaluation campaign"),
607 SchemaEntry::new(
608 "Conditioning.activate",
609 EffectClass::Write,
610 HonestyLabel::CapabilityLease,
611 "Record",
612 )
613 .with_arg(
614 SchemaArg::new("profile_id", "string", true)
615 .with_description("Profile URN to activate"),
616 )
617 .with_arg(
618 SchemaArg::new("version", "u64", true).with_description("Version number to activate"),
619 )
620 .with_description("Move active registry pointer after approval gates"),
621 SchemaEntry::new(
622 "Conditioning.rollback",
623 EffectClass::Write,
624 HonestyLabel::CapabilityLease,
625 "Record",
626 )
627 .with_arg(
628 SchemaArg::new("profile_id", "string", true)
629 .with_description("Profile URN to rollback"),
630 )
631 .with_arg(
632 SchemaArg::new("target_version", "u64", false)
633 .with_description("Target version or previous active if omitted"),
634 )
635 .with_description("Restore a prior approved version"),
636 ];
637 schemas.extend(runtime_entries::entries());
638 schemas.extend(geo_geodesy_entries::entries());
639 schemas.extend(geo_terrain_node_entries::entries());
640 schemas.extend(geo_geomorph_strata_entries::entries());
641 schemas.extend(geo_gis_io_entries::entries());
642 schemas.extend(geo_sparql_deontic_entries::entries());
643 schemas.extend(geo_vector_gp_entries::entries());
644 schemas.extend(geo_spatial_stats_algebra_entries::entries());
645 schemas.extend(geo_wgsl_forge_entries::entries());
646 schemas.extend(geo_cartography_poet_entries::entries());
647 schemas.extend(geo_viewport_entries::entries());
648 schemas.extend(etalon_vibe_entries::entries());
649 schemas
650}
651
652pub fn schema_for(id: &str) -> Option<SchemaEntry> {
654 all_schemas().into_iter().find(|e| e.id == id)
655}
656
657pub fn all_ids() -> Vec<String> {
659 all_schemas().into_iter().map(|e| e.id).collect()
660}
661
662pub fn schema_to_value() -> Value {
664 Value::List(all_schemas().iter().map(|e| e.to_value()).collect())
665}
666
667#[cfg(test)]
668mod tests {
669 use super::*;
670
671 #[test]
672 fn t51_schema_has_entries() {
673 let schemas = all_schemas();
674 assert!(
675 schemas.len() > 30,
676 "expected 30+ schema entries, got {}",
677 schemas.len()
678 );
679 }
680
681 #[test]
682 fn t51_schema_ids_are_unique() {
683 let schemas = all_schemas();
684 let ids: Vec<&str> = schemas.iter().map(|e| e.id.as_str()).collect();
685 let mut sorted = ids.clone();
686 sorted.sort();
687 sorted.dedup();
688 assert_eq!(ids.len(), sorted.len(), "duplicate schema ids found");
689 }
690
691 #[test]
692 fn t51_schema_for_known_id() {
693 let entry = schema_for("time.now").unwrap();
694 assert_eq!(entry.id, "time.now");
695 assert_eq!(entry.effect, EffectClass::Read);
696 assert_eq!(entry.returns, "Instant");
697 }
698
699 #[test]
700 fn t51_schema_for_unknown_returns_none() {
701 assert!(schema_for("nonexistent.call").is_none());
702 }
703
704 #[test]
705 fn t51_all_ids_contains_core_calls() {
706 let ids = all_ids();
707 assert!(ids.contains(&"time.now".to_string()));
708 assert!(ids.contains(&"crypto.sha256".to_string()));
709 assert!(ids.contains(&"zk.prove_threshold".to_string()));
710 assert!(ids.contains(&"graph.query".to_string()));
711 assert!(ids.contains(&"pulse.publish".to_string()));
712 }
713
714 #[test]
715 fn t51_deprecated_labels_on_time_unix() {
716 let entry = schema_for("time.unix").unwrap();
717 assert_eq!(entry.honesty, HonestyLabel::Deprecated);
718 }
719
720 #[test]
721 fn t51_always_labels_on_pure_calls() {
722 let entry = schema_for("host.version").unwrap();
723 assert_eq!(entry.honesty, HonestyLabel::Always);
724 assert_eq!(entry.effect, EffectClass::Pure);
725 }
726
727 #[test]
728 fn t51_schema_entry_to_value() {
729 let entry = schema_for("crypto.sha256").unwrap();
730 let v = entry.to_value();
731 match v {
732 Value::Record(r) => {
733 assert!(r.contains_key("id"));
734 assert!(r.contains_key("effect"));
735 assert!(r.contains_key("honesty"));
736 assert!(r.contains_key("args"));
737 assert!(r.contains_key("returns"));
738 }
739 _ => panic!("expected Record"),
740 }
741 }
742
743 #[test]
744 fn t51_schema_to_value_is_list() {
745 let v = schema_to_value();
746 match v {
747 Value::List(xs) => assert!(xs.len() > 30),
748 _ => panic!("expected List"),
749 }
750 }
751
752 #[test]
753 fn t51_effect_class_as_str() {
754 assert_eq!(EffectClass::Pure.as_str(), "pure");
755 assert_eq!(EffectClass::Read.as_str(), "read");
756 assert_eq!(EffectClass::Write.as_str(), "write");
757 assert_eq!(EffectClass::External.as_str(), "external");
758 }
759
760 #[test]
761 fn t51_honesty_label_as_str() {
762 assert_eq!(HonestyLabel::Always.as_str(), "always");
763 assert_eq!(HonestyLabel::CapabilityLease.as_str(), "capability_lease");
764 assert_eq!(HonestyLabel::FailClosed.as_str(), "fail_closed");
765 assert_eq!(HonestyLabel::Deprecated.as_str(), "deprecated");
766 }
767
768 #[test]
769 fn t51_schema_arg_to_value() {
770 let arg = SchemaArg::new("data", "bytes", true).with_description("the data to hash");
771 let v = arg.to_value();
772 match v {
773 Value::Record(r) => {
774 assert_eq!(r.get("name"), Some(&Value::String("data".into())));
775 assert_eq!(r.get("type"), Some(&Value::String("bytes".into())));
776 assert_eq!(r.get("required"), Some(&Value::Bool(true)));
777 assert!(r.contains_key("description"));
778 }
779 _ => panic!("expected Record"),
780 }
781 }
782
783 #[test]
784 fn t51_crypto_entries_have_correct_args() {
785 let entry = schema_for("crypto.aead_encrypt").unwrap();
786 assert_eq!(entry.args.len(), 5);
787 assert_eq!(entry.args[0].name, "algorithm");
788 assert_eq!(entry.args[0].required, true);
789 }
790
791 #[test]
792 fn t51_zk_entries_have_correct_args() {
793 let entry = schema_for("zk.prove_matmul").unwrap();
794 assert_eq!(entry.args.len(), 5);
795 assert_eq!(entry.args[3].name, "a");
796 assert_eq!(entry.args[3].ty, "List<f64>");
797 }
798}