سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 4, 08:00 UTC
fix: preserve pending edits with tenant-bound versioned sync
JVK committed
Nov 4, 2026 at 02:08 UTC
56818d8732a0595d49e1d042ccb374935c6b2efd
32 files changed
+2115
-66
.github/workflows/quality.yml
+3
-1
@@ -24,6 +24,8 @@ jobs:
24
run: node scripts/migration-manifest-test.mjs
25
- name: Purchase correction server-mode guards
26
run: node scripts/wp1-purchase-correction-guard-test.mjs
27
+ - name: Versioned sync compatibility and pending-edit protection
28
+ run: node --test scripts/wp1-client-capability-test.mjs
29
- name: JavaScript syntax
30
run: node scripts/syntax-check.mjs
31
- name: Generated Pages public regression (standalone suite)
@@ -131,7 +133,7 @@ jobs:
133
- name: Real DOM smoke
134
run: |
135
python3 -m http.server 4173 >/tmp/finora-http.log 2>&1 &
134
- npx playwright test scripts/commerce-route-types.spec.js scripts/workspace-access.spec.js scripts/password-recovery.spec.js scripts/password-admin-ui.spec.js scripts/login-auth-transport.spec.js scripts/login-startup-readiness.spec.js scripts/phase0-startup-performance.spec.js scripts/dom-smoke.spec.js scripts/platform-office.spec.js scripts/enterprise-license.spec.js scripts/enterprise-role.spec.js scripts/enterprise-invitation.spec.js scripts/enterprise-org-ux.spec.js scripts/identity-wave5a.spec.js scripts/identity-wave5b.spec.js scripts/identity-wave5c.spec.js scripts/branding-login.spec.js scripts/login-connectivity.spec.js scripts/shell-scroll-ownership.spec.js scripts/office-slice-c1.spec.js scripts/office-slice-c2.spec.js scripts/office-slice-c3.spec.js scripts/office-slice-c4.spec.js scripts/office-slice-c5.spec.js scripts/office-slice-c6.spec.js scripts/office-slice-c7.spec.js scripts/office-slice-c8.spec.js scripts/office-slice-c8-runtime.spec.js scripts/request-workflow-d2.spec.js scripts/request-workflow-d3b.spec.js scripts/request-workflow-d3c.spec.js scripts/request-workflow-d4a.spec.js scripts/taxpayer-print.spec.js scripts/chart-completeness.spec.js scripts/accounting-p0-journal.spec.js scripts/ux-hardening-r2.spec.js scripts/ux-keyboard-f2.spec.js scripts/phase0-dark-theme-contrast.spec.js scripts/phase0-selector-stress.spec.js scripts/phase0-invoice-persistence.spec.js scripts/phase0-modal-dashboard.spec.js scripts/accounting-document-workflow.spec.js scripts/admin-provisioning.spec.js scripts/pages-artifact.spec.js --reporter=line --workers=1
136
+ npx playwright test scripts/wp1-client-sync.spec.js scripts/commerce-route-types.spec.js scripts/workspace-access.spec.js scripts/password-recovery.spec.js scripts/password-admin-ui.spec.js scripts/login-auth-transport.spec.js scripts/login-startup-readiness.spec.js scripts/phase0-startup-performance.spec.js scripts/dom-smoke.spec.js scripts/platform-office.spec.js scripts/enterprise-license.spec.js scripts/enterprise-role.spec.js scripts/enterprise-invitation.spec.js scripts/enterprise-org-ux.spec.js scripts/identity-wave5a.spec.js scripts/identity-wave5b.spec.js scripts/identity-wave5c.spec.js scripts/branding-login.spec.js scripts/login-connectivity.spec.js scripts/shell-scroll-ownership.spec.js scripts/office-slice-c1.spec.js scripts/office-slice-c2.spec.js scripts/office-slice-c3.spec.js scripts/office-slice-c4.spec.js scripts/office-slice-c5.spec.js scripts/office-slice-c6.spec.js scripts/office-slice-c7.spec.js scripts/office-slice-c8.spec.js scripts/office-slice-c8-runtime.spec.js scripts/request-workflow-d2.spec.js scripts/request-workflow-d3b.spec.js scripts/request-workflow-d3c.spec.js scripts/request-workflow-d4a.spec.js scripts/taxpayer-print.spec.js scripts/chart-completeness.spec.js scripts/accounting-p0-journal.spec.js scripts/ux-hardening-r2.spec.js scripts/ux-keyboard-f2.spec.js scripts/phase0-dark-theme-contrast.spec.js scripts/phase0-selector-stress.spec.js scripts/phase0-invoice-persistence.spec.js scripts/phase0-modal-dashboard.spec.js scripts/accounting-document-workflow.spec.js scripts/admin-provisioning.spec.js scripts/pages-artifact.spec.js --reporter=line --workers=1
137
138
identity-wave5a-database:
139
runs-on: ubuntu-24.04
PROJECT_STATE.md
+15
@@ -253,3 +253,18 @@ Owner requests layer-by-layer click/functional testing of all controls and compa
253
- NewpurchaseguardRED→GREEN: enforce/network/malformedmode/accountswitchreject beforelocalreversal/save/sync; onlyconfirmedmissingRPC oroff/auditretainlegacycorrection. Browser28/28PASS incl3newnegativecases; generatedPages3/3PASS. Guard is safe refusal, NOT completedserverpurchasecorrection. Firstbrowserattemptfailedbecausefixtureorgwasaddedbeforeorganizationbootstrap; correctedfixturesetsorgafterready, noappAuthchange/assertionrelaxation. Newsourcechange notyetremoteCIverified.
254
255
- Elevenprerequisite conservativeDOWNscripts generatedfromdisposable pre/postcatalogs andproved inreverseorder aftercorrectionDOWN. Restored71baselinefunctions/ACLs andpriortriggers; newAPIgrantsrevoked;4postedvouchers,10lines,10auditrows,counterhistory retainedbit-identically byhash. ReUPall12 thenD1/D2PASS. Source-derivedscope only; compatibleindexes/columns/inerthelpers retained intentionally. Proof scripts/wp1-prerequisite-rollback.mjs; evidence docs/wp1/evidence/prerequisite-rollback. CIstep added; finalheadCIpending.
256
+
257
+### 2026-11-03 — Capability-safe client continuation
258
+- Environment recovered; remote PR195 head799cff4 confirms prerequisite rollback commit was pushed. Exact-head Security/three existing DB jobs PASS; full Quality/WP1 still running at inspection. No production change.
259
+- Current task: use optional record revisions on existing reads without an extra login probe; detect server capability only before writes; share the protocol with organization-RBAC's real runtime override. Validate complete CAS acknowledgements, prevent stale tenant responses, preserve pending edits on conflicts/uncertain outcomes, and never silently downgrade a versioned write. Meaningful isolated regressions precede implementation; generated Pages and startup regressions required. Full manual/purchase RPC workflows and WP1 release remain unfinished.
260
+- Exact799cff4 server/rollback CI now fully verified: Quality41626213964,Security41626213753,WP1proof41626213760 SUCCESS, including1000events,concurrency and all12 conservativeDOWN/UP. No production SQL.
261
+- Client checkpoint: shared lazy capability/CAS protocol, complete ACK validation, bounded requests and memory-only pending-edit protection implemented. Independent review reproduced queued-save starvation, then a same-user cross-organization transition race before new hydration; both observedRED and fixed with explicit snapshot-tenant binding and scoped queue resumption. Reviewer independently ran41/41 Node PASS and found no remaining blocking scoped issue. Initial36case regression subset against799cff4 fails31 as expected; five later cases have separate pre-fixRED evidence.
262
+- Local browser environment: installed missing Chromium; reproduced two invoice failures on unchanged799cff4 under defaultWOFF2 systemfont configuration, then both passed with process-onlyTTF/OTF fontconfig, no application/assertion relaxation. Earlier full run had9 legacyfixture failures because capability absence was not modeled; fixtures now explicitly returnPGRST202 and hydrate the correct tenant before saving. All55pre-browser/security commands and7/7newgeneratedPages cases PASS. Finalfullbrowser running; no completion/production acceptance inferred.
263
+- Next WP1 work after this client checkpoint: explicit asynchronous journal UI RPC adapter (keep existing synchronous engine callers intact), pending-edit-safe server result refresh, full transactional purchase correction/cancel and truthful per-source statuses. Reconcile real-schema drift, full shadow audit, isolated JWT/PostgREST acceptance, backup/restore and completeG1reviewablepackage before production. Remaining WP2–9 gates stay open in docs/ROADMAP_CURRENT.md.
264
+
265
+### 2026-11-04 — Resume final client verification
266
+- Last222browser run completed221PASS/1FAIL; failure was C8 policy-editor Publish disabled. No whole-suite success claimed. Its fixture installed synthetic permission before asynchronous organization adapter readiness; the adapter can replace that authority mid-form. Added explicit existing startup readiness before fixture injection, preserving role/disable/publish assertions; repeat execution and finalfullsuite required.
267
+- Final application change adds truthful unconfirmed badge after same-tenant identity refresh discards a late ACK with no queued save. It neither retries nor cancels a newer save timer. Both scenarios tested; independent reviewer43/43PASS with no remaining scoped blocking/important finding. GeneratedPages8/8PASS. Allproductionaccess unchanged; main remains4416794, PR195remote remains799cff4 before client publication.
268
+
269
+- FinalNov4 client checkpoint:222/222fullChromium,8/8generatedPages,43/43Node and55pre-browser/release commands PASS; C8fixture repeated30/30PASS after deterministic readiness. Allbusiness/permission assertions retained. Evidence+sourcehashes docs/wp1/evidence/client-sync/result.json. Currentcode reviewed independently; freshclientPRheadCIpending. No merge/deploy.
270
+- Nextserverreview identified missing reversal analytical dimensions and draft-update date/type validation gaps. Authorized isolated branches from799cff4 are provingRED and additive fixes; these are NOT fixed/accepted yet. Source-backed read findings also include entity-backed dimension compatibility and required/optional rule enforcement gaps; record and validate before claiming fullsourcecoverage.
docs/EXECUTION_STATUS.md
+9
-1
@@ -1,4 +1,12 @@
1
-> **2026-11-03 — WP1 server checkpoint IN PROGRESS.** WP0 PR194 exact-head required CI succeeded. Server D1/D2 regression tests and14postingnegatives now pass on disposablePG17; correction-only UP/DOWN/UP passes with history retained. Full1000/concurrency, freshCI, allprerequisiteDOWN and client/purchaseintegration remain separate gates. No productionactivation. [WP1 status](wp1/STATUS_FA.md).
1
+# وضعیت جاری — ۲۰۲۶/۱۱/۰۴
2
+
3
+هدف جاری: تکمیل WP1 با ثبت مالی معتبر سمت سرور و حفاظت ویرایشهای ذخیرهنشده. مالک ادامه همه WPها را مجاز کرده؛ گیت هر مرحله و G1–G5 برقرار است. [نقشه راه جاری](ROADMAP_CURRENT.md) و [وضعیت دقیق WP1](wp1/STATUS_FA.md) مرجع فعلیاند.
4
+
5
+- انجامشده: WP0 و CI آن؛ آزمون کامل مالی شامل۱۰۰۰رویداد/همزمانی و برگشت/نصب مجدد۱۲تغییر روی799cff4 درCI موفق. هیچ نصب عملیاتی انجام نشده است.
6
+- در حال تأیید نهایی: کلاینت سازگار با سرور قدیم/جدید، تأیید کامل ذخیره، حفظ ویرایش در تعارض و حفاظت جابهجایی سازمان.۴۳آزمون مستقل،۸آزمونPages و۵۵فرمان کنترل موفق؛ اجرای کامل۲۲۲/۲۲۲موفق است؛ CI کامیت جدید پس از انتشار بررسی میشود.
7
+- باقیمانده: مسیرRPC سند دستی، اصلاح/ابطال تراکنشی خرید،پوشش منابع،حل تعارض،تطبیق ساختار واقعی،shadowکامل،پذیرش واقعی،بکاپ/بازیابی و بستهG1. ممیزی کامل همه دکمهها و ورود روی اینترنت مالک همچنان پذیرش نهایی ندارند.
8
+
9
+## سوابق پیشین (وضعیتهای تاریخدار)
10
11
> **2026-11-02 — Current owner REV2 scope: WP0 + WP1.** WP0 baseline/report and disposable D1/D2 reproductions published in [PR194](https://github.com/davoodmehraban89/Factor-easy/pull/194); CI pending, public QA F-150 remains failed. Full local211browser and3existingDBjobs pass. Financial defects remain uncorrected; WP1 pending. See [Persian report](wp0/BASELINE_REPORT_FA.md). No production migration/data write. Earlier dated entries below remain historical.
12
docs/ROADMAP_CURRENT.md
+3
-3
@@ -1,4 +1,4 @@
1
-# نقشه راه جاری فینورا — ۲۰۲۶/۱۱/۰۳
1
+# نقشه راه جاری فینورا — ۲۰۲۶/۱۱/۰۴
2
3
مرجع نیازمندی: [پرامپت مالک REV2](owner-prompts/FINORA_HARDENING_MASTER_2026-11-02_REV2.txt). دستور جدید مالک «فازها را تکمیل کن» ادامه همه بستهها را پس از گیت هر مرحله مجاز کرده است. شمارههای WP زیر با نقشههای قدیمی فاز۰/Phase1A/Stage1–3 یکی نیستند؛ [تطبیق تاریخچه](CURRENT_WORK_REGISTER_2026-10-30.md) محفوظ است.
4
@@ -17,8 +17,8 @@
17
18
## کار جاری
19
20
-۱. نتیجه آزمون کامل WP1 در CI مستقل از قطع محیط، سپس رفع هر شکست بدون تضعیف تست.
20
+۱. آزمون کامل SQL،۱۰۰۰رویداد،همزمانی و هر۱۲rollback روی799cff4 در CI موفق؛ اتصال کلاینت در حال تأیید نهایی است.
21
۲. حفاظت خرید زیر ENFORCE پیش از تغییر محلی؛ اتصال امن sync/RPC با تشخیص قابلیت و خطای صادقانه.
22
-۳. تکمیل rollback پیشنیازها، گردش کامل خرید و پوشش منبعبهمنبع. [بسته انتشار هنوز آماده نیست](wp1/ROLLOUT_HOLD.md).
22
+۳. rollback پیشنیازها اثبات شده؛ گردش کامل خرید،پوشش منبعبهمنبع و حل تعارض کاربر باقی است. [بسته انتشار هنوز آماده نیست](wp1/ROLLOUT_HOLD.md).
23
24
تست synthetic یا SQL fixture معادل تأیید ورود روی اینترنت مالک، JWT/PostgREST واقعی،چاپگر یا داده واقعی نیست. هیچ درصد تکمیل ساختگی گزارش نمیشود. G1 نصب migration،G2 تنظیمات داشبورد،G3 راز بکاپ،G4 داده تست Production وG5 هزینه همچنان فقط پس از آمادهشدن نتیجه قابل بررسی به مالک ارجاع میشوند.
docs/wp1/CLIENT_SYNC_CONTRACT.md
new
+23
@@ -0,0 +1,23 @@
1
+# WP1 client sync contract
2
+
3
+This is candidate application code in draft PR195, not a production activation or complete WP1 acceptance.
4
+
5
+- Existing record hydration requests select `*` under existing RLS (and the organization filter). Optional server revisions are captured in a separate map. No extra capability call is made during login; a missing version column does not break the legacy read. Present but unsafe revisions reject the snapshot rather than permitting a legacy downgrade.
6
+- Before a changed batch is sent, a bounded guard-mode read discovers the staged protocol. Only explicitly absent function codes, with no prior revision/capability evidence, allow the old transactional RPC. Transport, permission and malformed responses stop the write. Once a versioned server is observed, it never silently downgrades to a legacy write.
7
+- Existing rows require the last read revision; creates require zero. A missing revision blocks the batch without discarding pending edits. Upserts and deletes use the same V2 transaction and organization argument. Captured serialized payloads cannot be changed by nested edits made during the capability request.
8
+- The complete acknowledgement must identify every requested row exactly once, without extra/deleted identities or invalid revisions. Every returned upsert revision must be exactly expected+1. No partial acknowledgement advances either snapshot.
9
+- Identity, organization, user object and snapshot generation are checked around awaited work. The published snapshot also carries its own user/organization binding: changing the active organization before its read completes cannot send the old organization’s data, even for the same user and colliding record IDs. Late responses cannot publish into another tenant or overwrite a newer same-tenant refresh. Revocation clears revisions and the tenant binding, and advances the generation. A queued save in a newly hydrated context resumes after an old request releases the lock; same-context conflicts do not gain a retry timer.
10
+- V2 rejection, CAS conflict, malformed reply, timeout and capability failure preserve local edits, keep `syncPending`, show an unconfirmed-save badge, and schedule no automatic retry timer or reload. Local edits are memory-only: exiting/reloading can still lose them. Existing explicit save/visibility actions may retry; full user-facing reconciliation/export remains an open WP1 task. A timeout can mean the server committed without a received acknowledgement; no success is inferred.
11
+- The organization extension no longer replaces the write protocol with a separate legacy implementation. Existing legacy financial-conflict recovery is retained only on the confirmed legacy path.
12
+
13
+## Evidence and limits
14
+
15
+`node --test scripts/wp1-client-capability-test.mjs`: 43 PASS. The original 36-case subset against pre-change files from799cff4 fails31 cases, including incomplete acknowledgements, missing revisions and tenant races. The later scheduling/tenant/status cases have separate RED evidence captured before their fixes. These are synthetic VM protocol tests. Source browser coverage also exercises the real organization extension and rendered save badge; generated Pages testing uses the same contract with bundled code/CSP. Full acceptance must still exercise real Auth/JWT/PostgREST and the actual deployed schema, and server-authoritative manual/purchase workflows remain separate work.
16
+
17
+The local image initially lacked Chromium; it was installed. Default system WOFF2 fonts then reproduced invoice input/printing failures on unchanged799cff4. With a process-only fontconfig selecting installed TTF/OTF system fonts, both baseline comparison cases passed without application/assertion changes. This environment workaround is outside repository/CI configuration. Failed/incomplete attempts are not counted as passes.
18
+
19
+Independent review identified and reproduced two scheduling/tenant races. Both were fixed with failing-before/passing-after tests; final reviewer independently ran43/43 tests and found no remaining blocking issue in this scoped review. This does not replace browser or production acceptance. Legacy browser fixtures explicitly model the absent mode RPC (PGRST202), and real hydration is required before fixture writes; existing persistence/print assertions are retained.
20
+
21
+A final identity-refresh status regression is also covered: with no queued save, stale write completion changes a still-pending same-tenant badge from saving to unconfirmed, without accepting the stale ACK or clearing a newer save timer.
22
+
23
+Final local checkpoint2026-11-04:43Node,222full-browser,8generatedPages and55quality commands PASS. C8 fixture now waits for actual organization/startup readiness before injecting synthetic authority;30repeated cases PASS. [Hashes and evidence](evidence/client-sync/result.json). New-headCI is separate and pending at publication.
docs/wp1/ROLLOUT_HOLD.md
+3
-1
@@ -9,8 +9,10 @@ Required before G1:
9
- Reconcile24/24historical migration-version drift by SQL content, and verify new columns/indexes/function contracts against the live catalog.
10
- Red/green tests for all corrective findings; actual concurrent posting;1000event trial balance; all suite and CI results at exact SHA.
11
- Conservative DOWN/UP for all11prerequisites pluscorrection is now locally proved:71baselinefunctiondefinitions/ACLs andbaseline triggers restored;4postedvouchers/10lines/10auditrows retained byhash; candidate APIs revoked, compatibleindexes/counters retained. Fresh exactheadCI andproductionparity remain gates. This is notpristineschema rollback.
12
-- Capability-safe client integration; correct purchase correction/cancel transaction; no successful toast without server acknowledgement. Until proven, no enforcement cutover.
12
+- Capability-safe client candidate is locally tested; final CI and real-service integration remain. Correct purchase correction/cancel transaction; no successful toast without server acknowledgement. Until proven, no enforcement cutover.
13
- Per-source shadow report including fieldscope/currency/period checks, not only aggregate balance. Existing11posted vouchers had zero anomalies in the limited aggregate audit; that is not full cutover approval.
14
- Read-only encrypted backup and disposable restore proof (G3secret viaenvironment), ordered verification queries, owner-reviewable G1 checklist.
15
16
Do not automatically rewrite historical vouchers. Never enable enforcement merely because migration execution succeeded. No G2–G5 operation is needed for this disposable SQL checkpoint.
17
+
18
+Rollback must coordinate the frontend and server: conservative SQL DOWN retains the version column but revokes candidate APIs. The new client deliberately refuses to downgrade a versioned snapshot; revert to the tested previous frontend when rolling the server back. Do not treat a SQL-only DOWN as a complete service rollback.
docs/wp1/SOURCE_COVERAGE.md
+4
-4
@@ -2,9 +2,9 @@
2
3
| Source | Candidate server path | Current acceptance |
4
|---|---|---|
5
-| Manual journal | create/update/post/reverse RPC | SQL revalidation in progress; UI integration pending |
6
-| Sales invoice | server monetary contract + autopost | SQL tests in progress; current main client unchanged |
7
-| Purchase invoice | fixed purchase contract + autopost | SQL tests in progress; corrective/cancel ENFORCE flow incomplete |
5
+| Manual journal | create/update/post/reverse RPC | Disposable SQL suite PASS; manual UI RPC integration pending |
6
+| Sales invoice | server monetary contract + autopost | Disposable SQL suite PASS; end-to-end UI server path pending |
7
+| Purchase invoice | fixed purchase contract + autopost | Disposable SQL suite PASS; client refuses unsupported ENFORCE correction; complete corrective/cancel transaction pending |
8
| Receipt/payment | existing staged RPC source allowlist | End-to-end server amount derivation and allocations NOT VERIFIED |
9
| Cheques | no completed source adapter | Not yet server-enforced |
10
| Expenses/income | allowlisted staged path | Source-derived amounts/lifecycle not yet fully server-enforced |
@@ -12,4 +12,4 @@
12
| COGS/inventory | existing model needs source-specific contract | Not yet server-enforced |
13
| Payroll/contracts/assets/petty cash | historical allowlists are not implementation proof | Not yet accepted; no new modules in this scope |
14
15
-No UI activation has been made in this WP1 checkpoint. UI state labels and capability detection remain explicit required work before rollout. An allowlist or balanced caller-provided payload is not proof of authoritative source posting.
15
+No production UI activation has been made. Candidate capability-safe sync and unconfirmed-save labels are under verification; source-specific posting UI and reconciliation remain required before rollout. An allowlist or balanced caller-provided payload is not proof of authoritative source posting.
docs/wp1/STATUS_FA.md
+17
-20
@@ -1,28 +1,25 @@
1
-# WP1 — دفتر مالی سمت سرور
1
+# WP1 — وضعیت جاری دفتر مالی سمت سرور
2
3
-وضعیت: **در حال انجام؛ قابل انتشار نیست.**
3
+**در حال انجام؛ آماده ادغام یا نصب عملیاتی نیست.** بهروزشده: ۲۰۲۶/۱۱/۰۴. هدف: ثبت مالی معتبر و تراکنشی روی سرور، حفظ تاریخچه قطعی، جداسازی شرکت/سازمان و اعلام صادقانه نتیجه ذخیره. شاخه مستقل روی WP0 PR194؛ [پیشنویس PR195](https://github.com/davoodmehraban89/Factor-easy/pull/195).
4
5
-هدف: رد سند نامتوازن و تغییر پس از قطعیشدن در خود پایگاهداده، با مسیر RPC تراکنشی، کنترل شرکت/سال/دسترسی، برگشت و شمارهگذاری ایمن. شروع از WP0 PR194 با Quality41416988716/Security41416988731 موفق؛ گزارش خط مبنا و شواهد تحویل شدهاند. PR194 هنوز ادغام نشده است؛ این شاخه روی آن قرار دارد.
5
+## انجامشده با شاهد
6
7
-کار جاری: انتقال انتخابی۱۱ SQL مرحلهبندیشده از PR162–173 به شاخه مستقل، آزمون مجدد روی PostgreSQL17 برگرفته از migrationهای واقعی مخزن. هیچ API یا کد کلاینت فعال نشده و هیچ migration روی Production اجرا نشده است.
7
+- زنجیره ۱۱ پیشنیاز و یک اصلاح تکمیلی: حالت پیشفرض audit؛ تغییر حالت فقط برای مدیر سیستم؛ کنترل شرکت/سال/ارز/مبالغ؛ شمارنده تفکیکشده شرکت؛ حفاظت سند قطعی، ابعاد و انتقال هویت؛ مجوز برگشت تکراری. فایلهای اولیه برای ردیابی حفظ شدهاند؛ نصب جزئی آنها مجاز نیست.
8
+- D1/D2 و ابعاد روی baseline با علت مورد انتظار شکست میخورند و روی اصلاح موفقاند. آزمونهای منفی، تراز ۱۰۰۰ رویداد و رقابت واقعی دو اتصال PostgreSQL موفقاند.
9
+- برگشت محافظهکارانه هر ۱۲ تغییر، سپس نصب مجدد موفق: تعریف و مجوز ۷۱ تابع پایه و تریگرهای قبلی بازمیگردد؛ ۴ سند قطعی، ۱۰ ردیف، ۱۰ رویداد ممیزی و شمارندهها بدون تغییر میمانند. ساختارها و ایندکسهای سازگار عمداً حفظ میشوند. [شاهد محلی](evidence/prerequisite-rollback/result.json).
10
+- کامیت `799cff4fcb1b9a98f763baf9e79a030c099deb58`: [Quality41626213964](https://github.com/davoodmehraban89/Factor-easy/actions/runs/41626213964)، [Security41626213753](https://github.com/davoodmehraban89/Factor-easy/actions/runs/41626213753) و [WP1 proof41626213760](https://github.com/davoodmehraban89/Factor-easy/actions/runs/41626213760) موفق؛ شامل آزمون کامل SQL و هر دو چرخه rollback. این شاهد به تغییرات بعد از این کامیت تعمیم داده نمیشود.
11
+- محافظ اصلاح/ابطال خرید زیر ENFORCE، خطای ارتباط یا تعویض حساب پیش از تغییر محلی متوقف میشود. این محافظ معادل تکمیل گردش اصلاح خرید روی سرور نیست.
12
9
-شواهد اولیه: تست مستقل D1/D2/D2_DIMENSION روی baseline با پیام مشخص WP1_REQUIRED_GUARDS_MISSING شکست خورد؛ روی زنجیره SQL منتقلشده موفق شد. D2 از سند جداگانه متوازن استفاده میکند؛ SET CONSTRAINTS ALL IMMEDIATE و فهرست خطاهای قابلقبول از قبولی کاذب جلوگیری میکنند. این قبولی، کل WP1 یا امنیت تمام RPCها را تأیید نمیکند.
13
+## کار جاری
14
11
-یافتههای باز در کد قبلی: حالت پیشفرض off؛ تغییر حالت توسط مالک عادی سازمان؛ نبود WHEN محدود به دفتر؛ شمارهگذاری بدون تفکیک شرکت؛ کنترل ناکامل سال/ارز ردیف و وضعیت بسته سال مالی؛ مجوز برگشت تکراری. بازبینی و migration اصلاحی در حال تهیه است.
15
+اتصال مشترک sync و مسیر سازمان به نسخه رکورد و تأیید کامل پاسخ سرور؛ بدون probe اضافی هنگام ورود. کنترل تعارض همزمانی، پاسخ ناقص/دیرهنگام و حفظ ویرایش ذخیرهنشده. ۴۳ آزمون Node و ۸ آزمون Pages موفق؛ بازبینی مستقل بدون مورد مهم باقیمانده تمام شده است. اجرای کامل نهایی۲۲۲/۲۲۲ و۵۵فرمان کنترل موفقاند؛ fixture گردشکار پس از انتظار آمادهشدن ماژول مجوزها۳۰بار موفق شد. CI کامیت جدید پس از انتشار باید جداگانه تأیید شود. [شواهد](evidence/client-sync/result.json). [قرارداد کلاینت](CLIENT_SYNC_CONTRACT.md).
16
13
-باقیمانده: تستهای منفی یافتههای بالا و رفع آنها؛ اثبات همزمانی و۱۰۰۰رویداد؛ DOWN برای تمام تغییرات و UP/DOWN/UP؛ feature probe و fallback صحیح کلاینت؛ مسیر اصلاح/ابطال/ذخیره خرید زیر ENFORCE؛ پوشش منبعبهمنبع و برچسب صادقانه پوشش؛ گزارش shadow؛ بسته rollout/backup/rollback برای G1؛ CI تازه. آزمون واقعی JWT/PostgREST و Production پذیرش نشدهاند.
17
+## باقیمانده برای پایان WP1
18
15
-هیچ نصب یا تأییدی از مالک اکنون لازم نیست. G1 فقط پس از آمادهشدن بسته قابل بازبینی و اثبات کامل درخواست میشود. مالک در ۲۰۲۶/۱۱/۰۳ ادامه فازهای بعد را تأیید کرده؛ آغاز آنها تابع گیت مرحله قبل است. [نقشه راه جاری](../ROADMAP_CURRENT.md).
19
+۱. تکمیل مسیر دستی و خرید با RPC، شامل اصلاح/ابطال تراکنشی و نمایش نتیجه واقعی؛ محافظ رد عملیات کافی نیست.
20
+۲. پذیرش همه منابع در [ماتریس پوشش](SOURCE_COVERAGE.md)، برچسب صادقانه قابلیتهای ناقص و گردش حل تعارض بدون از دسترفتن ویرایشها.
21
+۳. تطبیق محتوای ۲۴/۲۴ اختلاف تاریخی migration با سرور و آزمون روی ساختار کامل، نه فقط fixture برگرفته از منابع مخزن.
22
+۴. shadow کامل شرکت/سال/ارز/دوره؛ گزارش محدود قبلی ۱۱ سند بدون اشکال تراز، جانشین این بررسی نیست.
23
+۵. پذیرش واقعی Auth/JWT/PostgREST در محیط غیرعملیاتی، بکاپ رمزگذاریشده و بازیابی مستقل، بسته قابل بررسی G1 و CI دقیق نسخه نهایی.
24
17
-## checkpoint 2026-11-03
18
-پس از راهاندازی مجدد محیط، آزمونهای هدفمند دوباره اجرا شدند:۱۴ حالت منفی posting و قرارداد shadow/defaultaudit/adminsetter/WHEN موفق. آزمون کامل۱۰۰۰رویداد هنوز نتیجه نهایی ندارد؛ اجرای قطعشده قبلی قبولی محسوب نمیشود.۱۲فایل candidate جدید باعث۹۴فایل migration شده؛۲۴production-only و۳۶repo-only شامل۱۲candidate نصبنشده است، نه۱۲اختلاف تازه Production.
19
-
20
-آزمون همزمان واقعیِ دو اتصال نیز موفق شد: ساخت تکراری یک سند ایجاد کرد، دو قطعیسازی شمارههای۱و۲ گرفتند، و از دو برگشت همزمان فقط یکی مجاز شد. آزمون انتقال هویت سند و مقدار null و چرخه اصلاحی UP/DOWN/UP مجدداً موفقاند؛ شواهد در پوشههای concurrency-final،scope-final،correction-final ثبت شدهاند. اجرای۱۰۰۰رویداد دوباره پیش از نتیجه نهایی قطع شد؛ قبولی آن ثبت نمیشود. شاخه بهصورت پیشنویس منتشر میشود تا CI مستقل از قطع محیط ادامه دهد؛ قابل ادغام یا نصب نیست.
21
-
22
-## نتیجه تازه CI
23
-
24
-روی کامیت `4b00e5b`، [Quality41586514247](https://github.com/davoodmehraban89/Factor-easy/actions/runs/41586514247)،[Security41586514251](https://github.com/davoodmehraban89/Factor-easy/actions/runs/41586514251) و [WP1 proof41586514303](https://github.com/davoodmehraban89/Factor-easy/actions/runs/41586514303) موفق شدند. فرمان کامل SQL شامل آزمون۱۰۰۰رویداد و همزمانی پایان یافت؛ این شاهد جایگزین اجرای محلی قطعشده است. دریافت artifact از provider ممکن نشد؛ نتیجه job/step در GitHub API تأیید شد، نه شمارش ساختگی لاگ.
25
-
26
-محافظ جدید خرید قبل از تغییر محلی، حالت سرور را بررسی میکند: ENFORCE یا خطای شبکه/حالت نامعتبر/تعویض حساب، اصلاح و ابطال را بدون تغییر رد میکند. نبود صریح RPC یا off/audit مسیر قبلی را حفظ میکند.۲۸تست مرورگر و۳تست محافظ در Pages موفق؛ اجرای نهایی CI این تغییر جداست. این حفاظت معادل تکمیل عملیات اصلاح خرید روی سرور نیست.
27
-
28
-بازگشت محافظهکارانه هر۱۱پیشنیاز نیز اکنون در محیط مستقل موفق است:۷۱تعریف تابع/مجوز و تریگرهای قبلی بازگردانده شدند؛۴سند قطعی،۱۰ردیف و۱۰رویداد ممیزی و تاریخچه شمارنده بدون تغییر ماندند. پس از UP مجدد،D1/D2 موفقاند. ایندکسها و ساختارهای سازگار عمداً حفظ میشوند؛ همسانی با Production هنوز گیت جداست. [شاهد](evidence/prerequisite-rollback/result.json).
25
+هیچ migration یا داده مالی عملیاتی تغییر نکرده است. [بسته انتشار هنوز آماده نیست](ROLLOUT_HOLD.md). دستور مالک ادامه WP0–WP9 را مجاز کرده؛ گیتهای صریح G1–G5 باقیاند و فقط پس از تهیه نتیجه قابل بازبینی مطرح میشوند. [نقشه راه جاری](../ROADMAP_CURRENT.md). [تاریخچه این گزارش](history/STATUS_BEFORE_CLIENT_SYNC_2026-11-03.md).
docs/wp1/evidence/client-sync/c8-repeat.log
new
+74
@@ -0,0 +1,74 @@
1
+
2
+Running 30 tests using 1 worker
3
+
4
+(node:626) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
5
+(Use `node --trace-warnings ...` to show where the warning was created)
6
+
7
+
8
+(node:626) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
9
+(Use `node --trace-warnings ...` to show where the warning was created)
10
+
11
+
12
+[1/30] scripts/office-slice-c8.spec.js:8:1 › Office C8 policy editor publishes a two-stage policy
13
+[2/30] scripts/office-slice-c8.spec.js:51:1 › Office C8 policy publish control is authority-safe
14
+[3/30] scripts/office-slice-c8.spec.js:78:1 › Office C8 correspondence panel renders stage, history and performs one transition
15
+[4/30] scripts/office-slice-c8.spec.js:97:1 › Office C8 transition disables duplicate intent and refreshes stale revision without auto retry
16
+[5/30] scripts/office-slice-c8.spec.js:114:1 › Office C8 discards a late response after organization switch
17
+[6/30] scripts/office-slice-c8.spec.js:121:1 › Office C8 attach uses catalog selection and keeps one request id for the same pending intent
18
+(node:1128) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
19
+(Use `node --trace-warnings ...` to show where the warning was created)
20
+
21
+
22
+(node:1128) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
23
+(Use `node --trace-warnings ...` to show where the warning was created)
24
+
25
+
26
+[7/30] scripts/office-slice-c8.spec.js:8:1 › Office C8 policy editor publishes a two-stage policy
27
+[8/30] scripts/office-slice-c8.spec.js:51:1 › Office C8 policy publish control is authority-safe
28
+[9/30] scripts/office-slice-c8.spec.js:78:1 › Office C8 correspondence panel renders stage, history and performs one transition
29
+[10/30] scripts/office-slice-c8.spec.js:97:1 › Office C8 transition disables duplicate intent and refreshes stale revision without auto retry
30
+[11/30] scripts/office-slice-c8.spec.js:114:1 › Office C8 discards a late response after organization switch
31
+[12/30] scripts/office-slice-c8.spec.js:121:1 › Office C8 attach uses catalog selection and keeps one request id for the same pending intent
32
+(node:1629) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
33
+(Use `node --trace-warnings ...` to show where the warning was created)
34
+
35
+
36
+(node:1629) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
37
+(Use `node --trace-warnings ...` to show where the warning was created)
38
+
39
+
40
+[13/30] scripts/office-slice-c8.spec.js:8:1 › Office C8 policy editor publishes a two-stage policy
41
+[14/30] scripts/office-slice-c8.spec.js:51:1 › Office C8 policy publish control is authority-safe
42
+[15/30] scripts/office-slice-c8.spec.js:78:1 › Office C8 correspondence panel renders stage, history and performs one transition
43
+[16/30] scripts/office-slice-c8.spec.js:97:1 › Office C8 transition disables duplicate intent and refreshes stale revision without auto retry
44
+[17/30] scripts/office-slice-c8.spec.js:114:1 › Office C8 discards a late response after organization switch
45
+[18/30] scripts/office-slice-c8.spec.js:121:1 › Office C8 attach uses catalog selection and keeps one request id for the same pending intent
46
+(node:2125) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
47
+(Use `node --trace-warnings ...` to show where the warning was created)
48
+
49
+
50
+(node:2125) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
51
+(Use `node --trace-warnings ...` to show where the warning was created)
52
+
53
+
54
+[19/30] scripts/office-slice-c8.spec.js:8:1 › Office C8 policy editor publishes a two-stage policy
55
+[20/30] scripts/office-slice-c8.spec.js:51:1 › Office C8 policy publish control is authority-safe
56
+[21/30] scripts/office-slice-c8.spec.js:78:1 › Office C8 correspondence panel renders stage, history and performs one transition
57
+[22/30] scripts/office-slice-c8.spec.js:97:1 › Office C8 transition disables duplicate intent and refreshes stale revision without auto retry
58
+[23/30] scripts/office-slice-c8.spec.js:114:1 › Office C8 discards a late response after organization switch
59
+[24/30] scripts/office-slice-c8.spec.js:121:1 › Office C8 attach uses catalog selection and keeps one request id for the same pending intent
60
+(node:2617) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
61
+(Use `node --trace-warnings ...` to show where the warning was created)
62
+
63
+
64
+(node:2617) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
65
+(Use `node --trace-warnings ...` to show where the warning was created)
66
+
67
+
68
+[25/30] scripts/office-slice-c8.spec.js:8:1 › Office C8 policy editor publishes a two-stage policy
69
+[26/30] scripts/office-slice-c8.spec.js:51:1 › Office C8 policy publish control is authority-safe
70
+[27/30] scripts/office-slice-c8.spec.js:78:1 › Office C8 correspondence panel renders stage, history and performs one transition
71
+[28/30] scripts/office-slice-c8.spec.js:97:1 › Office C8 transition disables duplicate intent and refreshes stale revision without auto retry
72
+[29/30] scripts/office-slice-c8.spec.js:114:1 › Office C8 discards a late response after organization switch
73
+[30/30] scripts/office-slice-c8.spec.js:121:1 › Office C8 attach uses catalog selection and keeps one request id for the same pending intent
74
+ 30 passed (22.7s)
docs/wp1/evidence/client-sync/full-browser.log
new
+257
@@ -0,0 +1,257 @@
1
+
2
+Running 222 tests using 1 worker
3
+
4
+(node:4180) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
5
+(Use `node --trace-warnings ...` to show where the warning was created)
6
+
7
+
8
+(node:4180) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
9
+(Use `node --trace-warnings ...` to show where the warning was created)
10
+
11
+
12
+[1/222] scripts/accounting-document-workflow.spec.js:90:1 › invoice and purchase registers isolate companies selected in Settings; no ALL fallback or cross-company edit
13
+[2/222] scripts/accounting-document-workflow.spec.js:156:1 › formal invoice remains editable draft across server reload; explicit posting creates exactly one balanced voucher
14
+[3/222] scripts/accounting-document-workflow.spec.js:212:1 › posted sale can be returned to an editable corrective draft; original voucher stays immutable and balances
15
+[4/222] scripts/accounting-document-workflow.spec.js:264:1 › pilot manual journal correction permits draft edits, balanced repost and auditable cancellation
16
+[5/222] scripts/accounting-document-workflow.spec.js:297:1 › pilot cancellation preserves posted invoice record while only unposted drafts can be deleted
17
+[6/222] scripts/accounting-document-workflow.spec.js:335:1 › pilot purchase: posted to corrective draft to edited balanced repost via document manager
18
+[7/222] scripts/accounting-document-workflow.spec.js:389:1 › pilot purchase denies paid/consumed source; cancels unallocated posting without erasing old voucher
19
+[8/222] scripts/accounting-document-workflow.spec.js:416:1 › seamless sale correction: opening and cancelling leaves ledger unchanged; saving retains visible identity, printing and audit
20
+[9/222] scripts/accounting-document-workflow.spec.js:460:1 › seamless purchase correction: same visible number, no write on opening, save and print corrected purchase
21
+[10/222] scripts/accounting-document-workflow.spec.js:507:1 › treasury amendment in the same form preserves one record and same reference without on-open ledger writes
22
+[11/222] scripts/accounting-document-workflow.spec.js:562:1 › treasury correction excludes cheque, linked settlements and locked periods; cancellation retains immutable history
23
+[12/222] scripts/accounting-document-workflow.spec.js:601:1 › treasury amend rejection on lost RPC keeps protected original on server and no partial correction payload
24
+[13/222] scripts/accounting-document-workflow.spec.js:618:1 › cannot finalize draft if fiscal posting chart has no required account; draft remains intact
25
+[14/222] scripts/accounting-document-workflow.spec.js:630:1 › F2 validates formal invoice then saves a draft without posting any financial journal
26
+[15/222] scripts/accounting-document-workflow.spec.js:648:52 › WP1 ENFORCE purchase return rejects before local or server mutation
27
+[16/222] scripts/accounting-document-workflow.spec.js:648:52 › WP1 ENFORCE purchase cancel rejects before local or server mutation
28
+[17/222] scripts/accounting-document-workflow.spec.js:648:52 › WP1 ENFORCE purchase seamless rejects before local or server mutation
29
+[18/222] scripts/accounting-p0-journal.spec.js:26:1 › journal P0 renders header controls, live balance and dynamic dimensions
30
+[19/222] scripts/accounting-p0-journal.spec.js:44:1 › journal row copy preserves account, amount and analytic selection
31
+[20/222] scripts/admin-provisioning.spec.js:3:1 › central administrator provisions account via server-only endpoint, with no prior signup
32
+[21/222] scripts/admin-provisioning.spec.js:32:1 › invalid email/weak password are rejected client-side without invoking server
33
+[22/222] scripts/admin-provisioning.spec.js:54:1 › server-side provisioning 400 shows actionable safe Persian reason without leaking raw HTTP error
34
+[23/222] scripts/branding-login.spec.js:8:1 › Finora login renders premium ERP branding and real icon assets
35
+[24/222] scripts/branding-login.spec.js:19:1 › Finora login remains focused and usable on mobile
36
+[25/222] scripts/branding-login.spec.js:24:2 › complete login fits short desktop 1366x650
37
+[26/222] scripts/branding-login.spec.js:24:2 › complete login fits short desktop 1024x600
38
+[27/222] scripts/branding-login.spec.js:24:2 › complete login fits short desktop 920x600
39
+[28/222] scripts/branding-login.spec.js:42:2 › overflow login remains reachable from top to bottom 1024x450
40
+[29/222] scripts/branding-login.spec.js:42:2 › overflow login remains reachable from top to bottom 680x400
41
+[30/222] scripts/branding-login.spec.js:42:2 › overflow login remains reachable from top to bottom 390x568
42
+[31/222] scripts/chart-completeness.spec.js:10:1 › chart upgrade previews every addition and changes accounts only on explicit apply
43
+[32/222] scripts/chart-completeness.spec.js:22:1 › conflicting custom account blocks all chart additions and escapes its title
44
+[33/222] scripts/chart-completeness.spec.js:28:1 › switching active company after preview blocks application
45
+[34/222] scripts/commerce-route-types.spec.js:21:1 › commerce menu routes offer only matching document families and retain unsaved sale fields
46
+[35/222] scripts/commerce-route-types.spec.js:35:1 › sales document selector reflects restored defaults and existing kind changes
47
+[36/222] scripts/dom-smoke.spec.js:43:1 › Phase A rail stays exact through organization refresh and real commerce/accounting/report navigation
48
+[37/222] scripts/dom-smoke.spec.js:104:1 › Phase A visible licensed launcher preserves extra workspaces without adding rail items
49
+[38/222] scripts/dom-smoke.spec.js:133:1 › Phase A omits an unavailable purchase command and restores it when its implementation returns
50
+[39/222] scripts/dom-smoke.spec.js:150:1 › real DOM shell and post-login smoke
51
+[40/222] scripts/dom-smoke.spec.js:153:1 › expired license browser enforcement
52
+[41/222] scripts/dom-smoke.spec.js:156:1 › isolated print document honors CSS paper size in Chromium PDF
53
+[42/222] scripts/dom-smoke.spec.js:159:1 › operational settings persist warehouse, currency and costing with an accurate audit record
54
+[43/222] scripts/enterprise-invitation.spec.js:3:1 › ELI-3 exposes invitation UI actions and URL acceptance hook
55
+[44/222] scripts/enterprise-invitation.spec.js:13:1 › ELI-3 invitation URL processor accepts token once and removes it from address bar
56
+[45/222] scripts/enterprise-license.spec.js:3:1 › ELI-1 named-user capacity and delegated core admin DOM contract
57
+[46/222] scripts/enterprise-org-ux.spec.js:3:1 › ELI-4 enterprise organization UX exposes typed tree and capacity dashboard
58
+[47/222] scripts/enterprise-role.spec.js:3:1 › ELI-2 role grants merge with direct grants and role UI stays core-admin only
59
+[48/222] scripts/identity-wave5a.spec.js:2:1 › Wave 5a exposes explicit OTP login and signup modes
60
+[49/222] scripts/identity-wave5a.spec.js:3:1 › Wave 5a OTP login cannot silently create a user
61
+[50/222] scripts/identity-wave5a.spec.js:4:1 › Wave 5a explicit signup is the email OTP creation path
62
+[51/222] scripts/identity-wave5b.spec.js:2:1 › Wave 5b export fails closed when fresh membership is denied
63
+[52/222] scripts/identity-wave5b.spec.js:8:1 › Wave 5b known revocation clears tenant memory and stale user
64
+[53/222] scripts/identity-wave5c.spec.js:2:1 › Wave 5c full export is denied without organization-management authority
65
+[54/222] scripts/identity-wave5c.spec.js:7:1 › Wave 5c restore is denied before reading file without organization-management authority
66
+[55/222] scripts/login-auth-transport.spec.js:10:1 › Auth timeout covers a stalled password response body after headers reach the real SDK
67
+[56/222] scripts/login-auth-transport.spec.js:37:1 › A complete Auth response preserves status, headers and an unread body
68
+[57/222] scripts/login-auth-transport.spec.js:51:1 › Real SDK keeps a completed invalid-password response distinct from a transport timeout
69
+[58/222] scripts/login-auth-transport.spec.js:65:1 › Restoring an expired session retries a stalled Auth body and recovers through the real SDK
70
+[59/222] scripts/login-auth-transport.spec.js:91:1 › Upstream cancellation remains effective while an Auth body is still arriving
71
+[60/222] scripts/login-auth-transport.spec.js:111:1 › Non-Auth reads retain their streaming response and original cancellation signal
72
+[61/222] scripts/login-connectivity.spec.js:15:1 › Login diagnostics distinguish a reachable auth service from password errors
73
+[62/222] scripts/login-connectivity.spec.js:28:1 › Login diagnostics label upstream unreachable without exposing credentials
74
+[63/222] scripts/login-connectivity.spec.js:36:1 › Login diagnostics label HTTP server failures, not bad passwords
75
+[64/222] scripts/login-connectivity.spec.js:44:1 › A failing manifest cannot falsely classify working login JS and Auth as SITE_UNREACHABLE
76
+[65/222] scripts/login-connectivity.spec.js:61:1 › Critical JS read fails but manifest and Auth are healthy: report failed asset precisely
77
+[66/222] scripts/login-connectivity.spec.js:77:1 › Both site resources and Auth unreachable: report independent failures without exposing user data
78
+[67/222] scripts/login-connectivity.spec.js:91:1 › Preflight comparison keeps standard Auth and REST failures when simple health responds
79
+[68/222] scripts/login-connectivity.spec.js:138:1 › Preflight comparison supplemental failure cannot override healthy ordinary endpoints
80
+[69/222] scripts/login-connectivity.spec.js:158:1 › Preflight comparison report excludes credentials query values bodies and raw errors
81
+[70/222] scripts/login-connectivity.spec.js:188:1 › Preflight comparison clears an earlier report before an offline attempt
82
+[71/222] scripts/login-connectivity.spec.js:205:1 › Preflight comparison never puts a non-publishable key into a query
83
+[72/222] scripts/login-connectivity.spec.js:225:1 › Auth and static files can work while Supabase PostgREST data endpoint is unreachable
84
+[73/222] scripts/login-connectivity.spec.js:239:1 › A 503 data gateway response remains distinct from good Auth service
85
+[74/222] scripts/login-connectivity.spec.js:259:3 › An immediate AUTH_UNREACHABLE remains distinct when another probe times out
86
+[75/222] scripts/login-connectivity.spec.js:259:3 › An immediate SITE_JS_NETWORK_ERROR remains distinct when another probe times out
87
+[76/222] scripts/login-startup-readiness.spec.js:83:1 › Pages login does not wait for a separate recovery script download
88
+[77/222] scripts/login-startup-readiness.spec.js:110:1 › Pages preload and execute one core URL versioned from its complete auth content
89
+[78/222] scripts/login-startup-readiness.spec.js:127:1 › Pages static button handlers have a content version for their DOM order
90
+[79/222] scripts/login-startup-readiness.spec.js:141:3 › early successful Pages login survives a slow business bundle before company-read timeout starts
91
+[80/222] scripts/login-startup-readiness.spec.js:141:3 › early successful Pages login survives a slow accounting bundle before company-read timeout starts
92
+[81/222] scripts/login-startup-readiness.spec.js:171:1 › stalled Pages assets expire visibly without late entry and a fresh click recovers after download
93
+[82/222] scripts/login-startup-readiness.spec.js:195:1 › cached-session restoration owns the login attempt while early password clicks are ignored
94
+[83/222] scripts/login-startup-readiness.spec.js:211:1 › early password click waits for the pending initial session check then continues once without another click
95
+[84/222] scripts/login-startup-readiness.spec.js:226:1 › Pages downloads its pinned extension bundle before slow accounting finishes and executes it once
96
+[85/222] scripts/login-startup-readiness.spec.js:254:1 › early successful credentials cannot open the workspace when a required Pages bundle fails
97
+[86/222] scripts/office-slice-c1.spec.js:3:1 › Office C1 exposes server-authoritative read-evidence hook
98
+[87/222] scripts/office-slice-c2.spec.js:3:1 › Office C2 exposes actionable referral work queue
99
+[88/222] scripts/office-slice-c3.spec.js:3:1 › Office C3 exposes related-letter and archive controls
100
+[89/222] scripts/office-slice-c4.spec.js:3:1 › Office C4 exposes versioned template controls without mutating registered history
101
+[90/222] scripts/office-slice-c5.spec.js:2:1 › Office C5 exposes internal approval controls
102
+[91/222] scripts/office-slice-c6.spec.js:2:1 › Office C6 exposes internal SLA controls
103
+[92/222] scripts/office-slice-c7.spec.js:2:1 › Office C7 exposes searchable archive OCR provenance controls
104
+[93/222] scripts/office-slice-c8-runtime.spec.js:17:1 › C8 runtime renders server text safely and transitions with expected revision
105
+[94/222] scripts/office-slice-c8-runtime.spec.js:32:1 › C8 stale transition refreshes state and never blind-retries mutation
106
+[95/222] scripts/office-slice-c8-runtime.spec.js:45:1 › C8 network retry reuses request id and read-only state exposes no mutation control
107
+[96/222] scripts/office-slice-c8-runtime.spec.js:56:1 › C8 unattached correspondence offers policy attach and sends idempotency key
108
+[97/222] scripts/office-slice-c8.spec.js:8:1 › Office C8 policy editor publishes a two-stage policy
109
+[98/222] scripts/office-slice-c8.spec.js:51:1 › Office C8 policy publish control is authority-safe
110
+[99/222] scripts/office-slice-c8.spec.js:78:1 › Office C8 correspondence panel renders stage, history and performs one transition
111
+[100/222] scripts/office-slice-c8.spec.js:97:1 › Office C8 transition disables duplicate intent and refreshes stale revision without auto retry
112
+[101/222] scripts/office-slice-c8.spec.js:114:1 › Office C8 discards a late response after organization switch
113
+[102/222] scripts/office-slice-c8.spec.js:121:1 › Office C8 attach uses catalog selection and keeps one request id for the same pending intent
114
+[103/222] scripts/pages-artifact.spec.js:10:1 › hardened Pages artifact loads without script/CSP console errors
115
+scripts/pages-artifact.spec.js:10:1 › hardened Pages artifact loads without script/CSP console errors
116
+Pages artifact built: 133 static + 270 runtime inline handlers externalized; diag.html intentionally excluded.
117
+
118
+
119
+[104/222] scripts/pages-artifact.spec.js:30:1 › Production CSP login and connectivity actions work while later ERP JS is still downloading
120
+[105/222] scripts/pages-artifact.spec.js:59:1 › Slow final CSP dispatcher keeps login usable without loading legacy ERP scripts
121
+[106/222] scripts/pages-artifact.spec.js:122:1 › Built Pages uses exactly one SHA-pinned local bundle for all 14 ERP extensions
122
+[107/222] scripts/pages-artifact.spec.js:145:1 › A blocked production bundle fails closed and never exposes a partial financial workspace
123
+[108/222] scripts/pages-artifact.spec.js:166:1 › Built Pages loads exactly three ordered core groups instead of 38 blocking requests
124
+[109/222] scripts/pages-artifact.spec.js:189:1 › A blocked required core Pages group prevents opening partial financial workspace
125
+[110/222] scripts/pages-artifact.spec.js:210:1 › Published Pages CSP event bindings open Commerce and the top-bar sales invoice menu
126
+[111/222] scripts/pages-artifact.spec.js:253:1 › Published Pages invoice product and buyer filters stay scoped and do not persist draft edits
127
+[112/222] scripts/password-admin-ui.spec.js:26:1 › central user/license row sends only target Auth identity to the recovery endpoint
128
+[113/222] scripts/password-admin-ui.spec.js:37:1 › global software admin assigns a new password from the central user row and secrets are cleared
129
+[114/222] scripts/password-admin-ui.spec.js:54:1 › generated strict-CSP Pages central reset button opens and invokes the server action
130
+[115/222] scripts/password-admin-ui.spec.js:68:1 › central password form rejects mismatched and weak passwords before calling the server
131
+[116/222] scripts/password-admin-ui.spec.js:84:1 › organization owner cannot render or invoke the central direct-password form
132
+[117/222] scripts/password-admin-ui.spec.js:92:1 › failed central password assignment shows no success and never echoes server details
133
+[118/222] scripts/password-admin-ui.spec.js:110:1 › organization owner targets the active Auth user, never the membership UUID or inactive member
134
+[119/222] scripts/password-admin-ui.spec.js:121:1 › ordinary member and foreign organization calls cannot invoke manager recovery
135
+[120/222] scripts/password-admin-ui.spec.js:128:1 › pending repeated sends and the successful-send cooldown invoke the server once
136
+[121/222] scripts/password-admin-ui.spec.js:140:1 › server rejection shows a localized reason and never a false success or raw response
137
+[122/222] scripts/password-admin-ui.spec.js:153:1 › a stalled manager request ends with an uncertain-result message and no immediate duplicate
138
+[123/222] scripts/password-admin-ui.spec.js:168:1 › a thrown transport error never leaks raw server details
139
+[124/222] scripts/password-admin-ui.spec.js:179:1 › a delegated core manager can assist an active member independently of paid license state
140
+[125/222] scripts/password-admin-ui.spec.js:192:44 › central pending success cannot alter a reopened password dialog
141
+[126/222] scripts/password-admin-ui.spec.js:192:44 › central pending failure cannot alter a reopened password dialog
142
+[127/222] scripts/password-admin-ui.spec.js:216:1 › central password action rejects another submission while its request is pending
143
+[128/222] scripts/password-recovery.spec.js:48:1 › Forgot Password validates email and sends one account-neutral implicit recovery request
144
+[129/222] scripts/password-recovery.spec.js:62:1 › A stalled recovery request times out and restores usable login controls
145
+[130/222] scripts/password-recovery.spec.js:80:1 › Implicit recovery link opens required password panel without hydrating financial workspace
146
+[131/222] scripts/password-recovery.spec.js:93:1 › Invalid recovery link never uses a different cached account to change a password
147
+[132/222] scripts/password-recovery.spec.js:103:1 › Recovery marker alone cannot turn a cached session into a password reset
148
+[133/222] scripts/password-recovery.spec.js:119:3 › Invalid recovery can return to login: marker without a session
149
+[134/222] scripts/password-recovery.spec.js:119:3 › Invalid recovery can return to login: recovery callback without a refresh token
150
+[135/222] scripts/password-recovery.spec.js:135:1 › Verified recovery survives reload only for the same validated account
151
+[136/222] scripts/password-recovery.spec.js:149:1 › An unsupported fresh callback discards an earlier valid recovery proof
152
+[137/222] scripts/password-recovery.spec.js:160:1 › Recovery validates password, suppresses double submit and enters the verified account once
153
+[138/222] scripts/password-recovery.spec.js:181:1 › Rejected password update stays in recovery without exposing raw provider error
154
+[139/222] scripts/password-recovery.spec.js:193:1 › Another tab changing the account while recovery is checked cannot update that account
155
+[140/222] scripts/password-recovery.spec.js:208:1 › A session change after the final check cannot redirect the password mutation
156
+[141/222] scripts/password-recovery.spec.js:225:1 › Recovery proof cannot authorize a later session for the same account
157
+[142/222] scripts/password-recovery.spec.js:240:1 › Cancel recovery preserves another account that signed in in a different tab
158
+[143/222] scripts/password-recovery.spec.js:252:1 › Cancel logout remains pinned to recovery when the persistent account changes after its check
159
+[144/222] scripts/password-recovery.spec.js:267:1 › Cancel stays disabled until a pending recovery exchange has finished
160
+[145/222] scripts/password-recovery.spec.js:283:1 › Cancel a verified recovery clears only its local session and prevents automatic re-entry
161
+[146/222] scripts/password-recovery.spec.js:297:1 › Strict CSP recovery form is ready while a required business bundle is held
162
+[147/222] scripts/phase0-dark-theme-contrast.spec.js:57:1 › F0-06 dark mode maintains readable accounting panels, controls and shell
163
+[148/222] scripts/phase0-dark-theme-contrast.spec.js:69:1 › F0-06 light mode remains legible after switching out of dark mode
164
+[149/222] scripts/phase0-invoice-persistence.spec.js:80:1 › F0-03 isolated invoice save → mock-server sync → reload → edit → reload → print
165
+[150/222] scripts/phase0-invoice-persistence.spec.js:122:1 › F0-03 isolated transient RPC failure remains pending and retries without duplicate invoice
166
+[151/222] scripts/phase0-invoice-persistence.spec.js:139:1 › invoice defaults preserve zero VAT, document kind and every currency mode through save and session reload
167
+[152/222] scripts/phase0-invoice-persistence.spec.js:178:1 › source: company Edit and Save buttons persist settings and active company through logout without applying a chart
168
+[153/222] scripts/phase0-invoice-persistence.spec.js:178:1 › published Pages: company Edit and Save buttons persist settings and active company through logout without applying a chart
169
+[154/222] scripts/phase0-modal-dashboard.spec.js:19:1 › all representative close buttons, dynamically rendered dialogs and backdrop dismiss without reload
170
+[155/222] scripts/phase0-modal-dashboard.spec.js:35:1 › dashboard cash/assets cards drill to accounts, rows to ledger, recent voucher opens document
171
+[156/222] scripts/phase0-modal-dashboard.spec.js:64:1 › F0-02 commerce tab navigates away from accounting and exposes sales, purchases, product and contact links
172
+[157/222] scripts/phase0-selector-stress.spec.js:17:1 › F0-05 products: 1208 choices, Persian variants, keyboard and cross-tenant negative control
173
+scripts/phase0-selector-stress.spec.js:17:1 › F0-05 products: 1208 choices, Persian variants, keyboard and cross-tenant negative control
174
+F0-05 product filter browser ms: 11.8
175
+
176
+[158/222] scripts/phase0-selector-stress.spec.js:45:1 › F0-05 people: 1206 choices and 11-digit metadata filter with no implicit writes
177
+scripts/phase0-selector-stress.spec.js:45:1 › F0-05 people: 1206 choices and 11-digit metadata filter with no implicit writes
178
+F0-05 contact filter browser ms: 88.2
179
+
180
+[159/222] scripts/phase0-selector-stress.spec.js:65:1 › F0-05 1200+ account, project and contract comboboxes: scoped metadata, keyboard, no writes
181
+scripts/phase0-selector-stress.spec.js:65:1 › F0-05 1200+ account, project and contract comboboxes: scoped metadata, keyboard, no writes
182
+F0-05 account filter browser ms: 116.8
183
+
184
+F0-05 project filter browser ms: 111.2
185
+
186
+F0-05 contract filter browser ms: 117.9
187
+
188
+[160/222] scripts/phase0-startup-performance.spec.js:12:1 › F0 startup downloads ordered extension scripts concurrently and still initializes login
189
+scripts/phase0-startup-performance.spec.js:12:1 › F0 startup downloads ordered extension scripts concurrently and still initializes login
190
+F0 startup extension dispatch spread browser ms: 5
191
+
192
+[161/222] scripts/phase0-startup-performance.spec.js:38:1 › F0 startup is independent of optional spreadsheet CDN and keeps on-demand Excel guard
193
+[162/222] scripts/phase0-startup-performance.spec.js:47:1 › F0 login controls are actionable before a delayed non-auth extension completes
194
+scripts/phase0-startup-performance.spec.js:47:1 › F0 login controls are actionable before a delayed non-auth extension completes
195
+F0 login form enabled before late ERP script, elapsed ms: 434
196
+
197
+[163/222] scripts/phase0-startup-performance.spec.js:68:1 › F0 login visibly reports a pending mocked sign-in and suppresses duplicate requests
198
+[164/222] scripts/phase0-startup-performance.spec.js:90:1 › F0 auth transport times out stalled requests without affecting other Supabase endpoints
199
+[165/222] scripts/phase0-startup-performance.spec.js:115:1 › F0 restored session with stalled company data returns actionable error instead of endless loading
200
+[166/222] scripts/phase0-startup-performance.spec.js:136:1 › F0 cancelled company records read cannot apply a late partial datastore snapshot
201
+[167/222] scripts/phase0-startup-performance.spec.js:173:1 › F0 organization-scoped record hydration respects abort and tenant boundary
202
+[168/222] scripts/phase0-startup-performance.spec.js:204:1 › F0 test-account lifetime entitlement waits for delayed organization adapter, not placeholder profile
203
+[169/222] scripts/phase0-startup-performance.spec.js:284:1 › F0 bootstrap timeout reports ACCOUNT_CONTEXT without email, token or private profile
204
+[170/222] scripts/phase0-startup-performance.spec.js:297:1 › F0 bootstrap timeout reports TENANT_RECORDS when profile has already resolved
205
+[171/222] scripts/platform-office.spec.js:3:1 › modular launcher and office surfaces render from licensed modules
206
+[172/222] scripts/request-workflow-d2.spec.js:32:1 › D2 builder shows published state and publishes through server RPC
207
+[173/222] scripts/request-workflow-d2.spec.js:48:1 › D2 hides publishing for users without configure capability
208
+[174/222] scripts/request-workflow-d2.spec.js:55:1 › D2 retries create with the same idempotency key
209
+[175/222] scripts/request-workflow-d2.spec.js:68:1 › D2 stale publish revision refreshes instead of overwriting
210
+[176/222] scripts/request-workflow-d2.spec.js:78:1 › D2 renders and serializes all supported immutable form field types
211
+[177/222] scripts/request-workflow-d2.spec.js:104:1 › D2 select option authoring is preserved in publish payload
212
+[178/222] scripts/request-workflow-d3b.spec.js:19:1 › D3b visual editor publishes ordered steps with a bounded condition
213
+[179/222] scripts/request-workflow-d3b.spec.js:39:1 › D3b renders a read-only timeline with skipped and active condition evidence
214
+[180/222] scripts/request-workflow-d3c.spec.js:3:1 › D3c adds SLA configuration and surfaces outbox/runtime operations
215
+[181/222] scripts/request-workflow-d4a.spec.js:3:1 › D4a renders actionable queue and submits guarded decision
216
+[182/222] scripts/shell-scroll-ownership.spec.js:3:1 › desktop shell keeps three independent right-edge vertical scroll owners
217
+[183/222] scripts/shell-scroll-ownership.spec.js:41:1 › mobile keeps normal RTL document flow
218
+[184/222] scripts/taxpayer-print.spec.js:4:1 › Taxpayer System print follows the approved official landscape structure
219
+[185/222] scripts/taxpayer-print.spec.js:46:1 › isolated print waits for the supplied image before opening print
220
+[186/222] scripts/taxpayer-print.spec.js:65:1 › all visible invoice print digits are Persian across formal, informal and taxpayer templates without mutating data
221
+[187/222] scripts/taxpayer-print.spec.js:119:1 › purchase print popup displays Persian digits while keeping purchase master data untouched
222
+[188/222] scripts/ux-hardening-r2.spec.js:47:1 › saved keyboard preferences survive real sync, logout/login and reload with true and false values
223
+[189/222] scripts/ux-hardening-r2.spec.js:72:1 › settings hydration follows the restored account without discarding unsaved checkboxes on ordinary refresh
224
+[190/222] scripts/ux-hardening-r2.spec.js:92:1 › all five Excel field selections survive save, logout/login and reload with the initial product form restored
225
+[191/222] scripts/ux-hardening-r2.spec.js:116:1 › Excel hydration follows account restoration without discarding unsaved fields on ordinary refresh
226
+[192/222] scripts/ux-hardening-r2.spec.js:132:1 › Excel settings cannot mutate or save preferences when the existing write guard rejects
227
+[193/222] scripts/ux-hardening-r2.spec.js:144:1 › UX R2 adds searchable selectors, keyboard close/zeros and settings controls
228
+[194/222] scripts/ux-hardening-r2.spec.js:165:1 › counterparty project manager reuses global project master and attaches existing project
229
+[195/222] scripts/ux-hardening-r2.spec.js:177:1 › factory reset deletes only active-company rows and preserves ambiguous legacy rows in multi-company mode
230
+[196/222] scripts/ux-hardening-r2.spec.js:187:1 › factory reset denies non-manager without touching company data
231
+[197/222] scripts/ux-hardening-r2.spec.js:196:1 › product combobox searches one field by code, name and specification
232
+[198/222] scripts/ux-hardening-r2.spec.js:207:1 › existing invoice row rehydrates after cloud data arrives, displays an unclipped list and fills price/unit
233
+[199/222] scripts/ux-keyboard-f2.spec.js:50:1 › searchable products filter Persian variants; arrows select highlighted entry with Enter, not first
234
+[200/222] scripts/ux-keyboard-f2.spec.js:74:1 › large dropdown wheel scroll, PageDown, Home/End and Escape preserve selection
235
+[201/222] scripts/ux-keyboard-f2.spec.js:101:1 › F2 explicitly saves valid active form but rejects missing rows, unsupported modal and no active entry
236
+[202/222] scripts/ux-keyboard-f2.spec.js:132:1 › F2 saves the company form or default settings according to focused field
237
+[203/222] scripts/ux-keyboard-f2.spec.js:148:1 › Settings keyboard saves the focused appearance card through its real save handler
238
+[204/222] scripts/ux-keyboard-f2.spec.js:167:1 › Settings keyboard saves the focused Excel card without saving invoice defaults
239
+[205/222] scripts/ux-keyboard-f2.spec.js:181:1 › Settings keyboard routes only the focused operational card to its existing save action
240
+[206/222] scripts/ux-keyboard-f2.spec.js:199:1 › Settings keyboard never saves invoice defaults from an unrelated account form
241
+[207/222] scripts/ux-keyboard-f2.spec.js:207:1 › F2 never silently finalizes a purchase: explicit confirmation is required
242
+[208/222] scripts/ux-keyboard-f2.spec.js:229:1 › F2 detects a safe save command in other module forms and active dialogs, never a posting button
243
+[209/222] scripts/workspace-access.spec.js:16:1 › Settings exposes existing organization members, invitations and capacities
244
+[210/222] scripts/workspace-access.spec.js:25:1 › Settings module chooser reaches organization and requests through real clicks
245
+[211/222] scripts/workspace-access.spec.js:34:1 › permission refresh removes organization management entry and stale footer access
246
+[212/222] scripts/workspace-access.spec.js:47:1 › global admin without organization authority cannot open organization manager
247
+[213/222] scripts/workspace-access.spec.js:56:1 › delegated organization configure manager retains invitations while module-only manager does not
248
+[214/222] scripts/workspace-access.spec.js:71:1 › accounting and treasury licenses retain their organization workspace without HR access
249
+[215/222] scripts/wp1-client-sync.spec.js:27:1 › versioned sync saves only after complete acknowledgement without login probe
250
+[216/222] scripts/wp1-client-sync.spec.js:35:61 › pending edits survive partial-ack with no success badge or reload
251
+[217/222] scripts/wp1-client-sync.spec.js:35:61 › pending edits survive conflict with no success badge or reload
252
+[218/222] scripts/wp1-client-sync.spec.js:35:61 › pending edits survive forbidden with no success badge or reload
253
+[219/222] scripts/wp1-client-sync.spec.js:46:1 › legacy schema remains usable with explicitly absent capability
254
+[220/222] scripts/wp1-client-sync.spec.js:58:1 › late response cannot acknowledge an old organization inside a new one
255
+[221/222] scripts/wp1-client-sync.spec.js:65:1 › same-user organization transition never sends the previous snapshot
256
+[222/222] scripts/wp1-client-sync.spec.js:77:1 › identity refresh during a save ends with an unconfirmed badge and retained edits
257
+ 222 passed (4.0m)
docs/wp1/evidence/client-sync/green.log
new
+51
@@ -0,0 +1,51 @@
1
+✔ confirmed absent server uses legacy columns and legacy sync (5.275319ms)
2
+✔ present capability loads versions and uses versioned sync acknowledgement (6.209853ms)
3
+✔ transport probe errors preserve pending edits without a legacy write (1.283953ms)
4
+✔ partial server with no row version fails before write (0.976547ms)
5
+✔ account switch during probe cannot send old edits (1.124251ms)
6
+✔ old-organization write acknowledgement cannot overwrite new snapshot (1.442282ms)
7
+✔ incomplete upsert acknowledgement cannot mark pending changes saved (1.300477ms)
8
+✔ incomplete delete acknowledgement cannot erase snapshot (1.65935ms)
9
+✔ missing V2 write RPC never silently downgrades to legacy write (1.707653ms)
10
+✔ new server capability requires fresh versions without discarding pending edits (1.680872ms)
11
+✔ organization wrapper uses same capability and versioned protocol (2.491458ms)
12
+✔ late read cannot publish across identity switch (org wrapper false) (1.54694ms)
13
+✔ CAS conflict preserves edits without reload or retry (org wrapper false) (0.969286ms)
14
+✔ late read cannot publish across identity switch (org wrapper true) (2.079555ms)
15
+✔ CAS conflict preserves edits without reload or retry (org wrapper true) (1.409622ms)
16
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":5},{"collection":"companies","id":"C","version":5}],"deletes":[]} (1.424595ms)
17
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":4}],"deletes":[]} (1.0839ms)
18
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":"5"}],"deletes":[]} (1.010799ms)
19
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"other","version":5}],"deletes":[]} (1.111581ms)
20
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":5}],"deletes":[{"collection":"companies","id":"C"}]} (1.373318ms)
21
+✔ malformed acknowledgement stays pending: null (1.124932ms)
22
+✔ positive version evidence prevents falling back when probe disappears (1.001064ms)
23
+✔ new record uses version zero and deletion acknowledges exact identity (1.365676ms)
24
+✔ edits made during write stay pending and use returned version on next batch (1.802596ms)
25
+✔ malformed guard mode cannot authorize a write (1.737909ms)
26
+✔ invalid persisted revision cannot downgrade to legacy: null (0.698116ms)
27
+✔ invalid persisted revision cannot downgrade to legacy: 0 (0.822524ms)
28
+✔ invalid persisted revision cannot downgrade to legacy: -1 (0.758578ms)
29
+✔ invalid persisted revision cannot downgrade to legacy: 1.5 (0.775903ms)
30
+✔ invalid persisted revision cannot downgrade to legacy: 4 (0.620598ms)
31
+✔ invalid persisted revision cannot downgrade to legacy: 9007199254740992 (0.936736ms)
32
+✔ late acknowledgement after same-tenant refresh cannot replace fresh revisions (1.219885ms)
33
+✔ nested edits during capability probe cannot mutate the captured write payload (0.942987ms)
34
+✔ stalled probe has a bounded failure and no late success (14.488526ms)
35
+✔ stalled write has a bounded failure and no late success (1.505397ms)
36
+✔ duplicate pending identifiers fail before any write (1.322811ms)
37
+✔ queued save resumes after stale tenant request releases sync lock (2.620704ms)
38
+✔ queued save resumes after stale identity request releases sync lock (1.340998ms)
39
+✔ same-context CAS rejection does not automatically retry queued edits (1.811521ms)
40
+✔ same user cannot dispatch old-organization edits while new organization is loading (2.125005ms)
41
+✔ direct same-user organization change cannot write before its own snapshot (0.883827ms)
42
+✔ identity refresh without queued save marks unconfirmed edits instead of endless saving (0.970858ms)
43
+✔ stale identity status preserves a newer save timer that has not fired (0.948965ms)
44
+ℹ tests 43
45
+ℹ suites 0
46
+ℹ pass 43
47
+ℹ fail 0
48
+ℹ cancelled 0
49
+ℹ skipped 0
50
+ℹ todo 0
51
+ℹ duration_ms 157.02843
docs/wp1/evidence/client-sync/identity-status-red.log
new
+71
@@ -0,0 +1,71 @@
1
+✔ confirmed absent server uses legacy columns and legacy sync (4.394814ms)
2
+✔ present capability loads versions and uses versioned sync acknowledgement (2.727583ms)
3
+✔ transport probe errors preserve pending edits without a legacy write (1.346986ms)
4
+✔ partial server with no row version fails before write (0.990697ms)
5
+✔ account switch during probe cannot send old edits (1.028555ms)
6
+✔ old-organization write acknowledgement cannot overwrite new snapshot (1.133083ms)
7
+✔ incomplete upsert acknowledgement cannot mark pending changes saved (1.414027ms)
8
+✔ incomplete delete acknowledgement cannot erase snapshot (1.392064ms)
9
+✔ missing V2 write RPC never silently downgrades to legacy write (1.205693ms)
10
+✔ new server capability requires fresh versions without discarding pending edits (0.98509ms)
11
+✔ organization wrapper uses same capability and versioned protocol (2.075978ms)
12
+✔ late read cannot publish across identity switch (org wrapper false) (0.97212ms)
13
+✔ CAS conflict preserves edits without reload or retry (org wrapper false) (1.139974ms)
14
+✔ late read cannot publish across identity switch (org wrapper true) (1.901765ms)
15
+✔ CAS conflict preserves edits without reload or retry (org wrapper true) (1.123518ms)
16
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":5},{"collection":"companies","id":"C","version":5}],"deletes":[]} (0.910196ms)
17
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":4}],"deletes":[]} (0.881002ms)
18
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":"5"}],"deletes":[]} (0.834261ms)
19
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"other","version":5}],"deletes":[]} (1.190119ms)
20
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":5}],"deletes":[{"collection":"companies","id":"C"}]} (0.889094ms)
21
+✔ malformed acknowledgement stays pending: null (0.702863ms)
22
+✔ positive version evidence prevents falling back when probe disappears (0.891057ms)
23
+✔ new record uses version zero and deletion acknowledges exact identity (1.024529ms)
24
+✔ edits made during write stay pending and use returned version on next batch (1.518706ms)
25
+✔ malformed guard mode cannot authorize a write (1.773071ms)
26
+✔ invalid persisted revision cannot downgrade to legacy: null (0.784716ms)
27
+✔ invalid persisted revision cannot downgrade to legacy: 0 (0.620228ms)
28
+✔ invalid persisted revision cannot downgrade to legacy: -1 (0.626427ms)
29
+✔ invalid persisted revision cannot downgrade to legacy: 1.5 (0.606778ms)
30
+✔ invalid persisted revision cannot downgrade to legacy: 4 (0.586807ms)
31
+✔ invalid persisted revision cannot downgrade to legacy: 9007199254740992 (0.644995ms)
32
+✔ late acknowledgement after same-tenant refresh cannot replace fresh revisions (0.987383ms)
33
+✔ nested edits during capability probe cannot mutate the captured write payload (0.915674ms)
34
+✔ stalled probe has a bounded failure and no late success (10.015741ms)
35
+✔ stalled write has a bounded failure and no late success (1.407267ms)
36
+✔ duplicate pending identifiers fail before any write (0.954412ms)
37
+✔ queued save resumes after stale tenant request releases sync lock (1.543123ms)
38
+✔ queued save resumes after stale identity request releases sync lock (1.121525ms)
39
+✔ same-context CAS rejection does not automatically retry queued edits (1.121585ms)
40
+✔ same user cannot dispatch old-organization edits while new organization is loading (1.536763ms)
41
+✔ direct same-user organization change cannot write before its own snapshot (0.83345ms)
42
+✖ identity refresh without queued save marks unconfirmed edits instead of endless saving (1.650695ms)
43
+ℹ tests 42
44
+ℹ suites 0
45
+ℹ pass 41
46
+ℹ fail 1
47
+ℹ cancelled 0
48
+ℹ skipped 0
49
+ℹ todo 0
50
+ℹ duration_ms 122.664264
51
+
52
+✖ failing tests:
53
+
54
+test at scripts/wp1-client-capability-test.mjs:175:1
55
+✖ identity refresh without queued save marks unconfirmed edits instead of endless saving (1.650695ms)
56
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
57
+ + actual - expected
58
+
59
+ + 'saving'
60
+ - 'conflict'
61
+
62
+ at TestContext.<anonymous> (file:///workspace/Factor-easy-wp1/scripts/wp1-client-capability-test.mjs:179:9)
63
+ at async Test.run (node:internal/test_runner/test:1389:7)
64
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
65
+ generatedMessage: true,
66
+ code: 'ERR_ASSERTION',
67
+ actual: 'saving',
68
+ expected: 'conflict',
69
+ operator: 'strictEqual',
70
+ diff: 'simple'
71
+ }
docs/wp1/evidence/client-sync/pages.log
new
+20
@@ -0,0 +1,20 @@
1
+
2
+Running 8 tests using 1 worker
3
+
4
+(node:34518) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
5
+(Use `node --trace-warnings ...` to show where the warning was created)
6
+
7
+
8
+(node:34518) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
9
+(Use `node --trace-warnings ...` to show where the warning was created)
10
+
11
+
12
+[1/8] scripts/wp1-client-sync.spec.js:27:1 › versioned sync saves only after complete acknowledgement without login probe
13
+[2/8] scripts/wp1-client-sync.spec.js:35:61 › pending edits survive partial-ack with no success badge or reload
14
+[3/8] scripts/wp1-client-sync.spec.js:35:61 › pending edits survive conflict with no success badge or reload
15
+[4/8] scripts/wp1-client-sync.spec.js:35:61 › pending edits survive forbidden with no success badge or reload
16
+[5/8] scripts/wp1-client-sync.spec.js:46:1 › legacy schema remains usable with explicitly absent capability
17
+[6/8] scripts/wp1-client-sync.spec.js:58:1 › late response cannot acknowledge an old organization inside a new one
18
+[7/8] scripts/wp1-client-sync.spec.js:65:1 › same-user organization transition never sends the previous snapshot
19
+[8/8] scripts/wp1-client-sync.spec.js:77:1 › identity refresh during a save ends with an unconfirmed badge and retained edits
20
+ 8 passed (4.3s)
docs/wp1/evidence/client-sync/red.log
new
+554
@@ -0,0 +1,554 @@
1
+✔ confirmed absent server uses legacy columns and legacy sync (6.188932ms)
2
+✖ present capability loads versions and uses versioned sync acknowledgement (2.496987ms)
3
+✖ transport probe errors preserve pending edits without a legacy write (3.925348ms)
4
+✔ partial server with no row version fails before write (2.665652ms)
5
+✔ account switch during probe cannot send old edits (1.430804ms)
6
+✖ old-organization write acknowledgement cannot overwrite new snapshot (2.454182ms)
7
+✖ incomplete upsert acknowledgement cannot mark pending changes saved (1.53984ms)
8
+✖ incomplete delete acknowledgement cannot erase snapshot (2.563267ms)
9
+✖ missing V2 write RPC never silently downgrades to legacy write (4.121174ms)
10
+✔ new server capability requires fresh versions without discarding pending edits (1.456193ms)
11
+✖ organization wrapper uses same capability and versioned protocol (2.537759ms)
12
+✖ late read cannot publish across identity switch (org wrapper false) (1.298975ms)
13
+✖ CAS conflict preserves edits without reload or retry (org wrapper false) (1.820404ms)
14
+✔ late read cannot publish across identity switch (org wrapper true) (1.446287ms)
15
+✖ CAS conflict preserves edits without reload or retry (org wrapper true) (2.764041ms)
16
+✖ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":5},{"collection":"companies","id":"C","version":5}],"deletes":[]} (32.789969ms)
17
+✖ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":4}],"deletes":[]} (3.642169ms)
18
+✖ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":"5"}],"deletes":[]} (1.28224ms)
19
+✖ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"other","version":5}],"deletes":[]} (1.402131ms)
20
+✖ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":5}],"deletes":[{"collection":"companies","id":"C"}]} (2.944283ms)
21
+✖ malformed acknowledgement stays pending: null (3.483209ms)
22
+✖ positive version evidence prevents falling back when probe disappears (1.485246ms)
23
+✖ new record uses version zero and deletion acknowledges exact identity (1.851781ms)
24
+✖ edits made during write stay pending and use returned version on next batch (4.408979ms)
25
+✖ malformed guard mode cannot authorize a write (2.408313ms)
26
+✖ invalid persisted revision cannot downgrade to legacy: null (0.893141ms)
27
+✖ invalid persisted revision cannot downgrade to legacy: 0 (3.030905ms)
28
+✖ invalid persisted revision cannot downgrade to legacy: -1 (0.855163ms)
29
+✖ invalid persisted revision cannot downgrade to legacy: 1.5 (2.075349ms)
30
+✖ invalid persisted revision cannot downgrade to legacy: 4 (0.948805ms)
31
+✖ invalid persisted revision cannot downgrade to legacy: 9007199254740992 (2.401342ms)
32
+✖ late acknowledgement after same-tenant refresh cannot replace fresh revisions (0.966582ms)
33
+✖ nested edits during capability probe cannot mutate the captured write payload (1.320588ms)
34
+✖ stalled probe has a bounded failure and no late success (1.015736ms)
35
+✖ stalled write has a bounded failure and no late success (0.981394ms)
36
+✖ duplicate pending identifiers fail before any write (1.059693ms)
37
+ℹ tests 36
38
+ℹ suites 0
39
+ℹ pass 5
40
+ℹ fail 31
41
+ℹ cancelled 0
42
+ℹ skipped 0
43
+ℹ todo 0
44
+ℹ duration_ms 290.816091
45
+
46
+✖ failing tests:
47
+
48
+test at scripts/wp1-client-capability-test.mjs:32:1
49
+✖ present capability loads versions and uses versioned sync acknowledgement (2.496987ms)
50
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
51
+ + actual - expected
52
+
53
+ + 'collection,id,data'
54
+ - '*'
55
+
56
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:33:47)
57
+ at async Test.run (node:internal/test_runner/test:1389:7)
58
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
59
+ generatedMessage: true,
60
+ code: 'ERR_ASSERTION',
61
+ actual: 'collection,id,data',
62
+ expected: '*',
63
+ operator: 'strictEqual',
64
+ diff: 'simple'
65
+ }
66
+
67
+test at scripts/wp1-client-capability-test.mjs:37:1
68
+✖ transport probe errors preserve pending edits without a legacy write (3.925348ms)
69
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
70
+
71
+ 0 !== 1
72
+
73
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:39:106)
74
+ at async Test.run (node:internal/test_runner/test:1389:7)
75
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
76
+ generatedMessage: true,
77
+ code: 'ERR_ASSERTION',
78
+ actual: 0,
79
+ expected: 1,
80
+ operator: 'strictEqual',
81
+ diff: 'simple'
82
+ }
83
+
84
+test at scripts/wp1-client-capability-test.mjs:47:1
85
+✖ old-organization write acknowledgement cannot overwrite new snapshot (2.454182ms)
86
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
87
+ + actual - expected
88
+
89
+ + undefined
90
+ - 'new-tenant'
91
+
92
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:50:91)
93
+ at async Test.run (node:internal/test_runner/test:1389:7)
94
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
95
+ generatedMessage: true,
96
+ code: 'ERR_ASSERTION',
97
+ actual: undefined,
98
+ expected: 'new-tenant',
99
+ operator: 'strictEqual',
100
+ diff: 'simple'
101
+ }
102
+
103
+test at scripts/wp1-client-capability-test.mjs:52:1
104
+✖ incomplete upsert acknowledgement cannot mark pending changes saved (1.53984ms)
105
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
106
+ + actual - expected
107
+
108
+ + 'changed'
109
+ - 'before'
110
+
111
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:54:9)
112
+ at async Test.run (node:internal/test_runner/test:1389:7)
113
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
114
+ generatedMessage: true,
115
+ code: 'ERR_ASSERTION',
116
+ actual: 'changed',
117
+ expected: 'before',
118
+ operator: 'strictEqual',
119
+ diff: 'simple'
120
+ }
121
+
122
+test at scripts/wp1-client-capability-test.mjs:56:1
123
+✖ incomplete delete acknowledgement cannot erase snapshot (2.563267ms)
124
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
125
+
126
+ false !== true
127
+
128
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:57:140)
129
+ at async Test.run (node:internal/test_runner/test:1389:7)
130
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
131
+ generatedMessage: true,
132
+ code: 'ERR_ASSERTION',
133
+ actual: false,
134
+ expected: true,
135
+ operator: 'strictEqual',
136
+ diff: 'simple'
137
+ }
138
+
139
+test at scripts/wp1-client-capability-test.mjs:59:1
140
+✖ missing V2 write RPC never silently downgrades to legacy write (4.121174ms)
141
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
142
+
143
+ 1 !== 0
144
+
145
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:61:9)
146
+ at async Test.run (node:internal/test_runner/test:1389:7)
147
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
148
+ generatedMessage: true,
149
+ code: 'ERR_ASSERTION',
150
+ actual: 1,
151
+ expected: 0,
152
+ operator: 'strictEqual',
153
+ diff: 'simple'
154
+ }
155
+
156
+test at scripts/wp1-client-capability-test.mjs:67:1
157
+✖ organization wrapper uses same capability and versioned protocol (2.537759ms)
158
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
159
+ + actual - expected
160
+
161
+ + 'collection,id,data,owner_id,organization_id'
162
+ - '*'
163
+
164
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:68:64)
165
+ at async Test.run (node:internal/test_runner/test:1389:7)
166
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
167
+ generatedMessage: true,
168
+ code: 'ERR_ASSERTION',
169
+ actual: 'collection,id,data,owner_id,organization_id',
170
+ expected: '*',
171
+ operator: 'strictEqual',
172
+ diff: 'simple'
173
+ }
174
+
175
+test at scripts/wp1-client-capability-test.mjs:73:2
176
+✖ late read cannot publish across identity switch (org wrapper false) (1.298975ms)
177
+ AssertionError [ERR_ASSERTION]: Missing expected rejection.
178
+ at async TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:74:99)
179
+ at async Test.run (node:internal/test_runner/test:1389:7)
180
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
181
+ generatedMessage: false,
182
+ code: 'ERR_ASSERTION',
183
+ actual: undefined,
184
+ expected: undefined,
185
+ operator: 'rejects',
186
+ diff: 'simple'
187
+ }
188
+
189
+test at scripts/wp1-client-capability-test.mjs:76:2
190
+✖ CAS conflict preserves edits without reload or retry (org wrapper false) (1.820404ms)
191
+ evalmachine.<anonymous>:1
192
+ versionSnap.get('companies|C')
193
+ ^
194
+
195
+ ReferenceError: versionSnap is not defined
196
+ at evalmachine.<anonymous>:1:1
197
+ at Script.runInContext (node:vm:149:12)
198
+ at Object.runInContext (node:vm:301:6)
199
+ at Object.evalCode (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:25:23)
200
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:78:160)
201
+ at async Test.run (node:internal/test_runner/test:1389:7)
202
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7)
203
+
204
+test at scripts/wp1-client-capability-test.mjs:76:2
205
+✖ CAS conflict preserves edits without reload or retry (org wrapper true) (2.764041ms)
206
+ evalmachine.<anonymous>:1
207
+ versionSnap.get('companies|C')
208
+ ^
209
+
210
+ ReferenceError: versionSnap is not defined
211
+ at evalmachine.<anonymous>:1:1
212
+ at Script.runInContext (node:vm:149:12)
213
+ at Object.runInContext (node:vm:301:6)
214
+ at Object.evalCode (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:25:23)
215
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:78:160)
216
+ at async Test.run (node:internal/test_runner/test:1389:7)
217
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7)
218
+
219
+test at scripts/wp1-client-capability-test.mjs:88:3
220
+✖ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":5},{"collection":"companies","id":"C","version":5}],"deletes":[]} (32.789969ms)
221
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
222
+
223
+ 0 !== 1
224
+
225
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:90:9)
226
+ at async Test.run (node:internal/test_runner/test:1389:7)
227
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
228
+ generatedMessage: true,
229
+ code: 'ERR_ASSERTION',
230
+ actual: 0,
231
+ expected: 1,
232
+ operator: 'strictEqual',
233
+ diff: 'simple'
234
+ }
235
+
236
+test at scripts/wp1-client-capability-test.mjs:88:3
237
+✖ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":4}],"deletes":[]} (3.642169ms)
238
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
239
+
240
+ 0 !== 1
241
+
242
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:90:9)
243
+ at async Test.run (node:internal/test_runner/test:1389:7)
244
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
245
+ generatedMessage: true,
246
+ code: 'ERR_ASSERTION',
247
+ actual: 0,
248
+ expected: 1,
249
+ operator: 'strictEqual',
250
+ diff: 'simple'
251
+ }
252
+
253
+test at scripts/wp1-client-capability-test.mjs:88:3
254
+✖ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":"5"}],"deletes":[]} (1.28224ms)
255
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
256
+
257
+ 0 !== 1
258
+
259
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:90:9)
260
+ at async Test.run (node:internal/test_runner/test:1389:7)
261
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
262
+ generatedMessage: true,
263
+ code: 'ERR_ASSERTION',
264
+ actual: 0,
265
+ expected: 1,
266
+ operator: 'strictEqual',
267
+ diff: 'simple'
268
+ }
269
+
270
+test at scripts/wp1-client-capability-test.mjs:88:3
271
+✖ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"other","version":5}],"deletes":[]} (1.402131ms)
272
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
273
+
274
+ 0 !== 1
275
+
276
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:90:9)
277
+ at async Test.run (node:internal/test_runner/test:1389:7)
278
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
279
+ generatedMessage: true,
280
+ code: 'ERR_ASSERTION',
281
+ actual: 0,
282
+ expected: 1,
283
+ operator: 'strictEqual',
284
+ diff: 'simple'
285
+ }
286
+
287
+test at scripts/wp1-client-capability-test.mjs:88:3
288
+✖ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":5}],"deletes":[{"collection":"companies","id":"C"}]} (2.944283ms)
289
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
290
+
291
+ 0 !== 1
292
+
293
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:90:9)
294
+ at async Test.run (node:internal/test_runner/test:1389:7)
295
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
296
+ generatedMessage: true,
297
+ code: 'ERR_ASSERTION',
298
+ actual: 0,
299
+ expected: 1,
300
+ operator: 'strictEqual',
301
+ diff: 'simple'
302
+ }
303
+
304
+test at scripts/wp1-client-capability-test.mjs:88:3
305
+✖ malformed acknowledgement stays pending: null (3.483209ms)
306
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
307
+
308
+ 0 !== 1
309
+
310
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:90:9)
311
+ at async Test.run (node:internal/test_runner/test:1389:7)
312
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
313
+ generatedMessage: true,
314
+ code: 'ERR_ASSERTION',
315
+ actual: 0,
316
+ expected: 1,
317
+ operator: 'strictEqual',
318
+ diff: 'simple'
319
+ }
320
+
321
+test at scripts/wp1-client-capability-test.mjs:92:1
322
+✖ positive version evidence prevents falling back when probe disappears (1.485246ms)
323
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
324
+
325
+ 1 !== 0
326
+
327
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:93:133)
328
+ at async Test.run (node:internal/test_runner/test:1389:7)
329
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
330
+ generatedMessage: true,
331
+ code: 'ERR_ASSERTION',
332
+ actual: 1,
333
+ expected: 0,
334
+ operator: 'strictEqual',
335
+ diff: 'simple'
336
+ }
337
+
338
+test at scripts/wp1-client-capability-test.mjs:95:1
339
+✖ new record uses version zero and deletion acknowledges exact identity (1.851781ms)
340
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
341
+
342
+ undefined !== 0
343
+
344
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:97:40)
345
+ at async Test.run (node:internal/test_runner/test:1389:7)
346
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
347
+ generatedMessage: true,
348
+ code: 'ERR_ASSERTION',
349
+ actual: undefined,
350
+ expected: 0,
351
+ operator: 'strictEqual',
352
+ diff: 'simple'
353
+ }
354
+
355
+test at scripts/wp1-client-capability-test.mjs:100:1
356
+✖ edits made during write stay pending and use returned version on next batch (4.408979ms)
357
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
358
+
359
+ 0 !== 2
360
+
361
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:102:75)
362
+ at async Test.run (node:internal/test_runner/test:1389:7)
363
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
364
+ generatedMessage: true,
365
+ code: 'ERR_ASSERTION',
366
+ actual: 0,
367
+ expected: 2,
368
+ operator: 'strictEqual',
369
+ diff: 'simple'
370
+ }
371
+
372
+test at scripts/wp1-client-capability-test.mjs:104:1
373
+✖ malformed guard mode cannot authorize a write (2.408313ms)
374
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
375
+
376
+ false !== true
377
+
378
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:105:161)
379
+ at async Test.run (node:internal/test_runner/test:1389:7)
380
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
381
+ generatedMessage: true,
382
+ code: 'ERR_ASSERTION',
383
+ actual: false,
384
+ expected: true,
385
+ operator: 'strictEqual',
386
+ diff: 'simple'
387
+ }
388
+
389
+test at scripts/wp1-client-capability-test.mjs:107:68
390
+✖ invalid persisted revision cannot downgrade to legacy: null (0.893141ms)
391
+ AssertionError [ERR_ASSERTION]: Missing expected rejection.
392
+ at async TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:108:66)
393
+ at async Test.run (node:internal/test_runner/test:1389:7)
394
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
395
+ generatedMessage: false,
396
+ code: 'ERR_ASSERTION',
397
+ actual: undefined,
398
+ expected: undefined,
399
+ operator: 'rejects',
400
+ diff: 'simple'
401
+ }
402
+
403
+test at scripts/wp1-client-capability-test.mjs:107:68
404
+✖ invalid persisted revision cannot downgrade to legacy: 0 (3.030905ms)
405
+ AssertionError [ERR_ASSERTION]: Missing expected rejection.
406
+ at async TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:108:66)
407
+ at async Test.run (node:internal/test_runner/test:1389:7)
408
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
409
+ generatedMessage: false,
410
+ code: 'ERR_ASSERTION',
411
+ actual: undefined,
412
+ expected: undefined,
413
+ operator: 'rejects',
414
+ diff: 'simple'
415
+ }
416
+
417
+test at scripts/wp1-client-capability-test.mjs:107:68
418
+✖ invalid persisted revision cannot downgrade to legacy: -1 (0.855163ms)
419
+ AssertionError [ERR_ASSERTION]: Missing expected rejection.
420
+ at async TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:108:66)
421
+ at async Test.run (node:internal/test_runner/test:1389:7)
422
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
423
+ generatedMessage: false,
424
+ code: 'ERR_ASSERTION',
425
+ actual: undefined,
426
+ expected: undefined,
427
+ operator: 'rejects',
428
+ diff: 'simple'
429
+ }
430
+
431
+test at scripts/wp1-client-capability-test.mjs:107:68
432
+✖ invalid persisted revision cannot downgrade to legacy: 1.5 (2.075349ms)
433
+ AssertionError [ERR_ASSERTION]: Missing expected rejection.
434
+ at async TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:108:66)
435
+ at async Test.run (node:internal/test_runner/test:1389:7)
436
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
437
+ generatedMessage: false,
438
+ code: 'ERR_ASSERTION',
439
+ actual: undefined,
440
+ expected: undefined,
441
+ operator: 'rejects',
442
+ diff: 'simple'
443
+ }
444
+
445
+test at scripts/wp1-client-capability-test.mjs:107:68
446
+✖ invalid persisted revision cannot downgrade to legacy: 4 (0.948805ms)
447
+ AssertionError [ERR_ASSERTION]: Missing expected rejection.
448
+ at async TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:108:66)
449
+ at async Test.run (node:internal/test_runner/test:1389:7)
450
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
451
+ generatedMessage: false,
452
+ code: 'ERR_ASSERTION',
453
+ actual: undefined,
454
+ expected: undefined,
455
+ operator: 'rejects',
456
+ diff: 'simple'
457
+ }
458
+
459
+test at scripts/wp1-client-capability-test.mjs:107:68
460
+✖ invalid persisted revision cannot downgrade to legacy: 9007199254740992 (2.401342ms)
461
+ AssertionError [ERR_ASSERTION]: Missing expected rejection.
462
+ at async TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:108:66)
463
+ at async Test.run (node:internal/test_runner/test:1389:7)
464
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
465
+ generatedMessage: false,
466
+ code: 'ERR_ASSERTION',
467
+ actual: undefined,
468
+ expected: undefined,
469
+ operator: 'rejects',
470
+ diff: 'simple'
471
+ }
472
+
473
+test at scripts/wp1-client-capability-test.mjs:110:1
474
+✖ late acknowledgement after same-tenant refresh cannot replace fresh revisions (0.966582ms)
475
+ evalmachine.<anonymous>:1
476
+ versionSnap.get('companies|C')
477
+ ^
478
+
479
+ ReferenceError: versionSnap is not defined
480
+ at evalmachine.<anonymous>:1:1
481
+ at Script.runInContext (node:vm:149:12)
482
+ at Object.runInContext (node:vm:301:6)
483
+ at Object.evalCode (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:25:23)
484
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:113:17)
485
+ at async Test.run (node:internal/test_runner/test:1389:7)
486
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7)
487
+
488
+test at scripts/wp1-client-capability-test.mjs:115:1
489
+✖ nested edits during capability probe cannot mutate the captured write payload (1.320588ms)
490
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
491
+
492
+ 0 !== 2
493
+
494
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:118:75)
495
+ at async Test.run (node:internal/test_runner/test:1389:7)
496
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
497
+ generatedMessage: true,
498
+ code: 'ERR_ASSERTION',
499
+ actual: 0,
500
+ expected: 2,
501
+ operator: 'strictEqual',
502
+ diff: 'simple'
503
+ }
504
+
505
+test at scripts/wp1-client-capability-test.mjs:120:38
506
+✖ stalled probe has a bounded failure and no late success (1.015736ms)
507
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
508
+
509
+ false !== true
510
+
511
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:126:29)
512
+ at async Test.run (node:internal/test_runner/test:1389:7)
513
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
514
+ generatedMessage: true,
515
+ code: 'ERR_ASSERTION',
516
+ actual: false,
517
+ expected: true,
518
+ operator: 'strictEqual',
519
+ diff: 'simple'
520
+ }
521
+
522
+test at scripts/wp1-client-capability-test.mjs:120:38
523
+✖ stalled write has a bounded failure and no late success (0.981394ms)
524
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
525
+
526
+ false !== true
527
+
528
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:126:29)
529
+ at async Test.run (node:internal/test_runner/test:1389:7)
530
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
531
+ generatedMessage: true,
532
+ code: 'ERR_ASSERTION',
533
+ actual: false,
534
+ expected: true,
535
+ operator: 'strictEqual',
536
+ diff: 'simple'
537
+ }
538
+
539
+test at scripts/wp1-client-capability-test.mjs:130:1
540
+✖ duplicate pending identifiers fail before any write (1.059693ms)
541
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
542
+
543
+ 5 !== 1
544
+
545
+ at TestContext.<anonymous> (file:///workspace/wp1-client-baseline/scripts/wp1-client-capability-test.mjs:131:187)
546
+ at async Test.run (node:internal/test_runner/test:1389:7)
547
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
548
+ generatedMessage: true,
549
+ code: 'ERR_ASSERTION',
550
+ actual: 5,
551
+ expected: 1,
552
+ operator: 'strictEqual',
553
+ diff: 'simple'
554
+ }
docs/wp1/evidence/client-sync/result.json
new
+26
@@ -0,0 +1,26 @@
1
+{
2
+ "recorded_at": "2026-11-04T02:08:04.757577+00:00",
3
+ "base_commit": "799cff4fcb1b9a98f763baf9e79a030c099deb58",
4
+ "node_tests": 43,
5
+ "browser_tests": 222,
6
+ "generated_pages_tests": 8,
7
+ "quality_commands": 55,
8
+ "c8_repeat_cases": 30,
9
+ "status": "PASS_LOCAL",
10
+ "source_sha256": {
11
+ "js/sync.js": "7149bbeddf45f7938ad62a1c13b9916a8ffc3a71da80edac755484d26b8d39d4",
12
+ "js/organization-rbac.js": "a96b75d13390ad2305b6ccb2bf6574b6ab891b87cac2961536e4e15bcc328e3a",
13
+ "js/bootstrap.js": "937d822dd39ea81f58a07c8399f039cc6efe20658a18cc662fd3ef8997449416",
14
+ "index.html": "788c0eba3dc93a56f24148a15991744526bcbd776fc6b01680b500e3b06985ea",
15
+ "scripts/wp1-client-capability-test.mjs": "7288920686e2afc074e02c18171fb49b1968bcd3a67194f0b57ffe1cc52106d4",
16
+ "scripts/wp1-client-sync.spec.js": "7b1e5801e85fc95c57e405a8fc7348fc2e83943d1cf22f7b57e4ae721f9057f9",
17
+ "scripts/office-slice-c8.spec.js": "27eafaa3f04f17b66960a47394c3151e09f490a3d079fc2f1996f1eba0412f49"
18
+ },
19
+ "limits": [
20
+ "Synthetic services and disposable fixtures only",
21
+ "Node24 locally; Node22 in CI",
22
+ "Process-only system fontconfig workaround",
23
+ "Fresh published client CI pending",
24
+ "No production changes; WP1 remains incomplete"
25
+ ]
26
+}
docs/wp1/evidence/client-sync/scheduler-red.log
new
+83
@@ -0,0 +1,83 @@
1
+✔ confirmed absent server uses legacy columns and legacy sync (5.258615ms)
2
+✔ present capability loads versions and uses versioned sync acknowledgement (3.123115ms)
3
+✔ transport probe errors preserve pending edits without a legacy write (1.697478ms)
4
+✔ partial server with no row version fails before write (1.450815ms)
5
+✔ account switch during probe cannot send old edits (1.253206ms)
6
+✔ old-organization write acknowledgement cannot overwrite new snapshot (1.366007ms)
7
+✔ incomplete upsert acknowledgement cannot mark pending changes saved (1.238113ms)
8
+✔ incomplete delete acknowledgement cannot erase snapshot (0.923457ms)
9
+✔ missing V2 write RPC never silently downgrades to legacy write (1.288279ms)
10
+✔ new server capability requires fresh versions without discarding pending edits (1.435361ms)
11
+✔ organization wrapper uses same capability and versioned protocol (2.879437ms)
12
+✔ late read cannot publish across identity switch (org wrapper false) (1.416343ms)
13
+✔ CAS conflict preserves edits without reload or retry (org wrapper false) (0.92536ms)
14
+✔ late read cannot publish across identity switch (org wrapper true) (1.403163ms)
15
+✔ CAS conflict preserves edits without reload or retry (org wrapper true) (2.086667ms)
16
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":5},{"collection":"companies","id":"C","version":5}],"deletes":[]} (1.010298ms)
17
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":4}],"deletes":[]} (1.098091ms)
18
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":"5"}],"deletes":[]} (0.903187ms)
19
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"other","version":5}],"deletes":[]} (0.950017ms)
20
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":5}],"deletes":[{"collection":"companies","id":"C"}]} (1.073304ms)
21
+✔ malformed acknowledgement stays pending: null (0.891118ms)
22
+✔ positive version evidence prevents falling back when probe disappears (1.089017ms)
23
+✔ new record uses version zero and deletion acknowledges exact identity (1.986445ms)
24
+✔ edits made during write stay pending and use returned version on next batch (1.060935ms)
25
+✔ malformed guard mode cannot authorize a write (0.829164ms)
26
+✔ invalid persisted revision cannot downgrade to legacy: null (1.545188ms)
27
+✔ invalid persisted revision cannot downgrade to legacy: 0 (0.603604ms)
28
+✔ invalid persisted revision cannot downgrade to legacy: -1 (0.7536ms)
29
+✔ invalid persisted revision cannot downgrade to legacy: 1.5 (0.62087ms)
30
+✔ invalid persisted revision cannot downgrade to legacy: 4 (0.569111ms)
31
+✔ invalid persisted revision cannot downgrade to legacy: 9007199254740992 (0.675813ms)
32
+✔ late acknowledgement after same-tenant refresh cannot replace fresh revisions (0.921715ms)
33
+✔ nested edits during capability probe cannot mutate the captured write payload (0.997509ms)
34
+✔ stalled probe has a bounded failure and no late success (16.932747ms)
35
+✔ stalled write has a bounded failure and no late success (1.567001ms)
36
+✔ duplicate pending identifiers fail before any write (1.438246ms)
37
+✖ queued save resumes after stale tenant request releases sync lock (2.337316ms)
38
+✖ queued save resumes after stale identity request releases sync lock (1.362721ms)
39
+✔ same-context CAS rejection does not automatically retry queued edits (0.994705ms)
40
+ℹ tests 39
41
+ℹ suites 0
42
+ℹ pass 37
43
+ℹ fail 2
44
+ℹ cancelled 0
45
+ℹ skipped 0
46
+ℹ todo 0
47
+ℹ duration_ms 137.045648
48
+
49
+✖ failing tests:
50
+
51
+test at scripts/wp1-client-capability-test.mjs:133:43
52
+✖ queued save resumes after stale tenant request releases sync lock (2.337316ms)
53
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
54
+
55
+ 0 !== 1
56
+
57
+ at TestContext.<anonymous> (file:///workspace/Factor-easy-wp1/scripts/wp1-client-capability-test.mjs:146:54)
58
+ at async Test.run (node:internal/test_runner/test:1389:7)
59
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
60
+ generatedMessage: true,
61
+ code: 'ERR_ASSERTION',
62
+ actual: 0,
63
+ expected: 1,
64
+ operator: 'strictEqual',
65
+ diff: 'simple'
66
+ }
67
+
68
+test at scripts/wp1-client-capability-test.mjs:133:43
69
+✖ queued save resumes after stale identity request releases sync lock (1.362721ms)
70
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
71
+
72
+ 0 !== 1
73
+
74
+ at TestContext.<anonymous> (file:///workspace/Factor-easy-wp1/scripts/wp1-client-capability-test.mjs:146:54)
75
+ at async Test.run (node:internal/test_runner/test:1389:7)
76
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
77
+ generatedMessage: true,
78
+ code: 'ERR_ASSERTION',
79
+ actual: 0,
80
+ expected: 1,
81
+ operator: 'strictEqual',
82
+ diff: 'simple'
83
+ }
docs/wp1/evidence/client-sync/static.log
new
+365
@@ -0,0 +1,365 @@
1
+Migration archive manifest and known drift
2
+PASS committed archive manifest: 94 files; body hashes verified.
3
+UNRECONCILED migration ledger: 24 production-only / 36 repository-only versions. This is NOT schema parity or deployment approval.
4
+Migration manifest mutation tests
5
+PASS manifest mutations: changed body, missing file, added file, new production version rejected; known drift remains explicit.
6
+Purchase correction server-mode guards
7
+PASS purchase correction/cancel guards: enforce, transport, malformed mode, changed identity reject before mutation; off/audit/missing RPC retain legacy path.
8
+Versioned sync compatibility and pending-edit protection
9
+✔ confirmed absent server uses legacy columns and legacy sync (6.725055ms)
10
+✔ present capability loads versions and uses versioned sync acknowledgement (5.858314ms)
11
+✔ transport probe errors preserve pending edits without a legacy write (1.542193ms)
12
+✔ partial server with no row version fails before write (1.484797ms)
13
+✔ account switch during probe cannot send old edits (1.313938ms)
14
+✔ old-organization write acknowledgement cannot overwrite new snapshot (1.361951ms)
15
+✔ incomplete upsert acknowledgement cannot mark pending changes saved (4.909859ms)
16
+✔ incomplete delete acknowledgement cannot erase snapshot (1.33524ms)
17
+✔ missing V2 write RPC never silently downgrades to legacy write (1.288128ms)
18
+✔ new server capability requires fresh versions without discarding pending edits (0.953442ms)
19
+✔ organization wrapper uses same capability and versioned protocol (2.301181ms)
20
+✔ late read cannot publish across identity switch (org wrapper false) (1.067485ms)
21
+✔ CAS conflict preserves edits without reload or retry (org wrapper false) (0.981324ms)
22
+✔ late read cannot publish across identity switch (org wrapper true) (1.659802ms)
23
+✔ CAS conflict preserves edits without reload or retry (org wrapper true) (1.069298ms)
24
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":5},{"collection":"companies","id":"C","version":5}],"deletes":[]} (0.868514ms)
25
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":4}],"deletes":[]} (1.028927ms)
26
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":"5"}],"deletes":[]} (1.527911ms)
27
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"other","version":5}],"deletes":[]} (1.423694ms)
28
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":5}],"deletes":[{"collection":"companies","id":"C"}]} (1.06431ms)
29
+✔ malformed acknowledgement stays pending: null (0.76033ms)
30
+✔ positive version evidence prevents falling back when probe disappears (3.242636ms)
31
+✔ new record uses version zero and deletion acknowledges exact identity (1.049568ms)
32
+✔ edits made during write stay pending and use returned version on next batch (1.477435ms)
33
+✔ malformed guard mode cannot authorize a write (2.588006ms)
34
+✔ invalid persisted revision cannot downgrade to legacy: null (0.810567ms)
35
+✔ invalid persisted revision cannot downgrade to legacy: 0 (0.692708ms)
36
+✔ invalid persisted revision cannot downgrade to legacy: -1 (1.135338ms)
37
+✔ invalid persisted revision cannot downgrade to legacy: 1.5 (0.86588ms)
38
+✔ invalid persisted revision cannot downgrade to legacy: 4 (0.570253ms)
39
+✔ invalid persisted revision cannot downgrade to legacy: 9007199254740992 (0.744015ms)
40
+✔ late acknowledgement after same-tenant refresh cannot replace fresh revisions (1.300818ms)
41
+✔ nested edits during capability probe cannot mutate the captured write payload (1.199254ms)
42
+✔ stalled probe has a bounded failure and no late success (18.109028ms)
43
+✔ stalled write has a bounded failure and no late success (2.39246ms)
44
+✔ duplicate pending identifiers fail before any write (1.309441ms)
45
+✔ queued save resumes after stale tenant request releases sync lock (1.604557ms)
46
+✔ queued save resumes after stale identity request releases sync lock (1.471135ms)
47
+✔ same-context CAS rejection does not automatically retry queued edits (1.385206ms)
48
+✔ same user cannot dispatch old-organization edits while new organization is loading (4.116357ms)
49
+✔ direct same-user organization change cannot write before its own snapshot (0.873571ms)
50
+✔ identity refresh without queued save marks unconfirmed edits instead of endless saving (0.954033ms)
51
+✔ stale identity status preserves a newer save timer that has not fired (1.082849ms)
52
+ℹ tests 43
53
+ℹ suites 0
54
+ℹ pass 43
55
+ℹ fail 0
56
+ℹ cancelled 0
57
+ℹ skipped 0
58
+ℹ todo 0
59
+ℹ duration_ms 169.825908
60
+JavaScript syntax
61
+syntax ok: accounting-foundation-render.js
62
+syntax ok: accounting-foundation-ui.js
63
+syntax ok: accounting-foundation.js
64
+syntax ok: accounting.js
65
+syntax ok: admin.js
66
+syntax ok: backup.js
67
+syntax ok: bootstrap.js
68
+syntax ok: cheques.js
69
+syntax ok: commercial-rnd.js
70
+syntax ok: companies.js
71
+syntax ok: contacts.js
72
+syntax ok: context-help.js
73
+syntax ok: core.js
74
+syntax ok: document-management.js
75
+syntax ok: drilldown.js
76
+syntax ok: enterprise-iran-v2.js
77
+syntax ok: enterprise-iran.js
78
+syntax ok: expenses.js
79
+syntax ok: idle-and-reports.js
80
+syntax ok: invoice-excel-import.js
81
+syntax ok: invoices.js
82
+syntax ok: journal-engine.js
83
+syntax ok: journal-ui.js
84
+syntax ok: login-connectivity.js
85
+syntax ok: money-format.js
86
+syntax ok: office-automation.js
87
+syntax ok: office-mature.js
88
+syntax ok: office-rbac.js
89
+syntax ok: office-workflow.js
90
+syntax ok: operations.js
91
+syntax ok: organization-enterprise-ux.js
92
+syntax ok: organization-invitations.js
93
+syntax ok: organization-rbac.js
94
+syntax ok: organization-shell.js
95
+syntax ok: password-recovery.js
96
+syntax ok: patches.js
97
+syntax ok: payments.js
98
+syntax ok: phase4-contracting.js
99
+syntax ok: phase5-domain.js
100
+syntax ok: phase5-enterprise.js
101
+syntax ok: phase6-reporting.js
102
+syntax ok: platform-modules.js
103
+syntax ok: print.js
104
+syntax ok: products.js
105
+syntax ok: projects.js
106
+syntax ok: purchases.js
107
+syntax ok: request-workflow-d2.js
108
+syntax ok: request-workflow-d3b.js
109
+syntax ok: request-workflow-d3c.js
110
+syntax ok: request-workflow-d4a.js
111
+syntax ok: selfcheck.js
112
+syntax ok: sync.js
113
+syntax ok: taxpayer-print.js
114
+syntax ok: ui.js
115
+syntax ok: ux-hardening-r2.js
116
+syntax ok: words.js
117
+syntax ok: scripts/accounting-p0-check.mjs
118
+syntax ok: scripts/accounting-product-guidance-check.mjs
119
+syntax ok: scripts/admin-provisioning-contract.mjs
120
+syntax ok: scripts/admin-recovery-handler.spec.mjs
121
+syntax ok: scripts/branding-login-check.mjs
122
+syntax ok: scripts/build-pages.mjs
123
+syntax ok: scripts/chart-completeness-check.mjs
124
+syntax ok: scripts/commercial-rnd-check.mjs
125
+syntax ok: scripts/enterprise-behavior-check.mjs
126
+syntax ok: scripts/enterprise-invitation-check.mjs
127
+syntax ok: scripts/enterprise-license-check.mjs
128
+syntax ok: scripts/enterprise-org-ux-check.mjs
129
+syntax ok: scripts/enterprise-role-check.mjs
130
+syntax ok: scripts/finance-integrity-audit-test.mjs
131
+syntax ok: scripts/finance-integrity-audit.mjs
132
+syntax ok: scripts/golden-accounting-core-check.mjs
133
+syntax ok: scripts/identity-wave5a-check.mjs
134
+syntax ok: scripts/identity-wave5b-check.mjs
135
+syntax ok: scripts/identity-wave5c-check.mjs
136
+syntax ok: scripts/kavenegar-otp-preflight-test.mjs
137
+syntax ok: scripts/login-connectivity-check.mjs
138
+syntax ok: scripts/migration-manifest-check.mjs
139
+syntax ok: scripts/migration-manifest-test.mjs
140
+syntax ok: scripts/office-c8-concurrency.mjs
141
+syntax ok: scripts/office-slice-c1-check.mjs
142
+syntax ok: scripts/office-slice-c2-check.mjs
143
+syntax ok: scripts/office-slice-c3-check.mjs
144
+syntax ok: scripts/office-slice-c4-check.mjs
145
+syntax ok: scripts/office-slice-c5-check.mjs
146
+syntax ok: scripts/office-slice-c6-check.mjs
147
+syntax ok: scripts/office-slice-c7-check.mjs
148
+syntax ok: scripts/office-slice-c8-check.mjs
149
+syntax ok: scripts/pages-blocking-bundles.mjs
150
+syntax ok: scripts/phase2-check.mjs
151
+syntax ok: scripts/phase3-behavior-check.mjs
152
+syntax ok: scripts/phase3-check.mjs
153
+syntax ok: scripts/phase4-behavior-check.mjs
154
+syntax ok: scripts/phase5-behavior-check.mjs
155
+syntax ok: scripts/phase6-behavior-check.mjs
156
+syntax ok: scripts/platform-office-check.mjs
157
+syntax ok: scripts/posting-idempotency-check.mjs
158
+syntax ok: scripts/public-qa-regression-check.mjs
159
+syntax ok: scripts/quality-check.mjs
160
+syntax ok: scripts/release-safety-check.mjs
161
+syntax ok: scripts/request-workflow-d1-check.mjs
162
+syntax ok: scripts/request-workflow-d1-security-check.mjs
163
+syntax ok: scripts/request-workflow-d1-transition-check.mjs
164
+syntax ok: scripts/request-workflow-d2-check.mjs
165
+syntax ok: scripts/request-workflow-d3b-check.mjs
166
+syntax ok: scripts/request-workflow-d3c-check.mjs
167
+syntax ok: scripts/request-workflow-d4a-check.mjs
168
+syntax ok: scripts/slice-b-rbac-check.mjs
169
+syntax ok: scripts/stripe-edge-sandbox-test.mjs
170
+syntax ok: scripts/stripe-sandbox-readonly-test.mjs
171
+syntax ok: scripts/stripe-sandbox-readonly.mjs
172
+syntax ok: scripts/syntax-check.mjs
173
+syntax ok: scripts/ux-hardening-r2-check.mjs
174
+syntax ok: scripts/wp0-ledger-harness.mjs
175
+syntax ok: scripts/wp0-ledger-reproduce.mjs
176
+syntax ok: scripts/wp1-client-capability-test.mjs
177
+syntax ok: scripts/wp1-concurrency.mjs
178
+syntax ok: scripts/wp1-correction-cycle.mjs
179
+syntax ok: scripts/wp1-ledger-test.mjs
180
+syntax ok: scripts/wp1-prerequisite-rollback.mjs
181
+syntax ok: scripts/wp1-purchase-correction-guard-test.mjs
182
+Syntax passed for 56 JavaScript modules and 65 MJS test scripts.
183
+Generated Pages public regression (standalone suite)
184
+Pages artifact built: 133 static + 270 runtime inline handlers externalized; diag.html intentionally excluded.
185
+Public QA regression invariants: PASS
186
+Offline encrypted backup safety contracts
187
+test_age_failure_deletes_ciphertext_and_manifest (__main__.OfflineBackupContract.test_age_failure_deletes_ciphertext_and_manifest) ... ok
188
+test_disposable_local_restore_pipeline (__main__.OfflineBackupContract.test_disposable_local_restore_pipeline) ... ok
189
+test_dump_failure_deletes_ciphertext_and_manifest (__main__.OfflineBackupContract.test_dump_failure_deletes_ciphertext_and_manifest) ... ok
190
+test_encrypted_archive_manifest_and_verify (__main__.OfflineBackupContract.test_encrypted_archive_manifest_and_verify) ... ok
191
+test_integrity_tamper_detected (__main__.OfflineBackupContract.test_integrity_tamper_detected) ... ok
192
+test_reject_checkout_storage_and_invalid_recipient (__main__.OfflineBackupContract.test_reject_checkout_storage_and_invalid_recipient) ... ok
193
+test_restore_to_remote_or_ordinary_db_blocked (__main__.OfflineBackupContract.test_restore_to_remote_or_ordinary_db_blocked) ... ok
194
+
195
+----------------------------------------------------------------------
196
+Ran 7 tests in 0.772s
197
+
198
+OK
199
+Application invariants
200
+Static quality and security invariants passed for 56 JavaScript modules.
201
+Independent accounting integrity fixture
202
+PASS: valid records accepted; imbalance and duplicate invoice rejected
203
+Stripe sandbox invoice read-only invariants
204
+PASS: sandbox-only read adapter + positive and adversarial checks; no writes or live credentials
205
+Finora Stripe sandbox Edge authorization and invariant gates
206
+PASS: Finora Stripe Edge function tested with 26 sandbox access and adversarial cases; no production writes
207
+Finora Kavenegar OTP offline signed-hook and provider safety checks
208
+PASS: Finora Kavenegar OTP offline preflight: signed request, disabled default, provider errors, phone/token isolation, zero real SMS.
209
+Commercial workspace and factory-reset invariants
210
+Commercial R&D invariants passed.
211
+UX commerce/settings R2 invariants
212
+UX/commerce/settings R2 invariants passed.
213
+Accounting, product coding and commercial workspace guidance invariants
214
+Accounting/product guidance invariants passed.
215
+Phase 2 accounting foundation invariants
216
+Phase 2 accounting foundation invariants passed.
217
+Chart completeness and history preservation
218
+Chart completeness: all 8 templates, contra types, safe explicit upgrades, preview UI and rejection boundaries passed.
219
+Phase 3 double-entry invariants
220
+Phase 3 double-entry invariants passed.
221
+Phase 3 behavioral accounting scenarios
222
+Phase 3 behavioral accounting scenarios passed.
223
+Accounting P0 dimensions and journal invariants
224
+Accounting P0 invariants passed.
225
+Phase 4 accounting invariants
226
+Phase 4 accounting invariants passed.
227
+Phase 5 complementary ERP invariants
228
+Phase 5 behavioral/domain scenarios passed.
229
+Phase 5 depreciation reversal semantics passed.
230
+Phase 5 restore atomicity and posted-history protection passed.
231
+Phase 5 financial sync conflict reconciliation passed.
232
+Iran enterprise payroll and service-period behavior
233
+Enterprise Iran behavior PASS
234
+Phase 6 reporting and reconciliation scenarios
235
+Phase 6 reporting/reconciliation scenarios passed.
236
+Phase 6 20k-line reporting performance passed in 55ms.
237
+Golden accounting core journey
238
+Golden accounting core journey passed: sale -> receipt -> purchase -> payment -> expense/income -> reversal -> trial balance -> financial statements.
239
+Modular ERP and office automation invariants
240
+Platform/office foundation checks PASS: full-suite entitlement | server collection entitlement | office private storage | atomic registry allocation | module launcher | future modules disabled | office scan upload | configurable request fields | rbac boundary documented
241
+Slice B tenant and RBAC invariants
242
+Slice B tenant/RBAC invariants PASS (20260930031853_organization_membership_rbac_foundation.sql, 20260930031942_office_shared_rbac_and_referrals.sql, 20260930032615_slice_b_rbac_fk_indexes.sql, 20260930032654_harden_legacy_office_storage_member_writes.sql, 20260930033010_allow_member_core_read_context.sql)
243
+Enterprise license seats and delegated admin invariants
244
+ELI-1 database contract invariants: PASS
245
+Reusable organization roles invariants
246
+ELI-2 reusable role database contract: PASS
247
+Secure organization invitation invariants
248
+ELI-3 invitation database + runtime contract: PASS
249
+Enterprise organization UX invariants
250
+ELI-4 enterprise organization UX contract: PASS
251
+Wave 5a identity/bootstrap invariants
252
+Wave 5a identity/bootstrap invariants passed
253
+Wave 5b offboarding/revocation invariants
254
+Wave 5b offboarding/revocation invariants passed
255
+Wave 5c privileged backup authorization invariants
256
+Wave 5c privileged backup authorization invariants passed
257
+Finora branding and login invariants
258
+Finora branding/login invariants passed
259
+Login connectivity diagnostics
260
+PASS: login connectivity diagnostics are read-only, cache-versioned and credential-free
261
+Office Slice C1 invariants
262
+Office Slice C1 server + runtime contract: PASS
263
+Office Slice C2 invariants
264
+Office Slice C2 server + runtime contract: PASS
265
+Office Slice C3 invariants
266
+Office Slice C3 server + runtime contract: PASS
267
+Office Slice C4 invariants
268
+Office Slice C4 registration + template contract: PASS
269
+Office Slice C5 invariants
270
+Office Slice C5 internal approval contract: PASS
271
+Office Slice C6 invariants
272
+Office Slice C6 SLA contract: PASS
273
+Office Slice C7 invariants
274
+Office Slice C7 searchable archive contract: PASS
275
+Office Slice C8 policy UI invariants
276
+Office Slice C8 policy UI + SQL contract: PASS
277
+Request Workflow Slice D1 foundation invariants
278
+Slice D1 request workflow foundation invariants: OK
279
+Request Workflow Slice D1 transition evidence invariants
280
+Slice D1 transition evidence invariants: OK
281
+Request Workflow Slice D1 RPC security invariants
282
+Slice D1 RPC security invariants: OK
283
+Request Workflow Slice D2 UI/read-model invariants
284
+PASS D2 runtime is loaded after legacy office UI
285
+PASS D2 reads server request definitions and immutable versions
286
+PASS publishing uses the server-authorized D1 RPC
287
+PASS runtime creation uses the server-authorized D1 RPC with idempotency
288
+PASS configure actions are capability-gated
289
+PASS published version and draft-change state are visible
290
+PASS legacy record-store request writes are not used by D2
291
+PASS stale revision has an explicit recoverable surface
292
+PASS legacy cutover is traceable and non-destructive
293
+Request Workflow D2 static contracts verified.
294
+Request Workflow Slice D3b visual/condition/timeline invariants
295
+Request Workflow D3b invariants: OK
296
+Request Workflow Slice D3c operations invariants
297
+Request Workflow D3c invariants: OK
298
+Request Workflow Slice D4a work queue invariants
299
+Request Workflow D4a static invariants: PASS
300
+Posted-source uniqueness and draft safety contract
301
+Financial draft/posted data safety invariants PASS
302
+Secure admin provisioning contract
303
+Admin server-only provisioning and credential reset contract PASS
304
+Central admin credential and organization recovery controls
305
+✔ global administrator requests only the current verified Auth email and fixed callback (29.593972ms)
306
+✔ active organization owner may request recovery for an active same-organization Auth user (1.967197ms)
307
+✔ ordinary member and forged user metadata never grant recovery management (2.2079ms)
308
+✔ direct core configure permission authorizes the active member (1.877601ms)
309
+✔ existing full_suite configure permission authorizes the active member (1.484787ms)
310
+✔ module-specific configure and malformed capability strings do not manage recovery (1.51987ms)
311
+✔ active reusable role permission authorizes recovery without a new global role (1.043378ms)
312
+✔ system_admin role name without configure permission grants nothing (0.948335ms)
313
+✔ inactive assignment cannot authorize recovery (0.893923ms)
314
+✔ inactive role cannot authorize recovery (0.642433ms)
315
+✔ foreign assignment cannot authorize recovery (0.589512ms)
316
+✔ foreign role cannot authorize recovery (0.424282ms)
317
+✔ foreign permission cannot authorize recovery (1.337083ms)
318
+✔ suspended actor membership cannot send a recovery email (0.866572ms)
319
+✔ left actor membership cannot send a recovery email (0.347606ms)
320
+✔ suspended target membership cannot send a recovery email (0.306994ms)
321
+✔ left target membership cannot send a recovery email (0.261777ms)
322
+✔ cross-organization target and organization identifiers cannot escape caller scope (0.435088ms)
323
+✔ membership UUID is not an Auth-user UUID and cannot select a recipient (0.553498ms)
324
+✔ suspended organization and missing caller membership fail closed (0.870397ms)
325
+✔ profiles read error fails closed without sending mail (0.938841ms)
326
+✔ organizations read error fails closed without sending mail (0.689553ms)
327
+✔ organization_members read error fails closed without sending mail (0.302698ms)
328
+✔ member_module_permissions read error fails closed without sending mail (0.612667ms)
329
+✔ organization_member_roles read error fails closed without sending mail (0.425794ms)
330
+✔ organization_roles read error fails closed without sending mail (0.379153ms)
331
+✔ organization_role_permissions read error fails closed without sending mail (0.492806ms)
332
+✔ missing or unconfirmed email cannot be replaced by stale profile information (1.026994ms)
333
+✔ Auth target lookup failure returns no sensitive details and sends no email (0.838349ms)
334
+✔ untrusted recovery field email is rejected (0.647149ms)
335
+✔ untrusted recovery field redirectTo is rejected (0.896787ms)
336
+✔ untrusted recovery field password is rejected (1.292526ms)
337
+✔ untrusted recovery field role is rejected (0.267074ms)
338
+✔ untrusted recovery field is_owner is rejected (0.222076ms)
339
+✔ malformed target and organization identifiers are rejected before Auth target lookup (2.179864ms)
340
+✔ global platform admin can set a password through Auth Admin and receives only an outcome (1.365416ms)
341
+✔ organization owner and delegated managers cannot assign any global Auth password (0.658697ms)
342
+✔ malformed direct reset identifiers and unexpected fields are rejected without Auth lookup (1.894977ms)
343
+✔ weak assigned passwords fail server policy without Auth mutation (1.258684ms)
344
+✔ Auth password update failures are bounded and never log the submitted secret (1.740444ms)
345
+✔ rate limits remain distinguishable without leaking provider error text (1.512018ms)
346
+✔ email request rejection and network exception cannot claim success or expose a link (0.906272ms)
347
+✔ recovery response and audit contain only outcome and account identifiers (0.593127ms)
348
+✔ global-admin account creation contract remains unchanged (0.692778ms)
349
+✔ organization owner and delegated manager cannot provision a global account (0.688512ms)
350
+✔ weak initial passwords remain rejected and creation errors stay bounded (0.811719ms)
351
+✔ CORS and HTTP method handling preserve existing restrictions (0.585637ms)
352
+✔ missing or rejected bearer and missing server configuration never send mail (0.577554ms)
353
+✔ invalid, array and oversized JSON requests cannot trigger recovery (1.911648ms)
354
+ℹ tests 49
355
+ℹ suites 0
356
+ℹ pass 49
357
+ℹ fail 0
358
+ℹ cancelled 0
359
+ℹ skipped 0
360
+ℹ todo 0
361
+ℹ duration_ms 183.476673
362
+Pages artifact built: 133 static + 270 runtime inline handlers externalized; diag.html intentionally excluded.
363
+Public QA regression invariants: PASS
364
+Release/QA safety invariants: PASS
365
+{'commands': 55, 'failed': []}
docs/wp1/evidence/client-sync/tenant-transition-red.log
new
+85
@@ -0,0 +1,85 @@
1
+✔ confirmed absent server uses legacy columns and legacy sync (4.09143ms)
2
+✔ present capability loads versions and uses versioned sync acknowledgement (2.752645ms)
3
+✔ transport probe errors preserve pending edits without a legacy write (1.465427ms)
4
+✔ partial server with no row version fails before write (2.155562ms)
5
+✔ account switch during probe cannot send old edits (1.484506ms)
6
+✔ old-organization write acknowledgement cannot overwrite new snapshot (2.210615ms)
7
+✔ incomplete upsert acknowledgement cannot mark pending changes saved (1.781916ms)
8
+✔ incomplete delete acknowledgement cannot erase snapshot (2.864077ms)
9
+✔ missing V2 write RPC never silently downgrades to legacy write (4.711262ms)
10
+✔ new server capability requires fresh versions without discarding pending edits (1.79805ms)
11
+✔ organization wrapper uses same capability and versioned protocol (3.733524ms)
12
+✔ late read cannot publish across identity switch (org wrapper false) (1.380899ms)
13
+✔ CAS conflict preserves edits without reload or retry (org wrapper false) (0.981315ms)
14
+✔ late read cannot publish across identity switch (org wrapper true) (1.332917ms)
15
+✔ CAS conflict preserves edits without reload or retry (org wrapper true) (4.31563ms)
16
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":5},{"collection":"companies","id":"C","version":5}],"deletes":[]} (1.108236ms)
17
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":4}],"deletes":[]} (2.804193ms)
18
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":"5"}],"deletes":[]} (2.346119ms)
19
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"other","version":5}],"deletes":[]} (2.127989ms)
20
+✔ malformed acknowledgement stays pending: {"upserts":[{"collection":"companies","id":"C","version":5}],"deletes":[{"collection":"companies","id":"C"}]} (2.108761ms)
21
+✔ malformed acknowledgement stays pending: null (1.660672ms)
22
+✔ positive version evidence prevents falling back when probe disappears (1.289701ms)
23
+✔ new record uses version zero and deletion acknowledges exact identity (1.360298ms)
24
+✔ edits made during write stay pending and use returned version on next batch (2.317396ms)
25
+✔ malformed guard mode cannot authorize a write (1.046844ms)
26
+✔ invalid persisted revision cannot downgrade to legacy: null (1.610847ms)
27
+✔ invalid persisted revision cannot downgrade to legacy: 0 (0.926151ms)
28
+✔ invalid persisted revision cannot downgrade to legacy: -1 (1.154526ms)
29
+✔ invalid persisted revision cannot downgrade to legacy: 1.5 (1.102308ms)
30
+✔ invalid persisted revision cannot downgrade to legacy: 4 (0.807892ms)
31
+✔ invalid persisted revision cannot downgrade to legacy: 9007199254740992 (1.517987ms)
32
+✔ late acknowledgement after same-tenant refresh cannot replace fresh revisions (1.974166ms)
33
+✔ nested edits during capability probe cannot mutate the captured write payload (2.003421ms)
34
+✔ stalled probe has a bounded failure and no late success (18.569945ms)
35
+✔ stalled write has a bounded failure and no late success (2.163323ms)
36
+✔ duplicate pending identifiers fail before any write (1.120926ms)
37
+✔ queued save resumes after stale tenant request releases sync lock (1.310252ms)
38
+✔ queued save resumes after stale identity request releases sync lock (1.19637ms)
39
+✔ same-context CAS rejection does not automatically retry queued edits (1.10363ms)
40
+✖ same user cannot dispatch old-organization edits while new organization is loading (2.87475ms)
41
+✖ direct same-user organization change cannot write before its own snapshot (1.104961ms)
42
+ℹ tests 41
43
+ℹ suites 0
44
+ℹ pass 39
45
+ℹ fail 2
46
+ℹ cancelled 0
47
+ℹ skipped 0
48
+ℹ todo 0
49
+ℹ duration_ms 175.385003
50
+
51
+✖ failing tests:
52
+
53
+test at scripts/wp1-client-capability-test.mjs:156:1
54
+✖ same user cannot dispatch old-organization edits while new organization is loading (2.87475ms)
55
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
56
+
57
+ 2 !== 1
58
+
59
+ at TestContext.<anonymous> (file:///workspace/Factor-easy-wp1/scripts/wp1-client-capability-test.mjs:167:9)
60
+ at async Test.run (node:internal/test_runner/test:1389:7)
61
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
62
+ generatedMessage: true,
63
+ code: 'ERR_ASSERTION',
64
+ actual: 2,
65
+ expected: 1,
66
+ operator: 'strictEqual',
67
+ diff: 'simple'
68
+ }
69
+
70
+test at scripts/wp1-client-capability-test.mjs:172:1
71
+✖ direct same-user organization change cannot write before its own snapshot (1.104961ms)
72
+ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
73
+
74
+ 2 !== 0
75
+
76
+ at TestContext.<anonymous> (file:///workspace/Factor-easy-wp1/scripts/wp1-client-capability-test.mjs:173:163)
77
+ at async Test.run (node:internal/test_runner/test:1389:7)
78
+ at async Test.processPendingSubtests (node:internal/test_runner/test:960:7) {
79
+ generatedMessage: true,
80
+ code: 'ERR_ASSERTION',
81
+ actual: 2,
82
+ expected: 0,
83
+ operator: 'strictEqual',
84
+ diff: 'simple'
85
+ }
docs/wp1/history/STATUS_BEFORE_CLIENT_SYNC_2026-11-03.md
new
+28
@@ -0,0 +1,28 @@
1
+# WP1 — دفتر مالی سمت سرور
2
+
3
+وضعیت: **در حال انجام؛ قابل انتشار نیست.**
4
+
5
+هدف: رد سند نامتوازن و تغییر پس از قطعیشدن در خود پایگاهداده، با مسیر RPC تراکنشی، کنترل شرکت/سال/دسترسی، برگشت و شمارهگذاری ایمن. شروع از WP0 PR194 با Quality41416988716/Security41416988731 موفق؛ گزارش خط مبنا و شواهد تحویل شدهاند. PR194 هنوز ادغام نشده است؛ این شاخه روی آن قرار دارد.
6
+
7
+کار جاری: انتقال انتخابی۱۱ SQL مرحلهبندیشده از PR162–173 به شاخه مستقل، آزمون مجدد روی PostgreSQL17 برگرفته از migrationهای واقعی مخزن. هیچ API یا کد کلاینت فعال نشده و هیچ migration روی Production اجرا نشده است.
8
+
9
+شواهد اولیه: تست مستقل D1/D2/D2_DIMENSION روی baseline با پیام مشخص WP1_REQUIRED_GUARDS_MISSING شکست خورد؛ روی زنجیره SQL منتقلشده موفق شد. D2 از سند جداگانه متوازن استفاده میکند؛ SET CONSTRAINTS ALL IMMEDIATE و فهرست خطاهای قابلقبول از قبولی کاذب جلوگیری میکنند. این قبولی، کل WP1 یا امنیت تمام RPCها را تأیید نمیکند.
10
+
11
+یافتههای باز در کد قبلی: حالت پیشفرض off؛ تغییر حالت توسط مالک عادی سازمان؛ نبود WHEN محدود به دفتر؛ شمارهگذاری بدون تفکیک شرکت؛ کنترل ناکامل سال/ارز ردیف و وضعیت بسته سال مالی؛ مجوز برگشت تکراری. بازبینی و migration اصلاحی در حال تهیه است.
12
+
13
+باقیمانده: تستهای منفی یافتههای بالا و رفع آنها؛ اثبات همزمانی و۱۰۰۰رویداد؛ DOWN برای تمام تغییرات و UP/DOWN/UP؛ feature probe و fallback صحیح کلاینت؛ مسیر اصلاح/ابطال/ذخیره خرید زیر ENFORCE؛ پوشش منبعبهمنبع و برچسب صادقانه پوشش؛ گزارش shadow؛ بسته rollout/backup/rollback برای G1؛ CI تازه. آزمون واقعی JWT/PostgREST و Production پذیرش نشدهاند.
14
+
15
+هیچ نصب یا تأییدی از مالک اکنون لازم نیست. G1 فقط پس از آمادهشدن بسته قابل بازبینی و اثبات کامل درخواست میشود. مالک در ۲۰۲۶/۱۱/۰۳ ادامه فازهای بعد را تأیید کرده؛ آغاز آنها تابع گیت مرحله قبل است. [نقشه راه جاری](../ROADMAP_CURRENT.md).
16
+
17
+## checkpoint 2026-11-03
18
+پس از راهاندازی مجدد محیط، آزمونهای هدفمند دوباره اجرا شدند:۱۴ حالت منفی posting و قرارداد shadow/defaultaudit/adminsetter/WHEN موفق. آزمون کامل۱۰۰۰رویداد هنوز نتیجه نهایی ندارد؛ اجرای قطعشده قبلی قبولی محسوب نمیشود.۱۲فایل candidate جدید باعث۹۴فایل migration شده؛۲۴production-only و۳۶repo-only شامل۱۲candidate نصبنشده است، نه۱۲اختلاف تازه Production.
19
+
20
+آزمون همزمان واقعیِ دو اتصال نیز موفق شد: ساخت تکراری یک سند ایجاد کرد، دو قطعیسازی شمارههای۱و۲ گرفتند، و از دو برگشت همزمان فقط یکی مجاز شد. آزمون انتقال هویت سند و مقدار null و چرخه اصلاحی UP/DOWN/UP مجدداً موفقاند؛ شواهد در پوشههای concurrency-final،scope-final،correction-final ثبت شدهاند. اجرای۱۰۰۰رویداد دوباره پیش از نتیجه نهایی قطع شد؛ قبولی آن ثبت نمیشود. شاخه بهصورت پیشنویس منتشر میشود تا CI مستقل از قطع محیط ادامه دهد؛ قابل ادغام یا نصب نیست.
21
+
22
+## نتیجه تازه CI
23
+
24
+روی کامیت `4b00e5b`، [Quality41586514247](https://github.com/davoodmehraban89/Factor-easy/actions/runs/41586514247)،[Security41586514251](https://github.com/davoodmehraban89/Factor-easy/actions/runs/41586514251) و [WP1 proof41586514303](https://github.com/davoodmehraban89/Factor-easy/actions/runs/41586514303) موفق شدند. فرمان کامل SQL شامل آزمون۱۰۰۰رویداد و همزمانی پایان یافت؛ این شاهد جایگزین اجرای محلی قطعشده است. دریافت artifact از provider ممکن نشد؛ نتیجه job/step در GitHub API تأیید شد، نه شمارش ساختگی لاگ.
25
+
26
+محافظ جدید خرید قبل از تغییر محلی، حالت سرور را بررسی میکند: ENFORCE یا خطای شبکه/حالت نامعتبر/تعویض حساب، اصلاح و ابطال را بدون تغییر رد میکند. نبود صریح RPC یا off/audit مسیر قبلی را حفظ میکند.۲۸تست مرورگر و۳تست محافظ در Pages موفق؛ اجرای نهایی CI این تغییر جداست. این حفاظت معادل تکمیل عملیات اصلاح خرید روی سرور نیست.
27
+
28
+بازگشت محافظهکارانه هر۱۱پیشنیاز نیز اکنون در محیط مستقل موفق است:۷۱تعریف تابع/مجوز و تریگرهای قبلی بازگردانده شدند؛۴سند قطعی،۱۰ردیف و۱۰رویداد ممیزی و تاریخچه شمارنده بدون تغییر ماندند. پس از UP مجدد،D1/D2 موفقاند. ایندکسها و ساختارهای سازگار عمداً حفظ میشوند؛ همسانی با Production هنوز گیت جداست. [شاهد](evidence/prerequisite-rollback/result.json).
index.html
+2
-2
@@ -924,7 +924,7 @@ body{background:#f6f9fc}
924
<script src="js/password-recovery.js?v=20261026-recovery-cancel-v2"></script>
925
<script src="js/core.js?v=20261025-password-recovery-v1"></script>
926
<script src="js/admin.js?v=20261028-central-password-reset-v1"></script>
927
-<script src="js/sync.js?v=20261012-login-read-cancel-v1"></script>
927
+<script src="js/sync.js?v=20261103-versioned-sync-v1"></script>
928
<script src="js/ui.js?v=20261031-workspace-recovery-v1"></script>
929
<script src="js/invoices.js?v=20261031-workspace-recovery-v1"></script>
930
<script src="js/print.js?v=20261012-clean-invoice-print-v1"></script>
@@ -935,7 +935,7 @@ body{background:#f6f9fc}
935
<script src="js/companies.js?v=20261028-company-edit-v1"></script>
936
<script src="js/backup.js?v=20260928-data-v3"></script>
937
<script src="js/words.js"></script>
938
-<script src="js/bootstrap.js?v=20261031-workspace-recovery-v1"></script>
938
+<script src="js/bootstrap.js?v=20261103-versioned-sync-v1"></script>
939
940
<style>
941
.form-control, textarea, select { direction: rtl; }
js/bootstrap.js
+1
-1
@@ -3,7 +3,7 @@
3
// browsers may download in parallel but preserve script execution/dependencies.
4
// Auth starts only once all extensions have finished loading or failed.
5
const FINORA_EXTENSION_SCRIPTS=[
6
- "js/organization-rbac.js?v=20261031-workspace-recovery-v1",
6
+ "js/organization-rbac.js?v=20261103-versioned-sync-v1",
7
"js/organization-invitations.js?v=20260930-eli3-v1",
8
"js/organization-enterprise-ux.js?v=20260930-eli4-v1",
9
"js/platform-modules.js?v=20261031-workspace-recovery-v1",
js/organization-rbac.js
+7
-10
@@ -59,7 +59,7 @@ async function loadOrganizationContext(user,{signal}={}){
59
fetchCurrentUser=async function(authUser,options={}){return loadOrganizationContext(await baseFetchCurrentUser(authUser,options),options)};
60
let finoraMembershipRevalidationBusy=false;
61
function clearFinoraTenantMemory(userId){
62
- clearTimeout(syncTimer);syncPending=false;syncAgain=false;syncFailCount=0;syncSnap.clear();
62
+ clearTimeout(syncTimer);syncPending=false;syncAgain=false;syncFailCount=0;syncSnap.clear();versionSnap.clear();finoraHydratedTenant=null;finoraSyncGeneration++;
63
const fresh={};COLLS.forEach(k=>fresh[k]=[]);datastore=fresh;
64
try{localStorage.removeItem('finora_active_org_'+userId);localStorage.removeItem(STORAGE_KEY);}catch(e){}
65
document.querySelectorAll('.modal-backdrop.active').forEach(el=>el.classList.remove('active'));
@@ -106,24 +106,21 @@ const legacyPullAll=pullAll;
106
pullAll=async function(options={}){
107
const signal=options?.signal;
108
if(!currentUser?.organizationId)return legacyPullAll(options);
109
- const uid=currentUser.id,orgId=currentUser.organizationId,fresh={};COLLS.forEach(k=>fresh[k]=[]);
110
- const snap=new Map(),page=1000;let from=0;
109
+ const context=finoraSyncContext(),uid=context.uid,orgId=context.org,fresh={};COLLS.forEach(k=>fresh[k]=[]);
110
+ const snap=new Map(),versions=new Map(),page=1000;let from=0;
111
for(;;){
112
- const request=sb.from('records').select('collection,id,data,owner_id,organization_id').eq('organization_id',orgId).order('collection').order('id').range(from,from+page-1);
112
+ const request=sb.from('records').select('*').eq('organization_id',orgId).order('collection').order('id').range(from,from+page-1);
113
const {data,error}=await finoraOrganizationRead(request,signal);
114
if(error)throw error;
115
- (data||[]).forEach(r=>{if(!fresh[r.collection])return;const obj=(r.data&&typeof r.data==='object'&&!Array.isArray(r.data))?r.data:{};obj.id=r.id;snap.set(r.collection+'|'+r.id,JSON.stringify(stripOwner(obj)));obj.ownerUserId=uid;fresh[r.collection].push(obj)});
115
+ (data||[]).forEach(r=>{if(!fresh[r.collection])return;const obj=(r.data&&typeof r.data==='object'&&!Array.isArray(r.data))?r.data:{};obj.id=r.id;snap.set(r.collection+'|'+r.id,JSON.stringify(stripOwner(obj)));finoraCaptureVersion(r,versions);obj.ownerUserId=uid;fresh[r.collection].push(obj)});
116
if(!data||data.length<page)break;from+=page;
117
}
118
// Never apply an aborted/stale company snapshot to the active tenant.
119
if(signal?.aborted)throw new Error('FINORA_LOGIN_READ_TIMEOUT');
120
if(currentUser?.id!==uid||currentUser.organizationId!==orgId)throw new Error('FINORA_ORGANIZATION_CONTEXT_CHANGED');
121
- datastore=fresh;syncSnap.clear();snap.forEach((v,k)=>syncSnap.set(k,v));
122
-};
123
-runSync=async function(){
124
- if(!currentUser)return;if(syncRunning){syncAgain=true;return;}syncRunning=true;
125
- try{let guardLoops=0;do{syncAgain=false;const {up,del}=computeDiff();if(!up.length&&!del.length)break;setSyncBadge('saving');const deletes=del.map(k=>{const j=k.indexOf('|');return {collection:k.slice(0,j),id:k.slice(j+1)}});const {error}=await sb.rpc('finora_sync_records',{p_upserts:up.map(r=>({collection:r.coll,id:r.id,data:r.payload})),p_deletes:deletes,p_organization_id:currentUser.organizationId||null});if(error)throw error;up.forEach(r=>syncSnap.set(r.key,r.s));deletes.forEach(r=>syncSnap.delete(r.collection+'|'+r.id));syncFailCount=0;guardLoops++}while(guardLoops<5);const d=computeDiff();syncPending=!!(d.up.length||d.del.length);if(syncPending)scheduleSync(500);else setSyncBadge('saved')}catch(err){console.error('sync error',err);await handleSyncError(err)}finally{syncRunning=false}
121
+ finoraPublishSyncSnapshot(fresh,snap,versions,context);
122
};
123
+// The base runSync uses the same organization-aware, versioned write contract.
124
window.switchFinoraOrganization=async function(orgId){
125
if(!currentUser?.organizations?.some(x=>x.organization.id===orgId))return false;
126
localStorage.setItem('finora_active_org_'+currentUser.id,orgId);
js/sync.js
+125
-17
@@ -18,25 +18,119 @@ function getMySettings(){
18
}
19
// ---------- Cloud data layer (Supabase). UI code keeps using `datastore`; this layer syncs it. ----------
20
const syncSnap=new Map();
21
+// Revisions are kept outside application records and never copied into user data.
22
+const versionSnap=new Map(),finoraVersionedTenants=new Set();
23
+let finoraSyncGeneration=0,finoraHydratedTenant=null;
24
+function finoraSyncContext(){return {user:currentUser,uid:currentUser?.id,org:currentUser?.organizationId||null,generation:finoraSyncGeneration};}
25
+function finoraSyncContextMatches(c){return currentUser===c.user&¤tUser?.id===c.uid&&(currentUser?.organizationId||null)===c.org&&finoraSyncGeneration===c.generation;}
26
+function finoraSyncIssue(code){const e=new Error(code);e.code=code;e.finoraPreservePending=true;return e;}
27
+function finoraAssertSyncContext(c){if(!finoraSyncContextMatches(c))throw finoraSyncIssue('FINORA_SYNC_CONTEXT_CHANGED');}
28
+function finoraAssertSyncSnapshot(c){
29
+ finoraAssertSyncContext(c);
30
+ if(finoraHydratedTenant!==finoraTenantKey(c))throw finoraSyncIssue('FINORA_SYNC_SNAPSHOT_REQUIRED');
31
+}
32
+function finoraValidVersion(v){return Number.isSafeInteger(v)&&v>0&&v<Number.MAX_SAFE_INTEGER;}
33
+function finoraCaptureVersion(r,versions){
34
+ if(!Object.prototype.hasOwnProperty.call(r,'version'))return;
35
+ if(!finoraValidVersion(r.version))throw finoraSyncIssue('FINORA_SYNC_VERSION_INVALID');
36
+ versions.set(r.collection+'|'+r.id,r.version);
37
+}
38
+function finoraTenantKey(c){return JSON.stringify([c.uid,c.org]);}
39
+function finoraPublishSyncSnapshot(fresh,snap,versions,c){
40
+ finoraAssertSyncContext(c);
41
+ datastore=fresh;syncSnap.clear();snap.forEach((v,k)=>syncSnap.set(k,v));
42
+ versionSnap.clear();versions.forEach((v,k)=>versionSnap.set(k,v));
43
+ if(versions.size)finoraVersionedTenants.add(finoraTenantKey(c));
44
+ finoraHydratedTenant=finoraTenantKey(c);finoraSyncGeneration++;
45
+}
46
+async function finoraBoundedSyncRequest(request,code){
47
+ let timer;
48
+ try{return await Promise.race([request,new Promise((_,reject)=>{timer=setTimeout(()=>reject(finoraSyncIssue(code)),20000);})]);}
49
+ finally{clearTimeout(timer);}
50
+}
51
+// Probe only on writes: login reads must work against either schema without a
52
+// speculative network call or an explicit select of a not-yet-installed column.
53
+async function finoraHasVersionedSync(c){
54
+ let result;
55
+ try{result=await finoraBoundedSyncRequest(sb.rpc('finora_journal_get_guard_mode',{p_organization_id:c.org}),'FINORA_SYNC_CAPABILITY_TIMEOUT');}
56
+ catch(e){throw finoraSyncIssue('FINORA_SYNC_CAPABILITY_UNAVAILABLE');}
57
+ finoraAssertSyncContext(c);
58
+ const key=finoraTenantKey(c);
59
+ if(result?.error){
60
+ if(['PGRST202','42883'].includes(result.error.code)&&!finoraVersionedTenants.has(key)&&versionSnap.size===0)return false;
61
+ throw finoraSyncIssue('FINORA_SYNC_CAPABILITY_UNAVAILABLE');
62
+ }
63
+ if(!['off','audit','enforce'].includes(result?.data))throw finoraSyncIssue('FINORA_SYNC_CAPABILITY_INVALID');
64
+ finoraVersionedTenants.add(key);return true;
65
+}
66
+function finoraExpectedVersion(key,creating){
67
+ if(creating&&!syncSnap.has(key))return 0;
68
+ const version=versionSnap.get(key);
69
+ if(!finoraValidVersion(version))throw finoraSyncIssue('FINORA_SYNC_VERSION_REQUIRED');
70
+ return version;
71
+}
72
+function finoraValidateSyncAck(data,upserts,deletes){
73
+ if(!data||!Array.isArray(data.upserts)||!Array.isArray(data.deletes)||data.upserts.length!==upserts.length||data.deletes.length!==deletes.length)throw finoraSyncIssue('FINORA_SYNC_ACK_INVALID');
74
+ const check=(rows,requested,withVersion)=>{
75
+ const expected=new Map(requested.map(r=>[r.collection+'|'+r.id,r]));
76
+ if(expected.size!==requested.length)throw finoraSyncIssue('FINORA_SYNC_ACK_INVALID');
77
+ for(const r of rows){
78
+ if(!r||typeof r.collection!=='string'||typeof r.id!=='string')throw finoraSyncIssue('FINORA_SYNC_ACK_INVALID');
79
+ const key=r.collection+'|'+r.id,want=expected.get(key);
80
+ if(!want||(withVersion&&(!finoraValidVersion(r.version)||r.version!==want.expected_version+1)))throw finoraSyncIssue('FINORA_SYNC_ACK_INVALID');
81
+ expected.delete(key);
82
+ }
83
+ if(expected.size)throw finoraSyncIssue('FINORA_SYNC_ACK_INVALID');
84
+ };
85
+ check(data.upserts,upserts,true);check(data.deletes,deletes,false);
86
+}
87
+async function finoraWriteSyncBatch(up,del,c){
88
+ finoraAssertSyncSnapshot(c);
89
+ const versioned=await finoraHasVersionedSync(c);
90
+ finoraAssertSyncContext(c);
91
+ const upserts=up.map(r=>({collection:r.coll,id:r.id,data:JSON.parse(r.s)}));
92
+ const deletes=del.map(k=>{const j=k.indexOf('|');return {collection:k.slice(0,j),id:k.slice(j+1)};});
93
+ if(new Set(up.map(r=>r.key).concat(del)).size!==up.length+del.length)throw finoraSyncIssue('FINORA_SYNC_DUPLICATE_KEYS');
94
+ if(versioned){
95
+ upserts.forEach(r=>r.expected_version=finoraExpectedVersion(r.collection+'|'+r.id,true));
96
+ deletes.forEach(r=>r.expected_version=finoraExpectedVersion(r.collection+'|'+r.id,false));
97
+ }
98
+ const args={p_upserts:upserts,p_deletes:deletes};
99
+ if(c.org||versioned)args.p_organization_id=c.org;
100
+ let result;
101
+ try{result=await finoraBoundedSyncRequest(sb.rpc(versioned?'finora_sync_records_v2':'finora_sync_records',args),'FINORA_SYNC_WRITE_UNCERTAIN');}
102
+ catch(e){throw finoraSyncIssue('FINORA_SYNC_WRITE_UNCERTAIN');}
103
+ finoraAssertSyncContext(c);
104
+ if(result?.error){
105
+ if(versioned){const e=finoraSyncIssue(result.error.code==='40001'?'FINORA_SYNC_VERSION_CONFLICT':'FINORA_SYNC_WRITE_REJECTED');throw e;}
106
+ throw result.error;
107
+ }
108
+ if(!result||typeof result!=='object'||result.error!==null)throw finoraSyncIssue('FINORA_SYNC_ACK_INVALID');
109
+ if(versioned)finoraValidateSyncAck(result.data,upserts,deletes);
110
+ // Validate the entire response before publishing any acknowledgement.
111
+ if(versioned)result.data.upserts.forEach(r=>versionSnap.set(r.collection+'|'+r.id,r.version));
112
+ up.forEach(r=>syncSnap.set(r.key,r.s));
113
+ deletes.forEach(r=>{const key=r.collection+'|'+r.id;syncSnap.delete(key);versionSnap.delete(key);});
114
+}
115
let syncTimer=null,syncRunning=false,syncAgain=false,syncPending=false,syncFailCount=0;
116
117
function keyOfRecord(coll,item){return coll==='settings'?'main':String(item&&item.id!=null?item.id:'');}
118
function stripOwner(item){const c=Object.assign({},item);delete c.ownerUserId;return c;}
119
function setSyncBadge(state){
120
const el=document.getElementById('sync-badge');if(!el)return;
27
- const map={saved:['✔ ذخیره شد','#059669'],saving:['⏳ در حال ذخیره…','#d97706'],error:['⚠️ ذخیره نشد؛ تلاش مجدد…','#dc2626']};
121
+ const map={saved:['✔ ذخیره شد','#059669'],saving:['⏳ در حال ذخیره…','#d97706'],error:['⚠️ ذخیره نشد؛ تلاش مجدد…','#dc2626'],conflict:['⚠️ ذخیره تأیید نشد؛ تغییرات محفوظ است','#dc2626']};
122
const m=map[state];if(!m)return;
123
el.textContent=m[0];el.style.background=m[1];el.style.display='block';
124
clearTimeout(setSyncBadge._t);
125
if(state==='saved')setSyncBadge._t=setTimeout(()=>{el.style.display='none';},2000);
126
}
127
async function pullAll({signal}={}){
34
- const uid=currentUser.id;
128
+ const context=finoraSyncContext(),uid=context.uid;
129
const fresh={};COLLS.forEach(k=>{fresh[k]=[];});
36
- const snap=new Map();
130
+ const snap=new Map(),versions=new Map();
131
const page=1000;let from=0;
132
for(;;){
39
- let request=sb.from('records').select('collection,id,data').order('collection').order('id').range(from,from+page-1);
133
+ let request=sb.from('records').select('*').order('collection').order('id').range(from,from+page-1);
134
if(signal&&typeof request.abortSignal==='function')request=request.abortSignal(signal);
135
const {data,error}=await finoraAbortableRead(request,signal);
136
if(signal?.aborted)throw new Error('FINORA_LOGIN_READ_TIMEOUT');
@@ -46,6 +140,7 @@ async function pullAll({signal}={}){
140
const obj=(r.data&&typeof r.data==='object'&&!Array.isArray(r.data))?r.data:{};
141
obj.id=r.id;
142
snap.set(r.collection+'|'+r.id,JSON.stringify(stripOwner(obj)));
143
+ finoraCaptureVersion(r,versions);
144
obj.ownerUserId=uid;
145
fresh[r.collection].push(obj);
146
});
@@ -55,8 +150,7 @@ async function pullAll({signal}={}){
150
// A timed-out restore must never replace current local data from a late
151
// response or publish a partial snapshot; writes still use existing guards.
152
if(signal?.aborted)throw new Error('FINORA_LOGIN_READ_TIMEOUT');
58
- datastore=fresh;
59
- syncSnap.clear();snap.forEach((v,k)=>syncSnap.set(k,v));
153
+ finoraPublishSyncSnapshot(fresh,snap,versions,context);
154
}
155
function computeDiff(){
156
const uid=currentUser.id;const up=[];const seen=new Set();
@@ -76,21 +170,16 @@ async function runSync(){
170
if(!currentUser)return;
171
if(syncRunning){syncAgain=true;return;}
172
syncRunning=true;
173
+ const context=finoraSyncContext();
174
try{
175
let guardLoops=0;
176
do{
177
syncAgain=false;
178
+ finoraAssertSyncSnapshot(context);
179
const {up,del}=computeDiff();
180
if(up.length===0&&del.length===0)break;
181
setSyncBadge('saving');
86
- const deletes=del.map(k=>{const j=k.indexOf('|');return {collection:k.slice(0,j),id:k.slice(j+1)};});
87
- const {error}=await sb.rpc('finora_sync_records',{
88
- p_upserts:up.map(r=>({collection:r.coll,id:r.id,data:r.payload})),
89
- p_deletes:deletes
90
- });
91
- if(error)throw error;
92
- up.forEach(r=>syncSnap.set(r.key,r.s));
93
- deletes.forEach(r=>syncSnap.delete(r.collection+'|'+r.id));
182
+ await finoraWriteSyncBatch(up,del,context);
183
syncFailCount=0;
184
guardLoops++;
185
}while(guardLoops<5);
@@ -98,11 +187,30 @@ async function runSync(){
187
syncPending=(d.up.length>0||d.del.length>0);
188
if(syncPending){scheduleSync(500);}else{setSyncBadge('saved');}
189
}catch(err){
101
- console.error('sync error',err);
102
- await handleSyncError(err);
103
- }finally{syncRunning=false;}
190
+ if(finoraSyncContextMatches(context)){
191
+ console.error('sync error',err);
192
+ await handleSyncError(err);
193
+ }
194
+ }finally{
195
+ syncRunning=false;
196
+ // A newer account/snapshot may have queued its save behind this request.
197
+ // Release that work only after the stale request relinquishes the lock;
198
+ // same-context uncertain/conflicting writes must not gain an automatic retry.
199
+ if(!finoraSyncContextMatches(context)&¤tUser&&syncAgain){
200
+ syncAgain=false;scheduleSync(0);
201
+ }else if(!finoraSyncContextMatches(context)&¤tUser?.id===context.uid&&(currentUser?.organizationId||null)===context.org&&finoraHydratedTenant===finoraTenantKey(context)){
202
+ const pending=computeDiff();
203
+ if(pending.up.length||pending.del.length){syncPending=true;setSyncBadge('conflict');}
204
+ }
205
+ }
206
}
207
async function handleSyncError(err){
208
+ if(err?.finoraPreservePending||err?.code==='40001'){
209
+ clearTimeout(syncTimer);syncPending=true;syncFailCount=0;setSyncBadge('conflict');
210
+ const conflict=err.code==='FINORA_SYNC_VERSION_CONFLICT'||err.code==='40001';
211
+ alert(conflict?'این اطلاعات همزمان تغییر کرده است؛ ویرایش شما حفظ شد ولی ذخیره نشد. پیش از بارگذاری مجدد، تغییرات را برای مقایسه نگه دارید.':'ذخیره روی سرور تأیید نشد؛ ویرایش شما در این صفحه حفظ شده است. پیش از خروج یا بارگذاری مجدد، تغییرات را نگه دارید و اتصال و وضعیت ذخیره را بررسی کنید.');
212
+ return;
213
+ }
214
const msg=String((err&&err.message)||''),code=String((err&&err.code)||'');
215
if(code==='42501'||/row-level security/i.test(msg)){
216
setSyncBadge('error');
scripts/accounting-document-workflow.spec.js
+2
-1
@@ -50,7 +50,7 @@ async function authenticatedMockBrowser(page){
50
maybeMigrateLegacyData=()=>{};
51
sb.from=collection=>({
52
select:()=>({
53
- order(){return this;},
53
+ order(){return this;},eq(){return this;},
54
async range(from,to){const rows=(await window.qaF0Read()).filter(r=>r.collection).sort((a,b)=>a.collection.localeCompare(b.collection)||a.id.localeCompare(b.id));return {data:rows.slice(from,to+1),error:null};}
55
})
56
});
@@ -61,6 +61,7 @@ async function authenticatedMockBrowser(page){
61
};
62
await enterApp({id:'FINORA_F0_FIXTURE_ONLY'});
63
currentUser.organizationId='QA_ORG';
64
+ await pullAll();refreshAllSurfaces();
65
document.querySelectorAll('.modal-backdrop.active').forEach(x=>x.classList.remove('active'));
66
switchView('view-invoices');
67
});
scripts/dom-smoke.spec.js
+3
-1
@@ -163,6 +163,7 @@ test('operational settings persist warehouse, currency and costing with an accur
163
const request=route.request(),path=new URL(request.url()).pathname;
164
const headers={'access-control-allow-origin':'*','access-control-allow-headers':'*','access-control-allow-methods':'GET,POST,OPTIONS'};
165
if(request.method()==='OPTIONS')return route.fulfill({status:204,headers});
166
+ if(path==='/rest/v1/rpc/finora_journal_get_guard_mode')return route.fulfill({status:404,contentType:'application/json',headers,body:JSON.stringify({code:'PGRST202',message:'Function absent in isolated legacy fixture'})});
167
if(path==='/rest/v1/rpc/finora_sync_records'){
168
writes++;const args=request.postDataJSON();
169
for(const row of args.p_upserts||[])rows.set(row.collection+'|'+row.id,JSON.parse(JSON.stringify(row)));
@@ -174,9 +175,10 @@ test('operational settings persist warehouse, currency and costing with an accur
175
});
176
await page.goto(process.env.FINORA_TEST_BASE_URL||'http://127.0.0.1:4173/index.html',{waitUntil:'domcontentloaded'});
177
await page.waitForFunction(()=>window.FinoraStartupStatus?.extensionsReady===true&&window.FinoraStartupStatus?.failedExtensionCount===0&&window.FinoraStartupStatus?.authChecked===true);
177
- await page.evaluate(()=>{
178
+ await page.evaluate(async()=>{
179
window.alert=()=>{};window.confirm=()=>false;
180
currentUser={id:'QA_OPS_SETTINGS',role:'admin',modules:['full_suite'],subscription:{type:'lifetime',status:'active',endDate:'2099-01-01'}};
181
+ await pullAll();
182
const fresh={};COLLS.forEach(key=>fresh[key]=[]);datastore=fresh;syncSnap.clear();
183
datastore.companies=[{id:'QA_OPS_CO',ownerUserId:currentUser.id,name:'Operational Settings Fixture'}];
184
datastore.settings=[{id:'main',ownerUserId:currentUser.id,default_company_id:'QA_OPS_CO',defaultWarehouseId:'QA_WH_A',baseCurrencyCode:'IRR',inventoryCostMethod:'weighted_average'}];
scripts/login-connectivity-check.mjs
+1
-1
@@ -9,7 +9,7 @@ assert(html.includes('id="auth-connectivity-result" aria-live="polite"'),'Diagno
9
assert(html.includes('js/login-connectivity.js?v=20261026-preflight-compare-v5'),'Missing versioned script');
10
assert(html.includes('js/core.js?v=20261025-password-recovery-v1'),'Production login controls must use new cache version');
11
assert(html.indexOf('<script src="js/login-connectivity.js?v=20261026-preflight-compare-v5"')<html.indexOf('<script src="js/core.js?v=20261025-password-recovery-v1"'),'Connectivity handler script must execute before core (not just preload)');
12
-assert(html.includes('js/bootstrap.js?v=20261031-workspace-recovery-v1'),'Parallel bootstrap must also be cache-busted');
12
+assert(html.includes('js/bootstrap.js?v=20261103-versioned-sync-v1'),'Parallel bootstrap must also be cache-busted');
13
assert(html.includes('id="auth-login-button"')&&html.includes('id="auth-login-status"'),'Login control requires real readiness/progress feedback');
14
assert(core.includes('window.FinoraAppAssetsReady'),'Authenticated workspace must remain gated until all module scripts settle');
15
assert(core.includes('window.FinoraOrganizationContextReady')&&core.includes('organizationAccount'),'Profile and license lookup must wait for the organization account adapter');
scripts/office-slice-c8.spec.js
+4
-1
@@ -1,5 +1,8 @@
1
const {test,expect}=require('@playwright/test');
2
async function isolatePolicyEditor(page){
3
+ // Install synthetic identity/permissions only after the real async organization
4
+ // adapter has loaded; otherwise it can replace the fixture authority mid-form.
5
+ await page.waitForFunction(()=>window.FinoraStartupStatus?.extensionsReady===true&&window.FinoraStartupStatus?.failedExtensionCount===0&&window.FinoraStartupStatus?.authChecked===true);
6
await page.addStyleTag({content:'#auth-screen,.app-root{display:none!important;pointer-events:none!important}#c8-root{display:block!important;position:relative!important;z-index:2147483647!important}'});
7
}
8
test('Office C8 policy editor publishes a two-stage policy',async({page})=>{
@@ -61,7 +64,7 @@ test('Office C8 policy publish control is authority-safe',async({page})=>{
64
65
async function mountWorkflowPanel(page,rpcHandler){
66
await page.goto('http://127.0.0.1:4173/index.html',{waitUntil:'domcontentloaded'});
64
- await page.addStyleTag({content:'#auth-screen,.app-root{display:none!important;pointer-events:none!important}#c8-root{display:block!important;position:relative!important;z-index:2147483647!important}'});
67
+ await isolatePolicyEditor(page);
68
await page.evaluate(()=>{const root=document.createElement('div');root.id='c8-root';document.body.append(root)});
69
await page.evaluate((handlerSource)=>{
70
window.currentUser={organizationId:'aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa'};
scripts/phase0-invoice-persistence.spec.js
+1
@@ -48,6 +48,7 @@ async function authenticatedMockBrowser(page,companyId='QA_CO',url=BASE){
48
})
49
});
50
sb.rpc=async(name,args)=>{
51
+ if(name==='finora_journal_get_guard_mode')return {data:null,error:{code:'PGRST202'}};
52
if(name!=='finora_sync_records')throw Error('Unexpected RPC '+name);
53
return await window.qaF0Write(args);
54
};
scripts/phase3-check.mjs
+1
-1
@@ -7,7 +7,7 @@ need(u,['view-journal','jeSaveManual','jePostUi','jeReverseUi','je-trial'],'ui')
7
for(const x of ['postingProfiles','journalVouchers','journalLines','journalLineDimensions']){if(!c.includes("'"+x+"'")||!s.includes(x)||!b.includes(x))throw new Error('persistence missing '+x)}
8
need(i,['journal-engine.js?v=20261007-p0-r1','journal-ui.js?v=20261011-doc-manager-v1','document-management.js?v=20261011-doc-manager-v1'],'index');
9
need(inv,['function invoiceDocumentStatus','function finalizeInvoiceDocument','accountingStatus:\'draft\'','documentStatus:\'draft\''],'invoice draft and explicit posting');
10
-need(s,["sb.rpc('finora_sync_records'",'p_upserts','p_deletes'],'atomic sync');
10
+need(s,["sb.rpc(versioned?'finora_sync_records_v2':'finora_sync_records',args)",'p_upserts','p_deletes','await finoraWriteSyncBatch(up,del,context)','finoraValidateSyncAck(result.data,upserts,deletes)'],'atomic legacy/versioned sync');
11
need(pay,["date:old?.date||getJalaliNumeric()"],'payment fiscal date');
12
need(inv,['invoiceCreatesAccountingEntry',"kind==='formal'||kind==='non_formal'"],'invoice posting semantics');
13
need(exp,['jePostSourceRecord(kind,record)','contactId','projectId','accountingVersion:1'],'expense/income posting semantics');
scripts/ux-hardening-r2.spec.js
+1
-1
@@ -32,7 +32,7 @@ async function signInSettings(page,user=SETTINGS_USER){
32
window.alert=()=>{};window.confirm=()=>false;maybeMigrateLegacyData=()=>{};
33
fetchCurrentUser=async auth=>({id:auth.id,fullName:'آزمون تنظیمات',role:'admin',modules:['full_suite'],subscription:{type:'lifetime',status:'active',endDate:'2099-01-01'}});
34
sb.from=()=>({select:()=>({order(){return this},async range(from,to){return {data:(await window.qaSettingsRead(currentUser.id)).slice(from,to+1),error:null}}})});
35
- sb.rpc=async(name,args)=>{if(name!=='finora_sync_records')throw new Error('Unexpected settings RPC');return window.qaSettingsWrite(currentUser.id,args)};
35
+ sb.rpc=async(name,args)=>{if(name==='finora_journal_get_guard_mode')return {data:null,error:{code:'PGRST202'}};if(name!=='finora_sync_records')throw new Error('Unexpected settings RPC');return window.qaSettingsWrite(currentUser.id,args)};
36
sb.auth.signOut=async()=>{await window.qaSettingsSignOut();return {error:null}};
37
await enterApp({id});navigateShell('settings','view-settings','experience');
38
},user);
scripts/wp1-client-capability-test.mjs
new
+186
@@ -0,0 +1,186 @@
1
+import fs from 'node:fs';
2
+import vm from 'node:vm';
3
+import assert from 'node:assert/strict';
4
+import test from 'node:test';
5
+function fixture({mode='audit',missing=false,orgWrapper=false}={}){
6
+ const calls=[],reads=[];const state={mode,missing,readError:null,probeError:null,writeError:null,ack:null,probeHook:null,writeHook:null,rows:[{collection:'companies',id:'C',data:{name:'before'},version:4,organization_id:'O'}]};
7
+ const c={console:{error(){},warn(){}},Map,Set,JSON,Promise,Number,String,Array,Date,Math,setTimeout:()=>1,clearTimeout(){},setInterval(){},
8
+ currentUser:{id:'U',organizationId:'O'},COLLS:['companies','settings','journalVouchers','journalLines','journalLineDimensions'],ID_RE:/^[A-Za-z0-9_-]+$/,
9
+ document:{getElementById:()=>null,addEventListener(){},querySelectorAll:()=>[]},localStorage:{getItem:()=>null,removeItem(){},setItem(){}},
10
+ enterApp:async()=>{},fetchCurrentUser:async()=>c.currentUser,canWrite:()=>true,requireWrite:()=>true,refreshAllSurfaces(){},alert(){},finoraAbortableRead:async(p)=>p,finoraTrackLoginRead:async(s,p)=>p};
11
+ c.window=c;c.addEventListener=()=>{};
12
+ c.sb={rpc:async(name,args)=>{
13
+ calls.push({name,args});
14
+ if(name==='finora_journal_get_guard_mode'){
15
+ if(state.probeHook)await state.probeHook();
16
+ return state.probeError?{error:state.probeError}:state.missing?{error:{code:'PGRST202'}}:{data:state.mode,error:null};
17
+ }
18
+ if(state.writeHook)await state.writeHook();
19
+ if(state.writeError)return {error:state.writeError};
20
+ return {error:null,data:(state.explicitAck||state.ack)?state.ack:{upserts:(args.p_upserts||[]).map(r=>({collection:r.collection,id:r.id,version:(r.expected_version||0)+1})),deletes:args.p_deletes||[]}};
21
+ },from(table){let columns='';const q={select(s){columns=s;return q;},eq(){return q;},order(){return q;},abortSignal(){return q;},range(){reads.push({table,columns});return Promise.resolve(state.readError?{error:state.readError}:{data:structuredClone(state.rows),error:null});}};return q;}};
22
+ vm.createContext(c);vm.runInContext(fs.readFileSync('js/sync.js','utf8'),c);
23
+
24
+ if(orgWrapper)vm.runInContext(fs.readFileSync('js/organization-rbac.js','utf8'),c);
25
+ const evalCode=s=>vm.runInContext(s,c);
26
+ return {c,state,calls,reads,evalCode};
27
+}
28
+test('confirmed absent server uses legacy columns and legacy sync',async()=>{
29
+ const f=fixture({missing:true});delete f.state.rows[0].version;await f.c.pullAll();f.evalCode("datastore.companies[0].name='changed'");await f.c.runSync();
30
+ assert.ok(f.reads.every(x=>!x.columns.split(',').includes('version')));assert.equal(f.calls.at(-1).name,'finora_sync_records');
31
+});
32
+test('present capability loads versions and uses versioned sync acknowledgement',async()=>{
33
+ const f=fixture();await f.c.pullAll();assert.equal(f.reads[0].columns,'*');assert.equal(f.calls.length,0);
34
+ f.evalCode("datastore.companies[0].name='changed'");await f.c.runSync();assert.equal(f.calls.at(-1).name,'finora_sync_records_v2');
35
+ assert.equal(f.calls.at(-1).args.p_upserts[0].expected_version,4);assert.equal(f.evalCode("versionSnap.get('companies|C')"),5);
36
+});
37
+test('transport probe errors preserve pending edits without a legacy write',async()=>{
38
+ const f=fixture();await f.c.pullAll();f.evalCode("datastore.companies[0].name='unsaved'");f.state.probeError={code:'NETWORK',message:'provider private'};await f.c.runSync();
39
+ assert.equal(f.calls.length,1);assert.equal(f.evalCode('datastore.companies[0].name'),'unsaved');assert.equal(f.evalCode('computeDiff().up.length'),1);
40
+});
41
+test('partial server with no row version fails before write',async()=>{
42
+ const f=fixture();delete f.state.rows[0].version;await f.c.pullAll();f.evalCode("datastore.companies[0].name='unsaved'");await f.c.runSync();assert.equal(f.calls.length,1);
43
+});
44
+test('account switch during probe cannot send old edits',async()=>{
45
+ const f=fixture();await f.c.pullAll();f.evalCode("datastore.companies[0].name='changed'");f.state.probeHook=async()=>{f.c.currentUser={id:'B',organizationId:'B'};};await f.c.runSync();assert.equal(f.calls.length,1);
46
+});
47
+test('old-organization write acknowledgement cannot overwrite new snapshot',async()=>{
48
+ const f=fixture();await f.c.pullAll();f.evalCode("datastore.companies[0].name='changed'");
49
+ f.state.writeHook=async()=>{f.c.currentUser={id:'B',organizationId:'B'};f.evalCode("syncSnap.clear();syncSnap.set('companies|B','new-tenant')");};
50
+ await f.c.runSync();assert.equal(f.evalCode("syncSnap.has('companies|C')"),false);assert.equal(f.evalCode("syncSnap.get('companies|B')"),'new-tenant');
51
+});
52
+test('incomplete upsert acknowledgement cannot mark pending changes saved',async()=>{
53
+ const f=fixture();await f.c.pullAll();f.evalCode("datastore.companies[0].name='changed'");f.state.ack={upserts:[],deletes:[]};await f.c.runSync();
54
+ assert.equal(f.evalCode("JSON.parse(syncSnap.get('companies|C')).name"),'before');assert.equal(f.evalCode('computeDiff().up.length'),1);
55
+});
56
+test('incomplete delete acknowledgement cannot erase snapshot',async()=>{
57
+ const f=fixture();await f.c.pullAll();f.evalCode('datastore.companies=[]');f.state.ack={upserts:[],deletes:[]};await f.c.runSync();assert.equal(f.evalCode("syncSnap.has('companies|C')"),true);
58
+});
59
+test('missing V2 write RPC never silently downgrades to legacy write',async()=>{
60
+ const f=fixture();await f.c.pullAll();f.evalCode("datastore.companies[0].name='changed'");f.state.writeError={code:'PGRST202'};await f.c.runSync();
61
+ assert.equal(f.calls.filter(x=>x.name==='finora_sync_records').length,0);assert.equal(f.evalCode('computeDiff().up.length'),1);
62
+});
63
+test('new server capability requires fresh versions without discarding pending edits',async()=>{
64
+ const f=fixture({missing:true});delete f.state.rows[0].version;await f.c.pullAll();f.state.missing=false;f.evalCode("datastore.companies[0].name='unsaved'");await f.c.runSync();
65
+ assert.equal(f.calls.filter(x=>x.name==='finora_sync_records_v2').length,0);assert.equal(f.evalCode('datastore.companies[0].name'),'unsaved');
66
+});
67
+test('organization wrapper uses same capability and versioned protocol',async()=>{
68
+ const f=fixture({orgWrapper:true});await f.c.pullAll();assert.equal(f.reads[0].columns,'*');assert.equal(f.calls.length,0);f.evalCode("datastore.companies[0].name='changed'");await f.c.runSync();
69
+ assert.equal(f.calls.at(-1).name,'finora_sync_records_v2');assert.equal(f.calls.at(-1).args.p_organization_id,'O');assert.equal(f.calls.at(-1).args.p_upserts[0].expected_version,4);
70
+});
71
+
72
+for(const orgWrapper of [false,true]){
73
+ test(`late read cannot publish across identity switch (org wrapper ${orgWrapper})`,async()=>{
74
+ const f=fixture({orgWrapper});const p=f.c.pullAll();f.c.currentUser={id:'B',organizationId:'B'};await assert.rejects(p);assert.equal(f.evalCode('datastore.companies.length'),0);
75
+ });
76
+ test(`CAS conflict preserves edits without reload or retry (org wrapper ${orgWrapper})`,async()=>{
77
+ const f=fixture({orgWrapper});await f.c.pullAll();f.evalCode("datastore.companies[0].name='unsaved'");f.state.writeError={code:'40001',message:'FINORA_VERSION_CONFLICT'};await f.c.runSync();
78
+ assert.equal(f.evalCode('datastore.companies[0].name'),'unsaved');assert.equal(f.evalCode('syncPending'),true);assert.equal(f.reads.length,1);assert.equal(f.evalCode("versionSnap.get('companies|C')"),4);
79
+ });
80
+}
81
+for(const ack of [
82
+ {upserts:[{collection:'companies',id:'C',version:5},{collection:'companies',id:'C',version:5}],deletes:[]},
83
+ {upserts:[{collection:'companies',id:'C',version:4}],deletes:[]},
84
+ {upserts:[{collection:'companies',id:'C',version:'5'}],deletes:[]},
85
+ {upserts:[{collection:'companies',id:'other',version:5}],deletes:[]},
86
+ {upserts:[{collection:'companies',id:'C',version:5}],deletes:[{collection:'companies',id:'C'}]},
87
+ null
88
+])test(`malformed acknowledgement stays pending: ${JSON.stringify(ack)}`,async()=>{
89
+ const f=fixture();await f.c.pullAll();f.evalCode("datastore.companies[0].name='unsaved'");f.state.ack=ack;f.state.explicitAck=true;await f.c.runSync();
90
+ assert.equal(f.evalCode('computeDiff().up.length'),1);assert.equal(f.evalCode('syncPending'),true);
91
+});
92
+test('positive version evidence prevents falling back when probe disappears',async()=>{
93
+ const f=fixture({missing:true});await f.c.pullAll();f.evalCode("datastore.companies[0].name='changed'");await f.c.runSync();assert.equal(f.calls.filter(x=>x.name==='finora_sync_records').length,0);
94
+});
95
+test('new record uses version zero and deletion acknowledges exact identity',async()=>{
96
+ const f=fixture();await f.c.pullAll();f.evalCode("datastore.companies=[{id:'NEW',ownerUserId:'U',name:'new'}]");await f.c.runSync();
97
+ const args=f.calls.at(-1).args;assert.equal(args.p_upserts[0].expected_version,0);assert.equal(args.p_deletes[0].expected_version,4);
98
+ assert.equal(f.evalCode("versionSnap.get('companies|NEW')"),1);assert.equal(f.evalCode("syncSnap.has('companies|C')"),false);assert.equal(f.evalCode('computeDiff().up.length'),0);
99
+});
100
+test('edits made during write stay pending and use returned version on next batch',async()=>{
101
+ const f=fixture();await f.c.pullAll();f.evalCode("datastore.companies[0].name='first'");let n=0;f.state.writeHook=async()=>{if(n++===0)f.evalCode("datastore.companies[0].name='second'")};await f.c.runSync();
102
+ const writes=f.calls.filter(x=>x.name==='finora_sync_records_v2');assert.equal(writes.length,2);assert.equal(writes[1].args.p_upserts[0].expected_version,5);assert.equal(f.evalCode("versionSnap.get('companies|C')"),6);
103
+});
104
+test('malformed guard mode cannot authorize a write',async()=>{
105
+ const f=fixture({mode:null});await f.c.pullAll();f.evalCode("datastore.companies[0].name='unsaved'");await f.c.runSync();assert.equal(f.calls.length,1);assert.equal(f.evalCode('syncPending'),true);
106
+});
107
+for(const version of [null,0,-1,1.5,'4',Number.MAX_SAFE_INTEGER+1])test(`invalid persisted revision cannot downgrade to legacy: ${version}`,async()=>{
108
+ const f=fixture({missing:true});f.state.rows[0].version=version;await assert.rejects(f.c.pullAll());assert.equal(f.evalCode('datastore.companies.length'),0);assert.equal(f.calls.length,0);
109
+});
110
+test('late acknowledgement after same-tenant refresh cannot replace fresh revisions',async()=>{
111
+ const f=fixture();await f.c.pullAll();f.evalCode("datastore.companies[0].name='changed'");
112
+ f.state.writeHook=async()=>{f.state.rows[0].version=9;f.state.rows[0].data.name='fresh';await f.c.pullAll();};await f.c.runSync();
113
+ assert.equal(f.evalCode("versionSnap.get('companies|C')"),9);assert.equal(f.evalCode("JSON.parse(syncSnap.get('companies|C')).name"),'fresh');
114
+});
115
+test('nested edits during capability probe cannot mutate the captured write payload',async()=>{
116
+ const f=fixture();f.state.rows[0].data.details={name:'old'};await f.c.pullAll();f.evalCode("datastore.companies[0].details.name='first'");
117
+ let n=0;f.state.probeHook=async()=>{if(n++===0)f.evalCode("datastore.companies[0].details.name='second'")};await f.c.runSync();
118
+ const writes=f.calls.filter(x=>x.name==='finora_sync_records_v2');assert.equal(writes.length,2);assert.equal(writes[0].args.p_upserts[0].data.details.name,'first');assert.equal(writes[1].args.p_upserts[0].data.details.name,'second');
119
+});
120
+for(const stage of ['probe','write'])test(`stalled ${stage} has a bounded failure and no late success`,async()=>{
121
+ const f=fixture();await f.c.pullAll();f.evalCode("datastore.companies[0].name='unsaved'");
122
+ const rpc=f.c.sb.rpc;let release;const pending=new Promise(resolve=>{release=resolve});
123
+ f.c.sb.rpc=(name,args)=>((stage==='probe'&&name==='finora_journal_get_guard_mode')||(stage==='write'&&name==='finora_sync_records_v2'))?pending:rpc(name,args);
124
+ let timerIndex=0;
125
+ f.c.setTimeout=fn=>{timerIndex++;if(stage==='probe'||timerIndex===2)queueMicrotask(fn);return timerIndex};
126
+ await f.c.runSync();assert.equal(f.evalCode('syncPending'),true);assert.equal(f.evalCode('computeDiff().up.length'),1);
127
+ release({error:null,data:stage==='probe'?'audit':{upserts:[{collection:'companies',id:'C',version:5}],deletes:[]}});await new Promise(resolve=>setImmediate(resolve));
128
+ assert.equal(f.evalCode("versionSnap.get('companies|C')"),4);assert.equal(f.evalCode('syncPending'),true);
129
+});
130
+test('duplicate pending identifiers fail before any write',async()=>{
131
+ const f=fixture();await f.c.pullAll();f.evalCode("datastore.companies.push({id:'C',ownerUserId:'U',name:'duplicate'});datastore.companies[0].name='changed'");await f.c.runSync();assert.equal(f.calls.length,1);assert.equal(f.evalCode('syncPending'),true);
132
+});
133
+for(const change of ['tenant','identity'])test(`queued save resumes after stale ${change} request releases sync lock`,async()=>{
134
+ const f=fixture({orgWrapper:true});await f.c.pullAll();f.evalCode("datastore.companies[0].name='first'");
135
+ const timers=new Map();let id=0;f.c.setTimeout=(fn,ms)=>{timers.set(++id,{fn,ms});return id};f.c.clearTimeout=id=>timers.delete(id);
136
+ let release,started;const held=new Promise(resolve=>release=resolve),entered=new Promise(resolve=>started=resolve);
137
+ // Identity-only case stalls before any write; tenant case stalls an old write.
138
+ if(change==='tenant')f.state.writeHook=async()=>{started();await held;};else f.state.probeHook=async()=>{started();await held;};
139
+ const oldRun=f.c.runSync();await entered;
140
+ if(change==='tenant'){
141
+ f.c.currentUser={id:'B',organizationId:'B'};f.state.rows=[{collection:'companies',id:'B',data:{name:'before-B'},version:9,organization_id:'B'}];await f.c.pullAll();
142
+ }else f.c.currentUser={...f.c.currentUser};
143
+ f.evalCode("datastore.companies[0].name='second';saveDatastore()");
144
+ const queued=[...timers.entries()].find(([,t])=>t.ms===300);assert.ok(queued);timers.delete(queued[0]);await queued[1].fn();
145
+ release();await oldRun;f.state.writeHook=null;f.state.probeHook=null;
146
+ assert.equal(f.evalCode('syncPending'),true);assert.equal(timers.size,1);
147
+ const [retryId,retry]=[...timers.entries()][0];assert.ok(retry.ms<=500);timers.delete(retryId);await retry.fn();
148
+ assert.equal(f.calls.at(-1).args.p_organization_id,change==='tenant'?'B':'O');assert.equal(f.calls.at(-1).args.p_upserts[0].data.name,'second');assert.equal(f.evalCode('computeDiff().up.length'),0);
149
+});
150
+test('same-context CAS rejection does not automatically retry queued edits',async()=>{
151
+ const f=fixture();await f.c.pullAll();f.evalCode("datastore.companies[0].name='unsaved'");
152
+ const timers=new Map();let id=0;f.c.setTimeout=(fn,ms)=>{timers.set(++id,{fn,ms});return id};f.c.clearTimeout=id=>timers.delete(id);
153
+ f.state.writeHook=async()=>{await f.c.runSync()};f.state.writeError={code:'40001'};await f.c.runSync();
154
+ assert.equal(timers.size,0);assert.equal(f.evalCode('syncPending'),true);assert.equal(f.evalCode('datastore.companies[0].name'),'unsaved');
155
+});
156
+test('same user cannot dispatch old-organization edits while new organization is loading',async()=>{
157
+ const f=fixture({orgWrapper:true});await f.c.pullAll();f.evalCode("datastore.companies[0].name='first'");
158
+ const timers=new Map();let id=0;f.c.setTimeout=(fn,ms)=>{timers.set(++id,{fn,ms});return id};f.c.clearTimeout=id=>timers.delete(id);
159
+ let release,started;const held=new Promise(resolve=>release=resolve),entered=new Promise(resolve=>started=resolve);
160
+ f.state.writeHook=async()=>{started();await held};const oldRun=f.c.runSync();await entered;
161
+ f.evalCode("datastore.companies[0].name='old-org-secret';saveDatastore()");const queued=[...timers.entries()].find(([,t])=>t.ms===300);timers.delete(queued[0]);await queued[1].fn();
162
+ f.c.currentUser={id:'U',organizationId:'B'};
163
+ let finishRead;const read=new Promise(resolve=>finishRead=resolve);
164
+ f.c.sb.from=()=>{const q={select(){return q},eq(){return q},order(){return q},range(){return read}};return q};const newPull=f.c.pullAll();
165
+ release();await oldRun;f.state.writeHook=null;
166
+ for(const [key,timer] of [...timers]){timers.delete(key);await timer.fn()}
167
+ assert.equal(f.calls.filter(x=>x.name==='finora_sync_records_v2').length,1);
168
+ assert.equal(f.calls.filter(x=>x.args.p_organization_id==='B').length,0);
169
+ finishRead({data:[{collection:'companies',id:'C',data:{name:'new-org-data'},version:4}],error:null});await newPull;
170
+ f.evalCode("datastore.companies[0].name='new-org-edit'");await f.c.runSync();assert.equal(f.calls.at(-1).args.p_organization_id,'B');assert.equal(f.calls.at(-1).args.p_upserts[0].data.name,'new-org-edit');
171
+});
172
+test('direct same-user organization change cannot write before its own snapshot',async()=>{
173
+ const f=fixture();await f.c.pullAll();f.evalCode("datastore.companies[0].name='old-org'");f.c.currentUser={id:'U',organizationId:'B'};await f.c.runSync();assert.equal(f.calls.length,0);
174
+});
175
+test('identity refresh without queued save marks unconfirmed edits instead of endless saving',async()=>{
176
+ const f=fixture();await f.c.pullAll();const badges=[];f.c.setSyncBadge=state=>badges.push(state);
177
+ f.evalCode("datastore.companies[0].name='unsaved';syncPending=true");
178
+ f.state.writeHook=async()=>{f.c.currentUser={...f.c.currentUser}};await f.c.runSync();
179
+ assert.equal(badges.at(-1),'conflict');assert.equal(f.evalCode('syncPending'),true);assert.equal(f.evalCode("versionSnap.get('companies|C')"),4);assert.equal(f.calls.filter(x=>x.name==='finora_sync_records_v2').length,1);
180
+});
181
+test('stale identity status preserves a newer save timer that has not fired',async()=>{
182
+ const f=fixture();await f.c.pullAll();f.evalCode("datastore.companies[0].name='first'");
183
+ const timers=new Map();let id=0;f.c.setTimeout=(fn,ms)=>{timers.set(++id,{fn,ms});return id};f.c.clearTimeout=id=>timers.delete(id);
184
+ f.state.writeHook=async()=>{f.c.currentUser={...f.c.currentUser};f.evalCode("datastore.companies[0].name='second';saveDatastore()")};await f.c.runSync();
185
+ assert.equal(timers.size,1);assert.equal([...timers.values()][0].ms,300);assert.equal(f.evalCode('syncPending'),true);assert.equal(f.evalCode('datastore.companies[0].name'),'second');assert.equal(f.calls.filter(x=>x.name==='finora_sync_records_v2').length,1);
186
+});
scripts/wp1-client-sync.spec.js
new
+90
@@ -0,0 +1,90 @@
1
+const {test,expect}=require('@playwright/test');
2
+const BASE=process.env.FINORA_TEST_BASE_URL||'http://127.0.0.1:4173/index.html';
3
+
4
+async function fixture(page){
5
+ await page.route(/https:\/\/[^/]*supabase\.co\//,route=>route.abort());
6
+ await page.goto(BASE,{waitUntil:'domcontentloaded'});
7
+ await page.waitForFunction(()=>window.FinoraStartupStatus?.extensionsReady&&window.FinoraStartupStatus?.authChecked);
8
+ await page.evaluate(async()=>{
9
+ window.__syncQA={calls:[],reads:0,alerts:[],mode:'audit',ack:'complete',error:null,rows:[{collection:'companies',id:'QA_CO',data:{name:'before'},version:4,organization_id:'QA_ORG'}]};
10
+ window.alert=m=>__syncQA.alerts.push(String(m));
11
+ currentUser={id:'QA_USER',organizationId:'QA_ORG'};
12
+ sb.from=()=>{
13
+ const q={select(){return q},eq(){return q},order(){return q},abortSignal(){return q},async range(){__syncQA.reads++;return {data:JSON.parse(JSON.stringify(__syncQA.rows)),error:null}}};return q;
14
+ };
15
+ sb.rpc=async(name,args)=>{
16
+ __syncQA.calls.push({name,args:JSON.parse(JSON.stringify(args))});
17
+ if(name==='finora_journal_get_guard_mode')return __syncQA.mode==='missing'?{error:{code:'PGRST202'},data:null}:{data:__syncQA.mode,error:null};
18
+ if(__syncQA.switchTenant){currentUser={id:'OTHER',organizationId:'OTHER_ORG'};syncSnap.clear();syncSnap.set('companies|OTHER','new-tenant');return {data:null,error:null};}
19
+ if(__syncQA.error)return {error:__syncQA.error,data:null};
20
+ if(name==='finora_sync_records')return {data:null,error:null};
21
+ return {error:null,data:{upserts:__syncQA.ack==='complete'?args.p_upserts.map(r=>({collection:r.collection,id:r.id,version:r.expected_version+1})):[],deletes:args.p_deletes}};
22
+ };
23
+ await pullAll();
24
+ });
25
+}
26
+
27
+test('versioned sync saves only after complete acknowledgement without login probe',async({page})=>{
28
+ await fixture(page);
29
+ expect(await page.evaluate(()=>__syncQA.calls.length)).toBe(0);
30
+ await page.evaluate(async()=>{datastore.companies[0].name='changed';await runSync()});
31
+ await expect(page.locator('#sync-badge')).toContainText('ذخیره شد');
32
+ expect(await page.evaluate(()=>({name:__syncQA.calls.at(-1).name,version:versionSnap.get('companies|QA_CO'),pending:syncPending}))).toEqual({name:'finora_sync_records_v2',version:5,pending:false});
33
+});
34
+
35
+for(const failure of ['partial-ack','conflict','forbidden'])test(`pending edits survive ${failure} with no success badge or reload`,async({page})=>{
36
+ await fixture(page);
37
+ await page.evaluate(async failure=>{
38
+ if(failure==='partial-ack')__syncQA.ack='partial';
39
+ else __syncQA.error={code:failure==='conflict'?'40001':'42501',message:'isolated rejection'};
40
+ datastore.companies[0].name='unsaved';await runSync();
41
+ },failure);
42
+ await expect(page.locator('#sync-badge')).toContainText('ذخیره تأیید نشد');
43
+ expect(await page.evaluate(()=>({name:datastore.companies[0].name,version:versionSnap.get('companies|QA_CO'),pending:syncPending,reads:__syncQA.reads,changed:computeDiff().up.length}))).toEqual({name:'unsaved',version:4,pending:true,reads:1,changed:1});
44
+});
45
+
46
+test('legacy schema remains usable with explicitly absent capability',async({page})=>{
47
+ await fixture(page);
48
+ await page.evaluate(async()=>{
49
+ // Independent old-server tenant: no cached versioned capability or revision.
50
+ currentUser={id:'LEGACY_USER',organizationId:'LEGACY_ORG'};
51
+ delete __syncQA.rows[0].version;__syncQA.mode='missing';await pullAll();
52
+ datastore.companies[0].name='legacy edit';await runSync();
53
+ });
54
+ await expect(page.locator('#sync-badge')).toContainText('ذخیره شد');
55
+ expect(await page.evaluate(()=>__syncQA.calls.at(-1).name)).toBe('finora_sync_records');
56
+});
57
+
58
+test('late response cannot acknowledge an old organization inside a new one',async({page})=>{
59
+ await fixture(page);
60
+ await page.evaluate(async()=>{__syncQA.switchTenant=true;datastore.companies[0].name='changed';await runSync()});
61
+ expect(await page.evaluate(()=>({old:syncSnap.has('companies|QA_CO'),other:syncSnap.get('companies|OTHER'),alerts:__syncQA.alerts.length}))).toEqual({old:false,other:'new-tenant',alerts:0});
62
+ await expect(page.locator('#sync-badge')).not.toContainText('✔ ذخیره شد');
63
+});
64
+
65
+test('same-user organization transition never sends the previous snapshot',async({page})=>{
66
+ await fixture(page);
67
+ await page.evaluate(async()=>{
68
+ datastore.companies[0].name='old organization private edit';
69
+ currentUser={id:'QA_USER',organizationId:'NEW_ORG'};
70
+ await runSync();
71
+ });
72
+ expect(await page.evaluate(()=>__syncQA.calls.length)).toBe(0);
73
+ await expect(page.locator('#sync-badge')).toContainText('ذخیره تأیید نشد');
74
+ expect(await page.evaluate(()=>datastore.companies[0].name)).toBe('old organization private edit');
75
+});
76
+
77
+test('identity refresh during a save ends with an unconfirmed badge and retained edits',async({page})=>{
78
+ await fixture(page);
79
+ await page.evaluate(async()=>{
80
+ const original=sb.rpc;
81
+ sb.rpc=async(name,args)=>{
82
+ const result=await original(name,args);
83
+ if(name==='finora_sync_records_v2')currentUser={...currentUser};
84
+ return result;
85
+ };
86
+ datastore.companies[0].name='not acknowledged';syncPending=true;await runSync();
87
+ });
88
+ await expect(page.locator('#sync-badge')).toContainText('ذخیره تأیید نشد');
89
+ expect(await page.evaluate(()=>({pending:syncPending,name:datastore.companies[0].name,version:versionSnap.get('companies|QA_CO')}))).toEqual({pending:true,name:'not acknowledged',version:4});
90
+});