Skip to content

fix: bind queued messages to session owners#452

Merged
chubes4 merged 4 commits into
mainfrom
fix/451-queue-owner-binding
Jul 21, 2026
Merged

fix: bind queued messages to session owners#452
chubes4 merged 4 commits into
mainfrom
fix/451-queue-owner-binding

Conversation

@chubes4

@chubes4 chubes4 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • authorize chat start, enqueue, and queue claims against the existing canonical conversation session store for the supplied workspace and principal
  • serialize transient run and queue read-modify-write operations through an optional generic atomic store capability
  • implement the default mutex with bounded, non-autoloaded rows in the existing WordPress options table using create-only insertion, token plus expiry, conditional stale takeover, transactional token fencing, and token-checked release
  • coordinate explicit workspaces through the canonical main-network options table while preserving workspace state in the existing network option store
  • reserve client run IDs before handlers execute, including requests that do not yet have a session, so duplicate same-owner requests cannot both run
  • fail closed on ownership, lock, storage, and corrupt-state failures while preserving unowned site-local compatibility for existing stores
  • keep the substrate generic with no product coupling, custom production tables, or schema migrations

Concurrency Coverage

  • independent MariaDB connections serialize site and workspace state mutations
  • expired lease holders cannot overwrite a conditional takeover winner
  • foreign-owner and same-owner duplicate run_id races admit exactly one execution
  • pre-session run reservations admit exactly one arbitrary handler and bind the winner to its canonical session
  • double queue claims return every message exactly once without resurrection
  • enqueue concurrent with claim preserves every message exactly once
  • stale takeover, active contention timeout, token-checked release, and exception-safe release
  • corrupt and structurally malformed state fail closed without overwrite
  • single-site workspace fallback and WordPress option-cache coherence

Tests

  • composer test
  • composer phpstan
  • composer validate --strict
  • php tests/agents-chat-ability-smoke.php
  • php tests/default-agents-chat-handler-smoke.php
  • php tests/provider-turn-adapter-smoke.php
  • php tests/chat-run-control-smoke.php
  • php tests/chat-run-control-multisite-smoke.php
  • php tests/bootstrap-version-skew-smoke.php
  • AGENTS_API_WP_ROOT=/var/www/extrachill.com AGENTS_API_DB_HOST=... AGENTS_API_DB_NAME=... AGENTS_API_DB_USER=... AGENTS_API_DB_PASSWORD=... php tests/run-control-option-store-integration.php
  • PHP syntax checks and git diff --check

Fixes #451

@chubes4

chubes4 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Architecture constraint for this fix: no custom tables or migrations, and no parallel session-owner registry when the canonical conversation store can resolve ownership. Start/enqueue/claim should validate against the existing workspace-scoped principal-aware session owner; unsupported ownership resolution must fail closed. Agents API remains generic and Core-oriented.

@chubes4
chubes4 merged commit 2c35d0f into main Jul 21, 2026
3 checks passed
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.

fix: bind queued chat messages to the session owner

1 participant