Skip to content

v0.24.0

Choose a tag to compare

@wajihtba wajihtba released this 06 Nov 00:23
· 49 commits to main since this release

The reliability pass: weft reviewed against its reliability principles (R1–R16) and the Weftbase boundary decisions, every confirmed finding fixed, and the fixes reviewed again for regressions.

Changed (breaking)

  • mcp: the idempotency key is sent under both _meta names again for one transition release — ai.weftbase/idempotency_key and the old dev.weftgo/idempotency_key — so an MCP server that still deduplicates on the old name (a 0.22-era server) keeps deduplicating a 0.24 client's retries; 0.23.0 sent the new name only, and such a server silently lost dedupe. The caller link stays under ai.weftbase/caller alone. Both old names (sent and read) go in the next release.
  • mcp: an imported tool's tools/call whose ctx carries no deadline — no Timeout on the tool or the agent, none on the run — is now bounded at one minute (WR-17); past it the call reads as a lost answer (OUTCOME_UNKNOWN: … for a tool that is not ReplaySafe). A call that ran longer than a minute with no Timeout used to wait for ever on a silent server; give it a Timeout through Policy (or a deadline on the run) to choose another bound. A Timeout through Policy replaces the default whatever its value: Policy(core.Timeout(0)) is the deliberate lift and the call runs with no deadline (the default used to apply under the lift too); an agent's positive Timeout bounds the call as before.
  • thread/sqlite: the lock row's host is the hostname and, on Linux, the PID namespace (myhost#pid:[4026531836]). Two writers that shared a hostname but not a PID namespace — two containers over one bind-mounted database file — could not see each other's pids, so the second read the first's live lock as dead (its pid unseen, or its own PID 1) and took the session over. Another namespace now reads as another host: ErrLocked, never a takeover. What it costs: a restarted container gets a new PID namespace, so a lock row left by a container that died without closing its sessions stays ErrLocked across its restart (it used to be reclaimed) — close sessions on shutdown, run the writer in the host's PID namespace, or sqlite.BreakLock once the old holder is known gone. Lock rows written before this version name a plain hostname and read as another host's too: a session whose writer died under the old version needs BreakLock once after the upgrade. No schema change. jsonl's lock is the kernel's flock, which holds across namespaces, and is unchanged.
  • thread: Session.Custom refuses a kind under the reserved weft/ prefix with ErrReservedKey, writing nothing. It accepted any kind, so application state could write weft/pin — what Pin writes and compaction reads — and forge a session fact. Migration: an application that stored its own state under a weft/… kind writes it under a prefix of its own; entries already on file still load (only new writes are refused).
  • thread/pool: Wrap refuses handler middleware given through ToolOptions — core.WrapHandler, alone or inside a core.ToolOptions bundle — with an error naming it (MustWrap panics). Such middleware sat below the delegation and ran on the bare path only: under a session the delegation answers the call in place of the subagent's handler, so it was skipped without a word. Write instead: core.WrapTools middleware, which runs above the delegation (before the approval boundary) on both paths.

Added

  • otel: the default resource carries weft.record.v (int, 1), the record contract's version (WR-38; record contract §1): it moves only when a record or span changes shape in a way a reader must know, never with the framework version alone.
  • otel: ErrRecordsLost and LossError (see Fixed).
  • core: Agent.ServeCall(ctx, call, key) — one call executed the way the loop executes it, for a server answering calls from outside any run: the tool's Timeout (else the agent's) with the pinned "timed out" / OUTCOME_UNKNOWN texts, the result cap, panic containment, and a handler Call carrying the caller's idempotency key (never invented: "" when the client sent none — and the calls its handler dispatches with CallTool then carry none either, never a key derived from "" that every keyless request would share). A panicking ToolSource is the call's error, never a crash of the serving process (mcp.Serve keeps its own panic guard too: the go-sdk recovers none); a middleware's park after the handler of a tool that is not ReplaySafe ran reads OUTCOME_UNKNOWN, as in a run, never "requires approval". CallTool is unchanged.
  • core: ToolDef.Timeout() — the tool's own Timeout and whether it has one, telling the deliberate Timeout(0) lift from "none set" (what weft/mcp's default call bound reads). Facade: a method of weft.ToolDef.
  • core: Agent.CurrentTools() — copies of the tools a step starting now would resolve calls against: a fresh, validated fetch of the ToolSource when the agent has one (ErrNilTool/ErrDuplicateTool for a malformed snapshot), the registered set otherwise. Tools and Manifest still report the static set. Facade: a method of weft.Agent.
  • thread: ErrDecisionSpent — Decide and DecideSigned refuse with it a decision that repeats exactly one a resume already applied on another line of the tree (see Fixed).
  • thread: ApprovalDecisionEntry.ApprovedBy — the approval class the deciding call's context named (WithApprovedBy), recorded on every decision Decide and DecideSigned write (WR-27); a resume armed by another call, a Resume after a restart, reports it on the resumed call's weft.tool.approved_by. GrantEntry.SchemaSHA256 — the granted tool's schema hash at the mint (below). Both additive, omitempty: no format version change, an older reader ignores them.
  • core/mw: mw.MaxTotal(d) bounds a Retry's whole call, every try and every wait between tries included: no retry (and no wait) starts that would end past d, and the last error is returned wrapped (retrying would pass MaxTotal). Off by default; MaxWait(0)'s unbounded retry-after can now be bounded. The manifest's mw.Retry params carry max_total when set. Facade: mw.MaxTotal.

Fixed

  • otel: a hung Sink stalled the agent run whose records it wrote — its exports are synchronous on the run's goroutine and had no deadline (the Timeout destination option reached only OTLP exporters). Each Sink export is now bounded by the destination's Timeout (default 2 s): past it the export is abandoned and its records counted dropped (the destination's drop counter and throttled WARN), and while it is still stuck every later record is dropped at once, so a run never waits on telemetry for more than about one Timeout. The deadline is the Timeout's alone: a record emitted on a canceled context (a canceled run's tail) is still written. The pipeline's Shutdown never shuts a Sink's exporters down under an export still running: it waits for an abandoned export (bounded by its ctx and one more Timeout) and, when the export is still inside Export after that, leaves the exporters open and returns an error saying so. A Sink whose store may wait on a lock longer than 2 s (SQLite with a long busy_timeout) should set its Timeout to at least that wait.
  • otel: loss at shutdown was silent (WR-36). Pipeline.Shutdown ignored the flush's and the providers' errors, and its flush could spend the whole context, leaving the providers' last export an expired one. It now returns those errors joined, with a *LossError matching ErrRecordsLost (counts per destination) when any record was lost during the pipeline's life or its shutdown; the flush takes at most half of what the context has left (5 s at most), the providers the rest; Install's function logs the error. A thread record whose body a destination could not read is counted lost, no longer as a policy filter. (weft/thread's own held records dropped at Close are thread's and not part of this count.)
  • record contract: heartbeat-derived status (running, interrupted) is a display, never a control fact — no recovery, lease, cancel or retry decision may read it (R8; §4 heartbeat, §6 status).
  • mcp: a tool served by mcp.Serve never saw the client's idempotency key — core.CallFromContext reported no call and the call ids were a per-process counter restarting at mcp_call_1 — so a retried tools/call ran a ReplayKeyed tool twice although the recipe said a deduplicating server applies it once. Its handler now reads the client's key (_meta's ai.weftbase/idempotency_key, else the old name) as Call.IdempotencyKey, its call id derived from the key; a request without a key carries none, and its id names the session (or a random per-Serve instance) and a count. The godoc and the recipe say the agent tool runs the agent as a child run whose parks cannot be decided over MCP.
  • mcp: mcp.Serve ignored a served tool's own Timeout and result cap (its godoc said the SDK bounded the call; it does not). Each call now runs under the tool's Timeout, else the agent's, with the loop's texts (tool "x" timed out after d, or OUTCOME_UNKNOWN: … for a tool that is not ReplaySafe), and its result is capped like the loop's.
  • mcp: a tools/call the go-sdk refused before writing it — the session already closed (ErrClientClosing, -32003) — read as an unknown outcome (OUTCOME_UNKNOWN); it is now a plain mcp: … failure, since nothing was sent (ADR 0032 amendment). ErrServerClosing (-32004) stays unknown: a server also answers it to a request it received.
  • mcp: Tools' godoc said a transport failure reads mcp: <err>; it is an unknown outcome unless the request provably never left (or the tool is ReplaySafe). The package doc's import list named a module, a satellite and internal/adapterkit it does not import.
  • thread: an Edit of a call whose thread/pool delegation was still open (a cut-off turn's delegating call left to the pool) was accepted and its revision approved, so the resume delegated a second time beside the open delegation — under edited arguments, so a new idempotency key no downstream dedupe could catch; the same through DecideSigned. An edit is now refused with ErrStillRunning while the delegation is open or the call's handler is still running, as an approval is. An edit of a dangling call no request entry names (Pending's synthetic r_… request) opened a stub revision without run settings, schema or metadata; it is now ErrInvalidDecision — approve, deny or resolve such a call.
  • thread: an Approver's answer kept the Via it wrote, so one answering Via: "recovery" was taken for the session's own recovery retry and resolved the call alone under Quorum(n) ("grant", "expiry" changed its quorum identity or conflict handling the same way; WR-26). The chain now records every Approver answer with Via "approver", as Decide records "user"; and an approval stored with Via "recovery" counts as the session's own retry only when it follows the recovery ladder's "retry" audit step on a recovery request — an earlier build's spoofed one reads as an approver's.
  • thread: the drift check skipped ToolSource tools (MCP tools served the documented way; WR-16): their requests recorded no schema hash, so an approval ran the call after the source changed the tool's input. The schema is now hashed from the tool as the agent resolves it (Agent.CurrentTools) at the park and compared at the resume; a source that no longer serves the tool denies the call as no longer available. Such calls also parked with Reason "unknown tool" instead of "tool requires approval", and the recovery ladder read a ToolSource tool as ReplayNever with no Reconcile and no RequireApproval — a cut-off ReplaySafe source call parked for a person instead of being redone. Requests recorded before carry no hash and are not checked. The source is read once per entry point (Decide, DecideSigned, Grant, RecoverTurn, a turn or resume as it starts) before the session lock is taken, never under it: a source that reads the session, or waits on the network, neither deadlocks nor holds the session.
  • thread: after a Branch back to a boundary a resume had applied a decision at, the same unsigned decision forwarded again (a reconciler's retry) was recorded and ran the call a second time, while its signed twin was answered as applied (R7, R14). Such a re-forward, unsigned or signed, now fails with the new thread.ErrDecisionSpent — nothing recorded, nothing run, and the caller learns the boundary still waits instead of reading it applied; a deliberate new decision on that line differs from the spent one (another Who or reason; signed, a fresh Request challenge). An identical decision still in force (under Quorum, one approval short) or for a request already resolved stays applied, (nil, nil). A decision a Fork copied still repeats nothing in the fork.
  • thread: OnRequest never fired for an edit's revision, so under Quorum(n) the approvers still needed were never told. A revision a Decide or DecideSigned leaves pending now fires OnRequest on that caller's goroutine, after the append, holding no lock; a panic inside Decide or DecideSigned (the caller's IDs or Clock) still releases the session.
  • thread: session grants matched on tool name and arguments alone (WR-26). A grant now records its tool's schema hash at the mint (s.Grant and ApproveAlways) and matches only while the tool still has it; a grant for a tool the agent did not hold then, or one recorded before the field, matches as before. A grant revoked after it approved a call still waiting at the boundary (a sibling parked for a person) let the resume run the call; the resume now re-validates grant-sourced approvals — such a call reads "DENIED: no decision" and the resume's audit entry (outcome grant_revoked) names the grant.
  • thread: the docs said an identical signed decision delivered again fails ErrReplay (Session.Request, DecideSigned, docs/thread-operations.md §11); it is applied, (nil, nil), and only another decision under a recorded nonce is ErrReplay. Decide's godoc now says an identical bound repeat is applied. The operations guide's warning that the parent's decision chain may approve a delegating call described a gap that is closed; it states the rule. ApprovalDecisionEntry.ArgsSHA256's godoc said "empty when the decider stated none"; Decide requires it, so only chain-step and session denials leave it empty.
  • core: ParkUnknown, the park rule a handler's CallTool reads, the dispatch gate and hook, the inner-dispatch scope and (new) the OnlyTools narrowing leaked into a run started on a tool call's context — a Subagent's child, a Generate in a handler or a middleware: a child parked its own unknown-outcome call (the parent read SUBAGENT_PENDING), a child handler's CallTool was parked by the parent's ParkOn, and a child's middleware CallTool passed the parent's gate. Every run now clears that scope at entry; ParkAllExcept and metadata are inherited as before (ADR 0031's 2026-11-05 amendment).
  • core: a handler's CallTool matched its outer call's scope by call id alone, so a child call reusing the parent's id (call_0) used the parent's gate, hook and key lineage. It matches the whole Call now.
  • core: a CallTool from a WrapTools middleware ran gated but with an empty IdempotencyKey. Under a BeforeDispatch gate it is now refused with ErrNotDispatched before anything runs (the outer call has not started; weft/thread's gate refused it already); with none it carries a key derived from the outer key apart from the handler's inner keys.
  • core: a call of a tool that is not ReplaySafe whose handler answered with no error — or was still running — while a WrapTools middleware then failed, panicked, gave up on it or parked it, or the AfterDispatch hook panicked, read as that layer's plain failure (or parked for an approval that would run it again); the effect had happened. It is now of unknown outcome: two new pinned OUTCOME_UNKNOWN texts, and under ParkUnknown it parks (ADR 0032's 2026-11-05 amendment). A middleware that calls next more than once is judged on every attempt: unknown while any attempt still runs or when any answered with no error, a plain failure only when every attempt failed on its own. A handler's own failure keeps its words; ReplaySafe tools keep the old texts. The Output tool (submit_output) is now ReplaySafe (manifest replay_policy: safe): it has no effect, so a layer's failure after it stays a plain failure the model repairs — never OUTCOME_UNKNOWN or a ParkUnknown park — and mw.RepairJSON closes its cut arguments.
  • core: an edited call (ApproveEdited) that parked again in its resume was reported on RunResult.Pending with the edited arguments, while a plain Approve of it ran the model's original arguments. Pending now shows the transcript's call — what Approve runs; an edit covers one resume. thread: such a call's recovery request is recorded on the edited arguments it ran on, so its retry stays the edit.
  • core: an edited call's EDITED line was added after the result cap, so the result could exceed MaxResultBytes (rule 8). The cap now covers the line and the result together, the line kept whole.
  • core: a handler a WrapTools middleware let go of before it started (a middleware that returned while a goroutine of its own still held next) could start after the loop had settled the call as that middleware's failure — an effect behind an answer that said nothing ran. Once a call's chain returns the call is settled: a later next is refused, under the lock a Timeout already uses (0.22.1).
  • core: a handler that answered right as its Timeout passed could lose its real result to a timeout (a select between two ready cases); an answer the handler gave by the deadline now wins, and one given after it (the handler reacting to the deadline's cancellation) is still a timeout, whichever the select saw first.
  • core: a panicking IdempotencyKeys function was called uncontained (under Stream, a process crash). It is contained: that call fails closed with ErrNotDispatched, the run goes on, one Warn line.
  • core: a panicking ParkSource parked nothing (fail open). Its set is unknown, so the run now parks every call but its own Output answer (park_source), with one Warn line (was Debug).
  • core/mw: RepairJSON closed truncated arguments for every tool, so an effectful tool could run on guessed arguments ("ali" for "alice"). It now closes a cut only for a ReplaySafe tool; any other tool gets lossless repairs only (fence, whitespace) and the model reads INVALID_INPUT.
  • core: godoc drift. BeforeDispatch said a CallTool from the handler does not inherit the gate (it does, as an inner call); Call.IdempotencyKey promised a call "re-run by a resume takes effect once" under the default key, which is run-scoped (a resume is another run: keys that hold across one need IdempotencyKeys, as weft/thread passes); UsageLimit and Subagent now say a child abandoned at its Timeout is counted only up to then; OnlyTools and CallTool say the narrowing holds for a handler's CallTool.
  • thread: a step a shutdown cut off with one call answered and a sibling still running was never recovered. The answered result's tool message sat last on the line and the cut-off check read only the last message, so Send was accepted, the unanswered call was offered as an ordinary request and a skip read DENIED to the model. The check now looks past a step's partial results: the unanswered call is the cut-off run's own, Send is refused with ErrRecoveryRequired, and RecoverTurn parks it as a recovery request. The turn entry's pending lists such a call once (it was listed twice).
  • thread: a shutdown took every error result of a call that is not ReplaySafe out of the cut-off step, including a handler's own definite failure (a declined card), so recovery offered a call whose outcome was known as one that "may have run". Only a result the core marked OUTCOME_UNKNOWN is taken out now; a handler's own error, and a refusal before the handler ran, stay the call's answer.
  • thread: the session's runner never asked the cut-off check (it answered "not cut off" while the runner was alive). A turn whose end could not be written (ErrNotPersisted) or that panicked (ErrTurnPanicked) after dispatching a call of unknown outcome let the send queued behind it — or a steer's follow-up — run at once; its input repaired the call into a synthetic "interrupted" result, and recovery lost the call for good (RecoverTurn then read ErrNotPending, even after a restart). The runner now reads the file on its own transitions: it holds the queue behind such a turn, the turn's error carries ErrRecoveryRequired, Send refuses as after a restart, and RecoverTurn decides the call before the held sends run. A resume item checks the file before it starts too. The check keeps a negative answer while the turns that follow each end with their turn entry, so it costs nothing per queued turn instead of a walk of the whole session (R13); a navigation, a cut-off turn or a recovery makes the next check read the file again.
  • thread: the docs promised that an Append batch survives a crash all or none; jsonl keeps a torn batch's complete prefix lines (a kill inside a large write, a power cut) and drops only the torn last line. A turn's end wrote its turn entry first and the recovery request for a call of unknown outcome after it, so a torn prefix kept the turn without the request: the call was offered as an ordinary request and a skip read DENIED. The turn entry (and a resume's end audit just before it) now goes last in the batch, so any prefix reads as the turn cut off and RecoverTurn decides the call again; Storage.Append, the package docs and docs/thread-operations.md state the real guarantee (sqlite and Memory: all or none; jsonl: a prefix of complete lines, never a gap). No format change; a file reader that expected the turn entry before the requests in a parked turn's batch sees them after it now.
  • thread: a caller whose context ended while RecoverTurn asked a tool's Reconcile had the interrupted ask recorded as reconcile_error, and the call went to a person for good. An interrupted ask is not an answer: RecoverTurn now returns the context's error and writes nothing, and the next RecoverTurn asks again. Several cut-off calls now ask their Reconcile in parallel under one shared 30 s bound (they were asked one after another, each with its own), and a Reconcile that ignores its context is abandoned at the bound and reads as an error instead of holding the recovery.
  • thread: Session.Close's godoc said a turn felled by a Close that gave up records as canceled with the interruption text on its calls. That holds only for a turn with no call of unknown outcome; one felled under ErrShutdown, or whose started calls with effects gave no answer, records as cut off, those calls unanswered with no synthetic text, for RecoverTurn. The godoc says so now.
  • thread/pool: a sync delegation whose child run a shutdown cut off — its parent session closed under thread.ErrShutdown while the pool stayed open — or whose child another writer holds is let go by the pool. Its receipt stayed unsettled, as it should, but the pool kept claiming it for its life: Recover of the reopened parent skipped it as live, Cancel returned nil and did nothing, Wait returned the stale running at once, and Delegated never billed it. Now Recover recovers the child on its own ladder (waiting for a handler the cut-off left running), Cancel recovers and then cancels it, and the receipt settles. A closed pool still keeps such a child for its drain.
  • thread/pool: a delegation's acceptance receipt is written before its child session is created, and a wrapped call's child takes an id derived from the delegating call's idempotency key ("s_" and 32 hex digits; the next free one when the call delegates again). The child used to be created first under a random id: a crash between the two left a session with the parent's lineage that no receipt named — missing from Children and Descendants, the cascade-delete list — and approving the call's recovery created a second child beside it. Now no child exists that no receipt names; a recovery retry of a call whose crash came before its acceptance reaches the same child id (one whose acceptance was written takes the next derived id, the first child still named by its receipt); a child whose creation fails settles its receipt failed at once; and Recover settles an accepted receipt whose child does not exist failed with "child session does not exist and its run never started: nothing ran" (model-visible inside SUBAGENT_FAILED when the call is still parked; ADR 0022 amendment 2026-11-05). Submit and a pool given IDs keep minted ids, now also written in the receipt first. On jsonl a crash inside the child's creation can leave its file with no complete header under the accepted receipt: Recover removes that stub and settles the receipt the same way (jsonl's no-header ErrCorrupt now wraps io.ErrUnexpectedEOF, which no other corruption does), and Children and Descendants list such a child while its receipt reads accepted instead of failing on it; a child still being created on memory or sqlite has no file yet and is not listed. While its child is being created a delegation counts as live — until its registration, or its settlement when the pool closed meanwhile, so a Recover in that window no longer settles it a second time — and Cancel waits for the registration and cancels it (it answered an orphan StateError while Recover skipped the receipt, and the child ran to done).
  • thread/pool: Usage.Delegated covers the whole delegated subtree. A settlement billed the child's turns and summaries but dropped the child's own Delegated, so a budget reading the top session's Delegated (AGENTS.md rule 13) missed every grandchild. A settlement — live, or read back by Recover — now carries the child's turns, summaries and Delegated, each level counted once. An async grandchild that settles after its parent's own settlement is billed in that parent's Delegated only.
  • thread/pool: a panic out of a wrapped tool's handler chain on the bare path (no session) no longer loses the pool's slot: the slot is released and the calling run's slot retaken on the way out. On pool.New(1) every later delegation used to wait for good.
  • thread/pool: Recover's godoc says that it returns once a cut-off child's recovery has started, not when it has parked or answered — the receipt reads unsettled, and Wait reaches the rest — and the pool's godoc says how the writer lease bounds two processes over one storage (each writes only through sessions it holds; the second's write fails with ErrLocked) and what it does not decide (which process recovers).