Skip to content

Email a Run notification only when the Command did not end merged - #1201

Merged
JacobStephens2 merged 5 commits into
mainfrom
issue-1114
Oct 24, 2026
Merged

JacobStephens2 merged 5 commits into
mainfrom
issue-1114

Conversation

@JacobStephens2

@JacobStephens2 JacobStephens2 commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

A Run notification can now be emailed only when the Command did not end merged. Choose it per command with email-unless-merged [<address>] (or --email-unless-merged), or on every Command with email.unless_merged = true in the User config. A merged Command's notification is still saved beside its Command log; it just isn't emailed.

 RunNotification::finish(account)
   save notification beside the Command log
-  if asked to email
+  if asked to email
+     and not (asked unless-merged and account.merged_with_nothing_waiting())
     send through Resend

How the flags and the User config decide (Flags::notification):

email / email-unless-merged / no-email given  -> that flag (any two together is an argument error)
else email.unless_merged = true               -> unless-merged (with or without email.always)
else email.always = true                      -> always
else                                          -> none
  • Merged with nothing waiting: the outcome is merged, with no Security finding left open by its fix and none waiting for the Day shift. So a merged Security fix that still needs a human is still emailed.
  • Setup: counts email.unless_merged as notifications on. Answering no to the notifications question turns it off too. Setup writes the key at its default with the other settings.
  • Docs: the help line, docs/guide.md (with the regenerated site/docs/index.html) and the GLOSSARY.md entries for Run notification and User config are updated. The hand-written site pages don't cover the email flags, so they are unchanged.

Evidence

  • Before: the new tests/run_notification.rs tests failed against main's behaviour (unknown key email.unless_merged, and the flag was not recognised): 0 passed, 6 failed. The reviewers' two tests also failed against the first commit, each with left: 0, right: 1 requests:

    • unless_merged_alone_in_the_user_config_emails_a_ticket_run_that_did_not_merge
    • email_unless_merged_still_emails_a_merged_fix_that_left_its_finding_open
  • After: these all pass:

    merge + email-unless-merged me@...      -> 0 emails, notification saved with "Result: merged"
    email-unless-merged (ready for review)  -> 1 email
    merge + email-unless-merged, failed     -> 1 email
    [email] unless_merged = true, no-merge  -> 1 email; with merge -> 0
    [email] unless_merged = true + email    -> 1 email even when merged
    secure ... merge email-unless-merged    -> 1 email if the close was left open, 0 if closed
    
  • Full Rust suite on cfd4025: cargo test --no-fail-fast gave 2431 passed, 0 failed. It ran with tag.gpgsign=false set through GIT_CONFIG_*, because this host's global tag.gpgsign = true fails three unrelated worktree::synchronization_tests with "no tag message?".

  • Site: npm test --prefix site passed 49 of 49.

  • After the last origin/main merge (d449187):

    • cargo clippy --all-targets -D warnings and cargo fmt --check are clean.
    • Unit tests for setup, asks, config, args, run_ending and notification pass.
    • The test files run_notification, command_surface, setup, user_config and the security_run email tests pass.
    • npm run docs:check passes.
    • The full suite on this merged head is left to CI.

Merge Danger

Door: two-way

The change is additive: a new flag and a new User config key, both off by default. One existing message changes: the email-flag conflict error now reads "email, email-unless-merged and no-email can't be used together".

Blast Radius: notifications

Only whether a Run notification is emailed is affected, and only when the new flag or key is used. A wrong decision could drop an email you wanted, but the notification file is always saved.

Review coverage

Both reviewers used origin/main as the fixed point, since local main was behind it.

  • Excluded as generated: site/docs/index.html. Its source is docs/guide.md, and cd site && npm run docs:check exits 0.

  • Changed after review, new hunks not reviewed:

    • src/run_ending.rs
    • src/setup/questions.rs
    • tests/security_run.rs
    • the cfd4025 hunks in the other files

    Every other changed file was read by both reviewers.

Unaddressed findings

Standards

  • Duplicated Code / Repeated Switches (NotificationAsk::SendUnlessMerged repeats Send in take_flag, public_flag_words and RunNotification::new): declined as a judgement call. The variant follows the existing Send(Option<String>) / Skip shape in src/notification.rs. Merging them into Send { to, unless_merged } would rewrite every NotificationAsk::Send(..) site in src/asks.rs, src/args.rs and their tests, to save three small arms.
  • Primitive Obsession (branching on Account.outcome's display string): partly addressed. The comparison now lives once, in Account::merged_with_nothing_waiting (src/run_ending.rs), beside the existing self.outcome == "review required" in Account::summary. Giving Account.outcome its own type is outside add user config / command flag that lets you get emailed notice of run completion only when the result is not merged #1114.
  • Shotgun Surgery (the EMAIL_FLAGS error string changed in several tests): declined. It comes from the existing EMAIL_FLAGS constant and ask_once design in src/args.rs, as the reviewer notes.

Security

  • None introduced. The Security review of c32f00b...HEAD found no unaddressed finding: the address after email-unless-merged passes the same is_address check as email and goes into retry commands as one quoted word (shell_command in src/args.rs). A malformed email.unless_merged is rejected (src/config.rs). Holding back an email is the user's own choice, and a merged Security fix whose finding is left open, or whose findings are waiting, is still emailed (Account::merged_with_nothing_waiting).

Spec

  • (a)1, end-to-end tests only for some Command kinds: partly addressed with the Security run tests. Architect, Pickup and Spec run tests are declined:
    • They all take their ask from Flags::notification (src/asks.rs), which unit tests cover.
    • They all send through the one RunNotification::finish (src/notification.rs).
    • Their merged outcome comes from Account::of_run (src/run_ending.rs), the same as the Ticket run tests exercise.

Closes #1114

Built with claude · claude-opus-5-5 · high

Security review outcome

No unaddressed introduced findings.

A Run notification asked for with the email-unless-merged flag, or by
email.always with email.unless_merged in the User config, is saved but
not emailed when the command ended merged.
…that left work waiting

Address the review of the email-unless-merged change:
- email.unless_merged asks for a Run notification on its own, as
  email-unless-merged does; Setup counts it as on, and answering no
  turns it off.
- A merged Security run whose fix left its finding open, or whose audit
  left findings waiting for the Day shift, is still emailed.
- Fold the flag into the help's email line, keeping help within its cap.
- Name the new tests in Ticket run vocabulary and fix the guide and
  glossary wording.
@JacobStephens2
JacobStephens2 merged commit a3cabce into main Oct 24, 2026
18 checks passed
@JacobStephens2
JacobStephens2 deleted the issue-1114 branch October 24, 2026 00:02
@JacobStephens2 JacobStephens2 mentioned this pull request Oct 24, 2026
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.

add user config / command flag that lets you get emailed notice of run completion only when the result is not merged

1 participant