Skip to content

fix(#4): match exact deployed payments and retain refusals - #609

Merged
RonildoBraga merged 8 commits into
mainfrom
codex/4-exact-payment-refusals
Sep 15, 2026
Merged

RonildoBraga merged 8 commits into
mainfrom
codex/4-exact-payment-refusals

Conversation

@RonildoBraga

@RonildoBraga RonildoBraga commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #4

Matched payments now use the captured deployment's decimals and exact integer units. Three shares at 1.23 with two deployed decimals produce 369 raw units even when asset pricing uses six decimals. Inexact totals and amounts outside the stored range cannot persist a failed match.

Matching tries compatible candidates in existing price/time order until a proposed fill is representable. Each failed attempt rolls back before the next; skipped resting orders, reservations and timestamps stay unchanged. No fill is rounded or resized. If every compatible candidate fails, the submission UUID records a permanent refusal. With no compatible candidate, admission remains OPEN. A refused UUID never becomes successful after a valid candidate arrives; a deliberate new attempt requires a new UUID. This implements the owner's selected policy and addresses the candidate-selection finding.

Calculation and immutable context capture share one deployment snapshot per actual attempt. Exact formatting replaces the float helper; completed V1 market reads decode the recorded scale. Existing signed history remains unchanged, including older V1 amounts that disagree with their quote. tokens.0055_order_submission_settlement_refusal extends the existing refusal constraint; upgrade preserves history and reversal refuses to discard a newly supported refusal. No RLS policy or API response-shape change.

Local evidence

Source 965df4b1ebc57e9de953ccead36a815b85021006, isolated PostgreSQL 16 and synthetic chains:

Check Measured result
Ordinary backend, settings.test --parallel 4 --noinput 3,888 tests; 444 expected skips; 1160.361s
Scoped backend, settings.test_scoped --require-scoped-coverage --noinput 375 tests; zero skips; 808.798s
Fresh migrations, roles, catalogue and drift 0055 applied; scoped access to 73 tables; 172 policies across 43 tables and five helpers; no drift
Six candidate regressions 6 tests; zero skips; 7.914s
Real EVM / Bitcoin regtest 63 / 4 tests; zero skips; 210.423s / 69.418s
Real Redis and ClamAV 15 tests; zero skips; 19.246s
Shared / dashboard / mobile / contracts, make test 380 / 276 / 567 / 138 tests
make test-gates 294 tests
Static checks make check, make lint, backend Black/isort/flake8 and git diff --check passed
Complete generated schema comparison Identical; 188 operations and four explicit provider exclusions

The six new candidate controls failed against the previous matcher (six failures, 5.781s), then passed. They cover both incoming sides, exact whole lots with inexact partial fills, overflow, multiple rejected candidates, price/time selection, unchanged database and Python parent state, no skipped-attempt events, immutable refusal replay, non-amount failures and the winning deployment snapshot. They also run in the registered scoped suite.

A broader focused run exposed a test expecting 500 where DatabaseError correctly maps to 503. Its server-error assertion was corrected while retaining the pending/unspent/rollback checks. That run and the interrupted earlier scoped run are superseded. Earlier arithmetic and permanent-refusal controls also failed before their fixes. The signed-history control passes; restoring the old decoder produces the expected wrong-scale failure. A previously corrected large-integer fixture now sets the deployment scale and retains its exact raw-amount assertion.

Local dependencies include PyJWT 2.14.0, openai 3.13.0, Django 6.1.1 and web3 8.0.0. The earlier EVM run with PyJWT 2.13.0 is excluded; the table uses the rerun with 2.14.0.

Final head fef67a3c1193e75ba86d5cea9dd77e5f5b7a8691 integrates #602 (74a59145). Only the two marketing dependency files changed; the backend tree and complete feature patch are unchanged. Fresh marketing install, full make check, marketing lint/build and diff checking passed after integration. Independent reviewer Boole verified the source, final local evidence and integration delta and approved this exact head. He inspected the logs without rerunning the tests.

Hosted verification

CI run 35023093433 passed at fef67a3c1193e75ba86d5cea9dd77e5f5b7a8691; its synthetic merge a9f1427 has the same complete source tree.

Check Measured result
Ordinary backend 3,888 tests; 444 expected dedicated-suite skips; 1228.365s
Scoped backend 375 tests; zero skips; 337.770s
Real EVM / Bitcoin 63 / 4 tests; zero skips; 97.165s / 7.420s
Real Redis and ClamAV 7 + 4 + 4 tests; zero skips
Shared / dashboard / mobile / contracts 380 / 276 / 567 / 138 tests
Gate / Chromium smoke tests 294 / 3 tests; zero skips; 28.869s / 5.0s
Lint, migration drift, fresh migration and roles/catalogue Passed; 0055 installed; 172 policies across 43 tables and five helpers
Full schema artifact Equals the committed document; 188 operations and four exclusions; repository-format SHA-256 5b5bd1d91525676ba010fc898865fe9496a1b08a8e628b610ff30e4dde32eef0

Hosted runtime includes PostgreSQL 16.15, Django 6.1.1 and PyJWT 2.14.0. The dependency audit passed with its existing exclusions. All ten check results reported: eight successes and the two intended native build scope skips. Scope/aggregate checks passed; these skips do not establish a new Android/iOS build or physical-device result.

The original automated reviewer re-reviewed this exact head and reported no major issues; its matching finding is resolved. Boole independently verified the completed hosted logs and schema; final source/evidence signoff is recorded separately on this PR before merge. Prior run34977272575 covered the superseded 58cf9853 head and is not used to establish the new candidate behavior.

#4 remains open for legacy action retirement and #6 durable-execution/#5 reservation integration. Trading and signer admission stay closed. No live migration, deployment, activation or real-value use occurred. Full logs, source identities and failed/superseded evidence are retained under .git/codex-checks/issue-4-exact-payment/.

Copilot AI balanced review requested due to automatic review settings September 15, 2026 13:47
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-15T21:05:25.746649Z fef67a3 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@RonildoBraga

Copy link
Copy Markdown
Collaborator Author

Independent reviewer: Boole (/root/whitelist_review), relayed by Codex. Reviewed head: 58cf9853e2f2617e20f1a1c183b1becd00a2564a.

Source approved. Boole independently read the complete payment/refusal source and its test changes, then verified both main integrations. The feature patch is byte-identical after #603's URL updates and #604's two requirement lower-bound updates. No source blocker remains.

Boole verified the complete local evidence at 332231e9: ordinary 3,876/438 expected skips; scoped 369/0; EVM63/0; Bitcoin4/0; services15/0; workspace380/276/567/138; gates294; fresh migrations/roles/catalogue, schema, formatting and integrated checks. The PR explicitly records the earlier tested commits and dependency versions. After #604, Boole verified the requirement delta and the integrated make check result at 58cf9853 and confirmed source approval carries. Those earlier full-suite results are historical evidence, not a claim that they were rerun with the new dependency minimum.

The author additionally ran the recorded focused authentication/payment/submission/signable controls with PyJWT2.14.0 at this final head:129 tests/16 dedicated-scoped skips,69.299s,exit0. Full current-head hosted CI and final evidence review are still required before merge. This comment does not claim a merge slot or issue completion.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 58cf9853e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread backend/tokens/services/atomic_swap_service.py
@RonildoBraga

Copy link
Copy Markdown
Collaborator Author

Independent reviewer: Boole (/root/whitelist_review), relayed by Codex. Reviewed head: 58cf9853e2f2617e20f1a1c183b1becd00a2564a.

Source and final validation approved. No review blockers remain. Boole independently inspected the final ordinary log, completed backend/workspace/gate logs, full schema artifact and current check snapshot. The source approval recorded in5681274425 remains at this same head.

CI34977272575 passed ordinary 3,876 tests /438 expected dedicated-suite skips,1301.767s; scoped 369/0; EVM 63/0; Bitcoin 4/0; real services 15/0; shared/dashboard/mobile/contracts 380/276/567/138; gates 294; Chromium smoke 3. Complete schema matches. Lint, migration drift, migrations and roles/catalogue pass. Hosted dependencies include PyJWT2.14.0 and openai3.14.0.

All ten check results completed: eight successes and the two intended Android/iOS scope skips. Logs identify the reviewed head and expected base; the worktree is clean. Approval covers this payment/refusal correction. Native device execution, live deployment and real-value use were not exercised; remaining #4/#6/#5 acceptance stays open.

@RonildoBraga

Copy link
Copy Markdown
Collaborator Author

Merge held: new behavioral review finding

During the final review-comment audit I found the automated P1 in4016347031: an existing open candidate whose proposed fill is unrepresentable can repeatedly refuse incoming submissions before later valid candidates are considered. The final hosted validation and Boole review above establish the recorded tests, but do not clear this additional matching behavior. Do not merge this head while it is being assessed. No merge slot has been claimed.

I have reopened independent behavioral review with Boole and am checking the actual create/matching path. The owner-selected permanent outcome for a refused submission UUID remains in force. Any correction must preserve that original outcome while resolving candidate selection explicitly, with a regression that fails at this head. #4 remains the owning issue.

Attempt candidates in existing price/time order through the atomic match boundary. Roll back only unrepresentable proposed fills, preserve permanent all-invalid submission refusals, and retain the original UUID outcome after a valid candidate arrives. Keep one deployment snapshot per actual settlement attempt.
@RonildoBraga RonildoBraga changed the title fix(#4): persist exact deployed payment refusals fix(#4): match exact deployed payments and retain refusals Sep 15, 2026
@RonildoBraga

Copy link
Copy Markdown
Collaborator Author

@codex review

Please re-review head fef67a3c1193e75ba86d5cea9dd77e5f5b7a8691, especially your blocking candidate-selection finding 4016347031. The owner selected trying later representable candidates in #4 comment5687628536. Each real match attempt has its own savepoint; only amount refusals advance to the next candidate. Every compatible candidate failing retains a permanent refusal; no candidates retains OPEN admission; prior refused UUIDs cannot reopen. Six new controls failed before the correction and pass afterward, including both sides, overflow, multiple candidates, price/time, rollback/no events, non-amount failures and deployment capture.

Independent reviewer Boole approved source and local evidence at 965df4b1, then verified approval carries to this exact integrated head. Only #602's two marketing dependency files changed; backend tree 7bf430902fc9e20e5d335ac254fb3bf01f0732f3 and full feature patch are unchanged. He verified ordinary 3,888/444 expected skips, scoped 375/0, EVM 63/0, Bitcoin 4/0, services 15/0, workspace 380/276/567/138, gates 294, schema/catalogue and static checks, plus integrated make check and marketing install/lint/build. The PR body records the complete evidence and superseded failures. He inspected logs without rerunning tests.

The source/local hold is cleared by Boole; your original finding and fresh current-head hosted checks still need clearance before merge. No merge slot is claimed yet.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: fef67a3c11

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@RonildoBraga

Copy link
Copy Markdown
Collaborator Author

Candidate-selection hold cleared at fef67a3c1193e75ba86d5cea9dd77e5f5b7a8691.

The original automated reviewer completed the explicitly requested re-review at this head and reported no major issues in 5688077801, with its approval reaction timestamped 21:05:28Z. Boole's independent source/local approval is recorded in5688030077. Together these clear the behavioral hold I recorded in5681696628.

Fresh hosted verification is still pending in the two Django jobs of run35023093433. Source gates, JavaScript/workspace/contract checks, metadata, security and native scope/aggregate checks have completed successfully; native builds were scoped out. No merge or slot claim until both Django jobs and final evidence review finish.

@RonildoBraga

Copy link
Copy Markdown
Collaborator Author

Independent reviewer: Boole (/root/whitelist_review), relayed by Codex. Final source and validation approval at fef67a3c1193e75ba86d5cea9dd77e5f5b7a8691. No remaining review blocker or evidence condition.

Boole independently verified current-head hosted evidence: ordinary 3,888 tests / 444 expected skips, 1228.365s; scoped 375 / 0, 337.770s; EVM 63 / 0; Bitcoin 4 / 0; Redis/ClamAV 15 / 0; workspace suites 380 / 276 / 567 / 138; Chromium smoke 3; gates 294. Formatting, migrations, role/catalogue checks and complete schema comparison passed.

The final snapshot has ten completed checks: eight successful and two native builds skipped by scope. CI's merge tree equals the reviewed head; the worktree is clean and includes current main. The candidate-selection finding is cleared, including the original automated reviewer's fresh exact-head review in5688077801.

Review covered source behavior, regression strength and local/hosted evidence. Boole did not rerun tests or exercise native devices. This clearance covers #609's scope; the remaining #4/#6/#5 settlement-recovery work stays open.

@RonildoBraga
RonildoBraga merged commit 83cd1dd into main Sep 15, 2026
11 checks passed
@RonildoBraga
RonildoBraga deleted the codex/4-exact-payment-refusals branch September 21, 2026 22:33
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.

2 participants