Skip to content

writ registers --store and reads it nowhere: status reports on the default store regardless #753

Closed

Description

@David-Noble-at-work

writ registers --store on its root and reads it nowhere. A user who points writ at another store gets a
report on the default one, with nothing said.

$ writ status --store /some/other/root
Layers:
  ...
Store: 0 run(s) folded          <- folded from the DEFAULT store, not the one named

Root cause

A flag registered on a root that no leaf consumes. cmd/writ/writ/root.go:49 calls
cli.AddOutputFlags(rootCmd, &outputOptions), so cobra advertises --filter, --jq, --output/-o, and
--store on every writ command's help. Consuming them is a separate act, and writ performs it once:

$ grep -rn outputOptions cmd/writ
cmd/writ/writ/config.go:160    cfg.JSONOutput = outputOptions.Format == "json"
cmd/writ/writ/commands.go:290  var outputOptions cli.SinkOptions
cmd/writ/writ/commands.go:302  pipeline, err := cli.BuildPipeline(outputOptions, cmd.OutOrStdout())   <- runVerify

outputOptions.Store is read by nothing. The same root cause produces
#754 -- writ accepts any --output value, because
the string never reaches FormatterByName -- which is the milder face of it: that one accepts wrong input,
this one substitutes a different data source.

Why this one is not cosmetic

--store only means something when someone calls SetStoreRoot, and that has exactly one caller in the
tree:

cmd/devlore-test/devloretest/commands.go:61

Yet writ genuinely uses the execution store: readback.go reads cli.TracesDir() (lines 228, 247) and
cli.GraphsDir() (line 500) to fold runs into its inventory. So the flag is not merely ignored -- writ reads
a different filesystem location than the one it was told to read, and reports the result as though it had
complied.

An absent flag errors and the user tries something else. A present flag that silently substitutes a
different data source produces a confident wrong answer.

Fix

writ resolves --store through cli.SetStoreRoot before any command that touches the store, restoring on
exit as devlore-test does. Every command reading TracesDir() or GraphsDir() is affected: status,
repo, and anything else routed through readback.

Verification

  • writ status --store <tmp> reports on <tmp>, and reports zero runs when <tmp> is empty.
  • A relative --store resolves the way devlore-test's does; OpenTree requires an absolute path.
  • Deploying into a relocated store and reading it back reports what was deployed.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions