Repository navigation
v0.24.0
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
_metanames again for one transition release —ai.weftbase/idempotency_keyand the olddev.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 underai.weftbase/calleralone. Both old names (sent and read) go in the next release. - mcp: an imported tool's
tools/callwhose ctx carries no deadline — noTimeouton 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 notReplaySafe). A call that ran longer than a minute with noTimeoutused to wait for ever on a silent server; give it aTimeoutthroughPolicy(or a deadline on the run) to choose another bound. ATimeoutthroughPolicyreplaces 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 positiveTimeoutbounds 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 staysErrLockedacross its restart (it used to be reclaimed) — close sessions on shutdown, run the writer in the host's PID namespace, orsqlite.BreakLockonce 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 needsBreakLockonce after the upgrade. No schema change. jsonl's lock is the kernel'sflock, which holds across namespaces, and is unchanged. - thread:
Session.Customrefuses a kind under the reservedweft/prefix withErrReservedKey, writing nothing. It accepted any kind, so application state could writeweft/pin— whatPinwrites and compaction reads — and forge a session fact. Migration: an application that stored its own state under aweft/…kind writes it under a prefix of its own; entries already on file still load (only new writes are refused). - thread/pool:
Wraprefuses handler middleware given throughToolOptions—core.WrapHandler, alone or inside acore.ToolOptionsbundle — with an error naming it (MustWrappanics). 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.WrapToolsmiddleware, 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:
ErrRecordsLostandLossError(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'sTimeout(else the agent's) with the pinned "timed out" /OUTCOME_UNKNOWNtexts, the result cap, panic containment, and a handlerCallcarrying the caller's idempotency key (never invented:""when the client sent none — and the calls its handler dispatches withCallToolthen carry none either, never a key derived from""that every keyless request would share). A panickingToolSourceis the call's error, never a crash of the serving process (mcp.Servekeeps its own panic guard too: the go-sdk recovers none); a middleware's park after the handler of a tool that is notReplaySaferan readsOUTCOME_UNKNOWN, as in a run, never "requires approval".CallToolis unchanged. - core:
ToolDef.Timeout()— the tool's ownTimeoutand whether it has one, telling the deliberateTimeout(0)lift from "none set" (whatweft/mcp's default call bound reads). Facade: a method ofweft.ToolDef. - core:
Agent.CurrentTools()— copies of the tools a step starting now would resolve calls against: a fresh, validated fetch of theToolSourcewhen the agent has one (ErrNilTool/ErrDuplicateToolfor a malformed snapshot), the registered set otherwise.ToolsandManifeststill report the static set. Facade: a method ofweft.Agent. - thread:
ErrDecisionSpent—DecideandDecideSignedrefuse 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 decisionDecideandDecideSignedwrite (WR-27); a resume armed by another call, aResumeafter a restart, reports it on the resumed call'sweft.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 aRetry's whole call, every try and every wait between tries included: no retry (and no wait) starts that would end pastd, 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'smw.Retryparams carrymax_totalwhen set. Facade:mw.MaxTotal.
Fixed
- otel: a hung
Sinkstalled the agent run whose records it wrote — its exports are synchronous on the run's goroutine and had no deadline (theTimeoutdestination option reached only OTLP exporters). Each Sink export is now bounded by the destination'sTimeout(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 oneTimeout. The deadline is theTimeout's alone: a record emitted on a canceled context (a canceled run's tail) is still written. The pipeline'sShutdownnever shuts a Sink's exporters down under an export still running: it waits for an abandoned export (bounded by its ctx and one moreTimeout) and, when the export is still insideExportafter 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 longbusy_timeout) should set itsTimeoutto at least that wait. - otel: loss at shutdown was silent (WR-36).
Pipeline.Shutdownignored 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*LossErrormatchingErrRecordsLost(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. Athreadrecord whose body a destination could not read is counted lost, no longer as a policy filter. (weft/thread's own held records dropped atCloseare 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; §4heartbeat, §6status). - mcp: a tool served by
mcp.Servenever saw the client's idempotency key —core.CallFromContextreported no call and the call ids were a per-process counter restarting atmcp_call_1— so a retriedtools/callran aReplayKeyedtool twice although the recipe said a deduplicating server applies it once. Its handler now reads the client's key (_meta'sai.weftbase/idempotency_key, else the old name) asCall.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-Serveinstance) 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.Serveignored a served tool's ownTimeoutand result cap (its godoc said the SDK bounded the call; it does not). Each call now runs under the tool'sTimeout, else the agent's, with the loop's texts (tool "x" timed out after d, orOUTCOME_UNKNOWN: …for a tool that is notReplaySafe), and its result is capped like the loop's. - mcp: a
tools/callthe go-sdk refused before writing it — the session already closed (ErrClientClosing, -32003) — read as an unknown outcome (OUTCOME_UNKNOWN); it is now a plainmcp: …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 readsmcp: <err>; it is an unknown outcome unless the request provably never left (or the tool isReplaySafe). The package doc's import list named a module, a satellite andinternal/adapterkitit does not import. - thread: an
Editof 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 throughDecideSigned. An edit is now refused withErrStillRunningwhile 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 syntheticr_…request) opened a stub revision without run settings, schema or metadata; it is nowErrInvalidDecision— approve, deny or resolve such a call. - thread: an
Approver's answer kept theViait wrote, so one answeringVia: "recovery"was taken for the session's own recovery retry and resolved the call alone underQuorum(n)("grant", "expiry" changed its quorum identity or conflict handling the same way; WR-26). The chain now records everyApproveranswer withVia"approver", asDeciderecords "user"; and an approval stored withVia"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
ToolSourcetools (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 aToolSourcetool asReplayNeverwith noReconcileand noRequireApproval— a cut-offReplaySafesource 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
Branchback 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 newthread.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 (anotherWhoor reason; signed, a freshRequestchallenge). An identical decision still in force (underQuorum, one approval short) or for a request already resolved stays applied,(nil, nil). A decision aForkcopied still repeats nothing in the fork. - thread:
OnRequestnever fired for an edit's revision, so underQuorum(n)the approvers still needed were never told. A revision aDecideorDecideSignedleaves pending now firesOnRequeston that caller's goroutine, after the append, holding no lock; a panic insideDecideorDecideSigned(the caller'sIDsorClock) 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.GrantandApproveAlways) 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 (outcomegrant_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 isErrReplay.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";Deciderequires it, so only chain-step and session denials leave it empty. - core:
ParkUnknown, the park rule a handler'sCallToolreads, the dispatch gate and hook, the inner-dispatch scope and (new) theOnlyToolsnarrowing leaked into a run started on a tool call's context — aSubagent's child, aGeneratein a handler or a middleware: a child parked its own unknown-outcome call (the parent readSUBAGENT_PENDING), a child handler'sCallToolwas parked by the parent'sParkOn, and a child's middlewareCallToolpassed the parent's gate. Every run now clears that scope at entry;ParkAllExceptand metadata are inherited as before (ADR 0031's 2026-11-05 amendment). - core: a handler's
CallToolmatched 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 wholeCallnow. - core: a
CallToolfrom aWrapToolsmiddleware ran gated but with an emptyIdempotencyKey. Under aBeforeDispatchgate it is now refused withErrNotDispatchedbefore 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
ReplaySafewhose handler answered with no error — or was still running — while aWrapToolsmiddleware then failed, panicked, gave up on it or parked it, or theAfterDispatchhook 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 pinnedOUTCOME_UNKNOWNtexts, and underParkUnknownit parks (ADR 0032's 2026-11-05 amendment). A middleware that callsnextmore 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;ReplaySafetools keep the old texts. TheOutputtool (submit_output) is nowReplaySafe(manifestreplay_policy: safe): it has no effect, so a layer's failure after it stays a plain failure the model repairs — neverOUTCOME_UNKNOWNor aParkUnknownpark — andmw.RepairJSONcloses its cut arguments. - core: an edited call (
ApproveEdited) that parked again in its resume was reported onRunResult.Pendingwith the edited arguments, while a plainApproveof it ran the model's original arguments. Pending now shows the transcript's call — whatApproveruns; 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
EDITEDline was added after the result cap, so the result could exceedMaxResultBytes(rule 8). The cap now covers the line and the result together, the line kept whole. - core: a handler a
WrapToolsmiddleware let go of before it started (a middleware that returned while a goroutine of its own still heldnext) 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 laternextis refused, under the lock aTimeoutalready uses (0.22.1). - core: a handler that answered right as its
Timeoutpassed 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
IdempotencyKeysfunction was called uncontained (underStream, a process crash). It is contained: that call fails closed withErrNotDispatched, the run goes on, one Warn line. - core: a panicking
ParkSourceparked nothing (fail open). Its set is unknown, so the run now parks every call but its ownOutputanswer (park_source), with one Warn line (was Debug). - core/mw:
RepairJSONclosed truncated arguments for every tool, so an effectful tool could run on guessed arguments ("ali"for"alice"). It now closes a cut only for aReplaySafetool; any other tool gets lossless repairs only (fence, whitespace) and the model readsINVALID_INPUT. - core: godoc drift.
BeforeDispatchsaid aCallToolfrom the handler does not inherit the gate (it does, as an inner call);Call.IdempotencyKeypromised 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 needIdempotencyKeys, asweft/threadpasses);UsageLimitandSubagentnow say a child abandoned at itsTimeoutis counted only up to then;OnlyToolsandCallToolsay the narrowing holds for a handler'sCallTool. - 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
Sendwas accepted, the unanswered call was offered as an ordinary request and a skip readDENIEDto the model. The check now looks past a step's partial results: the unanswered call is the cut-off run's own,Sendis refused withErrRecoveryRequired, andRecoverTurnparks it as a recovery request. The turn entry'spendinglists such a call once (it was listed twice). - thread: a shutdown took every error result of a call that is not
ReplaySafeout 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 markedOUTCOME_UNKNOWNis 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 (RecoverTurnthen readErrNotPending, 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 carriesErrRecoveryRequired,Sendrefuses as after a restart, andRecoverTurndecides 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
Appendbatch 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 readDENIED. 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 andRecoverTurndecides 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
RecoverTurnasked a tool'sReconcilehad the interrupted ask recorded asreconcile_error, and the call went to a person for good. An interrupted ask is not an answer:RecoverTurnnow returns the context's error and writes nothing, and the nextRecoverTurnasks again. Several cut-off calls now ask theirReconcilein parallel under one shared 30 s bound (they were asked one after another, each with its own), and aReconcilethat 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 underErrShutdown, or whose started calls with effects gave no answer, records as cut off, those calls unanswered with no synthetic text, forRecoverTurn. The godoc says so now. - thread/pool: a sync delegation whose child run a shutdown cut off — its parent session closed under
thread.ErrShutdownwhile 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:Recoverof the reopened parent skipped it as live,Cancelreturned nil and did nothing,Waitreturned the stalerunningat once, andDelegatednever billed it. NowRecoverrecovers the child on its own ladder (waiting for a handler the cut-off left running),Cancelrecovers 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 fromChildrenandDescendants, 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 receiptfailedat once; andRecoversettles an accepted receipt whose child does not existfailedwith "child session does not exist and its run never started: nothing ran" (model-visible insideSUBAGENT_FAILEDwhen the call is still parked; ADR 0022 amendment 2026-11-05).Submitand a pool givenIDskeep 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:Recoverremoves that stub and settles the receipt the same way (jsonl's no-headerErrCorruptnow wrapsio.ErrUnexpectedEOF, which no other corruption does), andChildrenandDescendantslist 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 aRecoverin that window no longer settles it a second time — andCancelwaits for the registration and cancels it (it answered an orphanStateErrorwhileRecoverskipped the receipt, and the child ran to done). - thread/pool:
Usage.Delegatedcovers the whole delegated subtree. A settlement billed the child's turns and summaries but dropped the child's ownDelegated, so a budget reading the top session'sDelegated(AGENTS.md rule 13) missed every grandchild. A settlement — live, or read back byRecover— now carries the child's turns, summaries andDelegated, each level counted once. An async grandchild that settles after its parent's own settlement is billed in that parent'sDelegatedonly. - 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, andWaitreaches 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 withErrLocked) and what it does not decide (which process recovers).