{
  "name": "harness-apd",
  "language": "rust",
  "version": "0.1.0",
  "description": "APD benchmark driver \u2014 binds harness-runtime (HarnessSpec v0.1) to an OpenAI-compatible inference route, local dev planes, and the MAP spine when MAP_BASE_URL is set (WS-11)",
  "manifest": "forge-rs/harness-apd/Cargo.toml",
  "manifestSha256": "9b1cc5d4fbf7f818d531f3524aabefadb257c34249e7deed8b907ca5a70e5846",
  "status": "source-reference",
  "registryPublicationVerified": false,
  "route": "/libraries/rust/harness-apd",
  "features": {},
  "files": [
    {
      "path": "forge-rs/harness-apd/src/driver.rs",
      "sha256": "7b4af215e5351992fc93637fb11179f5cc6dff75bdec76233a861391862fb9f1",
      "artifactSha256": "ba01958e4b849b56fa248658623274138d1de17ff98b83e1ce00ec30702b868d",
      "url": "/reference/source/forge-rs/harness-apd/src/driver.rs.txt",
      "declarations": [
        {
          "name": "::RunArtifacts",
          "line": 49,
          "signature": "#[derive(Debug)]\npub struct RunArtifacts {\n/// The runner-facing result (`apd-harness-result/1`).\n\npub result: ApdRunResult,\n/// The full HarnessSpec run record (`harness.run.v1`).\n\npub record: RunRecord\n}",
          "documentation": "Everything one executed attempt produces."
        },
        {
          "name": "::DriverError",
          "line": 58,
          "signature": "#[derive(Debug, thiserror::Error)]\npub enum DriverError {\n    /// The spec could not be read or parsed.\n    #[error(\"spec: {0}\")]\n    Spec(String),\n    /// A plane could not be constructed.\n    #[error(\"plane binding: {0}\")]\n    Binding(String),\n    /// Admission denied the harness (denied runs never execute, \u00a74.4).\n    #[error(\"admission denied: {0}\")]\n    Admission(String),\n    /// The run itself faulted outside the terminal-outcome contract.\n    #[error(\"runtime: {0}\")]\n    Runtime(String),\n    /// Writing an artifact failed.\n    #[error(\"artifact write: {0}\")]\n    Artifact(String),\n}",
          "documentation": "Driver-level failures (the run never reached a terminal state)."
        },
        {
          "name": "::run",
          "line": 77,
          "signature": "pub async fn run(spec: &ApdTaskSpec, events_path: PathBuf) -> Result<RunArtifacts, DriverError>;",
          "documentation": "Execute one task spec end-to-end."
        }
      ]
    },
    {
      "path": "forge-rs/harness-apd/src/inference.rs",
      "sha256": "7d3afaaa65479c37e487e2ce174e51bfba1b452bd8b4a9a8dfec6edf3526446b",
      "artifactSha256": "5d61fb136831a4a98b7fafd7a3452c661c7b562d5c85b95dc8a2d2ef2f88c455",
      "url": "/reference/source/forge-rs/harness-apd/src/inference.rs.txt",
      "declarations": [
        {
          "name": "::OpenAiInferencePlane",
          "line": 66,
          "signature": "pub struct OpenAiInferencePlane {\n\n}",
          "documentation": "Inference plane over an OpenAI-compatible route."
        },
        {
          "name": "::OpenAiInferencePlane::new",
          "line": 79,
          "signature": "pub fn new(\n        base_url: &str,\n        api_key: Option<String>,\n        model: impl Into<String>,\n        temperature: Option<f64>,\n        max_output_tokens: Option<u64>,\n        price: SpecPrice,\n        tools: Vec<String>,\n    ) -> Result<Self, PlaneError>;",
          "documentation": "Bind the plane to a route. `api_key` becomes the route's\n`authorization: Bearer` header when present; the key value is held\nonly inside the HTTP client's default headers."
        }
      ]
    },
    {
      "path": "forge-rs/harness-apd/src/lib.rs",
      "sha256": "bba65e5ff0f309af2c54fc8b923c9146064301c66f0f6ec530d36d4f3b030ef3",
      "artifactSha256": "108927e0cbf36e05b2aaa8ba796819cb539d3819abd068d533cbc46f04502c05",
      "url": "/reference/source/forge-rs/harness-apd/src/lib.rs.txt",
      "declarations": [
        {
          "name": "driver",
          "line": 28,
          "signature": "pub mod driver;",
          "documentation": "# harness-apd\n\nThe APD benchmark harness arm (`one/app/benchmarks`, WS-11; FINAL_SPEC\n\u00a78.5): executes one benchmark task spec as a real HarnessSpec v0.1 run\nthrough [`harness_runtime`] \u2014 admission gate, ReAct loop, verification\ngates, settlement, archived run record \u2014 and projects the terminal\nrecord into the benchmark runner's result contract.\n\nPlane binding:\n\n- **Memory + context** dispatch through the MAP spine (MIND\n  `store_memory`/`recall_memory`, optional MARC `reasoning_task`)\n  when `MAP_BASE_URL` is set \u2014 the same spine switch ONE's\n  PlaneRegistry keys on \u2014 and bind local dev planes otherwise.\n- **Inference** rides the OpenAI-compatible route named by the spec,\n  metered from the runner's fail-loud price table.\n- **Identity, policy, economics, telemetry, substrate, tools,\n  verification** bind the local dev planes (real structural\n  verification, in-process ledger, workspace filesystem tools, shell\n  command gates, JSONL event emission).\n\nThe binary is `harness-apd-driver`; the TypeScript `HarnessDriver`\nspawns it per task attempt."
        },
        {
          "name": "inference",
          "line": 29,
          "signature": "pub mod inference;",
          "documentation": ""
        },
        {
          "name": "local_planes",
          "line": 30,
          "signature": "pub mod local_planes;",
          "documentation": ""
        },
        {
          "name": "patch",
          "line": 31,
          "signature": "pub mod patch;",
          "documentation": ""
        },
        {
          "name": "spec",
          "line": 32,
          "signature": "pub mod spec;",
          "documentation": ""
        },
        {
          "name": "pub use driver::{run, DriverError, RunArtifacts};",
          "line": 34,
          "signature": "pub use driver::{run, DriverError, RunArtifacts};",
          "documentation": ""
        },
        {
          "name": "pub use spec::{ApdRunResult, ApdTaskSpec, SpecError, SPEC_SCHEMA};",
          "line": 35,
          "signature": "pub use spec::{ApdRunResult, ApdTaskSpec, SpecError, SPEC_SCHEMA};",
          "documentation": ""
        }
      ]
    },
    {
      "path": "forge-rs/harness-apd/src/local_planes.rs",
      "sha256": "00ab97812b91ab7355e114d82c7b0e63e627808b200e8261467166d35acac44e",
      "artifactSha256": "3df85e20668b4e5e3ee6c52a5efe0de0cf3840dc63044257227f498a57523600",
      "url": "/reference/source/forge-rs/harness-apd/src/local_planes.rs.txt",
      "declarations": [
        {
          "name": "::LocalIdentityPlane",
          "line": 47,
          "signature": "pub struct LocalIdentityPlane;",
          "documentation": "Local dev identity plane: real structural verification of the OAS\nbinding (DID method, lineage reference form, human-root kind, depth\nbound) with a content-hashed evidence reference. It does not claim\nKeystone's cryptographic lineage resolution \u2014 it verifies everything\na local check honestly can."
        },
        {
          "name": "::LocalPolicyPlane",
          "line": 95,
          "signature": "pub struct LocalPolicyPlane;",
          "documentation": "Local dev policy plane: evaluates real rules over the admission\nrequest \u2014 the subject DID must be well-formed, the declared\nentitlement must scope the requested permission, and at least one\npolicy document must be declared. A miss denies in-contract (\u00a74.6)."
        },
        {
          "name": "::LocalContextPlane",
          "line": 152,
          "signature": "pub struct LocalContextPlane;",
          "documentation": "Static context packer: the frame is the task text as declared (the APD\ntask prompt plus its declared context files), token-counted by the\ndocumented ceil(chars/4) estimate. Used when no spine is configured."
        },
        {
          "name": "::LocalMemoryPlane",
          "line": 189,
          "signature": "#[derive(Default)]\npub struct LocalMemoryPlane {\n\n}",
          "documentation": "In-process memory plane: a real store (writes are retained and\nconsolidated within the process) with content-hashed evidence\nreferences. Used when no spine is configured."
        },
        {
          "name": "::LocalEconomicsPlane",
          "line": 265,
          "signature": "#[derive(Default)]\npub struct LocalEconomicsPlane {\n\n}",
          "documentation": "In-process economics ledger: reservations grant exactly what the\nmanifest requests (the runtime's budget ledger enforces the caps from\nthere), settlement records the run's real usage totals exactly once."
        },
        {
          "name": "::LocalTelemetryPlane",
          "line": 360,
          "signature": "pub struct LocalTelemetryPlane {\n\n}",
          "documentation": "Local telemetry plane: every event is appended as one JSON line to the\nrun's events file \u2014 real emission with a real receipt (file + line\nnumber), never a dropped ack."
        },
        {
          "name": "::LocalTelemetryPlane::new",
          "line": 367,
          "signature": "pub fn new(path: impl Into<PathBuf>) -> Self;",
          "documentation": "Bind emission to a JSONL file (created or appended)."
        },
        {
          "name": "::LocalSubstratePlane",
          "line": 416,
          "signature": "pub struct LocalSubstratePlane;",
          "documentation": "Local-process substrate: the placement is this process, honestly\nidentified (run id + pid)."
        },
        {
          "name": "::LocalToolsPlane",
          "line": 447,
          "signature": "pub struct LocalToolsPlane {\n\n}",
          "documentation": "Workspace tools plane: real filesystem implementations of the\nallowlisted `one.code/*` tools, rooted at the task's pristine checkout\nwith path-traversal containment. `request_approval` denies closed \u2014\nthe APD driver has no human approval surface, and the manifest gates\nno tool."
        },
        {
          "name": "::LocalToolsPlane::new",
          "line": 453,
          "signature": "pub fn new(root: impl Into<PathBuf>) -> Result<Self, PlaneError>;",
          "documentation": "Root the tools at a workspace directory (canonicalized once)."
        },
        {
          "name": "::LocalVerificationPlane",
          "line": 592,
          "signature": "pub struct LocalVerificationPlane {\n\n}",
          "documentation": "Local verification plane: runs each declared gate as a real shell\ncommand in the workspace root with a timeout; the exit code and the\ncaptured output tail are the machine-checkable result. `evidence_ref`\nis absent \u2014 a local sh gate produces no durable provider evidence, and\nthe honesty policy prefers absence over synthesis (\u00a75.10)."
        },
        {
          "name": "::LocalVerificationPlane::new",
          "line": 598,
          "signature": "pub fn new(root: impl Into<PathBuf>) -> Self;",
          "documentation": "Bind gate execution to a workspace directory."
        }
      ]
    },
    {
      "path": "forge-rs/harness-apd/src/main.rs",
      "sha256": "ce6e1bc409ff17e6a2f5c1574badce7a342cd941225b8d3b1ba2f85db9e318cd",
      "artifactSha256": "90612127dfe5f095373978bc5b876fa761475d0e39a6cf83d1e85409266df546",
      "url": "/reference/source/forge-rs/harness-apd/src/main.rs.txt",
      "declarations": []
    },
    {
      "path": "forge-rs/harness-apd/src/patch.rs",
      "sha256": "10d0a7ee94ff4f46632d72084b24fdd535776cccc63697b38d264387dfe02573",
      "artifactSha256": "bf181574e22a115caf57f0529e8bf1c7a20de1d5885b02e3335186838133ae30",
      "url": "/reference/source/forge-rs/harness-apd/src/patch.rs.txt",
      "declarations": [
        {
          "name": "::extract_patch",
          "line": 10,
          "signature": "pub fn extract_patch(completion: &str) -> Option<String>;",
          "documentation": "Unified-diff extraction from a model completion \u2014 the Rust port of the\nbenchmark runner's `extractPatch` (`one/app/benchmarks/runner/src\ndrivers/baseline.ts`), kept byte-compatible so both arms extract under\nidentical rules: a fenced ```diff block first, then a raw scan for the\nfirst `diff --git ` header; the candidate must carry `--- ` and `+++ `\nlines to count as a unified diff.\nExtract a unified diff from a completion, or `None` when the\ncompletion carries none."
        }
      ]
    },
    {
      "path": "forge-rs/harness-apd/src/spec.rs",
      "sha256": "33fc4f5706fbb2792611e3359c6620a4dc2f33a96c19de41547259389156e9fc",
      "artifactSha256": "67d5c2ee946b38211dc3b743328f3c5275295a3326d25de457a0c475657fceb7",
      "url": "/reference/source/forge-rs/harness-apd/src/spec.rs.txt",
      "declarations": [
        {
          "name": "::SPEC_SCHEMA",
          "line": 12,
          "signature": "pub const SPEC_SCHEMA: &str;",
          "documentation": "The spec schema tag."
        },
        {
          "name": "::ApdTaskSpec",
          "line": 16,
          "signature": "#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]\npub struct ApdTaskSpec {\n/// Schema tag; must be [`SPEC_SCHEMA`].\n\npub schema: String,\n/// Corpus task id (e.g. `json5-cve-2022-46175`).\n\npub task_id: String,\n/// The task prompt from the corpus.\n\npub prompt: String,\n/// The task's declared context files, in declared order.\n\npub context_files: Vec<SpecContextFile>,\n/// Absolute path of the pristine workspace checkout (tools plane root).\n\npub workspace_dir: String,\n/// Operator-supplied model identifier (never defaulted \u2014 live-catalog\n\n/// discipline, L1F-16).\n\npub model: String,\n/// OpenAI-compatible base URL of the model route (e.g. a Foundry\n\n/// route or provider gateway).\n\npub base_url: String,\n/// Environment variable holding the route's API key. The key value is\n\n/// read from the process environment at run time; it is never written\n\n/// to the spec, the result, or the run record.\n\n#[serde(default)]\npub api_key_env: Option<String>,\n/// Sampling temperature. `null` omits the parameter entirely \u2014 some\n\n/// current flagship models accept only their default temperature and\n\n/// reject an explicit value.\n\n#[serde(default)]\npub temperature: Option<f64>,\n/// Output-token cap per model call.\n\n#[serde(default)]\npub max_output_tokens: Option<u64>,\n/// ReAct loop step cap (`[loop].max_steps`).\n\n#[serde(default = \"default_max_steps\")]\npub max_steps: u64,\n/// Context frame cap (`[context].frame_budget_tokens`).\n\n#[serde(default = \"default_frame_budget_tokens\")]\npub frame_budget_tokens: u64,\n/// USD budget cap (`[inference].budget_usd`).\n\npub budget_usd: f64,\n/// Token budget cap (`[inference].budget_tokens`).\n\npub budget_tokens: u64,\n/// The model's current price entry (the runner's fail-loud price\n\n/// table resolved it before any spend).\n\npub price: SpecPrice,\n/// Enable the MARC `reasoning_task` decomposition section when the\n\n/// MAP spine is configured. Ignored when it is not.\n\n#[serde(default = \"default_marc_decomposition\")]\npub marc_decomposition: bool\n}",
          "documentation": "One benchmark task attempt, as handed to the harness arm."
        },
        {
          "name": "::SpecContextFile",
          "line": 79,
          "signature": "#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]\npub struct SpecContextFile {\n/// Repo-relative path.\n\npub path: String,\n/// Current content at the pinned ref.\n\npub content: String\n}",
          "documentation": "A declared context file (path + current content)."
        },
        {
          "name": "::SpecPrice",
          "line": 88,
          "signature": "#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]\npub struct SpecPrice {\n/// USD per 1M input tokens.\n\npub input_per_mtok: f64,\n/// USD per 1M output tokens.\n\npub output_per_mtok: f64\n}",
          "documentation": "USD per 1M tokens, resolved by the runner's price table at spec time."
        },
        {
          "name": "::ApdTaskSpec::from_json",
          "line": 97,
          "signature": "pub fn from_json(source: &str) -> Result<Self, SpecError>;",
          "documentation": "Parse and check a spec document."
        },
        {
          "name": "::SpecError",
          "line": 126,
          "signature": "#[derive(Debug, thiserror::Error)]\npub enum SpecError {\n    /// The document is not valid JSON for the spec shape.\n    #[error(\"malformed spec: {0}\")]\n    Malformed(serde_json::Error),\n    /// The schema tag is not supported by this driver.\n    #[error(\"unsupported spec schema {0:?} (expected {SPEC_SCHEMA:?})\")]\n    UnsupportedSchema(String),\n    /// A required field is missing or invalid.\n    #[error(\"missing or invalid field: {0}\")]\n    MissingField(&'static str),\n}",
          "documentation": "Spec rejection reasons."
        },
        {
          "name": "::ApdRunResult",
          "line": 140,
          "signature": "#[derive(Debug, Clone, PartialEq, Serialize)]\npub struct ApdRunResult {\n/// Schema tag.\n\npub schema: String,\n/// Corpus task id.\n\npub task_id: String,\n/// The harness run id minted at admission.\n\npub run_id: String,\n/// The model route used.\n\npub model: String,\n/// Terminal outcome kind (`verified` | `failed` | `halted`).\n\npub outcome: String,\n/// The unified diff extracted from the run's final answer, when the\n\n/// loop produced one. `null` is honest: no patch exists.\n\npub patch: Option<String>,\n/// Real metered usage from the run record's usage totals.\n\npub usage: ApdUsage,\n/// MAP spine dispatches made by the run's planes (empty when the\n\n/// spine is unconfigured \u2014 local planes served the run).\n\npub map_spine: ApdMapSpine,\n/// Terminal error detail (halt reason / verification failure), when\n\n/// the run did not verify.\n\npub error: Option<String>\n}",
          "documentation": "The result artifact written per attempt (`apd-harness-result/1`)."
        },
        {
          "name": "::ApdUsage",
          "line": 166,
          "signature": "#[derive(Debug, Clone, Copy, PartialEq, Serialize)]\npub struct ApdUsage {\n/// Total input tokens across all model calls.\n\npub prompt_tokens: u64,\n/// Total output tokens across all model calls.\n\npub completion_tokens: u64,\n/// Total USD charged against the budget ledger.\n\npub cost_usd: f64\n}",
          "documentation": "Metered usage projected for the runner's `DriverOutput`."
        },
        {
          "name": "::ApdMapSpine",
          "line": 177,
          "signature": "#[derive(Debug, Clone, PartialEq, Serialize)]\npub struct ApdMapSpine {\n/// Whether `MAP_BASE_URL` configured a spine for this run.\n\npub configured: bool,\n/// Every dispatch the run's planes made, in order.\n\npub dispatches: Vec<harness_runtime::SpineDispatchRecord>\n}",
          "documentation": "The run's spine traffic, for the evidence bundle."
        }
      ]
    }
  ]
}
