سامانه صدور فاکتور و حسابداری

feature/finora-phase1a-supabase-cli-20261016
audit-remediation-wave3-4-20261002 audit-remediation-wave3-verify-20261002 audit-remediation-wave4-20261002 audit-remediation-wave4b-20261002 audit-remediation-wave5a-identity-20261002 audit-remediation-wave5b-offboarding-20261002 audit-remediation-wave5c-authorization-20261002 audit-security-intent-review-20261002 audit/finora-financial-core-20261115 audit/finora-master-prompt-phase0-20261016 audit/finora-stage3-legacy-source-readonly-20261023 audit/full-controls-20261030 audit/owner-live-state-reconcile-20261012 audit/owner-review-20261007 audit/phase1-live-permissions-readonly-20261013 audit/reconcile-live-state-20261006 audit/reconcile-state-20261002 audit/wp0-hardening-baseline-20261102 branding-login-favicon-20261002 c8-workflow-task1 c8-workflow-task2 c8-workflow-task3 chore/wave0-pages-gate-closeout claude-code-plugins-setup design/finora-c01-authoritative-source-draft-20261124 docs-wave4b-verified-20261002 docs/active-company-invoice-release-evidence-20261014 docs/agent-operating-model-20261114 docs/chart-taxpayer-release-evidence-20261004 docs/cloud-only-agent-orchestration-20261115 docs/confirm-finora-product-charter-20261115 docs/continuation-20261030 docs/d4a-verified docs/external-work-review-20261121 docs/finora-audit-continuity-20261014 docs/finora-backup-merge-evidence-20261014 docs/finora-ci-reconciliation-20261122 docs/finora-codex-master-prompt docs/finora-eight-phase-plan-20261011 docs/finora-f002-live-buyer-filter-verified-20261015 docs/finora-license-race-release-evidence-20261014 docs/finora-license-rollout-acceptance-20261015 docs/finora-phase0-repeat-and-pages-nav-verified-20261015 docs/finora-phase0-repeat-evidence-20261015 docs/finora-selectors-release-and-fixture-qa-20261015 docs/finora-stagea-pr240-ci-triage-20261123 docs/finora-test-license-live-pass-20261015 docs/finora-v2-m01-coverage-20261124 docs/handoff-charter-v2-20261124 docs/invoice-product-search-release-20261011 docs/invoice-workspace-release-20261007 docs/phase-status-20261031 docs/phase0-acceptance-release-evidence-20261012 docs/phase0-admin-provision-release-evidence-20261012 docs/phase0-core-bundle-owner-login-open-20261013 docs/phase0-duplicate-js-release-20261016 docs/phase0-f001-auth-rest-shared-timeout-20261013 docs/phase0-f001-owner-login-observed-20261013 docs/phase0-f001-second-device-fail-40s-20261013 docs/phase0-f003-release-verification-20261011 docs/phase0-f004-print-release-evidence-20261012 docs/phase0-f004-watermark-release-evidence-20261012 docs/phase0-f005-large-selector-release-20261012 docs/phase0-f005-release-evidence-20261012 docs/phase0-f006-dark-release-evidence-20261012 docs/phase0-f008-final-pr-closure-evidence-20261012 docs/phase0-f008-reconcile-stale-prs-20261012 docs/phase0-f107-production-evidence-20261012 docs/phase0-kavenegar-otp-preflight-release-20261012 docs/phase0-login-release-evidence-20261012 docs/phase0-login-rest-bootstrap-stage-release-20261012 docs/phase0-owner-app-assets-bundle-release-20261013 docs/phase0-owner-login-csp-release-20261012 docs/phase0-reconcile-postmerge-evidence-20261012 docs/phase0-site-probe-release-evidence-20261012 docs/phase0-startup-release-evidence-20261012 docs/phase3-treasury-release-evidence-20261014 docs/pilot-posted-correction-release-evidence-20261014 docs/pilot-purchase-correction-release-evidence-20261014 docs/print-persian-release-verification-20261011 docs/qa-ci-triage-218-20261122 docs/real-account-qa-20261030 docs/release-state-20261007 docs/seamless-amendment-release-20261014 docs/seamless-document-correction-release-20261014 docs/settings-login-release-20261025 docs/stripe-qa-deployment-evidence-20261011 docs/ux-f2-release-evidence-20261011 docs/ux-f2-release-verification-20261011 docs/wave0-closeout docs/wave2-closeout exec-phase1-architecture exec-phase1-implementation exec-phase1-qa exec-phase1-security-release exec-phase1-ux feat/accounting-document-draft-approval-20261011 feat/accounting-document-release-candidate-20261011 feat/active-company-strict-isolation-20261014 feat/admin-provisioning-reconciled-20261011 feat/admin-secure-user-provisioning-20261011 feat/admin-user-provisioning-merged-20261011 feat/d4a-request-work-queue feat/document-lifecycle-atf-20261118 feat/document-lifecycle-temp-permanent-atef feat/draft-first-attachment-lifecycle-216 feat/finora-offline-encrypted-backup-20261014 feat/finora-phase-a-navigation-20261023 feat/finora-stripe-sandbox-edge-gate feat/immutable-attachment-temporary-vouchers feat/iran-accounting-design-audit feat/journal-document-lifecycle-20261118 feat/journal-rpc-repository-adapter-20261117 feat/office-c7-fulltext-ocr-provenance feat/password-recovery-admin-reset-20261025 feat/pilot-expense-income-inplace-amendment-20261014 feat/pilot-journal-invoice-correction-20261014 feat/pilot-purchase-correction-20261014 feat/pilot-treasury-unallocated-correction-20261014 feat/retain-document-editor-after-save-20261014 feat/seamless-financial-document-correction-20261014 feat/slice-b-tenant-rbac feat/stripe-sandbox-invoice-probe feature/accounting-core-p0 feature/accounting-product-guidance feature/admin-identity-phone-auth feature/commercial-rnd feature/finora-phase1a-supabase-cli-20261016 feature/finora-stage2-manual-canary-20261017 feature/finora-stage3-commercial-payload-20261023 feature/finora-stage3-enforce-invoice-rpc-20261023 feature/finora-stage3-enforce-purchase-red-20261023 feature/invoice-workspace-cleanup feature/phase0-kavenegar-otp-preflight-20261012 feature/ux-commerce-settings-r2 fix-shell-scroll-live-cache-20261002 fix-shell-scrollbar-explicit-ownership-20261002 fix-shell-scrollbar-ownership-20261002 fix-shell-scrollbar-right-edge-20261002 fix/about-bug-report-20261114 fix/active-company-invoice-scope-20261014 fix/active-company-isolation-reconcile-20261014 fix/admin-central-password-reset-20261028 fix/auth-network-diagnostics fix/chart-taxpayer-reference-20261003 fix/combobox-enter-reliability fix/combobox-live-search fix/combobox-production-cache fix/combobox-release-asset-v2 fix/company-edit-action-20261028 fix/company-edit-pilot-delete-20261014 fix/company-form-action-state-20261014 fix/company-form-action-state-rebased-20261014 fix/contact-operational-balance-20261111 fix/dark-theme-contrast fix/financial-lifecycle-recovery-20261124 fix/finora-accounting-test-organization-readiness-20261015 fix/finora-b01-safe-org-switch-20261124 fix/finora-b02-sync-recovery-20261124 fix/finora-b03-conflict-review-20261124 fix/finora-org-license-bootstrap-race-20261014 fix/finora-stage3-posted-source-immutable-20261023 fix/finora-v2-b03-r2-qa-20261124 fix/finora-v2-b03-r3-readonly-20261124 fix/g01-asof-financial-position-20261128 fix/invoice-product-search-rehydrate-20261011 fix/invoice-search-cache-bust fix/issue229-linked-draft-status-20261122 fix/login-assets-retry-20261014 fix/login-inert-startup-20261110 fix/login-member-access-20261101 fix/login-resilience-20261017 fix/login-short-viewport-20261028 fix/login-startup-readiness-20261024 fix/navigation-utilities-placement-20261105 fix/office-c7-source-ref-binding fix/office-c7-source-ref-binding-v2 fix/owner-login-network-20261026 fix/password-recovery-invalid-cancel-20261026 fix/payment-amount-format-20261111 fix/phase0-admin-provision-seat-bootstrap-20261012 fix/phase0-auth-bundled-assets-for-unstable-isp-20261013 fix/phase0-auth-handler-binding-stalled-session-20261012 fix/phase0-login-context-stage-visibility-20261012 fix/phase0-login-single-local-bundle-20261013 fix/phase0-login-site-probe-clarity-20261012 fix/phase0-login-ui-ready-20261012 fix/phase0-modal-dashboard-drill-20261011 fix/phase0-pages-blocking-core-bundles-20261013 fix/phase0-print-no-draft-watermark-20261012 fix/phase0-startup-parallel-asset-load-20261012 fix/phase3-behavioral-verification fix/preserve-pending-edits-20261121 fix/print-persian-digit-consistency-20261011 fix/recovery-login-startup-20261027 fix/report-opening-balance-release-20261130 fix/settings-checkbox-persistence-20261024 fix/taxpayer-arithmetic-20261004 fix/ux-keyboard-search-f2-20261011 fix/wave2-request-input-integrity hardening/c01-source-draft-20261129 hardening/global-draft-conversion-20261113 hardening/wp1-ledger-integrity-20261102 integration/finora-execution-20261124 integration/issue229-ui-qa-20261122 integration/wp1-ledger-core-20261115 integration/wp2-manual-journal-rpc-20261116 main ops-heartbeat-v2-20261002 ops-progress-heartbeat-rule-20261002 ops/wave4-production-20261003 plan/financial-core-phase1-approval-20261016 qa/attachment-allocator-two-session-20261122 qa/draft-first-save-red-evidence-20261122 qa/finora-autopost-retry-identity-red-20261122 qa/finora-identity-rpc-security-tripwire-20261122 qa/finora-issue223-manual-kardex-browser-red-20261123 qa/finora-issue223-stock-real-jwt-20261123 qa/finora-issue238-inventory-count-browser-red-20261123 qa/finora-issue238-save-browser-red-20261122 qa/finora-login-cors-header-preflight-20261025 qa/finora-phase0-saved-session-repeat-20261015 qa/finora-phase5-posted-insert-jwt-red-20261123 qa/finora-stage3-ui-jwt-autopost-20261023 qa/finora-v2-g01-report-reconciliation-20261125 qa/free-supabase-local-wp2-20261116 qa/issue229-approval-boundary-jwt-20261122 qa/issue229-sale-save-linked-draft-red-20261122 qa/phase0-acceptance-start-20261012 qa/phase0-f005-account-project-contract-stress-20261012 qa/phase0-f005-selector-stress-20261012 qa/phase0-f006-dark-contrast-20261012 qa/post-wave4-verification-20261003 qa/posted-source-immutable-jwt-20261122 qa/pr219-wp1-disposable-dburl-proof-20261123 qa/purchase-source-jwt-20261122 qa/real-settings-acceptance-20261025 qa/recovery-mail-acceptance-20261026 qa/source-autopost-jwt-atomicity-20261122 qa/wave0-negative-gate-proof qa/wp2-auth-tenant-e2e-20261117 qa/wp2-authorized-journal-write-20261122 qa/wp2-financial-paths-reconciliation-20261122 qa/wp3-financial-tenant-isolation-20261117 remediation/wave0-liveqa-wave1 remediation/wave2-request-integrity staging/finora-stage22-free-20261022 state-scroll-verified-20261002 state-wave4b-production-20261002 state-wave5a-production-20261002 test/finora-accounting-boot-readiness-20261015 test/finora-f0-02-production-selectors-20261015 test/finora-pages-commerce-event-wiring-20261015 test/finora-pages-invoice-selectors-readonly-20261015 test/finora-stage3-jwt-source-post-20261023 test/phase0-invoice-fixture-bootstrap-20261016 test/phase0-invoice-persistence-20261011 test/phase0-pages-delayed-dispatcher-20261016 ux-scroll-ownership-20261002 work/finora-stage3-enforce-purchase-green-20261023 work/finora-stage3-enforce-sale-green-20261023 work/finora-stage3-payload-green-20261023
md 36.7 KB

PROJECT STATE — FINORA 1.0 / FACTOR-EASY (فشرده‌شده در فاز صفر)

مرجع اجرایی جاری برای AI و توسعه‌دهندگان · مخزن davoodmehraban89/Factor-easy · شاخه محافظت‌شده main · تاریخ ۱۴۰۵/۰۷/۲۴. تاریخچه کامل بدون حذف یک بایت: docs/archive/PROJECT_STATE_PRE_MASTER_PHASE0_2026-10-16.md. Blob SHA پیش/پس از آرشیو: 4e8adb5c82b4c7e5d16f26c94cc904ba5774bca6، ۲۹۰٬۹۱۳ کاراکتر، ۸۰۹ خط؛ برای جزئیات هر فاز/شناسه PR و تصمیم‌های قدیمی به همین سند رجوع شود. آرشیو را بدون درخواست مالک تغییر ندهید.

۱. اصول و اختیار

  • قبل از کار AGENTS.md، README.md و همین فایل را بخوان؛ از وضعیت زنده main، CI، نسخه استقرار و در کارهای مرتبط Supabase را مستقل اطمینان بگیر. آخرین درخواست مالک نسبت به تاریخچه اولویت دارد. تاریخچه پشتیبان، ادعای اجرای فعلی نیست.
  • هماهنگ‌کننده مسئول اجرا/QA/امنیت/مستندات است. بدون ابزار واقعی ادعای ایجنت موازی نکن. تغییرات کوچک و قابل بازگشت، شاخه و PR مستقل؛ نتیجه واقعی با SHA و لاگ تست. CI موفق ≠ تایید مرورگر مشتری.
  • مرز توقف: تغییر schema/RLS/Auth/role/grants، بازنویسی تاریخچه مالی، عملیات مخرب، cutover یا هزینه و ارسال بیرونی نیازمند اجازه صریح جداگانه است. شرکت/tenant/RLS، تاریخچه posted، audit و idempotency حفظ شود؛ سرویس پولی یا کارت بین‌المللی راه‌حل اجباری نباشد.
  • هر migration تولیدشده باید فایل واقعی در supabase/migrations/ داشته باشد؛ فقط محیط تست مستقل، rollback، و مجوز عملیات Production. اسناد قطعی را بازنویسی نکن؛ اصلاح با تاریخچه برگشت و سند جدید.
  • ماژول‌های اتوماسیون اداری، workflow، OCR و SLA موجود فریزند، حذف یا توسعه نمی‌شوند مگر درخواست جدید مالک. معماری UI مرجع: docs/reference/finora-ui-target-v1.jpg.

۲. تفکیک نقشه‌راه‌ها

  • پرامپت جدید مالک finora-master-prompt-cloud.md، اجرا فقط فاز به فاز: ۰ ممیزی/فشرده‌سازی؛ ۱ هسته مالی سمت سرور؛ ۲ موتور سند خودکار؛ ۳ سلامت دفتر؛ ۴ تجربه کاربر؛ ۵ آمادگی فروش. فقط فاز ۰ در این PR مجاز است. فاز ۱ به مجوز مشخص تغییر اسکیما و محیط تست مستقل نیاز دارد.
  • نقشه راه هشت‌فازی قدیمی در docs/FINORA_EIGHT_PHASE_APPROVED_ROADMAP_2026-10-11.md محفوظ است؛ نام فاز صفر آن «پایداری/ورود» با فاز صفر جدید «ممیزی سند مالی» یکی نیست. شماره فاز قدیمی را به جای فاز جدید گزارش نکن.

۳. آخرین baseline قابل اتکا

  • قبل از ممیزی جدید: protected main = 612998edb51274ac1e6136a31265cd17b9abd265 (PR #158، حذف درخواست تکراری enterprise-iran.js). GitHub exact-SHA Quality 38815971255 123/123 Playwright PASS، Golden Accounting PASS، هر سه Postgres disposable jobs PASS؛ Security 38815971233، Release Gate 38816410495، gated Pages 38816440543 همگی SUCCESS.
  • اصلاح تکرار JS بر اساس CDP/Playwright بود؛ ورود سرد/پایداری اینترنت رایانه مالک همچنان تأیید نشده. Issue #106 باز بماند. Product+buyer live lookup در یک حساب تست/کار read-only قبول شده، ولی ذخیره/چاپ واقعی و مالک-ISP cold login جداگانه باز است.
  • Supabase Production با ref hcsixhqbyuhpshfwqpjx شناخته می‌شود؛ تاریخچه پیشین حدود ۸۲ migration تا ۱۴۰۵/۰۷/۲۱، drift آرشیو phone_identity_profile و warningهای امنیتی ثبت شده‌اند. در ممیزی جدید Supabase Production فقط read-only catalog بررسی شد: وضعیت ACTIVE_HEALTHY، ۸۲ migration، آخرین 20261012075507، فقدان ستون records.version و RPC finora_post_event، وجود دو امضای ۲/۳ آرگومانی finora_sync_records، و تریگرهای journal فقط UPDATE/DELETE. هیچ داده مالی/DDL/DML خوانده یا تغییر داده نشد. بدون preflight ادعای وضعیت زنده امروز نکن.

۴. فاز صفر جدید پرامپت مالی — خروجی/مرز

  • مالک کار: هماهنگی + ممیزی مالی/کیفیت. ورودی: SHA ثابت بالا، JS مالی، SQL migration، workflow و فایل پرامپت کاربر.
  • خروجی: docs/EVENT_COVERAGE.md (جدول رویدادها، سند خودکار/مشروط/مفقود و همه مسیرهای دستی)، docs/TEST_AUDIT_PHASE0.md (۳۸ مجموعه Playwright + ۳۵ چک ایستا/regex + ۱۴ رفتاری/ترکیبی + ۵ ابزار)، docs/PHASE0_FINANCIAL_AUDIT_2026-10-16.md (گزارش یک‌صفحه‌ای، P0/P1 و مرز تست) و آرشیو کامل تاریخچه.
  • یافته فنی: موتور اصلی jeCreateDraft/jePost/jeAutoPost مرورگری است؛ finora_sync_records رکورد JSONB را upsert می‌کند؛ guardهای posted روی UPDATE/DELETE هستند و INSERT زیر سند posted فاقد حفاظت هم‌ارز است؛ jeNextNumber سمت مرورگر اجرا می‌شود. عدم تعادل/هم‌زمانی و source-idempotency سراسری هنوز بر سرور با تست‌های منفی فاز ۱ تأیید نشده است.
  • خطرات دیگر: چک مستقل، COGS، FX، closing/opening، VAT settlement و بخشی از چرخه برگشتی سند خودکار ندارند؛ js/sync.js:139–143 رشته‌ها را با neutralize دگرگون می‌کند. در فاز ۰ هیچ مورد اصلاح عملیاتی نشده است.
  • تست موجود baseline: 123/123 Chromium + Golden + ۳ DB و Security PASS (با شماره اجرا در بالا)؛ تست واقعی ۱۰۰۰ رویداد تصادفی، concurrency مالی و production E2E را NOT VERIFIED ثبت کن. تست‌ها از source/CI بررسی شده‌اند؛ clone به محیط محلی این چت به دلیل DNS ممکن نبود.
  • تغییرات این فاز: چهار فایل سند/آرشیو، همین خلاصه، و افزودن اجرای public-qa-regression-check.mjs به Quality CI؛ هیچ کد JS، اسکیما، Production SQL، نقش یا داده مالی تغییر نکرده است. برای تکمیل، PR scoped باید Quality/Security موفق و یکپارچگی آرشیو تأیید شود.

۵. تعهدها/کارهای معوق (در فاز صفر انجام نشد)

  • فاز ۱ جدید تنها پس از دستور صریح مالک + دسترسی به Postgres آزمایشی مستقل و preflight/rollback: deferred balance+min lines، guard درج، optimistic version، شماره سند تراکنشی، قفل دوره، ممیزی append-only، event RPC/idempotency و گزارش read-only ناسازگاری تاریخی.
  • Issue #106 ورود روی اینترنت مالک، آزمون واقعی تسویه/چاپ، QA دوکاربره tenant، رفع drift مایگریشن، Leaked Password Protection و بکاپ رمزنگاری‌شده Production + کپی بیرونی + بازیابی آزمایشی همچنان OPEN / NOT VERIFIED. بدون مجوز در این موارد کاری نکن.
  • مدارک مرجع دیگر: docs/FINORA_OFFLINE_BACKUP_FA.md، docs/FINORA_PHASE0_ACCEPTANCE_REGISTER_2026-10-12.md، docs/PRODUCTION_ACCOUNTING_CUTOVER_READINESS_2026-09-30.md و آرشیو کامل بالا.

۶. ثبت پایان این نوبت

  • درخواست مالک در ۱۴۰۵/۰۷/۲۴: «پرامپت را کامل مبنا بگیر؛ فقط فاز ۰ را اجرا کن و بعد از پایان گزارش خلاصه بده؛ ادامه فاز ۱ با دستور جداگانه».
  • شروع از main SHA بالا، ایجاد شاخه audit/finora-master-prompt-phase0-20261016، آرشیو کامل و گزارش‌ها تولید شد. وضعیت QA این شاخه باید از GitHub PR-head جدا بررسی شود؛ تایید نهایی فاز فقط با قبولی آن و ادغام مستندات معتبر است.

2026-10-16 Phase 0 post-merge Chromium intermittent fixture (QA-only follow-up; NOT application defect proven)

  • Original Phase 0 PR: #160 merged exact-main 67be4fbfa6161156b10ce6279445266c989e97d3. PR-head Quality 38867730181 123/123 Chromium PASS, isolated DB and Security PASS. Protected main Quality 38868319174 attempt 1 FAIL 122/123 at scripts/phase0-invoice-persistence.spec.js:52, #auth-screen remained visible for 5 seconds; all three DB jobs and Security 38868319200 succeeded. Same-SHA failed-job rerun attempt 2 was requested; result must be verified separately. Neither result proves actual production financial persistence or login failure.
  • Source-reproduced test harness race: authenticatedMockBrowser waits only for enterApp, commitSaveInvoice, pullAll functions before installing a fake authenticated identity; asynchronously loaded organization-rbac wrapper can supersede the fake identity. Prior scripts/accounting-document-workflow.spec.js:36–43 already fixes the identical fixture ordering issue by waiting for FinoraStartupStatus.extensionsReady, zero failed extensions, and authChecked. Apply the same pre-mock readiness condition only in this synthetic invoice test; preserve all UI, Supabase/Auth/RLS, financial accounting and live record behavior. Require Quality 123/123, Security and all three disposable DB on exact repair SHA; then controlled protected merge and same-main checks. Rollback is a test-only revert. All owner-ISP and real invoice E2E remain NOT VERIFIED.

2026-10-16 — Master Phase 1A preflight, owner conditional approval (STOP)

  • Owner authorizes only phase 1A preflight / later test-branch & isolated Supabase CLI work; Phase 1B waits for a separate approval; NO Production DDL/DML (hcsixhqbyuhpshfwqpjx).
  • Main baseline bccd474433b4188e43aae345773498ea6fc65209. Read-only catalog vs repo migration manifest: 82 live versions vs 81 tracked; 25 live-only and 24 repo-only exact identifiers; phone_identity_profile is production-only, and profiles.phone exists live. Full Supabase CLI rebuild/schema equality NOT VERIFIED.
  • Source + live finora_sync_records expose full JSONB writes for eligible users; journal status/number/postedAt originate in browser, triggers only guard UPDATE/DELETE of already posted records. Runtime bypass test NOT RUN in production.
  • Preflight evidence: docs/FINORA_PHASE1A_READONLY_PREFLIGHT_2026-10-16.md + complete docs/FINORA_PHASE1A_MIGRATION_VERSION_DIFF_2026-10-16.md on isolated branch plan/financial-core-phase1-approval-20261016.
  • GATE: material schema-history drift; stop before migration or code/test rollout; report conditions 3/4 to owner and await explicit authorization to reconcile/test. No Phase 1A/1B completion claimed.

2026-10-16 — Phase 1A CLI schema reconciliation and passing isolated regression (no Production writes)

  • Following owner approval, work isolated to branch feature/finora-phase1a-supabase-cli-20261016; no Production DDL/DML, no 1B, no migration-history repair or rename of applied migrations. Read-only Production catalog/aggregates captured as hash-only fixtures.
  • 1069 schema object fingerprints matched in baseline rebuilt by full Supabase CLI after idempotent missing phone/profile bridge; all 154 function definitions matched by token-aware comparison (SQL literals retained). Initial differences were 29 whitespace-only candidates and one additional legacy SQL comment group; all cleared at lexical gate without touching prior migration files.
  • Genuine isolated GitHub Actions result 38889304877 SUCCESS, see docs/FINORA_PHASE1A_CLI_QA_CHECKPOINT_2026-10-16.md. Red-before-fix 11 failed; after 1A test migrations 11 passed. CAS, cross-tenant, 1000 postings+1000 compensating reversals, indexed 10000-voucher benchmark, JS syntax all PASS.
  • Still not a releasable Phase 1A: js/journal-engine.js authentic user-created draft carries protected status/number; protected postedAt mutation via client sync also remains, likely blocking actual journal UX. Need a dedicated server-side allowed transition path and non-Production browser E2E. Full migration up/down/up with preserved data, direct PostgREST authorization, Security Definer grant audit, concurrency and multi-user UX remain unverified.
  • Stop any production-facing release or merge until blocked items resolve; owner separately approves 1B later.

2026-10-16 — Owner authorizes staged Phase 1A implementation, Stage 1 ONLY

  • Stage 1: server SQL only (five lifecycle RPCs + atomic source-post, tenant/year counter, computed reversal status, append-only basic audit, org guard off/audit/enforce), tests and CI preflight; STOP and report before Stage 2.
  • Stage 2 requires a new owner go-ahead: async strangler for manual journal UI with real Playwright; STOP before Stage 3.
  • Stage 3 requires another owner go-ahead: sale, purchase, receipt/payment and subsequent source integrations with browser gate per path.
  • No DDL/DML Production, no merge to main, no Phase 1B. No enforce activation without separately approved backup and browser acceptance. Posted originals immutable; reversal references original only, computed reversal status in view. Any necessary posted-original trigger exception must STOP for approval.
  • Existing risks to retain: client-editable fiscal year lock; operational inventory records with status/postedAt outside journal guard. Existing Phase 1A test CI at branch head before this request was RED for positive client journal flow; expected until Stage 2, never mark as green.

2026-10-17 — New-chat continuity: exact tools, environments, Stage 1 handoff (documentation only)

  • Authority/source: Read AGENTS.md, README.md and this PROJECT_STATE.md fully, plus docs/archive/PROJECT_STATE_PRE_MASTER_PHASE0_2026-10-16.md for earlier history. Verify CURRENT GitHub ref/main/CI/Production READ-ONLY; do not treat this snapshot as live ground truth.
  • GitHub remote: davoodmehraban89/Factor-easy; protected main baseline bccd474433b4188e43aae345773498ea6fc65209; work ONLY on feature/finora-phase1a-supabase-cli-20261016. GitHub connector can read files/branches, edit branch files and inspect workflow runs/jobs/logs; NEVER merge, deploy or write to main without separate consent.
  • Production: https://factoreasy.ir ; Supabase project ref hcsixhqbyuhpshfwqpjx. Production database access through Supabase connector is SELECT/catalog/aggregates ONLY, explicitly NO DDL, DML, INSERT/UPDATE/DELETE or write-like test, and NO migration ledger repair or db push. Latest read-only inspection found 608 records across two data-bearing organizations (401 and 207 rows), 9 posted/reversed vouchers in those orgs (7 + 2); both owners verified with previous login; treat org B as REAL, not synthetic. No identity or personal details to be exposed in reports.
  • Disposable database test: GitHub Actions workflow .github/workflows/phase1a-supabase-parity.yml; ubuntu-latest, Docker, Supabase CLI pinned 2.121.0; isolated supabase start -x inbucket (unlinked, no remote project configured), local Postgres 127.0.0.1:54322 database postgres user postgres via psql; Node.js scripts and SQL in supabase/tests; synthetic auth.users, orgs and records only here. Main stage1 tests include SQL behavior, two-fiscal counters, seeded 1000 events (seed=20261016), real concurrent psql sessions, up/down/up and SECURITY DEFINER grant audit. Historical migration tail \n normalization happens ONLY inside ephemeral CI checkout. No historic blob edits.
  • Browser/QA: Node.js/Playwright Chromium + GitHub workflows .github/workflows/quality.yml, qa.yml, security.yml, release-gate.yml, pages.yml; browser real integration must target a separate staging URL backed by disposable TEST Supabase, never mutate Production. Staging URL and credential/account readiness have NOT been independently confirmed. TinyFish browser automation profile 'Finora ERP — Test / Work Account' id prof_5ea28cf6866d447d; read-only authenticated dashboard session was observed in prior browser test, but saved login status needs re-verification. TinyFish may inspect Production read-only; cannot replace Postgres concurrency/RLS/schema tests. Other debugging aids: GitHub Actions logs/artifacts, SQL fixture and schema fingerprint comparison, container/Python for non-Production work; Remote Desktop Commander only if connected and specifically authorized. Production backup tool/document docs/FINORA_OFFLINE_BACKUP_FA.md is documented, actual encrypted backup + restore UNVERIFIED.
  • Current staged SQL: migrations 20261016100000 (server journal invariants), 20261016100500 (CAS and legacy sync compatibility), 20261016101000 (per-org off/audit/enforce + immutable audit), 20261016101500 (core/counters/scope/unique source), 20261016102000 (five lifecycle RPCs + atomic autopost, computed reverse view). The stage1 code has NOT passed the full test gate; never call accepted or release-ready. No per-organization enforce on Production; local synthetic fixtures can use enforce.
  • Last observed branch head BEFORE this note: 2513a49b2b79da3dc2d1448de5923f5790e98689; latest Actions run 38911880626 CANCELLED, preceding 38911422707 FAILED specifically at seeded 1000 events due to duplicate key 'ux_finora_journal_source_version'; branch now includes scripts/phase1a-stage1-concurrency.mjs and supabase/tests/phase1a_stage1_counter_two_fiscal.sql. Obtain newer CI evidence before diagnosing next. Positive legacy JS journal client contract is RED and belongs to Stage 2; do not hide it by removing assertions.
  • Three approval stop gates: Stage 1 SQL + isolated tests ONLY -> report proof, stop; Stage 2 manual journal async strangler with existing function names + Playwright real staging, CI green -> report, stop; Stage 3 source flows one by one sale -> purchase -> receipt/payment -> other with browser test per path. Never start Stage 2 or 3 without separate approval following prior stage report. No Phase 1B, no merge into main, no Production writes. Activating enforce requires owner's additional explicit signoff AFTER verified backup and staging-browser test. Original posted voucher immutable; reverse-only link toward original and computed view; if trigger exception or original mutation needed STOP for user approval.
  • Known unresolved security/domain risks: fiscal year lock is client-editable; stock/inventory operational records status/postedAt outside journal guard; source autopost must strictly validate source-to-ledger amounts and permitted mappings rather than trust caller-supplied lines; duplicate-click and concurrent reversal must be independently proved. Stage 1 seed test failure is real; no 'pass' without exact-run evidence.
  • User requested a SINGLE copyable plain-text prompt/file for migrating to a new ChatGPT chat; this section ensures tools and test environments are recorded in repository history too. New chat should proceed from actual repo/tool state, not speculative claims.

2026-10-17 — Stage 1 continuation, authorized branch-only correction (IN VALIDATION)

  • Owner's current instruction: finish ONLY approved Stage 1 SQL + disposable Supabase CLI tests; STOP before Stage 2. No Production DDL/DML, no main merge, no enforce in Production, no historical migration editing.
  • Read-only live GitHub recovery: feature HEAD ca33d0982c388a471098245723f9bbc0c1d42526, protected main bccd474433b4188e43aae345773498ea6fc65209. Stage 1 run 38974967435 on exact old HEAD entered seeded 1000 events, not yet a completed PASS. Production SELECT-only catalog confirmed historical ux_finora_journal_source_version includes reversals and 93 SECURITY DEFINER routines (0 anon EXECUTE / 0 missing empty search_path).
  • This scoped branch patch: optimize locked counter bootstrap (historic maximum only when no counter row), and fail-closed source type/version/amount-to-journal validation before automatic draft creation, with negative tests for altered amount and proforma-as-sale. Existing document original/lines remain immutable. No new source posting architecture or Stage 2/3 client integration.
  • Acceptance PENDING exact new-head Actions: seeded 1000, two-fiscal counter, two real PostgreSQL connection races, UP/DOWN/UP, tenant/role tests, SECURITY DEFINER sweep, baseline parity. Existing legacy client positive contract is still expected RED until Stage 2; do not count that as Stage 1 server PASS or remove it. Additional source account-profile mapping remains Stage 3 risk (not claimed complete).

2026-10-17 — Stage 1 SQL test coverage extension (PENDING)

  • Owner authorizes Stage1 only. Added two-Postgres-connection concurrent same-ID create (exactly one voucher and 2 lines), same-line 600+600 competing partial reversal (1000 original; only one winner), computed partial status, manual owner UPDATE/DELETE, and commerce-only denial of manual edit/delete/reverse. No Production changes.
  • Deferred legacy JS positive-client contract is retained, now ordered AFTER server Stage1 checks, baseline parity and artifact upload to separately report known Stage2 RED without suppressing Stage1 evidence. Exact-SHA CI still required. Stop before Stage2.

2026-10-17 — Stage 1 seeded performance tuning (PENDING CI)

  • Live exact SHA run 38977189304 had 20 successful steps but seeded 1000-event DO was still running >10 minutes; preceding run 38976093909 was cancelled at seeded (not PASS/FAIL). Added tenant-scoped partial index for posted reversal source lookup and NOTICE per 100 events to diagnose without reducing event coverage. No Production changes. Exact-SHA CI required.

2026-10-17 — Stage 1 seeded 1000 generation completed, verification timed out (PENDING CI)

  • Exact SHA c198a1b5c71e10fb1a3558d142f49516d8a5e23f, run 38978629359: 20 steps PASS and seeded progress reached event 1000 (23:09:27Z); job cancelled at 23:31:41Z at 35-minute timeout without validation PASS. Counters/races/rollback/security tests skipped; no Stage1 completion claim.
  • Changed only disposable seeded SQL test: all 1000 authenticated write operations and deterministic random event definitions retained. Deferred constraints and global read-only invariant checks now execute after RESET ROLE to local Postgres to avoid pathological RLS overhead and ensure all tenant rows are visible during global integrity audit. Added explicit checkpoints for counts, per-voucher and per-org balances, cross-org leaks. No Production DDL/DML, no main merge, no Stage2/3.

2026-10-17 — Stage 1 seeded full PASS, counter test private-grant fix (PENDING NEW CI)

  • Exact SHA 2e708fdec5bc29d3b5530b59035d0da82702b4a6, run 38998387737: 1000 seeded events and 238 full/114 partial reversals, voucher balance, both organization balances and cross-org leak assertion PASS. Two-year counter test line 65 failed only when authenticated test role tried SELECT of deliberately private counters. Kept ACL unchanged; moves private table read-only assertions after RESET ROLE to disposable PostgreSQL DBA while all posting operations remain authenticated RPC. CI rerun pending, no Production writes or Stage2/3 work.

2026-10-17 — Stage 1 exact-SHA isolated server QA PASS; Stage 2 legacy client test fixture exposed as false-positive

  • GitHub Actions run 38999356580 on exact branch SHA 8ff8357e12f772188e2f7c818778ae2447bbcdc6 concluded SUCCESS. Logs verify deterministic 1000 event seed 20261016 / 2 organizations / 238 full+114 partial reversals, all ledger and tenant property checks; 2-year counter baseline 40->41 and 11->12 with rollback; true 2-connection simultaneous duplicate draft and gapless posts plus same-line partial reversal race (one winner), conservative UP/DOWN/UP (audit/counters/posted original retained), every public/private SECURITY DEFINER searched and none with unsafe path/effective anon/PUBLIC grants, 1069 matching baseline objects and 154 lexical-equivalent function sources.
  • IMPORTANT QA limitation: scripts/phase1a-positive-client-contract.mjs was PASS 3/3 only because fixture guard was implicitly OFF; that pass CANNOT establish real client compatibility with enforce. Test fixture now sets disposable org to enforce, re-executes same real psql 3 scenarios, and should expose known Stage2 legacy JS incompatibility. Do not remove or mark compatibility green if it fails. Exact new SHA run is PENDING.
  • Stage 1 server SQL foundation has positive evidence, but source autopost currently guarantees persisted source identity/type, amount and journal sum, NOT fully canonical source-account mappings for each module (Stage 3 risk); full Production readiness, staging browser E2E, actual encrypted backup/restore and Production guard enforce all NOT VERIFIED. Owner-approved work STOP before Stage2 and Stage3, main merge, Production DDL/DML, deployment.

2026-10-17 — Owner decisions: Stage 1 autopost semantic gates; separate login P1 (approval gate)

  • Owner approves Stage 1-only fail-closed design restricted to sale -> purchase checkpoint, then STOP for review; receipt/payment and remaining types are NOT authorized for implementation yet. Server must derive authoritative journal lines from committed source and versioned approved contract; client lines comparison-only. Unknown/unapproved sources reject with FINORA_AUTOPOST_CONTRACT_UNSUPPORTED. No fallback to guessed account codes or JS-derived ledgers. Seeded independent oracle and enforce-asserting red-before-green tests required; no synthetic 900-series accounts in positive tests.
  • HARD PAUSE before implementing postingProfiles / mapping controls: owner explicitly requires prior report and separate approval of who can configure records, immutable versioned audit and role authorization. Security discovery: postingProfiles currently lives in public.records/accounting module and ordinary authenticated sync insert/update privileges apply through module create/edit policies; no dedicated versioned posting-profile audit proven. Do NOT implement sale/purchase semantics until approved contract governance is resolved.
  • Read-only Production aggregate 2026-10-17: nine posted/reversed journal records: six sale and three reversal. Among six sale vouchers, five have same-org/company persisted source and one has no matching source; total canonical semantic-account mismatch remains UNDETERMINED until source-contract version is defined. Historical vouchers must not be revalidated or edited.
  • Baseline exact SHA 4f45335aaf20662c6c86bb9e5e74ac6301121ddf: Actions run 39000286807, job 117301585152, Stage 1 steps 12-28 PASS; legacy positive-client compatibility step 29 RED (three failures), so whole workflow FAILURE. Stage 2 blocked until owner formally accepts Stage 1, regardless of any expected-red split.
  • The branch-only Stage 1 guards do NOT protect Production. Until completion/approval of Stage 3 source integration, verified backup and staging tests, separately authorized deployment and Production guard enforce, no Production financial protection is claimed. No Production DDL/DML, no main merge, no Phase 1B.
  • پایداری ورود P1 در مسیر جدا. Login resilience is strictly read-only analysis/design on separate proposed branch fix/login-resilience-20261017; do not commit login changes to Stage 1 or deploy without independent owner approval.

2026-10-17 — Verification of isolated client RED sentinel and Stage 1 SQL CI; WAIT FOR OWNER PROFILE-GOVERNANCE APPROVAL

  • Branch-only commits: b9482332d37d5aa81c110b79aa4a99146f51be4e (owner decision/security gate) and 44914b4a8f465c1c1a521de76fae6edb07b68f21 (isolated expected-RED compatibility job and enforce-asserting fixture). Exact SHA Actions run 39008343264 SUCCESS: SQL job supabase-cli-parity ID 117325361884, Stage 1 steps 20–25 PASS (incl. 1000 seeded/2-fiscal/concurrency/UP-DOWN-UP/all SECURITY DEFINER); schema parity 27 PASS, artifact upload 28 PASS, artifact finora-phase1a-schema-parity-44914b4a8f465c1c1a521de76fae6edb07b68f21 ID 12091828570. Separate job client-compat-expected-red-until-stage2 ID 117325361696, step 7 PASS ONLY as strict known-RED sentinel, exactly three fail-on-enforce client flows, not Stage 1 client compatibility PASS.
  • NO sale/purchase semantic mapping implementation yet: the owner requires approval of financial control governance first. Production postingProfiles and accounts systemRole remain ordinary authenticated records subject to generic accounting create/edit and without separately verified immutable versioned mapping approval. Proposed new publish-only configuration endpoint, explicit accounting:configure/owner authorization, versioned immutable audit, protected sync fields await signoff.
  • Production READ-ONLY aggregate: 6 sale and 3 reversal posted/reversed vouchers, 1/6 sale missing matching same-organization source. Full historical semantic incompatibility count cannot be computed before a pinned new contract version; NEVER retroactively validate/change posted history.
  • B0 login-only analysis is separate: new fix/login-resilience-20261017 branch points at unchanged main bccd474433b4188e43aae345773498ea6fc65209, zero commits. Source scripts/build-pages.mjs ALREADY builds one hash-versioned 14-extension bundle on Pages; source null is not deployed manifest. Offline Playwright isolated 14 blocked source modules + production-like bundle and core timeout message reproduced via mocked dependencies, NOT owner network or real webpage E2E. Live DNS, HTTP cache headers, transfer size and owner VPN/mobile comparative diagnostic UNVERIFIED. No B code changes.
  • CI SUCCESS does not waive owner stop gate: no Stage2/Stage3/1B, no main merge, no Production writes/guard-enforce/deployment. Wait for posting-profile governance authorization.

2026-10-17 — Stage 1 account-mapping control scope approved; semantic RED first

  • Owner authorizes only Stage 1 role-assignment protection + authoritative SQL contracts sale then purchase, each red-before-green with seeded independent 1000-case oracle. Contract rules fixed SQL; ONLY organization role-to-account assignment is versioned data, initial snapshot v1 with review requirement. Publication only organization owner, immutable audit, protected effective account fields, audit/enforce modes, recheck at post. Unsupported receipt/payment/expense/income and all other sources fail-closed until later approval; no Phase 1B, Stage 2/3, Production DDL/DML, main merge, or login-path activity. Historical postings informational only. Production guard remains OFF. Separate expected-red client job is NOT Stage 1 compatibility.

2026-10-17 — Stage 1 sale+purchase checkpoint: isolated CI PASS, STOP for owner acceptance

  • Exact tested code SHA 83e031e1cda4b38662d37d61b01b6031634e854f; Actions run 39013215513 SUCCESS. Job supabase-cli-parity 117339931348: steps 13 (balanced wrong-sale negative), 14 (owner role assignment, audit/enforce sync, append-only and draft/post contract change), 15 (purchase RED first), 16 (sale/purchase semantic negatives, unsupported, cross-org and reversal idempotence), 17–31 regression/concurrency/security/schema parity PASS, step 32 schema artifact ID 12094172133. Historical RED proof: sale run 39010660696/job 117332320514/step 13; purchase run 39012780445/job 117338642036/step 15.
  • Independent JavaScript oracle for 1000 sale sources, seed 20261017, enforce, realistic chart: job 117339931168 step 7 PASS. Same for 1000 purchase sources: job 117339931270 step 7 PASS (run 39013215513).
  • Separate client-compat-expected-red-until-stage2 job 117339931399 step 7 passes ONLY as strict known-RED sentinel for three incompatibilities; it is NOT a green Stage 1 client integration.
  • Fixed SQL contract rules; private immutable versioned organization role-to-account mappings, owner-only publish RPC, append-only audit and guard for protected account fields. Existing mapping bootstrap v1 remains UNAPPROVED pending actual owner review. Audit-mode legacy UI remains writable and audited. No Production code, migrations, guards, or rows changed.
  • STOP after sale+purchase pending formal owner acceptance. Unsupported receipt/payment/expense/income and other sources remain fail-closed; no Stage 2/3, Phase 1B, login P1 work, main merge or Production deployment. Risks/unverified: two real tenant owner reviews, Production backup + restore, isolated staging full browser E2E, Production enforce/cutover and historical canonical semantic mismatch count.

2026-10-17 — پذیرش مشروط Stage 1 توسط مالک؛ صرفاً این دامنه

  • پذیرفته‌شده فقط: هسته‌ی دفتر کل سروری (تعادل، قفل، نسخه‌بندی، شماره‌گذاری، ممیزی، RPCهای ژورنال). قرارداد autopost فقط برای sale و purchase.
  • پذیرفته نیست: receipt، payment، expense، income، petty_cash، depreciation، benefit، contract_statement، inventory_adjustment، payroll_run و سایر انواع؛ همه fail-closed. آمادگی Production، سازگاری کلاینت، هر نوع enforce روی Production نیز پذیرفته نیست.
  • شاهد مبنای پذیرش: SHA 83e031e1cda4b38662d37d61b01b6031634e854f، Run 39013215513 SUCCESS، Job 117339931348 Steps 13–32، oracle sale Job 117339931168 Step 7، oracle purchase Job 117339931270 Step 7. Job 117339931399 Step 7 فقط EXPECTED RED است و سازگاری کلاینت نیست. Run اسناد قبلی 39026945693 روی SHA a4a3167f9a3f5757c9e47bfc525d436dacf84ae4 نیز SUCCESS.
  • Stage 2 فقط طرح سند دستی بدون کدنویسی تا تصویب طرح توسط مالک؛ Stage 3 فقط گزارش مباحث هم‌ارزی JS/SQL، مقدار اعشاری، روش پرداخت، Production read-only و COGS. تا تأیید بعدی، هیچ کد Stage 2 و هیچ تغییر روی مسیر ورود. بدون Production DDL/DML، بدون merge به main، بدون Phase 1B و بدون Production enforce.
  • نکتهٔ انتشار: snapshotهای فعلی سازمان‌ها هنوز تأیید مالک همان سازمان را ندارند؛ استقرار Production و E2E واقعی جداگانه نیازمند مجوز و ارزیابی است.
  • اوراکل‌های sale/purchase با ورودی کامل قرارداد سبز شدند ولی با خروجی UI واقعی هم‌ارز ثابت نشده‌اند. Prior run 39013215513, jobs 117339931168 and 117339931270 step 7 generated complete source payloads, NOT actual invoice/purchase UI writes.
  • Production READ-ONLY aggregates: 15/15 formal and non_formal invoice records have no vatMode, so under the current server SQL contract they would be rejected; purchase records: zero. Inline SELECT-only reason-code evaluation: FINORA_SOURCE_VAT_RULE_INVALID=15; FINORA_SOURCE_TYPE_OR_VERSION_MISMATCH=4 pre-invoices. No retroactive validation or data changes.
  • Stage 3 only, not implemented: real JS/SQL parity, currency scale, quantity decimals, payment methods, COGS and actual UI integration. Proposed v2 draft, not approved for implementation: quantities <=3 decimal places when unit permits; count units integer only; per-line round-half-up to integer rial using scaled integer arithmetic in JS; total from rounded lines; reject overprecision explicitly; validate client/server with same seed and actual UI functions. Monetary unit semantics for non-rial settings need owner-approved policy; do NOT silently multiply/divide by 10. Payment and inventory valuation remain separate owner decisions.
  • Before any Production enforce, approve explicit opening/closing voucher contracts, and organization-owner role assignments for BOTH live organizations. Opening/closing are disabled under Stage 2 enforce pending owner approval.
  • Stage 2 scope ONLY step 2.1 infrastructure + local canaries: production-target preconnection deny, authenticated direct posted-status rejection, real negative/positive CI runs and artifacts, Draft PR marked DO NOT MERGE after PR/security checks. Stage 2.2 manual voucher browser lifecycle is NOT authorized and must not start; atomic correction/reversal RPC and audited owner-controlled server flag are design only until separately approved. Login resilience path STOPPED; no merge main, no Production DDL/DML, no Production enforce, no Phase 1B.