Repository navigation
feat: RunnerQ Cloud commands (cancel, retry, run now, reschedule, priority, delete, signal) - #16
Merged
Merged
Conversation
Attempts are now tracked by activity id, so the agent can stop a cancelled activity at once instead of at its next heartbeat. The attempt aborts with claim_lost, as a heartbeat that finds its claim gone does, and counts as a lost claim, not a failure or retry. The method is keyed by a symbol the package doesn't export. A reclaim of an activity still running here supersedes the stale attempt, which no longer removes the new attempt's entries.
A port of runnerq-go's command contract and Postgres implementation: cancel (with cascade), retry and redrive, run now, reschedule, set priority, whole-tree delete and signal, on ids, a bounded filter or an idempotency key. Commands are idempotent through the runnerq_commands ledger, shared with Go: same table, advisory lock key, result JSON and pruning (a week; replay is promised for 24 hours). initialize creates the ledger in an existing database; connect accepts a database without it and checks it when present. Retention now sweeps cancelled trees and treats cancelled as terminal, through tree helpers shared with the delete command. Ports Go's command conformance cases.
With AgentConfig.allowControl (off by default, as in Go) and a CommandStorage, the agent advertises and serves the activities.* commands: per-command field checks, the queue check, foreign ids as skipped not_found, per-item error codes, conflict on a reused command id, and Go's fingerprint (sha256 of the re-marshalled request). An applied cancel interrupts the activity if it runs on this worker.
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.
RunnerQ Cloud commands for the TypeScript SDK, at parity with the Go SDK. With
allowControl: true, a worker's agent advertises and serves the sevenactivities.*commands, so the console no longer shows it as read-only.What's in it
CommandStorage/isCommandStorageand the command types, inrunnerq/storage.PostgresStorage.applyCommand: a port of Go's SQL covering cancel (optionally cascading to descendants), retry (optionally resetting attempts), run_now, reschedule, set_priority, delete and signal.runnerq_commandsledger replays its result.runnerq_commands, column for column Go's, includingidx_runnerq_commands_created.initializecreates the table withIF NOT EXISTS, under the advisory lock shared with Go.verifySchemaaccepts a database without the table. Commands with an id then fail and ask you to runinitialize.allowControl, defaultfalse, matching Go'sAllowControl. Metadata-only mode doesn't affect commands, as in Go.{v: 1, targets}, withidempotency_keyfor signal only.not_found, and the per-item error codes with a status detail.Differences from Go
1e400).created_atuse the database clock, as TS's existing helpers do.Behaviour notes
ActivityStatusgains"cancelled". It's an addition, but exhaustiveswitchstatements in user code may need a new case.allowReuseOnFailurenow also reuses a cancelled activity's idempotency key, as Go does.Tests
test/commands.test.mjs: Go's command conformance cases ported.test/conductor-commands.test.mjs: capabilities, round trips and the immediate interrupt.npm run build,typecheckandformat:checkpass.npm testpasses against Postgres (104 tests).