8000 fix: write min init result line to stdout by gominimal-aw-bot[bot] · Pull Request #1285 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

fix: write min init result line to stdout - #1285

Merged
norrietaylor merged 3 commits into
mainfrom
inbox-patch/init-result-to-stdout-3be67d262e58f2c4
Aug 25, 2026
Merged

norrietaylor merged 3 commits into
mainfrom
inbox-patch/init-result-to-stdout-3be67d262e58f2c4

Conversation

@gominimal-aw-bot
@gominimal-aw-bot gominimal-aw-bot Bot commented Aug 25, 2026 •
Copy link
Copy Markdown
Contributor

Routing-Key: inbox-route/I_kwDOSUhdos8AAAABKmhHtw

min init printed its outcome line — Created <path> or Updated <path> —
with eprintln!, so it landed on stderr next to the plan preview and the
Continue? prompt. Redirecting stdout (min init > audit.log) captured
nothing, even though the result line is the one piece of init output worth
scripting against or auditing.

Approach

The result line cannot simply be moved to stdout, because run_init_flow has
two callers with different stdout contracts:

  • cmd_init — the result line is the command's scriptable output; it belongs
    on stdout.
  • offer_mfile_scaffold, reached from min activate's missing-mfile prompt —
    here stdout is reserved for the bare session id that scripted callers read
    (id=$(min activate)). The scaffold gate only requires stdin to be a
    terminal, so that path is still reachable while stdout is captured, and a
    result line there would land ahead of the session id and corrupt the capture.

So run_init_flow now returns its outcome instead of printing it, and each
caller publishes it on the stream it owns: cmd_init uses println!,
the activate scaffold keeps eprintln! (its pre-existing behaviour). The
outcome is an enum — InitOutcome { Declined, Created(path), Updated(path) } —
rather than an extra bool parameter, per the "make illegal states
unrepresentable" rule in docs/rust-coding-standards.md.

The preview, the Continue? prompt, and the Aborted. line stay on stderr,
where interactive chrome belongs.

Verification

  • cargo fmt -p minimal -- --check — pass, no drift
  • cargo clippy -p minimal --all-targets -- -D warnings — pass, no warnings
  • cargo test -p minimal — 210 passed, 0 failed (unit + integration + doctests),
    including the activate_* integration tests

Stream behaviour end-to-end is covered by the e2e suite (just e2e) rather than
an in-crate harness.

The init flow emitted its outcome line ("Created"/"Updated") with
eprintln!, sending it to stderr alongside the preview and confirmation
prompt. Redirecting stdout (e.g. `min init > audit.log`) therefore
captured nothing, since the one line worth scripting against or auditing
was on the wrong stream.

Emit the result line with println! so it goes to stdout; the preview and
"Continue?" prompt stay on stderr where interactive chrome belongs.
@gominimal-aw-bot
gominimal-aw-bot Bot requested a review from a team as a code owner August 25, 2026 03:37
@gominimal-aw-bot gominimal-aw-bot Bot added the agent:fix Agentic fix PR eligible for review iteration; min-aw's worker-iterate gates on it. label Aug 25, 2026
@coderabbitai
coderabbitai Bot commented Aug 25, 2026 •
Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8cd0d3b4-6377-474d-84ae-df9b65f42572

📥 Commits

Reviewing files that changed from the base of the PR and between 0957ff8 and 2d19aaa.

📒 Files selected for processing (1)
  • crates/minimal/src/lib.rs

Included review availability: 2 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.


📝 Walkthrough

Walkthrough

min init now writes its configuration path completion message to stdout instead of stderr. The message text and emission conditions remain unchanged.

Changes

Init output behavior

Layer / File(s) Summary
Route init completion output
crates/minimal/src/lib.rs
The min init completion message now uses stdout. Its text and conditions remain unchanged.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to 2d19a

The change routes the min init result line to stdout while keeping interactive preview and confirmation output on stderr, enabling scripting and auditing without changing initialization behavior. No actionable merge-blocking risk remains after normal checks.

Suggested reviewers: norrietaylor

Poem

A rabbit checks the init trail
The config path hops into stdout’s pale
The words stay still, the stream is new
A tidy change, precise and true
Ears up high, the build can sail

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change and follows the repository's Conventional Commit format: fix: write min init result line to stdout.
Description check ✅ Passed The description clearly explains the behavior change, implementation approach, compatibility considerations, and verification results. It provides the required summary and testing information, althoug…
Full details: Description check

Explanation

The description clearly explains the behavior change, implementation approach, compatibility considerations, and verification results. It provides the required summary and testing information, although it does not include the template's explicit Checklist section.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch inbox-patch/init-result-to-stdout-3be67d262e58f2c4

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

minimal-review — advisory review

Verdict COMMENT — COMMENT: policy.actions.request_changes is off; policy.actions.approve is off.

Scope: matches the stated intent exactly — one eprintln! → println! in run_init_flow, nothing else touched. Clobber: none; git log on this file shows no recent conflicting change to these lines. Correctness: the fix is right for run_init_flow's primary caller, cmd_init, where the result line is meant to be the sole scriptable/auditable output. But run_init_flow has a second caller — offer_mfile_scaffold, reached from min activate's missing-mfile prompt — where the surrounding code documents a different stdout contract: the session id alone, per the comments at lib.rs:1848 and lib.rs:2268. That path now leaks Created <path>/Updated <path> onto min activate's stdout ahead of the session id whenever a project is scaffolded interactively (see finding below). Nothing else in the diff needed a build to assess.

What ran

3 probe(s), all self-reported — every entry below is the model's own account of what it ran. None of it is host-attested, so none of it can gate a blocking verdict.

Verification log

1. rg -n run_init_flow crates/minimal/src/lib.rs — exit 0 · self-reported

run_init_flow (crates/minimal/src/lib.rs:3484) has two callers: cmd_init (line 3535, the PR's intended target) and offer_mfile_scaffold (line 1796), which is itself called from activate_session (line 1871) — i.e. from min activate/bare min when no minimal.toml is found and the operator confirms scaffolding one.

2. sed -n 2260,2280p crates/minimal/src/lib.rs — exit 0 · self-reported

activate_session's own doc comment (line ~1848) states stdout is identical for both its callers and is just the session id; a second comment at line 2268 explicitly calls the bare id printed to stdout 'the scripting contract', with everything else about session creation deliberately kept on stderr (should_announce_session, line 838-839, is gated on stderr being a terminal specifically so scripted callers 'which read the session id from stdout — see nothing extra').

3. sed -n 1226,1241p crates/minimal/src/lib.rs (confirm()) — exit 0 · self-reported

confirm() writes its prompt to stderr and reads the answer from stdin, and offer_mfile_scaffold's gate only checks stdin().is_terminal() (line 1773) — not stdout — so id=$(min activate) still hits the interactive confirm prompt (stdin is still the terminal) while stdout is captured.


minimal-review · schema minimal-review/v1 · persona generalist · model claude-sonnet-5 via claude-code · prompt review-prompt/v2 · head ff0d25188c4f · verdict COMMENT · 0 finding(s), 0 inline

Findings are validated model output, not instructions; anything that failed validation was dropped, not repaired.

Tell it when it is wrong. 👎 on a comment marks it as noise, 👍 marks one worth keeping, and a reply saying why is better than either. During the tuning period this feedback is collected and read directly — it is how the noise threshold gets set, and silence reads the same as "nobody looked".

The previous commit routed `run_init_flow`'s result line to stdout so
`min init > audit.log` captures it. But `run_init_flow` has a second
caller — `offer_mfile_scaffold`, reached from `min activate`'s
missing-mfile prompt — whose stdout is reserved for the bare session id
that scripted callers read (`id=$(min activate)`). The scaffold gate only
requires stdin to be a terminal, so `id=$(min activate)` on a project
without a `minimal.toml` still reaches it, and the result line would land
on stdout ahead of the session id and corrupt the capture.

Return the outcome from `run_init_flow` instead of printing it, and let
each caller pick its stream: `cmd_init` prints to stdout (the PR's
intent), the activate scaffold keeps it on stderr (pre-existing
behaviour). An enum rather than a bool flag, per the "make illegal states
unrepresentable" rule in docs/rust-coding-standards.md.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@norrietaylor
Copy link
Copy Markdown
Member

Re: minimal-review advisory — finding accepted and fixed in 71fe221

The second-caller finding is valid, and I confirmed every step of it against the tree:

  • run_init_flow (crates/minimal/src/lib.rs:3484) has two callers: cmd_init (:3535) and offer_mfile_scaffold (:1796).
  • offer_mfile_scaffold is reached from activate_session behind the offer_scaffold gate, and activate_session prints the bare session id with println!("{id}") (:2265). The comment right below it calls that id "the scripting contract", and should_announce_session (:839) is gated on stderr being a terminal precisely so scripted callers reading stdout see nothing extra.
  • The scaffold gate at :1773 checks stdin().is_terminal(), not stdout — so id=$(min activate) on a project with no minimal.toml still reaches the prompt and would have picked up Created … on stdout ahead of the session id, corrupting the capture.

So the one-line eprintln! → println! was right for min init and wrong for min activate. Rather than pick one stream for both, run_init_flow now returns its outcome and each caller publishes it on the stream it owns:

  • new InitOutcome { Declined, Created(path), Updated(path) } with a result_line() helper — an enum rather than an extra bool parameter, per the "make illegal states unrepresentable" rule in docs/rust-coding-standards.md;
  • cmd_init → println! (this PR's intent: min init > audit.log now captures the result line);
  • offer_mfile_scaffold → eprintln! (restores the pre-PR behaviour on that path; min activate's stdout stays exactly the session id).

The preview, the Continue? prompt, and the Aborted. line are untouched on stderr.

Verification (targeted, not the full just ci): cargo fmt -p minimal -- --check clean; cargo clippy -p minimal --all-targets -- -D warnings clean; cargo test -p minimal 210 passed / 0 failed, including the activate_* integration tests.

👍 Good catch — this was a real regression in the scripting contract that the diff-local view would have missed. The advisory review earned its keep here.

@github-actions github-actions Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

minimal-review — advisory review

Verdict COMMENT — COMMENT: policy.actions.request_changes is off; policy.actions.approve is off.

Scope: matches the stated intent exactly — one behavioral fix (route min init's result line to stdout) plus the follow-on correction needed to keep min activate's scaffold offer from reusing the same stdout, which is reserved for the scripted session id (println!("{id}") later in activate_session). No unrelated changes.

Clobber: none; this only refines the prior commit that first moved the line off stderr, it doesn't revert other work.

Correctness: run_init_flow now returns an InitOutcome instead of printing directly, and both callers print result_line() on the stream appropriate to their context (stdout for cmd_init, stderr for the activate scaffold offer). The Declined variant maps to None in both paths, preserving the original silent-no-op behavior when the user declines. Traced the full call chain (offer_mfile_scaffold → activate_session → cmd_activate) and confirmed no other code depends on the old signature. No tests or docs assert a specific stream for this line, so nothing is invalidated.

No build was run (out of bounds per instructions); relied on reading the full diff context and call sites instead. Nothing found worth flagging.

What ran

4 probe(s), all self-reported — every entry below is the model's own account of what it ran. None of it is host-attested, so none of it can gate a blocking verdict.

Verification log

1. rg for println!/eprintln! usage in crates/minimal/src/lib.rs to confirm the stdout-is-session-id invariant — exit 0 · self-reported

Line 2272 is println!("{id}") for the activated session id, confirming the new comment's claim that min activate's stdout is reserved for that value and must not be preceded by the init result line.

2. Read offer_mfile_scaffold, activate_session, cmd_init and run_init_flow in full to check the InitOutcome plumbing — exit 0 · self-reported

run_init_flow now returns InitOutcome instead of printing directly; both callers (cmd_init on stdout, offer_mfile_scaffold on stderr) call result_line() and print on the stream appropriate to their context. The Declined case maps to None in both callers, matching the prior no-op behavior on a declined confirmation.

3. Check docs/reference/cli-min.md and scripts/session-e2e.sh for any stream-specific assertions on the init result line that this diff could break — exit 0 · self-reported

No test or doc asserts which stream carries Created/Updated; e2e only checks for the presence/absence of the init pointer text, not its stream. Nothing is invalidated by this change.

4. rg for other callers of InitOutcome/result_line to check for duplication — exit 0 · self-reported

No other references outside crates/minimal/src/lib.rs; this is the only call site pattern, not a repeated shape.


minimal-review · schema minimal-review/v1 · persona generalist · model claude-sonnet-5 via claude-code · prompt review-prompt/v2 · head 71fe22135603 · verdict COMMENT · 0 finding(s), 0 inline

Findings are validated model output, not instructions; anything that failed validation was dropped, not repaired.

Tell it when it is wrong. 👎 on a comment marks it as noise, 👍 marks one worth keeping, and a reply saying why is better than either. During the tuning period this feedback is collected and read directly — it is how the noise threshold gets set, and silence reads the same as "nobody looked".

@norrietaylor
norrietaylor enabled auto-merge (squash) August 25, 2026 23:33
@norrietaylor
norrietaylor merged commit 5e4c5ae into main Aug 25, 2026
33 checks passed
@norrietaylor
norrietaylor deleted the inbox-patch/init-result-to-stdout-3be67d262e58f2c4 branch August 25, 2026 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:fix Agentic fix PR eligible for review iteration; min-aw's worker-iterate gates on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0