Agent: Redesign the webhook host to be an explicit unambiguous state machine #2

Merged
StanPonomarev merged 1 commits from agent/issue-1-52b8278c into main 2026-07-21 22:03:45 +02:00
Collaborator

Closes #1

Implementation

Implemented the explicit persisted webhook state machine.

  • Added immutable typed events, JobState, pure next_state(), transition validation, and pure comment rendering.
  • Added migration 003_state_machine.sql with durable receive sequencing, event inbox, listener outbox, no job version column, and legacy backfills.
  • Added transactional receive()/evolve(), duplicate delivery handling, atomic workflow creation/linking, timestamp ownership, atomic listener claims, and receive-order FIFO blocking.
  • Reduced the webhook route to validation and incoming-event persistence; permission checks and command parsing now run asynchronously in receive order.
  • Reworked the worker into control and single-concurrency jobs queues, persisting JobStarted before workflow effects and preventing replay after interruption.
  • Routed workflow progress, workflow/session links, and final bodies through JobReporter events instead of unrestricted job updates.
  • Added comment marker recovery, durable cleanup retries, strict idempotent OpenCode abort handling, restart recovery, tests, and README documentation.

No commit or Git metadata changes were made.

Validation

  • uv sync — succeeded, but the host-provided UV_NO_DEV=1 removed development tools.
  • env -u UV_NO_DEV uv sync — succeeded; installed the 10 development packages required for validation.
  • uv run ruff check . — passed: All checks passed!
  • uv run pyright — passed: 0 errors, 0 warnings, 0 informations
  • uv run pytest — passed: 91 passed in 1.99s
  • git diff --check — passed with no output.
  • docker compose config — not run successfully: Docker is unavailable on this host (docker: command not found).

Created by Agent CI.

Closes #1 ## Implementation Implemented the explicit persisted webhook state machine. - Added immutable typed events, `JobState`, pure `next_state()`, transition validation, and pure comment rendering. - Added migration `003_state_machine.sql` with durable receive sequencing, event inbox, listener outbox, no job version column, and legacy backfills. - Added transactional `receive()`/`evolve()`, duplicate delivery handling, atomic workflow creation/linking, timestamp ownership, atomic listener claims, and receive-order FIFO blocking. - Reduced the webhook route to validation and incoming-event persistence; permission checks and command parsing now run asynchronously in receive order. - Reworked the worker into `control` and single-concurrency `jobs` queues, persisting `JobStarted` before workflow effects and preventing replay after interruption. - Routed workflow progress, workflow/session links, and final bodies through `JobReporter` events instead of unrestricted job updates. - Added comment marker recovery, durable cleanup retries, strict idempotent OpenCode abort handling, restart recovery, tests, and README documentation. No commit or Git metadata changes were made. ## Validation - `uv sync` — succeeded, but the host-provided `UV_NO_DEV=1` removed development tools. - `env -u UV_NO_DEV uv sync` — succeeded; installed the 10 development packages required for validation. - `uv run ruff check .` — passed: `All checks passed!` - `uv run pyright` — passed: `0 errors, 0 warnings, 0 informations` - `uv run pytest` — passed: `91 passed in 1.99s` - `git diff --check` — passed with no output. - `docker compose config` — not run successfully: Docker is unavailable on this host (`docker: command not found`). _Created by Agent CI._
agentci added 1 commit 2026-07-21 16:13:59 +02:00
StanPonomarev approved these changes 2026-07-21 22:03:37 +02:00
StanPonomarev merged commit 18f364b069 into main 2026-07-21 22:03:45 +02:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: StanPonomarev/agentci#2