Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The router owns the crewmate/scout-only boundary; primary and secondmate integra
| Model discovery | `commandcode --list-models`; authentication preflight is `commandcode status`. |
| Marker | None; the process title is the anchored name `command-code`, which identifies the adapter and outranks foreign inherited markers. |
| Trust dialogs | `--trust` skips the fresh-worktree folder-trust prompt and `--yolo` bypasses permission prompts. |
| Commit attribution | Command Code adds `Co-authored-by: CommandCodeBot <noreply@commandcode.ai>` by default and only its settings files can turn that off, so the fleet commit-msg strip removes it unless the home sets `config/keep-ai-trailers` (`../../../docs/configuration.md` "Commit attribution"). |
| Commit attribution | Command Code adds `Co-authored-by: CommandCodeBot <noreply@commandcode.ai>` by default and only its settings files can turn that off; Firstmate applies the [commit attribution policy](../../../../../docs/configuration.md#commit-attribution) through Git hooks. |

## Per-process wiring limits

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The router owns the crewmate/scout-only boundary; primary and secondmate integra
| Marker | None; anchored native `cortex` ancestry identifies the adapter and outranks foreign inherited markers. |
| Trust dialogs | `--dangerously-allow-all-tool-calls` (alias `--bypass`) also skips the `Do you trust this project?` dialog and writes nothing to `~/.snowflake/cortex/cortex.json`; project hooks and settings still load. |
| Imported config | Cortex loads Claude-compatible `~/.claude/settings.json` and project `.claude/settings.json` and `settings.local.json` hooks as well as its own `.cortex/` files, so a worker in a project with Claude hooks runs them; there is no switch to disable the import. |
| Commit attribution | The model, not a client setting, writes a `Generated with Snowflake CoCo` line and a `Co-authored-by: Snowflake CoCo <noreply@snowflake.com>` trailer; the spawn-owned commit-msg strip (`../../../../../bin/fm-git-strip-ai-trailers.sh`) removes both unless the home sets `config/keep-ai-trailers`. |
| Commit attribution | The model, not a client setting, writes a `Generated with Snowflake CoCo` line and a `Co-authored-by: Snowflake CoCo <noreply@snowflake.com>` trailer; Firstmate applies the [commit attribution policy](../../../../../docs/configuration.md#commit-attribution) through Git hooks. |

## Worker lifecycle limits

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Cross-harness provider and credential identity is owned by `references/common/mo
|---|---|
| Binary | `fm_cursor_resolve_binary` in `../../../bin/fm-cursor-lib.sh` resolves stable launcher `cursor-agent` or legacy `agent`, never `cursor`, and accepts each candidate only after that owner's bounded launch probe (via `fm_run_timed`, so coreutils `timeout` is not required) so a broken preferred name falls through; both names normally symlink into `~/.local/share/cursor-agent/versions/<version>/cursor-agent`, whose target auto-update replaces. |
| Launch | Positional instructions with `--trust`, `--yolo`, optional `--model <model>`, and `--workspace <absolute-task-worktree>`, after clearing foreign primary markers. |
| Attribution | Cursor can append a Co-authored-by trailer after the typed message. Unless the home sets `config/keep-ai-trailers` (`../../../../../docs/configuration.md` "Commit attribution"), every fleet launch installs the pane-scoped commit-msg strip in `../../../bin/fm-git-strip-ai-trailers.sh`, which removes known AI trailers and leaves human co-authors and the author identity untouched. |
| Attribution | Cursor can append a Co-authored-by trailer after the typed message; Firstmate applies the [commit attribution policy](../../../../../docs/configuration.md#commit-attribution). |
| Models | Use current-account `cursor-agent --list-models` or legacy `agent --list-models`; the drifting observed list had only `cursor-grok-4.5-high` and `cursor-grok-4.5-high-fast` for Grok plus several `xhigh` ids, so choose a returned reasoning id and never assume low or medium Grok. |
| Busy state | `../../../bin/fm-busy-lib.sh` folds the per-conversation transcript as `cursor-transcript`: `role:user` opens and typed `turn_ended` closes success or abort, covering manual interrupt; nothing is armed or seeded, and this backend-agnostic source was identical on tmux and Herdr. |
| Exit command | `/exit`. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The router owns the crewmate/scout-only boundary; primary and secondmate integra
| Marker | None; anchored native `devin` ancestry identifies the adapter and outranks foreign inherited markers. |
| Trust dialogs | The launch skips workspace trust for this run; the spawn owner carries the exact flags. |
| Imported config | The worker config sets `read_config_from.claude` false, so no Claude Code hook, `CLAUDE.md` rule, `.claude/skills`, or Claude MCP entry is imported; `AGENTS.md` and `.agents/skills` still load. |
| Commit attribution | Unless the home sets `config/keep-ai-trailers` (`../../../../../docs/configuration.md` "Commit attribution"), the worker config sets `attribution` false, Devin's switch for its `Co-Authored-By` trailer and `Generated with Devin` line; with the flag, the user config's setting (default on) is kept. |
| Commit attribution | The private worker config applies the [commit attribution policy](../../../../../docs/configuration.md#commit-attribution); `fm-devin-config.sh` owns the enforced settings. |

## Worker lifecycle limits

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The router owns the crewmate/scout-only boundary; primary and secondmate integra
| Marker | None; the daemon's anchored `polytoken` comm in tool-subprocess ancestry identifies the adapter (a tool subprocess's parent IS the daemon, verified live), and a structural polytoken ancestor outranks foreign inherited markers. |
| Trust dialogs | None at launch: the permission posture comes from the generated config dir under [`fm_polytoken_write_config`'s policy](../../../../../bin/fm-polytoken-lib.sh), and the first-start license dialog requires an operator decision - `--accept-license-terms` is never passed, and the readiness gate fails loudly on a pane that never starts processing its brief. |
| Imported config | The worktree `.polytoken/` project layer (hooks and facets) plus the generated per-task config dir, which fully replaces the global config (verified live: a `version: 4`-only project config.yaml fails startup with zero providers, and no `--global-config-dir` reaches the daemon). |
| Commit attribution | The shared `state/<id>.git-hooks` commit-msg strip covers polytoken like every launched runtime. |
| Commit attribution | The shared Git hooks apply the [commit attribution policy](../../../../../docs/configuration.md#commit-attribution). |

## Worker lifecycle limits

Expand Down
4 changes: 2 additions & 2 deletions .agents/skills/operational-home-layout/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ config/backend runtime session-provider backend override for new tasks; LOCAL,
config/t3code-token LOCAL, gitignored T3 Code mcp-client credential; docs/t3code-backend.md "Sign-in" owns minting, expiry, and secondmate linking
config/t3code-instances LOCAL, gitignored, inherited T3 provider-instance map; docs/t3code-backend.md "Provider instances and models" owns schema and catalog validation
config/calm Calm presentation preference shared by the Pi extension and the Claude Code mod; LOCAL, gitignored, and not inherited; see docs/configuration.md "Calm preference"
config/keep-ai-trailers optional presence flag to keep AI co-author trailers in this home's fleet commits; LOCAL, gitignored; inherited by secondmate homes; see docs/configuration.md "Commit attribution"
config/keep-ai-trailers optional commit-attribution flag; LOCAL, gitignored; inherited by secondmate homes; docs/configuration.md "Commit attribution" owns its policy
config/supervision-branch-model config/supervision-branch-effort Pi supervision-branch model and reasoning-effort pins written by /supervision-model; LOCAL, gitignored, independently settable, and not inherited; see docs/configuration.md "Pi supervision branch model and effort"
config/supervision-host optional supervision-host engine setting: the host runs the supervision branch's contract on a headless engine beside a non-Pi primary, away and, on a Claude or Cursor primary, attended; absent runs it on a Claude primary and nowhere else; LOCAL, gitignored, not inherited; see docs/configuration.md "Supervision host"
config/supervision-host-off optional presence flag opting this home out of the supervision host on every primary; LOCAL, gitignored; inherited by secondmate homes under the primary-authoritative contract; see docs/configuration.md "Supervision host"
Expand Down Expand Up @@ -98,7 +98,7 @@ state/ runtime records and signals; gitignored
<id>.cortex-plugin/ firstmate-owned per-task Cortex Code plugin directory (mode 700; busy-state hooks and Herdr pane registration) passed through --plugin-dir so no user or project config is edited; bin/fm-cortex-plugin.sh owns it; removed by teardown
<id>.muse-session muse busy-source binding (sessions root plus task worktree) written by fm-spawn; removed by teardown
<id>.cursor-session cursor busy-source binding (projects root, task worktree, prior conversations) written by fm-spawn; removed by teardown
<id>.git-hooks/ per-task git hooksPath that strips AI commit trailers at the commit object unless config/keep-ai-trailers is present; written by fm-spawn, removed by teardown (bin/fm-git-strip-ai-trailers.sh)
<id>.git-hooks/ per-task git hooksPath for the commit attribution policy and push guards; written by fm-spawn, removed by teardown (bin/fm-git-strip-ai-trailers.sh); docs/configuration.md "Commit attribution" owns selection
<id>.reconcile-nudged epoch second of the last inventory-reconcile nudge sent to this secondmate; bin/fm-secondmate-reconcile.sh owns its per-home cooldown window
<id>.ready-timeout durable record that the opt-in ready-session timeout stopped (or failed to stop) this ship worker's idle agent while its PR awaited merge; while a `stopped` record names the current spawn_gen and crew state still reads done the worker is deliberately stopped, not stuck, and relaunches on demand; bin/fm-ready-timeout-lib.sh owns it; removed by teardown
<id>.backlog-close the exact backlog transition a teardown recorded before removing the task's record, so an interrupted cleanup can still be finished at the next session start; bin/fm-backlog-transition-lib.sh owns its format and replay, and a landed transition removes it
Expand Down
4 changes: 2 additions & 2 deletions bin/fm-config-inherit-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
# declared configuration.
# Primary config/t3code-instances selects the T3 provider account for each
# harness, so secondmates inherit it rather than falling back to a default.
# Primary config/keep-ai-trailers is a home-wide commit-attribution choice, so
# a secondmate's own crewmates keep AI co-author trailers too.
# Primary config/keep-ai-trailers propagates the legacy attribution preference;
# docs/configuration.md "Commit attribution" owns its policy.
# Primary config/supervision-host-off is the fleet's supervision-host opt-out,
# so a primary that opts out opts every secondmate home out too, while each
# home's config/supervision-host engine line stays its own.
Expand Down
5 changes: 3 additions & 2 deletions bin/fm-devin-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
# and Claude MCP imports, while AGENTS.md and .agents/skills still load.
# attribution=false is forced too, because Devin otherwise adds a
# Co-Authored-By: Devin trailer and a Generated with Devin line to commits
# and PRs, unless FM_KEEP_AI_TRAILERS=1 (fm-spawn sets it when the home has
# config/keep-ai-trailers); then the source's attribution setting is kept.
# and PRs, unless FM_KEEP_AI_TRAILERS=1; then the source's attribution setting
# is kept. fm-spawn resolves that value under docs/configuration.md's
# "Commit attribution" policy.
# UserPromptSubmit opens a turn; Stop and SessionEnd close it. Devin 3000.11.1
# emits no Stop on double-Escape cancellation, so fm-control invalidates its
# state to unknown after delivering that interrupt, never fabricating idle.
Expand Down
176 changes: 176 additions & 0 deletions bin/fm-git-attribution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
#!/usr/bin/env python3
"""Scoped commit attribution.

Usage: fm-git-attribution.py mode <config> <project>
fm-git-attribution.py stamp <task-meta> <runtime> <model> <message>
fm-git-attribution.py strip-fields <message>

docs/configuration.md "Commit attribution" owns launch-repository selection
and its accepted cross-repository limitation.
Stamp runs in Git's hook cwd and rechecks origin. Session references come from
runtime context or existing task metadata, never a new persistent record.
"""
import os
import re
import subprocess
import sys
from pathlib import Path
from urllib.parse import urlsplit

UUID = re.compile(r"[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}", re.I)
SHARED_FIELDS = {"agent-system", "agent-platform", "agent-session"}


def is_ai_coauthor(value):
# Match known product names and observed bot addresses, never vendor domains
# or name substrings, so human co-authors employed by vendors remain.
name = value.strip().lower()
email = ""
if "<" in name and ">" in name.split("<", 1)[1]:
name, email = name.split("<", 1)
name = name.strip()
email = email.split(">", 1)[0].strip()
return (email.startswith("cursoragent@") or email in {
"noreply@firstmate.invalid", "noreply@anthropic.com", "noreply@openai.com",
"copilot@github.com", "noreply@commandcode.ai", "noreply@snowflake.com",
} or name in {
"cursor", "cursor agent", "claude", "claude code", "github copilot", "copilot",
"codex", "chatgpt", "gemini", "google gemini", "grok", "openai", "commandcodebot",
"snowflake coco", "cortex code",
})


def remove_trailers(content, keys, strip_ai=False):
args = ["git", "interpret-trailers", "--only-input"]
block = subprocess.run(args + ["--only-trailers"], input=content,
capture_output=True, text=True, check=True).stdout
if not block:
return content
formatted = subprocess.run(args, input=content, capture_output=True,
text=True, check=True).stdout
divider = re.search(r"(?m)^---(?:[ \t]|\r?$)", formatted)
cursor = divider.start() if divider else len(formatted)
entries = re.findall(r"(?m)^[^\s][^\n]*(?:\n[ \t][^\n]*)*\n?", block)
for entry in reversed(entries):
start = formatted.rfind(entry, 0, cursor)
if start < 0:
raise ValueError("cannot locate Git-parsed trailer in message")
key, _, value = entry.partition(":")
key = key.strip().lower()
value = " ".join(line.strip() for line in value.splitlines())
if (key in keys or strip_ai and key == "co-authored-by"
and is_ai_coauthor(value)):
formatted = formatted[:start] + formatted[start + len(entry):]
cursor = start
return formatted


def t27sol(project):
result = subprocess.run(["git", "-C", project, "config", "--get", "remote.origin.url"],
capture_output=True, text=True, check=False)
url = result.stdout.strip()
if "://" in url:
parsed = urlsplit(url)
if parsed.scheme not in ("ssh", "https"):
return False
host, path = parsed.hostname or "", parsed.path.lstrip("/")
else:
match = re.fullmatch(r"(?:[^/@:]+@)?([^/:]+):([^\s]+)", url)
if not match:
return False
host, path = match.groups()
return host.lower() == "github.com" and bool(re.fullmatch(
r"t27sol/[a-z0-9_.-]+", path.lower().rstrip("/").removesuffix(".git")))


def mode(config, project):
if t27sol(project):
return "add"
return "keep" if Path(config).exists() else "strip"


def session(runtime, lines, task_meta):
# This variable is supplied to shell tools by Codex, not a parent endpoint ID.
if runtime == "codex":
value = os.environ.get("CODEX_THREAD_ID", "")
return value if UUID.fullmatch(value) else ""
if runtime.startswith("claude"):
for line in lines:
if line.lower().startswith("claude-session:"):
value = line.split(":", 1)[1].strip()
if UUID.fullmatch(value) or re.fullmatch(
r"https://claude\.ai/code/session_[a-zA-Z0-9]+", value):
return value
if runtime.startswith("opencode"):
value = os.environ.get("OPENCODE_SESSION_ID", "")
return value if re.fullmatch(r"ses_[a-zA-Z0-9]+", value) else ""
if runtime == "polytoken" and task_meta and Path(task_meta).is_file():
for line in Path(task_meta).read_text().splitlines():
if line.startswith("polytoken_session="):
value = line.split("=", 1)[1]
return value if re.fullmatch(r"[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}", value) else ""
return ""


def stamp(task_meta, runtime, model, message):
if not t27sol("."):
subprocess.run([str(Path(__file__).with_name("fm-git-strip-ai-trailers.sh")), message], check=True)
return
# Runtime/model are launch metadata, never free-form trailer contents.
if not re.fullmatch(r"[a-z0-9][a-z0-9_.-]*", runtime):
raise ValueError("unsafe runtime for Agent-Platform")
path = Path(message)
# Replace our fields on amend/retry; retain existing co-authors.
content = remove_trailers(path.read_text(), SHARED_FIELDS)
trailers = subprocess.run(["git", "interpret-trailers", "--parse"], input=content,
capture_output=True, text=True, check=True).stdout.splitlines()
sid = session(runtime, trailers, task_meta)
coauthors = [line for line in trailers if re.match(
rf"(?i)^co-authored-by:\s*{re.escape(runtime)}(?:\s|<|$)", line)]
# Claude Code omits model IDs from commit attribution. A default model is
# unresolved launch metadata, so it must not be presented as a model ID.
platform = runtime
if not runtime.startswith("claude") and model not in ("default", "auto"):
if (not model or any(c.isspace() or not c.isprintable() for c in model)
or model.startswith(("/", ".", "~")) or "\\" in model
or re.match(r"^[a-zA-Z]:/", model) or "://" in model
or any(part in (".", "..") for part in model.split("/"))):
raise ValueError("unsafe model for Agent-Platform")
platform += f"/{model}"
args = ["git", "interpret-trailers", "--in-place"]
if not coauthors:
args += ["--if-exists", "addIfDifferent", "--trailer",
f"Co-authored-by: {runtime} <noreply@firstmate.invalid>"]
args += ["--if-exists", "replace", "--trailer", "Agent-System: fac:firstmate",
"--trailer", f"Agent-Platform: {platform}"]
native_session = any(
re.fullmatch(r"[a-z0-9-]+-session", line.split(":", 1)[0], re.I)
and line.split(":", 1)[1].strip() == sid
for line in trailers if ":" in line
)
if sid and not native_session:
args += ["--trailer", f"Agent-Session: {sid}"]
path.write_text(content)
subprocess.run(args + [message], check=True)


if __name__ == "__main__":
try:
if len(sys.argv) == 4 and sys.argv[1] == "mode":
print(mode(*sys.argv[2:]))
elif len(sys.argv) == 6 and sys.argv[1] == "stamp":
stamp(*sys.argv[2:])
elif len(sys.argv) == 3 and sys.argv[1] == "strip-fields":
message = Path(sys.argv[2])
content = remove_trailers(
message.read_text(), SHARED_FIELDS | {"claude-session"}, strip_ai=True)
# Only the observed Cortex link forms count as generated attribution;
# other "Generated with" prose belongs to the author.
message.write_text("".join(line for line in content.splitlines(keepends=True)
if not re.fullmatch(
r"generated with \[(?:snowflake coco|cortex code)\]"
r"\(https://docs\.snowflake\.com/.*\)", line.strip(), re.I)))
else:
raise ValueError(__doc__)
except (OSError, ValueError, subprocess.CalledProcessError) as exc:
sys.exit(f"fm-git-attribution: {exc}")
Loading
Loading