[GAP-068]: verify complete deployed Strategies source folder

This commit is contained in:
2026-10-26 09:03:16 -04:00
parent 5907e9cc54
commit 0bbc031c58
7 changed files with 197 additions and 8 deletions

View File

@@ -4,25 +4,27 @@
## ▶️ 2026-10-24 STATE — read this first ## ▶️ 2026-10-24 STATE — read this first
**Run order of record: `NEXT_PROMPT.md`.** P0-E is complete: GAP-064 and governance sync committed separately on 2026-10-26; `verify-build.bat` passed 581 tests and the working tree is clean. Stage 0 remains in progress: the 2026-07-13 orphan `bin\Custom\Strategies\SimpleORBStrategy.cs` is **still deployed** (GAP-065), and 46 commits remain unpushed (GAP-069). **Run order of record: `NEXT_PROMPT.md`.** P0-E is complete: GAP-064 and governance sync committed separately on 2026-10-26; `verify-build.bat` passed 581 tests and the working tree is clean. P0-D / GAP-069 closed 2026-10-26 after the operator pushed `cleanup/wrappers-pass2` (`99e993b..5907e9c`); the branch is level with origin. Stage 0 remains in progress: the 2026-07-13 orphan `bin\Custom\Strategies\SimpleORBStrategy.cs` is **still deployed** (GAP-065).
| Area | State | Evidence | | Area | State | Evidence |
|---|---|---| |---|---|---|
| Deployed code matches repo | ❌ | Orphan `SimpleORBStrategy.cs` still present (modified 2026-07-13). **GAP-065** | | Deployed code matches repo | ❌ | Orphan `SimpleORBStrategy.cs` still present (modified 2026-07-13). **GAP-065** |
| **Backtests trade** | ❌ **NO since 2026-08-18** | `session_20261019_155354.log`: `Account : Backtest`, `HistoricalReplayCatchup count=117`, zero `SUBMIT`. **GAP-077** | | **Backtests trade** | ❌ **NO since 2026-08-18** | `session_20261019_155354.log`: `Account : Backtest`, `HistoricalReplayCatchup count=117`, zero `SUBMIT`. **GAP-077** |
| Live SIM | 🟡 | 2026-10-05: 844 `WarmupIncomplete`, `ageSeconds≈602` — possible delayed data. **GAP-078** | | Live SIM | 🟡 | 2026-10-05: 844 `WarmupIncomplete`, `ageSeconds≈602` — possible delayed data. **GAP-078** |
| Working tree / push | ❌ | Dirty; unpushed (GAP-069) | | Working tree / push | ✅ | Operator push completed 2026-10-26; GAP-069 closed. Subsequent local commits are not pushed by this task. |
| Gate Run #3 | ⏳ cannot start | Freeze discarded (`DEC-20260922-01`) | | Gate Run #3 | ⏳ cannot start | Freeze discarded (`DEC-20260922-01`) |
**P0-E / N-04 complete (2026-10-26):** `[GAP-064]` `bf7acbb`; governance/prompt extraction `[GOV]` commit follows. Verification: `verify-build.bat`, 581/581 tests. No deploy or push. **P0-E / N-04 complete (2026-10-26):** `[GAP-064]` `bf7acbb`; governance/prompt extraction `[GOV]` commit follows. Verification: `verify-build.bat`, 581/581 tests. No deploy or push.
**P0-D / GAP-069 closed (2026-10-26):** operator pushed `cleanup/wrappers-pass2` to origin (`99e993b..5907e9c`); branch confirmed level with origin.
**Open blockers (v9.0 + 2026-10-24):** **Open blockers (v9.0 + 2026-10-24):**
- **[GAP-077] Backtests take zero trades** | HIGH | 🔴 NEW — live catch-up guard `State == State.Historical && Account != null` blocks every Strategy Analyzer intent because Analyzer uses the `Backtest` account. Also breaks backtest `MaxDailyTrades` counting. `DEC-20261024-01`; prompt `NEXT_PROMPT.md` App. B. - **[GAP-077] Backtests take zero trades** | HIGH | 🔴 NEW — live catch-up guard `State == State.Historical && Account != null` blocks every Strategy Analyzer intent because Analyzer uses the `Backtest` account. Also breaks backtest `MaxDailyTrades` counting. `DEC-20261024-01`; prompt `NEXT_PROMPT.md` App. B.
- **[GAP-065] Deployed-source divergence** | CRITICAL | operator P0-A sweep. `DEC-20260922-01`. - **[GAP-065] Deployed-source divergence** | CRITICAL | operator P0-A sweep. `DEC-20260922-01`.
- **[GAP-054] Runner trail failed a +$1,200 excursion** | CRITICAL | independent of GAP-065; `TASK_GAP054_FOLLOWUP_TRAIL_VALIDATION_FAILURE_PROMPT.md` (Stage 2). - **[GAP-054] Runner trail failed a +$1,200 excursion** | CRITICAL | independent of GAP-065; `TASK_GAP054_FOLLOWUP_TRAIL_VALIDATION_FAILURE_PROMPT.md` (Stage 2).
- **[GAP-066] `base.OnStateChange()` last — overwrites 4 ORB defaults** | HIGH | `TASK_GAP066_SETDEFAULTS_ORDERING_PROMPT.md`. - **[GAP-066] `base.OnStateChange()` last — overwrites 4 ORB defaults** | HIGH | `TASK_GAP066_SETDEFAULTS_ORDERING_PROMPT.md`.
- **[GAP-068] Deploy verification per-file only** | HIGH | `TASK_GAP068_DEPLOY_VERIFICATION_PROMPT.md`. - **[GAP-068] Deploy verification per-file only** | HIGH | ✅ Whole-folder preflight implemented; operator "before"/"after" proof pending (`TASK_GAP068_DEPLOY_VERIFICATION_PROMPT.md`).
- **[GAP-069] Commits unpushed** | HIGH | operator P0-D. - **[GAP-069] Commits unpushed** | ✅ CLOSED 2026-10-26 | Operator push `99e993b..5907e9c`; branch level with origin.
- **[GAP-064 / GAP-034] Silent zero-trade days** | root cause GAP-065; closes on N-02 SIM day showing `OrbRangeNotEstablished`. - **[GAP-064 / GAP-034] Silent zero-trade days** | root cause GAP-065; closes on N-02 SIM day showing `OrbRangeNotEstablished`.
- **[GAP-062] `trend_confirm` direction fix** | ❌ never live (in the shadowed file). - **[GAP-062] `trend_confirm` direction fix** | ❌ never live (in the shadowed file).
- **[GAP-067] 8 shadowed properties** | MEDIUM | `NEXT_PROMPT.md` App. C. - **[GAP-067] 8 shadowed properties** | MEDIUM | `NEXT_PROMPT.md` App. C.

View File

@@ -9,8 +9,8 @@ Run order of record: **`NEXT_PROMPT.md`**. Stage model from Master Document v9.0
| ID | Item | Prompt / action | Owner | | ID | Item | Prompt / action | Owner |
|---|---|---|---| |---|---|---|---|
| P0-E | ✅ Complete 2026-10-26; GAP-064 `bf7acbb`, governance/prompt extraction `[GOV]` commit follows; 581 tests passed | `NEXT_PROMPT.md` App. A → `TASK_P0E_TREE_RECONCILE_PROMPT.md` | Kilocode | | P0-E | ✅ Complete 2026-10-26; GAP-064 `bf7acbb`, governance/prompt extraction `[GOV]` commit follows; 581 tests passed | `NEXT_PROMPT.md` App. A → `TASK_P0E_TREE_RECONCILE_PROMPT.md` | Kilocode |
| P0-D | `git push origin cleanup/wrappers-pass2` (GAP-069) | operator | Operator | | P0-D | ✅ CLOSED 2026-10-26; operator pushed `cleanup/wrappers-pass2` (`99e993b..5907e9c`), branch level with origin (GAP-069) | operator | Operator |
| P0-B | Whole-folder deploy verification (GAP-068) | `TASK_GAP068_DEPLOY_VERIFICATION_PROMPT.md` | Kilocode | | P0-B | ✅ Implemented and committed 2026-10-26; whole-folder deploy verification (GAP-068), operator before/after run remains | `TASK_GAP068_DEPLOY_VERIFICATION_PROMPT.md` | Kilocode |
| P0-A | Delete orphan `SimpleORBStrategy.cs` + sweep `bin\Custom\Strategies` (GAP-065) | operator, after preflight "before" run | Operator | | P0-A | Delete orphan `SimpleORBStrategy.cs` + sweep `bin\Custom\Strategies` (GAP-065) | operator, after preflight "before" run | Operator |
| P0-C | `base.OnStateChange()` ordering (GAP-066) | `TASK_GAP066_SETDEFAULTS_ORDERING_PROMPT.md` | Kilocode | | P0-C | `base.OnStateChange()` ordering (GAP-066) | `TASK_GAP066_SETDEFAULTS_ORDERING_PROMPT.md` | Kilocode |
| P0-H | **Backtests blocked by live catch-up guard (GAP-077)** | `NEXT_PROMPT.md` App. B → `TASK_GAP077_BACKTEST_HISTORICAL_GUARD_PROMPT.md` | Kilocode | | P0-H | **Backtests blocked by live catch-up guard (GAP-077)** | `NEXT_PROMPT.md` App. B → `TASK_GAP077_BACKTEST_HISTORICAL_GUARD_PROMPT.md` | Kilocode |

View File

@@ -13,6 +13,24 @@ Use this file to record durable project decisions that affect implementation pat
## Decision Log ## Decision Log
### DEC-20261026-01
- **ID:** DEC-20261026-01
- **Date:** 2026-10-26
- **Status:** implemented — GAP-068 whole-folder verification committed; operator before/after validation pending
- **Context:** `tools/preflight/preflight.ps1` check 5 compared only deployed `NT8StrategyBase.cs`. `Write-DeployedSourceHashes` captured every Strategies `.cs` but did not compare them. This left the orphan-source failure in DEC-20260922-01 undetected; see Master Document v9.0 §1.3 Finding 1 and §4.4.
- **Decision:** Compare the four `.cs` files copied to `bin\Custom\Strategies` by `deploy-to-nt8.bat` against repository SHA-256 values, and fail on any other `.cs` except `@` NinjaTrader samples, the operator's `@@` strategies, `ORBFibPullbackV1.cs`, and `MinimalTestStrategy.cs` (the last is retained despite the known deploy-script mismatch, GAP-073). Report each discrepancy with repository/deployed timestamps and, for unexpected files, same-name source paths and any same-type match found in deployed SDK/NT assemblies. Never delete deployed files from preflight.
- **Verification:** The standalone PowerShell fixture test exercises a matching file, hash mismatch, missing deployed file, allow-listed foreign file, and unexpected file; it passed separately from `verify-build.bat`. The operator must run the documented preflight before P0-A and retain the failure naming `SimpleORBStrategy.cs`; run it again after cleanup/recompile.
- **Scope note:** Manifest hashes and additional backup copies were not added; the secondary requests were deferred. `deployment/Verify-Deployment.ps1`'s `MinimalTestStrategy.cs` mismatch is documented and left unchanged.
- **Related Files:** `tools/preflight/preflight.ps1`, `tools/preflight/strategy-source-verification.ps1`, `tools/preflight/tests/strategy-source-verification.tests.ps1`, `deployment/deploy-to-nt8.bat`, `deployment/Verify-Deployment.ps1`, DEC-20260922-01, Master Document v9.0 §§1.3, 4.4.
### DEC-20261026-02
- **ID:** DEC-20261026-02
- **Date:** 2026-10-26
- **Status:** resolved — GAP-069 / P0-D closed
- **Context:** Operator pushed branch `cleanup/wrappers-pass2` to origin on 2026-10-26, covering `99e993b..5907e9c`.
- **Decision:** Mark GAP-069 closed; branch confirmed level with origin. No push performed by this task.
- **Related Files:** `SPRINT_BOARD.md`, `docs/00-governance/active_work.md`.
### DEC-20261024-01 ### DEC-20261024-01
- **ID:** DEC-20261024-01 - **ID:** DEC-20261024-01
- **Date:** 2026-10-24 - **Date:** 2026-10-24

View File

@@ -19,7 +19,10 @@ The script prints `PASS` or `FAIL` for:
- `MaxDailyTrades=1` - `MaxDailyTrades=1`
4. Most recent settings export `Account` and `Instrument` match the expected arguments 4. Most recent settings export `Account` and `Instrument` match the expected arguments
5. Deployed `NT8StrategyBase.cs` hash matches the repo copy 5. Deployed `NT8StrategyBase.cs` hash matches the repo copy
6. Free disk space in the log directory drive is greater than `1 GB` 6. All four `.cs` files copied by `deploy-to-nt8.bat` (`NT8StrategyBase.cs`, `SimpleORBNT8.cs`, `BaseNT8StrategyWrapper.cs`, `SimpleORBNT8Wrapper.cs`) match repository SHA-256 hashes, and no unexpected `.cs` files exist in `Strategies`
7. Free disk space in the log directory drive is greater than `1 GB`
The folder check allows root-level `@`/`@@` NinjaTrader and operator strategies plus `ORBFibPullbackV1.cs` and `MinimalTestStrategy.cs`. It reports discrepancies with file timestamps; unexpected files also report same-named matches under `src` and any duplicate declared type found in `NT8.Strategies.dll` or `NinjaTrader.Custom.dll`. It never deletes deployed files. `MinimalTestStrategy.cs` remains allow-listed despite the known `Verify-Deployment.ps1`/batch deploy mismatch (GAP-073).
Every failure prints a specific remedy. The script exits `0` only when every check passes. Any failure returns exit code `1`. Every failure prints a specific remedy. The script exits `0` only when every check passes. Any failure returns exit code `1`.
@@ -77,6 +80,12 @@ powershell -ExecutionPolicy Bypass -File .\tools\preflight\preflight.ps1 `
PowerShell also accepts `-Freeze`. PowerShell also accepts `-Freeze`.
The fixture test for the whole-folder comparison logic can be run directly with:
```powershell
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\tools\preflight\tests\strategy-source-verification.tests.ps1
```
Freeze captures: Freeze captures:
- current settings export - current settings export

View File

@@ -38,6 +38,7 @@ function Get-ScriptDirectory {
$script:ScriptDir = Get-ScriptDirectory $script:ScriptDir = Get-ScriptDirectory
$script:RepoRoot = [System.IO.Path]::GetFullPath((Join-Path $script:ScriptDir '..\..')) $script:RepoRoot = [System.IO.Path]::GetFullPath((Join-Path $script:ScriptDir '..\..'))
. (Join-Path $script:ScriptDir 'strategy-source-verification.ps1')
if ([string]::IsNullOrEmpty($RepoStrategyBasePath)) { if ([string]::IsNullOrEmpty($RepoStrategyBasePath)) {
$RepoStrategyBasePath = [System.IO.Path]::GetFullPath((Join-Path $script:RepoRoot 'src\NT8.Adapters\Strategies\NT8StrategyBase.cs')) $RepoStrategyBasePath = [System.IO.Path]::GetFullPath((Join-Path $script:RepoRoot 'src\NT8.Adapters\Strategies\NT8StrategyBase.cs'))
} }
@@ -518,6 +519,10 @@ function Invoke-PreflightChecks {
} }
Write-CheckResult -Number 5 -Passed $hashPassed -Title 'Deployed NT8StrategyBase.cs matches repo copy' -Detail $hashDetail -Remedy 'Redeploy NT8StrategyBase.cs from the repo to the NinjaTrader Strategies directory and confirm the deployed source exactly matches the repo copy before enabling.' Write-CheckResult -Number 5 -Passed $hashPassed -Title 'Deployed NT8StrategyBase.cs matches repo copy' -Detail $hashDetail -Remedy 'Redeploy NT8StrategyBase.cs from the repo to the NinjaTrader Strategies directory and confirm the deployed source exactly matches the repo copy before enabling.'
$sourceIssues = @(Compare-DeployedStrategySources -RepositoryRoot $script:RepoRoot -DeployedDirectory $NtStrategiesDirectory)
$sourceDetail = if ($sourceIssues.Count -eq 0) { 'all four deploy-managed source files match; no unexpected .cs files found' } else { Format-StrategySourceIssues -Issues $sourceIssues }
Write-CheckResult -Number 6 -Passed ($sourceIssues.Count -eq 0) -Title 'All deployed Strategies sources match the repository; no unexpected .cs files' -Detail $sourceDetail -Remedy 'For each discrepancy, compare repository/deployed timestamps and hashes. Restore or redeploy missing/mismatched managed files. Review unexpected files and remove or retain them deliberately; preflight never deletes deployed files.'
$spacePassed = $false $spacePassed = $false
$spaceDetail = '' $spaceDetail = ''
if ($logDirExists) { if ($logDirExists) {
@@ -526,7 +531,7 @@ function Invoke-PreflightChecks {
$spaceDetail = ('free space={0} GB' -f [Math]::Round(($freeBytes / 1GB), 2)) $spaceDetail = ('free space={0} GB' -f [Math]::Round(($freeBytes / 1GB), 2))
} }
else { $spaceDetail = 'log directory missing' } else { $spaceDetail = 'log directory missing' }
Write-CheckResult -Number 6 -Passed $spacePassed -Title 'Disk space greater than 1 GB in log directory drive' -Detail $spaceDetail -Remedy 'Free disk space on the log drive or move the log directory to a drive with more than 1 GB available before enabling the strategy.' Write-CheckResult -Number 7 -Passed $spacePassed -Title 'Disk space greater than 1 GB in log directory drive' -Detail $spaceDetail -Remedy 'Free disk space on the log drive or move the log directory to a drive with more than 1 GB available before enabling the strategy.'
} }
catch { catch {
$script:AllPassed = $false $script:AllPassed = $false

View File

@@ -0,0 +1,114 @@
function Get-ExpectedStrategySourceFiles {
param([string]$RepositoryRoot)
return @{
'NT8StrategyBase.cs' = 'src\NT8.Adapters\Strategies\NT8StrategyBase.cs'
'SimpleORBNT8.cs' = 'src\NT8.Adapters\Strategies\SimpleORBNT8.cs'
'BaseNT8StrategyWrapper.cs' = 'src\NT8.Adapters\Wrappers\BaseNT8StrategyWrapper.cs'
'SimpleORBNT8Wrapper.cs' = 'src\NT8.Adapters\Wrappers\SimpleORBNT8Wrapper.cs'
}
}
function Get-DeclaredSourceTypeNames {
param([string]$FilePath)
$content = [System.IO.File]::ReadAllText($FilePath)
$namespaceMatch = [regex]::Match($content, '(?m)^\s*namespace\s+([\w.]+)')
if (-not $namespaceMatch.Success) { return @() }
$namespaceName = $namespaceMatch.Groups[1].Value
$typeMatches = [regex]::Matches($content, '(?m)^\s*(?:(?:public|internal|protected|private|abstract|sealed|static|partial|new)\s+)*(?:class|struct|interface|enum)\s+(\w+)')
return @($typeMatches | ForEach-Object { $namespaceName + '.' + $_.Groups[1].Value } | Select-Object -Unique)
}
function Find-DeployedAssemblyTypeCollisions {
param(
[string]$FilePath,
[string]$AssemblyDirectory
)
$declaredTypes = @(Get-DeclaredSourceTypeNames -FilePath $FilePath)
if ($declaredTypes.Count -eq 0 -or -not (Test-Path -LiteralPath $AssemblyDirectory -PathType Container)) { return @() }
$collisions = @()
$assemblies = @(Get-ChildItem -LiteralPath $AssemblyDirectory -File -Filter '*.dll' | Where-Object { $_.Name -in @('NT8.Strategies.dll', 'NinjaTrader.Custom.dll') })
foreach ($assemblyFile in $assemblies) {
try {
$assembly = [System.Reflection.Assembly]::ReflectionOnlyLoadFrom($assemblyFile.FullName)
foreach ($typeName in $declaredTypes) {
if ($assembly.GetType($typeName, $false, $false) -ne $null) {
$collisions += ('{0} in {1}' -f $typeName, $assemblyFile.Name)
}
}
}
catch {
# An unavailable dependency must not hide the source-file discrepancy itself.
}
}
return @($collisions | Select-Object -Unique)
}
function Compare-DeployedStrategySources {
param(
[string]$RepositoryRoot,
[string]$DeployedDirectory,
[hashtable]$ExpectedFiles = (Get-ExpectedStrategySourceFiles -RepositoryRoot $RepositoryRoot),
[string[]]$AllowedForeignNames = @('MinimalTestStrategy.cs', 'ORBFibPullbackV1.cs')
)
$issues = New-Object System.Collections.Generic.List[object]
$expectedByDestination = @{}
foreach ($destination in $ExpectedFiles.Keys) {
$expectedByDestination[$destination] = $ExpectedFiles[$destination]
$repoPath = Join-Path $RepositoryRoot $ExpectedFiles[$destination]
$deployedPath = Join-Path $DeployedDirectory $destination
if (-not (Test-Path -LiteralPath $repoPath -PathType Leaf)) {
$issues.Add([pscustomobject]@{ Kind = 'missing-repository'; File = $destination; RepoPath = $ExpectedFiles[$destination]; RepoTimestamp = 'missing'; DeployedTimestamp = if (Test-Path -LiteralPath $deployedPath) { (Get-Item -LiteralPath $deployedPath).LastWriteTime.ToString('yyyy-MM-dd HH:mm:ss') } else { 'missing' }; SameNamedSource = ''; TypeCollisions = @() })
continue
}
$repoFile = Get-Item -LiteralPath $repoPath
if (-not (Test-Path -LiteralPath $deployedPath -PathType Leaf)) {
$issues.Add([pscustomobject]@{ Kind = 'missing-deployed'; File = $destination; RepoPath = $ExpectedFiles[$destination]; RepoTimestamp = $repoFile.LastWriteTime.ToString('yyyy-MM-dd HH:mm:ss'); DeployedTimestamp = 'missing'; SameNamedSource = ''; TypeCollisions = @() })
continue
}
$deployedFile = Get-Item -LiteralPath $deployedPath
$repoHash = (Get-FileHash -LiteralPath $repoPath -Algorithm SHA256).Hash
$deployedHash = (Get-FileHash -LiteralPath $deployedPath -Algorithm SHA256).Hash
if ($repoHash -ne $deployedHash) {
$issues.Add([pscustomobject]@{ Kind = 'hash-mismatch'; File = $destination; RepoPath = $ExpectedFiles[$destination]; RepoTimestamp = $repoFile.LastWriteTime.ToString('yyyy-MM-dd HH:mm:ss'); DeployedTimestamp = $deployedFile.LastWriteTime.ToString('yyyy-MM-dd HH:mm:ss'); SameNamedSource = ''; TypeCollisions = @() })
}
}
if (Test-Path -LiteralPath $DeployedDirectory -PathType Container) {
$deployedSources = @(Get-ChildItem -LiteralPath $DeployedDirectory -Recurse -File -Filter '*.cs')
foreach ($deployedFile in $deployedSources) {
$relativePath = $deployedFile.FullName.Substring($DeployedDirectory.TrimEnd('\').Length).TrimStart('\')
if ($expectedByDestination.ContainsKey($relativePath)) { continue }
$isRootFile = $relativePath.IndexOf('\') -lt 0
if ($isRootFile -and ($deployedFile.Name.StartsWith('@', [System.StringComparison]::Ordinal) -or $AllowedForeignNames -contains $deployedFile.Name)) { continue }
$sameNamed = @(Get-ChildItem -LiteralPath (Join-Path $RepositoryRoot 'src') -Recurse -File -Filter $deployedFile.Name -ErrorAction SilentlyContinue)
$sameNamedPath = if ($sameNamed.Count -gt 0) { $sameNamed[0].FullName.Substring($RepositoryRoot.TrimEnd('\').Length).TrimStart('\') } else { 'none under src' }
$repoTimestamp = if ($sameNamed.Count -gt 0) { $sameNamed[0].LastWriteTime.ToString('yyyy-MM-dd HH:mm:ss') } else { 'not found' }
$collisions = @(Find-DeployedAssemblyTypeCollisions -FilePath $deployedFile.FullName -AssemblyDirectory (Split-Path -Parent $DeployedDirectory))
$issues.Add([pscustomobject]@{ Kind = 'unexpected'; File = $relativePath; RepoPath = ''; RepoTimestamp = $repoTimestamp; DeployedTimestamp = $deployedFile.LastWriteTime.ToString('yyyy-MM-dd HH:mm:ss'); SameNamedSource = $sameNamedPath; TypeCollisions = $collisions })
}
}
else {
$issues.Add([pscustomobject]@{ Kind = 'missing-deployed-directory'; File = $DeployedDirectory; RepoPath = ''; RepoTimestamp = 'n/a'; DeployedTimestamp = 'missing'; SameNamedSource = ''; TypeCollisions = @() })
}
return @($issues.ToArray())
}
function Format-StrategySourceIssues {
param([object[]]$Issues)
$lines = @()
foreach ($issue in $Issues) {
$line = ('{0}: {1}; repo timestamp={2}; deployed timestamp={3}' -f $issue.Kind, $issue.File, $issue.RepoTimestamp, $issue.DeployedTimestamp)
if ($issue.SameNamedSource) { $line += '; same-named source=' + $issue.SameNamedSource }
if ($issue.TypeCollisions.Count -gt 0) { $line += '; GAP-065 type collision: ' + [string]::Join(', ', $issue.TypeCollisions) }
$lines += $line
}
return [string]::Join([Environment]::NewLine, $lines)
}

View File

@@ -0,0 +1,41 @@
$ErrorActionPreference = 'Stop'
. (Join-Path $PSScriptRoot '..\strategy-source-verification.ps1')
$tempRoot = Join-Path ([System.IO.Path]::GetTempPath()) ('strategy-source-verification-' + [guid]::NewGuid().ToString('N'))
$repoRoot = Join-Path $tempRoot 'repo'
$deployedDirectory = Join-Path $tempRoot 'deployed\Strategies'
$pipelineFiles = Get-ExpectedStrategySourceFiles -RepositoryRoot $repoRoot
if ($pipelineFiles.Count -ne 4 -or -not $pipelineFiles.ContainsKey('NT8StrategyBase.cs') -or -not $pipelineFiles.ContainsKey('SimpleORBNT8.cs') -or -not $pipelineFiles.ContainsKey('BaseNT8StrategyWrapper.cs') -or -not $pipelineFiles.ContainsKey('SimpleORBNT8Wrapper.cs')) {
throw 'Deploy-managed source allow-list does not match deployment contract.'
}
$null = New-Item -ItemType Directory -Path (Join-Path $repoRoot 'src\Fixtures') -Force
$null = New-Item -ItemType Directory -Path $deployedDirectory -Force
try {
$repoFiles = @{
'Match.cs' = 'src\Fixtures\Match.cs'
'Mismatch.cs' = 'src\Fixtures\Mismatch.cs'
'Missing.cs' = 'src\Fixtures\Missing.cs'
}
[System.IO.File]::WriteAllText((Join-Path $repoRoot $repoFiles['Match.cs']), 'same')
[System.IO.File]::WriteAllText((Join-Path $repoRoot $repoFiles['Mismatch.cs']), 'repository')
[System.IO.File]::WriteAllText((Join-Path $repoRoot $repoFiles['Missing.cs']), 'repository-only')
[System.IO.File]::WriteAllText((Join-Path $repoRoot 'src\Fixtures\Unexpected.cs'), "namespace Fixture {`r`n public class OrphanType {}`r`n}")
[System.IO.File]::WriteAllText((Join-Path $deployedDirectory 'Match.cs'), 'same')
[System.IO.File]::WriteAllText((Join-Path $deployedDirectory 'Mismatch.cs'), 'deployed')
[System.IO.File]::WriteAllText((Join-Path $deployedDirectory 'Unexpected.cs'), "namespace Fixture {`r`n public class OrphanType {}`r`n}")
[System.IO.File]::WriteAllText((Join-Path $deployedDirectory '@Sample.cs'), 'operator-owned')
$issues = @(Compare-DeployedStrategySources -RepositoryRoot $repoRoot -DeployedDirectory $deployedDirectory -ExpectedFiles $repoFiles)
if ($issues.Count -ne 3) { throw "Expected 3 discrepancies, got $($issues.Count)." }
if (@($issues | Where-Object Kind -eq 'hash-mismatch').Count -ne 1) { throw 'Expected one hash mismatch.' }
if (@($issues | Where-Object Kind -eq 'missing-deployed').Count -ne 1) { throw ('Expected one missing deployed file. Got: ' + [string]::Join(', ', @($issues | ForEach-Object { $_.Kind }))) }
$unexpected = @($issues | Where-Object Kind -eq 'unexpected')
if ($unexpected.Count -ne 1 -or $unexpected[0].File -ne 'Unexpected.cs') { throw 'Unexpected source file was not rejected.' }
if ($unexpected[0].SameNamedSource -ne 'src\Fixtures\Unexpected.cs') { throw 'Unexpected file did not report its matching src path.' }
if ($unexpected[0].RepoTimestamp -eq 'not found' -or $unexpected[0].DeployedTimestamp -eq 'missing') { throw 'Unexpected-file timestamps were not reported.' }
if (@(Get-DeclaredSourceTypeNames -FilePath (Join-Path $deployedDirectory 'Unexpected.cs')) -notcontains 'Fixture.OrphanType') { throw 'Source type-name detection did not identify the orphan type.' }
Write-Output 'PASS strategy-source verification fixture (match, mismatch, missing, allow-listed, unexpected)'
}
finally {
Remove-Item -LiteralPath $tempRoot -Recurse -Force -ErrorAction SilentlyContinue
}