Skip to content

fix(cli): Improve logging control, exit codes, and input/output safety#186

Merged
mhiro2 merged 5 commits into
mainfrom
fix/cli-operability-and-safety
Jun 5, 2026
Merged

fix(cli): Improve logging control, exit codes, and input/output safety#186
mhiro2 merged 5 commits into
mainfrom
fix/cli-operability-and-safety

Conversation

@mhiro2

@mhiro2 mhiro2 commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Honor RUST_LOG in the log filter so operators can trace a single module (e.g. RUST_LOG=relune_introspect=debug); -v/-q set the level when it is unset.
  • Fall back to the DATABASE_URL environment variable for live-DB input when no input flag is given, avoiding DSN exposure via argv/shell history; an explicit flag always wins.
  • Unify the migration-risk and lint deny gates on exit code 10 so CI can distinguish a policy gate from a general failure.
  • Make --quiet suppress non-error diagnostics (warning/info/hint) while keeping exit-code decisions on the full diagnostic set.
  • Reject a missing --out parent directory as a usage error (exit 2) that names the path, and cap PNG rasterization size with a clear message.
  • Document CLI exit codes and the new behavior in the CLI reference, getting-started guide, and the relune skill.

Changes

  • be52ff7 fix(cli): honor RUST_LOG for log filtering
    • Build the log EnvFilter from RUST_LOG when set so a single module can be traced with full per-target control, falling back to the -v/-q verbosity level otherwise, with unit tests covering the precedence.
  • 4c89e62 feat(cli): fall back to DATABASE_URL when no input flag is given
    • Resolve live-DB input from DATABASE_URL when no input flag is passed (render/inspect/doc/export/lint), keeping the DSN out of argv and shell history; an explicit --sql/--schema-json/--db-url always wins.
    • Relax the clap input groups from required to optional so input-presence validation lives in one place, with an after_help note that keeps the input contract discoverable in --help.
  • 2ee9b97 fix(cli): cap PNG rasterization dimensions
    • Validate the rasterization target against a 100-megapixel budget before allocating the pixmap, replacing the misleading "dimensions may be zero" message with one that distinguishes zero from oversized and points to SVG.
  • 54457c9 fix(cli): align deny exit code, honor --quiet, and validate --out path
    • Exit 10 via a shared DenyThresholdReached when lint --deny hits the threshold, matching the migration-risk deny gate and diff --exit-code so CI can tell a policy gate from a general failure.
    • Suppress non-error diagnostics under --quiet without changing exit-code logic, and report a missing --out parent directory as a usage error that names the path.
  • b372402 docs: document CLI exit codes, RUST_LOG, --quiet, and DATABASE_URL
    • Add an exit-codes table and document RUST_LOG precedence, the --quiet contract, the DATABASE_URL fallback (with a warning against DSNs on the command line), and the --out directory check across the CLI reference, getting-started guide, and skill.

mhiro2 added 3 commits June 5, 2026 18:37
The log filter hardcoded the level from -v/-q and never consulted the
environment, so RUST_LOG was ignored. Build the EnvFilter from RUST_LOG
when it is set (standard EnvFilter syntax, full per-target control) and
fall back to the verbosity-derived default level otherwise. This lets
operators trace a single module, e.g. RUST_LOG=relune_introspect=debug.
Passing a live-DB DSN via --db-url leaks it into argv (ps) and shell
history. For render/inspect/doc/export/lint, when no input flag is given,
resolve the input from the DATABASE_URL environment variable instead; an
explicit flag always wins. This required relaxing the clap input groups
from required to optional, so input-presence validation now lives in the
single resolve() path. An after_help note keeps the input contract
discoverable in --help, and a clearer usage error names the env fallback.
Pixmap allocation for a huge diagram failed with a misleading 'image
dimensions may be zero' message (or risked an OOM). Validate the target
size against a 100-megapixel budget before allocating, with a clear error
that distinguishes zero dimensions from an oversized image and suggests
rendering to SVG instead.
@mhiro2 mhiro2 self-assigned this Jun 5, 2026
@mhiro2 mhiro2 added the bug Something isn't working label Jun 5, 2026
@github-actions

This comment has been minimized.

Three related fixes to the post-execution output/exit pipeline:

- lint --deny now exits 10 when an issue reaches the threshold, via a
  shared CliError::DenyThresholdReached (was exit 1, indistinguishable
  from a general failure). This matches diff --exit-code and the
  migration-risk deny gate so CI can tell a policy gate apart from a
  real failure.
- --quiet now suppresses non-error diagnostics (warning/info/hint) on
  stderr, living up to its documented 'less non-error output'. Exit-code
  decisions still consider the full diagnostic set.
- A missing --out parent directory is now reported as a usage error
  (exit 2) naming the path, instead of an opaque general failure; other
  I/O errors still surface as general failures.

Adds tests for the lint deny gate, quiet suppression, and the --out
directory check.
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

Schema review

Tip

✅ No risk findings — schema changes look safe to merge.

@mhiro2
mhiro2 force-pushed the fix/cli-operability-and-safety branch from 21173cb to 79b2e60 Compare June 5, 2026 13:02
Update the CLI reference and the relune skill to cover the new behavior:
an exit-codes table (0/1/2/3/10) with the shared deny/exit-code semantics,
RUST_LOG precedence, the --quiet output contract, the DATABASE_URL input
fallback (with a warning against DSNs on the command line), and the --out
parent-directory usage error.
@mhiro2
mhiro2 force-pushed the fix/cli-operability-and-safety branch from 79b2e60 to b372402 Compare June 5, 2026 13:04
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

Code Metrics Report

main (552e599) #186 (cce5e30) +/-
Coverage 94.4% 94.5% +0.0%
Test Execution Time 1m41s 1m36s -5s
Details
  |                     | main (552e599) | #186 (cce5e30) |  +/-  |
  |---------------------|----------------|----------------|-------|
+ | Coverage            |          94.4% |          94.5% | +0.0% |
  |   Files             |            100 |            100 |     0 |
  |   Lines             |          36683 |          36849 |  +166 |
+ |   Covered           |          34657 |          34826 |  +169 |
+ | Test Execution Time |          1m41s |          1m36s |   -5s |

Code coverage of files in pull request scope (92.1% → 93.3%)

Files Coverage +/- Status
crates/relune-cli/src/cli.rs 88.0% 0.0% modified
crates/relune-cli/src/commands/diff.rs 95.0% 0.0% modified
crates/relune-cli/src/commands/doc.rs 80.9% 0.0% modified
crates/relune-cli/src/commands/export.rs 92.1% 0.0% modified
crates/relune-cli/src/commands/input.rs 88.7% +3.7% modified
crates/relune-cli/src/commands/inspect.rs 100.0% 0.0% modified
crates/relune-cli/src/commands/lint.rs 82.4% +4.0% modified
crates/relune-cli/src/commands/render.rs 98.4% +0.0% modified
crates/relune-cli/src/commands/review.rs 91.3% 0.0% modified
crates/relune-cli/src/error.rs 97.9% 0.0% modified
crates/relune-cli/src/main.rs 98.9% +3.9% modified
crates/relune-cli/src/output.rs 95.2% +0.7% modified
crates/relune-cli/src/png.rs 94.0% -6.0% modified

Reported by octocov

@mhiro2
mhiro2 merged commit 73494cb into main Jun 5, 2026
6 checks passed
@mhiro2
mhiro2 deleted the fix/cli-operability-and-safety branch June 5, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant