Files
nt8-sdk/TASK_GAP068_DEPLOY_VERIFICATION_PROMPT.md
mo 5907e9cc54
Some checks failed
CI Build & Test / Build & Test (Windows) (push) Has been cancelled
CI Build & Test / Build & Test (Linux/mono) (push) Has been cancelled
[GOV]: sync governance to v9.0 + 2026-10-24 findings; stage GAP-077/067 prompts
2026-10-26 08:12:20 -04:00

6.2 KiB
Raw Blame History

TASK: GAP-068 — deploy verification is per-file and cannot detect an orphan

Staged: 2026-09-22 — v9.0 task P0-B / next-action N-06

Sprint: Stage 0 — restore trust in the artifact

Owner: Kilocode

Deploy: COMMIT ONLY — tooling change, no strategy behaviour touched. Do NOT run

deploy-to-nt8.bat as part of this task.

─────────────────────────────────────────────────────────────────

WHY THIS EXISTS

On 2026-09-22 it was found that NinjaTrader had been compiling a 2026-07-13 orphan copy of SimpleORBStrategy.cs sitting in C:\Users\billy\Documents\NinjaTrader 8\bin\Custom\Strategies\. That file is not copied by deploy-to-nt8.bat — it belongs to a different project and ships inside NT8.Strategies.dll — so no deploy ever touched it, and NinjaTrader's own compilation bound to the orphan source in preference to the DLL's type. It cost roughly three weeks of misdirected diagnosis (GAP-064, GAP-065) and silently disabled GAP-062 for a month.

The machinery to have caught this already existed and was pointed at the wrong file. That is what this task fixes.

READ-FIRST

  1. tools/preflight/preflight.ps1, check 5 (~510–518). It SHA-256-compares the deployed NT8StrategyBase.cs against the repository copy — and only that one file, which happened to be the file that was current. Understand exactly what it compares and how it reports.
  2. tools/preflight/preflight.ps1, Write-DeployedSourceHashes (~202–222). It hashes every .cs in the deployed Strategies folder into the freeze capture — including the orphan — and nothing anywhere ever compares those hashes to anything. The data was being collected and discarded.
  3. deployment/deploy-to-nt8.bat — note which files it copies (three DLLs; BaseNT8StrategyWrapper.cs, SimpleORBNT8Wrapper.cs, NT8StrategyBase.cs, SimpleORBNT8.cs), which it backs up (five — not the two Strategies/ sources), and what its verify step checks (existence only, and not the two files it just copied).
  4. deployment/Verify-Deployment.ps1:15 — it expects MinimalTestStrategy.cs in the Strategies folder, which deploy-to-nt8.bat never copies. The two scripts disagree on the deployment contract (GAP-073). Note it; fixing it is in scope only if trivial.

THE FIX — TWO CLAUSES, BOTH REQUIRED

Extend preflight's deployed-source verification from one file to the whole folder. It must assert both of the following, and the second clause is the one that matters:

  1. Every expected file matches. For each .cs the deploy pipeline is supposed to place in bin\Custom\Strategies, the deployed copy's SHA-256 must equal the repository copy's.
  2. No unexpected file exists. Any .cs in bin\Custom\Strategies that does not correspond to a known repository path is a failure, not a warning. This is the clause that would have caught GAP-065 on the day it was introduced.

Clause 2 needs an explicit allow-list, because that folder legitimately contains files this project does not own — the operator's own @@-prefixed strategies (@@ATMmonitorStrategy.cs, @@MicroBandRevert.cs, @@VWAPsnap.cs and others), NinjaTrader's @-prefixed samples (@SampleMACrossOver.cs etc.), and ORBFibPullbackV1.cs. Design the allow-list so that adding a personal strategy does not require a code change but adding an SDK-owned file does — a prefix rule plus an explicit named list is probably right; propose the shape in your implementation note if you see a better one.

Report findings so an operator can act without reading the script: for each discrepancy, say which file, what kind (missing / hash mismatch / unexpected), the deployed and repo timestamps, and for an unexpected file whether a same-named file exists anywhere under src/.

Also surface the orphan-class risk explicitly: if an unexpected .cs declares a type that also exists in one of the deployed DLLs, that is the GAP-065 signature exactly and should be called out in those terms.

SECONDARY, IF CHEAP

  • Record hashes in deployment/backups/<stamp>/manifest.txt. It currently records source and destination paths only — no hashes, no git SHA, no file sizes — so a backup cannot be used to prove what was deployed. Adding the git HEAD short SHA and a hash per copied file would make the manifest evidence rather than a note.
  • Back up NT8StrategyBase.cs and SimpleORBNT8.cs before overwriting them. deploy-to-nt8.bat currently deploys seven files and backs up five, so those two have no rollback copy.

If either turns out to be more than a small change, stop and report rather than expanding scope.

REQUIRED TEST

At minimum, a test that exercises the comparison logic against a fixture directory containing: one matching file, one hash-mismatched file, one missing file, one allow-listed foreign file, and one unexpected .cs that should fail. The last case is the regression test for GAP-065 and is the reason this task exists — it must fail loudly if the clause-2 logic is ever weakened.

DO NOT

  • Do not change deploy-to-nt8.bat's copy behaviour in this task. Verification first; changing what gets deployed is a separate decision.
  • Do not delete anything from the deployed folder programmatically. Preflight reports; the operator acts. A script that silently deletes files from NinjaTrader's compile directory is a worse failure mode than the one being fixed.
  • Do not deploy.

VALIDATION (operator)

Run preflight against the current deployed tree before the P0-A/N-01 cleanup: it must fail and name SimpleORBStrategy.cs as an unexpected file. Run it again after the cleanup and recompile: it must pass. That before/after pair is the proof this task works, and it is available only until the cleanup happens — so run the "before" case first, or capture the current folder listing now.

GOVERNANCE

Track as GAP-068 in SPRINT_BOARD.md. Reference DEC-20260922-01 and Master Document v9.0 §1.3 Finding 1 and §4.4 in the commit and in decisions.md. If the manifest and backup items above are implemented, note them against GAP-073 as partial.