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

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 (87) hide show
  1. package/.github/copilot-instructions.md +69 -32
  2. package/AGENTS.md +69 -32
  3. package/AI_PROMPT_SOURCE.md +69 -32
  4. package/CHANGELOG.md +9 -0
  5. package/CLAUDE.md +69 -32
  6. package/GEMINI.md +69 -32
  7. package/package.json +1 -1
  8. package/src/machine/auth.js +5 -18
  9. package/src/machine/game_v2_1.js +15 -0
  10. package/src/request/request.js +44 -4
  11. package/src/util/constant.js +5 -1
  12. package/src/util/tokenStore.js +44 -0
  13. package/tests/session.test.mjs +177 -0
  14. package/e2e/feature-map.md +0 -61
  15. package/prepare-for-pr/JT-1776243420.md +0 -85
  16. package/prepare-for-pr/TI-16026/STATE.md +0 -17
  17. package/prepare-for-pr/TI-16026/after-prepare-authorization.md +0 -3
  18. package/prepare-for-pr/TI-16026/analysis.md +0 -38
  19. package/prepare-for-pr/TI-16026/answer-analyze-01.md +0 -1
  20. package/prepare-for-pr/TI-16026/answer-commit-01.md +0 -2
  21. package/prepare-for-pr/TI-16026/answer-commit-02.md +0 -1
  22. package/prepare-for-pr/TI-16026/bundle.json +0 -18
  23. package/prepare-for-pr/TI-16026/checklist.md +0 -39
  24. package/prepare-for-pr/TI-16026/claude-after-model +0 -1
  25. package/prepare-for-pr/TI-16026/claude-commit-session +0 -1
  26. package/prepare-for-pr/TI-16026/claude-harvest-session +0 -1
  27. package/prepare-for-pr/TI-16026/claude-hops/01-analyze.err +0 -1
  28. package/prepare-for-pr/TI-16026/claude-hops/01-analyze.out +0 -2
  29. package/prepare-for-pr/TI-16026/claude-hops/02-analyze.err +0 -1
  30. package/prepare-for-pr/TI-16026/claude-hops/02-analyze.out +0 -4
  31. package/prepare-for-pr/TI-16026/claude-hops/03-dev.err +0 -1
  32. package/prepare-for-pr/TI-16026/claude-hops/03-dev.out +0 -4
  33. package/prepare-for-pr/TI-16026/claude-hops/04-dev.err +0 -1
  34. package/prepare-for-pr/TI-16026/claude-hops/04-dev.out +0 -4
  35. package/prepare-for-pr/TI-16026/claude-hops/05-dev.err +0 -1
  36. package/prepare-for-pr/TI-16026/claude-hops/05-dev.out +0 -3
  37. package/prepare-for-pr/TI-16026/claude-hops/06-after.err +0 -1
  38. package/prepare-for-pr/TI-16026/claude-hops/06-after.out +0 -2
  39. package/prepare-for-pr/TI-16026/claude-hops/07-commit.err +0 -1
  40. package/prepare-for-pr/TI-16026/claude-hops/07-commit.out +0 -2
  41. package/prepare-for-pr/TI-16026/claude-hops/08-commit.err +0 -1
  42. package/prepare-for-pr/TI-16026/claude-hops/08-commit.out +0 -2
  43. package/prepare-for-pr/TI-16026/claude-hops/09-commit.err +0 -1
  44. package/prepare-for-pr/TI-16026/claude-hops/09-commit.out +0 -8
  45. package/prepare-for-pr/TI-16026/claude-hops/10-harvest.err +0 -1
  46. package/prepare-for-pr/TI-16026/claude-hops/10-harvest.out +0 -3
  47. package/prepare-for-pr/TI-16026/commit-note.md +0 -5
  48. package/prepare-for-pr/TI-16026/feature-map.before.md +0 -61
  49. package/prepare-for-pr/TI-16026/harvest-redaction.out +0 -1
  50. package/prepare-for-pr/TI-16026/harvest.md +0 -37
  51. package/prepare-for-pr/TI-16026/lessons.md +0 -5
  52. package/prepare-for-pr/TI-16026/open-questions.md +0 -6
  53. package/prepare-for-pr/TI-16026/publish.md +0 -28
  54. package/prepare-for-pr/TI-16026/review-convergence-response.md +0 -3
  55. package/prepare-for-pr/TI-16026/review-input/scope.md +0 -18
  56. package/prepare-for-pr/TI-16026/review-log.md +0 -57
  57. package/prepare-for-pr/TI-16026/review-notes.md +0 -97
  58. package/prepare-for-pr/TI-16026/review-response-r1.md +0 -7
  59. package/prepare-for-pr/TI-16026/spec-proposal.md +0 -34
  60. package/prepare-for-pr/TI-16026/spec-snapshot.md +0 -291
  61. package/prepare-for-pr/TI-16026/state-log.md +0 -35
  62. package/prepare-for-pr/TI-16026/user-messages/01.md +0 -12
  63. package/prepare-for-pr/TI-16026/user-messages/02.md +0 -20
  64. package/prepare-for-pr/TI-16026/user-messages/03.md +0 -1
  65. package/prepare-for-pr/TI-16026/user-messages/04.md +0 -1
  66. package/prepare-for-pr/TI-16026/user-messages/05.md +0 -1
  67. package/prepare-for-pr/TI-16026/user-messages/06.md +0 -1
  68. package/prepare-for-pr/TI-16026/user-messages/07.md +0 -1
  69. package/prepare-for-pr/TI-16026/user-messages/08.md +0 -1
  70. package/prepare-for-pr/TI-16026/user-messages/09.md +0 -1
  71. package/prepare-for-pr/TI-16026/user-messages/10.md +0 -1
  72. package/prepare-for-pr/TI-16026/user-messages/11.md +0 -1
  73. package/prepare-for-pr/TI-16026/user-messages/12.md +0 -1
  74. package/prepare-for-pr/TI-16026/user-messages/13.md +0 -1
  75. package/prepare-for-pr/TI-16026/user-messages/14.md +0 -1
  76. package/prepare-for-pr/TI-16026/user-messages/15.md +0 -1
  77. package/prepare-for-pr/TI-16026/user-messages/16.md +0 -1
  78. package/prepare-for-pr/TI-16026/user-messages/17.md +0 -1
  79. package/prepare-for-pr/TI-16026/user-messages/18.md +0 -10
  80. package/prepare-for-pr/TI-16026/user-messages/19.md +0 -1
  81. package/prepare-for-pr/TI-16026/user-messages/20.md +0 -1
  82. package/prepare-for-pr/TI-16026/user-messages/21.md +0 -1
  83. package/prepare-for-pr/TI-16026/user-messages/22.md +0 -1
  84. package/prepare-for-pr/TI-16026/user-messages/23.md +0 -8
  85. package/prepare-for-pr/TI-16026/user-question.md +0 -24
  86. package/prepare-for-pr/TI-16026/verify-after.md +0 -15
  87. package/prepare-for-pr/TI-16026.md +0 -408
@@ -0,0 +1,177 @@
1
+ import test from 'node:test'
2
+ import assert from 'node:assert/strict'
3
+ import { interpret } from 'xstate'
4
+ import Request from '../src/request/request.js'
5
+ import createTokenStore from '../src/util/tokenStore.js'
6
+ import { TOKEN_MAX_AGE } from '../src/util/constant.js'
7
+ import game from '../src/machine/game_v2_1.js'
8
+
9
+ globalThis.localStorage = { getItem: () => null, setItem() {}, removeItem() {} }
10
+ globalThis.location = { protocol: 'http:' }
11
+
12
+ // 只模擬 tokenStore 用到的行為:以 name 覆寫、Max-Age=0 即刪除
13
+ function installDocument() {
14
+ const jar = new Map()
15
+ const writes = []
16
+ globalThis.document = {
17
+ get cookie() {
18
+ return [...jar].map(([name, value]) => `${name}=${value}`).join('; ')
19
+ },
20
+ set cookie(text) {
21
+ writes.push(text)
22
+ const [pair, ...attributes] = text.split('; ')
23
+ const index = pair.indexOf('=')
24
+ const name = pair.slice(0, index)
25
+ const maxAge = attributes.find((item) => item.startsWith('Max-Age='))
26
+ if (maxAge && Number(maxAge.slice(8)) <= 0) jar.delete(name)
27
+ else jar.set(name, pair.slice(index + 1))
28
+ },
29
+ }
30
+ return { jar, writes }
31
+ }
32
+
33
+ function createRequest(respond) {
34
+ const calls = []
35
+ const axios = {
36
+ defaults: {},
37
+ interceptors: { request: { use() {} }, response: { use() {} } },
38
+ isCancel: () => false,
39
+ async request(config) {
40
+ calls.push(config.url)
41
+ return respond(config, calls.length)
42
+ },
43
+ }
44
+ const request = new Request(axios, { clientId: 'SITE', fullURL: 'https://api.test/v1/SITE' })
45
+ const handled = []
46
+ request.setErrorHandler((error) => handled.push(error.code))
47
+ return { request, calls, handled }
48
+ }
49
+
50
+ const expired = () => Promise.reject({ code: 'ERR_A108' })
51
+ const ok = (data = {}) => Promise.resolve({ data })
52
+
53
+ test('token lives in a host-only cookie with a 300 second lifetime', () => {
54
+ const { jar, writes } = installDocument()
55
+ const store = createTokenStore('cuora_SITE')
56
+
57
+ assert.equal(store.get(), null)
58
+ store.set('token.a')
59
+ assert.equal(store.get(), 'token.a')
60
+ assert.equal(writes.at(-1), `cuora_SITE=token.a; Path=/; Max-Age=${TOKEN_MAX_AGE}; SameSite=Lax`)
61
+ assert.ok(!/Domain=/i.test(writes.at(-1)))
62
+
63
+ jar.set('cuora_SITE-cred', 'sealed')
64
+ assert.equal(store.get(), 'token.a')
65
+
66
+ const before = writes.length
67
+ assert.equal(store.extend(), 'token.a')
68
+ assert.equal(writes.length, before + 1)
69
+
70
+ store.clear()
71
+ assert.equal(store.get(), null)
72
+ assert.equal(store.extend(), null)
73
+ })
74
+
75
+ test('request reads and writes the token through the cookie', () => {
76
+ installDocument()
77
+ const { request } = createRequest(() => ok())
78
+
79
+ request.setToken('token.a')
80
+ assert.equal(request.getToken(), 'token.a')
81
+ assert.equal(request.extendToken(), 'token.a')
82
+ request.removeToken()
83
+ assert.equal(request.getToken(), null)
84
+ })
85
+
86
+ test('ERR_A108 renews through /self and resends the request once', async () => {
87
+ installDocument()
88
+ const { request, calls, handled } = createRequest((config, count) => (count === 1 ? expired() : ok({ url: config.url })))
89
+ request.setToken('token.a')
90
+
91
+ const result = await request.send({ url: 'payment/v2/setting', method: 'get' })
92
+
93
+ assert.deepEqual(calls, ['payment/v2/setting', 'self', 'payment/v2/setting'])
94
+ assert.deepEqual(result, { url: 'payment/v2/setting' })
95
+ assert.deepEqual(handled, [])
96
+ })
97
+
98
+ test('a resent request that still fails with ERR_A108 is routed as before', async () => {
99
+ installDocument()
100
+ const { request, calls, handled } = createRequest((config) => (config.url === 'self' ? ok() : expired()))
101
+ request.setToken('token.a')
102
+
103
+ await assert.rejects(request.send({ url: 'payment/v2/setting', method: 'get' }), { code: 'ERR_A108' })
104
+
105
+ assert.deepEqual(calls, ['payment/v2/setting', 'self', 'payment/v2/setting'])
106
+ assert.deepEqual(handled, ['ERR_A108'])
107
+ })
108
+
109
+ test('ERR_A108 is not resent when /self cannot renew the session', async () => {
110
+ installDocument()
111
+ const { request, calls, handled } = createRequest(() => expired())
112
+ request.setToken('token.a')
113
+
114
+ await assert.rejects(request.send({ url: 'payment/v2/setting', method: 'get' }), { code: 'ERR_A108' })
115
+
116
+ assert.deepEqual(calls, ['payment/v2/setting', 'self'])
117
+ assert.deepEqual(handled, ['ERR_A108'])
118
+ })
119
+
120
+ test('/self itself and public requests are never resent', async () => {
121
+ installDocument()
122
+ const { request, calls } = createRequest(() => expired())
123
+ request.setToken('token.a')
124
+
125
+ await assert.rejects(request.send({ url: 'self', method: 'get' }), { code: 'ERR_A108' })
126
+ await assert.rejects(request.send({ url: 'getConfig', method: 'get', isPublic: true }), { code: 'ERR_A108' })
127
+
128
+ assert.deepEqual(calls, ['self', 'get-config'])
129
+ })
130
+
131
+ test('a request whose identity changed while renewing is not resent', async () => {
132
+ installDocument()
133
+ let request
134
+ const created = createRequest((config, count) => {
135
+ if (count === 1) return expired()
136
+ request.setToken('token.b')
137
+ return ok()
138
+ })
139
+ request = created.request
140
+ request.setToken('token.a')
141
+
142
+ await assert.rejects(request.send({ url: 'payment/v2/setting', method: 'get' }), { code: 'ERR_A108' })
143
+
144
+ assert.deepEqual(created.calls, ['payment/v2/setting', 'self'])
145
+ assert.deepEqual(created.handled, [])
146
+ })
147
+
148
+ test('ABANDON_GAME leaves a game without calling game/logout', async () => {
149
+ installDocument()
150
+ const sent = []
151
+ const request = {
152
+ config: { appSecret: 'secret' },
153
+ async send(descriptor) {
154
+ sent.push(descriptor.url)
155
+ return { type: 'url', redirect_url: 'https://game.test', wallet_type: 'CASH' }
156
+ },
157
+ }
158
+ globalThis.window = { location: { origin: 'https://site.test', href: 'https://site.test/play', search: '' } }
159
+ const service = interpret(game(request)).start()
160
+
161
+ service.send({
162
+ type: 'ENTER_GAME',
163
+ data: { game: { providerId: 'P', gameId: 'G', gameTypeId: 'SLOT', mappingId: 1 }, locale: 'en-US' },
164
+ })
165
+ await new Promise((resolve) => setTimeout(resolve, 0))
166
+ assert.ok(service.state.matches('flow.playing'))
167
+ assert.equal(service.state.context.gameURL, 'https://game.test')
168
+
169
+ service.send({ type: 'ABANDON_GAME' })
170
+ assert.ok(service.state.matches('flow.idle'))
171
+ assert.equal(service.state.context.gameURL, undefined)
172
+
173
+ service.send({ type: 'EXIT_GAME', data: 'uid' })
174
+ assert.ok(service.state.matches('flow.idle'))
175
+ assert.ok(!sent.includes('game/logout'))
176
+ service.stop()
177
+ })
@@ -1,61 +0,0 @@
1
- # Feature map — per-repo scenario knowledge that outlives a bundle
2
-
3
- A task bundle is removed after delivery and commit (bundle-contract.md "Retention"), and with it everything the task learned about reaching its screens: routes, preconditions, selectors that held, states a site can or cannot show, and the methods that wasted runs. The feature map keeps that knowledge, per repo, for the next task. Model: pstack create-verification-skill "feature map" / control adapter.
4
-
5
- ## Where
6
-
7
- `<repoRoot>/e2e/feature-map.md`, beside `e2e/review-playbook.md`. Local only, never tracked: the repo's `.gitignore` or the global excludes file must ignore it. `call-claude.sh --stage harvest` refuses to run when `git check-ignore` does not report it ignored.
8
-
9
- The map holds per-feature knowledge. Repo-wide rules the review relies on stay in `e2e/review-playbook.md`, which the harvest never edits; a harvest finding that contradicts the playbook is reported, not written there.
10
-
11
- ## Format
12
-
13
- ```markdown
14
- # Feature map — <repo>
15
-
16
- Hints, not facts: verify any line you rely on with this task's own BEFORE capture.
17
- Each line ends with (observed YYYY-MM-DD <TASK-id>) = the last task that confirmed it.
18
-
19
- ## Repo-wide
20
-
21
- - <runtime gotcha that affects every feature: cause → workaround> (observed …)
22
-
23
- ## <screen or route> e.g. `/main` lobby — game cards
24
-
25
- - Entry: <route or menu path>; site <CONFIG_NAME>; viewport <w×h> (observed …)
26
- - Preconditions: <guest | logged-in, account kind only>; backend <dev|qa>; data <API path or fixture boundary> (observed …)
27
- - Selectors: <stable anchor> — `<file:line>` (observed …)
28
- - States: <state> — <how it is reached (fixture, fault, menu)> | unreachable on <site>: <evidence> (observed …)
29
- - Gotchas: <what failed, its proven cause> → <what works>; see measurement-recipes.md "<row>" when it applies (observed …)
30
- ```
31
-
32
- - One `##` section per screen or route; `## Repo-wide` first. Section keys use the screen names `repos.md` uses, so the analyze hop can find them.
33
- - Size cap: about 300 lines for the file, 25 lines per section.
34
- - Only what a capture, a measurement or the code showed. A guess, a plan not run, or "not found" without saying how far the search went (e.g. sub-menus not expanded) is either written with that limit or left out.
35
-
36
- ## Credentials (README hard rule 5a, text rule)
37
-
38
- The map is text evidence: no account value, password, token, test display name, or any value from `e2e/test-accounts.local.json`. Name an account by its kind ("logged-in member with a wallet", "the site's test account via `--auth accounts`"). The harvest stage runs `runner/redaction-check.mjs` on the map after Claude writes it and restores the previous map on any hit.
39
-
40
- ## Who reads it
41
-
42
- | Reader | When | How |
43
- | ------------------------------------------------ | ------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
44
- | Claude analyze hop (`/ui-baseline-codex` Step 1) | before writing `scenarios.mjs`, fixtures and selectors | read `## Repo-wide` and the sections for the screens in this repo's `repos.md` row; list the lines used under `## Feature map lines used` in `analysis.md` (section + line text) |
45
- | Claude verify-before hop (Step 2) | a capture failed | check the matching Gotchas before writing a Retake basis; a known cause with a known workaround is the Retake basis |
46
- | `/qa-fix` | writing "How to verify" | entry, site and preconditions for the screen; read only, never written (no runtime observation happens there) |
47
-
48
- ## Who writes it — the harvest hop
49
-
50
- Driver: after `NEXT: committed` (and after a supplement's delivery), **before** the bundle removal, Codex runs `call-claude.sh --stage harvest`. Always a new Claude session. Claude reads the bundle's text files and updates the map; the script backs the map up into the bundle, allows only the map to change, and runs the redaction check. Claude command "Harvest" holds the procedure. The same hop routes the run's other lessons (Codex's `lessons.md`) to a script check, `measurement-recipes.md` or a flow-file line — as proposals in `harvest.md` `## Lesson routing` for the user to approve; it writes nothing but the map. The bundle stays until the user has answered each proposal (bundle-contract.md Retention "When the removal runs").
51
-
52
- ## Pruning
53
-
54
- In this order, on every harvest, within the sections this task touched (and `## Repo-wide`):
55
-
56
- 1. **Invalidated by evidence** — a line this task's capture or code contradicts is replaced by the new observation (never kept beside it); a `file:line` that no longer exists is fixed or the line removed; a screen the code no longer has loses its section.
57
- 2. **Confirmed** — a line listed under `## Feature map lines used` in `analysis.md` that this task's BEFORE capture bore out gets this task's date and ID.
58
- 3. **Merged** — duplicates and lines that say the same thing are merged into one.
59
- 4. **Over the cap** — only then, remove the lines unconfirmed for longest (oldest `observed`). Age alone is a weak signal, so this is the last step, not the first.
60
-
61
- Claude writes `prepare-for-pr/{TASK-id}/harvest.md`: lines added, lines confirmed, every line removed with its reason (1, 3 or 4), and any contradiction with `e2e/review-playbook.md`. Codex copies it into the final report before the bundle is removed, so a removal stays visible.
@@ -1,85 +0,0 @@
1
- # JT-1776243420: Third-Party Register Carry Phone / Email Payload
2
-
3
- ## Key Changes
4
-
5
- 1. Extended third-party redirect payload assembly to read `tp_phone`, `tp_countryCode`, and `tp_email` from storage.
6
- 2. Preserved existing affiliate code / nickname behavior and appended new fields only when values are valid.
7
- 3. Cleans the temporary third-party storage keys after composing the redirect query.
8
-
9
- ---
10
-
11
- ## Key Findings
12
-
13
- ### Strengths
14
-
15
- 1. The change is tightly scoped to the third-party auth redirect builder in `src/machine/auth.js:477-520`.
16
- 2. Existing affiliate code and nickname logic remains unchanged while phone / email are additive only.
17
- 3. Temporary keys are removed after payload composition, reducing leakage into later unrelated auth flows.
18
-
19
- ---
20
-
21
- ### Behavior Observed
22
-
23
- 1. Static review confirms `phone`, `countryCode`, and `email` are appended only when storage values are not `undefined` / `null`.
24
- 2. Channel and subchannel fallback logic stays intact after the new fields are added.
25
- 3. No unrelated file changes were present in this repo for the review scope.
26
-
27
- ---
28
-
29
- ## 🔧 Change Type
30
-
31
- - [ ] 🐛 Bug fix
32
- - [x] ✨ New feature
33
- - [ ] 💄 Style
34
- - [ ] ♻️ Refactor
35
- - [ ] ⚡ Performance
36
- - [ ] 🔧 Chore
37
-
38
- ---
39
-
40
- ## 📱 Impact Scope
41
-
42
- - Third-party register / login redirect query assembly in cuora shared auth machine.
43
- - Downstream PWA clients that store `tp_phone`, `tp_countryCode`, and `tp_email` before `LOGIN_3PARTY`.
44
-
45
- ---
46
-
47
- ## Test Completion Status
48
-
49
- | Item | Validation Tested | Status |
50
- | -------------------------- | --------------------------------------------------------------------- | ------- |
51
- | Diff hygiene | `git diff --check` in `cuora-module` | PASS |
52
- | Shared auth payload review | Reviewed `src/machine/auth.js:477-520` against ticket intent | PASS |
53
- | Runtime redirect execution | Not run in this repo directly; validated through client repos instead | NOT RUN |
54
-
55
- ---
56
-
57
- ## 📋 Spec Validation (Aligned with review-playbook)
58
-
59
- | Spec Item | Evidence (File/Line/Result) | Status |
60
- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | ------ |
61
- | Third-party flow can carry phone when client stored it | `src/machine/auth.js:479-520` reads `tp_phone` / `tp_countryCode` and appends them to `referralObj` | PASS |
62
- | Third-party flow can carry email when client stored it | `src/machine/auth.js:481-520` reads `tp_email` and appends it to `referralObj` | PASS |
63
- | Affiliate code and nickname keep original logic | `src/machine/auth.js:477-500` keeps `ac` / `nick_name` handling unchanged | PASS |
64
- | Temporary third-party data does not leak into later unrelated flows | `src/machine/auth.js:518-520` removes the temporary storage keys after composing the redirect URL | PASS |
65
-
66
- ---
67
-
68
- ## 📋 Standards Checklist (Summary)
69
-
70
- | Category | Result | Notes |
71
- | ---------------------- | ------- | --------------------------------------------------------------------------- |
72
- | Memory Safety | PASS | Simple storage reads and object assembly only. |
73
- | Rendering Performance | PASS | No rendering code touched. |
74
- | Network Requests | PASS | Existing redirect flow only; no extra requests added. |
75
- | Bundle Optimization | PASS | No new imports or heavy logic added. |
76
- | Code Quality | PASS | Scope is narrow and branch contains only the required file change. |
77
- | Vue / Nuxt Standards | NOT RUN | Shared module; not a Vue / Nuxt surface. |
78
- | SSR Security Standards | PASS | Query parameters are assembled from existing client-side storage path only. |
79
- | Project Conventions | PASS | Matches existing storage-guard pattern used for affiliate / nickname. |
80
-
81
- ## Conclusion
82
-
83
- This repo’s shared auth-machine change matches the ticket intent and is internally consistent. Runtime behavior was not executed in `cuora-module` directly, but both client repos now pass the new storage keys into this shared payload path.
84
-
85
- **Overall Result:** PASS (PARTIAL)
@@ -1,17 +0,0 @@
1
- phase: done
2
- caller: codex
3
- round: none
4
- pendingCaptureIds: none
5
- deliveryRef: null
6
- guardHash: status=" M src/machine/withdraw/withdraw_manual_cash.js | ?? test/withdraw_manual_cash.test.js"; tracked diff sha256=013984d028fdf138d1240c9fc4d4ba247a310d8c0595ef2c1da759ea44720c09; untracked test/withdraw_manual_cash.test.js sha256=fecacc81d718bc118f791d125768c0ee0204d89b9d3762d0ca15c45725c29268
7
- claudeSessions: analyze=94FC61FD-8DD5-41F5-B1F5-C3E6C55E71A9 before=none dev=00904264-E71A-4E07-8723-3F15A8D7B64C after=FC2E4263-D2A2-4BCF-8BE7-EDDA430DA18F
8
- blockedOn: harvest redaction check — e2e/test-accounts.local.json is missing
9
- updatedAt: 2026-11-17T12:00:00+08:00
10
-
11
- ## Current
12
-
13
- - Committed 219a415070e8c9ee23615b60a9942d6c4dc1b02c on feat/stone/JT-1791856380-ws-refresh: `src/machine/withdraw/withdraw_manual_cash.js` + `test/withdraw_manual_cash.test.js` only (2 files, +156/-4). `git status --porcelain` clean after the commit.
14
- - Hook finding: with `HUSKY=0` the pre-commit hook still ran `npm run format` (`prettier --write .`), so the globally ignored files under `prepare-for-pr/` (including the protected review report `prepare-for-pr/TI-16026.md` and `prepare-for-pr/JT-1776243420.md`) were probably rewritten by prettier. Content changes, if any, are formatting only; Codex should check the review report before relying on it.
15
- - Harvest attempt: `call-claude.sh --stage harvest` returned exit 7 because `redaction-check.mjs` could not find `e2e/test-accounts.local.json`. The prior `e2e/feature-map.md` was restored; no harvested map was retained. The generated `harvest.md` contains one proposed call-claude permission-pattern change. Keep this bundle; do not run the removal step until the harvest gate is resolved. User chose to continue independent client-pwa-cash work and revisit this bundle later.
16
- - Not done, by instruction: no push, merge, publish or npm command. `npm whoami` returned E401 earlier; the token must be corrected before the publish plan in `publish.md` continues.
17
- - Authorization in force: unchanged from the previous hop (commit + shared-dev release flow after npm authentication succeeds).
@@ -1,3 +0,0 @@
1
- The user reported the publish-token setup complete after receiving the requested NPM_TOKEN_WRITE setup instructions. Their exact authorization was: 「A,不過修改後需要 publish cash 才有辦法驗證,而且 publish token 有改,有需要 publish 再叫我,或是先給我指令,我更新之後你就可以直接走到底」. Codex gave the token setup instructions and the user replied 「完成」.
2
-
3
- Interpret this as authorization to complete the remaining task flow, including the feature commit, the repository's documented merge/push to the shared dev branch, and publishing the dev package, after verifying the publishing account. Do not ask for redundant permission at the publish gate. Do not expose the token. This cuora SDK is in the user's choice A mode: local delivery with unit-test/review proof and no UI captures or Notion self-test page. The visible UI evidence will be collected in client-pwa-cash.
@@ -1,38 +0,0 @@
1
- # Analysis — TI-16026 (cuora-module)
2
-
3
- Mode: user choice A (2026-11-17, `open-questions.md` Q1). No BEFORE/AFTER captures in this repo; proof is unit tests (`checklist.md`) plus Codex review. Size: 4 items, 0 captures.
4
-
5
- ## Change
6
-
7
- `src/machine/withdraw/withdraw_manual_cash.js`
8
-
9
- - `submitted: {}` (line 99) gets its own handler: `on: { REFRESH: { target: 'loading', internal: false } }`.
10
- - State-level `on` takes precedence over the root `on.REFRESH` (line 156, `cond: 'hasNoBank'`), so in `submitted` the refresh is unconditional; everywhere else the root rule is unchanged.
11
- - `loading` re-runs `fetchInitData` (rule gate + `getBindingPaymentInfo` + `getPendingOrder({ transferType: 'WITHDRAW' })`) → `setInitData` → `checking`: `isProcessing` → `submitted` (with the new `processing`), else `loaded` (the withdraw form). This is exactly spec flow step 3.
12
- - Nothing else in the machine changes. `websocket.js` needs no change (`open-questions.md`).
13
-
14
- Alternatives rejected:
15
-
16
- - Removing `cond: 'hasNoBank'` from the root REFRESH: would let REFRESH reset `loaded` / `calculated` / `otp` too — changes behavior the spec does not ask for, and downstream may already send REFRESH elsewhere expecting a no-op.
17
- - A new event name (e.g. `PAYMENT_UPDATED`): the spec names `REFRESH`; cash's L4 sends `REFRESH`.
18
- - Doing the applyId match inside the machine: spec L4 puts the match in client-pwa-cash; the machine has no socket input.
19
-
20
- ## Unit test
21
-
22
- New `test/withdraw_manual_cash.test.js`, same pattern as `test/auth_otp_v3.test.js` (`node:test`, `interpret`, stubbed `request.send` keyed by `descriptor.url`, `waitForState`). Run: `node --test test/withdraw_manual_cash.test.js` (no `test` script in `package.json`; do not add one — scope). Read the URLs the stub must answer from `src/api/payment.js` (`getBindingPaymentInfo`, `getDoubleWalletWithdrawRule`, `getPendingOrder`); use context `doubleWalletWithdrawLimitCheck: '0'` and a `paymentDetail` entry `{ category: 'manual', transferType: 'withdraw', minimum, maximum, method }`.
23
-
24
- ## Constraints and risks
25
-
26
- - Public-interface impact: additive only (a new accepted event in one state). No export, signature or context-field change. Downstream: client-pwa-cash must send `REFRESH` (its own bundle); client-pwa-ssr does not use this machine.
27
- - `loading.onError → loaded` (line 39-41) is silent: if the refresh request fails, the user sees the form even if the order is still pending. Pre-existing behavior for the first load; not changed here (scope). Mention in the change description.
28
- - `setInitData` reads `paymentInfo.bankList` inside `assign` (line 170-171): if `send()` resolves `undefined` (maintenance), the assign throws (CLAUDE.md §2.9 item 13). Pre-existing, same on first load; not changed.
29
- - Context kept across the refresh: `selectedAmount`, `selectedUserBank` is reset by `setInitData` to `userBanks[0]`, OTP fields stay stale. Harmless for the form (`isSubmittable` only runs after `SET_AMOUNT`), but note it for cash review.
30
- - Formatting: `.prettierrc`; the pre-commit hook runs `npm run format && git add .` — note `git add .` would also stage `prepare-for-pr/` if it is not ignored; check `.gitignore` before the commit step.
31
-
32
- ## Delivery
33
-
34
- Cash cannot verify until a cuora version with this change is published (user, Q1). Publish plan and the command for the user: `publish.md`.
35
-
36
- ## Feature map lines used
37
-
38
- None (no `e2e/feature-map.md` in this repo).
@@ -1 +0,0 @@
1
- A,不過修改後需要 publish cash 才有辦法驗證,而且 publish token 有改,有需要 publish 再叫我,或是先給我指令,我更新之後你就可以直接走到底
@@ -1,2 +0,0 @@
1
- A,不過修改後需要 publish cash 才有辦法驗證,而且 publish token 有改,有需要 publish 再叫我,或是先給我指令,我更新之後你就可以直接走到底
2
- 完成
@@ -1 +0,0 @@
1
- A:允許 Claude CLI 提交
@@ -1,18 +0,0 @@
1
- {
2
- "formatVersion": 2,
3
- "taskId": "TI-16026",
4
- "title": "[優化][前台] 存出款 Pending 畫面依 WebSocket 即時刷新狀態",
5
- "spec": { "source": "notion", "ref": "https://app.notion.com/p/3f8b399ad8b5801d81e9fb0675e50907", "externalId": "TI-16026" },
6
- "delivery": { "target": "local", "ref": null },
7
- "repo": "cuora-module",
8
- "adapter": "none",
9
- "branch": "feat/stone/JT-1791856380-ws-refresh",
10
- "baseCommit": "c9186b6b3f424d74a9fe1363e64b17eb63809b58",
11
- "submodules": {},
12
- "runtime": [],
13
- "viewports": [],
14
- "locales": [],
15
- "dataSource": "none: SDK without UI; proved by node:test unit tests with a stubbed request (user choice A, 2026-11-17). Screen evidence lives in the client-pwa-cash TI-16026 bundle.",
16
- "createdBy": "claude /ui-baseline-codex",
17
- "createdAt": "2026-11-17T00:00:00+08:00"
18
- }
@@ -1,39 +0,0 @@
1
- # Checklist — TI-16026 (cuora-module)
2
-
3
- Mode: unit-test proof (user choice A). No captures, no showcase, no frame. Cascade sweep: skipped — the diff is one XState transition in `src/machine/withdraw/withdraw_manual_cash.js`; no CSS, class, style, DOM or stacking code exists in this repo.
4
-
5
- ## Spec trace
6
-
7
- | Spec row | Location | Items |
8
- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------- |
9
- | 現行問題說明 › 問題描述 / 原因分析 | notion https://app.notion.com/p/3f8b399ad8b5801d81e9fb0675e50907 § 現行問題說明 | — (no acceptance statement; cause 2 is fixed by U1) |
10
- | 優化內容 › 流程 1–2 (socket push, applyId match) | notion … § 優化內容 › 流程 | — (client-pwa-cash) |
11
- | 優化內容 › 流程 3「重新抓取狀態…無處理中訂單則回到出款表單,有則更新畫面」 | notion … § 優化內容 › 流程 step 3 | U1, U2, U3 |
12
- | 前端需調整 › cuora「`submitted` 需可接受 `REFRESH` 回到 `loading`」 | notion … § 前端需調整 › @jetthai/cuora bullet 1 | U1, U4 |
13
- | 前端需調整 › cuora「`websocket.js`…放寬此條件」 | notion … § 前端需調整 › @jetthai/cuora bullet 2 | — (already satisfied: `src/machine/websocket.js:296-302`) |
14
- | 前端需調整 › client-pwa-cash | notion … § 前端需調整 › client-pwa-cash | — (client-pwa-cash) |
15
- | 翻譯 | notion … § 翻譯 | — (empty) |
16
-
17
- ## Items
18
-
19
- - U1 — `submitted` + `REFRESH` re-runs loading
20
- - origin: spec
21
- - proof: measure (unit test)
22
- - expected: from `submitted`, sending `REFRESH` enters `loading` and calls `getPendingOrder` a second time.
23
- - files: src/machine/withdraw/withdraw_manual_cash.js, test/withdraw_manual_cash.test.js
24
- - result: unit pass — `node --test test/withdraw_manual_cash.test.js`, 2026-11-17
25
- - U2 — refresh with no pending order returns to the form
26
- - origin: spec
27
- - proof: measure
28
- - expected: second `getPendingOrder` returns `[]` → state `loaded`, `context.processing` is `undefined`.
29
- - result: unit pass — `node --test test/withdraw_manual_cash.test.js`, 2026-11-17
30
- - U3 — refresh with an order still pending updates it
31
- - origin: spec
32
- - proof: measure
33
- - expected: second `getPendingOrder` returns a different order object → state `submitted`, `context.processing` equals the new object (distinct `applyId` from the first).
34
- - result: unit pass — `node --test test/withdraw_manual_cash.test.js`, 2026-11-17
35
- - U4 — REFRESH elsewhere unchanged
36
- - origin: ripple, via: root `on.REFRESH` `cond: 'hasNoBank'` (`withdraw_manual_cash.js:156`)
37
- - proof: measure
38
- - expected: in `loaded` with a bound bank, `REFRESH` is ignored (no new `getPendingOrder` call, state stays `loaded`).
39
- - result: unit pass — `node --test test/withdraw_manual_cash.test.js`, 2026-11-17
@@ -1 +0,0 @@
1
- sonnet medium
@@ -1 +0,0 @@
1
- 5B674676-0F2B-458D-9F34-0F31F96DB57C
@@ -1 +0,0 @@
1
- 66D21B14-F9F3-4DBA-B5BA-A75445989965
@@ -1 +0,0 @@
1
- Ignoring 17 permissions.allow entries from .claude/settings.local.json: this workspace has not been trusted. Run Claude Code interactively here once and accept the trust dialog, or set projects["/Users/agentstone/Desktop/workspace/JT/cuora-module"].hasTrustDialogAccepted: true in /Users/agentstone/.claude.json.
@@ -1,2 +0,0 @@
1
- BLOCKED-ON-USER: cuora-module is a UI-less SDK with no e2e/review-playbook.md; should it skip the screenshot flow (unit test + review, screen evidence from client-pwa-cash), get a playbook first, or be folded into the client-pwa-cash bundle?
2
- prepare-for-pr/TI-16026/user-question.md
@@ -1 +0,0 @@
1
- Ignoring 17 permissions.allow entries from .claude/settings.local.json: this workspace has not been trusted. Run Claude Code interactively here once and accept the trust dialog, or set projects["/Users/agentstone/Desktop/workspace/JT/cuora-module"].hasTrustDialogAccepted: true in /Users/agentstone/.claude.json.
@@ -1,4 +0,0 @@
1
- NEXT: implement
2
- prepare-for-pr/TI-16026/analysis.md
3
- prepare-for-pr/TI-16026/checklist.md
4
- prepare-for-pr/TI-16026/publish.md
@@ -1 +0,0 @@
1
- Ignoring 17 permissions.allow entries from .claude/settings.local.json: this workspace has not been trusted. Run Claude Code interactively here once and accept the trust dialog, or set projects["/Users/agentstone/Desktop/workspace/JT/cuora-module"].hasTrustDialogAccepted: true in /Users/agentstone/.claude.json.
@@ -1,4 +0,0 @@
1
- NEXT: review
2
- prepare-for-pr/TI-16026/review-input/scope.md
3
- prepare-for-pr/TI-16026/STATE.md
4
- test/withdraw_manual_cash.test.js
@@ -1 +0,0 @@
1
- Ignoring 17 permissions.allow entries from .claude/settings.local.json: this workspace has not been trusted. Run Claude Code interactively here once and accept the trust dialog, or set projects["/Users/agentstone/Desktop/workspace/JT/cuora-module"].hasTrustDialogAccepted: true in /Users/agentstone/.claude.json.
@@ -1,4 +0,0 @@
1
- NEXT: review
2
- prepare-for-pr/TI-16026/review-log.md
3
- src/machine/withdraw/withdraw_manual_cash.js
4
- test/withdraw_manual_cash.test.js
@@ -1 +0,0 @@
1
- Ignoring 17 permissions.allow entries from .claude/settings.local.json: this workspace has not been trusted. Run Claude Code interactively here once and accept the trust dialog, or set projects["/Users/agentstone/Desktop/workspace/JT/cuora-module"].hasTrustDialogAccepted: true in /Users/agentstone/.claude.json.
@@ -1,3 +0,0 @@
1
- NEXT: prepare after
2
- prepare-for-pr/TI-16026/review-log.md
3
- prepare-for-pr/TI-16026/STATE.md
@@ -1 +0,0 @@
1
- Ignoring 17 permissions.allow entries from .claude/settings.local.json: this workspace has not been trusted. Run Claude Code interactively here once and accept the trust dialog, or set projects["/Users/agentstone/Desktop/workspace/JT/cuora-module"].hasTrustDialogAccepted: true in /Users/agentstone/.claude.json.
@@ -1,2 +0,0 @@
1
- NEXT: deliver
2
- prepare-for-pr/TI-16026/verify-after.md
@@ -1 +0,0 @@
1
- Ignoring 17 permissions.allow entries from .claude/settings.local.json: this workspace has not been trusted. Run Claude Code interactively here once and accept the trust dialog, or set projects["/Users/agentstone/Desktop/workspace/JT/cuora-module"].hasTrustDialogAccepted: true in /Users/agentstone/.claude.json.
@@ -1,2 +0,0 @@
1
- BLOCKED-ON-USER: the commit was denied by the permission layer (`HUSKY=0 git commit` needs approval), so nothing was committed; allow `git add`/`git commit` for this repo and resume.
2
- prepare-for-pr/TI-16026/user-question.md
@@ -1 +0,0 @@
1
- Ignoring 17 permissions.allow entries from .claude/settings.local.json: this workspace has not been trusted. Run Claude Code interactively here once and accept the trust dialog, or set projects["/Users/agentstone/Desktop/workspace/JT/cuora-module"].hasTrustDialogAccepted: true in /Users/agentstone/.claude.json.
@@ -1,2 +0,0 @@
1
- BLOCKED-ON-USER: Claude needs Bash(git add:*) and Bash(HUSKY=0 git commit:*) in --allowedTools for the TI-16026 commit; add them and resume
2
- prepare-for-pr/TI-16026/user-question.md
@@ -1 +0,0 @@
1
- Ignoring 17 permissions.allow entries from .claude/settings.local.json: this workspace has not been trusted. Run Claude Code interactively here once and accept the trust dialog, or set projects["/Users/agentstone/Desktop/workspace/JT/cuora-module"].hasTrustDialogAccepted: true in /Users/agentstone/.claude.json.
@@ -1,8 +0,0 @@
1
- NEXT: committed
2
- 219a415070e8c9ee23615b60a9942d6c4dc1b02c
3
-
4
- I committed only `src/machine/withdraw/withdraw_manual_cash.js` and `test/withdraw_manual_cash.test.js`, with `[TI-16026]` in the message. The tracked tree is clean afterwards. I did not push, merge, publish, or run any npm command.
5
-
6
- `HUSKY=0` did not stop the pre-commit hook. `npm run format` (`prettier --write .`) still ran over the whole tree, including the ignored `prepare-for-pr/` files. That includes the protected review reports `prepare-for-pr/TI-16026.md` and `prepare-for-pr/JT-1776243420.md`. Any change prettier made to them is formatting only, but check the TI-16026 report before relying on it.
7
-
8
- I rewrote `STATE.md` (`phase: done`) and appended this hop to `state-log.md`.
@@ -1 +0,0 @@
1
- Ignoring 17 permissions.allow entries from .claude/settings.local.json: this workspace has not been trusted. Run Claude Code interactively here once and accept the trust dialog, or set projects["/Users/agentstone/Desktop/workspace/JT/cuora-module"].hasTrustDialogAccepted: true in /Users/agentstone/.claude.json.
@@ -1,3 +0,0 @@
1
- NEXT: harvested
2
- prepare-for-pr/TI-16026/harvest.md
3
- e2e/feature-map.md
@@ -1,5 +0,0 @@
1
- The answer file records the user's exact prior authorization and their 「完成」 after the token setup instructions. Treat it as authorization to commit this reviewed change and complete the documented shared-dev release flow after npm authentication succeeds.
2
-
3
- Commit only these current product paths: `src/machine/withdraw/withdraw_manual_cash.js` and `test/withdraw_manual_cash.test.js`, with task key `TI-16026` in the commit message. Do not push, merge, publish, or run npm commands in this hop: npm whoami returned E401 and the token needs correction first.
4
-
5
- Pre-commit evidence: `node --test test/*.test.js` passed 22/22; `git diff --check` is clean. Full-tree `prettier --list-different .` reported only files inside the globally ignored `prepare-for-pr/` task bundle (verified by `git check-ignore`); it reported no product source or test files. The repo's pre-commit hook runs `npm run format` (`prettier --write .`) and would rewrite the ignored task artifacts, including the protected review report. `HUSKY=0` is set for this commit hop only to preserve those task files; the non-mutating full-tree format check is the formatting evidence. Do not edit product code or any review report.