Skip to content

Make pipeline --wait wait, and delete the dead logs --region - #841

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/807-inert-flags
Oct 11, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/807-inert-flags

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Closes #807. Correctness audit 2026-10.

Both flags had exactly two references in the tree — declaration and registration — so
neither did anything with the value it demanded.

1. pipeline launch --wait returned immediately

The launch path invokes the orchestrator with InvocationType: Event and returns. So:

spawn pipeline launch p.json --wait && ./collect-results.sh

exited 0 at once and ran the next step against a pipeline that had not started — the
precise thing the flag exists to prevent.

It now polls until the pipeline is terminal and exits non-zero unless it succeeded.
That second half is what makes the flag worth having: a version that merely blocked would
still let the && run after a FAILED pipeline.

  • Transient read failures and a not-yet-written record are retried rather than reported as
    failure. The orchestrator writes the record asynchronously, so "not found" is normal
    immediately after launch — treating it as failure would make --wait useless exactly
    when it is used.
  • --wait-timeout bounds the wait at 24h. An unbounded wait on a wedged pipeline hangs CI
    forever: a different failure from the one being fixed, but no better. On timeout it says
    the pipeline is still running and how to check it.
  • PipelineStatus.IsTerminal/.Succeeded are new, with an exhaustive switch and no
    default, so an unclassified status cannot fall through to "keep waiting".

2. logs --region was worse than inert

A local flag wins the binding over a persistent one. So spawn logs x --region us-west-2 bound to the dead local flag, the value never reached SetSharedFlags, and
there was no working --region on that command at all. Deleting the local flag lets the
root flag apply, as it does everywhere else:

$ spawn logs --help | grep -c -- --region
1      # the global one, previously shadowed by a dead local

The structural gate

TestEveryFlagVariableIsReadSomewhere catches this class directly: a flag variable with
only its declaration and registration in non-test source is accepted from the user and
discarded. It reads the source, because cobra cannot tell a flag that is read from one
that is not.

Deprecated flags are exempt — that is what deprecating one means: still accepted so
scripts do not break, deliberately ignored. The exemption comes from the code's own
MarkDeprecated calls, not a hand list (rule 4). Three flags surfaced on the first run —
--use-reservation, pipeline --detached, cleanup --force — and all three are
deliberate deprecated no-ops. Neither --wait nor logs --region was, which is exactly
why they were defects and not decisions.

Two gates that exist because reverts went uncaught

Worth stating plainly, since the first pass looked complete and was not:

  • Reference counting passed if flagWait && false { return waitForPipeline(…) }. Both
    variables still had three references; the third was dead code. Reference counting finds a
    flag nobody looks at, but not one looked at and ignored — so
    TestPipelineLaunchActuallyWaits asserts the wiring: a plain if flagWait {, a call,
    and the result returned (otherwise a failed pipeline still exits 0).
  • IsTerminal's comment claimed a classification gate I had not written. Removing
    StatusCancelled from the terminal set as a deliberate revert failed nothing.
    TestEveryPipelineStatusIsClassified discovers the constants from the source and
    requires each to be named in the switch.

A gate removed after running it

The first version of cmd/inert_flags_test.go required that no local flag shadow a
persistent root flag — the theory being that logs --region broke because the local flag
won the binding. Run, it reported more than twenty commands declaring their own
--region: launch, list, doctor, every array subcommand, cleanup, footprint…

That is the repo's convention, not a defect. Keeping the gate would have meant an allowlist
of twenty entries each asserting that ordinary code is an exception — rule 4's anti-pattern
turned inside out, where the list is what is normal and the gate is what is wrong. The
reasoning is recorded in the file in place of the test.

The shadowing was never the defect; it only determined how the symptom presented. The
defect was that the flag was never read, and the gate above catches that with no reference
to shadowing at all.

Verification

make check (all nested modules), make check-docs with docs-gen/ regenerated
(logs.md, pipeline.md), changelog gate, semgrep 0 findings, make api-snapshot no
drift (pkg/pipeline is not in the public-surface set), Tier 0 e2e with -count=1.

Seven compiling reverts: --wait inert via dead code (×2 shapes — guard and discarded
return), the dead logs --region restored, --wait succeeding on a FAILED pipeline,
--wait-timeout defaulting to 0, and StatusCancelled dropped from the terminal set.

#808 is the remaining Phase 3 issue (compliance flag arity) and is next.

Both flags had exactly two references in the tree — declaration and
registration — so neither did anything with the value it demanded.

`pipeline launch --wait` returned immediately: the launch path invokes
the orchestrator with InvocationType: Event. A CI step written as
`spawn pipeline launch p.json --wait && ./collect-results.sh` exited 0
at once and ran the next step against a pipeline that had not started,
which is the precise thing the flag exists to prevent. It now polls
until terminal and exits non-zero unless the pipeline SUCCEEDED — that
second half is what makes the flag worth having, because a version that
merely blocked would still let the `&&` run after a FAILED pipeline.

Transient read failures and a not-yet-written record are retried rather
than reported as failure, since the orchestrator writes the record
asynchronously and "not found" is normal right after launch.
--wait-timeout bounds the wait at 24h: an unbounded wait on a wedged
pipeline hangs CI forever, which is a different failure from the one
being fixed but no better.

`logs --region` was worse than inert. A local flag wins the binding over
a persistent one, so the value never reached SetSharedFlags and there
was no working --region on that command at all. Deleting the local flag
lets the root flag apply, as it does elsewhere.

TestEveryFlagVariableIsReadSomewhere catches this class structurally,
reading the source because cobra cannot tell a flag that is read from
one that is not. Deprecated flags are exempt — that is what deprecating
means — and the exemption comes from the code's own MarkDeprecated calls
rather than a hand list. Three flags surfaced on the first run
(--use-reservation, pipeline --detached, cleanup --force), all three
deliberate deprecated no-ops. Neither --wait nor logs --region was,
which is why they were defects and not decisions.

Two more gates exist because two reverts went uncaught first time.
Reference counting passed `if flagWait && false { ... }` — three
references each, all dead — so it finds a flag nobody looks at but not
one looked at and ignored; the wiring needs its own assertion. And
IsTerminal's comment claimed a classification gate I had not written:
removing StatusCancelled from the terminal set failed nothing.

One gate was removed after running it. It required that no local flag
shadow a persistent root flag, and reported more than twenty commands
declaring their own --region. That is the repo's convention, not a
defect; keeping it would have meant twenty allowlist entries each
asserting that ordinary code is exceptional — rule 4's anti-pattern
inside out. The reasoning is recorded in the file in place of the test.

Closes #807
@scttfrdmn scttfrdmn added this to the Correctness audit 2026-10 milestone Oct 11, 2026
@codecov

codecov Bot commented Oct 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.75000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/pipeline.go 95.00% 2 Missing ⚠️
pkg/pipeline/pipeline.go 87.50% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 83e994e into main Oct 11, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/807-inert-flags branch October 11, 2026 20:18
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.

Two inert flags: pipeline launch --wait never waits, and logs --region is dropped while shadowing the global --region

1 participant