package cabal
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
sha256=17d60b924371d55eec46ca25005a7fd6e0f5a5117ff048ade568fb54f186aa1c
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 retainsSO_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
--toolsplus--no-approve. Missing or substituted tool/MCP policies fail before Pi starts. - The Daybreak test target declares its executable dependency, so a clean
dune runtestbuilds 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 throughAgentic_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 asFailed "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 aSuccesswith empty text.- A Pi task with
mcp_serversused 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 itsTimeoutstatus. - The YAML
piadapter delegates tasks withmcp_serverstoPi_cliinstead 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_guardedreturns 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 exactmcp.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 tomcp.jsonin a private agent directory passed asPI_CODING_AGENT_DIR(the host's agent directory stays reachable through links, except itsmcp.json), with-e builtin:mcp(andbuiltin:codemode/builtin:tool-searchwhen needed) before--no-extensions. Per-serverexposure(direct, deferred, codemode, hidden),toolExposurepatterns,cwd,timeout,enabledanddescription; read-only tasks allowmcp__<server>__*;broker_onlypasses--no-builtin-tools. Entries Pi would silently skip are refused.Pi_cli.command_for_specbuilds the argv. Backend_process.run_processandrun_task_withtake?extra_envand a?startup_watchwatchdog.
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 soAgentic_backend.run_taskon the Pi backend) accepted the optional?on_raw_linecallback 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 sharedBackend_processrunner ason_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 byPi_cli.run_taskand the YAMLpiadapter) returned the usage of the last assistantmessage_endonly. 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.costis now the sum over every assistantmessage_end, every tool-resultmessage_endthat carries usage (nested model work), everycompaction_endresult, and everyentry_appendedusage 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-zeromessage_updateusage is added; it is partial.turn_endandagent_endrepeat 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
coston failed and timed-out results.run_processparses usage from the retained stdout on every outcome, soFailed(nonzero exit, signal) andTimeoutresults carrySome costwhen the CLI printed usage before stopping; in 0.3.1 they carriedNone. Pi's truncated-output and terminal-errorFailedresults already carried complete usage in 0.3.1 (Pi_cli.normalize_terminal_resultkeeps it) and are unchanged.- Codex model catalogue and tier aliases. The static Codex model list (
Codex_cli.modelsandsrc/adapters/codex.yaml) now starts withgpt-6.1-sol,gpt-6-lunaandgpt-6-astra.Backend_tier.map_model_for_backendmaps Codexfasttogpt-6-luna,smarttogpt-6.1-solanddeeptogpt-6-astra(previouslygpt-5.1-codex-mini,gpt-5.3-codexandgpt-5.1-codex-max). Explicit model ids pass through unchanged.
Fixed
- Terminal process evidence is retained on every outcome.
Backend_process.run_processnow reads stdout and stderr in chunks as they arrive instead ofBuf_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_withtherefore 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_costruns on retained stdout for nonzero exit, signal and timeout too (usage on those outcomes is partial); parser andon_stdoutexceptions, andparse_session_idexceptions inrun_task_with, no longer escape.on_stdoutreceives a final unterminated line once. Stdout above 128 MiB, and a stderr line above 16 MiB, no longer raiseBuffer_limit_exceeded; both streams are retained without a cap. Ported from the process-runner part of MR !4. run_processtimeout 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, blockedrun_processindefinitely. 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 whenrun_processreturns 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(alsoPi_cli.parse_lifecycle) reduces Pi'scompaction_start/compaction_end,auto_retry_start/auto_retry_endandsummarization_retry_*events to bounded metadata: counts, at most 64 events (most recent kept,events_droppedcounts 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 finalstopReason, 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_jsonemitscabal.pi-lifecycle@1;~include_error_excerpts:falsedrops the excerpts. Pi 0.85.1 and 1.3.0 shapes are both accepted. Pi_cli.is_truncated_outputandPi_cli.truncated_output_reason.Pi_cli.mcp_isolation_args,Pi_cli.probe_versionandPi_cli.command_for_version.
Changed
Pi_cli.run_taskand the YAMLpiadapter probepi --versionand pass--no-mcpto Pi >= 1.0.4 (and when the version is unknown). Pi 0.99.0 to 1.0.3 have built-in MCP without--no-mcpand are refused. Pi < 0.99.0 (e.g. 0.85.1, which rejects unknown options) runs without the flag.Pi_cli.build_commandis unchanged and documented as not MCP-isolated.Pi_cli.normalize_terminal_resultreports a finalstopReason = "length"(Pi exits 0 in--mode json) or Pi 1.3.0's print-mode "Response was truncated" exit asFailed "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-overloadedorprovider-timeout(previouslyprovider-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_specgainsretain_session : bool(defaultfalse). Code that builds the record literally, or destructures it listing every field without; _, must add the field; callers ofBackend_types.make_task_specare unaffected.- New dependency on
digestifand a new C stub (cabal_nofollow_stubs.c) used by the structured-output file path. - The
picapability descriptor now reports session resume support.
Changed
Pi_cli.run_taskno longer re-runs a task by itself when Pi's stream ends without a finish reason; recovery belongs to the host throughAgentic_backend.resume_after_transient_failure. The YAML-builtpibackend thatAdapter_loader.register_allregisters still re-runs the whole prompt once in that case.
Added
- Fresh Pi session retention.
make_task_spec ~retain_session:trueomits--no-sessionfor 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_idstill maps to--session. - Retained-session resume after transport failures.
Agentic_backend.resume_after_transient_failurereturns a resume task spec only for a recognised transient failure on a backend that declares session resume.Pi_clinow declares it.Backend_types.generic_resume_promptexposes the role-neutral recovery instruction. Backends obtained from the YAML adapters thatAdapter_loader.register_allregisters (includingpi,claude-codeandcodex) 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_receiptvalidates native or host-designated structured output locally and returns aStructured_output.receipt. - Externally sandboxed Codex. With
CABAL_CODEX_EXTERNAL_SANDBOX=1,Codex_cliruns mutable tasks in Codex's externally sandboxed mode instead of nestedworkspace-writesandboxing; the host then owns the sandbox boundary. Read-only tasks keep-s read-only. The YAML-builtcodexbackend 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_resultturns a zero exit whose final assistant event hasstopReason = "error"into a failed task with a redacted provider category. The raw provider message remains instdout; seePi_cli.normalize_terminal_result.
Earlier changes (0.2.0 and before)
Added
Per-backend
modelsenumeration (non-breaking, additive). Every adapter implementingAgentic_backend.Snow exposes amodels : string listmember 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 listfor callers that already hold a backend handle, andRegistry.list_models : string -> string list optionfor callers that only know the backend id.Yaml_adapterconfig gains amodels : string listfield populated from a top-levelmodels: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:NonetoBackend_types.make_task_speccontinue to work unchanged.The same surface now has a dynamic-probe layer on top:
Agentic_backend.Sgained an optionalmodels_probe : (sw:_ -> env:_ -> (string list, string) result) option. WhenAdapter_loader.register_allis called with~swand~env, each registered backend's probe is invoked once under exception protection; a non-emptyOkresult replaces the static list for that backend, while anyError _, exception, orOk []cleanly falls back to the static declaration. The resolved view is exposed viaRegistry.resolved_models : string -> (string list * Registry.models_source) option, withmodels_source = Probe | Static | Hybriddocumenting the origin (Hybridis reserved and not yet emitted).Registry.list_modelskeeps its existing return type and is nowOption.map fst @@ resolved_models. Among the built-in adapters onlyopencodeships a probe today (parsingopencode models);claude-code,codex,gemini-cli, andcopilot-clisetmodels_probe = Noneuntil their upstream CLIs expose a non-interactive listing command.Backend_types.task_result.agent_text(non-breaking, additive). Adapters now populate a newagent_text : stringfield 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).stdoutcontinues 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 fromYojson.Safe.from_string result.stdout(or equivalent CLI-specific parsing) toresult.agent_textso they stop having to know which CLI ran.Backend_types.make_task_resultgains a?agent_text:stringoptional argument that defaults to"", so existing call sites continue to compile unchanged.Backend_completer.makenow prefersagent_textoverstdoutfor the completion text (with astdoutfallback for backends that have not yet populatedagent_text).
Changed
- Codex JSONL envelopes now fail closed on duplicate structural keys. Usage is accepted only from a unique
turn.completedtype and uniqueusagefield, and response text only from a uniqueitem.completedenvelope with a uniqueagent_messagetype and text. Sanitized Codex 0.161.0 fixtures covercache_write_input_tokensand oversized JSON integers. Yaml_adapter.config.cost_parseris explicit (source-breaking for OCaml record literals; YAML remains backward compatible). The bundled Codex YAML declarescodex-jsonlinstead 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 tonone. This public record change requires the next Cabal release to be0.2.0; consumers should usecabal >= 0.2.0 & < 0.3.0after release, or pin the exact reviewed commit beforehand.- Adapter override directory renamed from
.epure/to.cabal/(breaking).Adapter_loader.register_allnow reads user-global overrides from~/.cabal/adapters/*.yamland 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_namespaceis now host-neutral (breaking).Backend_types.default_managed_namespaceis 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 toGenerated by Cabal — do not edit manually, managed comment markers becomecabal-managed/cabal-hash, host-owned config files land under.cabal/backend-config/, sidecar files use the.cabal-meta.jsonsuffix, and--forcebackups use the.cabal-backupsuffix. Existing on-disk files with legacyepure-*markers and attribution remain readable:Backend_config_writerrecognises 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 explicitBackend_types.managed_namespaceand thread it throughmake_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_SMARTare the newBackend_tier.initlookups;CABAL_VALIDATOR_PARALLEL_MAX_MEMconfiguresResource_guardian's memory threshold; andCABAL_MOCK_AGENT_FIXTURESis the newMock_agentfixtures path. The oldEPURE_*names continue to work as deprecated aliases when theirCABAL_*counterpart is unset, so existing host-side wrappers are not broken — but new code and CI should set theCABAL_*names. - Standalone-repo
README.mdno longer documentsEPURE_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 isBountyNexus, Épure, tests, or another OCaml app, not "Épure" by default. .mlidocstrings generalised:Backend_config_gen.mli,Backend_config_writer.mli,Backend_types.mli,Mock_agent.mli, andSession_event_logmodule-level docs now describe behaviour as "the host application does X" rather than "Épure does X" when the behaviour is host-neutral. TheEpure_ownedownership 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'sconfig_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(previously0o640, 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_fieldsset now coversenvironment,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 embeddeduser:password@credentials and JWT-shaped tokens in any field. urlanderrorremoved fromsafe_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
mliatresource_guardian.mli:127and three sites inbackend_process.mlused 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.0indune-project. - File-descriptor leak in
Backend_config_writer.read_file_opt: the channel was only closed on the success path. Now usesFun.protect. - Race condition in
Resource_guardianPID set:register_pid/unregister_pidmutated amutable int listwithout synchronisation. Now stored inint list Atomic.twith a CAS-retry helper. - Adapter id drift: bundled YAML adapters at
src/adapters/{gemini,copilot}.yamlregistered asgemini/copilot, while the static descriptors, the hand-written*_cli.mlmodules, andbackend_config_genall use the canonicalgemini-cli/copilot-cli.Registry.get "gemini-cli"returnedNone. Both YAMLs renamed.
Added
- Version / availability probes are now timed.
Backend_process.capture_version_outputandBackend_process.check_availabletake?timeout_seconds(default 5.0) and return promptly on a hung binary instead of freezing registry initialisation indefinitely. Resource_guardian.registered_pidsread-only accessor for diagnostics.Backend_types.validated_namespace— opt-inprivate managed_namespacewrapper.validate_namespace : managed_namespace -> (validated_namespace, string) resultis the only constructor; hosts can plumb the type through their own artifact paths to make namespace validation a compile-time obligation.Backend_json_helpersmodule sharing thejson_string_mapcodec previously duplicated in three*_cli.mladapters.Backend_config_cleanupmodule: text-cleanup helpers (remove_dangling_commas_before_closers,strip_managed_mcp_block) extracted fromBackend_config_writer.- CI matrix now covers
ubuntu-latest+macos-lateston OCaml 5.3.0, plus aubuntu-latestleg on 5.2.0. Addsdune build @docto every leg and a separate coverage job uploading abisect_ppxHTML report. - Opam metadata:
dev-repo,doc,tagsfields populated viadune-project.cabal.opamregenerated.
Diagnostics
Session_event_log.write_raw_eventandread_eventsnow emitDiagnostics.warnon unparseable lines instead of silently dropping them.Adapter_loader.env_mappings_fieldnow emits oneDiagnostics.warnper 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,forcebackup, 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.mlextended with version-probe timeout assertions.test/test_adapter_loader.mlextended with top-level / env-mapping negatives and a diagnostic-capture test.test/test_backend_registry.mlextended 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_intentopam field — requires(lang dune 3.18); the project pins 3.13.