Skip to content

feat(agent-ledger): assign close for terminal assignment closure#29

Merged
albertgwo merged 3 commits into
mainfrom
feat/agent-ledger-assign-close
May 15, 2026
Merged

feat(agent-ledger): assign close for terminal assignment closure#29
albertgwo merged 3 commits into
mainfrom
feat/agent-ledger-assign-close

Conversation

@albertgwo
Copy link
Copy Markdown
Contributor

Purpose

Give orchestrators a direct way to mark an assignment completed or abandoned after the work it scoped is done. Before this, an assignment row could only leave active via supersede or by aging out through gc, so there was no durable signal of why the row closed and no way to free its (task, agent) slot without inserting a replacement.

Summary of changes

  • New agent-ledger assign close --assignment <id> [--outcome completed|abandoned] [--reason ...] subcommand under assign, sibling to assign update.
  • Domain layer gains CloseAssignment (single BEGIN IMMEDIATE tx, SELECT-then-UPDATE), sentinels ErrAssignmentNotFound / ErrAssignmentNotActive / ErrInvalidAssignmentCloseOutcome, and ValidAssignmentCloseOutcome.
  • Emits one assignment.closed event; promotes that type from SPEC §12.2 post-MVP to §12.1 MVP.
  • Reason text is stored as sha256 only in metadata.close_reason_sha256 and the event payload, matching the §17 privacy rule.
  • SPEC §11.3 and new §18.3.2 document the transition, exit-code map, and the rejection of outcome=superseded. CHANGELOG entry added.
  • Six tests cover happy path, abandoned, replay conflict, not-found, rejected superseded, and the lifecycle boundary that active intents survive the close.

Changes to review

  • outcome=superseded is rejected at CLI and domain. Confirm the rationale in assign_close.go and SPEC §18.3.2 holds: supersede transitions own the replacement row, so allowing it here would strand the task and break the §11.3.1 chain walk.
  • Replay returns ExitConflict (4) assignment_not_active, not a silent no-op. Check this contract is what downstream adapters want when racing a concurrent supersede.
  • Active intents under a closed assignment are intentionally left alone (pinned by TestAssignClose_LeavesActiveIntentsAlone). Confirm gc and intent aging are the agreed sweep paths.
  • SPEC moves assignment.closed into the MVP event list (§12.1) and removes it from §12.2; downstream consumers keying on those lists may need to react.

@albertgwo albertgwo merged commit 06768ac into main May 15, 2026
7 checks passed
@albertgwo albertgwo deleted the feat/agent-ledger-assign-close branch May 15, 2026 20:29
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.

1 participant