Skip to content

fix(reporting): period retirement never resolves the period's open issue occurrences #1886

Open

Description

@bokelley

Summary

Period retirement deletes a period's consumer statements and obligation, but it leaves that period's open or acknowledged reporting_issue_lifecycle occurrences open. Nothing can retire them afterwards. As a result:

This is the sibling of #1885. The TypeScript SDK found and fixed the same gap in its port (adcontextprotocol/adcp-client#3654 follow-up), where retirement now resolves the period's open occurrences in the retirement transaction.

Where (next @ 74bbe6f)

Reproduction

  1. A mismatch opens and escalates, and both events are delivered.
  2. Retention retires the period: its statements and obligation are deleted, and the lifecycle row stays open.
  3. No resolved is ever recorded, so the seller's alert never closes.
  4. Seven days later, prune deletes the delivered escalated, and the next sweep records and delivers it again, with the same event_id. This repeats indefinitely (fix(reporting): issue-event retention prune re-escalates still-open occurrences every 7 days #1885).

Suggested fix

Inside the retirement transaction, retire the period's live mismatch occurrences: set issue_state = 'resolved' and retired_at, and call record_issue_transition_on so the outbox gets resolved with its usual same-transaction guarantee. Keep the outbox rows, since undelivered events must still go out. The resolved event renders issue=None. The TypeScript fix does exactly this with its existing per-obligation settle.

Python keys occurrences per chain (issue_key), not per obligation. So the retirement needs to resolve the occurrences whose scope (issue_scopes) names the retired obligation, or whose chain identity matches the retired period.

Add a test: an escalated, delivered occurrence of a period retired by retire_expired_periods gets exactly one resolved, is never re-escalated, and is eventually pruned.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions