Skip to content

fix: make A2A task admission atomic - #2792

Merged
EItanya merged 4 commits into
mainfrom
fix/atomic-task-admission
Sep 10, 2026
Merged

EItanya merged 4 commits into
mainfrom
fix/atomic-task-admission

Conversation

@EItanya

@EItanya EItanya commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Concurrent replies to a waiting A2A task can both pass gateway state checks and dispatch. Move continuation admission into one PostgreSQL transaction so only one reply advances the task; identical retries return the stored task without another dispatch, and conflicting reuse of a message ID fails.

The transaction checks lifecycle, checkpoint, and active-task barriers while archiving the question and reply and recording the retry hash. Initial-message retries resolve before readiness checks, so accepted requests remain readable after suspension. Explicit Suspend uses the same instance lock and rejects active tasks. Forked histories preserve retry receipts only through the checkpoint boundary.

This is part 1 of the concurrency work. Lifecycle generations/recovery and shared execution remain separate. Admission deduplication does not provide crash-safe dispatch. The unreleased migration 1 constraint is updated to permit retry hashes on reply events; this assumes a fresh database.

Validation:

  • Race tests passed for database, gateway, migrations, agentinstance, checkpoint, scheduler, MCP, and gRPC packages, independently of the later lifecycle changes.
  • Real PostgreSQL tests cover concurrent replies, retry conflicts, rollback at admission barriers, suspended retries, and checkpoint/fork receipt inheritance; migration and inline SQL preparation checks passed.
  • Focused database/gateway/migrations lint reports zero issues; formatting and diff checks pass.

@github-actions github-actions Bot added the bug Something isn't working label Sep 10, 2026
@EItanya
EItanya marked this pull request as ready for review September 10, 2026 16:26
@EItanya
EItanya requested a review from a team as a code owner September 10, 2026 16:26
@EItanya
EItanya force-pushed the fix/atomic-task-admission branch from 1cdd7a0 to e8db451 Compare September 10, 2026 16:29
@EItanya
EItanya merged commit 4a91c27 into main Sep 10, 2026
27 of 28 checks passed
@EItanya
EItanya deleted the fix/atomic-task-admission branch September 10, 2026 17:39
EItanya added a commit that referenced this pull request Sep 20, 2026
Concurrent lifecycle retries can issue duplicate Actor mutations, and
delayed callers can act after a newer operation. Keep the current
lifecycle generation and non-expiring executor claim on the
AgentInstance row. Claim and completion check that identity; superseded
observers return an explicit conflict without touching the runtime.

A successful joined caller observes current instance state while its
generation remains current. Remove the separate operation-history table,
serialized input/result copies, and historical lifecycle result
retention. Create/Fork retries preserve instance identity and return
current state without provisioning again.

Deletion leaves a DELETED tombstone that reserves the owner/request ID,
revokes shares, and releases runtime revision and checkpoint pins. Fork
source identity survives checkpoint deletion; a generated foreign-key
column pins that checkpoint only while the instance is live. Normal
instance/task/share access excludes tombstones, and reused creation
request IDs cannot recreate deleted compute.

Read-only preparation may retry before execution is claimed. Ambiguous
runtime failures and failed database completion retain the claim and
resource pins, blocking conflicting lifecycle operations including
Delete. Preserve pinned fork creation and per-Actor egress policy setup
before publishing READY.

Part 2 follows #2792. Shared A2A/checkpoint execution and multi-replica
observation remain later work; live Substrate settlement has not been
verified. This requires a clean database and no overlapping older
lifecycle binaries.

Validation:
- Core internal/package suites, including SQL preparation and migration
Up/Down.
- PostgreSQL-backed lifecycle and store race tests covering exclusive
claims, stale/ABA completions, delayed observers, ambiguous mutations,
failed database completion, and egress failures.
- Tombstone request reuse, task/share access, concurrent share
creation/deletion, and checkpoint/revision pin cleanup.
- Authenticated lifecycle service integration with real PostgreSQL and
controlled Actor responses.
- Go lint and diff checks.

The unreleased schema is consolidated in migration 1. The existing CI
migration-immutability check rejects that edit; no forward migration or
policy bypass is included.

Design and implementation tracker are updated locally and remain
uncommitted.

---------

Signed-off-by: Eitan Yarmush <[email protected]>
alexdarbyshire pushed a commit to alexdarbyshire/kagent that referenced this pull request Oct 5, 2026
Concurrent lifecycle retries can issue duplicate Actor mutations, and
delayed callers can act after a newer operation. Keep the current
lifecycle generation and non-expiring executor claim on the
AgentInstance row. Claim and completion check that identity; superseded
observers return an explicit conflict without touching the runtime.

A successful joined caller observes current instance state while its
generation remains current. Remove the separate operation-history table,
serialized input/result copies, and historical lifecycle result
retention. Create/Fork retries preserve instance identity and return
current state without provisioning again.

Deletion leaves a DELETED tombstone that reserves the owner/request ID,
revokes shares, and releases runtime revision and checkpoint pins. Fork
source identity survives checkpoint deletion; a generated foreign-key
column pins that checkpoint only while the instance is live. Normal
instance/task/share access excludes tombstones, and reused creation
request IDs cannot recreate deleted compute.

Read-only preparation may retry before execution is claimed. Ambiguous
runtime failures and failed database completion retain the claim and
resource pins, blocking conflicting lifecycle operations including
Delete. Preserve pinned fork creation and per-Actor egress policy setup
before publishing READY.

Part 2 follows kagent-dev#2792. Shared A2A/checkpoint execution and multi-replica
observation remain later work; live Substrate settlement has not been
verified. This requires a clean database and no overlapping older
lifecycle binaries.

Validation:
- Core internal/package suites, including SQL preparation and migration
Up/Down.
- PostgreSQL-backed lifecycle and store race tests covering exclusive
claims, stale/ABA completions, delayed observers, ambiguous mutations,
failed database completion, and egress failures.
- Tombstone request reuse, task/share access, concurrent share
creation/deletion, and checkpoint/revision pin cleanup.
- Authenticated lifecycle service integration with real PostgreSQL and
controlled Actor responses.
- Go lint and diff checks.

The unreleased schema is consolidated in migration 1. The existing CI
migration-immutability check rejects that edit; no forward migration or
policy bypass is included.

Design and implementation tracker are updated locally and remain
uncommitted.

---------

Signed-off-by: Eitan Yarmush <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant