Skip to content

fix(bonanza): restore live opening confirmation after 45-minute cap (#29) - #31

Closed
maghuro wants to merge 26 commits into
mainfrom
fix/bonanza-real-opening-confirmation
Closed

maghuro wants to merge 26 commits into
mainfrom
fix/bonanza-real-opening-confirmation

Conversation

@maghuro

@maghuro maghuro commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Regressão real

O PR #29 introduziu uma confirmação do anúncio de abertura que compara o BBCode enviado com o HTML/JoyPixels devolvido por GET /api/chat/messages/1, e exige timestamps inteiramente contidos numa janela de POST de apenas 183 ms quando o servidor regista segundos inteiros. Em produção, o anúncio chega ao Main Chat mas o userscript fica preso num pending e mostra alertas a cada carregamento.

Correção

  • Converter BBCode e HTML/JoyPixels em texto canónico, preservando os marcadores invisíveis e o conteúdo, antes da comparação.
  • Verificar autor, cursor anterior à publicação, mensagem integral e janela temporal. Para timestamps de precisão ao segundo que se sobrepõem parcialmente ao envio, exigir confirmação positiva do POST e correspondência única. Envios ambíguos ou anúncios duplicados continuam sem confirmar.
  • Persistir sendAcknowledged no checkpoint antes de verificar o anúncio. sponsorStartTs conserva o limite conservador: final do bucket do timestamp do servidor.
  • Manter o limite de 45 minutos e as restrições contra transferências duplicadas.
  • Testes de regressão de HTML real, JoyPixels, created_at com precisão ao segundo, anúncio anterior, colisões, autor errado, texto diferente e ausência de confirmação HTTP.

Segurança operacional

Não usar esta atualização para concluir automaticamente sorteios antigos ainda pending. O sorteio de 2026-10-14 deve ser cancelado explicitamente no browser, com cópia de segurança do snapshot, anúncio público de cancelamento e conferência separada de eventuais ofertas BON.

Validação

Aguardar Validate BONanza CI e revisão independente antes de merge/publicação. Fontes em src/; bundle gerado mantido sincronizado.

maghuro commented Oct 14, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please perform a fresh, independent, adversarial review of this entire PR at HEAD 8fdfef97cd4e00fcfe2da05b00b9a57e491f3fe8, not just the latest diff. This BONanza userscript can transfer real BON. Review all relevant source fragments, generated userscript, persistence/reload logic and tests, prioritizing real live DarkPeers API behavior (BBCode sent via POST versus rendered HTML/JoyPixels from GET; authenticated author shape; second-resolution timestamps), duplicate/old announcement false positives, positive HTTP acknowledgement durability, sponsor eligibility boundaries, failed/ambiguous POSTs and regressions to the 45-minute cap and settlement safety. Challenge cases that new regression tests might miss; report only concrete, actionable issues with realistic reproductions and severity, or explicitly say none found. Do not merge or publish.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 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-10-14T21:53:45.022393Z d188d45 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.

@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: 8fdfef97cd

ℹ️ 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 +120 to +121
if (!whollyInside &&
!(checkpoint.sendAcknowledged === true && overlapsAttempt)) continue;

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 Require the full timestamp bucket to fit the send window

For a normal acknowledged POST lasting from, for example, 20:25:29.220 to 20:25:29.403, this condition accepts a created_at bucket covering 20:25:29.000–29.999, even though part of that bucket predates the attempt. A positive HTTP response proves that some POST succeeded but does not prove that the sole matching record returned by a stale, filtered, or paginated GET is that POST rather than an identical own-user announcement created after the cursor and before startedAt; confirming it can therefore enable entries and eventual real-BON settlement against the wrong opening. Keep requiring the entire bucket to fall within the checkpoint window rather than treating overlap plus acknowledgement as sufficient.

AGENTS.md reference: AGENTS.md:L54-L60

Useful? React with 👍 / 👎.

maghuro commented Oct 14, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Fresh full PR review at latest HEAD 11749063611b3e97b4b91921ce0a5de7432dcc9d. The previous P1 on the ambiguous same-second timestamp bucket has been addressed by requiring a freshly generated 128-bit invisible per-opening proof marker, persisted before POST and checked against the precise rendered Main Chat message. Please challenge whether \u200B and \u2063 survive real DarkPeers BBCode->HTML/JoyPixels and whether any path could wrongly confirm another user's/old opening, lose or duplicate BON, or leave an unrecoverable pending state. Also scrutinize GET response shape, API pagination/after_id behavior, first start after reload, sendAcknowledged, and sponsor cutoff timestamps; inspect the entire PR and report concretely reproducible P1/P2 defects. Do not merge or publish.

@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: 1174906361

ℹ️ 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 +138 to +140
if (!whollyInside &&
!(hasUniqueProof && overlapsAttempt &&
canonical(message?.message, true).endsWith(proof))) continue;

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 Keep the full timestamp bucket inside the attempt

The fresh evidence at latest HEAD is the new hasUniqueProof && overlapsAttempt exception, which still confirms a message whose server timestamp bucket is not wholly contained in the POST window. For a send beginning at 20:25:29.220 with created_at=20:25:29, this accepts the 20:25:29.000–29.999 bucket even though its lower bound predates the attempt; the marker identifies the message but does not change the recorded timestamp resolution, while the repository invariant explicitly forbids confirmation from mere same-second overlap. This can enable entries and eventual BON settlement without the required publication-time proof.

AGENTS.md reference: AGENTS.md:L54-L60

Useful? React with 👍 / 👎.

Comment on lines +75 to +77
content = content.replace(
/\[(?:\/)?(?:b|i|u|s|color(?:=[^\]]*)?|size(?:=[^\]]*)?|url(?:=[^\]]*)?)\]/gi,
""

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Canonicalize all supported BBCode before comparing rendered text

When the optional custom message contains a supported tag outside this short allowlist—for example [quote]Good luck[/quote]—the prepared-side canonical form retains the BBCode while DarkPeers renders it as HTML and the rendered-side branch removes the resulting tags. The already-posted opening therefore never matches authoritative history, leaving its checkpoint pending and blocking entries, recovery, and subsequent starts even though the exact proof marker survived. Either parse BBCode consistently with DarkPeers or reject unsupported markup before the public POST.

AGENTS.md reference: AGENTS.md:L66-L67

Useful? React with 👍 / 👎.

maghuro commented Oct 14, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Fresh adversarial review of ENTIRE PR at current HEAD 27a19dbd5acc4c484192a4ce3a0af00bf11acba9. Previous P1 was serious: HTTP 200 plus partial second-resolution bucket could confirm an unrelated opening. Now an opening has a 128-bit cryptographically random zero-width marker, appended and durably checkpointed before POST, and partial coarse buckets require matching that exact marker. Review proof generation/serialization/site rendering, HTML/JoyPixels comparison, correctness of author resolution and GET paging, timing/sponsor boundaries, and new non-modal Cancel & archive workflow including race handling, legacy recovery, and real BON safety. Require actual production-compatible evidence rather than merely green simulated tests. Flag grounded issues (P1/P2) clearly. Do not merge or publish.

maghuro commented Oct 14, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please conduct a fresh, security-focused full-PR review at HEAD d70f2e8f38c7bcd4b01bc2167a3e3fe5a6f74621. The previously reported unsupported [quote] custom-BBCode false-pending issue now has a pre-POST rejection guard and test; inspect actual custom message processing and find any other realistic transformed markup cases. Re-assess the whole-second timing P1 considering the updated AGENTS.md protocol: openingProof is generated using crypto.getRandomValues after startedAt, durably written before the only POST, and checked against the exact authenticated rendered API message; thus a candidate containing that unique per-attempt proof cannot predate the current send. Challenge this claim concretely (including stripped/rewritten hidden characters, duplicate GET results, API actor shape and pagination), the new Cancel & archive UI, and any real-BON settlement risks. The last CI passed, but do not assume tests cover live DarkPeers. Report concrete findings, not repeats of an obsolete invariant. Do NOT merge or publish.

@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: d70f2e8f38

ℹ️ 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 +95 to 98
const url = new URL("/api/chat/messages/" + DARKPEERS_MAIN_CHATROOM_ID, location.origin);
url.searchParams.set("after_id", String(afterId));
const response = await fetchWithTimeout(
url, { credentials: "include", cache: "no-store" }, 5000

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 Paginate history when reverifying confirmed openings

When a confirmed giveaway is restored after enough Main Chat traffic, the original opening can fall outside the endpoint's current result page—especially because the opening path itself notes that UNIT3D may ignore after_id. This verifier retries the same unpaginated URL three times, so the required saved messageId is never found even though it remains in older authoritative history; restore then permanently pauses entries and real-BON settlement. Follow the API's pagination until the saved ID or bounded publication range is exhausted.

AGENTS.md reference: AGENTS.md:L128-L132

Useful? React with 👍 / 👎.

maghuro commented Oct 14, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please run a fresh, comprehensive and adversarial review of the ENTIRE PR at HEAD 98db4dd23154a6fa5c69cf823693c6426dd504b6, not only the recent diff. IMPORTANT: last review identified a P1 about trying to reverify an opening missing from a fixed-size chat history. We investigated upstream UNIT3D ChatController::messages() and ChatRepository::messages() (public repository HDInnovations/UNIT3D) and found that GET /api/chat/messages/{room_id} deliberately returns only the newest chat.message_limit messages (100 observed live) and has NO pagination/after_id support. The new fix returns a durable-confirmed proof when the full 100-message page's minimum ID is greater than the saved confirmed opening ID; on restore, it verifies the stored 128-bit proof presence, identity, original exact message ID, and conservative persisted sponsor boundary. PENDING, legacy/proofless, incomplete response, or still-in-window-but-missing announcements stay fail-closed. New tests simulate 100-message rollover and failure cases. Scrutinize precisely the safety of this approach (including the tradeoff that deleted old messages cannot be rechecked), spot realistic race/false positive cases, inspect BBCode/HTML and hidden marker encoding, and review cancel/archive, gift safety and 45-minute cap. Please report concrete, reproducible P1/P2 findings only. Do not merge or publish.

@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: 98db4dd231

ℹ️ 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 +138 to +140
if (!whollyInside &&
!(hasUniqueProof && overlapsAttempt &&
canonical(message?.message, true).endsWith(proof))) continue;

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 Reject proof duplicates outside the send window

When the authenticated host's marked payload appears once in the accepted timestamp overlap and a second time after windowEnd—for example, because a delayed duplicate is created after sendCompletedAt—the later record is discarded here before entering matches, leaving matches.length === 1 and confirming an ambiguous opening. Count matching author/text/proof occurrences before applying the publication-window test and reject confirmation whenever the marker occurs more than once.

AGENTS.md reference: AGENTS.md:L61-L67

Useful? React with 👍 / 👎.

maghuro commented Oct 14, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please perform a fresh independent adversarial FULL-PR review of latest HEAD d188d45c3af654e969fcd7339a0271b9768b1fcd. The prior P1 on duplicate opening messages being ignored outside the allowed POST-time window has been addressed: candidate author/BBCode-to-HTML text/proof matches are now counted across the entire returned chat payload before timestamps can discard them. More than one distinct message ID fails closed; repeated API rows with the same ID are deduplicated. Regression tests cover a duplicate before/after the time window, malformed timestamp, and repeated same-ID rows. CI currently passes 159/159. Reassess the previous P1 rigorously, check restore/history-rollover safety, all 15 source fragments, generated script, bounded UNIT3D history, user-controlled cancellation, 45-minute cap, sponsor accounting and real BON payout safety. Report concrete reproducible P1/P2 findings, not theoretical generic advice. Do not merge or publish.

@maghuro maghuro closed this Oct 14, 2026

@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: d188d45c3a

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

if (!expectedHost || serverName !== expectedHost) continue;
}
if (canonical(message?.message, true) !== expected) continue;
matchingAnnouncementIds.add(id);

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 Count duplicates before pinning confirmed IDs

Fresh evidence at latest HEAD is that confirmed restores still discard every non-saved ID at lines 114–115 before adding candidates to matchingAnnouncementIds. If the returned payload contains the original confirmed message plus a copied announcement with the same author, rendered text, and proof under another ID—even outside the POST window—the copy is never counted and the original is accepted, allowing entries and eventual real-BON settlement despite an ambiguous duplicated marker. Perform the author/text/proof duplicate scan across all post-cursor IDs before restricting the actual confirmation candidate to checkpoint.messageId.

AGENTS.md reference: AGENTS.md:L58-L67

Useful? React with 👍 / 👎.

Comment on lines +179 to +181
pageIds.length >= 100 && pageIds.every(id =>
Number.isSafeInteger(id) && id > 0
) && Math.min(...pageIds) > confirmedId) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Require distinct IDs for history rollover

This treats array length as proof of a full 100-message page without checking ID uniqueness. For example, a response containing 99 newer messages plus a replayed row has pageIds.length === 100 and a minimum ID above the saved opening, so it takes historyEvicted and resumes settlement even though the response is only a 99-message short history; repeated API rows are explicitly considered possible elsewhere in this verifier. Base the rollover exception on at least 100 distinct valid message IDs so only a genuinely full latest page can bypass direct re-verification.

AGENTS.md reference: AGENTS.md:L75-L82

Useful? React with 👍 / 👎.

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