Skip to content

Stop the Windows bar wrapper discarding the finals gate's answer - #109

Merged
mspinola merged 1 commit into
mainfrom
claude/windows-wrapper-exit-code
Aug 21, 2026
Merged

Stop the Windows bar wrapper discarding the finals gate's answer#109
mspinola merged 1 commit into
mainfrom
claude/windows-wrapper-exit-code

Conversation

@mspinola

Copy link
Copy Markdown
Owner

Found on the real Windows box while repointing it after the ADR-0007 removals.

The bug

The wrapper this repo ships ran --metadata straight after --bars with no guard, and a .cmd exits with the code of its last command:

"...marketdata-update.exe" --bars --domain futures --require-final   REM exits 1 on a defer
"...marketdata-update.exe" --metadata                                REM exits 0

So a deferral's exit 1 was overwritten by --metadata's exit 0. Task Scheduler recorded success, restart-on-failure never fired, and the task waited until the next day having fetched nothing.

That is exactly the failure --require-final exists to prevent, reintroduced one layer out: the gate computed the right answer every night and the wrapper threw it away. Same symptom this whole migration keeps producing — a green run that did nothing.

The fix

"%MDEXE%" --bars --domain futures --require-final
if errorlevel 1 exit /b %ERRORLEVEL%

"%MDEXE%" --metadata
exit /b %ERRORLEVEL%

Skipping --metadata on a defer is deliberate, not just convenient. Restart-on-failure turns this task into a poll loop, and each retry should be the cheap date compare the gate is — not a full contract-spec fetch of all 49 symbols against NDU.

Why if errorlevel 1 and not ||. if errorlevel 1 tests >= 1 and needs no variable expansion, so it is safe on one line. || exit /b %ERRORLEVEL% would not be, and it is worth naming because it is the obvious thing to reach for: cmd expands %ERRORLEVEL% when it parses the line, before the command on that line has run, so it returns the previous command's code. On its own line, after the command, it is correct.

Also adds setlocal and quotes the set, matching the other wrappers.

Verification, and its limit

There is no cmd in this sandbox, so this is reasoned from cmd's parse-time expansion rules, not executed. What I did check rather than remember: the Python exit codes on the other side — a deferral returns 1, --metadata returns 0.

Confirm on the box with Last Run Result on a deferred run: it must be 0x1, not 0x0.

ruff clean, 199 pass (docs/examples only — no source touched).


Generated by Claude Code

Found on the real box. The wrapper this repo ships ran --metadata straight after
--bars with no guard, and a .cmd exits with the code of its LAST command. So a
deferral's exit 1 was overwritten by --metadata's exit 0: Task Scheduler recorded
SUCCESS, restart-on-failure never fired, and the task waited until the next day
having fetched nothing.

That is the precise failure --require-final exists to prevent, reintroduced one
layer out. The gate computed the right answer every night and the wrapper threw it
away, and the symptom is the one this whole session keeps circling -- a green run
that did nothing.

The fix keeps the bars exit code and stops there. Skipping --metadata on a defer is
deliberate rather than incidental: restart-on-failure turns this task into a poll
loop, and each retry should be the cheap date compare the gate is, not a full
contract-spec fetch of every symbol against NDU.

`if errorlevel 1` tests >= 1 and needs no expansion, so it is safe on one line.
`|| exit /b %ERRORLEVEL%` would NOT be, and is worth naming because it is the
obvious thing to reach for: cmd expands %ERRORLEVEL% when it PARSES the line, before
the command on that line has run, so it returns the previous command's code. On its
own line, after the command, it is correct.

Not executable in this sandbox -- there is no cmd here -- so this is reasoned from
cmd's parse-time expansion rules and from the exit codes on the Python side, which
were read rather than remembered: a deferral returns 1, --metadata returns 0.
Confirm on the box with Last Run Result on a deferred run: it must be 0x1, not 0x0.
@mspinola
mspinola marked this pull request as ready for review August 21, 2026 00:05
@mspinola
mspinola merged commit 1abb2f0 into main Aug 21, 2026
5 checks passed
@mspinola
mspinola deleted the claude/windows-wrapper-exit-code branch August 21, 2026 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants