Skip to content

feat: order lifecycle comply scenarios and tests#382

Merged
bokelley merged 10 commits into
mainfrom
bokelley/order-lifecycle-client
Mar 24, 2026
Merged

feat: order lifecycle comply scenarios and tests#382
bokelley merged 10 commits into
mainfrom
bokelley/order-lifecycle-client

Conversation

@bokelley

@bokelley bokelley commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds compliance testing and schema validation for the order lifecycle management features from adcp#1611.

  • Schema sync: new fields across all media buy schemas (confirmed_at, revision, valid_actions, canceled_*, history, creative_deadline, include_history)
  • Error codes: 6 new codes (INVALID_STATE, NOT_CANCELLABLE, MEDIA_BUY_NOT_FOUND, PACKAGE_NOT_FOUND, VALIDATION_ERROR, BUDGET_EXCEEDED)
  • CanceledBy enum: new buyer | seller type exported
  • Comply scenarios: lifecycle (pause/resume/cancel), terminal state enforcement, package lifecycle, enriched response previews, revision concurrency check (stale revision -> CONFLICT), include_history in get_media_buys
  • Comply observations: advisory observations when agents don't return confirmed_at, revision, or history entries
  • Zod schema tests: lifecycle fields (canceled_by, canceled_at, cancellation_reason, revision, valid_actions, history, creative_deadline)
  • Response validation tests: lifecycle fields on create/get responses, canceled media buy and package fields, history entries
  • Bug fix: || -> ?? for numeric revision extraction (falsy-unsafe for value 0)

Test plan

  • 1326/1326 tests pass locally (0 failures, 2 skipped)
  • TypeScript typecheck clean
  • Pre-push validation passes
  • Code review: all Must Fix and Should Fix addressed
  • Security review: no Must Fix or Should Fix findings
  • CI passes

🤖 Generated with Claude Code

bokelley and others added 5 commits March 23, 2026 20:33
Sync schemas for cancellation, revision tracking, valid_actions, and
history on media buys. Add 6 new error codes and CanceledBy enum.
Update governance middleware for upstream changes (governance_context
now opaque string, buyer_campaign_ref removed from requests).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Regenerate types, keep governanceContext optional for backward compat.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bokelley bokelley requested a review from EmmaLouise2018 March 23, 2026 12:04
bokelley and others added 2 commits March 24, 2026 08:00
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Enrich response_preview with confirmed_at, revision, valid_actions
- Add include_history to get_media_buys status check
- Add revision concurrency test (stale revision -> CONFLICT)
- Add comply observations for confirmed_at, revision, history support
- Deduplicate observations to fire once per compliance run
- Add Zod schema tests for lifecycle fields (canceled_by, history, etc.)
- Add response validation tests for lifecycle and cancellation fields
- Fix: use ?? instead of || for numeric revision extraction

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bokelley bokelley changed the title feat: support order lifecycle management feat: order lifecycle comply scenarios and tests Mar 23, 2026
bokelley and others added 3 commits March 24, 2026 08:20
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… preview

Empty valid_actions array is semantically meaningful for terminal states.
Using || would discard it and fall through to nested value.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Scenarios:
- Add budget mutation step (update_budget with 20% increase, handle BUDGET_EXCEEDED)
- Track revision numbers across steps for monotonicity validation
- Use actual stale revision from earlier step instead of sentinel -1
- Add revision monotonicity check (revisions must increase across operations)
- Test completed terminal state (not just canceled) in testTerminalStateEnforcement
- Fall back to completed media buy test when NOT_CANCELLABLE
- Enrich cancel response with canceled_by and canceled_at fields

Observations:
- Promote valid_actions to severity: warning (buyer agents need this)
- Promote confirmed_at to severity: warning (order confirmation audit trail)
- Add creative_deadline observation (buyers need material deadlines)
- Add canceled_by validation (well-formed cancellation objects)
- Validate history entry shape (timestamp + action required)
- Add sandbox/dry_run confirmation observation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bokelley bokelley merged commit 8ea9139 into main Mar 24, 2026
10 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.

1 participant