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

docs(phase0): reconcile stale PRs and correct live Wave 4b migration status (#96)

* docs(phase0): record F0-08 live stale-PR reconciliation before changes * docs(phase0): reconcile Wave 4b live migration instead of copying stale PR #28 status * docs(phase0): ground nine-PR disposition and correct Wave4b live migration truth * docs(phase0): update F0-08 audit evidence and retained high-risk review gates * docs(phase0): record verified F0-08 source audit and guarded close candidates

davoodmehraban89 committed Oct 12, 2026 at 12:01 UTC 2a4d637d0145f333412fbce0e299ab6962f0b262
4 files changed +70 -3
PROJECT_STATE.md
+15
@@ -347,3 +347,18 @@ Owner reports login blocked with generic 'check internet/VPN' network error on l
347
348
349 - **F0-06 QA suite follow-up (no runtime change):** Documentation PR #95 initial Quality run `38220841194` failed **1/86** in the existing F0-06 light-mode contrast test at `button.contrast=1.56`; Security `38220841248` PASS and all three disposable DB jobs PASS. The isolated test toggled the body class and sampled immediately while the actual `.btn` CSS has a 200ms background-color transition; delayed `finoraApplyTheme` boot can also override the manually toggled class. Patched the fixture to hold the requested theme stable using a test-only `getMySettings` wrapper, use the actual `finoraApplyTheme()` transition, and poll for steady-state light-button contrast >=4.5 before asserting other surfaces. This does **not** waive the contrast threshold or alter live application CSS. Retest entire workflow on final PR head; do not merge on a red CI.
350 +
351 +
352 +## 2026-10-12 Phase 0 F0-08 stale PR disposition — OWNER CONTINUATION / IN PROGRESS
353 +- **Instruction:** Owner requested to advance the approved Phase 0. Accountable: Coordination + QA. Baseline protected main `4595dafcb98185984894faacb97244cec2aa55e4`, last release PR #95 accepted and published. Owner-authenticated F0-01/02/03/04/07 and broad F0-06 remain open; we must not claim phase closure.
354 +- **Selected independent safe scope:** complete `F0-08` disposition of 9 stale open PRs, preserving finance/identity/scroll issues pending separate verification. Re-read current main, inspect each historical diff, pin Supabase migration evidence read-only, correct obsolete historical status documents, then document rationale before any reversible PR closure. Do not merge stale changes, mutate live DB/Auth/RLS/roles, create accounts, change accounting, disclose secrets or reinterpret production migrations as live end-to-end acceptance.
355 +- **Initial finding:** Old PR #28 proposed correcting `docs/REQUEST_WORKFLOW_WAVE4B_VERIFICATION.md` to 'merged CI green / production migration NOT APPLIED'. However **live Supabase currently records** `20261002072526 request_wave4b_scheduler_outbox_delivery`, so blindly cherry-picking #28 would preserve a false production-not-applied claim. Current main document still says 'IMPLEMENTED ON BRANCH / CI PENDING' and requires reconciliation distinguishing *migration recorded* from *full D4c delivery consumers verified*. Audit rest of document and archive precise sources.
356 +- **Candidate superseded PRs to independently confirm:** #28 (Wave4b documentation), #43 (heartbeat already in AGENTS), #49 (outdated live status), #57 (dark contrast delivered by #92), #80 (admin provisioning delivered by #84/#94). Retain #6 (financial), #39/#40 (RTL scroll physical behavior), #58 (multi-change identity/migration archive drift) pending evidence. No partial/automated merging. Classification may change on inspection.
357 +- **Done criteria:** reconciliation doc and PROJECT_STATE change pass Quality/Security PR gates, merge to main, optionally close only fully superseded historical PRs with reference to surviving content and audit decision, verify post-merge CI. Exit F0-08 = disposition recorded, not blanket functional acceptance. Rollback: revert docs-only changes or reopen closed PRs, no DB or finance rollback.
358 +
359 +
360 +### 2026-10-12 F0-08 nine historical PR source audit — VERIFIED READ-ONLY / DOC PR GATES NEXT
361 +- Reconciled PR #6/#28/#39/#40/#43/#49/#57/#58/#80 against protected main `4595dafcb98185984894faacb97244cec2aa55e4`. Read changed filenames, relevant patches and current main. Detailed disposition and explicit risk boundaries in `docs/FINORA_PHASE0_F008_PR_RECONCILIATION_2026-10-12.md`.
362 +- **Important stale-fact correction:** current main `docs/REQUEST_WORKFLOW_WAVE4B_VERIFICATION.md` said `IMPLEMENTED ON BRANCH / CI PENDING`. Historical PR #28 described CI/merged PR #27 but said production migration NOT APPLIED. Independently read 82 Supabase migration rows and confirmed `20261002072526 request_wave4b_scheduler_outbox_delivery` **present**, and read-only pg_proc catalog confirms scheduler/outbox public/private RPCs; the original SQL explicitly says **D4c destination consumers remain disabled**. Corrected current main doc with merged historical CI, live migration presence and unverified real destination delivery, not blindly cherry-picking stale PR #28.
363 +- **Superseded candidates:** #28 historical QA docs (useful evidence now ported with current correction), #43 heartbeat already represented by AGENTS, #49 stale operating snapshot, #57 dark UX delivered better by #92/#95, #80 admin creation already delivered by #84/#94 with production identity bootstrap fix. Close only after this documentation PR is merged and read back; closures retain history and can be reopened. **Retain OPEN** #6 financial posted history; #39/#40 physical RTL wheel/scroll geometry; #58 phone-identity migration archive drift and privileged Auth/SMS issues.
364 +- F0-08 = **PRELIMINARY SOURCE RECONCILED**, final disposition depends on exact-head Quality/Security, merged doc and individually verified closure outcomes. Main runtime code unchanged by this slice; no customer data, ledger, DB, schema/RLS/Auth/roles, edge deployments or production scheduler dispatch mutated. **PHASE 0 OPEN** regardless of F0-08.
docs/FINORA_PHASE0_ACCEPTANCE_REGISTER_2026-10-12.md
+1 -1
@@ -26,7 +26,7 @@ Status definitions: **CONTROLLED QA PASS** = actual Chromium or isolated tests w
26 | **F0-05** · Large selectors | `scripts/phase0-selector-stress.spec.js`, **1,208 synthetic products + 1,206 persons** passed 2/2; keyboard/Persian/metadata covered | **CONTROLLED QA PASS for products/persons; real catalog and other high-volume selectors UNVERIFIED** / P1 open | Owner tenant/real workstation test plus assess account/project/contract selectors where applicable; measure interactive latency. UX/Perf. |
27 | **F0-06** · Modal, keyboard, RTL, themes | Targeted dark contrast PR **#92** released to protected main `745bdc847a3c2db22048d1d545da0fad0ae5cc67`; exact SHA Quality **38218505600** (**85/85 Chromium**, including two dark/light contrast tests, 3 disposable DB), Security **38218505535**, Release **38218679192**, Pages **38218725537** all SUCCESS. Remote read-only HTTP confirms updated live JS theme bundle. | **DARK/LIGHT CONTRAST RELEASED + CONTROLLED QA PASS; broader UI and owner visual acceptance UNVERIFIED** / P1 open | Owner dark/light screen review in authenticated session, keyboard/modal/RTL scroll ownership and critical save/delete/import/export negative-path tests. UI/QA. |
28 | **F0-07** · Access and release safety | Security checks remain green. **Owner-reported central admin user creation HTTP 400** traced to real Auth HTTP 500 `organization license not found` (23503): live signup trigger inserted owner membership before required trial license. Controlled fix **PR #94** deployed: protected `main` `e664e8fdbc77b660dfc1fedff580b206279899f3`, Quality **38220163720** (**86/86 Chromium**, 3 disposable DB), Security **38220163569**, Release **38220396895**, Pages **38220451051** all SUCCESS. Supabase `fix_identity_bootstrap_license_before_membership` migration **20261012075507** applied successfully (total 82); independent read-only verification confirmed `profiles → organizations → licenses → membership`, original seat trigger retained, ordinary role and email/phone support preserved. Live admin JS version `20261012-provision-error-v1` reachable. | **ADMIN PROVISIONING ROOT-CAUSE FIX RELEASED + CONTROLLED QA PASS; actual owner retry and dual-user isolation E2E UNVERIFIED** / P0 still open | Owner rechecks central Users list (avoid duplicate account), refreshes and attempts authorized creation once without sharing credentials; verify created account has ordinary role and expected trial, then license assignment separately. Formal RLS/cross-tenant two-account negative E2E, Auth-advisor security audit and full F0-07 signoff remain pending. Security/QA. |
29 -| **F0-08** · Stale PR reconciliation | **9** live open PRs audited against current main; all `diverged` from main | **Read-only preliminary disposition RECORDED; no PR integrated** / P1 open | Review below and safely disposition PRs with owner/context; never merge stale sensitive code automatically. Coordination. |
29 +| **F0-08** · Stale PR reconciliation | Current nine PR diffs reconciled to main. Read-only Supabase proof: 82 migrations, Wave4b `20261002072526` present and scheduler/outbox functions exist; old `docs/REQUEST_WORKFLOW_WAVE4B_VERIFICATION.md` falsely said CI pending. `docs/FINORA_PHASE0_F008_PR_RECONCILIATION_2026-10-12.md` defines evidence and disposition; old Wave4b doc corrected. | **SOURCE/PR AUDIT RECORDED; superseded PR closures PENDING until docs merged** / P1 | After exact PR Quality/Security and docs merge, close only superseded #28/#43/#49/#57/#80 with transparent rationale. Keep #6 finance, #39/#40 scroll UX, #58 identity/source drift open with specialist owner; no stale merge. Coordination. |
30
31 ### Exit decision
32
docs/FINORA_PHASE0_F008_PR_RECONCILIATION_2026-10-12.md new
+45
@@ -0,0 +1,45 @@
1 +# Finora Phase 0 F0-08 — Historical PR reconciliation and disposition (2026-10-12)
2 +
3 +**Source of truth:** protected `main` SHA `4595dafcb98185984894faacb97244cec2aa55e4` at start, `AGENTS.md`, `PROJECT_STATE.md`, the nine OPEN GitHub PRs and read-only live Supabase migration/function metadata.
4 +**Owner's direction:** continue approved Phase 0.
5 +**Responsible:** coordination/QA. **No historical PR code is to be auto-merged.**
6 +
7 +## Decision discipline
8 +
9 +1. A superseded PR may be **closed without merging** only when its historical intent is already present in main or preserved in a verified newer report. Closure is reversible, preserving its commits/discussion; it does not delete history.
10 +2. Old PRs touching financial postings, existing-user credentials, RLS/Auth, schema/migration drift or disputed scrollbar geometry must remain **open for independent specialist verification**.
11 +3. A historic green CI run validates its own commit, not current `main`. Controlled browser/SQL/CI QA is not owner-authenticated acceptance.
12 +4. No production SQL, data, login, API, permissions, real account creation or external messages are altered in this F0-08 reconciliation.
13 +
14 +## Specific nine-PR disposition, anchored to current released implementation
15 +
16 +| PR | Bucket | Verified reason | Action |
17 +|---|---|---|---|
18 +| [#6](https://github.com/davoodmehraban89/Factor-easy/pull/6) | **FINANCE REVIEW — KEEP OPEN** | 26 files including voucher journals, reversal, invoices/purchases, bank and recovery test contracts; legacy Phase 3 patch predates newer immutable-posted/idempotency work. No safe equivalence proof. | Audit each proposed financial invariant in disposable fixtures; **never merge** the stale branch as one unit. |
19 +| [#28](https://github.com/davoodmehraban89/Factor-easy/pull/28) | **SUPERSEDED DOCUMENTATION — CLOSE AFTER PORT** | Its unique Wave4b historical CI/SHA details are now preserved in `docs/REQUEST_WORKFLOW_WAVE4B_VERIFICATION.md`. Its claim that live production Wave4b migration was not applied is **false as of current live state**. | Close without merge **only after** this reconciliation merges; retain PR history. |
20 +| [#39](https://github.com/davoodmehraban89/Factor-easy/pull/39) | **OWNER-VISUAL UI AUDIT — KEEP OPEN** | Competing direction-only RTL scrollbar placement and physical screenshot/video expectations; overlaps #40 and newer scroll ownership test. | Obtain verified physical-RTL scroll ownership evidence; no blind merge. |
21 +| [#40](https://github.com/davoodmehraban89/Factor-easy/pull/40) | **OWNER-VISUAL UI AUDIT — KEEP OPEN** | Alternative structural scrollport geometry to #39; current desktop shell has three scroll owners with direction mapping covered by Playwright, but not owner physical acceptance. | Compare actual owner device screenshot and synthetic bounding/wheel tests; choose one safe targeted solution if needed. |
22 +| [#43](https://github.com/davoodmehraban89/Factor-easy/pull/43) | **SUPERSEDED OPERATIONS DOC — CLOSE** | Current root `AGENTS.md` already instructs liveness updates at verified checkpoints, continued execution without reply and explicitly disallows claiming unverified progress. | Close obsolete alternative wording without merging; current charter retained. |
23 +| [#49](https://github.com/davoodmehraban89/Factor-easy/pull/49) | **SUPERSEDED HISTORICAL STATE — CLOSE** | A historical 2026-10-06 `PROJECT_STATE.md` snapshot that cites 79 migrations and stale head. Actual 2026-10-12 Supabase has **82**; current state includes newer tested deployments, admin-provision repair and explicit open acceptance. | Close without merging stale snapshot; retain chronology in PR history. |
24 +| [#57](https://github.com/davoodmehraban89/Factor-easy/pull/57) | **SUPERSEDED UI FIX — CLOSE** | Dark-mode controls/cards/shell/input/placeholder/disabled fields/combobox shipped in newer PR [#92](https://github.com/davoodmehraban89/Factor-easy/pull/92). Mandatory `scripts/phase0-dark-theme-contrast.spec.js` uses true Chromium contrast threshold 4.5:1; browser transition fixture stabilized in #95. | Close outdated branch without overwriting newer theme asset; owner full visual F0-06 still open. |
25 +| [#58](https://github.com/davoodmehraban89/Factor-easy/pull/58) | **IDENTITY / SOURCE-DRIFT AUDIT — KEEP OPEN** | Old multi-feature patch also contains phone migration `20261007163500_phone_identity_profile.sql` absent from current main despite live migration ledger `20261007165208 phone_identity_profile`. Its Edge/Admin/Dark changes overlap newer fixes. | Audit migration body and source archive/name parity, SMS/Auth policy separately; **do not reapply old SQL or deploy old Edge function**. |
26 +| [#80](https://github.com/davoodmehraban89/Factor-easy/pull/80) | **SUPERSEDED ADMIN FEATURE — CLOSE** | Main has server-only `admin-user-management` with JWT+trusted `profiles.role=admin`, UI, contract + Playwright provisioning tests. Follow-up [#94](https://github.com/davoodmehraban89/Factor-easy/pull/94) fixed real `organization license not found` bug with verified Supabase migration `20261012075507`; #95 archived it. Reintroducing old branch risks resetting auth and the corrected UI. | Close obsolete unmerged branch **without touching the deployed Edge function or account records**; actual admin-owner creation remains acceptance OPEN. |
27 +
28 +## Live Wave 4b correction: migration recorded ≠ destination consumers operational
29 +
30 +- Supabase project `hcsixhqbyuhpshfwqpjx` has **82 recorded migrations**; `20261002072526 request_wave4b_scheduler_outbox_delivery` is present.
31 +- Direct read-only `pg_proc` query confirms `private.request_run_sla_scheduler`, `private.request_claim_outbox`, `private.request_complete_outbox`, `private.request_fail_outbox` plus public counterparts. The source file `supabase/migrations/20261002073500_request_wave4b_scheduler_outbox_delivery.sql` explicitly leaves D4c external destination consumers disabled.
32 +- The original PR #28's "production migration not applied" was true only for its historical checkpoint. Present-tense main documentation has now been corrected. **No new scheduler task was executed, no consumer destination was contacted, and no claim of real delivery is made.**
33 +
34 +## Retained blockers and follow-up
35 +
36 +- **#6:** financial invariants and irreversible posted ledger safety require controlled independent proof.
37 +- **#39/#40:** owner-real scrollbar placement in RTL; do not modify stable shell geometry without symptom/measurement.
38 +- **#58:** source-vs-live phone identity migration drift and admin/Auth security; read-only drift reconciliation precedes any privileged action.
39 +- Other Phase-0 acceptance gates F0-01 real affected-ISP login, F0-02 actual tenant catalogs, F0-03 safe authorized invoice persistence, F0-04 real printed invoice, F0-05 real 1,200+ selector and F0-07 dual-user/RLS remain OPEN.
40 +
41 +## Evidence, limits and rollback
42 +
43 +- Root PR diffs inspected: #6, #28, #39, #40, #43, #49, #57, #58, #80. Current main assets and contract checks inspected; branch-only historical CI is not recast as current source success.
44 +- F0-08 can be marked **HISTORIC PR DISPOSITION RECONCILED** after documentation and closings are verified; **not** equivalent to overall Phase-0 acceptance.
45 +- Rollback documentation by revert. Reopen any PR closed in error; no data, migration or external action requires rollback.
docs/REQUEST_WORKFLOW_WAVE4B_VERIFICATION.md
+9 -2
@@ -1,6 +1,13 @@
1 # Request Workflow Wave 4b Verification
2
3 -Status: IMPLEMENTED ON BRANCH / CI PENDING
3 +Status: **MERGED / HISTORICAL CI VERIFIED / LIVE MIGRATION RECORDED / EXTERNAL CONSUMERS NOT VERIFIED**.
4 +
5 +## 2026-10-12 read-only live reconciliation (Phase 0 F0-08)
6 +- Historical implementation [PR #27](https://github.com/davoodmehraban89/Factor-easy/pull/27) merged at `41aff95d11a66c67e2c64df3eac11a122f94dfd7`. Historic PR Quality `36975854976`, Security `36975855052`; protected-main Quality `36975968198`, Security `36975968108`, Release `36976087514`, gated Pages `36976115600` are recorded in the original unmerged [PR #28](https://github.com/davoodmehraban89/Factor-easy/pull/28) evidence. These describe that historical SHA, **not** a fresh 2026-10-12 live workflow acceptance test.
7 +- **Unlike the historic PR #28 claim that the production migration was not yet applied**, the Supabase project `hcsixhqbyuhpshfwqpjx` migration ledger **now** includes `20261002072526 request_wave4b_scheduler_outbox_delivery`. Independent read-only live PostgreSQL catalog queries confirm `private.request_run_sla_scheduler`, `private.request_claim_outbox`, `private.request_complete_outbox`, `private.request_fail_outbox` and their public RPC entrypoints. This verifies schema/function presence on 2026-10-12; it does not identify when consumer adapters became active or show successful real-world delivery.
8 +- **D4c destination adapters / external outbox consumer processing, real scheduler scheduling and actual target-system delivery remain NOT VERIFIED.** Their activation requires an authorized scoped integration and deduplication check using `destination_command_key`; do not infer this from the migration ledger.
9 +- Safe disposition: archive unique useful historic QA evidence here, do not merge the stale PR #28's false current-production status into main. No SQL, customer data or outbound messages changed in this reconciliation.
10 +
11
12 ## Scope
13 - SLA escalation scheduler policy: five-minute schedule slots, server-authoritative clock, durable run identity, replay binding, bounded batches and row claims with `FOR UPDATE SKIP LOCKED`.
@@ -16,4 +23,4 @@ The database server clock is authoritative. Scheduler callers provide only a fiv
23 Outbox claims expire after ten minutes. Delivery attempts are capped at five; retry delay is server-derived exponential backoff capped at one hour. The fifth failed attempt enters `dead_letter`. Authorized workflow configurators can replay a dead letter with an idempotency key; the stable destination command key is never regenerated.
24
25 ## Verification gate
19 -Disposable PostgreSQL assertions cover scheduler replay/slot/clock behavior, escalation evidence, stable command identity across retries, stale-claim rejection, retry scheduling, dead-letter transition, replay idempotency and audit dedupe. Production application and external destination consumers are NOT VERIFIED until separately executed.
26 +Disposable PostgreSQL assertions cover scheduler replay/slot/clock behavior, escalation evidence, stable command identity across retries, stale-claim rejection, retry scheduling, dead-letter transition, replay idempotency and audit dedupe. The migration and scheduler/outbox SQL functions are now present on production (as independently read-only verified 2026-10-12); external destination consumers, scheduling operations and real deliveries remain NOT VERIFIED without separate execution and end-to-end proof.