feat(claw): provision the workspace git identity at boot

Every forge thread works in a per-thread workspace, and implementer
turns end in commits. git commit refuses to run without user.name and
user.email, and a fresh workspace carries no gitconfig: the first
commit on a fresh image fails, or succeeds with whatever the agent
improvised. The agent commits as itself — its own name and address,
never the user's, never inferred from whatever accounts happen to
exist.

The identity store gains an email field beside the name, so what
onboarding collects with identity_set and the Agent · General page
edits is what commits carry. The config gains an optional git
section, an operator's override. Each field resolves independently:
config, then identity, then defaults (claw, claw@hostname).

The resolved pair is written into the daemon user's global git config
at boot, in both run shapes — a cron pass commits too. The write is
guarded: the settings store remembers the last pair the daemon wrote,
and boot rewrites a field only when the config still holds that pair
or nothing. A value anyone else set wins outright; the daemon is a
tenant of its user's machine, not the owner of its git config.

Provisioning runs from the binary's boot, not daemon assembly, so the
tests that build daemons never touch a real gitconfig. An ssh sandbox
runs git on another host and stays unprovisioned — a later story.

The web UI gains an Email row on Agent · General; the phone's wire
model gains the optional field.
This commit is contained in:
vhaudiquet committed 2026-11-22 11:53:15 +01:00
1 parent 6a81dfa466
commit 1b85cd8937
17 files changed
+598 -13

No files matched your search

+2 -1
View File
@@ -8,7 +8,8 @@ questions, spread across turns.
Write SOUL.md (your name, tone, purpose) and USER.md (who the user
is) with the bootstrap_save tool as facts arrive; incrementally is
fine. Set what you learn about your own presentation with the
identity_set tool as well — your name, a mark or initials, a tagline.
identity_set tool as well — your name, a mark or initials, a tagline, an
email to commit as.
An avatar only if the user hands you an image file; they can also
upload one in the web interface's settings, and saying so beats
hunting one down. Never invent facts the user did not give.
+52
View File
@@ -182,6 +182,26 @@ pub struct ClawConfig {
/// `rhema-sandboxd` over HTTP. The settings store owns the live
/// choice; this seeds it at boot, before the first settings write.
pub sandbox: Option<crate::sandbox::SandboxChoice>,
/// The git identity the daemon writes into its user's global git
/// config at boot, so workspace commits carry the agent as author.
/// A field set here wins over the agent's identity (what
/// onboarding and the settings page write); both win over
/// defaults. See [`crate::git_identity`].
pub git: Option<GitIdentity>,
}
/// One git identity as the config states it: both fields optional, a
/// set field winning over the identity store, an unset one falling
/// through.
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(default, rename_all = "snake_case", deny_unknown_fields)]
pub struct GitIdentity {
/// The commit author name.
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
/// The commit author address.
#[serde(skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
}
impl ClawConfig {
@@ -210,6 +230,7 @@ impl Default for ClawConfig {
ingest_token: None,
transcript: None,
sandbox: None,
git: None,
disabled_mcp_servers: std::collections::BTreeSet::new(),
}
}
@@ -444,6 +465,9 @@ sandbox:
kind: http
url: https://box.example:7600
token: sandbox-secret
git:
name: Bot
email: bot@example.net
";
let config: ClawConfig = serde_yaml::from_str(raw).expect("parses");
assert_eq!(config.poll_interval_secs, 30);
@@ -464,6 +488,9 @@ sandbox:
assert_eq!(sandbox.kind, crate::sandbox::SandboxKind::Http);
assert_eq!(sandbox.url.as_deref(), Some("https://box.example:7600"));
assert_eq!(sandbox.token.as_deref(), Some("sandbox-secret"));
let git = config.git.expect("the git identity parses");
assert_eq!(git.name.as_deref(), Some("Bot"));
assert_eq!(git.email.as_deref(), Some("bot@example.net"));
let config: ClawConfig = serde_yaml::from_str(
"sandbox:\n kind: ssh\n host: me@box.example\n workspace: /srv/claw\n",
@@ -524,6 +551,31 @@ sandbox:
assert!(valid.validate().is_ok(), "a bare login is all ssh needs");
}
#[test]
fn the_git_section_rejects_a_typo_and_carries_partial_identity() {
let err = serde_yaml::from_str::<ClawConfig>(
"git:
nmae: Bot
",
)
.expect_err("a typo inside the section must not read as its default");
assert!(
err.to_string().contains("nmae"),
"the error names the key: {err}"
);
// One field alone is legal: the other falls through to the
// identity store, then defaults.
let config: ClawConfig = serde_yaml::from_str(
"git:
email: bot@example.net
",
)
.expect("parses");
let git = config.git.expect("the section parses");
assert_eq!(git.email.as_deref(), Some("bot@example.net"));
assert_eq!(git.name, None);
}
#[test]
fn an_unknown_key_is_rejected_and_named() {
let err = serde_yaml::from_str::<ClawConfig>("listne: 127.0.0.1:7799\n")
+1 -1
View File
@@ -213,7 +213,7 @@ fn bound(raw: &str) -> String {
/// The hostname: `/etc/hostname`'s first line, else the `hostname`
/// command, else a stand-in — the file is not portable and the command
/// is not guaranteed, so absence is a report line.
fn hostname() -> String {
pub(crate) fn hostname() -> String {
if let Ok(raw) = std::fs::read_to_string("/etc/hostname") {
let name = bound(&raw);
if !name.is_empty() {
+459
View File
@@ -0,0 +1,459 @@
//! The workspace git identity: `user.name` and `user.email` in the
//! daemon user's global git config, written at boot so every commit a
//! workspace makes carries the agent as its author — before any
//! conversation happened, on a machine nobody onboarded.
//!
//! Like the environment report this is deterministic boot code, and
//! like every boot probe its failure is one log line, never a failed
//! boot. Each field resolves from three sources, first set wins: the
//! config file's `git` section (the operator's choice), the agent's
//! own presentation identity (`identity.name`, `identity.email` —
//! what onboarding and the settings page write), then defaults. The
//! values land in the git config the daemon user's `git` reads, so
//! thread workspaces, chat scratch repos, and anything the agent
//! inits itself all inherit them.
//!
//! The write is guarded. The settings store remembers the last pair
//! the daemon wrote; boot rewrites a field only when the config file
//! still holds that pair, or nothing at all. A value anyone else set
//! wins outright — the daemon is a tenant of its user's machine, not
//! the owner of its git config. An ssh sandbox runs git on another
//! host, so it stays out of scope here: those workspaces remain
//! unprovisioned until a later story pushes the values remotely.
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::sync::Arc;
use std::time::{Duration, Instant};
use crate::config::{ClawConfig, GitIdentity};
use crate::identity::{AgentIdentity, IdentityStore};
use crate::settings::SettingsStore;
/// The fallback author name, when the config and the identity are
/// both silent. Lowercase on purpose: a stand-in, not a persona.
pub const DEFAULT_NAME: &str = "claw";
/// The settings keys recording the last pair the daemon wrote. The
/// guard reads them back on every boot; a mismatch means the field
/// was hand-edited and is left alone.
const WRITTEN_NAME: &str = "git_identity_written_name";
const WRITTEN_EMAIL: &str = "git_identity_written_email";
/// The per-call budget: a local `git config` is a file operation; the
/// budget only bounds a wedged `git`, like any other boot probe.
const GIT_BUDGET: Duration = Duration::from_secs(2);
/// One resolved field: the value and where it came from, for the boot
/// log line.
pub struct ResolvedField {
/// The resolved value, ready for the config file.
pub value: String,
/// Where it came from: `config`, `identity`, or `default`, for
/// the boot log line.
pub source: &'static str,
}
/// Resolves both fields: config, then identity, then defaults. The
/// fields resolve independently — a config name beside an identity
/// email is a legal pair.
pub fn resolve(
git: Option<&GitIdentity>,
identity: &AgentIdentity,
hostname: &str,
) -> (ResolvedField, ResolvedField) {
let field = |configured: Option<String>, presented: Option<String>, default: String| {
if let Some(value) = configured {
ResolvedField {
source: "config",
value,
}
} else if let Some(value) = presented {
ResolvedField {
source: "identity",
value,
}
} else {
ResolvedField {
source: "default",
value: default,
}
}
};
let name = field(
git.and_then(|git| git.name.clone()),
identity.name.clone(),
DEFAULT_NAME.to_owned(),
);
let email = field(
git.and_then(|git| git.email.clone()),
identity.email.clone(),
format!("{}@{}", DEFAULT_NAME, hostname),
);
(name, email)
}
/// The boot entry point: opens the stores the daemon built, resolves,
/// provisions, and returns the log line. Nothing here is fatal — every
/// failure becomes the line the caller prints.
pub fn boot(config: &ClawConfig) -> String {
let outcome = (|| -> Result<String, String> {
let file = global_file().ok_or("no home directory known, nowhere to write")?;
let db = config.db_path().map_err(|err| err.to_string())?;
let settings = Arc::new(SettingsStore::open(&db).map_err(|err| err.to_string())?);
let dir = db
.parent()
.ok_or("the database has no parent directory")?
.join("identity");
let who = IdentityStore::new(settings.clone(), dir)
.get()
.map_err(|err| err.to_string())?;
Ok(provision_at(&file, config.git.as_ref(), &who, &settings))
})();
outcome.unwrap_or_else(|reason| format!("git identity not provisioned: {reason}"))
}
/// The global git config the daemon user's `git` reads: the
/// `GIT_CONFIG_GLOBAL` override when set (git's own precedence), else
/// `.gitconfig` in the home the family's XDG discovery resolves.
pub fn global_file() -> Option<PathBuf> {
if let Ok(path) = std::env::var("GIT_CONFIG_GLOBAL")
&& !path.trim().is_empty()
{
return Some(PathBuf::from(path));
}
rhema_config::Home::discover()
.ok()
.map(|home| home.home.join(".gitconfig"))
}
/// Provisions both fields against one git config file, and returns the
/// log line. The guard is per field: a hand-edited name beside an
/// email the daemon wrote is updated on the email side and left alone
/// on the name side.
pub fn provision_at(
file: &Path,
git: Option<&GitIdentity>,
identity: &AgentIdentity,
settings: &SettingsStore,
) -> String {
let (name, email) = resolve(git, identity, &crate::environment::hostname());
let mut parts = Vec::new();
field(file, "user.name", WRITTEN_NAME, &name, settings, &mut parts);
field(
file,
"user.email",
WRITTEN_EMAIL,
&email,
settings,
&mut parts,
);
format!("git identity: {}", parts.join(", "))
}
/// One field's guard, write, and log phrase:
/// - the config file holds someone else's value → kept, untouched;
/// - it already holds the resolved value → aligned (the marker too,
/// so a later resolution can still update it — a hand edit that
/// matches what the daemon resolved counts as the daemon's);
/// - it is unset, or it is exactly what the daemon wrote last time →
/// written, and the marker follows.
fn field(
file: &Path,
key: &str,
setting_key: &str,
want: &ResolvedField,
settings: &SettingsStore,
parts: &mut Vec<String>,
) {
let mut summary = |action: String| {
parts.push(format!(
"{} {:?} from {}: {}",
key.rsplit_once('.').map(|(_, n)| n).unwrap_or(key),
want.value,
want.source,
action
))
};
let written = settings.get(setting_key).ok().flatten();
match read(file, key) {
Err(reason) => summary(format!("unreadable ({reason}), left alone")),
Ok(Some(current))
if Some(current.as_str()) != written.as_deref() && current != want.value =>
{
summary("kept a hand-edited value".to_owned())
}
Ok(Some(current)) if current == want.value => {
if written.as_deref() != Some(current.as_str()) {
record(settings, setting_key, &current);
}
summary("already current".to_owned())
}
Ok(_) => match write(file, key, &want.value) {
Ok(()) => {
record(settings, setting_key, &want.value);
summary("wrote".to_owned())
}
Err(reason) => summary(format!("not written ({reason})")),
},
}
}
/// Records the pair the daemon wrote, so the next boot can tell its
/// own values from a hand edit. A store failure leaves the guard
/// conservative: the field reads as foreign next boot and is kept.
fn record(settings: &SettingsStore, key: &str, value: &str) {
let _ = settings.set(key, value);
}
/// One `git` invocation: fixed argv, no shell, stdin null, a short
/// budget. The exit code travels — a read's `1` means the key is
/// unset, which is an answer, not an error.
enum GitRun {
Completed { code: i32, stdout: String },
NotFound,
TimedOut,
}
fn git(args: &[&str]) -> GitRun {
let mut child = match Command::new("git")
.args(args)
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
{
Ok(child) => child,
Err(err) if err.kind() == std::io::ErrorKind::NotFound => return GitRun::NotFound,
Err(_) => return GitRun::NotFound,
};
let deadline = Instant::now() + GIT_BUDGET;
let code = loop {
match child.try_wait() {
Ok(Some(status)) => break status.code(),
Ok(None) if Instant::now() >= deadline => break None,
Ok(None) => std::thread::sleep(Duration::from_millis(10)),
Err(_) => break None,
}
};
let Some(code) = code else {
let _ = child.kill();
let _ = child.wait();
return GitRun::TimedOut;
};
let stdout = child
.stdout
.take()
.map(|mut pipe| {
let mut buf = Vec::new();
use std::io::Read;
let _ = pipe.read_to_end(&mut buf);
String::from_utf8_lossy(&buf).into_owned()
})
.unwrap_or_default();
GitRun::Completed { code, stdout }
}
/// Reads one key from the config file: `Some` when set, `None` when
/// unset (git exits 1 for that), an error when the read cannot be
/// trusted (a missing git, a multi-valued key) — and an untrusted read
/// is never written over.
fn read(file: &Path, key: &str) -> Result<Option<String>, String> {
match git(&["config", "--file", &file.to_string_lossy(), "--get", key]) {
GitRun::Completed { code: 0, stdout } => {
Ok(Some(stdout.trim().to_owned()).filter(|value| !value.is_empty()))
}
GitRun::Completed { code: 1, .. } => Ok(None),
GitRun::Completed { code, .. } => Err(format!("exit {code}")),
GitRun::NotFound => Err("git not found".to_owned()),
GitRun::TimedOut => Err("no exit in time".to_owned()),
}
}
/// Writes one key into the config file, replacing every value the key
/// carries (`--replace-all` keeps the field single-valued even over a
/// strange starting file).
fn write(file: &Path, key: &str, value: &str) -> Result<(), String> {
match git(&[
"config",
"--file",
&file.to_string_lossy(),
"--replace-all",
key,
value,
]) {
GitRun::Completed { code: 0, .. } => Ok(()),
GitRun::Completed { code, .. } => Err(format!("exit {code}")),
GitRun::NotFound => Err("git not found".to_owned()),
GitRun::TimedOut => Err("no exit in time".to_owned()),
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::config::GitIdentity;
use crate::identity::IdentityTexts;
/// The fixture: a temp config file, an in-memory settings store,
/// and a fresh store handle per test.
struct Fixture {
file: PathBuf,
settings: SettingsStore,
#[allow(dead_code)]
dir: tempfile::TempDir,
}
fn fixture() -> Fixture {
let dir = tempfile::tempdir().expect("tempdir");
let file = dir.path().join("gitconfig");
Fixture {
file,
settings: SettingsStore::in_memory().expect("the store opens"),
dir,
}
}
fn identity(name: Option<&str>, email: Option<&str>) -> AgentIdentity {
let store_settings = crate::settings::SettingsStore::in_memory().expect("the store opens");
let images = tempfile::tempdir().expect("tempdir");
let store = IdentityStore::new(Arc::new(store_settings), images.path().join("identity"));
store
.set_texts(&IdentityTexts {
name: name.map(str::to_owned),
mark: None,
initials: None,
tagline: None,
signoff: None,
email: email.map(str::to_owned),
})
.expect("the identity saves")
}
fn config_git(name: Option<&str>, email: Option<&str>) -> Option<GitIdentity> {
Some(GitIdentity {
name: name.map(str::to_owned),
email: email.map(str::to_owned),
})
}
fn value_of(file: &Path, key: &str) -> Option<String> {
read(file, key).expect("the key reads")
}
#[test]
fn defaults_land_when_nothing_is_set() {
let fix = fixture();
let who = identity(None, None);
let line = provision_at(&fix.file, None, &who, &fix.settings);
assert_eq!(value_of(&fix.file, "user.name").as_deref(), Some("claw"));
assert_eq!(
value_of(&fix.file, "user.email").as_deref(),
Some(format!("claw@{}", crate::environment::hostname()).as_str()),
);
assert!(line.contains("from default"), "{line}");
assert!(line.contains("wrote"), "{line}");
}
#[test]
fn config_beats_identity_beats_default() {
let fix = fixture();
let who = identity(Some("Kosmos"), Some("kosmos@example.net"));
provision_at(
&fix.file,
config_git(Some("Bot"), None).as_ref(),
&who,
&fix.settings,
);
assert_eq!(value_of(&fix.file, "user.name").as_deref(), Some("Bot"));
assert_eq!(
value_of(&fix.file, "user.email").as_deref(),
Some("kosmos@example.net"),
"the fields resolve independently"
);
let other = fixture();
provision_at(&other.file, None, &who, &other.settings);
assert_eq!(
value_of(&other.file, "user.name").as_deref(),
Some("Kosmos")
);
}
#[test]
fn a_hand_edited_value_wins_and_is_recorded_as_foreign() {
let fix = fixture();
write(&fix.file, "user.name", "The Operator").expect("the seed writes");
let who = identity(Some("Kosmos"), None);
let line = provision_at(&fix.file, None, &who, &fix.settings);
assert_eq!(
value_of(&fix.file, "user.name").as_deref(),
Some("The Operator")
);
assert!(line.contains("kept"), "{line}");
// The daemon did not write it, so no marker was recorded.
assert_eq!(fix.settings.get(WRITTEN_NAME).unwrap(), None);
// The unset email beside it still provisions: the guard is per field.
assert!(value_of(&fix.file, "user.email").is_some());
}
#[test]
fn reruns_update_what_the_daemon_wrote() {
let fix = fixture();
let first = identity(Some("Kosmos"), None);
provision_at(&fix.file, None, &first, &fix.settings);
let second = identity(Some("Kosmos Prime"), None);
let line = provision_at(&fix.file, None, &second, &fix.settings);
assert_eq!(
value_of(&fix.file, "user.name").as_deref(),
Some("Kosmos Prime"),
"the daemon rewrites its own values"
);
assert!(line.contains("wrote"), "{line}");
// And a rerun over an already-current pair is a no-op.
let before = std::fs::read_to_string(&fix.file).expect("the file reads");
let line = provision_at(&fix.file, None, &second, &fix.settings);
let after = std::fs::read_to_string(&fix.file).expect("the file reads");
assert_eq!(before, after, "nothing to do, nothing written");
assert!(line.contains("already current"), "{line}");
}
#[test]
fn a_config_change_flows_through_on_the_next_boot() {
let fix = fixture();
let who = identity(None, None);
provision_at(
&fix.file,
config_git(Some("Bot"), Some("bot@example.net")).as_ref(),
&who,
&fix.settings,
);
provision_at(
&fix.file,
config_git(Some("Renamed"), Some("moved@example.net")).as_ref(),
&who,
&fix.settings,
);
assert_eq!(value_of(&fix.file, "user.name").as_deref(), Some("Renamed"));
assert_eq!(
value_of(&fix.file, "user.email").as_deref(),
Some("moved@example.net"),
);
}
#[test]
fn a_hand_edit_that_matches_the_resolution_counts_as_the_daemons() {
let fix = fixture();
let who = identity(Some("Kosmos"), None);
write(&fix.file, "user.name", "Kosmos").expect("the seed writes");
provision_at(&fix.file, None, &who, &fix.settings);
// The marker was aligned, so a later resolution updates the field.
let renamed = identity(Some("Kosmos II"), None);
provision_at(&fix.file, None, &renamed, &fix.settings);
assert_eq!(
value_of(&fix.file, "user.name").as_deref(),
Some("Kosmos II")
);
}
}
+1
View File
@@ -2307,6 +2307,7 @@ async fn agent_put(
};
let texts = crate::identity::IdentityTexts {
name: field(body["name"].as_str(), &current.name),
email: field(body["email"].as_str(), &current.email),
mark: field(body["mark"].as_str(), &current.mark),
initials: field(body["initials"].as_str(), &current.initials),
tagline: field(body["tagline"].as_str(), &current.tagline),
+19 -1
View File
@@ -44,9 +44,13 @@ pub const MAX_IMAGE_BYTES: usize = 2 * 1024 * 1024;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct AgentIdentity {
/// The agent's display name: message author, window title,
/// notifications.
/// notifications, and the commit author name in workspaces.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
/// The address commits carry in workspaces; also the mail-like
/// identity other surfaces may quote.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
/// The glyph or emoji in the rail, the favicon, the empty states.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub mark: Option<String>,
@@ -69,6 +73,7 @@ pub struct AgentIdentity {
#[derive(Debug, Clone, Default)]
pub struct IdentityTexts {
pub name: Option<String>,
pub email: Option<String>,
pub mark: Option<String>,
pub initials: Option<String>,
pub tagline: Option<String>,
@@ -120,6 +125,7 @@ impl IdentityStore {
pub fn get(&self) -> Result<AgentIdentity, IdentityError> {
Ok(AgentIdentity {
name: self.text("name")?,
email: self.text("email")?,
mark: self.text("mark")?,
initials: self.text("initials")?,
tagline: self.text("tagline")?,
@@ -135,6 +141,7 @@ impl IdentityStore {
pub fn set_texts(&self, texts: &IdentityTexts) -> Result<AgentIdentity, IdentityError> {
let fields = [
("name", &texts.name, 64usize),
("email", &texts.email, 120),
("mark", &texts.mark, 8),
("initials", &texts.initials, 4),
("tagline", &texts.tagline, 120),
@@ -263,6 +270,7 @@ impl ToolOp for IdentitySet {
};
let texts = IdentityTexts {
name: field(args["name"].as_str(), current.name.as_deref()),
email: field(args["email"].as_str(), current.email.as_deref()),
mark: field(args["mark"].as_str(), current.mark.as_deref()),
initials: field(args["initials"].as_str(), current.initials.as_deref()),
tagline: field(args["tagline"].as_str(), current.tagline.as_deref()),
@@ -393,6 +401,7 @@ mod tests {
let saved = store
.set_texts(&IdentityTexts {
name: Some(" Kosmos ".to_owned()),
email: Some("kosmos@example.net".to_owned()),
mark: Some("✦".to_owned()),
initials: None,
tagline: Some("order".to_owned()),
@@ -400,6 +409,7 @@ mod tests {
})
.expect("the texts save");
assert_eq!(saved.name.as_deref(), Some("Kosmos"), "trimmed");
assert_eq!(saved.email.as_deref(), Some("kosmos@example.net"));
assert_eq!(saved.mark.as_deref(), Some("✦"));
assert_eq!(saved.initials, None);
assert_eq!(saved.signoff, None, "an empty string clears");
@@ -409,6 +419,7 @@ mod tests {
.set_texts(&IdentityTexts::default())
.expect("the clear saves");
assert_eq!(cleared.name, None);
assert_eq!(cleared.email, None);
}
#[test]
@@ -485,6 +496,7 @@ mod tests {
let answer = tool
.invoke(json!({
"name": "Kosmos",
"email": "kosmos@example.net",
"mark": "✦",
"avatar": "face.png",
}))
@@ -493,6 +505,7 @@ mod tests {
let answer: Value = serde_json::from_str(&answer).expect("parses");
assert_eq!(answer["saved"], true);
assert_eq!(answer["identity"]["name"], "Kosmos");
assert_eq!(answer["identity"]["email"], "kosmos@example.net");
assert_eq!(answer["identity"]["avatar"], true);
let (bytes, content_type) = store
.image(ImageKind::Avatar)
@@ -506,6 +519,11 @@ mod tests {
.expect("saves");
let identity = store.get().expect("reads");
assert_eq!(identity.name.as_deref(), Some("Kosmos"), "kept");
assert_eq!(
identity.email.as_deref(),
Some("kosmos@example.net"),
"kept"
);
assert_eq!(identity.tagline.as_deref(), Some("order"), "added");
assert!(identity.avatar, "untouched by a text-only save");
}
+8 -3
View File
@@ -32,9 +32,13 @@
//! - [`turn_store`] — the turn-history table: what each key's stream
//! streamed, appended per event, replayed whole after a restart
//! - [`hub`] — the event hub: per-key record and broadcast of turn events
//! - [`identity`] — the agent's presentation identity: name, mark,
//! images, served over `/v1/agent` and settable by the agent itself
//! through the `identity_set` tool
//! - [`identity`] — the agent's presentation identity: name, email,
//! mark, images, served over `/v1/agent` and settable by the agent
//! itself through the `identity_set` tool
//! - [`git_identity`] — the boot-time git identity: `user.name` and
//! `user.email` into the daemon user's global git config, resolved
//! from config, then identity, then defaults, guarded against
//! hand-edited values
//! - [`consents`] — the consent table and wake bridge: a running turn
//! asks the human (a secret to store, permission to act) and waits;
//! the chat surface answers through the consent routes
@@ -76,6 +80,7 @@ pub mod daemon;
pub mod environment;
pub mod extension;
pub mod forge;
pub mod git_identity;
pub mod handler;
pub mod http;
pub mod hub;
+5
View File
@@ -100,6 +100,11 @@ async fn run(args: Args) -> Result<(), ClawError> {
} else {
resolve_backends(&config)?
};
// The workspace git identity: written in both shapes (a cron pass
// commits too), from deterministic boot code, guarded against
// hand-edited values. Never fatal — provisioning problems are the
// one stderr line this prints.
eprintln!("[claw] {}", rhema_claw::git_identity::boot(&config));
eprintln!(
"[claw] active {}/{}, db {}, http {}",
backends.active().0,
+1
View File
@@ -94,6 +94,7 @@ fn config(dir: &tempfile::TempDir) -> ClawConfig {
transcript: None,
ingest_token: None,
sandbox: None,
git: None,
disabled_mcp_servers: std::collections::BTreeSet::new(),
}
}
+1
View File
@@ -60,6 +60,7 @@ fn config(dir: &tempfile::TempDir) -> ClawConfig {
transcript: None,
ingest_token: None,
sandbox: None,
git: None,
disabled_mcp_servers: std::collections::BTreeSet::new(),
}
}
+7 -1
View File
@@ -67,6 +67,7 @@ fn config(dir: &tempfile::TempDir, token: Option<&str>) -> ClawConfig {
ingest_token: None,
transcript: None,
sandbox: None,
git: None,
disabled_mcp_servers: std::collections::BTreeSet::new(),
}
}
@@ -2521,7 +2522,7 @@ async fn the_agent_identity_is_editable_over_the_surface() {
// A save names the fields it touches.
let saved: Value = client
.put(format!("{base}/v1/agent"))
.json(&json!({"name": "Kosmos", "mark": "✦", "tagline": "order"}))
.json(&json!({"name": "Kosmos", "email": "kosmos@example.net", "mark": "✦", "tagline": "order"}))
.send()
.await
.expect("the save posts")
@@ -2530,6 +2531,7 @@ async fn the_agent_identity_is_editable_over_the_surface() {
.expect("the save parses");
assert_eq!(saved["name"], "Kosmos");
assert_eq!(saved["mark"], "✦");
assert_eq!(saved["email"], "kosmos@example.net");
assert_eq!(saved["avatar"], false);
// A partial save leaves the fields it omitted.
@@ -2544,6 +2546,10 @@ async fn the_agent_identity_is_editable_over_the_surface() {
.expect("the partial save parses");
assert_eq!(partial["name"], "Kosmos Prime");
assert_eq!(partial["mark"], "✦", "untouched by the partial save");
assert_eq!(
partial["email"], "kosmos@example.net",
"untouched by the partial save"
);
// An empty string clears its field.
let cleared: Value = client
+1
View File
@@ -67,6 +67,7 @@ fn config(dir: &tempfile::TempDir) -> ClawConfig {
transcript: None,
ingest_token: None,
sandbox: None,
git: None,
disabled_mcp_servers: std::collections::BTreeSet::new(),
}
}
+11 -5
View File
@@ -3,11 +3,12 @@
name: identity_set
description: >-
Set your own presentation identity: the name, mark, initials,
tagline, and signoff the interfaces render, and your avatar or logo
images. This is how you look, not who you are — personality lives in
SOUL.md. Leave a field out to keep what is set; an empty string
clears it. The avatar and logo take a workspace-relative path to an
image file (png, jpeg, gif, or webp, under 2 MiB — svg is refused).
tagline, and signoff the interfaces render, an email to commit and
write as, and your avatar or logo images. This is how you look, not
who you are — personality lives in SOUL.md. Leave a field out to
keep what is set; an empty string clears it. The avatar and logo
take a workspace-relative path to an image file (png, jpeg, gif, or
webp, under 2 MiB — svg is refused).
parameters:
type: object
properties:
@@ -16,6 +17,11 @@ parameters:
description: >-
Display name: message author, window title, notifications. Up
to 64 chars.
email:
type: string
description: >-
The author address on the commits your workspaces make. Up to
120 chars.
mark:
type: string
description: Glyph or emoji for the rail and favicon. Up to 8 chars.