instinct-cli 0.3.10

Shared local memory for coding agents. Save a fix once and find it again in a new session or another connected tool.
// generated by hxc 1.0.0-acgt-compiler from tests/check_platform.hlx -- do not edit by hand

#[cfg(windows)]
#[allow(dead_code)]
const SYS_CURL: &str = "C:\\Windows\\System32\\curl.exe";
#[cfg(not(windows))]
#[allow(dead_code)]
const SYS_CURL: &str = "curl";
#[allow(dead_code)]
fn _helix_allowed(var: &str, what: &str) -> bool {
    let ok = std::env::var(var).map(|v| v == "1").unwrap_or(false);
    if !ok {
        eprintln!("helix: BLOCKED {} -- permission denied (set {}=1 to allow; `hxc run` allows by default, a `hxc build`/`export-rust` binary does not)", what, var);
    }
    ok
}
#[cfg(windows)]
#[allow(dead_code)]
fn _nw_exec(mut c: std::process::Command) -> std::process::Command {
    if !_helix_allowed("HELIX_ALLOW_RUN", "process execution") {
        std::process::exit(13);
    }
    use std::os::windows::process::CommandExt;
    c.creation_flags(0x08000000);
    c
}
#[cfg(not(windows))]
#[allow(dead_code)]
fn _nw_exec(c: std::process::Command) -> std::process::Command {
    if !_helix_allowed("HELIX_ALLOW_RUN", "process execution") {
        std::process::exit(13);
    }
    c
}
#[cfg(windows)]
#[allow(dead_code)]
fn _nw_net(mut c: std::process::Command) -> std::process::Command {
    if !_helix_allowed("HELIX_ALLOW_NET", "network access") {
        std::process::exit(13);
    }
    use std::os::windows::process::CommandExt;
    c.creation_flags(0x08000000);
    c
}
#[cfg(not(windows))]
#[allow(dead_code)]
fn _nw_net(c: std::process::Command) -> std::process::Command {
    if !_helix_allowed("HELIX_ALLOW_NET", "network access") {
        std::process::exit(13);
    }
    c
}

// hlx:2
#[cfg(windows)]
// hlx:3
#[test]
// hlx:4
fn unsupported_checked_hit_refuses_before_creating_bank() {
    // hlx:5
    use std::{fs, process::Command};
    // hlx:6
    let root = std::env::temp_dir().join(format!("instinct-platform-{}", std::process::id()));
    // hlx:7
    fs::create_dir_all(&root).unwrap();
    // hlx:8
    let bank = root.join("absent.hxdb");
    // hlx:9
    let output = Command::new(env!("CARGO_BIN_EXE_instinct"))
        .args([
            "hit",
            "in-absent",
            "--check",
            "--trusted-staging",
            "--outcome-id",
            "one",
            "--root",
        ])
        .arg(&root)
        .arg("--store")
        .arg(&bank)
        .output()
        .unwrap();
    // hlx:10
    assert!(!output.status.success());
    // hlx:11
    assert!(String::from_utf8_lossy(&output.stderr)
        .contains("check-verified hits are not supported on this platform; nothing recorded"));
    // hlx:12
    assert!(
        !String::from_utf8_lossy(&output.stderr).contains("instinct check attach"),
        "unsupported Windows hits must refuse before POSIX reattach guidance"
    );
    // hlx:13
    assert!(!String::from_utf8_lossy(&output.stderr).contains("bank binding"));
    // hlx:14
    assert!(!bank.exists());
    // hlx:15
    assert!(!root.join("absent.hxdb.lock").exists());
    // hlx:16
    fs::remove_dir(&root).unwrap();
    // hlx:17
}
// hlx:18
#[cfg(windows)]
// hlx:19
#[test]
// hlx:20
fn unsupported_observation_abstains_without_inventory() {
    // hlx:21
    use std::{
        io::Write,
        process::{Command, Stdio},
    };
    // hlx:22
    let mut child = Command::new(env!("CARGO_BIN_EXE_instinct"))
        .args([
            "check",
            "observe",
            "--root",
            "C:\\not-observed",
            "--input",
            "-",
        ])
        .stdin(Stdio::piped())
        .stdout(Stdio::piped())
        .spawn()
        .unwrap();
    // hlx:23
    child.stdin.take().unwrap().write_all(br#"{"schema":"instinct.artifact-policy/v1","assumptions":{"trusted_quiescent_staging":true},"allowed":[]}"#).ok();
    // hlx:24
    let output = child.wait_with_output().unwrap();
    // hlx:25
    let text = String::from_utf8(output.stdout).unwrap();
    // hlx:26
    assert!(output.status.success());
    // hlx:27
    assert!(
        text.contains("unsupported_platform")
            && text.contains("\"inventory\":[]")
            && text.contains("\"checks\":[]"),
        "{text}"
    );
    // hlx:28
}