Elffuss BraidHub

utopia-ia/elffuss-braid public

Landings, status and hub status say how the hub verifies the branch

A landing on a hub carries the answer's verify into the report, as
hub_verify in --json (null otherwise), and while the branch is red or
stuck braid says so in one line on standard error, naming the culprit and
braid hub verify status: braid land, change create --land, revert and hub
request land, the last with the request's repository.

A fetch records the hub's braid/green/<branch> and braid/red/<branch>
where it saw them, as remote/hub/braid/green/<branch>, when the store holds
what they name, and drops them when the hub does; it never carries them.
braid status --json gives them as hub_green and hub_red, and braid hub
status gives each branch's green and red.
Changeset9cd050413e8ec3a673d839579a54c37caae909332ca0bac542cf4c6796e9d70d
AuthorKikoCis <KikoCis@users.noreply.github.com> · 2026-10-22 17:10 +02:00
CommitterKikoCis <KikoCis@users.noreply.github.com> · 2026-10-22 17:10 +02:00
Parentse37ee20e4c7f

Browse the files at this changeset

11 files changed

modified crates/cli/src/hub/fetch.rs +74 −2
@@ -12,7 +12,9 @@
1212 //! changesets the hub does not have stays where it is, and is reported. A
1313 //! tag is created, and never moved. `remote/hub/<ref>` records where each
1414 //! of the hub's refs was seen, so that a branch kept back still has a name
15-//! for the hub's head.
15+//! for the hub's head. Of the hub's own refs, only `braid/green/<branch>`
16+//! and `braid/red/<branch>` are recorded so, when the store holds what they
17+//! name: they say how the hub verifies a branch, and are never carried.
1618
1719 use std::cell::RefCell;
1820 use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
@@ -23,6 +25,7 @@
2325 use braid_format::tree::{EntryKind, Node};
2426 use braid_format::{Kind, ObjectId, Objects, Signature};
2527 use braid_hubproto::api::MissingRequest;
28+use braid_hubproto::verify::{GREEN_PREFIX, RED_PREFIX};
2629 use braid_repo::{Repo, RepoHistory};
2730 use braid_store::{RefUpdate, Refs, Store, TransactError};
2831
@@ -49,6 +52,13 @@
4952 braid_repo::is_branch(name) || is_tag(name)
5053 }
5154
55+/// Whether a hub ref says how the hub verifies a branch (section 25 of
56+/// `docs/hub.md`): `braid/green/<branch>` or `braid/red/<branch>`. Never
57+/// carried, it is only recorded where it was seen.
58+pub(crate) fn is_verdict(name: &str) -> bool {
59+ name.starts_with(GREEN_PREFIX) || name.starts_with(RED_PREFIX)
60+}
61+
5262 /// What became of a local ref.
5363 #[derive(Clone, Copy, Debug, PartialEq, Eq)]
5464 pub(crate) enum Outcome {
@@ -505,11 +515,26 @@
505515 Err(err) => return Err(err),
506516 }
507517
518+ // How the hub verifies its branches, where the store holds what its
519+ // refs name: a changeset of a branch, which the branch brought.
520+ let mut verdicts: Vec<(String, ObjectId)> = Vec::new();
521+ for (name, id) in hub.refs.iter().filter(|(name, _)| is_verdict(name)) {
522+ if holds_changeset(store, id)? {
523+ verdicts.push((name.clone(), *id));
524+ }
525+ }
526+
508527 let mut history = repo.history();
509528 let mut decided = Vec::new();
510529 let description = format!("hub fetch {} from {}", link.repo, link.url);
511530 let result = store.transact_with(agent, |current| -> Result<_, Option<anyhow::Error>> {
512531 let mut updates = Vec::new();
532+ for (name, id) in &verdicts {
533+ let seen = remote_ref(name);
534+ if current.get(&seen) != Some(*id) {
535+ updates.push(RefUpdate::new(seen.clone(), current.get(&seen), Some(*id)));
536+ }
537+ }
513538 for (name, hub_head) in &carried {
514539 let before = current.get(name);
515540 let outcome = match skipped.get(name) {
@@ -542,11 +567,12 @@
542567 });
543568 }
544569 // A ref the hub no longer has, or that cannot be carried, has no
545- // place where it was seen.
570+ // place where it was seen, unless it says how a branch is verified.
546571 for (name, id) in current.iter() {
547572 if let Some(rest) = name.strip_prefix(REMOTE_PREFIX)
548573 && (!carried.iter().any(|(carried, _)| carried == rest)
549574 || skipped.contains_key(rest))
575+ && !verdicts.iter().any(|(verdict, _)| verdict == rest)
550576 {
551577 updates.push(RefUpdate::new(name, Some(id), None));
552578 }
@@ -726,6 +752,52 @@
726752 assert_eq!(outcome(&fourth, "behind"), Outcome::Diverged);
727753 }
728754
755+ #[test]
756+ fn the_hubs_green_and_red_are_recorded_where_they_were_seen() {
757+ let hub = FakeHub::new();
758+ let local = Fixture::linked(&hub);
759+ let root = ada_change(&hub.repo, None, &[("a.txt", "a\n")]);
760+ let two = ada_change(&hub.repo, Some(root), &[("b.txt", "b\n")]);
761+ set_ref(&hub.repo, "main", two);
762+ set_ref(&hub.repo, "braid/green/main", root);
763+ set_ref(&hub.repo, "braid/red/main", two);
764+ // One that names what the hub's branches do not bring is not
765+ // recorded: the store would not hold what it names.
766+ let elsewhere = ada_change(&hub.repo, None, &[("z.txt", "z\n")]);
767+ set_ref(&hub.repo, "braid/green/gone", elsewhere);
768+
769+ let first = fetch(&local.repo, &hub, &local.link, "tester", None).unwrap();
770+ let refs = local.repo.store().refs().unwrap();
771+ assert_eq!(refs.get("remote/hub/braid/green/main"), Some(root));
772+ assert_eq!(refs.get("remote/hub/braid/red/main"), Some(two));
773+ assert_eq!(refs.get("remote/hub/braid/green/gone"), None);
774+ // They are never carried, nor reported as branches.
775+ assert_eq!(refs.get("braid/green/main"), None);
776+ assert_eq!(refs.get("braid/red/main"), None);
777+ assert!(first.refs.iter().all(|r| !r.name.starts_with("braid/")));
778+ assert_eq!(first.hub_refs.get("braid/red/main"), Some(&two));
779+
780+ // Red cleared and green moved on the hub: the next fetch follows,
781+ // and nothing else moves.
782+ hub.repo
783+ .store()
784+ .transact("tester", "verify", |refs| {
785+ Ok::<_, std::convert::Infallible>(vec![
786+ RefUpdate::new("braid/red/main", refs.get("braid/red/main"), None),
787+ RefUpdate::new("braid/green/main", refs.get("braid/green/main"), Some(two)),
788+ ])
789+ })
790+ .unwrap();
791+ let second = fetch(&local.repo, &hub, &local.link, "tester", None).unwrap();
792+ assert!(second.operation.is_some());
793+ let refs = local.repo.store().refs().unwrap();
794+ assert_eq!(refs.get("remote/hub/braid/green/main"), Some(two));
795+ assert_eq!(refs.get("remote/hub/braid/red/main"), None);
796+ assert_eq!(refs.get("main"), Some(two));
797+ let third = fetch(&local.repo, &hub, &local.link, "tester", None).unwrap();
798+ assert_eq!(third.operation, None);
799+ }
800+
729801 #[test]
730802 fn tags_that_name_no_changeset_are_skipped() {
731803 let hub = FakeHub::new();
modified crates/cli/src/hub/land.rs +27 −0
@@ -522,6 +522,33 @@
522522 assert_eq!(s.hub.called("land"), lands);
523523 }
524524
525+ #[test]
526+ fn a_landing_reports_what_the_hub_says_of_the_branch() {
527+ let s = Setup::new();
528+ let ws = s.workspace("w1");
529+ let mine = edit_and_commit(&ws, "c.txt", "c\n");
530+ s.hub.verify.borrow_mut().landing = Some(braid_hubproto::verify::LandVerify {
531+ state: braid_hubproto::verify::STATE_RED.to_owned(),
532+ green: None,
533+ red: Some(mine),
534+ culprit: Some(mine),
535+ reverted: Vec::new(),
536+ });
537+ let landing = s.land(&ws).unwrap();
538+ let report = crate::work::Report::hub(landing.response.as_ref().unwrap());
539+ let json = report.json();
540+ assert_eq!(json["hub_verify"]["state"], "red");
541+ assert_eq!(json["hub_verify"]["culprit"], mine.to_hex());
542+ assert_eq!(json["hub_verify"]["reverted"], serde_json::json!([]));
543+ // A hub that says nothing of the branch: null.
544+ s.hub.verify.borrow_mut().landing = None;
545+ let two = edit_and_commit(&ws, "d.txt", "d\n");
546+ let landing = s.land(&ws).unwrap();
547+ let report = crate::work::Report::hub(landing.response.as_ref().unwrap());
548+ assert_eq!(report.head, Some(two));
549+ assert_eq!(report.json()["hub_verify"], serde_json::Value::Null);
550+ }
551+
525552 #[test]
526553 fn a_rebase_on_the_hub_brings_the_others_work_into_the_workspace() {
527554 let s = Setup::new();
modified crates/cli/src/hub/mod.rs +19 −3
@@ -155,7 +155,10 @@
155155 tag is created, and never moved. remote/hub/<ref> records where each of the
156156 hub's refs was seen, so `braid log remote/hub/main` shows the hub's main
157157 even when the local one was kept back. Tags that name no changeset are
158-skipped: the hub protocol carries changesets only.
158+skipped: the hub protocol carries changesets only. Of the hub's own refs,
159+only braid/green/<branch> and braid/red/<branch>, which say how the hub
160+verifies a branch, are recorded so (remote/hub/braid/green/<branch>), and
161+`braid status --json` gives them as hub_green and hub_red.
159162
160163 `braid land` and `braid update` fetch by themselves in a linked repository.
161164
@@ -177,10 +180,14 @@
177180 branch, and how the last sync ended: diverged means someone pushed to the
178181 mirror directly, and the hub's owner takes those commits in on the hub.
179182
183+A branch the hub verifies shows its green, the newest changeset with a pass
184+the hub accepts, and while the hub holds it red, its red (`braid hub verify
185+status` says more).
186+
180187 With --json it prints hub, repo, paths, login (null when not signed in),
181188 token (environment, file or null), mirror (url, last_sync, outcome and
182189 detail, or null), seq (the hub's op log sequence number) and branches, each
183-with name, local, hub and state.";
190+with name, local, hub, state, green and red (null when the hub has none).";
184191
185192 /// The long help of `hub whoami`.
186193 pub(crate) const WHOAMI_HELP: &str =
@@ -1216,6 +1223,8 @@
12161223 "local": hex(s.local),
12171224 "hub": hex(s.hub),
12181225 "state": s.state.code(),
1226+ "green": hex(s.green),
1227+ "red": hex(s.red),
12191228 })).collect::<Vec<_>>(),
12201229 }))?;
12211230 return Ok(ExitCode::SUCCESS);
@@ -1258,10 +1267,17 @@
12581267 }
12591268 }
12601269 for s in &states {
1261- let heads = match (s.local, s.hub) {
1270+ let mut heads = match (s.local, s.hub) {
12621271 (Some(here), Some(there)) if here == there => here.short(),
12631272 (here, there) => format!("here {}, hub {}", short(here), short(there)),
12641273 };
1274+ // How the hub verifies it, when it does.
1275+ if let Some(red) = s.red {
1276+ heads.push_str(&format!(", red at {}", red.short()));
1277+ }
1278+ if let Some(green) = s.green {
1279+ heads.push_str(&format!(", green at {}", green.short()));
1280+ }
12651281 println!(
12661282 " {:<24} {:<9} {heads}",
12671283 remote::shown(&s.name),
modified crates/cli/src/hub/request.rs +10 −1
@@ -59,6 +59,7 @@
5959 CONFLICTS, REFUSED, agent, body_text, exit_for, idempotency_key, print,
6060 };
6161 use super::transfer::store_stream;
62+use super::verify::land_note;
6263 use crate::work::count;
6364 use crate::{Cli, open_repo, print_json};
6465
@@ -203,7 +204,9 @@
203204 "
204205
205206 With --json it prints {request, land}: the request as it is now, and the
206-landing as `POST …/land` answers it."
207+landing as `POST …/land` answers it, with verify when the hub verifies the
208+base. While the hub holds the base red, braid also says so on standard
209+error, as `braid land` does."
207210 );
208211
209212 /// The long help of `hub request checkout`.
@@ -1897,6 +1900,12 @@
18971900 print(cli, &serde_json::to_value(&landed)?, || {
18981901 landed_text(target, number, &landed)
18991902 })?;
1903+ // The base, red on a hub that verifies it, as `braid land` says.
1904+ if let Some(verify) = &landed.land.verify
1905+ && let Some(note) = land_note(&landed.land.reference, verify, Some(target))
1906+ {
1907+ eprintln!("braid: {note}");
1908+ }
19001909 Ok(code)
19011910 }
19021911
modified crates/cli/src/hub/status.rs +18 −1
@@ -2,12 +2,13 @@
22 // Copyright (c) 2026 UtopiaIA
33
44 //! How each branch of a linked repository compares with the hub's, for
5-//! `braid hub status`.
5+//! `braid hub status`, and how the hub verifies it: its green and its red.
66
77 use std::collections::{BTreeMap, BTreeSet};
88
99 use anyhow::Result;
1010 use braid_format::{Kind, ObjectId, Objects};
11+use braid_hubproto::verify::{green_ref, red_ref};
1112 use braid_repo::Repo;
1213
1314 use super::fetch::remote_ref;
@@ -50,6 +51,11 @@
5051 pub(crate) hub: Option<ObjectId>,
5152 /// How they compare.
5253 pub(crate) state: State,
54+ /// The hub's green of the branch, when it verifies the branch: the
55+ /// newest changeset with a pass it accepts.
56+ pub(crate) green: Option<ObjectId>,
57+ /// The hub's red of the branch, while it holds the branch red.
58+ pub(crate) red: Option<ObjectId>,
5359 }
5460
5561 /// Compares every branch of `repo` and of the hub, whose refs are `hub`.
@@ -105,6 +111,8 @@
105111 local: here,
106112 hub: there,
107113 state,
114+ green: hub.get(&green_ref(name)).copied(),
115+ red: hub.get(&red_ref(name)).copied(),
108116 });
109117 }
110118 history.flush()?;
@@ -145,6 +153,9 @@
145153 ("moved", unknown),
146154 ("lost", unknown),
147155 ("tags/v1", two),
156+ // The hub verifies `behind`: green at root, red at two.
157+ ("braid/green/behind", root),
158+ ("braid/red/behind", two),
148159 ]
149160 .into_iter()
150161 .map(|(name, id)| (name.to_owned(), id))
@@ -164,5 +175,11 @@
164175 ("same", State::Same),
165176 ]
166177 );
178+ let verified: Vec<(&str, Option<ObjectId>, Option<ObjectId>)> = states
179+ .iter()
180+ .filter(|s| s.green.is_some() || s.red.is_some())
181+ .map(|s| (s.name.as_str(), s.green, s.red))
182+ .collect();
183+ assert_eq!(verified, [("behind", Some(root), Some(two))]);
167184 }
168185 }
modified crates/cli/src/hub/testing.rs +8 −2
@@ -19,7 +19,7 @@
1919 };
2020 use braid_hubproto::stream;
2121 use braid_hubproto::verify::{
22- self as verify, ReportPolicy, VerifyEvent, VerifyPolicy, VerifyReport, VerifyReset,
22+ self as verify, LandVerify, ReportPolicy, VerifyEvent, VerifyPolicy, VerifyReport, VerifyReset,
2323 VerifyStatus,
2424 };
2525 use braid_repo::Repo;
@@ -349,7 +349,10 @@
349349 agent,
350350 &committer,
351351 ) {
352- Ok(report) => Ok(response(&report)),
352+ Ok(report) => Ok(LandResponse {
353+ verify: self.verify.borrow().landing.clone(),
354+ ..response(&report)
355+ }),
353356 Err(braid_wc::Error::NotOnBranch { .. }) => Err(HubError::api(
354357 409,
355358 "not_on_branch",
@@ -412,6 +415,8 @@
412415 pub(crate) lose: usize,
413416 /// What every call answers instead, while it is set.
414417 pub(crate) refuse: Option<Refusal>,
418+ /// What the answers of landings say of the branch, as `verify`.
419+ pub(crate) landing: Option<LandVerify>,
415420 /// The answers given, by key: the same key gets the same answer.
416421 answers: HashMap<String, Value>,
417422 }
@@ -429,6 +434,7 @@
429434 verdicts: Vec::new(),
430435 lose: 0,
431436 refuse: None,
437+ landing: None,
432438 answers: HashMap::new(),
433439 }
434440 }
modified crates/cli/src/hub/verify.rs +61 −1
@@ -30,7 +30,7 @@
3030 use braid_hubproto::RepoPath;
3131 use braid_hubproto::names::is_owner;
3232 use braid_hubproto::verify::{
33- FEATURE, MAX_REPORTERS, MODE_OFF, MODE_REPORT, SOURCE_REPORT, STATE_OFF, STATE_RED,
33+ FEATURE, LandVerify, MAX_REPORTERS, MODE_OFF, MODE_REPORT, SOURCE_REPORT, STATE_OFF, STATE_RED,
3434 STATE_STUCK, VerifyEvents, VerifyPolicy, VerifyReport, VerifyReportAnswer, VerifyReset,
3535 VerifyStatus, is_git_commit, is_suite,
3636 };
@@ -833,6 +833,30 @@
833833 out.trim_end().to_owned()
834834 }
835835
836+/// What braid notes on standard error after a landing whose answer says
837+/// that `branch` is red: one line, or `None` when there is nothing to say.
838+/// `repo`, when given, is the repository to name with `-R` in the hint.
839+pub(crate) fn land_note(
840+ branch: &str,
841+ verify: &LandVerify,
842+ repo: Option<&RepoPath>,
843+) -> Option<String> {
844+ if !is_red(&verify.state) {
845+ return None;
846+ }
847+ let blame = match (verify.culprit, verify.red) {
848+ (Some(culprit), _) => format!(", culprit {}", culprit.short()),
849+ (None, Some(red)) => format!(" at {}, no culprit named", red.short()),
850+ (None, None) => String::new(),
851+ };
852+ let flag = repo.map_or_else(String::new, |repo| format!(" -R {repo}"));
853+ Some(format!(
854+ "note: {} is {} on the hub{blame}: `braid hub verify status{flag}` says more",
855+ shown(branch),
856+ shown(&verify.state)
857+ ))
858+}
859+
836860 #[cfg(test)]
837861 mod tests {
838862 use super::*;
@@ -1416,4 +1440,40 @@
14161440 Asked::Status { fail_on_red: true }
14171441 ));
14181442 }
1443+
1444+ #[test]
1445+ fn a_landing_on_a_red_branch_says_so() {
1446+ let id = ObjectId::hash(braid_format::Kind::Changeset, b"x");
1447+ let mut verify = LandVerify {
1448+ state: STATE_RED.into(),
1449+ green: None,
1450+ red: Some(id),
1451+ culprit: Some(id),
1452+ reverted: Vec::new(),
1453+ };
1454+ let note = land_note("main", &verify, None).unwrap();
1455+ assert_eq!(
1456+ note,
1457+ format!(
1458+ "note: main is red on the hub, culprit {}: `braid hub verify status` says more",
1459+ id.short()
1460+ )
1461+ );
1462+ verify.culprit = None;
1463+ verify.state = STATE_STUCK.into();
1464+ let note = land_note("main", &verify, Some(&path())).unwrap();
1465+ assert!(note.contains("is stuck on the hub at"), "{note}");
1466+ assert!(
1467+ note.ends_with("`braid hub verify status -R ada/demo` says more"),
1468+ "{note}"
1469+ );
1470+ for state in [STATE_GREEN, STATE_PENDING, "unknown", "later"] {
1471+ verify.state = state.into();
1472+ assert_eq!(land_note("main", &verify, None), None, "{state}");
1473+ }
1474+ // What the hub says is shown, never raw.
1475+ verify.state = STATE_RED.into();
1476+ let note = land_note("ma\u{1b}in", &verify, None).unwrap();
1477+ assert!(!note.contains('\u{1b}'), "{note}");
1478+ }
14191479 }
modified crates/cli/src/revert.rs +3 −0
@@ -160,6 +160,9 @@
160160 )?)
161161 };
162162 let code = report.as_ref().map_or(ExitCode::SUCCESS, Report::exit_code);
163+ if let Some(report) = &report {
164+ report.note_red();
165+ }
163166 if cli.json {
164167 print_json(&json!({
165168 "revert": change.to_hex(),
modified crates/cli/src/work.rs +38 −5
@@ -16,6 +16,7 @@
1616 use braid_engine::{Conflict, ConflictKind, HunkSide};
1717 use braid_format::{ChangeOp, EntryKind, ObjectId};
1818 use braid_hubproto::api::LandResponse;
19+use braid_hubproto::verify::LandVerify;
1920 use braid_repo::{Location, Repo};
2021 use braid_store::Refs;
2122 use braid_wc::{
@@ -69,6 +70,11 @@
6970 new change create on the branch after change create;
7071 otherwise null. It repeats the --repo, --agent and
7172 --workspace given on the command line
73+ hub_verify after a landing on a hub that verifies the branch, how
74+ the hub says it stands: {state, green, red, culprit,
75+ reverted}, as `braid hub verify --help` describes them;
76+ otherwise null. While it is red or stuck, braid also
77+ says so on standard error
7278
7379 Ids in JSON are full; text output shows their first 12 hex digits."
7480 };
@@ -86,6 +92,13 @@
8692 head the branch's head, or null when the branch does not exist
8793 green the newest changeset of the branch that passed `braid
8894 verify`, braid/green/<branch>, or null
95+ hub_green in a repository linked to a hub that verifies the
96+ branch, the hub's green as the last fetch saw it: the
97+ newest changeset of the branch with a pass the hub
98+ accepts; otherwise null
99+ hub_red the hub's red as the last fetch saw it: while the hub
100+ holds the branch red, the changeset it blames, or the
101+ first fail it cannot explain; otherwise null
89102 behind whether the branch has changesets the workspace does not
90103 behind_by how many: the changesets from the branch's head down to
91104 the one the workspace's own start from, along first
@@ -566,11 +579,10 @@
566579 })).collect::<Vec<_>>(),
567580 })
568581 });
569- let green = target
570- .repo
571- .store()
572- .refs()?
573- .get(&crate::verify::green_ref(&state.branch));
582+ let refs = target.repo.store().refs()?;
583+ let green = refs.get(&crate::verify::green_ref(&state.branch));
584+ // Where a fetch last saw the hub's own refs of the branch.
585+ let seen = |name: String| hex(refs.get(&hub::fetch::remote_ref(&name)));
574586 print_json(&json!({
575587 "workspace": workspace.name(),
576588 "path": workspace.dir().to_string_lossy(),
@@ -578,6 +590,8 @@
578590 "base": hex(state.base),
579591 "head": hex(report.head),
580592 "green": hex(green),
593+ "hub_green": seen(braid_hubproto::verify::green_ref(&state.branch)),
594+ "hub_red": seen(braid_hubproto::verify::red_ref(&state.branch)),
581595 "behind": report.behind(),
582596 "behind_by": report.behind_by,
583597 "clean": status.is_clean(),
@@ -790,6 +804,8 @@
790804 /// For a workspace: its base afterwards, and the paths of its working
791805 /// copy written or removed.
792806 workspace: Option<(Option<ObjectId>, Vec<String>)>,
807+ /// What a hub that verifies the branch says of it after the landing.
808+ hub_verify: Option<LandVerify>,
793809 }
794810
795811 impl Report {
@@ -814,6 +830,7 @@
814830 conflicts: conflicts.iter().map(conflict_json).collect(),
815831 next: None,
816832 workspace: None,
833+ hub_verify: None,
817834 }
818835 }
819836
@@ -838,6 +855,7 @@
838855 conflicts: response.conflicts.clone(),
839856 next: None,
840857 workspace: None,
858+ hub_verify: response.verify.clone(),
841859 }
842860 }
843861
@@ -858,6 +876,7 @@
858876 conflicts: Vec::new(),
859877 next: None,
860878 workspace: None,
879+ hub_verify: None,
861880 },
862881 };
863882 report.workspace = Some((
@@ -892,6 +911,7 @@
892911 report.base,
893912 report.updated_paths.iter().map(|p| show(p)).collect(),
894913 )),
914+ hub_verify: None,
895915 }
896916 }
897917
@@ -914,6 +934,7 @@
914934 "change": hex(self.change),
915935 "conflicts": self.conflicts,
916936 "next": self.next,
937+ "hub_verify": self.hub_verify,
917938 });
918939 if let Some((base, updated)) = &self.workspace {
919940 value["base"] = hex(*base);
@@ -922,6 +943,16 @@
922943 value
923944 }
924945
946+ /// Says on standard error, in one line, that the hub holds the branch
947+ /// red, when its answer says so.
948+ pub(crate) fn note_red(&self) {
949+ if let Some(verify) = &self.hub_verify
950+ && let Some(note) = hub::verify::land_note(&self.branch, verify, None)
951+ {
952+ eprintln!("braid: {note}");
953+ }
954+ }
955+
925956 pub(crate) fn exit_code(&self) -> ExitCode {
926957 if self.conflicted() {
927958 ExitCode::from(CONFLICTS)
@@ -1031,6 +1062,7 @@
10311062 } else {
10321063 report.print_landing(cli);
10331064 }
1065+ report.note_red();
10341066 Ok(report.exit_code())
10351067 }
10361068
@@ -1241,6 +1273,7 @@
12411273 crate::shell_word(&report.branch)
12421274 )));
12431275 }
1276+ report.note_red();
12441277 report.json()
12451278 }
12461279 None => Value::Null,
modified crates/cli/tests/hub.rs +24 −0
@@ -421,6 +421,30 @@
421421 assert!(out.status.success(), "{}", text(&out.stderr));
422422 }
423423
424+/// `braid status --json` gives the hub's green and red of the branch as a
425+/// fetch last recorded them, and null where none was.
426+#[test]
427+fn status_gives_the_hubs_green_and_red_as_last_seen() {
428+ let p = Place::new();
429+ let ws = p.workspace_with_a_commit("w1");
430+ let landed = json(&p.braid(&ws, &["land", "--local", "--json"], &[]));
431+ let head = landed["head"].as_str().unwrap().to_owned();
432+ let status = json(&p.braid(&ws, &["status", "--json"], &[]));
433+ assert_eq!(
434+ (&status["hub_green"], &status["hub_red"]),
435+ (&Value::Null, &Value::Null)
436+ );
437+ for name in ["remote/hub/braid/green/main", "remote/hub/braid/red/main"] {
438+ let out = p.braid(&p.root, &["ref", "set", name, &head], &[]);
439+ assert!(out.status.success(), "{}", text(&out.stderr));
440+ }
441+ let status = json(&p.braid(&ws, &["status", "--json"], &[]));
442+ assert_eq!(status["hub_green"], head.as_str());
443+ assert_eq!(status["hub_red"], head.as_str());
444+ // The local green of `braid verify` is another ref.
445+ assert_eq!(status["green"], Value::Null);
446+}
447+
424448 /// A request a stand-in hub read: its request line, its `Idempotency-Key`
425449 /// and its body.
426450 #[derive(Debug, Default, PartialEq, Eq)]
modified crates/cli/tests/workspaces.rs +3 −0
@@ -1083,6 +1083,7 @@
10831083 "conflicts",
10841084 "head",
10851085 "head_before",
1086+ "hub_verify",
10861087 "landed",
10871088 "merged_paths",
10881089 "next",
@@ -1126,6 +1127,8 @@
11261127 let landed = json(&ws, &["land"]);
11271128 assert_eq!(keys(&landed), fields);
11281129 assert_eq!(landed["outcome"], "fast-forward");
1130+ // No hub verifies a local landing.
1131+ assert_eq!(landed["hub_verify"], Value::Null);
11291132 assert_eq!(landed["head_before"], head.as_str());
11301133 assert_eq!(landed["head"], rebased.as_str());
11311134 assert_eq!(landed["base"], rebased.as_str());