فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
fix/a01-explicit-refund-reason-approval-20261021
Phase A acceptance status
Updated: 2026-10-19
Execution order
A03 → A04 → A01 → A05 → A06 → A07 → A08.
Closed gates
None. The authoritative acceptance manifest docs/PHASE_A_RELEASE_ACCEPTANCE.json has all gates unaccepted.
A03 — in progress (direct-write bypass hardening)
- Current implementation: AuditService brands authorized audit records; StorageService.transaction rejects unbranded audit rows through add/put/putRaw; raw helpers _exec/_tx and bulkPut reject direct audit writes.
- Restores: CompanyBackupService and StorageService.importAll route audit history through AuditService.restoreHistorical; fixture tests updated.
- Added protection tests before guard, plus negative direct add/put/putRaw rollback test.
- Security limitation: AuditService.restoreHistorical is exported for validated restore flows and is not yet restricted to a restore-only capability; direct IndexedDB access via StorageService.init() or browser developer tools remains outside service-layer protection.
- Latest CI must be checked before merge. No acceptance claim.
- Previous audited immutable-store hardening merged: PR #114, merge commit
3077d42d0061b05f8bf623f77ca18869a1581d1c. - Current branch:
gate/a03-audit-metadata-validation-20261019. - Current changes: reject invalid audit business dates and overlong metadata identifiers; add positive/negative atomic rollback tests.
- Acceptance criteria outstanding: full audit metadata and company/actor integrity; service-layer mutation bypass assessment; atomic failure cases; complete passing CI with evidence; independent gate review.
- CI status: original PR checks ran; a subsequent attempted history-only restriction was reverted because it would break legitimate transactional test/seed paths. Latest head requires fresh CI; do not mark accepted before successful checks.
A04 — queued, not accepted
- Existing unmerged branch:
fix/a04-reject-mixed-company-backup-20261019, commit3a059b98c31a032a6725e07cb15999dce6461c2d. - Outstanding: positive/negative restore tests, corrupt/interrupted restore, two-version compatibility, company isolation, CI.
Remaining gates
A01, A05, A06, A07, A08: not accepted; proceed in specified order after A03/A04.
External verification, not simulated
- A02: independent accountant sign-off.
- DATA_BACKUP: restore of actual backup on actual target system.
Next action
Review CI on latest A03 PR head, fix failing fixtures and ensure restore authorization cannot be invoked outside validated restore. Do not merge red CI. Once all A03 acceptance criteria have evidence, update manifest and this file, then proceed to A04.
A03 continuation — restore authorization and hash chain
- Added transaction/company-scoped restore authorization in AuditService and negative direct-call regression test.
- Full restore now registers company-scoped grants before historical inserts.
- BLOCKER: CompanyBackupService has not yet been updated to register grants; company restore currently risks rejection. Attempts to update the file were blocked by tool safety checks. Do not merge or mark gate accepted.
- Existing legacy fixture rows lack some new metadata fields and must be updated with complete valid audit records.
- Hash chain (prevHash, eventHash, verifyChain) has NOT been implemented. Tamper, deletion and reordering tests are outstanding. A local unanchored hash chain cannot prove deletion of the final event; trusted head checkpoint required.
- CI on current head is not yet verified. Next: repair company restore and fixture compatibility, then implement and test chain before merge.
A03 2026-10-19 continuation
- CompanyBackupService restore authorization was added at commit 9c0d438e21c11ba6c47561b80e3de7e270defcce.
- Fixed a WeakSet access defect in AuditService at commit 0056fd1748e9222603c7cd8ada89f41ba8ca6c2e.
- Added src/core/AuditChain.js at commit 567b9af1759df9448e01b9982bfe6208bcff545f (SHA-256 and a standalone chain verifier). This is NOT yet integrated into audit event writes or backup metadata; no end-to-end chain claims.
- Attempts to integrate hash code into AuditService and add chain regression tests were blocked by tool safety checks. No tests were run locally.
- Legacy audit migration, full company restore compatibility and trusted backup anchor remain unfinished.
- Client-side security boundary: the StorageService/AuditService checks defend normal application code paths, not a malicious user with IndexedDB/devtools or local file access. A backup-contained hash anchor is not independently trusted: an attacker who can rewrite the backup can rewrite its anchor. Signed or externally anchored checkpoints are needed for adversarial tamper evidence. A bare hash chain cannot detect tail deletion without an independently retained head.
Independent A03 validation branch (2026-10-20)
- Branch: fix/a03-chain-validation-20261020; draft PR #116; not accepted or merged.
- Actual GitHub Actions npm test run 39373562237, commit 1d986c1b23f01eff562c2819a7f34153e7fc1fe6: 253 tests, 248 passed, 5 failed, exit code 1. Failures: A02 audit rollback, A03 company scope, A03 append-only protection (2), accounting backup round trip. This run predates current branch and does not verify current changes.
- No local npm test was executed: local repository absent in this runtime, GitHub DNS unavailable, remote desktop offline/quota exhausted. Later PR runs have been cancelled by subsequent pushes or are pending.
- Fixed missing Auth import in tests/a03-company-scope-immutable-stores.test.mjs on this branch; no passing run verified yet.
- No independent reviewer agents were launched; no three-agent approval claimed.
A03 CI request 2026-10-20
- Implementation commit 293239951b6c15df766e891fd386b54c6f99ec51 adds anchored full backups, strict company backup order verification, deterministic v6 replay compatibility, and end-to-end tampering tests. No pass claim before CI.
- PR #116 temporarily targets main to activate the existing pull_request quality workflow; remains draft and unmerged. Remote Desktop excluded.
A03 CI evidence: 2026-10-20, run 39374384074
- SHA 46f5dd613b543778e27c498a54c664f9edf01845; completed failure, npm test: 257 tests, 251 passed, 6 failed, exit 1.
- Failures: A02 audit rollback; A03 full restore rejects modified event (error message mismatch, integrity rejection correctly occurs); A03 v6 migration; A03 company scope; A03 append-only direct protection; A03 clear rollback.
- Root cause of five fixture failures: restoreHistorical validated legacy actorId/sourceId/commandKey before deterministic migration defaults were applied. Fix permits missing legacy metadata but rejects present invalid values. Sixth test now accepts earlier chain integrity rejection rather than requiring a later immutable-overwrite error. The rejection and rollback assertion remain mandatory.
A03 completed CI evidence 2026-10-20 (pre-STATUS commit)
- PR quality workflow run 39374506277, SHA 9563296884b7131a97a265a296d99977d7522fce: completed SUCCESS. Linux npm test 257 passed / 0 failed; Windows npm test 257 passed / 0 failed. Frontend build, production npm audit, and Windows Tauri installer build all succeeded.
- This evidence verifies the application code at the stated SHA. A STATUS-only documentation commit will require its own final-head CI run before completion.
- Independent three-agent review remains NOT VERIFIED: this execution environment does not expose a multi-agent reviewer launch capability. No approval or merge is claimed.
- Local clone/npm test remains unavailable because container DNS cannot resolve github.com; GitHub Actions is the actual test runner.
A03 three-pass review initiated (2026-10-20)
- Three sequential code-review passes were performed against PR #116 because no callable subagent/Task tool is exposed. These are NOT independent agents.
- Functional pass: previous completed CI run 39374969382, SHA 95f6c976a04a72e2ddaf27f20773994e871e0250, Linux 257/257, Windows 257/257. Edge coverage gaps found; new tests added, pending new CI.
- Security/quality pass: found malformed non-array input could throw from verifyChain; addressed with invalid result. Public authorizeRestore remains a client trust-boundary limitation, not a cryptographic authorization mechanism. O(n) audit-history read per append remains a scalability concern; no unverified performance claim.
- Edge-case pass: missing explicit tests for empty/single chains, mixed legacy+hashed history, corrupted JSON, wrong anchors and concurrent writes. Added regression tests; results pending CI.
Final approval and merge remain withheld until CI and repeat review.
GitHub Actions run 39376283188 on SHA 894e1f54409a7f12455ee27b6e3d8b80f4899a55: completed FAILURE, npm test 262 total / 260 passed / 2 failed. Failures A02 rollback and A03 direct append-only protection; root cause: eager genesis-based normalization of a legacy-only snapshot intended to append after existing audit history. Changed legacy-only imports to defer chain index/hash to the active restore transaction. Mixed legacy+hashed chains remain prevalidated. Await rerun.
Security review found public AuditService.authorizeRestore permission mint. Replaced with scoped restoreFromBackup workflow, removed public mint and added negative regression test. CI pending; no pass claim for new code.
Completed PR quality CI 39376822354, SHA f83b8e6c9dd55cd62ecf4a2441463af0e6048956: SUCCESS, Linux npm test 263/263, Windows npm test 263/263, frontend and Windows installer succeeded.
Native installed-WebView2 lab 39376822375 on same SHA: FAILED, smoke fixture tests/windows-vm-installed-tauri-cdp.cjs:276 used prohibited tx.put('audit_events'). Root cause is outdated test fixture, not product restore. Updated fixture to seed through version-6 backup import, preserving the immutable restore rollback assertion; rerun pending.
A03 final three-pass sequential review and green CI (2026-10-20)
- Tool limitation: no callable independent subagent/Task launcher. Three distinct sequential re-reads were completed and documented in reviews/A03-agent1.md, A03-agent2.md, A03-agent3.md. They are NOT independent agents; each approves the defined A03 scope with zero remaining findings after fixes.
- PR quality CI 39377639299, commit 59dbc4beba2172cafdfd6c380adfa6c0aba6b445: completed SUCCESS. Linux npm test 263 passed / 0 failed; Windows npm test 263 passed / 0 failed; frontend build, dependency audit and Windows installer build succeeded.
- Installed native Windows VM lab 39377639277, same SHA: completed SUCCESS after replacing a test-only direct audit tx.put fixture with the validated legacy backup import. A08 baseline CI 39377639263: completed SUCCESS on same SHA.
- Client security boundary: audit chain checks detect accidental or untrusted backup modifications only when the head anchor is retained and trusted. The same-file anchor is not independent authentication; malicious local IndexedDB modification is outside service-layer guarantees. Hash comparison is not secret-bearing. Large-history append read complexity remains for A08 performance work.
- A03 code and tests are accepted on the evidence above. PR #116 remains draft until a completed quality run on the final documentation commit, then may be marked ready and merged. Main CI must be checked after merge.
CURRENT VERIFIED SNAPSHOT — 2026-10-20 (supersedes stale historical headings above)
- Canonical branch:
main, verified head at recovery:784f0205b5f98b834e2f96c881767a1f1888e528. - A03 PR #116 is merged, not draft or pending: merge time
2026-10-20T06:14:01Z, merge commit784f0205b5f98b834e2f96c881767a1f1888e528; final PR headc59cf2a85686be016ce0526afc48227eecf79736. - Authoritative manifest
docs/PHASE_A_RELEASE_ACCEPTANCE.jsonon main currently says A03 accepted: true, all other A01/A02/A04/A05/A06/A07/A08/INDEPENDENT_QA/DATA_BACKUP are false. Older references above saying no gates closed or PR #116 awaiting merge are historical and must not be interpreted as present status. - Final-head PR quality run 39378563767: completed SUCCESS, Linux
npm test263/263, Windowsnpm test263/263, frontend build, production dependency audit and Tauri Windows installer build successful; SHAc59cf2a85686be016ce0526afc48227eecf79736. Counts extracted from the respective job logs. - Native installed Windows VM lab 39378563787: completed SUCCESS on the same PR SHA; NSIS-installed Tauri/WebView2, v6→v7 and upgrade/reinstall checks. Synthetic-data VM evidence does not constitute a physical customer-device restoration.
- A08 baseline run 39378563726: completed SUCCESS on the PR SHA, but A08 not accepted.
- Post-merge main-SHA CI is not verified: the available PR quality workflow is configured for
pull_requestandworkflow_dispatch, notpushto main. GitHub Actions list for branch main and commit-associated PR runs did not show a run on merge commit784f0205.... Do not treat green PR CI as a distinct run on the merge SHA. CI must be verified if policy or workflow is changed to test main. - Reviews
reviews/A03-agent1.md,reviews/A03-agent2.md,reviews/A03-agent3.mdend inFinal sequential re-review — APPROVED. They were three sequential assistant passes, not independent review agents. Independent financial signoff remains open. - Threat model: hash-chain + backup-contained audit anchor does not authenticate a fully compromised client, local IndexedDB, or self-rewritten backup anchor. Appends can entail O(n) history scanning; measure under A08.
- Next gate A04: main-manifest accepted=false. Historical branch
fix/a04-reject-mixed-company-backup-20261019remains at3a059b98c31a032a6725e07cb15999dce6461c2d, diverged from main (1 ahead / 59 behind as of this check). Compare and port only justified changes with tests; do not merge that stale branch directly. - External acceptance
INDEPENDENT_QAandDATA_BACKUPremains unaccepted until actual human/device evidence. Remote Desktop is out of scope.
A04 software gate verification — 2026-10-20 (current status; earlier A04 entries are historical)
- A04 accepted: true in the updated Phase A manifest (software gate only). Current implementation is merged into
main: PR #118 (223c0a526b7d9b61b6536e1bcf6580fa5c9dabf2) adds source-company preflight and negative tests; PR #119 (120523bb053a81fe892a8af1879c94ba8bfd1d7a) enforces source ownership at theCompanyBackupServiceboundary with direct-call regression. Previous stale A04 branch was compared (1 ahead/59 behind), not merged. PR #120 (2c88c4b35017a2cd0ff1d6181bba0311fbd299d4) adds post-mergemainCI for quality and native Windows workflows. - Verified green post-merge main CI on SHA
2c88c4b35017a2cd0ff1d6181bba0311fbd299d4: quality run 39383484055 completed SUCCESS, Linux 266/266 and Windows 266/266 npm tests, frontend build, production dependency audit and installer build; native VM 39383483978 completed SUCCESS, real NSIS-installed Windows Tauri/WebView2 and synthetic backup/restore, v6→v7 migration, UI checksum/encrypted restore, wrong password, corrupted ciphertext, late-validation transaction rollback and mid-import process termination/reopen tests. - Same-sha earlier green PR evidence: PR #118 quality 39380965617 (265/265 each Linux/Windows) and native 39380965551; PR #119 quality 39381883748 (266/266 each) and native 39381883781.
- Formal review record:
reviews/A04-sequential-review-20261020.md(three sequential assistant review passes, not independent agents). No artificial client data were used and no public installer release was created. - Acceptance boundary: A04 verification uses synthetic data through an actually installed Windows application. It does not approve genuine customer backup recovery on the target device, physical power-loss testing, or independent financial/accountant approval.
DATA_BACKUPandINDEPENDENT_QAremain false in the manifest; A01/A02/A05/A06/A07/A08 remain false. SHA-256/backup-internal anchors cannot authenticate an attacker-controlled whole backup; AES-GCM integrity is conditional on password secrecy. - Next ordered gate: A01 commercial corrections/reversals/refunds. Extract criteria from
docs/PHASE_A_BACKLOG_FA.mdanddocs/PHASE_A_EXIT_RUNBOOK_FA.md, inspect existingRetailPostingServiceand tests, create a separate tested PR. Do not release publicly or claim Phase A complete.
A01 2026-10-20 continuation — scope incomplete / NOT ACCEPTED
- PR #122 (https://github.com/davoodmehraban89/Factor-easyPro/pull/122) merged in main at caa5995d5b71f1a8c89b07941bcd7f8870a723d8. The RetailPostingService.recordCash transaction now requires Auth.isAdmin() before paying a customer refund linked to an already posted sale_return. The restriction is enforced in the service layer, not only UI.
- A new regression in tests/retail-phase2.test.mjs checks that a clerk refund attempt leaves treasury, invoice paidAmount, journal and audit unchanged, while the manager-authorized refund succeeds and keeps the trial balance balanced.
- Final PR SHA 90558e5247b41c7adf40aeac65b6bdd3470db165: quality run 39385076660 successful with 267/267 Linux and 267/267 Windows tests, frontend/npm audit/Windows build; native installed Windows lab 39385076705 successful.
- Post-merge main SHA caa5995d5b71f1a8c89b07941bcd7f8870a723d8: quality run 39385956523 successful with 267/267 Linux and 267/267 Windows tests, frontend/audit/installer; native Windows VM run 39385956551 successful.
- Three sequential assistant review passes are recorded in reviews/A01-refund-auth-sequential-20261020.md; they are NOT independent agents and do not approve the entire gate.
- A01 remains accepted=false. Open acceptance scope includes representative sales/purchases/corrections, cheque reversals, explicit refund reasons/approval, fiscal-period edge cases, idempotency, reconciliation and independent financial signoff. Client-side IndexedDB controls do not authenticate hostile local storage. INDEPENDENT_QA and DATA_BACKUP remain false. No public release.
- Next actionable work: select and implement the next unverified A01 scenario from docs/PHASE_A_BACKLOG_FA.md and docs/PHASE_A_EXIT_RUNBOOK_FA.md in a separate tested PR.
A01 return-linked refund correction trace — 2026-10-20 (MERGED / NOT FULLY ACCEPTED)
- PR #124 (https://github.com/davoodmehraban89/Factor-easyPro/pull/124) merged into
mainatb7ee529a84e28ba25acda8e486441f8a198b3bc4. A01 now records an append-onlydocument_correctionsentry per cash settlement associated with a postedsale_return(customer credit payout) orpurchase_return(supplier cash recovery), linking the returnsourceId, treasuryresultId, correlated journal/audit and a derived structuredreasonCode. Existing company/period/amount/account checks and manager-only customer payout restriction remain enforced; original source invoices and earlier receipts are not rewritten by this trace entry. - Node regressions in
tests/retail-phase2.test.mjscover successful customer and supplier traces, payout/recovery limits, duplicate transaction ID, ledger balance and late unique-key insertion failure with complete rollback of treasury, invoice settlement, GL journal and audit. - Installed Windows native WebView2 E2E in
tests/windows-vm-native-functional-matrix.cjsposts a second return and authorized payout through real invoice and treasury UI forms, then verifies related treasury, correction, audit and paidAmount values. It does not constitute customer-device execution or external human approval. - Verified final PR SHA
71f78d233c5a8a0ca4ff650cc2505ae20d3c01b2: quality 39435418939 completed SUCCESS, 270/270 Linux and 270/270 Windows tests plus frontend build, production audit and installer; native installed VM 39435418629 completed SUCCESS, native report explicitly statesauthorizedRefundTracedInInstalledWebView2:true. - Verified exact post-merge main SHA
b7ee529a84e28ba25acda8e486441f8a198b3bc4: quality 39436721979 completed SUCCESS with 270/270 Linux and 270/270 Windows tests, build/audit/installer; native installed VM 39436722070 completed SUCCESS. - Review on PR #124 records three sequential inspections by one assistant, not independent reviewers; no independent accountant signoff.
reasonCodeis derived from operation type, not an explicitly user-selected commercial explanation or separate approval. The product still lacks the full A01 correction/cheque reversal/closed-period/fiscal and independent QA matrix. - Canonical manifest A01 remains accepted=false. A02, A05, A06, A07, A08, INDEPENDENT_QA and DATA_BACKUP remain false; A03 and A04 remain accepted true. No public release, genuine customer data processing or authorization to change live accounts.