package cabal

All checked builds pass
  1. Overview
  2. Docs

doc/CHANGELOG.html

Changelog

All notable changes to Cabal are documented in this file.

The format is based on Keep a Changelog; releases are tagged X.Y.Z from 0.2.0 on. Entries before 0.3.0 are grouped under "Earlier changes" by the date a change merged to main.

Unreleased

0.3.7 — 2026-11-12

Fixed

  • Unix gateway peer UID authentication now builds on macOS and FreeBSD using getpeereid; Linux retains SO_PEERCRED. Platforms without a supported peer credential check cannot authenticate a gateway.
  • JSON Schema conversion preserves finite number bounds and rejects values outside JSON's number grammar, including Yojson Safe extensions.

Changed

  • The source archive excludes task records introduced after 0.3.6.

0.3.6 — 2026-11-12

Fixed

  • Daybreak Pi tasks now bind a typed host-selected built-in tool allowlist, materialize that allowlist and the exact declared MCP servers in the private agent directory, and always run with explicit --tools plus --no-approve. Missing or substituted tool/MCP policies fail before Pi starts.
  • The Daybreak test target declares its executable dependency, so a clean dune runtest builds it before the watchdog runs.
  • The Daybreak descriptor test writes to inherited file descriptors without relying on shell-specific redirection syntax.

Changed

  • Source archives exclude local task records and review output. The KB entry now points to current public interfaces and their tested invariants.
  • The canonical GitLab repository runs its build, tests, documentation build, and opam lint in merge request and tag pipelines.

0.3.5 — 2026-10-23

The Pi backend reports runs that never started as a typed start failure, stops a Pi that hangs before its first agent event, can retry such runs without paying twice, and accepts MCP servers (Pi >= 1.3.0).

Behaviour changes for hosts:

  • Pi_cli.run_task (and the Pi backend through Agentic_backend.run_task) stops a Pi that prints no agent event within 120 s, and reports a run that ended before its first agent event as Failed "Pi start-up failure: <kind>: ..." (no-start, start-hang, empty-prompt). A Pi that exited 0 after printing only its session header used to be a Success with empty text.
  • A Pi task with mcp_servers used to fail with "Pi backend does not support MCP server injection"; it now runs with those servers (Pi >= 1.3.0; older or unknown versions are refused before start). Such runs always pass --no-approve, also for mutable tasks. A task timeout that expires before Pi starts keeps its Timeout status.
  • The YAML pi adapter delegates tasks with mcp_servers to Pi_cli instead of running them with --no-mcp (MR !15). Its tasks without MCP servers are unchanged: no start-up watchdog, no start-failure mapping, and its existing re-run after "stream ended without finish_reason".

Added

  • Pi_cli.run_task_guarded returns the result together with the typed start failure (Pi_startup.failure: kind, exit code, stderr tail, timings, event types seen), whether a provider call may have been made, every attempt, and the provenance (Pi version, argv, SHA-256 of the exact mcp.json). An optional caller-owned retry (Pi_startup.retry: attempts, exponential backoff) applies only to start failures, inside the task timeout; an attempt that reached Pi's agent loop is never repeated.
  • MCP server injection for Pi (Pi_mcp): servers are written to mcp.json in a private agent directory passed as PI_CODING_AGENT_DIR (the host's agent directory stays reachable through links, except its mcp.json), with -e builtin:mcp (and builtin:codemode / builtin:tool-search when needed) before --no-extensions. Per-server exposure (direct, deferred, codemode, hidden), toolExposure patterns, cwd, timeout, enabled and description; read-only tasks allow mcp__<server>__*; broker_only passes --no-builtin-tools. Entries Pi would silently skip are refused. Pi_cli.command_for_spec builds the argv.
  • Backend_process.run_process and run_task_with take ?extra_env and a ?startup_watch watchdog.

0.3.4 — 2026-10-20

The Pi backend now calls the per-line output callback that the interface already documented.

Fixed

  • Pi forwards raw output lines to on_raw_line. Pi_cli.run_task (and so Agentic_backend.run_task on the Pi backend) accepted the optional ?on_raw_line callback and dropped it, so a host that asked for each stdout line of a Pi run received none. It now passes the callback to the shared Backend_process runner as on_stdout, which calls it once per stdout line in the order Pi printed it. The task result (stdout, agent_text, cost, status) is unchanged, a run without a callback behaves as before, and the namespace and MCP refusals still return before any process or callback runs. (MR !13)

0.3.3 — 2026-10-19

Pi usage now covers the whole run instead of its last response.

Behaviour change for hosts: task_result.cost for the Pi backend (both Pi_cli and the YAML pi adapter) grows for every multi-turn run, often by a large factor for agentic runs of many tool turns, because 0.3.2 and earlier reported only the final provider request. Spend totals and budgets computed from it were under-counted and will step up on upgrade. Timed-out and failed Pi results also include the response that was cut.

Fixed

  • Pi usage is summed over the whole run. Pi_cli.parse_json_events (used by Pi_cli.run_task and the YAML pi adapter) returned the usage of the last assistant message_end only. Pi reports usage per provider response (Pi 0.85.1 and 1.3.0; Pi's own session totals sum them), so a multi-turn run reported only its final request: on a three-request capture, 2700 of 5400 input tokens and half the USD. cost is now the sum over every assistant message_end, every tool-result message_end that carries usage (nested model work), every compaction_end result, and every entry_appended usage entry (Pi 1.3.0's cache warmer, on by default, refreshes provider caches during long gaps of a run). When the stream stops inside a response (timeout, signal), that response's last non-zero message_update usage is added; it is partial. turn_end and agent_end repeat counted messages and are ignored. Each field is summed over the events that report it. Branch-summary usage, which Pi does not emit in the stream, is not counted. The answer text and observed route still come from the last assistant message. (MR !11)

0.3.2 — 2026-10-19

Terminal process evidence is retained on every outcome, the stdin prompt is bounded by the task timeout, and the Codex model catalogue is refreshed.

Behaviour change for hosts: task_result.cost may now be Some on Failed and Timeout results built by Backend_process.run_process (nonzero exit, signal, timeout), where it was None. That usage is partial: it covers only what the CLI printed before it failed or was stopped. Hosts that add cost into spend totals should count it on every outcome. Stdout and stderr are no longer size-limited. The Codex fast/smart/deep tier aliases now map to different models.

Changed

  • cost on failed and timed-out results. run_process parses usage from the retained stdout on every outcome, so Failed (nonzero exit, signal) and Timeout results carry Some cost when the CLI printed usage before stopping; in 0.3.1 they carried None. Pi's truncated-output and terminal-error Failed results already carried complete usage in 0.3.1 (Pi_cli.normalize_terminal_result keeps it) and are unchanged.
  • Codex model catalogue and tier aliases. The static Codex model list (Codex_cli.models and src/adapters/codex.yaml) now starts with gpt-6.1-sol, gpt-6-luna and gpt-6-astra. Backend_tier.map_model_for_backend maps Codex fast to gpt-6-luna, smart to gpt-6.1-sol and deep to gpt-6-astra (previously gpt-5.1-codex-mini, gpt-5.3-codex and gpt-5.1-codex-max). Explicit model ids pass through unchanged.

Fixed

  • Terminal process evidence is retained on every outcome. Backend_process.run_process now reads stdout and stderr in chunks as they arrive instead of Buf_read.take_all, so a timed-out task returns the stdout printed so far (previously empty on the non-streaming path used by Pi, Codex and YAML adapters). After a timeout the pipes are drained while the child receives SIGTERM, then SIGKILL after 2 s, within a 2.5 s bound; the read ends are closed if a detached descendant still holds them. run_task_with therefore recovers the session id from a timed-out run, so a retained Pi session can be resumed and the host keeps Pi's lifecycle events. parse_cost runs on retained stdout for nonzero exit, signal and timeout too (usage on those outcomes is partial); parser and on_stdout exceptions, and parse_session_id exceptions in run_task_with, no longer escape. on_stdout receives a final unterminated line once. Stdout above 128 MiB, and a stderr line above 16 MiB, no longer raise Buffer_limit_exceeded; both streams are retained without a cap. Ported from the process-runner part of MR !4.
  • run_process timeout now covers the stdin prompt. The prompt was written before the timeout started, with the parent still holding the pipe's read end: a child that exited or hung without consuming a prompt larger than the pipe buffer (64 KiB on Linux), or that wrote a pipe buffer of output before reading its prompt, blocked run_process indefinitely. Stdin is now written concurrently with output capture inside the timeout, and a child that stops reading only loses the rest of its stdin. The stdout/stderr read ends are closed when run_process returns instead of at the end of the caller's switch.

0.3.1 — 2026-10-16

Pi lifecycle metadata, truncated-output classification and MCP isolation for Pi >= 1.0.4. Additive API; Pi_cli.run_task and the YAML pi adapter now probe pi --version before each task.

Added

  • Pi lifecycle metadata. Pi_lifecycle.parse (also Pi_cli.parse_lifecycle) reduces Pi's compaction_start/compaction_end, auto_retry_start/ auto_retry_end and summarization_retry_* events to bounded metadata: counts, at most 64 events (most recent kept, events_dropped counts the rest), line number, the timestamp of the last completed message, closed reason/source vocabularies, attempts, delays, token counts before/after compaction, success/aborted/willRetry flags, the final stopReason, and for errors a closed class, byte length, SHA-256 and a redacted excerpt of at most 160 bytes. Message text, tool data and summaries are never retained. Pi_lifecycle.to_json emits cabal.pi-lifecycle@1; ~include_error_excerpts:false drops the excerpts. Pi 0.85.1 and 1.3.0 shapes are both accepted.
  • Pi_cli.is_truncated_output and Pi_cli.truncated_output_reason.
  • Pi_cli.mcp_isolation_args, Pi_cli.probe_version and Pi_cli.command_for_version.

Changed

  • Pi_cli.run_task and the YAML pi adapter probe pi --version and pass --no-mcp to Pi >= 1.0.4 (and when the version is unknown). Pi 0.99.0 to 1.0.3 have built-in MCP without --no-mcp and are refused. Pi < 0.99.0 (e.g. 0.85.1, which rejects unknown options) runs without the flag. Pi_cli.build_command is unchanged and documented as not MCP-isolated.
  • Pi_cli.normalize_terminal_result reports a final stopReason = "length" (Pi exits 0 in --mode json) or Pi 1.3.0's print-mode "Response was truncated" exit as Failed "Pi terminal error: truncated-output: ..." instead of a success or a generic exit failure.
  • Pi terminal error categories may now also be context-overflow, provider-overloaded or provider-timeout (previously provider-error).

0.3.0 — 2026-10-16

This release brings the Pi, Codex and session-recovery work that CWR 0.22 production builds used from the pre-0.2.0 fix/pi-provider-errors line onto the 0.2.0 baseline, so one tagged Cabal carries both the validated Codex usage parser of 0.2.0 and the Pi session behavior CWR relies on.

Breaking

  • Backend_types.task_spec gains retain_session : bool (default false). Code that builds the record literally, or destructures it listing every field without ; _, must add the field; callers of Backend_types.make_task_spec are unaffected.
  • New dependency on digestif and a new C stub (cabal_nofollow_stubs.c) used by the structured-output file path.
  • The pi capability descriptor now reports session resume support.

Changed

  • Pi_cli.run_task no longer re-runs a task by itself when Pi's stream ends without a finish reason; recovery belongs to the host through Agentic_backend.resume_after_transient_failure. The YAML-built pi backend that Adapter_loader.register_all registers still re-runs the whole prompt once in that case.

Added

  • Fresh Pi session retention. make_task_spec ~retain_session:true omits --no-session for a fresh Pi task, so Pi writes its session JSONL into the session directory the host provides. It never selects a prior session; resume_session_id still maps to --session.
  • Retained-session resume after transport failures. Agentic_backend.resume_after_transient_failure returns a resume task spec only for a recognised transient failure on a backend that declares session resume. Pi_cli now declares it. Backend_types.generic_resume_prompt exposes the role-neutral recovery instruction. Backends obtained from the YAML adapters that Adapter_loader.register_all registers (including pi, claude-code and codex) still report no resume support; hosts that want resume must register the hand-written modules (Pi_cli, Claude_code, Codex_cli). The transient-failure match also searches the task's stdout transcript, so a non-transient failure whose transcript quotes a network error can be classified transient.
  • Provenance-bound structured output. Json_schema_enforcer.run_task_with_receipt validates native or host-designated structured output locally and returns a Structured_output.receipt.
  • Externally sandboxed Codex. With CABAL_CODEX_EXTERNAL_SANDBOX=1, Codex_cli runs mutable tasks in Codex's externally sandboxed mode instead of nested workspace-write sandboxing; the host then owns the sandbox boundary. Read-only tasks keep -s read-only. The YAML-built codex backend ignores the variable.

Fixed

  • Pi tasks without retention or resume pass --no-session, so Pi no longer derives a session directory name from long worktree paths.
  • Pi_cli.normalize_terminal_result turns a zero exit whose final assistant event has stopReason = "error" into a failed task with a redacted provider category. The raw provider message remains in stdout; see Pi_cli.normalize_terminal_result.

Earlier changes (0.2.0 and before)

Added

  • Per-backend models enumeration (non-breaking, additive). Every adapter implementing Agentic_backend.S now exposes a models : string list member listing the model ids it accepts via its CLI's --model (or equivalent) flag. The data is surfaced two ways: Agentic_backend.models : t -> string list for callers that already hold a backend handle, and Registry.list_models : string -> string list option for callers that only know the backend id. Yaml_adapter config gains a models : string list field populated from a top-level models: sequence in the YAML file; missing or malformed sequences fall back to [] (the documented "let the adapter pick" sentinel). Existing call sites that pass ~model:None to Backend_types.make_task_spec continue to work unchanged.

    The same surface now has a dynamic-probe layer on top: Agentic_backend.S gained an optional models_probe : (sw:_ -> env:_ -> (string list, string) result) option. When Adapter_loader.register_all is called with ~sw and ~env, each registered backend's probe is invoked once under exception protection; a non-empty Ok result replaces the static list for that backend, while any Error _, exception, or Ok [] cleanly falls back to the static declaration. The resolved view is exposed via Registry.resolved_models : string -> (string list * Registry.models_source) option, with models_source = Probe | Static | Hybrid documenting the origin (Hybrid is reserved and not yet emitted). Registry.list_models keeps its existing return type and is now Option.map fst @@ resolved_models. Among the built-in adapters only opencode ships a probe today (parsing opencode models); claude-code, codex, gemini-cli, and copilot-cli set models_probe = None until their upstream CLIs expose a non-interactive listing command.

  • Backend_types.task_result.agent_text (non-breaking, additive). Adapters now populate a new agent_text : string field with the agent's final reply, extracted from each CLI's native output format (claude-code JSON envelope, codex JSONL, gemini stream-json, opencode JSON events, copilot plain text). stdout continues to carry the raw bytes produced by the CLI so callers that need backend-specific post-processing retain access. Host applications consuming the response text should switch from Yojson.Safe.from_string result.stdout (or equivalent CLI-specific parsing) to result.agent_text so they stop having to know which CLI ran. Backend_types.make_task_result gains a ?agent_text:string optional argument that defaults to "", so existing call sites continue to compile unchanged. Backend_completer.make now prefers agent_text over stdout for the completion text (with a stdout fallback for backends that have not yet populated agent_text).

Changed

  • Codex JSONL envelopes now fail closed on duplicate structural keys. Usage is accepted only from a unique turn.completed type and unique usage field, and response text only from a unique item.completed envelope with a unique agent_message type and text. Sanitized Codex 0.161.0 fixtures cover cache_write_input_tokens and oversized JSON integers.
  • Yaml_adapter.config.cost_parser is explicit (source-breaking for OCaml record literals; YAML remains backward compatible). The bundled Codex YAML declares codex-jsonl instead of inferring its usage protocol from mutable routing or presentation values. It preserves explicit zero and cache counters only from exactly one valid terminal usage event; malformed or duplicate observations remain unknown. Missing YAML fields default to none. This public record change requires the next Cabal release to be 0.2.0; consumers should use cabal >= 0.2.0 & < 0.3.0 after release, or pin the exact reviewed commit beforehand.
  • Adapter override directory renamed from .epure/ to .cabal/ (breaking). Adapter_loader.register_all now reads user-global overrides from ~/.cabal/adapters/*.yaml and project-local overrides from <project_dir>/.cabal/adapters/*.yaml. Host applications that previously dropped YAML overrides under ~/.epure/adapters/ or <project>/.epure/adapters/ must move them to the new locations. Built-in adapters compiled into the library are unaffected. The rename makes the override path host-neutral now that cabal is consumed beyond Épure.
  • Default managed_namespace is now host-neutral (breaking). Backend_types.default_managed_namespace is now { id = "cabal"; display_name = "Cabal"; config_dir = ".cabal/backend-config" } instead of { id = "epure"; display_name = "Epure"; config_dir = ".epure/backend-config" }. Effects on freshly written artifacts: attribution lines change to Generated by Cabal — do not edit manually, managed comment markers become cabal-managed / cabal-hash, host-owned config files land under .cabal/backend-config/, sidecar files use the .cabal-meta.json suffix, and --force backups use the .cabal-backup suffix. Existing on-disk files with legacy epure-* markers and attribution remain readable: Backend_config_writer recognises the legacy namespace as a fallback and migrates legacy JSON metadata keys (_epure_attribution, _epure-managed, _epure-hash) to the current namespace's headers on next write. Hosts that depended on the old default must construct an explicit Backend_types.managed_namespace and thread it through make_task_spec / setup_project_config_with_options / generate_all_with_options.
  • Cabal-internal environment variables renamed to drop the EPURE_ prefix. CABAL_BACKEND_FAST / CABAL_BACKEND_SMART are the new Backend_tier.init lookups; CABAL_VALIDATOR_PARALLEL_MAX_MEM configures Resource_guardian's memory threshold; and CABAL_MOCK_AGENT_FIXTURES is the new Mock_agent fixtures path. The old EPURE_* names continue to work as deprecated aliases when their CABAL_* counterpart is unset, so existing host-side wrappers are not broken — but new code and CI should set the CABAL_* names.
  • Standalone-repo README.md no longer documents EPURE_NO_COMMIT_CHECK=1 dune ... invocations, which are an Épure-monorepo-specific escape hatch and belong in the monorepo's own docs. Architecture diagram and ownership boundaries reworded so the host is BountyNexus, Épure, tests, or another OCaml app, not "Épure" by default.
  • .mli docstrings generalised: Backend_config_gen.mli, Backend_config_writer.mli, Backend_types.mli, Mock_agent.mli, and Session_event_log module-level docs now describe behaviour as "the host application does X" rather than "Épure does X" when the behaviour is host-neutral. The Epure_owned ownership constructor is retained under its current name for source compatibility, but its docstring clarifies that it denotes a host-owned artifact under the active managed namespace's config_dir. User-facing strings written into generated Copilot CLI instructions and OpenCode comments now read "host application" instead of "Epure".

Security

  • Session NDJSON files now created with mode 0o600 (previously 0o640, group-readable). Post-redaction backend events could leak to any user in the file owner's group on shared/CI machines.
  • Redaction policy hardened. The sensitive_fields set now covers environment, env, env_vars, oauth_token / oauth / jwt / bearer, cookie / set_cookie / session, connection_string / dsn, signature, client_secret, and AWS / GCP credential field names. Pattern-based fallbacks now redact URLs containing embedded user:password@ credentials and JWT-shaped tokens in any field.
  • url and error removed from safe_string_fields. Both legitimately carry credentials (postgres://user:pw@host) or echo them in error messages; the field-name allowlist was masking those leaks.

Fixed

  • Build break: the mli at resource_guardian.mli:127 and three sites in backend_process.ml used the eio-1.x parameterised resource types (_ Eio.Time.clock, _ Eio.Flow.source, _ Eio.Flow.sink). The library targets eio 0.11 where these are zero-arity. Drop the _ and pin eio to >= 0.11 & < 1.0 in dune-project.
  • File-descriptor leak in Backend_config_writer.read_file_opt: the channel was only closed on the success path. Now uses Fun.protect.
  • Race condition in Resource_guardian PID set: register_pid / unregister_pid mutated a mutable int list without synchronisation. Now stored in int list Atomic.t with a CAS-retry helper.
  • Adapter id drift: bundled YAML adapters at src/adapters/{gemini,copilot}.yaml registered as gemini / copilot, while the static descriptors, the hand-written *_cli.ml modules, and backend_config_gen all use the canonical gemini-cli / copilot-cli. Registry.get "gemini-cli" returned None. Both YAMLs renamed.

Added

  • Version / availability probes are now timed. Backend_process.capture_version_output and Backend_process.check_available take ?timeout_seconds (default 5.0) and return promptly on a hung binary instead of freezing registry initialisation indefinitely.
  • Resource_guardian.registered_pids read-only accessor for diagnostics.
  • Backend_types.validated_namespace — opt-in private managed_namespace wrapper. validate_namespace : managed_namespace -> (validated_namespace, string) result is the only constructor; hosts can plumb the type through their own artifact paths to make namespace validation a compile-time obligation.
  • Backend_json_helpers module sharing the json_string_map codec previously duplicated in three *_cli.ml adapters.
  • Backend_config_cleanup module: text-cleanup helpers (remove_dangling_commas_before_closers, strip_managed_mcp_block) extracted from Backend_config_writer.
  • CI matrix now covers ubuntu-latest + macos-latest on OCaml 5.3.0, plus a ubuntu-latest leg on 5.2.0. Adds dune build @doc to every leg and a separate coverage job uploading a bisect_ppx HTML report.
  • Opam metadata: dev-repo, doc, tags fields populated via dune-project. cabal.opam regenerated.

Diagnostics

  • Session_event_log.write_raw_event and read_events now emit Diagnostics.warn on unparseable lines instead of silently dropping them.
  • Adapter_loader.env_mappings_field now emits one Diagnostics.warn per non-string env value, tagged with the YAML source.

Tests added

  • test/test_session_event_log.ml — file mode, dir mode, diagnostics surfacing.
  • test/test_backend_event_redaction.ml — 18 cases covering sensitive fields, value patterns, and nested-container redaction.
  • test/test_backend_config_writer.ml — managed-header round-trip, idempotent writes, hash-mismatch refusal, force backup, invalid-namespace refusal.
  • test/test_validated_namespace.ml — smart-constructor acceptance and rejection cases.
  • test/test_resource_guardian.ml — Domain-based concurrency tests for register/unregister.
  • test/test_backend_process.ml extended with version-probe timeout assertions.
  • test/test_adapter_loader.ml extended with top-level / env-mapping negatives and a diagnostic-capture test.
  • test/test_backend_registry.ml extended with two AC5 static-vs-runtime consistency property tests.

Deferred

  • ocamlformat enforcement — adopting stock ocamlformat would reformat every existing .ml/.mli. The current style is consistent but hand-formatted; a sweeping reformat is out of scope for a bug-fix PR and is better tracked as its own opt-in.
  • Full split of Backend_config_writer — only the cleanup helpers were extracted; further decomposition of sidecar IO / write policy would change the public surface and is left for a follow-up.
  • maintenance_intent opam field — requires (lang dune 3.18); the project pins 3.13.