Skip to content

Fix #1921: CI Health Check cron no longer sends a false 'CI failing' alert on Windows - #1929

Merged
amrmelsayed merged 10 commits into
mainfrom
builder/bugfix-1921
Nov 18, 2026
Merged

amrmelsayed merged 10 commits into
mainfrom
builder/bugfix-1921

Conversation

@amrmelsayed

@amrmelsayed amrmelsayed commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

On native Windows the CI Health Check cron task alerted "currently failing on main: 'map' is not recognized…" every 30 minutes while CI was green. This fixes the command's quoting so it parses under cmd.exe as well as a POSIX shell, and makes the condition require a clean run so a broken check never reads as a CI failure.

Fixes #1921

Root Cause

  1. Tower runs cron commands with child_process.exec, which is cmd.exe /d /s /c on Windows. cmd.exe does not treat single quotes as quotes, so the | inside --jq '…' piped into a program named map. The command exited 255, and runCommand returned its stderr as the output.
  2. The condition was output != ''. Conditions are evaluated on failed runs too (by design: exitCode is data), so the error text was delivered as the list of failing workflows. This half affects every platform: gh missing, unauthenticated or offline all read as "CI failing".

Reproduced on this machine by running the task's command through exec: exit 255, stderr 'map' is not recognized as an internal or external command.

Fix

  • .af-cron/ci-health.yaml: the jq expression is double-quoted, with \" for its inner strings. cmd.exe keeps the | quoted and gh (Go's argv parser) reads \" as a literal quote. A POSIX shell does the same inside double quotes. I checked the output is identical under cmd.exe and bash. I chose this over a helper script so the task stays a one-liner adopters can copy. The condition is now exitCode == 0 && output != ''. I also removed a stale "checks every minute (for testing)" comment.
  • codev-skeleton/.af-cron/ci-health.yaml.example had both faults (output != '0' alerted on any error text) and gets the same fix: exitCode == 0 && output != '0'.
  • Cron reference docs (afx SKILL.md ×4: .claude/.codex, ours and skeleton; agent-farm.md ×2) get one paragraph. It says commands run through cmd.exe on Windows, so use double quotes, and that output-inspecting conditions should also require exitCode == 0.
  • shipped-skill-hashes.ts is regenerated, because the afx skill content changed.
  • No separate "check is broken" alert. Tower already logs a WARN for a failed cron command, and a second message every 30 minutes would be noise of its own.
  • team-update.yaml was already correct: no quoting, and it already gates on exitCode == 0.

Test Plan

  • Regression test packages/codev/src/agent-farm/__tests__/cron-shipped-tasks.test.ts. It loads both shipped task files through loadWorkspaceTasks and runs each command through the real platform shell (exec), with gh swapped for a stub that echoes the --jq argument. It asserts the expression arrives intact and that each condition is false for a failed run (exit 255 / 127 with error text) and true for a real failure. Without the fix all 4 cases fail on Windows, the first with the exact 'map' is not recognized error. With the fix they pass.
  • Build passes (porch check)
  • Full packages/codev suite passes on native Windows (porch check, run alone; Tower PID unchanged before/after)
  • No Windows workflow dispatch: the PR touches task config, docs and a test, not platform code.

Review feedback (CMAP)

gemini skipped (agy not installed on this machine), codex APPROVE, claude APPROVE. Applied from the claude review:

  • Docs: cmd.exe counts every " as a quote toggle, so text between an escaped \"…\" pair is unquoted to it. The cron paragraph now says to keep | & < > ^ out of inner strings and use a script for anything that needs them.
  • Test: added a platform-independent guard (no single quotes in the shipped commands). The shell-run check only catches a reversion on Windows, and PR CI is Linux.

Deferred, not in this PR: tower-cron.ts runs commands with raw child_process.exec (cmd.exe on Windows). Every other shell-string call site goes through commandLaunch(), which uses Git Bash on Windows (Spec 1658). So an adopter's own POSIX-quoted cron command still fails on Windows; with the exitCode == 0 guidance it now fails as a WARN in the log, not a false alert. Routing cron through commandLaunch needs an exit-code-returning variant of execShellString, which is a cross-platform API change. Follow-up: #1930.

…ition requires exitCode == 0

The jq expression was single-quoted, which cmd.exe (Tower's exec shell on
Windows) does not treat as quoting, so its | became a pipe and the command
failed. The condition ignored exitCode, so the error text was reported as the
failing workflows. Double-quote with \" (parses the same in cmd.exe and sh)
and gate on exitCode == 0. Same fix in the skeleton example; cron docs note both.
…n docs, platform-independent single-quote guard in the test
@amrmelsayed
amrmelsayed merged commit 95cb8f5 into main Nov 18, 2026
8 checks passed
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.

cron: CI Health Check sends a false 'CI failing' alert on Windows (cmd.exe quoting, condition ignores exit code)

1 participant