instinct-cli 0.3.9

Shared local memory for coding agents. Save a fix once and find it again in a new session or another connected tool.
1
2
3
4
5
6
7
8
9
10
11
# Synthetic export policy controls; no delivery or account access.
TAA # use std::{io::Write,process::{Command,Stdio}};
TAA # fn call(input:&str)->(bool,String){let mut c=Command::new(env!("CARGO_BIN_EXE_instinct")).args(["check","export-boundary","--input","-"]).stdin(Stdio::piped()).stdout(Stdio::piped()).spawn().unwrap();c.stdin.take().unwrap().write_all(input.as_bytes()).ok();let out=c.wait_with_output().unwrap();(out.status.success(),String::from_utf8(out.stdout).unwrap())}
TAA # const INPUT:&str=r#"{"schema":"instinct.export-boundary/v1","policy":{"allowed_recipients":["team-a"],"allowed_fields":["total"],"allowed_destinations":["internal"],"allowed_labels":["aggregate"]},"export":{"recipients":["team-a"],"fields":["total"],"destination":"internal","labels":["aggregate"]},"conditions":{"complete_inventory":true,"explicit_policy_authority":true}}"#;
TAA # #[test]fn matching_export_passes_without_authorizing_or_sending(){let(ok,out)=call(INPUT);assert!(ok,"{out}");for s in["\"verdict\":\"pass\"","\"sent\":false","\"authorization\":\"not_evaluated\"","caller_reported_inventory_and_policy"]{assert!(out.contains(s),"{out}");}}
TAA # #[test]fn every_export_dimension_can_fail_without_leaking_witness(){for(from,to)in[("\"recipients\":[\"team-a\"]","\"recipients\":[\"PRIVATE_SENTINEL\"]"),("\"fields\":[\"total\"]","\"fields\":[\"PRIVATE_SENTINEL\"]"),("\"destination\":\"internal\"","\"destination\":\"PRIVATE_SENTINEL\""),("\"labels\":[\"aggregate\"]","\"labels\":[\"PRIVATE_SENTINEL\"]")]{let(ok,out)=call(&INPUT.replace(from,to));assert!(ok&&out.contains("\"verdict\":\"fail\""),"{out}");assert!(!out.contains("PRIVATE_SENTINEL"));}}
TAA # #[test]fn missing_or_false_authority_and_inventory_abstain(){for key in["complete_inventory","explicit_policy_authority"]{let bad=INPUT.replace(&format!("\"{key}\":true"),&format!("\"{key}\":false"));let(ok,out)=call(&bad);assert!(ok&&out.contains("\"verdict\":\"abstain\""),"{out}");}let input=INPUT.replace(",\"conditions\":{\"complete_inventory\":true,\"explicit_policy_authority\":true}","");let(ok,out)=call(&input);assert!(ok&&out.contains("abstain"),"{out}");}
TAA # #[test]fn missing_policy_fields_abstain_not_wildcard(){let input=INPUT.replace("\"allowed_recipients\":[\"team-a\"],","");let(ok,out)=call(&input);assert!(ok&&out.contains("abstain"),"{out}");}
TAA # #[test]fn invalid_duplicate_and_executable_fields_reject(){for input in[INPUT.replacen("{","{\"command\":\"PRIVATE_SENTINEL\",",1),INPUT.replace("\"recipients\":[\"team-a\"]","\"recipients\":[\"team-a\",\"team-a\"]"),INPUT.replace("\"complete_inventory\":true","\"complete_inventory\":\"PRIVATE_SENTINEL\"")]{let(ok,out)=call(&input);assert!(!ok,"{out}");assert!(!out.contains("PRIVATE_SENTINEL"));}}
TAA # #[test]fn all_boolean_policy_combinations_match_independent_oracle(){for mask in 0..64{let mut input=INPUT.to_owned();for(bit,from,to)in[(1,"\"recipients\":[\"team-a\"]","\"recipients\":[\"other\"]"),(2,"\"fields\":[\"total\"]","\"fields\":[\"secret\"]"),(4,"\"destination\":\"internal\"","\"destination\":\"public\""),(8,"\"labels\":[\"aggregate\"]","\"labels\":[\"private\"]"),(16,"\"complete_inventory\":true","\"complete_inventory\":false"),(32,"\"explicit_policy_authority\":true","\"explicit_policy_authority\":false")]{if mask&bit!=0{input=input.replace(from,to);}}let expected=if mask&48!=0{"abstain"}else if mask&15!=0{"fail"}else{"pass"};let(ok,out)=call(&input);assert!(ok,"{out}");assert!(out.contains(&format!("\"verdict\":\"{expected}\"")),"mask {mask}: {out}");}}
TAA # #[test]fn exact_scope_is_required(){let input=INPUT.replace("\"policy\":{","\"policy\":{\"scope\":{\"project\":\"lab\"},");let(ok,out)=call(&input);assert!(ok&&out.contains("abstain"),"{out}");let input=input.replacen("{","{\"scope\":{\"project\":\"other\"},",1);let(ok,out)=call(&input);assert!(ok&&out.contains("abstain"),"{out}");}