(bc86c85) Attribute a command typed at the board to the person, not the variable, and bump to 0.33.5

WORKLANE_ACTOR is set once in the environment an agent runs in, which is
right for an agent and wrong for the board: a person who exports it where
their own shell picks it up, the obvious way to configure it for the agents
on that machine, then moved a ticket with ':' and the board recorded the
move as the agent's.

Nothing but the reader can type that line, so the prompt asks for
--actor-from-git's precedence without the flag. An explicit --actor still
wins, which is how the reader puts somebody else's name on their own
keystrokes, and a machine with no git user configured reads unknown rather
than falling back to the variable, for the reason the flag does.

The attribution is a parameter of dispatch rather than a field the prompt
writes into what clap parsed: rewriting the arguments would need an arm per
entry-writing command, and the command added after it would be attributed
to the agent until somebody noticed. no_handler_decides_its_own_attribution
reads src for a handler naming an Attribution of its own, which the
compiler cannot catch because it compiles.

The same command typed in a shell is unchanged, which is what keeps a board
several agents write to saying which of them wrote what.

Also closes a code fence in the skill that e26e589 left open, duplicating
the mv --actor example under it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ansho Rei
2026-09-15 16:23:24 +02:00
co-authored by Claude Opus 5
parent a885f81da5
commit 3e732535f8
10 changed files with 282 additions and 47 deletions
+51 -11
View File
@@ -611,7 +611,7 @@ fn check_dependents(worklane_dir: &Path, uuid: &str, title: &str, sink: &mut Sin
/// A status is a [`Status`] rather than a string, so an unknown one is clap's to refuse
/// and nothing here has to check. What is left is the order of the flow, which is
/// `Status::ALL`.
pub fn cmd_mv(args: &MvArgs, start: &Path, sink: &mut Sink) -> Result<()> {
pub fn cmd_mv(args: &MvArgs, start: &Path, by: Attribution, sink: &mut Sink) -> Result<()> {
let MvArgs {
ticket: ticket_id,
status: target,
@@ -758,7 +758,7 @@ pub fn cmd_mv(args: &MvArgs, start: &Path, sink: &mut Sink) -> Result<()> {
&parse_ticket_field(&resolved, "ID"),
Kind::Status,
&change(&current_status, target_status),
&resolve_actor(actor.as_deref(), *actor_from_git),
&resolve_actor(actor.as_deref(), *actor_from_git, by),
&reason,
)?;
@@ -778,6 +778,7 @@ pub fn cmd_comment(
actor: &Option<String>,
actor_from_git: bool,
start: &Path,
by: Attribution,
sink: &mut Sink,
) -> Result<()> {
if body.is_empty() {
@@ -797,7 +798,7 @@ pub fn cmd_comment(
&ticket_uuid,
Kind::Comment,
body,
&resolve_actor(actor.as_deref(), actor_from_git),
&resolve_actor(actor.as_deref(), actor_from_git, by),
"",
)?;
@@ -976,7 +977,7 @@ fn report_in(
Ok(())
}
pub fn cmd_set(args: &SetArgs, start: &Path, sink: &mut Sink) -> Result<()> {
pub fn cmd_set(args: &SetArgs, start: &Path, by: Attribution, sink: &mut Sink) -> Result<()> {
if let Some(field) = args.contested() {
let name = field.name();
return Err(anyhow!(
@@ -1058,7 +1059,7 @@ pub fn cmd_set(args: &SetArgs, start: &Path, sink: &mut Sink) -> Result<()> {
&parse_ticket_field(&original, "Tags"),
&parse_ticket_field(&content, "Tags"),
),
&resolve_actor(args.actor.as_deref(), args.actor_from_git),
&resolve_actor(args.actor.as_deref(), args.actor_from_git, by),
"",
)?;
}
@@ -1089,7 +1090,7 @@ pub fn cmd_set(args: &SetArgs, start: &Path, sink: &mut Sink) -> Result<()> {
/// for a ticket it is filing, which is a default for something new; an owner taken away
/// says nobody owns this, and putting the person running the command there instead would
/// hand them a ticket they were giving up.
pub fn cmd_chown(args: &ChownArgs, start: &Path, sink: &mut Sink) -> Result<()> {
pub fn cmd_chown(args: &ChownArgs, start: &Path, by: Attribution, sink: &mut Sink) -> Result<()> {
let (ticket_id, user) = args.target().ok_or_else(|| {
anyhow!("chown takes a user and a ticket, or --clear with the ticket alone")
})?;
@@ -1117,7 +1118,7 @@ pub fn cmd_chown(args: &ChownArgs, start: &Path, sink: &mut Sink) -> Result<()>
&parse_ticket_field(&original, "Owner"),
&parse_ticket_field(&content, "Owner"),
),
&resolve_actor(args.actor.as_deref(), args.actor_from_git),
&resolve_actor(args.actor.as_deref(), args.actor_from_git, by),
"",
)?;
@@ -1129,7 +1130,7 @@ pub fn cmd_chown(args: &ChownArgs, start: &Path, sink: &mut Sink) -> Result<()>
Ok(())
}
pub fn cmd_append(args: &AppendArgs, start: &Path, sink: &mut Sink) -> Result<()> {
pub fn cmd_append(args: &AppendArgs, start: &Path, by: Attribution, sink: &mut Sink) -> Result<()> {
let worklane_dir = find_worklane_dir(start)?;
let (status, title, original) = resolve_ticket(&args.ticket, &worklane_dir)?;
let uuid = parse_ticket_field(&original, "ID");
@@ -1180,7 +1181,7 @@ pub fn cmd_append(args: &AppendArgs, start: &Path, sink: &mut Sink) -> Result<()
&parse_ticket_field(&original, "Tags"),
&parse_ticket_field(&content, "Tags"),
),
&resolve_actor(args.actor.as_deref(), args.actor_from_git),
&resolve_actor(args.actor.as_deref(), args.actor_from_git, by),
"",
)?;
}
@@ -1885,6 +1886,7 @@ pub fn cmd_assign(
actor: &Option<String>,
actor_from_git: bool,
start: &Path,
by: Attribution,
sink: &mut Sink,
) -> Result<()> {
let worklane_dir = find_worklane_dir(start)?;
@@ -1923,7 +1925,7 @@ pub fn cmd_assign(
&uuid,
Kind::Campaign,
&change(&before, campaign.name()),
&resolve_actor(actor.as_deref(), actor_from_git),
&resolve_actor(actor.as_deref(), actor_from_git, by),
"",
)?;
@@ -2387,7 +2389,7 @@ mod sink_tests {
let mut sink = Sink::buffer(&mut buf);
// A dangling uuid is a bookkeeping fault rather than a dependency, so the
// move happens and the warning is the whole of what is said about it.
cmd_mv(&args, &root, &mut sink).unwrap();
cmd_mv(&args, &root, Attribution::Session, &mut sink).unwrap();
sink.warnings()
};
@@ -2475,6 +2477,44 @@ mod sink_tests {
);
}
/// A handler takes the attribution `dispatch` was given and never decides one of its
/// own.
///
/// That parameter is what makes a command added tomorrow attributed correctly from
/// both callers at once. A handler naming `Attribution::Session` outright would be
/// the person's own keystrokes recorded as the agent's again, and it would compile,
/// so the compiler cannot be the thing that catches it.
#[test]
fn no_handler_decides_its_own_attribution() {
let mut deciding: Vec<String> = Vec::new();
for entry in fs::read_dir(concat!(env!("CARGO_MANIFEST_DIR"), "/src")).unwrap() {
let path = entry.unwrap().path();
if path.extension().and_then(|ext| ext.to_str()) != Some("rs") {
continue;
}
let source = fs::read_to_string(&path).unwrap();
let name = path.file_name().unwrap().to_string_lossy().to_string();
deciding.extend(
body_of(&source)
.map(str::trim)
.filter(|line| !line.starts_with("//"))
// The definition itself, which is where the parameter is named.
.filter(|line| {
line.contains("resolve_actor(") && !line.contains("fn resolve_actor(")
})
.filter(|line| !line.ends_with(", by)") && !line.ends_with(", by),"))
.map(|line| format!("{name}: {line}")),
);
}
assert!(
deciding.is_empty(),
"a handler passes the attribution it was dispatched with, `by`, so a line \
typed at the board stays the person's:\n{deciding:#?}"
);
}
/// A file's lines up to its test module, which in this crate is the only inline
/// `mod` at column 0. A file's own assertions are allowed to name a macro the file
/// may not call, this test's own body first among them.
+15 -8
View File
@@ -62,7 +62,9 @@ fn main() -> Result<()> {
// it opens the board above the working directory.
None => run_tui(&[], &start),
Some(Command::Tui { paths }) => run_tui(&paths, &start),
Some(command) => dispatch(&command, &start, &mut sink),
// Every call `main` dispatches came from a shell or a script, so the session's
// own chain answers: `WORKLANE_ACTOR` first, which is what it is set for.
Some(command) => dispatch(&command, &start, Attribution::Session, &mut sink),
};
// The board (and every handler) own their own writing, so flush what the last one
@@ -84,7 +86,12 @@ fn main() -> Result<()> {
/// A command added to [`Command`] therefore lands here once and is runnable from both.
/// The match is exhaustive for exactly that reason: there is no `_` arm for a new verb to
/// fall into and do nothing.
pub fn dispatch(command: &Command, start: &Path, sink: &mut Sink) -> Result<()> {
///
/// `by` is who the call is being made by, and it is a parameter here rather than a field
/// the prompt writes into the parsed arguments: an entry-writing command added tomorrow
/// is attributed correctly from both callers without an arm anywhere rewriting what clap
/// produced. `main` is the session, the prompt is the person at the board.
pub fn dispatch(command: &Command, start: &Path, by: Attribution, sink: &mut Sink) -> Result<()> {
match command {
// Reachable only from the prompt, since `main` takes this arm before it gets
// here. A board is not something a board can open.
@@ -99,11 +106,11 @@ pub fn dispatch(command: &Command, start: &Path, sink: &mut Sink) -> Result<()>
let worklane_dir = find_worklane_dir(start)?;
cmd_show(id, &worklane_dir, sink)
}
Command::Mv(args) => cmd_mv(args, start, sink),
Command::Set(args) => cmd_set(args, start, sink),
Command::Append(args) => cmd_append(args, start, sink),
Command::Mv(args) => cmd_mv(args, start, by, sink),
Command::Set(args) => cmd_set(args, start, by, sink),
Command::Append(args) => cmd_append(args, start, by, sink),
Command::Relate(args) => cmd_relate(args, start, sink),
Command::Chown(args) => cmd_chown(args, start, sink),
Command::Chown(args) => cmd_chown(args, start, by, sink),
Command::Check(args) => cmd_check(args, true, start, sink),
Command::Uncheck(args) => cmd_check(args, false, start, sink),
Command::Comment {
@@ -111,7 +118,7 @@ pub fn dispatch(command: &Command, start: &Path, sink: &mut Sink) -> Result<()>
body,
actor,
actor_from_git,
} => cmd_comment(ticket, body, actor, *actor_from_git, start, sink),
} => cmd_comment(ticket, body, actor, *actor_from_git, start, by, sink),
Command::Campaign { command } => match command {
CampaignCommand::Add(args) => cmd_campaign_add(args, start, sink),
CampaignCommand::Ls { ids } => {
@@ -130,7 +137,7 @@ pub fn dispatch(command: &Command, start: &Path, sink: &mut Sink) -> Result<()>
ticket,
actor,
actor_from_git,
} => cmd_assign(campaign, ticket, actor, *actor_from_git, start, sink),
} => cmd_assign(campaign, ticket, actor, *actor_from_git, start, by, sink),
// The bare form and `ls` are one arm: `worklane tags` was the listing before the
// group existed and the fish completion still calls it that way, so the two
// spellings cannot be allowed to drift into two behaviours.
+60 -4
View File
@@ -2744,7 +2744,12 @@ impl Board {
let mut buffer: Vec<u8> = Vec::new();
let (outcome, warned) = {
let mut sink = Sink::buffer(&mut buffer);
let outcome = crate::dispatch(command, &root, &mut sink).and_then(|()| sink.flush());
// The person's, not the session's. Nothing but the reader can type this line,
// so `WORKLANE_ACTOR` — set where the agents on this machine pick it up, and
// inherited by the shell that opened the board — does not describe whoever
// pressed enter.
let outcome = crate::dispatch(command, &root, Attribution::Person, &mut sink)
.and_then(|()| sink.flush());
// Read on both outcomes and reported on both: a `mv` that warns about a
// dangling blocker and is then refused by a real one wrote the warning
// first, and dropping it there would lose the half that says why the
@@ -8422,6 +8427,57 @@ approach";
);
}
/// An entry the prompt writes is the reader's own, whatever `WORKLANE_ACTOR` says.
///
/// The variable is set in the environment an agent runs in, and a person configuring
/// it for the agents on their machine exports it where their own shell picks it up
/// too — so the shell that opened this board carries it, and without the attribution
/// parameter this entry would name the agent.
///
/// Read against `get_git_user` rather than a literal, since the name depends on the
/// machine the suite runs on. With no git user configured there is nobody to name and
/// the entry reads `unknown`, which is the same rule and not a fallback to the
/// variable.
#[test]
fn an_entry_written_from_the_prompt_names_the_person() {
let (root, mut board) = runnable();
let dir = root.join(".worklane");
run_line(&mut board, "comment 1111111 \"typed at the board\"");
assert!(board.prompt.is_none(), "the line was refused: {:?}", refused(&board));
let log = read_history(&dir, "11111111-0000-4000-8000-000000000000").unwrap();
let entry = log
.iter()
.find(|entry| entry.body == "typed at the board")
.expect("the comment was not written");
assert_eq!(
entry.author,
get_git_user().unwrap_or_else(|| UNKNOWN_ACTOR.to_string()),
"the board attributed the reader's own line to somebody else"
);
// And `--actor` still wins, which is how the reader puts somebody else's name on
// their own keystrokes.
run_line(&mut board, "comment 1111111 \"for alice\" --actor alice");
let log = read_history(&dir, "11111111-0000-4000-8000-000000000000").unwrap();
let entry = log
.iter()
.find(|entry| entry.body == "for alice")
.expect("the second comment was not written");
assert_eq!(entry.author, "alice", "the flag lost to the board's own attribution");
// The two flags together are clap's refusal, reached here because the prompt
// parses against the same definition the shell does rather than a grammar of its
// own. A line it refuses keeps the prompt open with the line intact.
run_line(&mut board, "comment 1111111 both --actor alice --actor-from-git");
assert!(
refused(&board).is_some_and(|said| said.contains("cannot be used with")),
"the contradictory pair was taken: {:?}",
refused(&board)
);
}
/// What the handler said is what the board reports, word for word: those messages are
/// already written for a person, and a second set kept on the board would go stale the
/// first time one of them changed.
@@ -8441,7 +8497,7 @@ approach";
.unwrap();
{
let mut sink = Sink::buffer(&mut buffer);
crate::dispatch(&command, &root, &mut sink).unwrap();
crate::dispatch(&command, &root, Attribution::Session, &mut sink).unwrap();
sink.flush().unwrap();
}
let said = String::from_utf8(buffer).unwrap().trim_end().to_string();
@@ -8786,8 +8842,8 @@ approach";
// What the board calls instead.
assert!(
here.contains("crate::dispatch(command, &root, &mut sink)"),
"the board does not go through the table"
here.contains("crate::dispatch(command, &root, Attribution::Person, &mut sink)"),
"the board does not go through the table, or it does not attribute to the person"
);
}
+144 -19
View File
@@ -649,6 +649,32 @@ pub const ACTOR_ENV: &str = "WORKLANE_ACTOR";
/// The author written when nothing names one.
pub const UNKNOWN_ACTOR: &str = "unknown";
/// Who is making the call, which decides whether [`ACTOR_ENV`] describes them.
///
/// The variable is set once in the environment an agent runs in, so every call that agent
/// makes carries its name, which is exactly what a board several agents write to needs. A
/// line typed at the command prompt is not one of those calls: nothing but the reader can
/// type it, and a person who exported the variable where their own shell picks it up —
/// the obvious way to configure it for the agents on that machine — would otherwise watch
/// their own `mv` recorded as the agent's.
///
/// So the board attributes to the person, which is `--actor-from-git`'s precedence
/// applied by default rather than asked for. It is a parameter of [`dispatch`] and not a
/// field on the parsed arguments, so a command that grows an `--actor` tomorrow is
/// attributed correctly from both callers without an arm anywhere rewriting what clap
/// produced.
///
/// [`dispatch`]: crate::dispatch
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Attribution {
/// The process's own session: the variable, then the git user. Every call from a
/// shell or a script, which is every call `main` dispatches.
Session,
/// The person at the board: the git user, and [`UNKNOWN_ACTOR`] where none is
/// configured, never the variable.
Person,
}
/// The actor for the whole run, from the variable alone.
///
/// Split out from the caching wrapper for the reason `colors_wanted` is: a threaded test
@@ -675,11 +701,18 @@ fn session_actor(env: Option<&str>) -> Option<String> {
/// has nobody to name, which reads [`UNKNOWN_ACTOR`] rather than quietly attributing
/// back to the agent. Without it, today's chain: the variable, then the git user.
///
/// [`Attribution::Person`] asks for that same lift without the flag, because a line typed
/// at the board is the reader's own action and there is nothing to say. The two are one
/// branch rather than two: a `--actor-from-git` typed at the prompt asks for what the
/// prompt does anyway, and an explicit `--actor` outranks both, which is how the reader
/// puts somebody else's name on their own keystrokes.
///
/// `git_user` is a closure in both branches so the subprocess it costs is not run when
/// something ahead of it already answered.
fn entry_actor(
flag: Option<&str>,
from_git: bool,
by: Attribution,
session: Option<&str>,
git_user: impl FnOnce() -> Option<String>,
) -> String {
@@ -687,7 +720,7 @@ fn entry_actor(
return name.to_string();
}
if from_git {
if from_git || matches!(by, Attribution::Person) {
return git_user().unwrap_or_else(|| UNKNOWN_ACTOR.to_string());
}
@@ -698,13 +731,14 @@ fn entry_actor(
git_user().unwrap_or_else(|| UNKNOWN_ACTOR.to_string())
}
/// Who to attribute an entry to, from the flags the call carried.
/// Who to attribute an entry to, from the flags the call carried and who is calling.
///
/// Precedence: flag, then — unless `from_git` lifted it — `WORKLANE_ACTOR`, then the git
/// user, then `unknown`. Every entry the CLI writes goes through here, so a board
/// several agents write to says which of them wrote what instead of attributing all of
/// it to one human.
pub fn resolve_actor(flag: Option<&str>, from_git: bool) -> String {
/// Precedence: flag, then — unless `from_git` or [`Attribution::Person`] lifted it —
/// `WORKLANE_ACTOR`, then the git user, then `unknown`. Every entry the CLI writes goes
/// through here, so a board several agents write to says which of them wrote what
/// instead of attributing all of it to one human, and a line the person typed at the
/// board is theirs rather than whichever agent's variable their shell exports.
pub fn resolve_actor(flag: Option<&str>, from_git: bool, by: Attribution) -> String {
// Each half is decided once, the way should_use_colors is: neither input can change
// mid-run, and the git user costs a subprocess. They are two caches rather than one,
// because baking the git user into the session's answer would leave `--actor-from-git`
@@ -718,7 +752,7 @@ pub fn resolve_actor(flag: Option<&str>, from_git: bool) -> String {
session_actor(env.as_deref())
});
entry_actor(flag, from_git, session.as_deref(), || {
entry_actor(flag, from_git, by, session.as_deref(), || {
GIT_USER.get_or_init(get_git_user).clone()
})
}
@@ -4015,14 +4049,17 @@ mod tests {
fn the_variable_names_the_actor() {
let session = session_actor(Some("claude"));
let git_user = || Some("Ansho Rei".to_string());
assert_eq!(entry_actor(None, false, session.as_deref(), git_user), "claude");
assert_eq!(
entry_actor(None, false, Attribution::Session, session.as_deref(), git_user),
"claude"
);
}
#[test]
fn the_flag_overrides_the_variable() {
let session = session_actor(Some("claude"));
assert_eq!(
entry_actor(Some("opencode"), false, session.as_deref(), || None),
entry_actor(Some("opencode"), false, Attribution::Session, session.as_deref(), || None),
"opencode"
);
}
@@ -4032,7 +4069,13 @@ mod tests {
fn the_git_user_is_the_fallback() {
let git_user = || Some("Ansho Rei".to_string());
assert_eq!(
entry_actor(None, false, session_actor(None).as_deref(), git_user),
entry_actor(
None,
false,
Attribution::Session,
session_actor(None).as_deref(),
git_user
),
"Ansho Rei"
);
}
@@ -4045,7 +4088,10 @@ mod tests {
let git_user = || Some("Ansho Rei".to_string());
for raw in ["", " "] {
let session = session_actor(Some(raw));
assert_eq!(entry_actor(None, false, session.as_deref(), git_user), "Ansho Rei");
assert_eq!(
entry_actor(None, false, Attribution::Session, session.as_deref(), git_user),
"Ansho Rei"
);
}
}
@@ -4053,9 +4099,15 @@ mod tests {
#[test]
fn nothing_at_all_is_unknown() {
let session = session_actor(None);
assert_eq!(entry_actor(None, false, session.as_deref(), || None), UNKNOWN_ACTOR);
assert_eq!(
entry_actor(None, false, Attribution::Session, session.as_deref(), || None),
UNKNOWN_ACTOR
);
// An empty flag falls through rather than writing a blank author
assert_eq!(entry_actor(Some(""), false, None, || None), UNKNOWN_ACTOR);
assert_eq!(
entry_actor(Some(""), false, Attribution::Session, None, || None),
UNKNOWN_ACTOR
);
}
/// Free text, validated against nothing, the way the `chown` user is.
@@ -4063,7 +4115,7 @@ mod tests {
fn an_actor_is_free_text() {
let session = session_actor(Some("claude-code, session 3 (opus)"));
assert_eq!(
entry_actor(None, false, session.as_deref(), || None),
entry_actor(None, false, Attribution::Session, session.as_deref(), || None),
"claude-code, session 3 (opus)"
);
}
@@ -4074,7 +4126,10 @@ mod tests {
fn from_git_lifts_the_git_user_over_the_variable() {
let session = session_actor(Some("claude"));
let git_user = || Some("Ansho Rei".to_string());
assert_eq!(entry_actor(None, true, session.as_deref(), git_user), "Ansho Rei");
assert_eq!(
entry_actor(None, true, Attribution::Session, session.as_deref(), git_user),
"Ansho Rei"
);
}
/// An explicit `--actor` still wins outright beside the lift: it names somebody
@@ -4084,7 +4139,7 @@ mod tests {
let session = session_actor(Some("claude"));
let git_user = || Some("Ansho Rei".to_string());
assert_eq!(
entry_actor(Some("opencode"), true, session.as_deref(), git_user),
entry_actor(Some("opencode"), true, Attribution::Session, session.as_deref(), git_user),
"opencode"
);
}
@@ -4094,7 +4149,10 @@ mod tests {
#[test]
fn from_git_with_no_git_user_is_unknown_not_the_variable() {
let session = session_actor(Some("claude"));
assert_eq!(entry_actor(None, true, session.as_deref(), || None), UNKNOWN_ACTOR);
assert_eq!(
entry_actor(None, true, Attribution::Session, session.as_deref(), || None),
UNKNOWN_ACTOR
);
}
/// An empty variable still counts as unset with the lift on, which here means the
@@ -4103,11 +4161,78 @@ mod tests {
fn from_git_leaves_the_empty_variable_unset() {
let git_user = || Some("Ansho Rei".to_string());
assert_eq!(
entry_actor(None, true, session_actor(Some("")).as_deref(), git_user),
entry_actor(
None,
true,
Attribution::Session,
session_actor(Some("")).as_deref(),
git_user
),
"Ansho Rei"
);
}
/// The board's own case, and the reason this parameter exists: the person who
/// exported `WORKLANE_ACTOR` for the agents on their machine types a command at the
/// prompt, and the entry is theirs. No flag was given and none should have to be.
#[test]
fn a_line_typed_at_the_board_is_the_persons() {
let session = session_actor(Some("claude"));
let git_user = || Some("Ansho Rei".to_string());
assert_eq!(
entry_actor(None, false, Attribution::Person, session.as_deref(), git_user),
"Ansho Rei"
);
}
/// `--actor` still wins there, which is how the reader puts somebody else's name on
/// their own keystrokes.
#[test]
fn the_flag_wins_over_the_board_too() {
let session = session_actor(Some("claude"));
let git_user = || Some("Ansho Rei".to_string());
assert_eq!(
entry_actor(Some("alice"), false, Attribution::Person, session.as_deref(), git_user),
"alice"
);
}
/// And the lift is not a fallback here either. A machine with no git user configured
/// has nobody to name, and writing the variable's value would be the agent's name on
/// the person's move, which is the whole thing this avoids.
#[test]
fn the_board_with_no_git_user_is_unknown_not_the_variable() {
let session = session_actor(Some("claude"));
assert_eq!(
entry_actor(None, false, Attribution::Person, session.as_deref(), || None),
UNKNOWN_ACTOR
);
}
/// `--actor-from-git` typed at the prompt asks for what the prompt does anyway, so
/// the two together are the one lift rather than two that could disagree.
#[test]
fn from_git_at_the_board_is_the_same_lift() {
let session = session_actor(Some("claude"));
let git_user = || Some("Ansho Rei".to_string());
assert_eq!(
entry_actor(None, true, Attribution::Person, session.as_deref(), git_user),
"Ansho Rei"
);
}
/// The session's own chain is untouched: the same command typed in a shell is still
/// the variable's, which is what keeps a board several agents write to legible.
#[test]
fn the_session_keeps_the_variable_over_the_git_user() {
let session = session_actor(Some("claude"));
let git_user = || Some("Ansho Rei".to_string());
assert_eq!(
entry_actor(None, false, Attribution::Session, session.as_deref(), git_user),
"claude"
);
}
#[test]
fn unset_values_are_dimmed_and_set_ones_are_not() {
// Both paths, now that the colour decision is a parameter: with colour off the