Skip to content

draftcat 0.16.0: nine fixes and additions - #22

Merged
renezander030 merged 12 commits into
masterfrom
release/v0.16.0
Nov 23, 2026
Merged

renezander030 merged 12 commits into
masterfrom
release/v0.16.0

Conversation

@renezander030

Copy link
Copy Markdown
Owner

Version 0.16.0: nine fixes and additions, each reproduced on the published 0.15.1 binary, with a test that fails before and passes after and an end-to-end run of the built binary.

  1. Refused tool calls leave signed receipts: timed-out approvals, rejected requests and refused consumes. On 0.15.1, 27 refused requests left 10 receipts (a timed-out approval none); on 0.16.0 they leave 22, all of them verified by the 0.15.1 offline verifier, and the anchor verifies over all 22. Test: TestToolGate_RefusalsLeaveSignedReceipts.
  2. Removing an operator ends their standing grants, and a caller's permits end with its tools. On 0.15.1 a standing grant issued by an operator later removed from allowed_users still released calls, and a caller kept consuming a permit for a tool a restart had taken away; on 0.16.0 both go to a human (409 caller.tools, permit unspent, operator told). Test: TestStandingGrantEndsWithItsOperator.
  3. An unknown relay frame no longer closes an open approval as expired. On 0.15.1 a refused relay frame whose verb or approver id held the word "expired" got 410 on a live gate, which the Slack relay treats as final; on 0.16.0 it gets 403, the approval stays open and the next approve goes through. Test: TestRelayChannel_UnknownFrameKeepsGateOpen.
  4. Telegram buttons act only on their own data: no false Paused confirmation, one log line per tap. On 0.15.1 cron:pause: confirmed "Paused", unknown taps were never answered and a newline in callback data forged a log line; on 0.16.0 they answer "Unknown pipeline", every tap is answered and the data is logged quoted on one line. Test: TestCallbackDataIsParsedStrictly.
  5. A tool rule sets its own approval window with approval_window. On 0.15.1 approval_window on a tool rule was accepted and ignored (all calls expired with the global 6 s window); on 0.16.0 windows of 2 s, 6 s and 9 s expired after 1.34 s, 5.36 s and 8.33 s. Test: TestToolGate_RuleApprovalWindow.
  6. A model reply that fails its output schema gets one retry with the validation error. On 0.15.1 one invalid reply failed the run; on 0.16.0 an invalid then valid reply completes after 2 calls, all-invalid fails after 2, and output_retries: 0 keeps one call. Test: TestAIStepRetriesInvalidOutputOnceWithTheValidationError.
  7. **A tool-gate glob can allow a whole directory tree with *. On 0.15.1 src/ denied a file two levels down; on 0.16.0 it is allowed through the real gate hook, src/../secrets is denied and src/ still does not cross a /. Test: TestArgConstraint_DoubleStarGlob.
  8. The oversight report keeps a pipe or line break in a name inside its table cell. On 0.15.1 five report rows broke on a | or newline in a name; on 0.16.0 none do, and report --json and runs --json are byte-identical. Test: TestReportKeepsOddNamesInsideTheirCells.
  9. Anthropic models on OpenRouter can cache a step's fixed instructions (prompt_cache: true). Against a local OpenAI-compatible stub: the fixed instructions go out marked ephemeral, one write then two reads, and the stub-priced cost fell from 0.000581 to 0.000288. A real provider was not called. Test: TestPromptCacheMarksStepInstructionsForAnthropic.

Evidence

  • Each item was reproduced on the published 0.15.1 binary and run end to end on the built 0.16.0 binary; the numbers are in the list above.
  • Every item's test fails on 0.15.1's code and passes on this branch: 9 of 9.
  • go test -short ./... and with -tags voice, go vet, gofmt, golangci-lint 2.5 on the new code (0 issues), npm tests 20/20 and npm pack (0.16.0), all on Linux amd64.
  • The last commit tightens the code under these changes with no behaviour change: --json output, status codes, receipts and policy hashes are unchanged, and new tests pin the relay's response bodies, the whole report and the glob findings.
  • Not run here: native Windows and macOS binaries, the container image, and prompt caching against a real provider (a local stub only). The release workflow builds and checks the platform artifacts before publishing.

Door

Two-way until the release: reverting the merge undoes it. One-way after publishing: npm 0.16.0, the GitHub release and its binaries stay published, and a fix goes out as 0.16.1.

Blast radius

Everyone who updates to 0.16.0 through npm or the release downloads. What changes for them:

  • output_retries defaults to 1: an ai step whose reply fails its output_schema makes one more call. output_retries: 0 keeps failing on the first invalid reply.
  • A tool-gate glob with a /** segment, which matched like /* before, now covers the whole tree.
  • A standing grant ends when its operator leaves telegram.security.allowed_users, and a caller's permit is not spent once a restart took the tool off its list.
  • A relay frame the gate refuses gets 403 instead of 410, so the approval stays open.
  • Refused requests and consumes add signed receipts to the audit store.
  • prompt_cache is off by default; nothing changes until a model sets it.

…ed requests and refused consumes

An approval that timed out wrote no receipt: the action expired in the same transaction and the deny receipt was skipped, so the audit trail showed nothing for it. It now writes its deny receipt with the reason "approval timed out", and the action and the response carry that reason too.

A request the gate refused without deciding left no receipt either: a body that is not valid JSON, an invalid action_id, mode, wait, precondition or expires_at, no tool named, an agent that is not the caller token's name, an action_id already bound to other data, and a consume refused while the gate or agent is frozen, with another binding, a failed precondition or a permit already used. Each now writes a signed v2 receipt (decision deny, operator 0, lifecycle refused, the reason in policy) that receipts verify and the anchor chain cover like any other. Responses are unchanged. A request without an accepted token still writes none.
…ts end with its tools

A standing grant stands for the word of the operator who issued it. A grant now releases calls only while that operator is still in telegram.security.allowed_users, so removing an operator (at a restart) ends the grants they issued: their calls reach a human again and no use is taken. Before, the grant kept approving calls for up to 24 hours although the operator's own taps and commands were already refused.

A caller's permit is consumed only while the caller still lists the tool. A restart that takes a tool off a caller's tools now refuses the consume of a permit approved before it (409, rule caller.tools, the permit stays unspent) and sends the operator the denial notice; before, the caller could still spend it. The docs state that withdrawing a caller takes effect at the next restart, when its waiting calls close as expired and its token is refused, consume included.
The relay callback answered 410 expired for any refused decision whose error text held the word "expired": a decision verb from a newer relay such as card_expired, or an approver id such as expired@example.com. The gate itself stayed open, but a relay that follows hitl/v0 closes its card for good on a 410, so nobody could decide any more and the action timed out.

VerifyDecision now returns relay.ErrExpired for the gate's own expiry, and the callback matches it with errors.Is. Every other refused frame (a heartbeat, a verb outside the v0 set, an unknown approver) gets its 400, 401, 403 or 409 and leaves the approval open; the protocol document now says so for relay authors.
…tion, one log line per tap

A tap that reaches the command loop is now parsed strictly as cron:<pause|resume|run>:<pipeline>, at most Telegram's 64 bytes. A pipeline that is not configured answers Unknown pipeline instead of confirming Paused, Resumed or Starting with whatever name the data carried, and an action no button has, empty data or a tap on an already decided prompt is answered so the client stops waiting.

The callback data is logged quoted and cut at 64 bytes, so a newline in it can no longer write a log line of its own. Approval taps were already bound to their prompt's message, its approvers and the four button words, and stay unchanged.
A tool gate rule takes an optional approval_window, a Go duration, that replaces timeouts.operator_approval for that tool's calls: a short window for a low-risk tool, a longer one for a deploy. It bounds how long the human has to decide, how long a sync request is held, the expires_at the response and a relay dispatch carry, and how long the permit stays consumable. A rule without it keeps operator_approval.

draftcat validate (and the engine at start) refuses a value that is not a positive duration. The window a call was decided under is part of its policy hash, so configurations without approval_window keep their policy hashes.
…lidation error

An ai step whose reply failed output_schema used to fail the run at once. It now asks the model again with the original prompt and the validation error appended. The error names only schema fields from the config, never the rejected reply. Each retry is its own provider call: model policy, budget admission and settlement apply to it, and a refused admission ends the step without sending it.

output_retries on an ai step sets the count: omitted means 1, 0 fails on the first invalid reply, and startup validation rejects values outside 0 to 3. The engine clamps to that range even when validation is skipped, and a schema that does not check is never retried.
A glob segment that is exactly ** now matches any depth: /work/repo/src/** allows every file inside src/, src/**/*.go every .go file under it. Before, glob used path.Match alone, so ** meant the same as * and a rule could never cover nested paths. A pattern without a ** segment is still path.Match exactly, and * still never crosses a /.

A ** glob never matches a value with a .. segment, so src/../secrets cannot walk out of the tree the rule names; the denial says so. draftcat validate checks ** patterns with the same matcher and refuses one that has a .. segment of its own, since it could never match.
…table cell

draftcat report wrote pipeline, step and tool names into its Markdown tables as recorded. A name with a "|" opened an extra column and a line break split the row, so counts landed under the wrong decision and the report read wrong. Step and tool names come from config, an agent harness or a model, so every table cell now escapes "|" as "\|" and turns line breaks into spaces.

draftcat runs prints each step name and reason on one line the same way, so a line break in a name no longer prints what looks like another approval. --json output of both commands is unchanged.
A model with prompt_cache: true sends an AI step's prompt up to its first {{placeholder}} as a text part marked cache_control ephemeral, and the message data as a second part, so runs that start with the same instructions within five minutes read them from Anthropic's prompt cache. It applies to anthropic/ models on OpenRouter and is off by default; every other model and provider is sent the plain prompt string as before, and validate warns where the setting has no effect.

Usage accounting reads prompt_tokens_details.cache_write_tokens next to cached_tokens. Without a provider-reported charge, the cost caps count written tokens at the 1.25x write price and the admission reservation includes that premium; cache reads stay at the full input price. The engine logs the tokens read from and written to the cache for each step.
… too

Removing a tool from a caller now refuses the consume of a permit approved before; that refusal writes the same signed refusal receipt (lifecycle refused, operator 0, the reason in policy) as every other refused consume.
Version 0.16.0 in version.go and the npm package.
- callerDenial holds the shared-token and tool-list check, so a call and a
  consume share one guard.
- The relay gate records its own quorum under its own lock; the decision
  handler only admits the frame and picks the status.
- The update pump reads the approval keyboard's callback data instead of its
  own copy of the four button words.
- config.CheckGlob holds the two glob refusals validate reports, beside the
  matcher.
- The oversight report writes each table through one function that escapes
  every cell.

New tests pin the relay's response bodies, approval taps during a send, the
glob findings, the whole report and the cached instructions on an output
retry. --json output, status codes, receipts and policy hashes are unchanged.
@renezander030
renezander030 merged commit 5c0884a into master Nov 23, 2026
@renezander030
renezander030 deleted the release/v0.16.0 branch November 23, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant