Repository navigation
feat(cli): one exit code precedence for audit, outcome in the JSON and LLM reports - #1669
Merged
Merged
Conversation
nc9
force-pushed
the
feat/exit-code-precedence-1657
branch
from
November 10, 2026 05:07
44d0dc1 to
a3ac776
Compare
… one place #1657 Signed-off-by: Nik Cubrilovic <[email protected]>
…d LLM reports #1657 Signed-off-by: Nik Cubrilovic <[email protected]>
…throws or is interrupted #1657 Signed-off-by: Nik Cubrilovic <[email protected]>
…ifecycle #1657 Signed-off-by: Nik Cubrilovic <[email protected]>
Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
feat/exit-code-precedence-1657
branch
from
November 10, 2026 09:02
a3ac776 to
0016edc
Compare
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.
Closes #1657
What
squirrel auditsetprocess.exitCodein 34 places, each overwriting the last. The explicit-publish failure paths returned early, which skipped the failed/blocked code and the--fail-ongate. NowcomputeExitCode(apps/cli/src/audit/exit-code.ts) is a pure precedence table,process.exitCodeis assigned in one place (applyExitCode, reached throughexitWithandsettle), and the audit command has no assignment left.The JSON and LLM reports carry the answer:
outcome: { exit_code, status, publish: { status, reason? } }in JSON,<outcome exit-code status publish publish-reason/>in LLM. Both are written after publishing, so they can include its result; the other formats are written where they were.The two changed cases, and the decision for each
--publishfails on a blocked site: exit 3, was 1. The audit's own outcome outranks the publish; a CI job that already treats 3 as "perimeter refused us" keeps that signal. An explicit publish that fails on an otherwise ok audit still exits 1 and still does not evaluate--fail-on, as before.outcome.publishisfailedwith the error code, and the docs state the choice. If you would rather it exit non-zero, it is one row in the table (computeExitCode) plus its test row. Flagging this as the decision to confirm.Acceptance criteria
apps/cli/tests/cli/audit-exit-codes-1657-e2e.test.ts, 11 rows: ok, failed, blocked, redirected, unreachable, fail-on tripped and not, blocked beats the gate, three validation errors): green on the old code in its own first commit, and green after the refactor (the rows now also assertoutcome).partialexiting 0 is pinned by the existing max-duration e2e. The publish rows cannot run end to end, because a publish needs a public host and these fixtures are loopback (a non-public host never publishes), so they are in the unit tableapps/cli/tests/audit/exit-code.test.ts(30 tests), with the two changed rows marked.process.exitCodeis assigned in one place in the audit command (0 occurrences incommands/audit.ts).packages/report/tests/outcome-1657.test.ts).outcome.publish.status: "failed"); the exit code chosen (0) is documented.docs/cli/audit.mdxlists the precedence ("Which code wins");docs/configuration/output.mdxanddocs/reports.mdxdescribe the new fields;make validatepasses.Not covered: the unreachable and redirected start-URL reports (their own
statusshapes) do not carryoutcome; they exit 5 and 4 as before.Gates: the three new test files plus audit-stdout, waf-followups, offline-truthfulness, start-redirect, include-pages and max-duration e2e by explicit path;
tsgoinapps/cli,packages/report,packages/core-contracts; root lint;bun run format:checkinapps/cli;make validate.The squirrelscan agent skill needs no change. This overlaps in CHANGELOG and
docs/configuration/output.mdxwith the--resumechange; whichever lands second needs a one-line merge.Update: rebased on main after the resume PR, with the review fixes
meta.resumetook 1.7).createSettler, inexit-code.ts): a throw settles with a failed explicit publish carryingexception, a signal withinterrupted, so a held-back JSON or LLM report is not lost. Unit-tested (the order, no double write, a blocked audit keeps 3, the gate is skipped only for an explicit failure); the signal path itself is not tested.auditStatusToLifecycleinstead of a second open-coded copy.