From 86900b254584534b8f24b787ea83d41e930a6864 Mon Sep 17 00:00:00 2001 From: Matt Spinola Date: Fri, 23 Oct 2026 16:52:31 -0400 Subject: [PATCH 1/3] scheduling: key the sync guard on delivery, ungate the remote push Two faults in the chained replica deliveries, both of which fired on the 2026-10-23 COT release and between them cost the whole window. The poller's guard compared a newest_data fingerprint from before the fetch against one from after, so it fired only on the single repeat that happened to watch the map move. CFTC published at 15:28, the 15:29 repeat captured 2026-10-20 and called the syncs, the SMB mirror delivered nothing, and every repeat after it read BEFORE == AFTER and skipped the syncs as "nothing new landed". One failed delivery was therefore final for the day: both replicas sat on 2026-10-13 until a human noticed. Key the guard on the fingerprint of the last run in which every replica took the data instead, so a failed delivery is retried on the next repeat while a delivered week is still skipped. The second fault is the `if errorlevel 1 exit /b` between sync-store.cmd and push-to-server.cmd: an unreachable laptop on the LAN kept the week from the internet-facing replica, the one with readers. sync-store.cmd already refuses this between its own two store passes ("one broken thing presenting as two"); the wrappers never applied it one level up. Capture each code and exit the worst. run-series.cmd keeps its build code as the headline, but no longer lets a partial build hide a failed mirror. Docs only here, plus the two templates that carried the gated chain. The live wrappers on the producer box are not tracked in this repo and were patched in place; WINDOWS_SCHEDULING.md is the versioned record of the contract. Co-Authored-By: Claude Opus 5 --- docs/WINDOWS_SCHEDULING.md | 36 +++++++++++++++++++++++--- docs/examples/windows/run-equities.cmd | 18 +++++++++++-- docs/examples/windows/run-series.cmd | 25 +++++++++++++++--- 3 files changed, 70 insertions(+), 9 deletions(-) diff --git a/docs/WINDOWS_SCHEDULING.md b/docs/WINDOWS_SCHEDULING.md index b08c171..c03ecc2 100644 --- a/docs/WINDOWS_SCHEDULING.md +++ b/docs/WINDOWS_SCHEDULING.md @@ -249,7 +249,27 @@ to get wrong, because the obvious signal is the broken one: `newest_data` is the right signal and the documented one: it *"advances ONLY when genuinely new data arrives"* (see [status.json](../README.md#statusjson--new-data-signal-for-downstream-tools)). -Snapshot it before the fetch and after, and skip the syncs only when the two agree. + +**Key the guard on what was delivered, not on what arrived.** The obvious shape is to +snapshot `newest_data` before the fetch and after and sync only on the difference. Do not: +that fires on the single repeat which happens to watch the map move, so one failed delivery +is final for the whole window. + +> [!WARNING] +> **Measured on the reference box on 2026-10-23, and it cost a release.** CFTC published at +> 15:28, the 15:29 repeat captured the new week and called the syncs, the SMB mirror +> delivered nothing, and the wrapper exited. Every repeat after it read `BEFORE == AFTER` +> and skipped the syncs as "nothing new landed". Both replicas sat on the previous week +> until a human noticed, and the public dash only got the data because someone fetched CFTC +> on it by hand. The fetch half of the pipeline had worked perfectly, inside 90 seconds of +> publication. + +Record the fingerprint of the last run in which **every** replica took the data, in a file +beside the wrapper, and compare the store against *that*. A failed delivery is then retried +on the next repeat, a delivered week is still skipped for the rest of the window, and a quiet +Friday costs exactly what it did before. It also removes the ordering trap entirely: it no +longer matters which repeat sees the data arrive. Keep that file out of the store itself, or +the mirror will carry one box's scheduling state to every replica. **Do not guard the daily catch-up as well.** This is the trap on the other side, and it costs you bars rather than time. Both sync scripts mirror **both** stores since ADR-0007, so the @@ -269,8 +289,18 @@ Set-ScheduledTask -TaskName 'cotdata COT (Fri release)' -Action $a string as the executable path, so the argument ends up part of the filename.) **Make the guard fail toward syncing.** If `status.json` is missing or unparseable, sync -anyway rather than skipping. A redundant mirror is merely slow; a skipped one is invisible, -which is the failure mode this whole page exists to prevent. +anyway rather than skipping. A missing or empty delivery record reads the same way: nothing +was ever confirmed delivered, so deliver. A redundant mirror is merely slow; a skipped one is +invisible, which is the failure mode this whole page exists to prevent. + +**Do not gate one replica's delivery on another's.** If your wrapper chains an SMB mirror and +a remote push, the tempting `if errorlevel 1 exit /b` between them makes the second replica +hostage to the first. On 2026-10-23 that is what kept the week from the internet-facing +replica, the one with actual readers, because a laptop on the LAN was unreachable over SMB. +[`sync-store.cmd`](examples/windows/sync-store.cmd) already refuses to make this mistake +between its own two store passes, for the reason stated there: one broken thing should not +present as two. Run every delivery, capture each exit code on its own following line, and +exit the worst of them. ## Testing your tasks diff --git a/docs/examples/windows/run-equities.cmd b/docs/examples/windows/run-equities.cmd index f1ac559..212011c 100644 --- a/docs/examples/windows/run-equities.cmd +++ b/docs/examples/windows/run-equities.cmd @@ -113,7 +113,21 @@ REM The guard above means these are reached only when every symbol wrote. A REM partial equities fetch is not mirrored: the retry loop re-runs the whole REM full-history fetch, and the sync goes with the run that finally succeeds. call "REPLACE_WITH_SCHEDULER_DIR\sync-store.cmd" -if errorlevel 1 exit /b %ERRORLEVEL% +set "SYNC_RC=%ERRORLEVEL%" call "REPLACE_WITH_SCHEDULER_DIR\push-to-server.cmd" -exit /b %ERRORLEVEL% +set "PUSH_RC=%ERRORLEVEL%" + +REM The push is NOT gated on the sync. An `if errorlevel 1 exit /b` used to sit +REM between these two calls, so a failed SMB mirror to the Mac also starved the +REM remote replica, the one with actual readers. That is the mistake sync-store.cmd +REM already refuses to make between its own two store passes: one broken thing +REM presenting as two. Run both deliveries, then report. +REM +REM The two empty-guards are not paranoia: cmd aborts the whole file on a numeric +REM IF with an empty operand, which would skip the exit below and report success. +if "%SYNC_RC%"=="" set "SYNC_RC=1" +if "%PUSH_RC%"=="" set "PUSH_RC=1" +set "WORST=%SYNC_RC%" +if %PUSH_RC% GTR %WORST% set "WORST=%PUSH_RC%" +exit /b %WORST% diff --git a/docs/examples/windows/run-series.cmd b/docs/examples/windows/run-series.cmd index 77a40d7..198ac84 100644 --- a/docs/examples/windows/run-series.cmd +++ b/docs/examples/windows/run-series.cmd @@ -99,12 +99,29 @@ REM The raw JSON under _raw\tradingview never rides along: both scripts exclude REM _raw by name at any depth, for databento's paid raw store. Keep the directory REM name exactly _raw or both exclusions silently stop applying. call "REPLACE_WITH_SCHEDULER_DIR\sync-store.cmd" -if errorlevel 1 exit /b %ERRORLEVEL% +set "SYNC_RC=%ERRORLEVEL%" call "REPLACE_WITH_SCHEDULER_DIR\push-to-server.cmd" -if errorlevel 1 exit /b %ERRORLEVEL% +set "PUSH_RC=%ERRORLEVEL%" + +REM The push is NOT gated on the sync. An `if errorlevel 1 exit /b` used to sit +REM between these two calls, so a failed SMB mirror to the Mac also starved the +REM remote replica, the one with actual readers. That is the mistake sync-store.cmd +REM already refuses to make between its own two store passes: one broken thing +REM presenting as two. Run both deliveries, then report. +REM +REM The two empty-guards are not paranoia: cmd aborts the whole file on a numeric +REM IF with an empty operand, which would skip the exit below and report success. +if "%SYNC_RC%"=="" set "SYNC_RC=1" +if "%PUSH_RC%"=="" set "PUSH_RC=1" +set "WORST=%SYNC_RC%" +if %PUSH_RC% GTR %WORST% set "WORST=%PUSH_RC%" +if not "%WORST%"=="0" echo series: delivery incomplete ^(sync %SYNC_RC%, push %PUSH_RC%^). REM The build's code, not the push's: a partial build that synced cleanly is still REM a run with a refusal in it, and the operator and the verifier both want to see -REM that rather than a 0. -exit /b %RC% +REM that rather than a 0. A clean build with a broken delivery is still a failure, +REM though, so when the build has nothing to say the delivery's code is what exits. +REM The echo above is why a partial build cannot hide a failed mirror. +if not "%RC%"=="0" exit /b %RC% +exit /b %WORST% From 9d23a0b3b4537a35d25987510d8bfda7e9bb0717 Mon Sep 17 00:00:00 2001 From: Matt Spinola Date: Fri, 23 Oct 2026 17:07:05 -0400 Subject: [PATCH 2/3] docs: name the transient cause behind the 2026-10-23 lost release The mirror failure was a ten-second one: the destination took a new DHCP lease seconds before the copy, and the identical robocopy ran clean 90 minutes later (156 files, 0 failed). robocopy /R:2 /W:5 gives up in about ten seconds, so a wireless re-association on the far end loses a pass. What turned that into a lost release was the guard refusing to try again, which is the lesson the warning is there to carry. Co-Authored-By: Claude Opus 5 --- docs/WINDOWS_SCHEDULING.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/WINDOWS_SCHEDULING.md b/docs/WINDOWS_SCHEDULING.md index c03ecc2..68440a9 100644 --- a/docs/WINDOWS_SCHEDULING.md +++ b/docs/WINDOWS_SCHEDULING.md @@ -263,6 +263,12 @@ is final for the whole window. > until a human noticed, and the public dash only got the data because someone fetched CFTC > on it by hand. The fetch half of the pipeline had worked perfectly, inside 90 seconds of > publication. +> +> The mirror failure itself was transient. The destination took a new DHCP lease at +> 15:30:19, seconds before the copy, and the identical copy ran clean 90 minutes later: +> 156 files, nothing failed. `robocopy /R:2 /W:5` gives up in about ten seconds, so a +> wireless re-association on the far end is enough to lose a pass. **That is the point.** +> A ten-second blip cost a whole release only because the guard then refused to retry. Record the fingerprint of the last run in which **every** replica took the data, in a file beside the wrapper, and compare the store against *that*. A failed delivery is then retried From 88b49d31cadbb204c218e7c82ca8ef83c98a3c7b Mon Sep 17 00:00:00 2001 From: Matt Spinola Date: Fri, 23 Oct 2026 17:10:34 -0400 Subject: [PATCH 3/3] scheduling: raise the mirror's retry budget to /R:6 /W:10 /R:2 /W:5 gives up in about ten seconds, which is less than a wireless re-association on the destination. That is what lost the 2026-10-23 COT release: the SMB destination took a new DHCP lease at 15:30:19, the capture pass called the mirror seconds later, and the identical copy ran clean ninety minutes afterwards (156 files, 0 failed). Six attempts over sixty seconds rides that out without pretending to ride out an outage. The comment states the ceiling, because /R and /W are per failure: the budget multiplies by the file count on a destination flaky enough to fail file after file, and is bounded only because an unreachable share fails once at the directory level rather than per file. It also notes the two consequences a future tuner needs: the exit codes are unchanged, and during a real outage the 2-minute COT poller stretches by a minute or two because Task Scheduler will not start a second instance while one runs. /TBD is named in the comment but not added: nothing has produced an ERROR 67 to test it against. Co-Authored-By: Claude Opus 5 --- docs/examples/windows/sync-store.cmd | 33 ++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/docs/examples/windows/sync-store.cmd b/docs/examples/windows/sync-store.cmd index 975181f..2d97574 100644 --- a/docs/examples/windows/sync-store.cmd +++ b/docs/examples/windows/sync-store.cmd @@ -27,6 +27,35 @@ set "COT_DEST=REPLACE_WITH_COTDATA_DEST_PATH" set "BAR_SRC=REPLACE_WITH_MARKETDATA_STORE_PATH" set "BAR_DEST=REPLACE_WITH_MARKETDATA_DEST_PATH" +REM --------------------------------------------------------------------------- +REM THE RETRY BUDGET: /R:6 /W:10, six attempts over sixty seconds per failure. +REM +REM It was /R:2 /W:5, which gives up in about ten seconds, and on 2026-10-23 that +REM lost a COT release. The SMB destination took a new DHCP lease at 15:30:19 and +REM the capture pass called this script seconds later; the copy failed, and the +REM Friday poller's guard then read the store as already current and skipped every +REM remaining repeat. The identical copy ran clean ninety minutes later: 156 files, +REM nothing failed. Ten seconds is simply less than a wireless re-association on +REM the far end, and that destination roams between mesh access points. +REM +REM Sixty seconds rides out a re-association without pretending to ride out an +REM outage. Know the ceiling before raising it further: /R and /W are PER FAILURE, +REM so on a destination that is reachable but flaky enough to fail file after file, +REM the budget multiplies by the file count. It is bounded here because an +REM unreachable share fails at the directory level once, not per file, so a +REM powered-off replica costs about a minute per pass rather than hours. +REM +REM Two consequences worth knowing before you tune this: +REM - The exit codes below are unchanged, so a failure after six attempts still +REM reports exactly as it did before. The budget buys attempts, not silence. +REM - run-cot.cmd --poll repeats every 2 min, and Task Scheduler will not start a +REM second instance while one runs. During a real outage both passes burn their +REM budget, so the effective poll cadence stretches by a minute or two. That is +REM only true while something is broken, and the guard retries either way. +REM +REM If a failure ever shows ERROR 67 (network name not found) that these retries do +REM not catch, /TBD is the flag for it: it waits for share names to be defined. +REM Not added here because nothing has produced that error to test it against. REM --------------------------------------------------------------------------- REM Pass 1 — the COT store. REM @@ -50,7 +79,7 @@ REM matches by NAME AT ANY DEPTH, so had it been called manifest.json this sync REM have silently delivered raw bytes with no index. REM /XF also drops partial-write temps (*.tmp from parquet/JSON writes, *.part from REM in-flight raw downloads) so a sync mid-capture never lands a truncated file. -robocopy "%COT_SRC%" "%COT_DEST%" /MIR /R:2 /W:5 /NFL /NDL /NP ^ +robocopy "%COT_SRC%" "%COT_DEST%" /MIR /R:6 /W:10 /NFL /NDL /NP ^ /XD _cache _raw citpy ^ /XF manifest.json *.tmp *.part set "COT_RC=%ERRORLEVEL%" @@ -77,7 +106,7 @@ REM replica has no use for it and re-fetching it costs money. REM REM Both stores commit parquet with an atomic replace, so *.tmp / *.part are the REM same partial-write guard as above. -robocopy "%BAR_SRC%" "%BAR_DEST%" /MIR /R:2 /W:5 /NFL /NDL /NP ^ +robocopy "%BAR_SRC%" "%BAR_DEST%" /MIR /R:6 /W:10 /NFL /NDL /NP ^ /XD _raw ^ /XF *.tmp *.part set "BAR_RC=%ERRORLEVEL%"