Summary
The retention-selection logic in _create_context() has an unreachable branch intended to apply a narrower retention policy for JSON-only apps.
Details
lib/python/base_cli/app.py:489-503 (App.__init__) only sets self.retention = None in the else branch that requires max_log_files is not None.
- Consequently, whenever
self.retention is None is true at app.py:1224, self.max_log_files is not None is also guaranteed true, so the elif self.max_log_files is not None: branch (:1231) always fires first.
- The
elif context.json_output: branch at :1248 (applying RetentionPolicy(max_bundles=_JSON_DEFAULT_MAX_LOG_FILES) for JSON-only apps with no other retention config) can never execute.
Impact
It happens to be harmless today only because RetentionPolicy.safe_defaults() (the default retention whenever this branch would otherwise matter) coincidentally also uses max_bundles=20, but the intended narrower JSON-only policy (bundle count only, no age/size bound) never actually applies as documented in docs/json-contracts.md ("JSON mode bounds default-log retention to the most recent 20 run bundles"). A future change to either default would silently diverge from the documented contract without any test catching it, since the branch is currently dead.
Suggested fix
Remove the dead branch, or restructure App.__init__/_create_context so context.json_output-driven retention is reachable when intended.
Summary
The retention-selection logic in
_create_context()has an unreachable branch intended to apply a narrower retention policy for JSON-only apps.Details
lib/python/base_cli/app.py:489-503(App.__init__) only setsself.retention = Nonein theelsebranch that requiresmax_log_files is not None.self.retention is Noneis true atapp.py:1224,self.max_log_files is not Noneis also guaranteed true, so theelif self.max_log_files is not None:branch (:1231) always fires first.elif context.json_output:branch at:1248(applyingRetentionPolicy(max_bundles=_JSON_DEFAULT_MAX_LOG_FILES)for JSON-only apps with no other retention config) can never execute.Impact
It happens to be harmless today only because
RetentionPolicy.safe_defaults()(the default retention whenever this branch would otherwise matter) coincidentally also usesmax_bundles=20, but the intended narrower JSON-only policy (bundle count only, no age/size bound) never actually applies as documented indocs/json-contracts.md("JSON mode bounds default-log retention to the most recent 20 run bundles"). A future change to either default would silently diverge from the documented contract without any test catching it, since the branch is currently dead.Suggested fix
Remove the dead branch, or restructure
App.__init__/_create_contextsocontext.json_output-driven retention is reachable when intended.