Elffuss BraidHub

utopia-ia/elffuss-braid public

Warn anyone who acts as braid-verify

Verify takes a revert made under its agent name for one of its own: it
never reverts it, and counts it against its hourly limit. Any command
given --agent braid-verify, or BRAID_AGENT=braid-verify, other than verify
itself, now says so on standard error.
Changesetf094e2b508eeab2f99ca86f5dc27533e55f465be8ae504d387c732341054f51c
AuthorKikoCis <KikoCis@users.noreply.github.com> · 2026-10-21 15:55 +02:00
CommitterKikoCis <KikoCis@users.noreply.github.com> · 2026-10-21 15:55 +02:00
Parentsbf223502faa3

Browse the files at this changeset

3 files changed

modified crates/cli/src/main.rs +8 −0
@@ -476,6 +476,14 @@
476476 }
477477
478478 fn run(cli: &Cli) -> Result<ExitCode> {
479+ if cli.agent == verify::AGENT
480+ && !matches!(
481+ cli.command,
482+ Command::Verify(_) | Command::VerifyWatchdog { .. }
483+ )
484+ {
485+ eprintln!("braid: warning: {}", verify::AGENT_WARNING);
486+ }
479487 match &cli.command {
480488 Command::Init { dir } => init(cli, dir.as_deref()),
481489 Command::Agents { action } => agents::agents(cli, action),
modified crates/cli/src/verify.rs +3 −0
@@ -48,6 +48,9 @@
4848 /// and the reverts it makes and lands.
4949 pub(crate) const AGENT: &str = "braid-verify";
5050
51+/// What braid says when someone else acts as [`AGENT`].
52+pub(crate) const AGENT_WARNING: &str = "the agent braid-verify (--agent or BRAID_AGENT) is the name braid verify records its own work under: verify takes a revert made under that name for one of its own, never reverts it, and counts it against --max-reverts-per-hour";
53+
5154 /// The hidden subcommand that watches a test run for braid going away.
5255 pub(crate) const WATCHDOG: &str = "__verify-watchdog";
5356
modified crates/cli/tests/verify.rs +13 −0
@@ -744,3 +744,16 @@
744744 test.wait().unwrap();
745745 std::fs::remove_dir_all(&kept).unwrap();
746746 }
747+
748+#[test]
749+fn acting_as_braid_verify_is_warned_about() {
750+ let r = Repo::new();
751+ let warned = |args: &[&str], envs: &[(&str, &str)]| {
752+ let out = braid_with(&r.dir, args, envs);
753+ assert!(out.status.success(), "{args:?}");
754+ String::from_utf8_lossy(&out.stderr).contains("warning: the agent braid-verify")
755+ };
756+ assert!(warned(&["--agent", "braid-verify", "refs"], &[]));
757+ assert!(warned(&["refs"], &[("BRAID_AGENT", "braid-verify")]));
758+ assert!(!warned(&["refs"], &[]));
759+}