Skip to content

fix(runtime-usage): align post-success accounting with public contract #319

Description

@Yuiham

Follow-up from PR #309 after merge. Public contract: #318.

Context

PR #309 added runtime usage quota gate and metering support. A post-merge review against #318 found two remaining contract/behavior gaps that should be handled explicitly.

Follow-ups

  1. Terminal 404 handling after success

#318 says reservation_not_found / reservation_not_committed should become terminal reconciliation once the mem9 operation already succeeded and there is no valid local commit-pending state. Current code maps quota finalization 404 through UnavailableError, and metering 404 through retryable delivery failure, which can leave rows retrying forever.

Expected direction:

  • distinguish runtime usage 404 responses from transient availability errors
  • mark post-success commit 404 as terminal/manual-reconciliation
  • mark metering 404 as terminal when there is no explicit local commit-pending state for the same operation
  1. Async 202 Accepted durability boundary

Async message ingest and async content create reserve before returning 202, then finalize in an in-process goroutine. If the process exits after 202 and before finalization, the accepted operation has no durable pre-success state to commit, release, or reconcile.

Expected direction:

  • either document this release as best-effort with reservation TTL fallback and a product follow-up
  • or add durable pre-success state / durable async queue before returning 202
  1. Bounded post-success context for async success finalization

The async success paths still call AfterMemoryCreateSuccess(context.Background(), ...). If async 202 paths remain in this implementation, use the same detached bounded post-success context helper used by sync paths.

Acceptance criteria

  • Runtime usage 404 responses after successful mem9 work no longer retry forever.
  • Metering 404 handling follows docs(runtime-usage): define public quota and metering API contract #318 depending on local commit-pending state.
  • Async 202 runtime usage durability is either implemented or explicitly documented as product scope.
  • Async success finalization uses a bounded detached context.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions