Skip to content
pi-c Artifact [0edf951f83]
Login

Artifact [0edf951f83]

Artifact 0edf951f83448755b8e58e1c36d195b34729d9aa2857776a092d054908e4b041:


Durable Harness Build

Status: approved staged implementation and qualification plan, 2026-11-17. Local S0 qualification infrastructure is being implemented; no production harness, product performance baseline, or remote setup exists. The source maps describe 79 reference IDs; the core acceptance catalog defines 30 initial production scenarios to implement. This approval does not silently select unresolved architectural choices or authorize remote lifecycle implementation without its separate design review.

Agreed implementation-language boundary

C owns the runtime, simulation/oracle, core tests, fuzz targets, and benchmark measurement. Make/POSIX shell owns compiler and test orchestration. Small Python helpers are permitted for metadata validation, fixture generation, and report parsing, following ctx/suit. This does not authorize a Python runtime or a general-purpose Python remote orchestrator.

The initial Python remote worker and its tests were removed at the user's request. Remote lifecycle implementation is paused for a separate design review. Local S0 work can proceed; its passing checks do not satisfy the remote gates or complete full S0/release qualification.

Objective and boundary

Build a native C coding harness using context's storage/knowledge core, with explicit Pi behavior targets and durable execution contracts. Keep authoritative execution state separate from redacted/searchable history. Ship a benchmark-qualified native release, without DST, coverage, sanitizer, fuzzing, or Fil-C runtimes.

All claimed guarantees are bounded by a declared platform, workload, failure model, and durability policy. "Fastest" means the best validated candidate on those declared workloads, not a universal proof. No weakened fsync, omitted validation, or unsafe replay to win a benchmark.

Architectural gate before implementation

Compare two designs: an independent harness composing the current context CLI, and an embedded context core with one transaction-aware ownership boundary. Recommend the embedded core for atomicity and lower serialization cost, but approve its API/ownership before refactoring context. Keep the harness runtime out of context's knowledge/search responsibilities.

Resolve at stage S0: authoritative schema and versioning; transactional context API; writer ownership/fencing; credential retention and sync boundary; strict versus deferred progress; production power-loss policy; first provider and target OS matrix; native extension surface versus TypeScript/code-mode compatibility. Distinguish capability parity, format/protocol compatibility, and existing-plugin compatibility. A C-compatible script engine or bridge is possible, but not implicitly selected.

Reference quirks and limitations are not mandatory design choices. Record intentional deviations and their compatibility effect. Owned context/libfossil bugs are fixed upstream under the existing investigation/issue policy, not papered over in this harness.

Implementation sequence and exit gates

Stage Build / demonstrate Correctness gate Performance evidence introduced IDs / cases
S0 — Contracts and qualification skeleton Machine-readable contract/evidence registry; independent transition oracle; toolchain probes; fake clock/random/provider/effect ledger; benchmark schemas; remote lifecycle dry-run. Every one of 79 IDs has an owner stage and required/deferred/deviation status. Targeted test fails when a transition is deliberately corrupted. MC/DC probe compiles, runs, and produces a report. Hetzner teardown handles normal, timeout, abort, and lost SSH. Empty CLI/startup and empty effect/commit-path overhead measured with a trivial native fixture; no production target claimed. All IDs inventoried; A01–A30 specified; remote teardown cases.
S1 — Embedded context boundary Minimal reusable context API while existing CLI still works; explicit connection/transaction ownership and immutable source references. Existing context checks remain green. One transaction rolls back runtime fixture + versioned repository mutation together. Rebuild/sync cannot confer execution authority. Review context changes in its own repo. Baseline existing context search/open/index behavior; compare embedded calls and CLI composition. C01–C10; A08,A09,A30.
S2 — Runtime journal and storage Stable IDs, entries, submissions, documents, checkpoints, commit receipts, migrations, backup/restore. A01–A10 with real SQLite kills; independent oracle; committed state survives reopen; unknown outcome not treated as rollback. Single-owner enforcement and read-only nonmutation. Commit latency under declared sync policy, admission throughput, database bytes per transition, reopen/restore at increasing history sizes. D01–D04,D16–D18,D21; P01,P02; A01–A10.
S3 — First durable vertical slice Keyed input → versioned context → fake streamed tool request → deterministic tool → committed result → final response → restart. Add scheduler phases, retries, sleeps, and bounded crash recovery. A11–A13,A19–A21 and inherited storage suite; crash before/after every commit and effect; golden trace agrees with oracle; no unbounded retry/busy loop. Scheduler runnable/sleeping scale, recovery work versus active tasks, fake-provider end-to-end overhead and idle CPU. D05,D07,D11,D12,D20; P03–P09,P14; H01.
S4 — Real coding tools and ownership Read/write/edit/process tools, spill/output limits, deadlines, process groups, nested calls, cancellation, parking, child ownership. A14–A18,A25,A26; replay-unsafe effects not repeated; idempotent remote ledger; no child/process leak after deadline; corrupt/oversize inputs rejected. Bytes copied/allocated per output byte, truncation throughput, file edit cost, tool dispatch, cancellation completion and spill I/O. D06,D08–D10,D13,D22; H02–H05,H07; P07.
S5 — First provider, then provider matrix One selected provider via raw HTTP/TLS in C; streaming, auth, capabilities, limits, retries, usage; add adapters behind the same transcript boundary. A22–A24 against recorded/fake streams; opt-in live smoke only after budget/access approval. Credentials never enter search/sync/logs; provider wire quirks have fixtures. Parser scaling/chunk sensitivity, request assembly and peak memory; live model time reported separately from harness overhead. P01–P17; H24,H25; D05.
S6 — Sessions and context lifecycle Branch/fork/clone, prompt/tool manifests, rules/skills/templates/config, compaction and overflow recovery. A27,A28,A30; raw history retained; no task copy on fork; session branch is not filesystem rollback; context provenance stable across retries. Compare behavior with pinned Pi fixtures/oracles. Context assembly/compaction bookkeeping, FTS retrieval, branch/fork and memory versus total history and active window. H06,H10–H19,H24,H25; D14,D15; C04–C10.
S7 — Headless client protocol JSON/print/RPC, steering and follow-up, admission versus settled status, bounded durable observation and reconnect. A27,A29; LF framing including Unicode separators; slow/disconnected clients bounded; no lost authoritative state or premature settled signal. Event throughput, slow-client memory, reconnect bytes and latency, commit-to-visible latency under selected policy. H08,H09,H26; D19,D21; P05,P16.
S8 — Extensibility and ecosystem Defined native/process extension contract and hook ordering, MCP client, discovery/tool search, exports/packages; code mode and TS bridge only if selected at S0. Extend catalog for H20–H22,H27–H30; hook/reload/version tests; hostile payloads, OAuth expiry, collision naming, export XSS; sandbox boundary tests if scripting included. No blanket compatibility claim. Extension call/reload overhead, tool-discovery rank/latency, MCP connection/call cost, sandbox startup/limits if present. H20–H22,H27–H30; D10,D13,D17.
S9 — Terminal product Terminal UI, editor, Unicode/paste/resize/images, extension prompts and noninteractive fallbacks. Real PTY scenarios and expected screen/state traces; tested terminal/OS matrix; abort restores queues; rendering failure cannot corrupt journal. Keystroke/resize/render latency, cells/bytes redrawn, idle CPU and long-transcript memory. H07,H22,H23 plus client regression suite.
S10 — Qualified native release Matched correctness builds and native candidates; held-out PGO evaluation; backup/restore/recovery operations; full contract closure. All required IDs have passing evidence; reviewed explicit deferrals/deviations; native+sanitizer+Fil-C regression suites; targeted MC/DC complete; crash and declared stable-storage qualification; remote teardown proven. O2/O3/LTO/PGO/CPU-target comparisons, Pareto tradeoffs, sustained throughput/latency/RSS/DB-growth/idle tests; release hash binds all evidence. All required IDs; all implemented cases; no open critical correctness/performance/cleanup blocker.

These are dependency stages, not calendar estimates. Parallelize only work with stable interfaces and independent diffs; storage and checkpoint semantics lead UI and ecosystem work.

Definition of done for every slice

  1. Add an executable scenario and observe its expected failure before implementation; document red/green evidence.
  2. Implement only that slice; run its targeted checks, then all inherited regression gates.
  3. Add DST transitions and explicit invariants for new nondeterminism; save failing seeds as stable regressions.
  4. Add fuzz targets/corpus cases for new parsers and trust boundaries; run native sanitizers and the Fil-C lane where applicable.
  5. Expand MC/DC decision inventory and show the independent-condition test pair for each new safety-critical predicate.
  6. Add benchmark workload/raw results before optimizing; compare the release candidate on the same host/profile.
  7. Review semantics and scope independently; reconcile every contract ID and intentional difference.
  8. Require teardown evidence for all remote work. A skipped tool, missing environment, noisy benchmark, or cleanup failure is not green.

Proposed local command surface (not implemented): make check, make test, make dst, make coverage-mcdc, make fuzz-smoke, make sanitize, make filc-remote, make bench, make qualify. Commands must fail or report a gated result when a required tool/runner is absent; never silently skip to success.

Living end-to-end conformance

Maintain end-to-end conformance scenarios from the first working runtime slice, expanding them with every feature and fix. The proposed 24 families compare the C candidate with pinned Pi and Pi Durable where each applies, plus independent state/effect/ownership oracles. A nightly current-stage tier and exact-binary release tier must retain raw traces, fault schedules, hashes, and teardown results; they cannot pass by shrinking required case counts or copying an upstream bug.

Use deterministic fake providers and fresh isolated workspaces by default. Pin/review reference updates rather than silently changing expected behavior. Reference execution needs a development-only Node environment, not a C runtime dependency. Runner placement, dependency setup, artifact retention, and teardown require review before enabling this lane. No reference environment or nightly schedule has been created yet.

Correctness layers and proposed cadence

Lane Per change / PR Nightly Release
Native unit/integration and contract cases All bounded core cases + inherited regressions Full suite Exact packaged binary and installed layout
DST 100 deterministic seeds plus all regression seeds; bounded step/time cap 10000 seeds within an explicit job deadline Frozen adversarial corpus + new seeds; replay logs retained
MC/DC Changed critical decisions; condition-pair evidence Full declared critical-decision inventory 100% of reachable declared decisions, with reviewed exclusions; coverage denominator cannot shrink silently
Fuzz + sanitizers Saved corpus + 60 s per changed target 30 min per target, bounded runner jobs Corpus replay plus bounded extended campaign; no unresolved crash
Fil-C on Hetzner Core suite and saved fuzz regressions Full relevant integration suite Full relevant suite against the release source; compiler/version/checksum recorded
Real crash / storage faults Deterministic commit-boundary kills + ENOSPC/I/O fixtures Randomized operation/kill sequences Declared power-loss policy qualification and backup/restore
Native performance Fast fixed workloads on a qualified runner; otherwise informational Dedicated-runner complete suite Paired native-candidate matrix and sustained run, exact release binary

Counts/durations are proposed starting budgets, not measured capacity. S0 calibrates runtime without reducing invariants or hiding cases. Long jobs carry host-enforced deadlines. Third-party SQLite/libfossil coverage is reported separately; full application coverage must not be inferred from targeted runtime MC/DC. Fil-C is memory-safety evidence, not proof of transaction semantics or native-binary safety.

Performance contract

Workload envelope

Use fixed synthetic nonsecret fixtures with manifest hashes: 1/100/10000 conversations; 100/10000/1000000 transcript entries; small/large active windows; idle/sleeping/runnable tasks; 1 KiB/1 MiB tool payloads; 8-byte through 64-KiB stream chunks; one normal and one slow observer; FTS corpora with 1000/100000/1000000 chunks. Grow one axis at a time before mixed-load tests. Unsupported sizes become stated limits, not out-of-memory surprises. Disk budgets must be checked before generating large fixtures.

Measure startup, admission, commit, scheduling, parse/assemble, context retrieval, tool execution overhead, progress publication, cancellation, reconnect, reopen/recovery, RSS/peak allocations, database/WAL growth, checkpoint stalls, idle CPU, and long-run resource slope. Record p50/p95/p99 where sample counts support them, throughput, and sample counts. Do not report p99 from a handful of process starts.

Fair comparison and promotion

Hetzner Fil-C lifecycle and teardown

The user-designated remote alias is hetzner-hel. No SSH session, install, runner, or job was started while writing this plan.

Setup contract

Teardown order

  1. Prevent new work; stop the specific run's supervisor unit and descendants. Verify no run-owned process remains. Never kill unrelated shared-host work.
  2. Collect exit status, coverage/test logs, failing seeds, corpus additions, versions, resource inventories, and benchmark data if applicable. Transfer to a private off-host evidence directory and verify hashes before deleting remote outputs.
  3. Remove only run-created containers/mounts, private credentials, temporary downloads/builds, sockets, and run directories recorded in the manifest. Validate owner/prefix/canonical path before destructive cleanup; never use broad host-wide deletion.
  4. Retain shared compiler caches only if explicitly classified as retained resources. Record their hashes, owner, size, expiry, and cleanup responsibility. Retention is not a scratch leak.
  5. Compare post-run inventory against preflight; mark the manifest cleaned only with evidence. Archive the manifest and cleanup result off-host. If cleanup fails, mark qualification failed/cleanup-pending and prevent another colliding run until reconciled.
  6. An expired-run reaper may remove only verified manifest-owned expired resources. Ambiguous ownership is surfaced for review, not deleted.

Required lifecycle tests

Q01 normal completion; Q02 test failure; Q03 timeout; Q04 SSH disconnect; Q05 parent/supervisor interruption; Q06 disk full during evidence collection; Q07 repeated teardown; Q08 stale manifest after host reboot. Each asserts bounded process termination, no unrelated-resource deletion, and either verified off-host evidence or an explicit lost-evidence failure. Test teardown before trusting long remote campaigns.

No cloud resources need be provisioned by default. If later setup creates an instance, volume, firewall, credential, schedule, or persistent runner, add its identifier, owner, expiry, budget, and teardown command to the manifest before creation.

Evidence and release ledger

Every result binds source/dependency hashes, toolchain/flags, binary hash, host/OS/CPU/storage metadata, sync policy, workload/seed/corpus hashes, command, sample counts, raw outputs, expected versus observed state/effects, and teardown result. Store immutable run artifacts; link contract ID → test → result → binary. Never embed tokens or host credentials.

Use statuses NOT RUN, PASS, FAIL, GATED, DEFERRED, DEVIATION. A screenshot is not a storage test; a test count is not MC/DC; a single benchmark is not a capacity claim. Aggregate completion requires every required gate, not a percentage that conceals an untested subsystem.

Current environment facts versus future evidence

Initial local preflight found Apple clang 21 on macOS ARM64, MC/DC instrumentation, and matched LLVM tools through xcrun. Subsequent local S0 checks now compile and execute the probe, exercise negative coverage cases, run C fixture/DST/fuzz checks, and collect informational native samples. See S0 results for actual outcomes and limitations; none qualifies the production runtime. The Pi reference remains pinned and unchanged. Fil-C is not on the local PATH; the user designated Hetzner for that lane. A read-only Linux/user-manager preflight succeeded there, but remote implementation/setup remains paused and Fil-C qualification, product benchmarks, runtime coverage, and all release claims remain NOT RUN/GATED.