Skip to content

docs(cli): define global CLI output contract ADR (#1798)#1800

Merged
josecelano merged 7 commits into
torrust:developfrom
josecelano:1798-global-cli-output-contract-adr
May 20, 2026
Merged

docs(cli): define global CLI output contract ADR (#1798)#1800
josecelano merged 7 commits into
torrust:developfrom
josecelano:1798-global-cli-output-contract-adr

Conversation

@josecelano
Copy link
Copy Markdown
Member

Closes #1798

Summary

Establishes a repository-wide Architectural Decision Record (ADR) that defines a single, canonical CLI output contract for every first-party binary in torrust-tracker, aligned with the approach already adopted by torrust-index (ADR-T-010).

Changes

  • docs/adrs/20260519000000_define_global_cli_output_contract.md — new ADR with 10 sections:

    1. Output channels: stdout = one JSON result object; stderr = NDJSON diagnostics
    2. Exit codes: 0 / 1 / 2
    3. Binary classification table (5 normative binaries; profiling out of scope)
    4. TTY refusal: adopted unconditionally for stdout-result-data commands; exit 2 + JSON stderr diagnostic
    5. User-facing verbosity: command-specific; all output at any level must be JSON
    6. Shared CLI infrastructure: not prescribed; cli-common from Torrust Index as reference
    7. Redaction policy: mask secrets before inclusion in any JSON output
    8. Workspace lint guards: clippy::print_stdout / clippy::print_stderr deny once migration complete (interacts with chore: migrate lint configuration to [workspace.lints] in Cargo.toml #1786)
    9. AI agent output capture: redirect to .tmp/<cmd>.stdout / .tmp/<cmd>.stderr
    10. Migration policy: prescriptive; new commands comply immediately; existing migrated progressively; deprecated binaries removed
  • docs/adrs/index.md — new ADR row + ## ADR Lifecycle section (merged = accepted; - Status: only for special terminal states like Superseded)

  • console/tracker-client/docs/adrs/20260512080000_define_tracker_cli_io_contract_and_error_handling.md — status changed to Superseded by 20260519000000

  • docs/issues/open/1798-global-cli-output-contract-adr.md — spec updated (T1–T7, T9 DONE); binary classification table; T3/T4 decisions recorded; progress log updated

  • docs/issues/drafts/cli-output-contract-migration.md — new draft follow-up issue for migrating existing non-compliant binaries (46 print!/println!/eprint!/eprintln! occurrences surveyed; 9-task migration plan)

  • .github/skills/dev/planning/create-adr/SKILL.md — added ### ADR Status subsection: do not add - Status: by default; only for Superseded / Deprecated states

  • project-words.txt — added eprint

ADR Lifecycle Note

An ADR present in develop or main is accepted — the PR review process is the acceptance gate. No explicit - Status: Accepted header is needed. This PR itself constitutes the acceptance review for ADR 20260519000000.

What is NOT in scope

The current codebase does not yet fully comply with the contract. Migration of existing non-compliant binaries is tracked in the draft follow-up issue docs/issues/drafts/cli-output-contract-migration.md and will be handled in a separate issue/PR.

@josecelano josecelano requested a review from a team as a code owner May 19, 2026 20:57
Copilot AI review requested due to automatic review settings May 19, 2026 20:57
@josecelano josecelano self-assigned this May 19, 2026
@josecelano josecelano requested a review from da2ce7 May 19, 2026 21:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Establishes a repository-wide ADR that defines a single, canonical JSON-only CLI output contract (stdout result object + stderr NDJSON diagnostics, exit codes 0/1/2, and mandatory TTY refusal for stdout-result-data commands) for all first-party binaries in torrust-tracker, superseding the tracker-client–local ADR and adding follow-up migration planning.

Changes:

  • Adds new ADR documenting the global CLI output contract and migration policy.
  • Updates ADR index and tracker-client local ADR to reflect the new lifecycle/supersession policy.
  • Adds/updates issue-spec docs (open issue spec + draft migration plan) and supporting skill/spellcheck entries.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
docs/adrs/20260519000000_define_global_cli_output_contract.md New ADR defining the global JSON-only CLI output contract, including TTY refusal and migration policy.
docs/adrs/index.md Adds ADR index row and documents ADR lifecycle/status conventions.
console/tracker-client/docs/adrs/20260512080000_define_tracker_cli_io_contract_and_error_handling.md Marks the tracker-client ADR as superseded by the new global ADR.
docs/issues/open/1798-global-cli-output-contract-adr.md Adds/updates the #1798 issue spec with background, decisions, classification table, and progress tracking.
docs/issues/drafts/cli-output-contract-migration.md Draft follow-up migration issue to bring existing binaries into compliance and enable clippy print lints.
.github/skills/dev/planning/create-adr/SKILL.md Documents ADR - Status: header guidance (only for terminal states like Superseded).
project-words.txt Adds eprint to the spellcheck allowlist.
Comments suppressed due to low confidence (1)

docs/issues/open/1798-global-cli-output-contract-adr.md:46

  • This section says the tracker-client local ADR has status "Accepted", but this PR updates that ADR to "Superseded". To avoid internal doc inconsistency, update this wording (e.g. “was previously Accepted” or reflect the new Superseded status).
The tracker already has a local CLI I/O contract, but it is scoped only to
`console/tracker-client`:

- `console/tracker-client/docs/adrs/20260512080000_define_tracker_cli_io_contract_and_error_handling.md`
  (status: Accepted) — defines JSON default, stdout/stderr channel split, exit codes 0/1/2, and
  NDJSON progress for monitor-style commands.
- `console/tracker-client/docs/contracts/tracker-cli-io-contract.md` — the normative companion

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

---
doc-type: issue
issue-type: task
status: open
Comment on lines +84 to +87
{
"kind": "tty_refusal",
"message": "stdout is a TTY; pipe the output to consume result data"
}
josecelano added a commit to josecelano/torrust-tracker that referenced this pull request May 20, 2026
…t#1798)

- Fix issue spec frontmatter: status open → planned (matches repo
  convention for open issue specs).
- Fix issue spec background: local ADR reference updated from
  "status: Accepted" to "superseded by ADR 20260519000000".
- Fix ADR TTY-refusal example: add note that examples are
  pretty-printed; actual wire format is single-line NDJSON.
josecelano added a commit to josecelano/torrust-tracker that referenced this pull request May 20, 2026
…t#1798)

- Fix issue spec frontmatter: status open → planned (matches repo
  convention for open issue specs).
- Fix issue spec background: local ADR reference updated from
  "status: Accepted" to "superseded by ADR 20260519000000".
- Fix ADR TTY-refusal example: add note that examples are
  pretty-printed; actual wire format is single-line NDJSON.
@josecelano josecelano force-pushed the 1798-global-cli-output-contract-adr branch from 89763c7 to 1dd8024 Compare May 20, 2026 07:02
- Add docs/adrs/20260519000000_define_global_cli_output_contract.md
  with the full global CLI output contract (10 sections: channels,
  exit codes, binary classification, TTY refusal, verbosity, shared
  infra, redaction, lint guards, AI agent capture, migration policy).
- Add ADR row to docs/adrs/index.md.
- Mark tracker-client local ADR as superseded by the global ADR.
- Update issue spec: T1–T6 and T9 DONE; binary classification table
  added; T3/T4 decisions recorded.
- Add `eprint` to project-words.txt.
Merged ADRs are implicitly accepted via PR review. No `- Status:`
header is needed for the common case.

- Remove `- Status: Proposed` from the global CLI output contract ADR.
- Add an ADR Lifecycle section to docs/adrs/index.md explaining the
  policy (status header only for special states: Superseded, etc.).
- Add an ADR Status subsection to the create-adr skill with the same
  guidance.
…tion (torrust#1798)

Draft issue spec covering:
- Remove three deprecated binaries (udp_tracker_client,
  http_tracker_client, tracker_checker).
- Migrate http_health_check to JSON stdout/stderr.
- Wire TTY refusal into tracker_client.
- Rewrite tracker-client console abstraction layer.
- Replace library-level println! with tracing in packages/configuration
  and packages/udp-tracker-core.
- Enable clippy::print_stdout / clippy::print_stderr as workspace-level
  deny lints once migration is complete.
…ecycle (torrust#1798)

- Mark T7 DONE: workspace lint guard deferred to follow-up draft issue
  docs/issues/drafts/cli-output-contract-migration.md.
- Reword T8 note: peer review via PR; merged to develop = accepted.
- Update checkpoint: "ADR peer-reviewed and status set to Accepted" →
  "PR opened, reviewed, and merged to develop".
- Fix close-checkpoint path: drafts/ → open/.
- Reword AC10 to match the new ADR lifecycle (no explicit status field).
- Reformat migration draft tables (column alignment only).
…t#1798)

- Fix issue spec frontmatter: status open → planned (matches repo
  convention for open issue specs).
- Fix issue spec background: local ADR reference updated from
  "status: Accepted" to "superseded by ADR 20260519000000".
- Fix ADR TTY-refusal example: add note that examples are
  pretty-printed; actual wire format is single-line NDJSON.
Use `ndjson` as the code fence language instead of `json` to prevent
the IDE's automatic JSON formatter from reformatting the single-line
example into a multi-line block on save.
@josecelano josecelano force-pushed the 1798-global-cli-output-contract-adr branch from 1dd8024 to d8fb7f2 Compare May 20, 2026 07:47
@josecelano
Copy link
Copy Markdown
Member Author

ACK d8fb7f2

@josecelano josecelano merged commit e75c25a into torrust:develop May 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Define a Global CLI Output Contract for the Tracker (ADR)

2 participants