Treasury & Bank Transfer Management System — سامانه مدیریت خزانه‌داری و حواله‌های بانکی

Reverify guarded V6 Windows builder with corrected staging env and unchanged private source policy

davoodmehraban89 committed Oct 19, 2026 at 01:49 UTC 3b1098a90a43be7f2329e7baf7925cbe4fac1c61
1 file changed +163
.github/workflows/private-v6-builder-ephemeral-20261018.yml new
+163
@@ -0,0 +1,163 @@
1 +name: Ephemeral private V6 builder verification (no uploads)
2 +on:
3 + push:
4 + paths:
5 + - .github/workflows/private-v6-builder-ephemeral-20261018.yml
6 + workflow_dispatch:
7 +permissions:
8 + contents: read
9 +jobs:
10 + private-builder:
11 + runs-on: windows-2022
12 + timeout-minutes: 70
13 + steps:
14 + - name: Install Node 22
15 + uses: actions/setup-node@v4
16 + with:
17 + node-version: '22'
18 + - name: Verify private V6 builder from validated short staging path, no uploads
19 + shell: pwsh
20 + env:
21 + TF_VALIDATION_READ_TOKEN: ${{ secrets.TF_VALIDATION_READ_TOKEN }}
22 + run: |
23 + $ErrorActionPreference='Stop'
24 + if([string]::IsNullOrWhiteSpace($env:TF_VALIDATION_READ_TOKEN)){throw 'PRIVATE_READ_TOKEN_NOT_AVAILABLE'}
25 + $env:GH_TOKEN=$env:TF_VALIDATION_READ_TOKEN
26 + $private='davoodmehraban89/TreasuryFlow-Validation-Private'
27 + $branch='dev/v6-sql-editor-assertion-repair-20261017'
28 + $work=Join-Path $env:RUNNER_TEMP 'v6-protected-builder'
29 + New-Item -ItemType Directory -Path $work -Force | Out-Null
30 + $paths=@('qa/scripts/rebuild-v6-private-nonfinal-qa.ps1',
31 + 'qa/patches/v6-sql-assertion-fix.mjs',
32 + 'qa/patches/v6-add-readonly-sqlserver-adapter.mjs',
33 + 'qa/windows/v6-installed-native-gui-os-clipboard.mjs')
34 + foreach($path in $paths){
35 + $url="https://api.github.com/repos/$private/contents/${path}?ref=$branch"
36 + $api=Invoke-RestMethod -Uri $url -Headers @{ Authorization="Bearer $env:TF_VALIDATION_READ_TOKEN"; Accept='application/vnd.github+json'; 'User-Agent'='TreasuryFlow-private-qa' }
37 + if(!$api.content -or $api.encoding -ne 'base64'){throw 'PRIVATE_TEXT_FETCH_FAILED'}
38 + $dest=Join-Path $work $path
39 + New-Item -ItemType Directory -Path (Split-Path $dest -Parent) -Force | Out-Null
40 + [IO.File]::WriteAllBytes($dest,[Convert]::FromBase64String(($api.content -replace '\s','')))
41 + }
42 + $archive=Join-Path $work 'TreasuryFlow_Validation_Staging_20261017.zip'
43 + & gh release download validation-inputs-20261017 --repo $private --pattern TreasuryFlow_Validation_Staging_20261017.zip --dir $work *> (Join-Path $work 'release-fetch.log')
44 + if($LASTEXITCODE -ne 0){throw 'PRIVATE_RELEASE_DOWNLOAD_FAILED'}
45 + $destination=Join-Path $work 'run-once-candidate'
46 + $privateLog=Join-Path $work 'full-builder-log-private.txt'
47 + $errors=$null
48 + $tokens=$null
49 + [void][Management.Automation.Language.Parser]::ParseFile((Join-Path $work $paths[0]),[ref]$tokens,[ref]$errors)
50 + if($errors.Count -gt 0){throw 'PRIVATE_BUILDER_POWERSHELL_PARSE_FAILED'}
51 + & pwsh -NoProfile -File (Join-Path $work $paths[0]) -SourceArchive $archive -OutputRoot $destination *> $privateLog
52 + if($LASTEXITCODE -ne 0) {
53 + $known='ORIGINAL_PRIVATE_SOURCE_HASH_MISMATCH|UNSAFE_ZIP_ENTRY_PATH|ARCHIVE_ENTRY_COUNT_LIMIT|ZIP_UNCOMPRESSED_SIZE_LIMIT|ZIP_SYMLINK_DISALLOWED|DUPLICATE_ZIP_ENTRY|EXTRACTED_REPARSE_POINT_DISALLOWED|OFFICIAL_XLSX_PACKAGE_LOCK_INTEGRITY_NOT_PINNED_TO_VERIFIED_ARCHIVE|SHEETJS_OFFICIAL_VENDOR_SHA256_MISMATCH|INITIAL_NPM_CI_FAILED|REMOVE_VULNERABLE_XLSX_FAILED|INSTALL_PINNED_OFFICIAL_XLSX_FAILED|PATCHED_LOCK_NPM_CI_FAILED|KNOWN_PRODUCTION_DEPENDENCY_ADVISORIES_REMAIN|V6_UNIT_REGRESSION_FAILED|V6_GATE_FAILED_[A-Z]+|V6_NSIS_BUILDER_FAILED|READ_ONLY_SQL_ADAPTER_PATCH_FAILED|SQL_EDITOR_TEST_PATCH_FAILED'
54 + $nsisLog=Join-Path $destination 'private-local-logs/private-nsis.log'
55 + if(Test-Path -LiteralPath $nsisLog){
56 + $nsisText=Get-Content -LiteralPath $nsisLog -Raw
57 + $knownClasses=[ordered]@{
58 + NSIS_PROCESS='(?i)makensis|nsis'
59 + NETWORK='(?i)ETIMEDOUT|ECONNRESET|socket hang up|download failed'
60 + FILE_PATH='(?i)ENOENT|not found|cannot find module'
61 + SIGNING='(?i)signing|certificate|winCodeSign'
62 + ACCESS='(?i)EPERM|EACCES|access denied'
63 + NATIVE_DEPENDENCY='(?i)node-gyp|npmRebuild|native dependency'
64 + CONFIGURATION='(?i)configuration|invalid config|schema'
65 + ASAR='(?i)asar|cannot pack'
66 + WINDOWS_PATH_LENGTH='(?i)path too long|filename too long'
67 + UNKNOWN_BUILDER_ERROR='(?i)error|failed|⨯'
68 + }
69 + $specificClasses=[ordered]@{
70 + ASAR_ENTRY_MISSING='(?i)(?:Application entry file|main entry file|entry file.*does not exist)'
71 + ELECTRON_MAIN_MISSING='(?i)(?:main\.cjs.*not found|main\.js.*not found|entrypoint.*missing)'
72 + ELECTRON_APP_PACKAGE='(?i)(?:app\.asar.*does not exist|no app\.asar|invalid app package)'
73 + FILE_ALREADY_EXISTS='(?i)(?:file already exists|EEXIST)'
74 + PATH_IS_TOO_LONG='(?i)(?:ENAMETOOLONG|path too long|filename or extension is too long)'
75 + UNRESOLVED_DEPENDENCY='(?i)(?:unresolved dependenc|missing dependenc|cannot resolve)'
76 + APP_BUILDER_EXIT='(?i)(?:exit status [0-9]+|exit code [0-9]+|errorOut=)'
77 + CODE_SIGN_FAILURE='(?i)(?:failed to sign|signing failed|signtool.*error)'
78 + NSIS_MAKENSIS_FAILURE='(?i)(?:makensis.*failed|NSIS Error|failed to compile script)'
79 + INTEGRITY_FAILURE='(?i)(?:integrity checksum failed|incorrect integrity|checksum mismatch)'
80 + ZIP_FAILURE='(?i)(?:7zip.*error|failed to extract|archive corrupted)'
81 + RUNNER_RESOURCE_FAILURE='(?i)(?:out of memory|ENOMEM|disk full|ENOSPC)'
82 + WINDOWS_PROCESS_FAILURE='(?i)(?:spawn.*fail|The system cannot find|CreateProcess)'
83 + PACKAGING_REBUILD_FAILURE='(?i)(?:failed to rebuild|rebuilding native|node-gyp failed)'
84 + AFTER_PACK_HOOK_FAILURE='(?i)(?:afterPack.*fail|afterSign.*fail)'
85 + PUBLISH_FAILURE='(?i)(?:publish.*fail|upload.*fail)'
86 + }
87 + foreach($name in $specificClasses.Keys){
88 + Write-Host ('PRIVATE_QA_NSIS_SPECIFIC_'+$name+'='+[bool]($nsisText -match $specificClasses[$name]))
89 + }
90 + $releasePath=Join-Path $env:RUNNER_TEMP 'private-stage/release'
91 + $binCount=@(Get-ChildItem -LiteralPath $releasePath -File -Filter '*.exe' -ErrorAction SilentlyContinue).Count
92 + Write-Host ('PRIVATE_NSIS_RESULT_EXE_PRESENT='+[bool]($binCount -gt 0))
93 + $lastLineCount=@($nsisText -split '\\r?\\n' | Where-Object {$_ -match '(?i)error|fail|exit|throw'}).Count
94 + Write-Host ('PRIVATE_NSIS_ERROR_LIKE_LINE_COUNT='+[Math]::Min($lastLineCount,100))
95 + $shortCodes=[regex]::Matches($nsisText,'\\b(?:ERR_[A-Z0-9_]{4,64}|E(?:ACCES|PERM|NOENT|EXIST|CONNRESET|TIMEDOUT|NOTFOUND|NOSPC|NAMETOOLONG|PROTO|AI_AGAIN))\\b')
96 + $codes=@($shortCodes | ForEach-Object {$_.Value} | Select-Object -Unique | Select-Object -First 8)
97 + if($codes.Count -gt 0){Write-Host ('PRIVATE_QA_NSIS_SAFE_ERROR_CODES='+($codes -join ','))}
98 + foreach($name in $knownClasses.Keys){
99 + Write-Host ('PRIVATE_QA_NSIS_DIAGNOSTIC_'+$name+'='+[bool]($nsisText -match $knownClasses[$name]))
100 + }
101 + }
102 + $record=Get-Content $privateLog -Raw
103 + $phases=[regex]::Matches($record,'PRIVATE_QA_PHASE=[A-Z_]+')
104 + $lastPhase=if($phases.Count -gt 0){$phases[$phases.Count-1].Value}else{'PRIVATE_QA_PHASE=BEFORE_ARCHIVE_PREFLIGHT'}
105 + Write-Host ('DIAGNOSTIC_LAST_VERIFIED_PHASE='+$lastPhase)
106 + $match=[regex]::Match($record,$known)
107 + $code=if($match.Success){$match.Value}else{'PRIVATE_BUILD_FAILED_DETAILS_RETAINED_ONLY_ON_EPHEMERAL_WINDOWS_RUNNER'}
108 + throw $code
109 + }
110 + $deliverables=Join-Path $destination 'PRIVATE_QA_DELIVERABLES'
111 + $proof=Get-Content (Join-Path $deliverables 'NONFINAL_QA_SHA256_MANIFEST.json') -Raw | ConvertFrom-Json
112 + $source=Join-Path $deliverables 'TreasuryFlow_V6_1.0.1_Patched_NONFINAL_QA_Source.zip'
113 + $exe=Join-Path $deliverables 'TreasuryFlow_V6_1.0.1_Patched_NONFINAL_QA_Setup.exe'
114 + if(!(Test-Path $source) -or !(Test-Path $exe) -or $proof.finalRelease -ne $false -or $proof.v7FinalAccepted -ne $false -or $proof.productionNpmVulnerabilities -ne 0){throw 'NONFINAL_MANIFEST_POLICY_FAILED'}
115 + if((Get-FileHash $source -Algorithm SHA256).Hash -ne $proof.patchedSourceSha256 -or
116 + (Get-FileHash $exe -Algorithm SHA256).Hash -ne $proof.patchedInstallerSha256){throw 'NONFINAL_MANIFEST_DIGEST_MISMATCH'}
117 + Write-Host 'PRIVATE_V6_PATCHED_SOURCE_AND_WINDOWS_SETUP_BUILD_PASS'
118 + Write-Host 'PRIVATE_V6_NPM_SECURITY_TEST_TYPECHECK_LINT_BUILD_SMOKE_PASS'
119 + Write-Host 'NO_SOURCE_OR_BINARY_UPLOADED_TO_PUBLIC_ARTIFACTS'
120 + # Replay installed native GUI/clipboard acceptance on this exact built EXE.
121 + & node --check (Join-Path $work $paths[3])
122 + if($LASTEXITCODE -ne 0){throw 'INSTALLED_GUI_HARNESS_SYNTAX_FAILED'}
123 + $env:BANK_ADAPTER_MODE='disabled'
124 + $env:TREASURYFLOW_DESKTOP_LOCAL='1'
125 + $env:TREASURYFLOW_ENABLE_MAYAN_EXTERNAL_READ='0'
126 + $env:TREASURYFLOW_MAYAN_ENABLE_EXTERNAL_READ='0'
127 + $env:TREASURYFLOW_ENABLE_SQL_LAB='0'
128 + $isolation=Join-Path $env:RUNNER_TEMP 'v6-gui-test-data'
129 + $installDir=Join-Path $env:RUNNER_TEMP 'TreasuryFlow-V6-Isolated-Installed'
130 + New-Item -ItemType Directory -Path $isolation -Force | Out-Null
131 + $install=Start-Process -FilePath $exe -ArgumentList @('/S',('/D='+$installDir)) -PassThru
132 + if(!$install.WaitForExit(240000)){try{$install.Kill()}catch{};throw 'V6_NSIS_INSTALL_TIMEOUT'}
133 + if($install.ExitCode -ne 0){throw 'V6_NSIS_NONZERO_EXIT'}
134 + $installed=@(Get-ChildItem -LiteralPath $installDir -Recurse -Filter 'TreasuryFlow.exe' -File -ErrorAction SilentlyContinue)
135 + if($installed.Count -ne 1){throw 'INSTALLED_V6_EXE_NOT_UNIQUE'}
136 + Write-Host 'GATE_PASS_SAME_ARTIFACT_NSIS_INSTALL'
137 + $guiLog=Join-Path $work 'private-installed-gui-log.txt'
138 + & node (Join-Path $work $paths[3]) $installed[0].FullName $isolation *> $guiLog
139 + if($LASTEXITCODE -ne 0){
140 + $guiRecord=Get-Content (Join-Path $isolation 'private-gui-report.json') -Raw | ConvertFrom-Json
141 + $safe=$guiRecord.failure -replace '[^A-Z0-9_ ]',''
142 + if(!$safe){$safe='UNKNOWN'}
143 + throw ('V6_SAME_ARTIFACT_INSTALLED_GUI_FAILED_'+$safe)
144 + }
145 + $guiRecord=Get-Content (Join-Path $isolation 'private-gui-report.json') -Raw | ConvertFrom-Json
146 + if($guiRecord.status -ne 'PASS' -or !$guiRecord.osClipboard -or !$guiRecord.bankDisabled -or
147 + !$guiRecord.copyButton -or !$guiRecord.writable -or !$guiRecord.select){throw 'V6_SAME_ARTIFACT_GUI_REPORT_FAIL'}
148 + Write-Host 'GATE_PASS_SAME_ARTIFACT_INSTALLED_WINDOWS_OS_CLIPBOARD'
149 + $uninstall=@(Get-ChildItem -LiteralPath $installDir -Recurse -File -ErrorAction SilentlyContinue |
150 + Where-Object {$_.Name -match '^uninstall.*[.]exe$'})
151 + if($uninstall.Count -ne 1){throw 'V6_NSIS_UNINSTALLER_NOT_FOUND'}
152 + $uninstallProcess=Start-Process -FilePath $uninstall[0].FullName -ArgumentList '/S' -PassThru
153 + if(!$uninstallProcess.WaitForExit(90000)){try{$uninstallProcess.Kill()}catch{};throw 'V6_UNINSTALL_TIMEOUT'}
154 + if($uninstallProcess.ExitCode -ne 0){throw 'V6_UNINSTALL_NONZERO'}
155 + for($i=0;$i -lt 90;$i++){
156 + $remaining=@(Get-ChildItem -LiteralPath $installDir -Recurse -File -Filter 'TreasuryFlow.exe' -ErrorAction SilentlyContinue)
157 + if($remaining.Count -eq 0){break}
158 + Start-Sleep -Seconds 1
159 + }
160 + if($remaining.Count -gt 0){throw 'V6_UNINSTALL_LEFT_BINARY'}
161 + Write-Host 'GATE_PASS_SAME_ARTIFACT_NSIS_UNINSTALL'
162 + Write-Host 'V6_NONFINAL_PRIVATE_QA_10_PLUS_GATES_FULL_PASS'
163 +