feat: replace desktop membership with permanent point wallet

This commit is contained in:
2026-09-22 11:43:04 +08:00
parent 2f82b9f79c
commit a1cce428af
24 changed files with 1343 additions and 1707 deletions

View File

@@ -0,0 +1,61 @@
# Task: Adapt MakeLore to permanent token points
## Identity
- Task ID: 20260922-permanent-points-client-7f4c9a2e
- Mode: Feature
- Branch: codex/20260922-permanent-points-client-7f4c9a2e-permanent-points-client
- Worktree: D:\Datas\OthersProjects\.codex-worktrees\makelore\20260922-permanent-points-client-7f4c9a2e
- Base commit: 2f82b9f79cf72873d75c17a48853292323aa5df5
- Owner: codex
- Status: Ready for Integration
## Scope
- Complete MakeLore desktop adaptation to Works Square permanent Token Point accounts: Main/Renderer contracts, personal balance/recharge/history/orders, removal of subscription/reset-card surfaces, exhaustion wording, mock fixtures and focused unit/Electron acceptance.
## Intent And Constraints
- Concurrent Task Gate Passed: official check/start/status agree with this task ID, feature mode, branch, absolute worktree and main base above. User approved missing-directory registry recovery; official release-missing removed the 31 listed stale packaging records plus the subsequently missing package-155 record. No worktree, branch, commit or existing file was deleted.
- Planning Gate Passed: read entry/own record, memory index, positioning placeholder, integrated state, decisions, architecture/module/data-flow, domain rules/glossary, success criteria, evidence/reflection/commitment/stale indexes, auth ADR, README and AGENTS. Product positioning is established by current README/source: Code, Canvas, Robot and cloud Agents, Main-owned auth/network and light desktop UI.
- Read all 121 peer task records' Scope, Intent And Constraints and Promotion Candidates; 17 undefined scopes remain unknown and read-only. Old reset-card/menu tasks are superseded by the explicit user-approved permanent-points policy. No unresolved competing dependency affects this isolated implementation.
- Confirmed server source 4ef177b8 is integrated into works-square-server master: genuine signup gets 100 once, recharge CNY 1 = 50 points, no expiry, old rights canceled without gift/conversion, parent personal recharge, explicit shared payer and private balances/history. Consume the actual new DTOs rather than infer eligibility from first login.
- Preserve Main-owned credentials, fixed upstream routes, account isolation, existing module restrictions and cloud creator-pays/Plugin personal-payer boundaries. Do not restore Learning, Works gallery or publishing pages. Do not change provider pricing, app identity, external service configuration or unrelated Code/Pi architecture.
- The repository's no-worklog guidance is subordinate to the user's explicit requirement to apply maintain-project-docs. Keep this mandatory task record; feature mode writes no canonical project memory. README will describe product behavior.
- No subagents, remote push, packaging/install, production deployment or real payment. Primary checkout and existing task worktrees remain untouched.
## Plan
1. Replace old Main billing projection and Renderer DTOs with bounded permanent-wallet/recharge contracts; preserve auth/privacy and idempotent payment recovery.
2. Replace membership/reset-card UI with personal balance, recharge, paginated history/orders and frozen-order payment status; adapt exhaustion navigation and account changes.
3. Update focused unit/Host and Electron fixtures/specs; run typecheck, relevant tests, lint and full Vite build, then meaningful integration acceptance.
4. Record outcomes and release limits, run documentation gates and commit the completed feature.
## Outcome
- Replaced the desktop membership/week-cycle/reset-card account surfaces and DTOs with permanent personal balance, held points, recharge products, frozen orders, QR checkout, server-confirmed payment status and paginated own-wallet ledger/orders. Updated README; removed the subscription upgrade helper and obsolete reset-card tests.
- Main owns credentials and the fixed billing routes, projects only supported fields, uses the existing Renderer capability for recharge, preserves the request identity on an unknown payment outcome and discards results after an account switch. Renderer never supplies a payer, price or access token for billing. Existing pending/manual-review orders block a new checkout; reopening uses the original order.
- Genuine signup gifts and legacy-account treatment remain server-owned. The client does not invent a gift, expiry, payment result, balance or fallback payer. Recharge always targets the authenticated parent's personal wallet. Youth see their own exact balance; another payer's wallet exposes availability only.
- Real server inspection uncovered that a family payer's own wallet may have family_shared=true (legacy source=self or V1 source=shared_group). Projection now uses the API's shared_available field to distinguish another payer's coarse balance from the authenticated payer's own precise balance. AI programming funding wording is explicit; cloud creator-pays and Plugin personal-payer semantics are unchanged.
- Account reopening/focus refreshes the balance; an account-keyed wallet discards late prior-account responses. Pending checkout hides other products and redundant banners so the payment QR fits the desktop dialog. Payment-source management opens the fixed web account page.
## Verification
- Final focused run: 8 files / 103 tests passed, including Main credential/capability/privacy projection, permanent account contracts, real-server serialized fixtures, idempotent retry, frozen prices, pending/review recovery, youth/shared/own-family balances, menu reopening, account switching, pagination and retained Works routes.
- pnpm 10.33.4 run typecheck passed. Scoped ESLint across all changed TypeScript/TSX files passed. Final pnpm run build:vite passed for Renderer/Main/Preload/utility.
- Final Windows Electron E2E passed: zero balance, recharge, product repricing, unpaid-order recovery after Renderer reload, one POST, server-confirmed credit, updated balance and ledger. Fixture waits for the authenticated profile before operating the wallet. Pending/credited screenshots were visually inspected; no clipped QR or overlapping controls. This test uses a fake Host API/payment response, not a live payment.
- Cross-repository acceptance used the actual works-square-server permanent-points FastAPI router with an isolated in-memory SQLite database and a fake payment provider. Verified old account zero, genuine youth signup 100, same-key replay one order, repricing preserved the original 10 yuan / 500 points, duplicate success callback one credit, and exact own-family balance. Captured synthetic API responses in tests/fixtures/permanent-points-server.json; the desktop contract tests accept those actual serialized responses.
- Full pnpm test first phase: 245 files passed, 2 failed; 2159 tests passed, 2 failed, 2 skipped. Failures were an untouched Pi opener test expecting makelore-runtime-v6.mjs while the base runtime uses v7, and a Pi Bash timing assertion (2557 ms versus 2000 ms). Isolated rerun of these files plus the separately scheduled coding-chat pressure test: 9 passed / 1 failed; the timing case and pressure test passed, and the unchanged v6 assertion remained. No Pi/runtime/test expectation was edited.
- Extended Main TypeScript check reports 67 diagnostics. A read-only TypeScript Compiler API comparison overlaying the recorded base's works.ts and excluding the newly added route from the base reproduced the same 67 diagnostics, with zero added or removed. The normal Renderer typecheck and production build pass; this task does not repair the pre-existing full-Main baseline.
- Reviewed source and test diffs against the recorded base. Primary checkout, foreign task documents, dependencies and server source remain untouched. Build outputs, screenshots, logs and local runtime data are excluded from the commit.
## Follow-ups
- Integrate this feature into MakeLore main when requested; no merge, push, packaging, installation or deployment occurred.
- Before release, deploy the matching Works Square permanent-points API and 0094 migration, and verify real registration/payment callbacks and the configured desktop payment payload. JSAPI-only providers use the web account page to continue the original order. PostgreSQL concurrency/upgrade and non-Windows packaged acceptance remain separate release checks.
- Track the existing Pi v6/v7 test mismatch and the 67-diagnostic Main TypeScript baseline independently. The single full-suite timing failure passed in isolation; it is not evidence of a wallet regression.
## Promotion Candidates
- Target: .project-docs/30-worklog/current-state.md and .project-docs/40-domain/business-rules.md. Proposal: replace membership/week allowance/reset-card desktop claims with the user-confirmed permanent-points policy and own-versus-other-payer visibility. Evidence: updated README/UI/Main contracts, 103 focused tests, real-server contract acceptance and Electron E2E. Future impact: desktop release and account support must use the matching permanent-points API. Semantic conflict: supersedes older membership/reset-card task descriptions; the user explicitly authorized this product change. Additional human confirmation is not required for that accepted policy; canonical promotion still requires Integration Gate.
- Target: .project-docs/20-architecture/data-flow.md. Proposal: record Main-owned billing authentication/projection and stable explicit recharge request identity, server order recovery, and shared_available as the distinction between own precision and another payer's coarse availability. Evidence: works-billing route tests and captured real API family-payer response. Future impact: do not derive privacy or recharge rights solely from family_shared or old membership-management flags. No competing product decision; no additional human confirmation required.