Contextfulv0.23.0

Docs / Specification

contract assurance · 80-formal.md · 81-engineering.md · 82-consumer.md · 83-gate.md · guide · card

Engineering gates and the quality harness

How the tree is written, built and checked: one home per capability, test placement, build targets and artifacts, and the harness that turns read-path quality into a red or green verdict. The gate that runs these checks, the target ledger and the release tag live in spec/83-gate.md.

The tree, the checks over it, and the two verdicts they produce:

Flowchart diagram Flowchart, top to bottom. 14 nodes, 13 edges. source tree → build pipeline [three profiles]; → test suites [one binary per crate] build pipeline → CI gate [built binaries]; → release artifacts [archive, checksum, SBOM, image] test suites → CI gate [test results] typed subcommands → CI gate [stage commands] CI gate → pull request [one check per stage] formal model → CI gate [proof check] read contract: real store → quality harness [ranked retrieval] evals/cases JSONL → quality harness [cases] quality harness → within baselines and floors? [scores] within baselines and floors? → green verdict [yes]; → red verdict [no] read contract real store three profiles one binary per crate stage commands built binaries test results proof check one check per stage archive, checksum, SBOM,image cases ranked retrieval scores yes no source tree build pipeline test suites typed subcommands CI gate formal model pull request release artifacts evals/cases JSONL quality harness within baselines and floors? green verdict red verdict

structure-tree

One home per capability, the one enforcement decision module, adapters, mirror annotations and derived-artifact checks.

test

Assertion construction, guard validation, suite placement, test-first and acceptance tests, and the connector test kit.

build

Target directories, the engine-linked invocation, linked query functions, build targets, release artifacts and the dependency allowlist.

  • target-dir-per-stagetestEach cargo stage builds into a target directory of its own, reclaimed once the stage passes.
    Whybecause stages under different feature unification share no artifacts, and peak disk is then one stage
  • checkout-artifactstest.cargo/config.toml names the checkout root, and every workspace package’s build script folds its canonical path into the package fingerprint, so a shared target directory recompiles workspace packages per checkout while unchanged dependencies stay fresh.
    WhyA-assurance#gate-repair-evidence
  • runtime-checkouttestReusable test helpers resolve the workspace root and tested binary from explicit runtime inputs bound to the invocation; cached helpers carry no compile-time checkout path deciding which source or binary runs.
    WhyA-assurance#gate-repair-evidence
  • one-engine-buildtestThe workspace stage builds every engine-linked package in one cargo invocation over the union of their features, and the store adapter’s suites resolved without read link no SQL engine, so the features stage compiles one copy.
    Whybecause one cargo invocation compiles the engine once, and a store-adapter suite asserting through SQL links a second copy into the no-read features run
  • staged-feature-runstestA defect appearing under one feature combination alone is reached by a staged nightly run, one command per container.
  • linked-query-functionstestColumnar file reading and statement serialization link into every build linking the SQL engine, and the read path loads no extension while serving.
    WhyA-assurance#columnar-read-statement
  • runtime-extension-loadtestA read path loading an extension into a binary that statically links the SQL engine raises ExtensionAutoloadRefused.
    WhyA-assurance#columnar-read-statement
  • debug-infotestDevelopment and test profiles carry line-tables-only debug information for workspace code and none for dependencies.
    Whybecause every engine-linked test binary embeds the bundled engine, and full debug information multiplies each past a sandbox’s disk
  • release-profiletestRelease builds compile with thin link-time optimization, one codegen unit per crate and symbols stripped, and unwind on panic.
    Whybecause the run keeper survives a panicking job only by unwinding to its guard
  • profile-buildtestThe features stage tests each package under every feature set its manifest lists in feature-runs: each other package has its own nightly check; each binary feature run has separate nightly checks for differential tests and all remaining tests.
    Whybecause one cold build of the binary under one feature set fills most of a stage’s wall clock, and a listed set reaches what none and all miss
  • container-imagetestThe repository’s Dockerfile builds one profile, contextful-full by default, as a static binary for the PLATFORM and RUST_TARGET its arguments name, and ships it in a shell-free runtime image as a non-root user over a declared store volume.
  • release-imagetestEach profile’s release image is an OCI index of a linux/amd64 and a linux/arm64 manifest; contextful-ci image assembles each from the profile’s x86_64 or aarch64 musl release binary, with the Dockerfile’s runtime user, volume and entrypoint.
    Whybecause arm64 hosts pull the same tag natively, and each release cell already holds its target’s binary, so no image compiles twice
  • image-binary-mismatchtestA binary whose ELF machine differs from its target’s, or whose program headers name a dynamic interpreter, raises ImageBinaryMismatch, naming the target.
    Whybecause a mislabelled layer runs only under emulation, and a dynamic binary finds no C library in the static runtime
  • targetstestAll three profiles cross-compile to x86_64-unknown-linux-musl and aarch64-unknown-linux-musl; edge and full also build for aarch64-apple-darwin and x86_64-apple-darwin.
    WhyA-assurance#windows-release-support
  • windows-targettestWindows targets are excluded from the release matrix; no profile publishes Windows artifacts.
    WhyA-assurance#windows-release-support
  • wasi-probetestNo profile ships a wasm32-wasip2 release; a scheduled-tier ledger entry builds the edge profile for it and holds the compressed artifact to edge-budget.
    WhyA-assurance#edge-profile-ships
  • release-artifacttestEach profile ships a release archive with a SHA-256 checksum and an SBOM, a package-manager formula and an independently tagged container image; the bare formula name and the install script resolve to the full profile.
    WhyA-assurance#edge-profile-ships
  • release-buildertestThe release command uses cargo build by default and cargo zigbuild under --builder zigbuild, forwarding the selected target and profile features.
    Whybecause Cloudflare Linux builds Darwin targets through Zig while the local release command keeps its native build path
  • release-metadatatestEach release cell writes a JSON record naming its profile, target, archive, SHA-256 digest and SBOM.
    Whybecause distributed release cells need a small authenticated input for formula generation
  • formula-manifesttestThe formula command accepts a manifest covering every release matrix cell once, with matching asset names and SHA-256 digests, and writes formulas and SHA256SUMS without local archives.
    Whybecause one aggregation sandbox need not download every archive to produce formulas
  • licence-fieldtestEvery workspace package under crates/ or tools/ declares license = "Apache-2.0", inherited from [workspace.package]; a package declaring another value or none raises PackageLicenceMissing, naming its manifest.
    Whybecause cargo-deny, cargo-about and SBOM generators read the manifest field, not the LICENSE file, so an unlicensed package fails a consumer’s licence check
  • dependency-allowlisttestThe connector authoring dependency allowlist carries regex and serde_json at its depth limit; a profile graph reaching fancy-regex, pcre2, onig or serde_json’s unbounded_depth feature raises DependencyAllowlistViolation, naming the profile and path.
    Whybecause a backtracking matcher or a parser without a depth limit lets one hostile record pin a core or exhaust the stack

Scenarios

evaluate

The read-path quality harness: case format, deterministic metrics and floors, judged dimensions, the reader and the judge.

deterministic metrics

Ranked metrics and floors computed with no model call.

  • deterministic-tiertestRecall@k, R-precision, hit-rate@k, reciprocal rank and nDCG@k run with no model call, reported per leg — lexical, vector, hybrid — and per slice.
  • distinct-top-ktestMembership in the top k is distinct, and a repeated id counts once.
  • absent-truthtestA ranked metric over a case with no relevant set is NaN and drops out of every aggregate; an empty ranking against a non-empty relevant set scores zero.
  • precision-floortestPrecision at rank min(k, R), R being the relevant-set size, holds at or above 60 percent.
    Whybecause precision@k caps at R/k, below the floor whenever R is small
  • forbidden-row-ratetestA row named in a must-not-retrieve set holds at 0 percent of a regression case’s returned rows.
  • duplicate-row-ratetestA repeated table-and-row-key pair holds at 0 percent of the ranking.
  • in-window-ratetestA case declaring a recency bound holds its in-window rate at or above 95 percent.
  • abstentiontestA must-abstain case returns zero rows.
  • truth-per-surfacetestExpected artifacts score the artifact retriever and expected edges score the edge retriever, reported apart; edge truth with no edge surface configured counts in an unscored tally.

judged tier

The reader and the pinned judge score answers through the model endpoint.

Scenarios

baseline

Holding a run against committed baselines and absolute floors, intervals, golden custody and case generation.

backtest

Historical evaluations, called backtests: bounded cases, model-knowledge controls, label intervals and splits, execution metadata, planted leaks and replayable trajectories. Financial return-series and execution profiles are consumer-selected applications of this flow (domain-neutral).

Scenarios

forecast

Probability forecasts over consumer-declared outcomes: freeze instant, settlement, lead time, imputation, coverage, reference baselines and separate scoring tracks. Reference baselines belong to an explicitly selected profile (domain-neutral).

Scenarios

unsettled: Which consumer-selected reference anchors difficulty-adjusted probability scores across case sets? owner: eval affects: assurance.forecast

Shapes

A baseline file:

{
  "_run": { "k": 10, "tier": "judged", "model": "pinned-open-weights", "samples": 1 },
  "retrieval.hybrid.recall_at_k": 0.71,
  "retrieval.hybrid.recall_at_k.n": 184,
  "retrieval.hybrid.ndcg_at_k": { "value": 0.63, "band": 0.03 },
  "retrieval.hybrid.ndcg_at_k.n": 184,
  "judge.citation_faithfulness": 0.82,
  "judge.citation_faithfulness.n": 184,
  "latency_ms": { "value": 480, "band": 60 },
  "n_cases": 184
}

A case:

{
  "id": "edge-chain-0117",
  "corpus": "native/r3",
  "question": "Which supplier does the northern plant share with the coastal plant?",
  "expected": {
    "answer": "Meridian Castings",
    "artifacts": [["supplier_notes", "b7f1c2"], ["plant_registry", "0a44de"]],
    "edges": [["plant:north", "supplied_by", "supplier:meridian"]],
    "entities": ["supplier:meridian"],
    "must_cite": ["supplier_notes"],
    "must_abstain": false,
    "time_anchor": "<RFC 3339 instant>"
  },
  "tags": ["multi_hop", "entity_resolution"]
}