Repository navigation
draftcat 0.16.0: nine fixes and additions - #22
Merged
Merged
Conversation
…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.
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
TestToolGate_RefusalsLeaveSignedReceipts.TestStandingGrantEndsWithItsOperator.TestRelayChannel_UnknownFrameKeepsGateOpen.TestCallbackDataIsParsedStrictly.TestToolGate_RuleApprovalWindow.TestAIStepRetriesInvalidOutputOnceWithTheValidationError.TestArgConstraint_DoubleStarGlob.TestReportKeepsOddNamesInsideTheirCells.TestPromptCacheMarksStepInstructionsForAnthropic.Evidence
go test -short ./...and with-tags voice,go vet, gofmt, golangci-lint 2.5 on the new code (0 issues), npm tests 20/20 andnpm pack(0.16.0), all on Linux amd64.--jsonoutput, status codes, receipts and policy hashes are unchanged, and new tests pin the relay's response bodies, the whole report and the glob findings.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_retriesdefaults to 1: an ai step whose reply fails itsoutput_schemamakes one more call.output_retries: 0keeps failing on the first invalid reply./**segment, which matched like/*before, now covers the whole tree.telegram.security.allowed_users, and a caller's permit is not spent once a restart took the tool off its list.prompt_cacheis off by default; nothing changes until a model sets it.