Skip to content

Keep rejected gift fallbacks retryable - #28

Merged
maghuro merged 9 commits into
mainfrom
fix/gift-fallback-retryability
Oct 2, 2026
Merged

maghuro merged 9 commits into
mainfrom
fix/gift-fallback-retryability

Conversation

@maghuro

@maghuro maghuro commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • fix the P2 found by the full-repository Codex audit
  • preserve exclusive giveaway ownership during /gift fallback sends
  • inspect the real sendMessage() result instead of assuming the fallback was sent
  • when the chat transport definitively rejects the command, restore only the exact terminal marker written by that unsent attempt to retryable state
  • fail closed if ownership or durable ledger verification is unavailable
  • add static and pure-core regression coverage
  • bump BONanza to v1.5.14 and rebuild the generated userscript

Failure fixed

Previously fallbackToChat() terminalized the transfer ledger before calling sendMessage(cmd), then ignored a false result and returned success. If neither chat transport accepted the /gift, later settlement could treat an unsent winner payout/refund as already attempted.

Safety

The recovery path requires the current tab to still own the giveaway, checks the exact numeric terminal marker produced for this attempt, writes the retryable token, performs durable ledger read-back, and never retries ambiguous HTTP/network sends.

maghuro commented Oct 2, 2026

Copy link
Copy Markdown
Owner Author

@codex Please review this fix for the P2 you found in the full-repository audit. Focus on whether the rejected /gift fallback is now safely retryable without creating any duplicate-send path, ownership race, or ledger corruption. Review the actual diff and report only substantive issues.

@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: 3d0ea5f65e

ℹ️ 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 on lines +1398 to +1402
if (sent) return { sent: true };

// sendMessage() returning false means neither supported chat transport
// accepted the command. If we still own the giveaway, no transfer was
// initiated, so restore this exact terminal marker to retryable state.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Do not retry ambiguous chat API failures

When /api/chat/messages times out or throws after the server has accepted the /gift, and no chatbox fallback is available, sendMessage() returns false: it catches the ambiguous API failure and then returns sendViaChatbox()'s failure. This branch treats that result as definitive and restores the ledger token to retryable, so the next settlement retry can send the same gift again. Preserve the terminal/ambiguous marker unless the transport can specifically report that no request was initiated or accepted.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed. The /gift fallback now forces the synchronous chatbox-only path, so no /api/chat/messages request is made in this recovery branch. A false result is therefore a definitive no-dispatch rather than an ambiguous API timeout. I also added regression assertions for forceChatboxOnly and the API gate, then rebuilt the generated userscript.

maghuro commented Oct 2, 2026

Copy link
Copy Markdown
Owner Author

@codex review

1 similar comment

maghuro commented Oct 2, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: d9e0c17a37

ℹ️ 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".

@maghuro
maghuro merged commit abcecf5 into main Oct 2, 2026
1 check 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