Repository navigation
Description
Goal
Write a repository-wide Architectural Decision Record (ADR) that establishes a single, canonical command-line output contract for every first-party, operator-facing CLI entrypoint in the torrust-tracker repository, aligning with the approach adopted by torrust-index (ADR-T-010) and reflecting the reality that AI agents are the dominant CLI consumers today.
This ADR is prescriptive. The current codebase does not yet comply with the rules it establishes. Existing binaries will be migrated progressively in a separate follow-up issue.
Key rules (to be codified in the ADR)
- Both stdout and stderr are machine-readable JSON — no plain text on either channel.
- Stdout = result data (one JSON object + newline on success; empty on failure).
- Stderr = diagnostics — internal tracing records and user-facing progress events, both as NDJSON (filterable by record
kind/type). - TTY refusal adopted: commands with stdout result data refuse when stdout is a TTY (exit 2 + JSON stderr diagnostic).
- Exit codes:
0success,1runtime failure,2usage/TTY/argv failure. - Shared Rust infrastructure package (
packages/tracker-cli-common) to be decided. - Workspace lint guards
clippy::print_stdout/clippy::print_stderr(interacts with chore: migrate lint configuration to[workspace.lints]in Cargo.toml #1786). - Redaction policy for secrets in JSON diagnostics.
- AI agent output capture recommendation: per-command redirection to
.tmp/<cmd>.stdout/.tmp/<cmd>.stderr.
Scope — in-scope binaries
src/main.rs— tracker server (no-stdout-result class)src/bin/http_health_check.rs— stdout-result-data classsrc/bin/e2e_tests_runner.rs,src/bin/qbittorrent_e2e_runner.rs— TBDsrc/bin/profiling.rs— likely developer-only; may be out of normative scopeconsole/tracker-client/— all subcommands
Relationship to existing contracts
The tracker-client local ADR (console/tracker-client/docs/adrs/20260512080000_define_tracker_cli_io_contract_and_error_handling.md) will be superseded by this global ADR once accepted.
Full spec
docs/issues/open/1798-global-cli-output-contract-adr.md
References
- Index ADR-T-010: https://github.com/torrust/torrust-index/blob/develop/adr/010-global-command-line-output-contract.md
- Deployer UX research: console-output-logging-strategy, console-stdout-stderr-handling, user-output-vs-logging-separation
- Related: chore: migrate lint configuration to
[workspace.lints]in Cargo.toml #1786 (workspace lints migration)
Activity
docs(cli): address Copilot review comments on PR torrust#1800 (torrus…
docs(cli): use ndjson code fence for TTY-refusal example (torrust#1798)
docs(cli): add issue spec for global CLI output contract ADR (torrust…
docs(cli): draft global CLI output contract ADR (torrust#1798)
docs(adrs): drop explicit Status field from accepted ADRs (torrust#1798)
docs(issues): add draft follow-up issue for CLI output contract migra…
docs(issues): update spec progress — T7 DONE, T8 reworded for ADR lif…
docs(cli): address Copilot review comments on PR torrust#1800 (torrus…
docs(cli): use ndjson code fence for TTY-refusal example (torrust#1798)
docs(cli): add issue spec for global CLI output contract ADR (torrust…
docs(cli): draft global CLI output contract ADR (torrust#1798)
docs(adrs): drop explicit Status field from accepted ADRs (torrust#1798)
docs(issues): add draft follow-up issue for CLI output contract migra…
docs(issues): update spec progress — T7 DONE, T8 reworded for ADR lif…
docs(cli): address Copilot review comments on PR torrust#1800 (torrus…
docs(cli): use ndjson code fence for TTY-refusal example (torrust#1798)
chore(issues): archive closed issue specs #1790, #1793, #1795, #1797, #…
Merge #1812: chore(issues): archive closed issue specs to docs/issues…
Merge torrust#1800: docs(cli): define global CLI output contract ADR (t…