Skip to content

fix: keep transient idempotency responses retryable - #1537

Draft
stmr wants to merge 7 commits into
CalloraOrg:mainfrom
stmr:fix/assigned-1499-idempotency-cache-policy
Draft

stmr wants to merge 7 commits into
CalloraOrg:mainfrom
stmr:fix/assigned-1499-idempotency-cache-policy

Conversation

@stmr

@stmr stmr commented Oct 20, 2026 •

Copy link
Copy Markdown

Scope

Closes #1499 without replacing the accepted lease-fencing implementation. Integrated upstream main 22fd831bdd422de4e8b1fac9c058d2332a02a136.

  • Do not cache transient responses or nested reconciliation/in-progress errors; retry can execute again. Preserve deterministic replay, lease ownership, bounded encoded-body inspection and approved response headers.
  • Preserve payer isolation in billing lookups and duplicate-request handling.
  • Verify successful quote-bound on-chain app-token payment before fee signing; consume quote/payment atomically. Explicitly lock the quote before checking expiry after a lock wait. Compare the actual signed-envelope fee to the quote.
  • Restore full type/test contracts and keep SQLite demo startup compatible with PostgreSQL-only migrations.

API change: fee execution requires quoteId, the unchanged inner XDR, and a 64-hex payment transaction hash. Payment must carry the quote's MEMO_HASH. See docs/fee-abstraction.md.

Verification

Verified source tree: ee43bd3754d5acb556586133ebd77dfbac57b908; public head 5da7305c51371d35767218b8680f4abcf26afa77.

  • Local lint, full typecheck and application build passed.
  • Full default suite against isolated native PostgreSQL: 191 suites / 2,844 tests passed, with two pre-existing skips; one snapshot passed. Default PGlite payment route mode also passed all 38 cases.
  • Native PostgreSQL deterministic regression: 4/4 real multi-backend row-lock, rollback, unique-payment-index and expiry-during-wait scenarios passed. Runnable check: tests/integration/feeAbstraction.postgres.mjs.
  • Actual compiled HTTP + SDK signing on native PostgreSQL: two requests blocked in distinct backends; exactly one cryptographically valid signed envelope. Unpaid/mismatched requests, replay and signing-failure rollback/retry checked. Synthetic chain transport only; no real funds.
  • Compiled HTTP middleware/billing smoke: transient recovery, encoded replay, safe headers/cookies, body cap, lease fencing and payer isolation passed. Vercel bundle HTTP smoke passed.
  • Independent Sol-model read-only payment review found no remaining concrete financial blocker. Exact XHigh effort is unconfirmed, not claimed.
  • Exact-tree author-side Linux CI completed: build-and-test (including lint/types, 191 suites / 2,844 tests, bundle smoke) and OpenAPI compatibility passed. Migration-policy failed on the existing ten published-history violations. Overall CI is NOT green. The temporary validation PR was closed unmerged.

Release blockers — remains draft

Published SQL history is unchanged. The unsuppressed migration checker reports ten existing layout/approval violations: duplicate prefixes 26/27, missing payout/quote rollbacks, and missing destructive-approval markers. They require maintainer confirmation of deployed history before a data-safe repair; do not rename or replay financial backfills blindly. Existing deployment-history request.

No migration-policy waiver or maintainer CI configuration change requested. No deployment-readiness, points, award or payment claim.

Cache deterministic outcomes with safe response headers and a bounded
UTF-8 body. Keep reconciliation responses retryable.

Repair full lint/type contracts and preserve SQLite quota rollback.
Published 0026 collisions remain blocked on deployment history; do not
rename applied artifacts or bypass migration policy.

Refs CalloraOrg#1499
@drips-wave

drips-wave Bot commented Oct 20, 2026

Copy link
Copy Markdown

@stmr Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Keep the cache retry transition regression aligned with the current
public ErrorEnvelope contract. Preserve all retry, replay and
deduction-count assertions.
@stmr

stmr commented Oct 20, 2026

Copy link
Copy Markdown
Author

Fixed the reachable author-side full-suite regression in eb3fd3f: the test now reads the current documented error.code envelope, preserving the same-key reconciliation→success→cached-replay and exactly-two-deductions assertions.

Full original Linux workflow on the exact source/tree: build-and-test passed (full lint/type/build,175 suites/2629 tests/1 snapshot,2 existing skipped tests, Vercel bundle), and OpenAPI compatibility passed. migration-policy still fails only on the existing duplicate0026 prefixes (twice) and missing payout rollback. Overall CI is therefore not all green.

The only remaining repair prerequisite is the published-migration deployment-history clarification, needed to avoid replaying a financial backfill or invalidating applied artifacts. No CI-setting change or weakened check is requested. Keeping this draft until the data-safe migration resolution is possible. No merge, deployment, points or payment claimed.

stmr and others added 5 commits October 21, 2026 14:52
Merge accepted upstream main while preserving lease ownership, fencing,
renewal and response completion. Apply transient-response cache policy,
bounded encoded-body inspection and safe header replay.

Enforce billing payer ownership and duplicate-request isolation, restore
canonical error envelopes, repair source contracts and stable history
ETags, and restore seven repaired suites to default CI.

Keep every accepted historical SQL file byte-identical. Only the
unapplied response-header migration moves to the unused 0028 prefix.
Historical migration-policy violations remain explicit and unresolved.

Refs CalloraOrg#1499
Merge accepted upstream main while preserving lease ownership, fencing,
renewal and response completion. Apply transient-response cache policy,
bounded encoded-body inspection and safe header replay.

Enforce billing payer ownership and duplicate-request isolation, restore
canonical error envelopes, repair source contracts and stable history
ETags, and restore seven repaired suites to default CI.

Keep every accepted historical SQL file byte-identical. Only the
unapplied response-header migration moves to the unused 0028 prefix.
Historical migration-policy violations remain explicit and unresolved.

Refs CalloraOrg#1499
Preserve accepted lease fencing while integrating current main.
Lock quotes before expiry checks; verify on-chain payment and match
the actual signed envelope fee before committing consumption.

Keep published migration history unchanged. Migration policy remains
blocked pending deployed-history confirmation.

BREAKING CHANGE: fee execution requires quoteId and a quote-bound memo.
Refs CalloraOrg#1499
The published API-created head has the same complete tree as an
already integrated local ancestor. Join its ancestry without changing
the verified integration tree; no published changes are discarded.
@stmr

stmr commented Oct 21, 2026

Copy link
Copy Markdown
Author

Integrated accepted main 22fd831 and pushed 5da7305c51371d35767218b8680f4abcf26afa77 without force; verified tree ee43bd3754d5acb556586133ebd77dfbac57b908.

Exact-tree Linux run: build-and-test passed (lint, full types, 191 suites / 2,844 tests, Vercel HTTP smoke); OpenAPI compatibility passed. Two pre-existing skips remain. Overall CI is not green: migration-policy still reports ten published-history/layout violations. No historical SQL was edited or renumbered; the existing deployed-history question remains the prerequisite for a data-safe repair.

Payment signing now verifies quote-bound on-chain payment and consumes it atomically. Native PostgreSQL reproduced an expiry-after-lock-wait bug; explicit row locking fixes it. Four deterministic multi-backend races passed, plus real compiled HTTP/SDK signing with two blocked native backends and exactly one cryptographically verified envelope. Synthetic chain transport only; no real funds. The API requires quoteId and the quote MEMO_HASH, documented in docs/fee-abstraction.md.

The temporary author-side validation PR was closed unmerged. Keeping this PR draft; not claiming deployment readiness, points or payment.

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.

Stop idempotencyMiddleware from caching transient 4xx responses such as 429, 408 and 409 for the full retention window

1 participant