Skip to content

Enforcement: two tests that fail when a command leaves the output convention #776

Closed

Description

@David-Noble-at-work

Plan: docs/plans/feature/776-output-enforcement.md
Related: #774, #775, #743 — the adoption work these tests certify

Adoption of the output convention went backwards, not merely slowly. extract-output-package.md recorded
two call sites in March — lore inspect and writ snapshot. writ snapshot was removed, taking half the
convention's adopters with it, and nothing recorded that it had. Invariants that are not tested decay
silently. These tests are what "done" means for the epic.

The two invariants, plus the one neither catches

No command package writes to os.Stdout directly. A direct write bypasses the sink, and with it
-o, --jq, --filter and the result/narration split.

No command registers its own output flag. A hand-rolled --output, --format or --json is a second
convention, and two conventions drift.

Every root that calls AddOutputFlags has every leaf reaching BuildPipeline. Neither invariant
above catches #753 or #754: writ registered no flags of its own, and the os.Stdout check finds a
command that prints but not one that silently ignores the flags it inherited. A flag registered on a root
that no leaf consumes is worse than an absent one, because it looks like compliance.

What each test has to prove it can fail

Each test is authored to fail on the current tree, or is shown to fail by re-introducing the defect it
guards, before it is trusted. A test that has only ever passed has not been shown to be a test.

Test Turns red when
no direct os.Stdout a fmt.Print is added to any cmd/* package
no own output flag a command calls Flags().String("output", …)
every leaf consumes a root gains AddOutputFlags and a leaf's RunE never calls BuildPipeline

Also here

Regenerate the CLI docs and confirm every command documents the same flags. docs/cli is gitignored
here but published — docs-publish.yaml regenerates it on every push to develop — so the generated
surface is what users actually read.

Plan and design documents

Kind Document
Plan docs/plans/feature/776-output-enforcement.md

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions