Repository navigation
Description
- Severity: Medium
- Status: Confirmed — reproduced first-hand on 2026-06-08
- Component:
cmd/gaze/main.go(analyze and crap zero-result paths) - Affected commands:
gaze analyze,gaze crap(andreport,qualityzero-function paths) - Audited commit:
1a06131(main) - Target codebase: complytime-labs/crosscodex @
dae5cc4 - Evaluation model: Claude Opus 4.6 (1M context) —
claude-opus-4-6(analysis and parallel audit subagents)
Summary
When a command analyzes nothing — a package with no exported functions, or a
mistyped/zero-matching pattern — gaze exits 0 and the output looks like a pass.
For the threshold-bearing commands this means a CI gate "passes" on a package
that contains no analyzable code, masking misconfiguration.
Reproduction
# Package with only an unexported function (no exported API):
$ gaze analyze ./empty ; echo "exit=$?"
# WARN no functions found
exit=0
# Threshold gate on a package with no functions:
$ gaze crap --max-crapload=1 ./empty ; echo "exit=$?"
No functions analyzed.
exit=0 # gate "passes" with nothing to measure
A mistyped package path or a package that matches nothing therefore sails
through a --max-crapload / --max-gaze-crapload gate as a pass.
Expected vs Actual
- Expected: A gate command (one given a
--max-*threshold) that finds zero
analyzable functions should warn and/or fail, distinguishing "0 violations" in
real code from "nothing was analyzed." - Actual: Zero-result runs print an informational line and exit 0, identical
to a genuine pass.
Impact
Combined with BUG_007 (silent single-package truncation) and BUG_003 (silent
empty quality output), this makes it easy to wire a green CI gate that is in fact
measuring nothing. The recurring theme across BUG_001/002/003/008/016 is that
"could not analyze" is reported as a passing empty result.
Suggested fix
When a command was given a threshold flag (or a ./...-style pattern) but
produced zero analyzable functions/tests, emit a clear warning and exit
non-zero (or a documented "no-data" exit code), so empty results cannot be
mistaken for a pass.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone ✔️
Activity
jflowers commentedon Jun 16, 2026
Review Council Analysis
Five divisor agents (Adversary, Architect, Guard, SRE, Testing) reviewed this issue against the codebase and constitution. Unanimous verdict: VALID, CRITICAL.
Confirmed Code Paths
Every zero-result exit path was traced through the source:
gaze analyzemain.go:218-223return nil(exit 0) with warninggaze crap --max-crapload=5main.go:665-6760 > 5= false → exit 0gaze quality --min-contract-coverage=50main.go:877-880gaze report --max-crapload=5threshold.go:20-670 <= 5→ passgaze report --min-contract-coverage=1threshold.go:20-670 >= 1→ FAIL (coincidentally correct, not by design)Constitution Violations
Critical Assessment of the Suggested Fix
The suggestion — "exit non-zero when threshold flags are set and zero functions are analyzed" — is directionally correct but incomplete. Issues identified:
1. The
./...pattern clause is too broadThe trigger should be threshold flags only, not pattern shape.
gaze analyze ./...without thresholds is legitimate exploratory use.2.
gaze qualityhas a deeper control flow bugAt
main.go:877-880,runQualityreturns nil on zero results before threshold evaluation at line 941.--min-contract-coverageis dead code in this path. The fix must restructure the control flow, not just add a check.3.
gaze reportpipeline masks total failureAll four pipeline steps capture errors non-fatally (
runner.go:253-289). If ALL steps fail,ReportSummaryis zero-valued, and max thresholds pass. Needs a "total failure" check.4.
ReportSummarylacksTotalFunctionsaireport.ReportSummarycannot distinguish "CRAPload=0 because code is clean" from "CRAPload=0 because nothing was analyzed." ATotalFunctions intfield must be added and propagated fromcrap.Summary.TotalFunctions.5. Threshold API inconsistency between commands
gaze crapusesintwith> 0guard (0 disables the check), whilegaze reportuses*int+cmd.Flags().Changed()(nil disables,*0is a live threshold). These should be unified.6. An existing test documents the bug as correct
TestEvaluateThresholds_NilPayloadatthreshold_test.go:235asserts that a nil payload withMaxCrapload=5passes. This test enshrines the broken behavior.7. An escape hatch is needed
Legitimate zero-result scenarios exist (monorepo with mixed languages).
--allow-empty(opt-out of the safety check) is better than--fail-on-empty(opt-in), because the safe default should be "fail on empty when thresholds are active."Recommended Exit Code Design
Exit code 2 follows Unix convention (
grep,diff) and all CI systems treat it as failure. Alternatively, exit 1 with a clear stderr message is acceptable.Recommended Scope
checkCIThresholds— addTotalFunctions == 0guardintvs*intthreshold APIgaze analyzewithout thresholds (exit 0 is correct)EvaluateThresholds— addTotalFunctions == 0guard--allow-emptyflaggaze docscan(not a quality gate)runQuality— restructure early return so thresholds are evaluated./...ReportSummary— addTotalFunctionsfieldanalyzeParams/qualityParamsfor testabilityrunProductionPipelineno_dataindicatorRequired Tests (~10 new cases)
crap,quality,report)--allow-empty→ nil (escape hatch)TestEvaluateThresholds_NilPayload(currently asserts the bug)Backward Compatibility
This is a bug fix, not a feature change. Users whose pipelines break were getting false confidence. Recommendation: no deprecation period, document in release notes, minor version bump,
--allow-emptyas escape hatch.Bottom Line
The issue is valid and correctly diagnosed. The suggested fix needs refinement: scope to threshold-bearing invocations only, address the
gaze qualityearly return bypass, propagateTotalFunctionstoReportSummary, add--allow-empty, and unify threshold APIs. This requires a spec given it touches multiple commands, the threshold evaluation logic, and the report pipeline data model.fix: prevent silent CI passes on missing/partial data (unbound-force#101
fix: prevent silent CI passes on missing/partial data (unbound-force#101
fix: prevent silent CI passes on missing/partial data (unbound-force#101
fix: prevent silent CI passes on missing/partial data (#101, #108, #116)
fix: prevent silent CI passes on missing/partial data (unbound-force#101
fix(unbound-force#375): complete review-advisory sweep — quote versio…
fix(#375): complete review-advisory sweep — quote version inputs, pin…