@jetthai/cuora 1.1.485-dev.2 → 1.1.487-otp.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/.claude/commands/sync-ai-prompts.md +1 -88
  2. package/.claude/settings.local.json +1 -3
  3. package/.github/copilot-instructions.md +5 -8
  4. package/.husky/post-checkout +3 -3
  5. package/.husky/pre-push +1 -1
  6. package/.prettierignore +1 -2
  7. package/AGENTS.md +5 -8
  8. package/AI_PROMPT_SOURCE.md +5 -8
  9. package/CHANGELOG.md +29 -374
  10. package/CLAUDE.md +5 -8
  11. package/GEMINI.md +5 -8
  12. package/e2e/feature-map.md +19 -0
  13. package/package.json +3 -3
  14. package/prepare-for-pr/JT-1776243420.md +85 -0
  15. package/prepare-for-pr/TI-16026/STATE.md +18 -0
  16. package/prepare-for-pr/TI-16026/after-prepare-authorization.md +3 -0
  17. package/prepare-for-pr/TI-16026/analysis.md +38 -0
  18. package/prepare-for-pr/TI-16026/answer-analyze-01.md +1 -0
  19. package/prepare-for-pr/TI-16026/answer-commit-01.md +2 -0
  20. package/prepare-for-pr/TI-16026/answer-commit-02.md +1 -0
  21. package/prepare-for-pr/TI-16026/bundle.json +18 -0
  22. package/prepare-for-pr/TI-16026/checklist.md +196 -0
  23. package/prepare-for-pr/TI-16026/checklist.unit-test-original.md +39 -0
  24. package/prepare-for-pr/TI-16026/claude-after-model +1 -0
  25. package/prepare-for-pr/TI-16026/claude-commit-session +1 -0
  26. package/prepare-for-pr/TI-16026/claude-harvest-session +1 -0
  27. package/prepare-for-pr/TI-16026/claude-hops/01-analyze.err +1 -0
  28. package/prepare-for-pr/TI-16026/claude-hops/01-analyze.out +2 -0
  29. package/prepare-for-pr/TI-16026/claude-hops/02-analyze.err +1 -0
  30. package/prepare-for-pr/TI-16026/claude-hops/02-analyze.out +4 -0
  31. package/prepare-for-pr/TI-16026/claude-hops/03-dev.err +1 -0
  32. package/prepare-for-pr/TI-16026/claude-hops/03-dev.out +4 -0
  33. package/prepare-for-pr/TI-16026/claude-hops/04-dev.err +1 -0
  34. package/prepare-for-pr/TI-16026/claude-hops/04-dev.out +4 -0
  35. package/prepare-for-pr/TI-16026/claude-hops/05-dev.err +1 -0
  36. package/prepare-for-pr/TI-16026/claude-hops/05-dev.out +3 -0
  37. package/prepare-for-pr/TI-16026/claude-hops/06-after.err +1 -0
  38. package/prepare-for-pr/TI-16026/claude-hops/06-after.out +2 -0
  39. package/prepare-for-pr/TI-16026/claude-hops/07-commit.err +1 -0
  40. package/prepare-for-pr/TI-16026/claude-hops/07-commit.out +2 -0
  41. package/prepare-for-pr/TI-16026/claude-hops/08-commit.err +1 -0
  42. package/prepare-for-pr/TI-16026/claude-hops/08-commit.out +2 -0
  43. package/prepare-for-pr/TI-16026/claude-hops/09-commit.err +1 -0
  44. package/prepare-for-pr/TI-16026/claude-hops/09-commit.out +8 -0
  45. package/prepare-for-pr/TI-16026/claude-hops/10-harvest.err +1 -0
  46. package/prepare-for-pr/TI-16026/claude-hops/10-harvest.out +3 -0
  47. package/prepare-for-pr/TI-16026/claude-hops/11-harvest.err +1 -0
  48. package/prepare-for-pr/TI-16026/claude-hops/11-harvest.out +3 -0
  49. package/prepare-for-pr/TI-16026/commit-note.md +5 -0
  50. package/prepare-for-pr/TI-16026/evidence-index.json +215 -0
  51. package/prepare-for-pr/TI-16026/feature-map.before.md +61 -0
  52. package/prepare-for-pr/TI-16026/harvest-redaction.json +34 -0
  53. package/prepare-for-pr/TI-16026/harvest-redaction.out +37 -0
  54. package/prepare-for-pr/TI-16026/harvest.md +46 -0
  55. package/prepare-for-pr/TI-16026/lessons.md +5 -0
  56. package/prepare-for-pr/TI-16026/note-harvest-redaction.md +1 -0
  57. package/prepare-for-pr/TI-16026/open-questions.md +6 -0
  58. package/prepare-for-pr/TI-16026/publish.md +32 -0
  59. package/prepare-for-pr/TI-16026/review-convergence-response.md +3 -0
  60. package/prepare-for-pr/TI-16026/review-input/scope.md +18 -0
  61. package/prepare-for-pr/TI-16026/review-log.md +57 -0
  62. package/prepare-for-pr/TI-16026/review-notes.md +97 -0
  63. package/prepare-for-pr/TI-16026/review-response-r1.md +7 -0
  64. package/prepare-for-pr/TI-16026/self-test-report.md +67 -0
  65. package/prepare-for-pr/TI-16026/spec-proposal.md +34 -0
  66. package/prepare-for-pr/TI-16026/spec-snapshot.md +291 -0
  67. package/prepare-for-pr/TI-16026/state-log.md +57 -0
  68. package/prepare-for-pr/TI-16026/user-messages/01.md +12 -0
  69. package/prepare-for-pr/TI-16026/user-messages/02.md +20 -0
  70. package/prepare-for-pr/TI-16026/user-messages/03.md +1 -0
  71. package/prepare-for-pr/TI-16026/user-messages/04.md +1 -0
  72. package/prepare-for-pr/TI-16026/user-messages/05.md +1 -0
  73. package/prepare-for-pr/TI-16026/user-messages/06.md +1 -0
  74. package/prepare-for-pr/TI-16026/user-messages/07.md +1 -0
  75. package/prepare-for-pr/TI-16026/user-messages/08.md +1 -0
  76. package/prepare-for-pr/TI-16026/user-messages/09.md +1 -0
  77. package/prepare-for-pr/TI-16026/user-messages/10.md +1 -0
  78. package/prepare-for-pr/TI-16026/user-messages/11.md +1 -0
  79. package/prepare-for-pr/TI-16026/user-messages/12.md +1 -0
  80. package/prepare-for-pr/TI-16026/user-messages/13.md +1 -0
  81. package/prepare-for-pr/TI-16026/user-messages/14.md +1 -0
  82. package/prepare-for-pr/TI-16026/user-messages/15.md +1 -0
  83. package/prepare-for-pr/TI-16026/user-messages/16.md +1 -0
  84. package/prepare-for-pr/TI-16026/user-messages/17.md +1 -0
  85. package/prepare-for-pr/TI-16026/user-messages/18.md +10 -0
  86. package/prepare-for-pr/TI-16026/user-messages/19.md +1 -0
  87. package/prepare-for-pr/TI-16026/user-messages/20.md +1 -0
  88. package/prepare-for-pr/TI-16026/user-messages/21.md +1 -0
  89. package/prepare-for-pr/TI-16026/user-messages/22.md +1 -0
  90. package/prepare-for-pr/TI-16026/user-messages/23.md +8 -0
  91. package/prepare-for-pr/TI-16026/user-messages/24.md +24 -0
  92. package/prepare-for-pr/TI-16026/user-question.md +24 -0
  93. package/prepare-for-pr/TI-16026/verify/metrics-check.json +13 -0
  94. package/prepare-for-pr/TI-16026/verify/redaction.json +38 -0
  95. package/prepare-for-pr/TI-16026/verify/row-closure.json +45 -0
  96. package/prepare-for-pr/TI-16026/verify/s04-ws-capture.md +23 -0
  97. package/prepare-for-pr/TI-16026/verify-after.md +23 -0
  98. package/prepare-for-pr/TI-16026/verify.json +80 -0
  99. package/prepare-for-pr/TI-16026.md +408 -0
  100. package/scripts/auto-version.js +0 -1
  101. package/scripts/branch-auto-npm-publish.js +2 -9
  102. package/src/api/payment.js +0 -1
  103. package/src/machine/auth.js +18 -5
  104. package/src/machine/game_v2_1.js +0 -15
  105. package/src/machine/reward_cash.js +2 -2
  106. package/src/machine/user_sign_up.js +0 -3
  107. package/src/machine/withdraw/withdraw_manual_cash.js +14 -10
  108. package/src/request/request.js +4 -44
  109. package/src/util/constant.js +0 -3
  110. package/src/util/tokenStore.js +0 -44
  111. package/test/withdraw_manual_cash.test.js +0 -149
  112. package/tests/session.test.mjs +0 -177
@@ -0,0 +1,408 @@
1
+ # TI-16026: Withdraw submitted-state REFRESH review
2
+
3
+ ## Key Changes
4
+
5
+ 1. `submitted` accepts REFRESH -> loading and reuses fetchInitData. The r2 fix makes loading.onError return to submitted when processing exists, preserving the pending order and allowing retry; first-load failure still falls back to loaded (`src/machine/withdraw/withdraw_manual_cash.js:40`, :98-101).
6
+ 2. Target: feat/stone/JT-1791856380-ws-refresh; HEAD/base c9186b6b3f424d74a9fe1363e64b17eb63809b58. Product changes and test/withdraw_manual_cash.test.js remain uncommitted. The r2 incremental review verified the failure fix; its fresh independent convergence check reviews the complete base-to-working-tree change, including the original submitted REFRESH handler and all six untracked tests.
7
+
8
+ ---
9
+
10
+ ## Key Findings
11
+
12
+ ### Strengths
13
+
14
+ 1. The fix reuses isProcessing and existing state names, keeps successful initialization unchanged and adds observable rejection/retry assertions with a bound bank.
15
+ 2. A memory-only old-onError negative control makes exactly the new retry test fail, proving that it detects the original defect.
16
+
17
+ ---
18
+
19
+ ### Behavior Observed
20
+
21
+ 1. **F-r1-01 [medium], ACCEPT, verified in r2: yes.** Pending W-1 + bound bank -> REFRESH -> second pendingOrder rejects ERR_998 -> submitted with W-1 retained -> next REFRESH makes request 3 and reaches loaded. No new findings in r2. The historical finding and response remain in review-log.md.
22
+ 2. Initial pendingOrder rejection with processing=null still reaches loaded. Successful submitted reload enters loading; an empty response clears processing and reaches loaded; another pending order replaces W-1/500 with W-2/800 and reaches submitted. All six targeted tests pass.
23
+ 3. Root REFRESH remains conditional outside submitted. The loaded bank/no-bank transition probe passes both outcomes; other non-submitted definitions were inspected, not individually executed.
24
+ 4. The fresh whole-change reviewer formed observations from spec/diff/source before reading the full prior STATE/log/notes, then independently reproduced the six passing tests, the negative-control failure and root boundary results. No additional finding or re-raise was identified. The driver owns the next check-review.sh invocation and STATE update; this report does not declare loop convergence.
25
+
26
+ ---
27
+
28
+ ## 🔧 Change Type
29
+
30
+ - [x] 🐛 Bug fix
31
+ - [ ] ✨ New feature
32
+ - [ ] 💄 Style
33
+ - [ ] ♻️ Refactor
34
+ - [ ] ⚡ Performance
35
+ - [ ] 🔧 Chore
36
+
37
+ ---
38
+
39
+ ## 📱 Impact Scope
40
+
41
+ The shared SDK factory now accepts REFRESH from submitted regardless of bound banks, enters loading and fetches status again. Empty pending-order results reach loaded; a remaining order replaces processing and returns submitted. If initialization fails with an existing processing order, callers retain submitted and the previous order, then retry with the same REFRESH event. Import/export contracts, factory arguments, event/state names and successful initialization remain unchanged.
42
+
43
+ Internal unchanged consumers were searched with `rg -n 'withdraw_manual_cash|withdraw/index|\.\.\.withdraw|machine/index' src`: src/machine/withdraw/index.js:4 -> src/machine/index.js:18/:54 -> src/index.js:2/:7. Each is an export-forwarding layer without state/error decisions, needs no adaptation, and is listed in the r2 Impact block. The supplied scope also names client-pwa-cash; its exact consumer paths and rendering were not verified because no other repo was inspected. Other frontends using the factory receive the same corrected failure state.
44
+
45
+ The user selected unit tests and review for this SDK repo: adapter=none, delivery local, no SDK screenshots. Cash UI, WebSocket strict-ID behavior, real backend payloads and published-package integration remain with the cash verification flow. The convergence reviewer independently confirmed that src/machine/websocket.js:296-301 already forwards payment-info without a windowType toast filter; the spec's conditional relaxation therefore needs no additional patch on that static criterion. No real socket event was exercised. client-pwa-cash is an explicit downstream consumer; exact downstream paths were not inspected. client-pwa and client-pwa-ssr have no established direct callsite in this scoped input and were not inspected; any caller using this factory receives the same SDK behavior.
46
+
47
+ ---
48
+
49
+ ## Test Completion Status
50
+
51
+ | Item | Validation Tested | Status |
52
+ | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
53
+ | R2-E1 — accepted failure fix and success regression | node --test test/withdraw_manual_cash.test.js; six cases listed below, 6 passed, 0 failed, exit 0. | PASS |
54
+ | R2-E2 — test sensitivity | Same suite with only old unconditional loading.onError restored in memory: failed retry case times out waiting for submitted; 5 passed, 1 failed, exit 1 expected. | PASS |
55
+ | R2-E3 — root REFRESH boundary | Pure transitions: loaded with no bank -> loading; loaded with bound bank -> loaded; assertions pass, exit 0, no request. | PASS |
56
+ | R2-E4 — code/whitespace | git diff --check, empty output, exit 0; inspect onError, onDone, guard, initializer and exports. | PASS |
57
+ | C2-E1–C2-E4 — independent whole-change convergence | Fresh spec/source review, complete base-to-working-tree diff and untracked test; independently rerun six tests (6 pass), old-onError negative control (expected 1 failure), root boundaries (pass) and whitespace check (pass). Raw output below. | PASS |
58
+ | Full suite / alternate wallet gates / OTP / other errors | Not selected for this scoped whole-change review: services, wallet gating and OTP definitions are unchanged; no exhaustive event or error enumeration. | NOT RUN |
59
+ | Cash UI / real backend / published package | Outside this SDK review and not executed; user choice A replaces SDK screenshot evidence. | NOT RUN |
60
+
61
+ Evidence is embedded in this report because only this report, review-log.md and review-notes.md are writable. All commands ran from cuora-module. Local response stubs exercise the real XState factory and initializer without transport/backend calls or transactions.
62
+
63
+ R2-E1 raw output:
64
+
65
+ ```text
66
+ $ node --test test/withdraw_manual_cash.test.js
67
+ ✔ REFRESH in submitted re-runs loading and fetches the pending order again (4.531542ms)
68
+ ✔ REFRESH in submitted returns to the form when no order is pending (0.86175ms)
69
+ ✔ REFRESH in submitted keeps submitted with the updated order when one is still pending (1.483625ms)
70
+ ✔ a failed refresh in submitted keeps the pending order and a later REFRESH retries (0.742208ms)
71
+ ✔ a failed first load without a pending order still shows the form (0.394833ms)
72
+ ✔ REFRESH in loaded with a bound bank is still ignored (22.485208ms)
73
+ ℹ tests 6
74
+ ℹ suites 0
75
+ ℹ pass 6
76
+ ℹ fail 0
77
+ ℹ cancelled 0
78
+ ℹ skipped 0
79
+ ℹ todo 0
80
+ ℹ duration_ms 114.366834
81
+ exit: 0
82
+ ```
83
+
84
+ R2-E2 exact command (memory only):
85
+
86
+ ```sh
87
+ node --input-type=module <<'NODE'
88
+ import test from 'node:test'
89
+ import assert from 'node:assert/strict'
90
+ import { readFileSync } from 'node:fs'
91
+ import { interpret, createMachine } from 'xstate'
92
+ import original from './src/machine/withdraw/withdraw_manual_cash.js'
93
+ const suite = readFileSync('test/withdraw_manual_cash.test.js', 'utf8').replace(/^import .*\n/gm, '')
94
+ const mutant = (...args) => {
95
+ const machine = original(...args)
96
+ return createMachine({ ...machine.config, states: { ...machine.config.states, loading: { ...machine.config.states.loading, invoke: { ...machine.config.states.loading.invoke, onError: { target: 'loaded' } } } } }, machine.options)
97
+ }
98
+ console.log('NEGATIVE CONTROL ONLY: restore old loading.onError in memory; files unchanged')
99
+ new Function('test', 'assert', 'interpret', 'withdrawManualCash', suite)(test, assert, interpret, mutant)
100
+ NODE
101
+ ```
102
+
103
+ ```text
104
+ NEGATIVE CONTROL ONLY: restore old loading.onError in memory; files unchanged
105
+ ✔ REFRESH in submitted re-runs loading and fetches the pending order again (4.642166ms)
106
+ ✔ REFRESH in submitted returns to the form when no order is pending (1.186167ms)
107
+ ✔ REFRESH in submitted keeps submitted with the updated order when one is still pending (1.146458ms)
108
+ ✖ a failed refresh in submitted keeps the pending order and a later REFRESH retries (1001.534792ms)
109
+ ✔ a failed first load without a pending order still shows the form (0.655125ms)
110
+ ✔ REFRESH in loaded with a bound bank is still ignored (22.874459ms)
111
+ ℹ tests 6
112
+ ℹ suites 0
113
+ ℹ pass 5
114
+ ℹ fail 1
115
+ ℹ cancelled 0
116
+ ℹ skipped 0
117
+ ℹ todo 0
118
+ ℹ duration_ms 1034.528792
119
+ Error: Timed out waiting for submitted
120
+ at Timeout.eval [as _onTimeout] (eval at <anonymous> (.../[eval1]:12:1), <anonymous>:7:45)
121
+ at listOnTimeout (node:internal/timers:605:17)
122
+ at process.processTimers (node:internal/timers:541:7)
123
+ exit: 1 (expected)
124
+ ```
125
+
126
+ R2-E3 exact command and output:
127
+
128
+ ```sh
129
+ node --input-type=module <<'NODE'
130
+ import assert from 'node:assert/strict'
131
+ import factory from './src/machine/withdraw/withdraw_manual_cash.js'
132
+ const machine = factory({ send() { throw new Error('No requests expected') } })
133
+ assert.equal(machine.transition('loaded', 'REFRESH').value, 'loading')
134
+ const withBank = machine.withContext({ ...machine.context, userBanks: [{ bankCode: 'BANK' }] })
135
+ assert.equal(withBank.transition('loaded', 'REFRESH').value, 'loaded')
136
+ console.log('PASS: root REFRESH no bank -> loading; bound bank -> loaded; no requests')
137
+ NODE
138
+ ```
139
+
140
+ ```text
141
+ PASS: root REFRESH no bank -> loading; bound bank -> loaded; no requests
142
+ exit: 0
143
+ ```
144
+
145
+ ### Fresh r2 whole-change convergence evidence
146
+
147
+ C2-E1 repeats `node --test test/withdraw_manual_cash.test.js` against the actual working tree:
148
+
149
+ ```text
150
+ ✔ REFRESH in submitted re-runs loading and fetches the pending order again (4.552ms)
151
+ ✔ REFRESH in submitted returns to the form when no order is pending (1.1955ms)
152
+ ✔ REFRESH in submitted keeps submitted with the updated order when one is still pending (1.1305ms)
153
+ ✔ a failed refresh in submitted keeps the pending order and a later REFRESH retries (0.741834ms)
154
+ ✔ a failed first load without a pending order still shows the form (0.394833ms)
155
+ ✔ REFRESH in loaded with a bound bank is still ignored (22.575125ms)
156
+ ℹ tests 6
157
+ ℹ suites 0
158
+ ℹ pass 6
159
+ ℹ fail 0
160
+ ℹ cancelled 0
161
+ ℹ skipped 0
162
+ ℹ todo 0
163
+ ℹ duration_ms 118.840542
164
+ exit: 0
165
+ ```
166
+
167
+ C2-E2 independently repeats the R2-E2 memory-only command above (only the console label changes):
168
+
169
+ ```text
170
+ NEGATIVE CONTROL: old loading.onError in memory; files unchanged
171
+ ✔ REFRESH in submitted re-runs loading and fetches the pending order again (4.803667ms)
172
+ ✔ REFRESH in submitted returns to the form when no order is pending (1.337542ms)
173
+ ✔ REFRESH in submitted keeps submitted with the updated order when one is still pending (1.228041ms)
174
+ ✖ a failed refresh in submitted keeps the pending order and a later REFRESH retries (1002.164458ms)
175
+ ✔ a failed first load without a pending order still shows the form (2.062334ms)
176
+ ✔ REFRESH in loaded with a bound bank is still ignored (24.000333ms)
177
+ ℹ tests 6
178
+ ℹ suites 0
179
+ ℹ pass 5
180
+ ℹ fail 1
181
+ ℹ cancelled 0
182
+ ℹ skipped 0
183
+ ℹ todo 0
184
+ ℹ duration_ms 1039.1935
185
+ Error: Timed out waiting for submitted
186
+ at Timeout.eval (.../[eval1]:12:1, <anonymous>:7:45)
187
+ at listOnTimeout (node:internal/timers:605:17)
188
+ at process.processTimers (node:internal/timers:541:7)
189
+ exit: 1 (expected)
190
+ ```
191
+
192
+ C2-E3 independently repeats the exact R2-E3 root-boundary command:
193
+
194
+ ```text
195
+ PASS: root REFRESH no bank -> loading; bound bank -> loaded; no requests
196
+ exit: 0
197
+ ```
198
+
199
+ C2-E4: `git diff --check` produced no output. `shasum -a 256 src/machine/withdraw/withdraw_manual_cash.js test/withdraw_manual_cash.test.js` confirms the same reviewed product/test artifacts:
200
+
201
+ ```text
202
+ 13cfd851560c1b60c1bdf206d1c67d1db04d2f2db6652dde698659a34ec391f9 src/machine/withdraw/withdraw_manual_cash.js
203
+ fecacc81d718bc118f791d125768c0ee0204d89b9d3762d0ca15c45725c29268 test/withdraw_manual_cash.test.js
204
+ ```
205
+
206
+ `ps -eo pid,rss,command` was denied (`operation not permitted`). No server or background process was started; each Node tool call returned an exit status. No product file was changed by any probe.
207
+
208
+ ### Historical r1 evidence
209
+
210
+ These runs predate the r2 fix and preserve E1–E6 references in the append-only review log/notes. E5 records the original defect; current verification is R2-E1–E3 above.
211
+
212
+ E1 command and raw output (final targeted run):
213
+
214
+ ```text
215
+ $ node --test test/withdraw_manual_cash.test.js
216
+ ✔ REFRESH in submitted re-runs loading and fetches the pending order again (4.575458ms)
217
+ ✔ REFRESH in submitted returns to the form when no order is pending (0.872334ms)
218
+ ✔ REFRESH in submitted keeps submitted with the updated order when one is still pending (1.584917ms)
219
+ ✔ REFRESH in loaded with a bound bank is still ignored (23.343833ms)
220
+ ℹ tests 4
221
+ ℹ suites 0
222
+ ℹ pass 4
223
+ ℹ fail 0
224
+ ℹ cancelled 0
225
+ ℹ skipped 0
226
+ ℹ todo 0
227
+ ℹ duration_ms 119.1075
228
+ exit: 0
229
+ ```
230
+
231
+ E2 exact read-only probe:
232
+
233
+ ```sh
234
+ node --input-type=module <<'NODE'
235
+ import assert from 'node:assert/strict'
236
+ import factory from './src/machine/withdraw/withdraw_manual_cash.js'
237
+ const machine = factory({ send() { throw new Error('Pure transition check must not send requests') } })
238
+ assert.equal(machine.transition('loaded', 'REFRESH').value, 'loading')
239
+ const withBank = machine.withContext({ ...machine.context, userBanks: [{ bankCode: 'BANK' }] })
240
+ assert.equal(withBank.transition('loaded', 'REFRESH').value, 'loaded')
241
+ console.log('PASS: loaded + no bank -> loading; loaded + bound bank -> loaded (pure transitions, no network)')
242
+ NODE
243
+ ```
244
+
245
+ ```text
246
+ PASS: loaded + no bank -> loading; loaded + bound bank -> loaded (pure transitions, no network)
247
+ exit: 0
248
+ ```
249
+
250
+ E3 exact negative-control command (the changed guard exists only in a new in-memory machine):
251
+
252
+ ```sh
253
+ node --input-type=module <<'NODE'
254
+ import test from 'node:test'
255
+ import assert from 'node:assert/strict'
256
+ import { readFileSync } from 'node:fs'
257
+ import { interpret } from 'xstate'
258
+ import original from './src/machine/withdraw/withdraw_manual_cash.js'
259
+ const suite = readFileSync('test/withdraw_manual_cash.test.js', 'utf8').replace(/^import .*\n/gm, '')
260
+ const mutant = (...args) => original(...args).withConfig({ guards: { hasNoBank: () => true } })
261
+ console.log('NEGATIVE CONTROL ONLY: force hasNoBank=true in memory; repository files are unchanged')
262
+ new Function('test', 'assert', 'interpret', 'withdrawManualCash', suite)(test, assert, interpret, mutant)
263
+ NODE
264
+ ```
265
+
266
+ ```text
267
+ NEGATIVE CONTROL ONLY: force hasNoBank=true in memory; repository files are unchanged
268
+ ✔ REFRESH in submitted re-runs loading and fetches the pending order again (4.814583ms)
269
+ ✔ REFRESH in submitted returns to the form when no order is pending (1.313709ms)
270
+ ✔ REFRESH in submitted keeps submitted with the updated order when one is still pending (1.213916ms)
271
+ ✖ REFRESH in loaded with a bound bank is still ignored (1.107ms)
272
+ ℹ tests 4
273
+ ℹ suites 0
274
+ ℹ pass 3
275
+ ℹ fail 1
276
+ ℹ cancelled 0
277
+ ℹ skipped 0
278
+ ℹ todo 0
279
+ ℹ duration_ms 11.370083
280
+
281
+ ✖ failing tests:
282
+
283
+ ✖ REFRESH in loaded with a bound bank is still ignored (1.107ms)
284
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
285
+ false !== true
286
+ at TestContext.eval (...[eval1]:9:1), <anonymous>:103:12)
287
+ code: ERR_ASSERTION; actual: false; expected: true; operator: strictEqual
288
+ exit: 1 (expected)
289
+ ```
290
+
291
+ The negative control corresponds to `test/withdraw_manual_cash.test.js:105`; in the evaluated copy, import removal and Function wrapping shift the displayed line number. No files needed restoration.
292
+
293
+ E5 exact read-only convergence reproduction (local stub, no network or transaction):
294
+
295
+ ```sh
296
+ node --input-type=module <<'NODE'
297
+ import assert from 'node:assert/strict'
298
+ import { interpret } from 'xstate'
299
+ import factory from './src/machine/withdraw/withdraw_manual_cash.js'
300
+ const pending = { applyId: 'W-1', amount: 500 }
301
+ let pendingCalls = 0
302
+ const request = {
303
+ async send({ url }) {
304
+ if (url === 'payment/v2/getBindingPaymentInfo') return { bankList: [{ bankCode: 'BANK' }], ewalletList: [], cryptoList: [] }
305
+ if (url === 'payment/v2/withdrawRule') return { enableWithdraw: true }
306
+ if (url === 'payment/v2/pendingOrder') {
307
+ if (++pendingCalls === 1) return [pending]
308
+ throw { code: 'ERR_998' }
309
+ }
310
+ throw new Error(`Unexpected descriptor: ${url}`)
311
+ },
312
+ }
313
+ const service = interpret(factory(request, {
314
+ paymentDetail: [{ category: 'manual', transferType: 'withdraw', method: 'MANUAL', minimum: 100, maximum: 10000 }],
315
+ })).start()
316
+ async function waitFor(value) {
317
+ for (let i = 0; i < 100; i++) {
318
+ if (service.state.matches(value)) return
319
+ await new Promise(resolve => setTimeout(resolve, 1))
320
+ }
321
+ throw new Error(`Did not reach ${value}: ${service.state.value}`)
322
+ }
323
+ try {
324
+ await waitFor('submitted')
325
+ service.send('REFRESH')
326
+ await waitFor('loaded')
327
+ assert.deepEqual(service.state.context.processing, pending)
328
+ assert.equal(pendingCalls, 2)
329
+ service.send('REFRESH')
330
+ assert.equal(service.state.value, 'loaded')
331
+ assert.equal(pendingCalls, 2)
332
+ console.log('REPRODUCED: pendingOrder ERR_998 after submitted REFRESH -> loaded, stale processing W-1; bound-bank REFRESH retry ignored (2 calls).')
333
+ } finally {
334
+ service.stop()
335
+ }
336
+ NODE
337
+ ```
338
+
339
+ ```text
340
+ REPRODUCED: pendingOrder ERR_998 after submitted REFRESH -> loaded, stale processing W-1; bound-bank REFRESH retry ignored (2 calls).
341
+ exit: 0
342
+ ```
343
+
344
+ This run asserts the observed bad outcome to prove the counterexample. It does not claim that error recovery passed. The production Request path rethrows ERR_998 without errorHandler (`src/request/request.js:337–338`), matching the stub's rejection contract. No duplicate submission or rendered downstream outcome was tested.
345
+
346
+ E6 command and raw output:
347
+
348
+ ```text
349
+ $ node --test test/withdraw_manual_cash.test.js
350
+ ✔ REFRESH in submitted re-runs loading and fetches the pending order again (4.547083ms)
351
+ ✔ REFRESH in submitted returns to the form when no order is pending (0.8585ms)
352
+ ✔ REFRESH in submitted keeps submitted with the updated order when one is still pending (1.423208ms)
353
+ ✔ REFRESH in loaded with a bound bank is still ignored (22.29425ms)
354
+ ℹ tests 4
355
+ ℹ suites 0
356
+ ℹ pass 4
357
+ ℹ fail 0
358
+ ℹ cancelled 0
359
+ ℹ skipped 0
360
+ ℹ todo 0
361
+ ℹ duration_ms 115.091791
362
+ exit: 0
363
+ ```
364
+
365
+ ---
366
+
367
+ ## Conditional Review Triggers
368
+
369
+ | Trigger | Hit | Action |
370
+ | ---------------------------------- | --- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
371
+ | Stateful SDK error/retry selection | YES | Trace invoke rejection, guarded transition, context preservation, successful assignment/checking, handler precedence and root guard. No identity/storage/attribution/queue changes, so those sdk-state.md sections do not apply. |
372
+ | Required SDK UI checks | NO | No SDK UI runtime; explicit user choice A. Rendered cash evidence is outside this repo review. |
373
+
374
+ ---
375
+
376
+ ## 📋 Spec Validation (Aligned with review-playbook)
377
+
378
+ The driver restricts review inputs; no checklist or author analysis was read. Rows cite raw spec clauses and the explicit acceptance criteria rather than claim unseen checklist alignment. The fresh convergence check repeats the whole-change source review and C2-E1–C2-E3 checks independently.
379
+
380
+ | Spec Item | Evidence (File/Line/Result) | Status |
381
+ | ----------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
382
+ | Confirmed — submitted REFRESH reloads pending order (spec-snapshot.md:76) | Handler :100 -> invoke :34 -> getPendingOrder :276; test :58-70 asserts loading and query 2; R2-E1. | PASS |
383
+ | Confirmed — empty response returns form; remaining order updates pending (spec-snapshot.md:71), SDK state portion | setInitData :172-184 -> checking :44; tests :72-100 assert undefined processing/loaded and replacement W-2/submitted; R2-E1. | PASS |
384
+ | Confirmed r2 — failure preserves Pending and permits bound-bank retry | onError :40 uses isProcessing :229-230 and skips assignment; test :106-121 proves retained W-1 and call 3; R2-E1/E2. F-r1-01 verified yes. | PASS |
385
+ | Confirmed r2 — first-load failure preserves previous behavior | processing starts null at :21; fallback :40 -> loaded; test :123-133, R2-E1. | PASS |
386
+ | Confirmed r2 regression — non-submitted root guard unchanged | Root :159 and hasNoBank :226-227 unchanged; test :135-149 and R2-E3. Other non-submitted states inspected only. | PASS |
387
+ | Conditional SDK WebSocket filter relaxation (spec-snapshot.md:77) | src/machine/websocket.js:296-301 already forwards payment-info without a toast filter; no additional filter patch required on this static criterion. Real payload behavior is unverified. | PASS |
388
+ | Full cash UI / WebSocket strict-ID / published-package integration | Outside SDK repo review; cash flow owns verification. | NOT RUN |
389
+
390
+ ---
391
+
392
+ ## 📋 Standards Checklist (Summary)
393
+
394
+ | Category | Result | Notes |
395
+ | ------------------- | ------- | ------------------------------------------------------------------------------------------------------------- |
396
+ | XState v4 / context | PASS | Reuses isProcessing; rejection adds no assignment; successful onDone unchanged. |
397
+ | Correctness | PASS | All selected whole-change SDK acceptance cases pass; F-r1-01 independently verified again during convergence. |
398
+ | Security | NOT RUN | No wider security audit; no auth/request-boundary edits or remote requests. |
399
+ | Performance | PASS | Static inspection: no new timer, loop or dependency; retries remain explicit REFRESH events. No benchmark. |
400
+ | Project Conventions | PASS | Minimal guarded transition fits existing checking pattern; whitespace check passes. No formatter/lint run. |
401
+
402
+ ## Conclusion
403
+
404
+ The fresh r2 convergence reviewer independently checked the complete base-to-working-tree change before reading prior review records and found no additional product-code defect. F-r1-01 remains ACCEPT + verified in r2 yes. Targeted tests pass 6/6, the old-onError negative control fails exactly the new retry case as expected, and both root guard boundaries pass. The r2 Impact block now covers the whole change with one line for each of the three internal consumers. This independent review is complete within the assigned SDK scope. The driver must run check-review.sh and update STATE; this report does not declare loop convergence or readiness to publish.
405
+
406
+ Limits: injected local ERR_998 responses exercise the real initializer but not transport/backend, cash rendering, real WebSocket payloads, published-package wiring, alternate wallet gates, OTP, exhaustive non-submitted events or other errors. No browser ran, so browser exceptions were not assessed. ps -eo pid,rss,command was denied (operation not permitted); no server/background process started, all Node commands exited. Only three assigned review files were written; STATE remains the driver's responsibility. Convergence pre-edit backups: /var/folders/s8/rjb4nddx2f1c_nl7p_wwz8kh0000gn/T/TI-16026-cuora-r2-convergence.iivyDMK8Pm/.
407
+
408
+ **Overall Result:** PASS
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- // Copyright 2024 The Terasology Foundation
3
2
 
4
3
  // dev/qa 分支自動計算下一個 prerelease 版號
5
4
  // 版號格式:{master 版號}-{分支名}.{遞增編號}
@@ -14,15 +14,8 @@ const { version } = JSON.parse(readFileSync('package.json', 'utf8'))
14
14
  console.log(`Branch: ${branch}`)
15
15
  console.log(`Version: ${version}`)
16
16
 
17
- // 推送 commit 到遠端(--no-verify 避免觸發 pre-push hook 造成無限迴圈)
18
- execSync(`git push --no-verify ${remote} ${branch}`, { stdio: 'inherit' })
19
-
20
- // 單獨推送 tag;tag 已存在於 remote 時視為成功(不中斷 npm publish)
21
- try {
22
- execSync(`git push --no-verify ${remote} refs/tags/v${version}`, { stdio: 'inherit' })
23
- } catch {
24
- console.warn(`⚠ tag v${version} push 失敗(可能已存在),繼續 npm publish`)
25
- }
17
+ // 推送 commit 與 tag 到遠端(--no-verify 避免觸發 pre-push hook 造成無限迴圈)
18
+ execSync(`git push --no-verify --follow-tags ${remote} ${branch}`, { stdio: 'inherit' })
26
19
 
27
20
  // 發布到 npm,使用分支名稱作為 dist-tag(例如 npm install @jetthai/cuora@dev)
28
21
  try {
@@ -209,5 +209,4 @@ export default {
209
209
  isPublic: true,
210
210
  }),
211
211
  getPaymentPromotions: () => ({ url: 'payment/v2/promotions', method: 'get' }),
212
- setBonusSetting: ({ bonus }) => ({ url: 'payment/v2/setting', method: 'post', params: { bonus } }),
213
212
  }
@@ -8,7 +8,8 @@ import pickBy from 'lodash/pickBy.js'
8
8
  import { readParamFromLocation, writeParam, normalize, AC_KEYS, FC_KEYS } from '../util/paramStore.js'
9
9
 
10
10
  export default function (request) {
11
- const { appSecret, sentry } = request.config
11
+ const { appSecret, clientId, sentry } = request.config
12
+ const tokenKey = `cuora_${clientId}`
12
13
  const phoneCountryCode = 'phone_countrycode'
13
14
  const accountPhoneKey = 'account_phone'
14
15
  const accountEmailKey = 'account_email'
@@ -414,12 +415,16 @@ export default function (request) {
414
415
  }
415
416
  }),
416
417
  fetchToken: assign((context, event) => {
418
+ const token = storage.get(tokenKey)
417
419
  return {
418
- token: request.getToken(),
420
+ token,
419
421
  }
420
422
  }),
421
423
  setToken: assign((context, event) => {
422
- request.setToken(event.data)
424
+ storage.set(tokenKey, event.data, {
425
+ path: '/',
426
+ maxAge: 300,
427
+ })
423
428
  return {
424
429
  token: event.data,
425
430
  }
@@ -461,11 +466,19 @@ export default function (request) {
461
466
  }
462
467
  }),
463
468
  removeToken: assign((context, event) => {
464
- request.removeToken()
469
+ storage.remove(tokenKey, {
470
+ path: '/',
471
+ maxAge: 300,
472
+ })
465
473
  return { token: null, dt: null }
466
474
  }),
467
475
  extendToken: assign((context, event) => {
468
- return { token: request.extendToken() }
476
+ const token = storage.get(tokenKey)
477
+ storage.set(tokenKey, token, {
478
+ path: '/',
479
+ maxAge: 300,
480
+ })
481
+ return { token }
469
482
  }),
470
483
  redirectTo3Party: async (context, event) => {
471
484
  const { provider, fc } = event.data
@@ -6,8 +6,6 @@ import { GAME_SEARCH } from '../util/constant.js'
6
6
  // 對應 intersectionObserver 版本
7
7
  export default function (request) {
8
8
  const { appSecret } = request.config
9
- // 不呼叫 game/logout 直接回 idle:session 已換新時,舊 session 的遊戲登出沒有意義
10
- const abandonGame = { target: 'idle', actions: 'clearGameURL' }
11
9
  return createMachine(
12
10
  {
13
11
  id: 'game',
@@ -162,7 +160,6 @@ export default function (request) {
162
160
  EXIT_GAME: {
163
161
  target: 'disconnect',
164
162
  },
165
- ABANDON_GAME: abandonGame,
166
163
  },
167
164
  },
168
165
  demoGame: {
@@ -181,7 +178,6 @@ export default function (request) {
181
178
  EXIT_GAME: {
182
179
  target: 'disconnect',
183
180
  },
184
- ABANDON_GAME: abandonGame,
185
181
  },
186
182
  },
187
183
  connectSwitching: {
@@ -200,7 +196,6 @@ export default function (request) {
200
196
  EXIT_GAME: {
201
197
  target: 'disconnect',
202
198
  },
203
- ABANDON_GAME: abandonGame,
204
199
  },
205
200
  },
206
201
  playing: {
@@ -208,7 +203,6 @@ export default function (request) {
208
203
  EXIT_GAME: {
209
204
  target: 'disconnect',
210
205
  },
211
- ABANDON_GAME: abandonGame,
212
206
  REFRESH: {
213
207
  target: 'refreshing',
214
208
  },
@@ -230,7 +224,6 @@ export default function (request) {
230
224
  EXIT_GAME: {
231
225
  target: 'disconnect',
232
226
  },
233
- ABANDON_GAME: abandonGame,
234
227
  EXIT_DEMO_GAME: {
235
228
  target: 'idle',
236
229
  },
@@ -252,9 +245,6 @@ export default function (request) {
252
245
  actions: 'setGameURL',
253
246
  },
254
247
  },
255
- on: {
256
- ABANDON_GAME: abandonGame,
257
- },
258
248
  },
259
249
  refreshPending: {
260
250
  after: {
@@ -262,9 +252,6 @@ export default function (request) {
262
252
  target: 'connecting',
263
253
  },
264
254
  },
265
- on: {
266
- ABANDON_GAME: abandonGame,
267
- },
268
255
  },
269
256
  disconnect: {
270
257
  invoke: {
@@ -279,7 +266,6 @@ export default function (request) {
279
266
  },
280
267
  },
281
268
  on: {
282
- ABANDON_GAME: abandonGame,
283
269
  LOAD: {
284
270
  target: 'routing',
285
271
  actions: 'setLoadable',
@@ -440,7 +426,6 @@ export default function (request) {
440
426
  return event.data.gameWalletType
441
427
  },
442
428
  }),
443
- clearGameURL: assign({ type: undefined, gameToken: undefined, gameHtml: undefined, gameURL: undefined, gameWalletType: undefined }),
444
429
  setGameInfo: assign((context, event) => {
445
430
  const { providerId, gameId, gameTypeId, mappingId, portrait, gameCode, name, gameName } = event.data.game
446
431
  return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0, gameCode, name, gameName } }
@@ -197,7 +197,7 @@ export default function (request, context) {
197
197
  )
198
198
  const getOtherRewardAPI = request.send(
199
199
  activity.getRewardList({
200
- rewardType: 'CASH,FREE,PRIZE,GAME',
200
+ rewardType: 'CASH,FREE,PRIZE',
201
201
  count: 30,
202
202
  appSecret,
203
203
  orderColumn,
@@ -212,7 +212,7 @@ export default function (request, context) {
212
212
  const lang = context.lang
213
213
  const getOtherRewardAPI = request.send(
214
214
  activity.getRewardList({
215
- rewardType: 'CASH,FREE,PRIZE,GAME',
215
+ rewardType: 'CASH,FREE,PRIZE',
216
216
  count: 30,
217
217
  appSecret,
218
218
  orderColumn,
@@ -107,7 +107,6 @@ export default function (request) {
107
107
  return {
108
108
  signUpData: {
109
109
  provider: 'local',
110
- birthday,
111
110
  ...pickBindData(event.data),
112
111
  birthday,
113
112
  email,
@@ -131,7 +130,6 @@ export default function (request) {
131
130
  return {
132
131
  signUpData: {
133
132
  provider: 'phone',
134
- birthday,
135
133
  ...pickBindData(event.data),
136
134
  birthday,
137
135
  email,
@@ -154,7 +152,6 @@ export default function (request) {
154
152
  return {
155
153
  signUpData: {
156
154
  provider: 'email',
157
- birthday,
158
155
  ...pickBindData(event.data),
159
156
  birthday,
160
157
  email,
@@ -36,8 +36,9 @@ export default function (request, context) {
36
36
  target: 'checking',
37
37
  actions: 'setInitData',
38
38
  },
39
- // submitted 的 REFRESH 失敗時無法確認訂單已結束,保留原 Pending 畫面讓下次 REFRESH 可重試
40
- onError: [{ target: 'submitted', cond: 'isProcessing' }, { target: 'loaded' }],
39
+ onError: {
40
+ target: 'loaded',
41
+ },
41
42
  },
42
43
  },
43
44
  checking: {
@@ -95,11 +96,7 @@ export default function (request, context) {
95
96
  },
96
97
  },
97
98
  },
98
- submitted: {
99
- on: {
100
- REFRESH: { target: 'loading', internal: false },
101
- },
102
- },
99
+ submitted: {},
103
100
  otp: {
104
101
  type: 'parallel',
105
102
  states: {
@@ -135,9 +132,16 @@ export default function (request, context) {
135
132
  target: '#withdraw_manual_cash.submitted',
136
133
  actions: 'setProcessing',
137
134
  },
138
- onError: {
139
- target: '#withdraw_manual_cash.calculated',
140
- },
135
+ // 驗證碼錯誤(ERR_M129)留在 OTP 讓前台就地顯示錯誤、玩家重填;其他錯誤照舊回到 calculated
136
+ onError: [
137
+ {
138
+ target: 'idle',
139
+ cond: (context, event) => event.data?.code === 'ERR_M129',
140
+ },
141
+ {
142
+ target: '#withdraw_manual_cash.calculated',
143
+ },
144
+ ],
141
145
  },
142
146
  },
143
147
  reset: {