[Bugfix #1142] Expose exitCode to cron conditions; let condition-true failure runs deliver alerts#1143
Open
waleedkadous wants to merge 7 commits into
Open
[Bugfix #1142] Expose exitCode to cron conditions; let condition-true failure runs deliver alerts#1143waleedkadous wants to merge 7 commits into
waleedkadous wants to merge 7 commits into
Conversation
…ion-true failure runs deliver
- runCommand resolves { output, exitCode } for plain non-zero exits instead
of rejecting; only spawn failures and timeout/kills still reject (reported
as exitCode -1 / 124)
- evaluateCondition takes exitCode as a second scope variable, so
condition: "exitCode != 0" no longer throws ReferenceError
- Delivery gate: with a condition, the condition alone decides delivery
(failure runs can now alert); without one, deliver only on exit 0 as before
- last_result semantics unchanged (success/failure by exit code)
- Regression tests for exitCode conditions, output-only conditions,
no-condition failure runs, and the timeout path
- Document the condition environment in the afx skill and agent-farm.md,
both trees
Contributor
Author
Architect ReviewNice, tight execution — this carries the issue's prescribed design faithfully, and the docs work goes beyond the ask in a good way. Low-risk change (production diff is 37/22 in one file,
One intentional semantic change worth naming for the record (it's documented, and correct): an output-only condition that evaluates true on a failed run now delivers, where before failure suppressed everything. That's the point of the fix — "condition alone decides" — just noting it's a behavior change for pre-existing condition-bearing tasks, not a pure bugfix. CMAP unanimous (3× APPROVE/HIGH), CI 6/6 green. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the two-layer bug in
tower-cron.tswhere (1) conditions referencingexitCodethrewReferenceErroron every run, and (2) failure runs could never deliver alerts — making "alert me when this command fails" inexpressible.Root Cause
evaluateCondition()builtnew Function('output', 'return ' + condition)— onlyoutputwas in scope, socondition: "exitCode != 0"threwReferenceErrorevery run (12k+ WARN lines in a real tower.log). The catch forcedshouldNotify = false.runCommand()rejected on any non-zero exit, so the exit code was never available as data.if (shouldNotify && result === 'success')suppressed delivery on exactly the runs a monitoring task cares about.Fix
runCommand()resolves{ output, exitCode }. A plain non-zero exit (numericerror.code, no kill signal) resolves with that exit code — it's data, not an error. Spawn failures and timeout/kills still reject, reported asexitCode -1/124respectively.evaluateCondition(condition, output, exitCode = 0)exposes both variables to the condition. Output-only conditions are unchanged.conditiondelivers exactly when the condition is truthy (including failed runs). A task without aconditionkeeps today's behavior — deliver only on exit 0 — so existing tasks don't start alert-spamming on flaky commands. Non-delivering failures keep the WARN log.last_resultincron_tasksstill records success/failure by exit code — only delivery logic changed.output: string,exitCode: number) is now documented in the afx skill's## afx cronsection and a new### afx cronsection inagent-farm.md, in BOTH trees (instance + skeleton).Test Plan
tower-cron.test.ts(34 total, all pass):exitCode != 0condition delivers on non-zero exit, no ReferenceErrorexitCode != 0condition does not deliver on clean exitevaluateConditionunit coverage for exitCode scope + defaultpnpm buildpasses.Fixes #1142
🤖 Generated with Claude Code