Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

feat(decisions): let agents accept decisions by default, signed as themselves (#4688)

Raghav Chamadiyaee8c1c44bfaa
diff --git a/docs/layers/DECISIONS.md b/docs/layers/DECISIONS.md
index 53567a75c..c224ba353 100644
--- a/docs/layers/DECISIONS.md
+++ b/docs/layers/DECISIONS.md
@@ -6,8 +6,8 @@ you make in coding-agent sessions. Each record is tied to the files it governs,
backed by a verbatim quote, checked for staleness against the code, and handed
to your agent when it is about to edit those files.
-It does not decide anything for you. A machine can propose a candidate; only a
-person (or a committed ADR) makes it a decision that governs.
+It does not decide anything for you. Extraction only proposes candidates; a
+person, a signed agent, or a committed ADR makes one a decision that governs.
Cost: capture runs inside `repowise init` and `repowise update`. ADR files,
inline markers, manual entry and conventions need no LLM key. Commit, pull
@@ -183,13 +183,16 @@ What gets stored depends on how you add it:
Each acceptance records who signed it and what kind of signer: `person`,
`agent`, or `import` (the committed manifest or an ADR). The person defaults to
-`git config user.name`; `--as` records a different identity. An agent may
-withdraw authority (`dismiss`, `deprecate`) by signing as itself with
-`--agent SLUG`. Granting authority is refused for an agent unless the
-repository allows it with `repowise decision config agent-acceptance --on` (off
-by default); the agent then signs with, for example,
-`decision confirm ID --agent claude_code --session "$SESSION_ID"`. The dashboard badges any authority record a person did not sign, and
+`git config user.name`; `--as` records a different identity. An agent reviews
+and accepts by signing as itself, for example
+`decision confirm ID --agent claude_code --session "$SESSION_ID"`; `merge`,
+`dismiss` and `deprecate` take `--agent` too. The acceptance contract is the
+same for every signer, and an agent's own record also needs evidence. The
+dashboard badges any authority record a person did not sign, the generated
+`CLAUDE.md` marks it `[accepted by SLUG, not a person]`, and
`decision show --format json` returns the signature.
+`repowise decision config agent-acceptance --off` keeps granting to people:
+agents still propose and withdraw.
### The tracked manifest
diff --git a/docs/reference/CLI_REFERENCE.md b/docs/reference/CLI_REFERENCE.md
index 64dc3f044..7be3f4aba 100644
--- a/docs/reference/CLI_REFERENCE.md
+++ b/docs/reference/CLI_REFERENCE.md
@@ -955,7 +955,7 @@ repowise decision add --agent SLUG --title T --decision D --rationale R --affect
repowise decision candidates # awaiting review; these govern nothing
repowise decision confirm ID... # accept: this makes them govern
repowise decision dismiss ID... # tombstone (sticky; never re-proposed)
-repowise decision merge ID INTO_ID # fold into an existing decision
+repowise decision merge ID INTO_ID # fold into an existing decision (--agent signs)
repowise decision dedupe # fold duplicate candidates (dry run unless --apply)
repowise decision split ID # flag as bundling two choices; never splits it
repowise decision deprecate ID # optionally naming its successor
@@ -967,7 +967,7 @@ repowise decision migrate # classify pre-split rows (dry run unles
repowise decision config show # resolved capture policy
repowise decision config preset NAME # default | off | local_only | balanced | full
repowise decision config discovery # broad discovery call budget
-repowise decision config agent-acceptance --on|--off # may an agent grant authority? (off)
+repowise decision config agent-acceptance --on|--off # may an agent grant authority? (on)
repowise decision config capture-prompt --on|--off # agent records what it committed (off);
# --on installs the shell hook
repowise decision source list # source registry and state
@@ -1006,7 +1006,7 @@ Every subcommand takes `--format` (`table` default, or `json`) and an optional `
| `--lane` | Extraction lane: `pr`, `session`, `session_discovery`, `comment`, `git_archaeology`, `adr`, `inline_marker`, `conventions`, `cli`. Not the Decisions page review lanes. | all lanes |
| `--limit` | Max listed. | `30` |
-**`confirm`, `dismiss`, `deprecate`, `split`**
+**`confirm`, `dismiss`, `deprecate`, `merge`, `split`**
| Flag | What it does | Default |
|------|--------------|---------|
@@ -1015,7 +1015,7 @@ Every subcommand takes `--format` (`table` default, or `json`) and an optional `
| `--evidence REF` | `confirm`: commit, file or link. Repeatable. | |
| `--as NAME` | `confirm`: accepter other than git identity. | git identity |
| `--superseded-by ID` | `deprecate`: lineage edge to the replacement; deprecated id keeps resolving. | |
-| `--agent SLUG` | Not `split`: sign as an agent (e.g. `claude_code`). | |
+| `--agent SLUG` | Not `split`: sign as an agent (e.g. `claude_code`). Granting is refused only under `agent-acceptance --off`. | |
| `--session ID` | Not `split`: signing agent session. | |
| `--yes` / `-y` | `dismiss`: skip the prompt (as does `--format json`). | off |
| `--preview` | `confirm`, `dismiss`: report each id's outcome, write nothing. | off |
diff --git a/docs/reference/CONFIG.md b/docs/reference/CONFIG.md
index 47c0869a6..4aa540206 100644
--- a/docs/reference/CONFIG.md
+++ b/docs/reference/CONFIG.md
@@ -367,7 +367,7 @@ decisions:
| `discovery.max_sessions` | `12` | Per discovery pass, 1-24. |
| `discovery.max_input_tokens` | `30000` | Per discovery pass, 2000-60000. |
| `harnesses` | `[claude_code]` | Whose transcripts the session lane reads; add `codex`. |
-| `agent_acceptance` | `false` | Whether an agent may grant a decision authority. |
+| `agent_acceptance` | `true` | Whether an agent may grant a decision authority, signed as itself. |
| `capture_prompt` | `false` | Ask the agent to record what it just committed. |
### Sources
@@ -409,11 +409,12 @@ is the one switch proving no extraction reaches a model.
### `agent_acceptance` and `capture_prompt`
-Neither is about capture; both ship off and no preset enables them.
+Neither is about capture, and no preset changes them.
-- `agent_acceptance` off: an agent can propose and withdraw authority, never
- grant it. On: it may accept, recorded as an agent's with the signing
- session, on every surface, never as yours.
+- `agent_acceptance` on (default): an agent may accept, recorded as an
+ agent's with the signing session, on every surface, never as yours. Off: an
+ agent can propose and withdraw authority, never grant it. `false` is written
+ to the config so it survives a reload.
- `capture_prompt` on: a successful `git commit` with two or more decision
signals prompts the agent, once per session, to run `repowise decision add`;
never for a commit a record already cites, and only as a proposal. An agent
diff --git a/packages/cli/src/repowise/cli/agent_targets/_data/codex_prompts/repowise-decision.md b/packages/cli/src/repowise/cli/agent_targets/_data/codex_prompts/repowise-decision.md
index 99b542d34..c26a56d60 100644
--- a/packages/cli/src/repowise/cli/agent_targets/_data/codex_prompts/repowise-decision.md
+++ b/packages/cli/src/repowise/cli/agent_targets/_data/codex_prompts/repowise-decision.md
@@ -44,12 +44,16 @@ unless the repository turns it on.
awaiting review, each with its id and the `blockers` that stop it being accepted.
- **confirm** — `repowise decision confirm <id>...` — accept candidates so they
govern. `--decision`, `--reason`, `--scope <path>` and
- `--evidence <commit|file|link>` fill the blockers. An agent signs with `--agent <slug>`, which works only where
- the repository has run `repowise decision config agent-acceptance --on`;
- otherwise leave acceptance to a person.
+ `--evidence <commit|file|link>` fill the blockers. An agent may review and
+ accept: it signs with `--agent <slug>` (plus `--session <id>` if known), and
+ the acceptance is recorded as the agent's, not a person's. A repository that
+ ran `repowise decision config agent-acceptance --off` refuses it; then leave
+ acceptance to a person.
+- **merge** — `repowise decision merge <id> <into-id>` — fold a duplicate
+ candidate into an accepted decision instead of accepting it twice.
- **deprecate / dismiss** — `repowise decision deprecate <id>` (optionally
`--superseded-by <id>`) or `repowise decision dismiss <id> --reason ...`.
- An agent passes `--agent <slug>` here too.
+ An agent passes `--agent <slug>` to merge, deprecate and dismiss too.
## Notes
diff --git a/packages/cli/src/repowise/cli/commands/augment_cmd/decision_inject.py b/packages/cli/src/repowise/cli/commands/augment_cmd/decision_inject.py
index 62d46e810..0a8a3baab 100644
--- a/packages/cli/src/repowise/cli/commands/augment_cmd/decision_inject.py
+++ b/packages/cli/src/repowise/cli/commands/augment_cmd/decision_inject.py
@@ -591,7 +591,7 @@ _ACCEPTED_HEADER = (
#: from PRs, commits, comments and agents as well as sessions.
_CANDIDATE_HEADER = (
"[repowise] Candidate decisions awaiting review, NOT accepted; weigh them, "
- "do not treat them as rules. Review: repowise decision candidates"
+ "do not treat them as rules. Review and accept or dismiss: repowise decision candidates"
)
diff --git a/packages/cli/src/repowise/cli/commands/decision_batch.py b/packages/cli/src/repowise/cli/commands/decision_batch.py
index 463ce0de8..0b921622f 100644
--- a/packages/cli/src/repowise/cli/commands/decision_batch.py
+++ b/packages/cli/src/repowise/cli/commands/decision_batch.py
@@ -7,6 +7,7 @@ from __future__ import annotations
import re
from contextlib import asynccontextmanager
+from dataclasses import dataclass
from pathlib import Path
import click
@@ -14,6 +15,8 @@ from rich.table import Table
from repowise.cli.helpers import console, get_db_url_for_repo
from repowise.cli.output import emit_json, emit_refusal
+from repowise.core.agents.identity import is_agent_slug
+from repowise.core.analysis.decisions.lifecycle import ACCEPTER_SESSION_MAX
@asynccontextmanager
@@ -270,3 +273,57 @@ def _emit_single(result: dict, token: str, verb: str, fmt: str, note: str, remed
emit_refusal(
result["error"], f"Cannot {verb} {result['id'][:8]}: {result['message']}", fmt, **extra
)
+
+
+@dataclass(frozen=True)
+class _Signer:
+ """Who signs an acceptance-log row: an agent by slug, or the repository's person."""
+
+ agent: str
+ kind: str
+ session: str
+
+ def name(self, repo_path: Path, override: str = "") -> str:
+ from repowise.core.analysis.decisions.accepter import resolve_accepter
+
+ return self.agent or resolve_accepter(repo_path, override=override)
+
+
+def _signer(agent: str, agent_session: str, *, accepter: str = "") -> _Signer:
+ """Validate the signing flags and return who they sign as.
+
+ Shared by every verb that appends to the acceptance log, so an agent can
+ say it is one wherever it can act.
+ """
+ _check_agent_flag(agent, accepter)
+ _check_session_flag(agent_session, agent)
+ return _Signer(agent=agent, kind="agent" if agent else "person", session=agent_session)
+
+
+def _check_agent_flag(agent: str, accepter: str) -> None:
+ if agent and accepter:
+ raise click.ClickException("Pass --agent or --as, not both: they name different signers.")
+ if agent and not is_agent_slug(agent):
+ raise click.ClickException(
+ f"{agent!r} is not a well-formed agent slug (lowercase, digits and underscores)."
+ )
+
+
+def _check_session_flag(agent_session: str, agent: str) -> None:
+ if agent_session and not agent:
+ raise click.ClickException("--session names the agent signing; pass --agent too.")
+ if len(agent_session) > ACCEPTER_SESSION_MAX:
+ raise click.ClickException(f"--session is at most {ACCEPTER_SESSION_MAX} characters.")
+
+
+#: The two flags an agent signs with, on every verb that writes an authority
+#: row: withdrawing needs no switch, so it is the likeliest to go unsigned.
+def _signing_options(command):
+ command = click.option(
+ "--session", "agent_session", default="", help="The agent session signing."
+ )(command)
+ return click.option(
+ "--agent",
+ default="",
+ help="Sign as this agent (e.g. claude_code) rather than as a person.",
+ )(command)
diff --git a/packages/cli/src/repowise/cli/commands/decision_cmd.py b/packages/cli/src/repowise/cli/commands/decision_cmd.py
index e5fb6d547..69cf616ec 100644
--- a/packages/cli/src/repowise/cli/commands/decision_cmd.py
+++ b/packages/cli/src/repowise/cli/commands/decision_cmd.py
@@ -21,6 +21,9 @@ from repowise.cli.commands.decision_batch import (
_require_ids,
_resolve_decision_id,
_review_batch,
+ _Signer,
+ _signer,
+ _signing_options,
_split_ids_and_path,
)
from repowise.cli.helpers import (
@@ -31,9 +34,7 @@ from repowise.cli.helpers import (
)
from repowise.cli.output import emit_json, emit_refusal, format_option, notice_console
from repowise.cli.worktree import detect_worktree_base
-from repowise.core.agents.identity import is_agent_slug
from repowise.core.analysis.decisions.lifecycle import (
- ACCEPTER_SESSION_MAX,
AGENT_ACCEPTANCE_REMEDY,
AGREEMENT_KIND,
ARCHITECTURAL_KIND,
@@ -112,60 +113,6 @@ def _describe_signature(acceptance) -> dict[str, str] | None:
}
-@dataclass(frozen=True)
-class _Signer:
- """Who signs an acceptance-log row: an agent by slug, or the repository's person."""
-
- agent: str
- kind: str
- session: str
-
- def name(self, repo_path: Path, override: str = "") -> str:
- from repowise.core.analysis.decisions.accepter import resolve_accepter
-
- return self.agent or resolve_accepter(repo_path, override=override)
-
-
-def _signer(agent: str, agent_session: str, *, accepter: str = "") -> _Signer:
- """Validate the signing flags and return who they sign as.
-
- Shared by every verb that appends to the acceptance log, so an agent can
- say it is one wherever it can act.
- """
- _check_agent_flag(agent, accepter)
- _check_session_flag(agent_session, agent)
- return _Signer(agent=agent, kind="agent" if agent else "person", session=agent_session)
-
-
-def _check_agent_flag(agent: str, accepter: str) -> None:
- if agent and accepter:
- raise click.ClickException("Pass --agent or --as, not both: they name different signers.")
- if agent and not is_agent_slug(agent):
- raise click.ClickException(
- f"{agent!r} is not a well-formed agent slug (lowercase, digits and underscores)."
- )
-
-
-def _check_session_flag(agent_session: str, agent: str) -> None:
- if agent_session and not agent:
- raise click.ClickException("--session names the agent signing; pass --agent too.")
- if len(agent_session) > ACCEPTER_SESSION_MAX:
- raise click.ClickException(f"--session is at most {ACCEPTER_SESSION_MAX} characters.")
-
-
-#: The two flags an agent signs with, on every verb that writes an authority
-#: row: withdrawing needs no switch, so it is the likeliest to go unsigned.
-def _signing_options(command):
- command = click.option(
- "--session", "agent_session", default="", help="The agent session signing."
- )(command)
- return click.option(
- "--agent",
- default="",
- help="Sign as this agent (e.g. claude_code) rather than as a person.",
- )(command)
-
-
def _load_policy(repo_path: Path):
"""The resolved policy, through the same loader ``decision config`` uses."""
from repowise.cli.commands.decision_config_cmd import _load
@@ -901,8 +848,9 @@ def decision_confirm(
``--agent`` is how an agent signs as itself. Without it the acceptance is
recorded as a person's, because without it the identity resolves to the
- repository's git name and a person's is what it would be. It is refused
- unless ``decision config agent-acceptance`` is on for this repository.
+ repository's git name and a person's is what it would be. An agent's
+ acceptance is refused only where ``decision config agent-acceptance --off``
+ is set for this repository.
"""
ids, path = _split_ids_and_path(decision_ids)
_require_ids(ids, "accept", fmt)
diff --git a/packages/cli/src/repowise/cli/commands/decision_config_cmd.py b/packages/cli/src/repowise/cli/commands/decision_config_cmd.py
index 7271e4548..59b51ff6a 100644
--- a/packages/cli/src/repowise/cli/commands/decision_config_cmd.py
+++ b/packages/cli/src/repowise/cli/commands/decision_config_cmd.py
@@ -112,11 +112,14 @@ def _emit(repo_path: Path, resolution, fmt: str) -> None:
console.print(f" [dim]Harnesses read: {', '.join(policy.harnesses)}.[/dim]")
if policy.agent_acceptance:
console.print(
- " [yellow]Agent acceptance is ON: an agent may grant a decision "
- "authority. Its acceptances are signed as an agent's, not yours.[/yellow]"
+ " [dim]Agent acceptance: on. An agent may accept a decision, signed as "
+ "the agent's, never yours.[/dim]"
)
else:
- console.print(" [dim]Agent acceptance: off. Agents withdraw authority, never grant it.[/dim]")
+ console.print(
+ " [yellow]Agent acceptance: off. Agents withdraw authority; only a "
+ "person grants it.[/yellow]"
+ )
if policy.capture_prompt:
from repowise.cli.editor_integrations.claude_config import (
claude_code_capture_hook_installed,
@@ -346,9 +349,9 @@ def config_agent_acceptance(
) -> None:
"""Allow, or forbid, an agent granting a decision authority.
- Off by default, and off is complete: an agent still withdraws authority,
- proposes candidates and reads what governs. On, its acceptances are
- recorded as an agent's, with the session that signed, on every surface.
+ On by default: an agent's acceptances are recorded as an agent's, with the
+ session that signed, on every surface. Off is complete: an agent still
+ withdraws authority, proposes candidates and reads what governs.
"""
from repowise.cli.commands.decision_cmd import _resolve_decision_repo
diff --git a/packages/cli/src/repowise/cli/commands/decision_review_cmd.py b/packages/cli/src/repowise/cli/commands/decision_review_cmd.py
index 227291dbf..9c99de038 100644
--- a/packages/cli/src/repowise/cli/commands/decision_review_cmd.py
+++ b/packages/cli/src/repowise/cli/commands/decision_review_cmd.py
@@ -10,6 +10,7 @@ from __future__ import annotations
import click
from rich.table import Table
+from repowise.cli.commands.decision_batch import _signer, _signing_options
from repowise.cli.helpers import console, get_db_url_for_repo, run_async
from repowise.cli.output import emit_json, emit_refusal, format_option, notice_console
@@ -204,15 +205,26 @@ def candidates_command(
@click.argument("decision_id")
@click.argument("into_id")
@click.argument("path", required=False, default=None)
+@_signing_options
@format_option()
-def merge_command(decision_id: str, into_id: str, path: str | None, fmt: str) -> None:
- """Fold a candidate into an existing decision instead of accepting a duplicate."""
- from repowise.cli.commands.decision_cmd import _resolve_decision_id, _resolve_decision_repo
+def merge_command(
+ decision_id: str, into_id: str, path: str | None, agent: str, agent_session: str, fmt: str
+) -> None:
+ """Fold a candidate into an existing decision instead of accepting a duplicate.
+
+ ``--agent`` signs the merge as that agent, like ``decision confirm``.
+ """
+ from repowise.cli.commands.decision_cmd import (
+ _load_policy,
+ _resolve_decision_id,
+ _resolve_decision_repo,
+ )
+ signer = _signer(agent, agent_session)
repo_path = _resolve_decision_repo(path, fmt)
+ granted = _load_policy(repo_path).agent_acceptance if agent else False
async def _run():
- from repowise.core.analysis.decisions.accepter import resolve_accepter
from repowise.core.persistence import get_session
from repowise.core.persistence.crud.authority import merge_candidate
from repowise.core.persistence.models import DecisionRecord
@@ -229,7 +241,13 @@ def merge_command(decision_id: str, into_id: str, path: str | None, fmt: str) ->
rec = await session.get(DecisionRecord, src)
try:
await merge_candidate(
- session, rec, into_id=dst, accepter=resolve_accepter(repo_path)
+ session,
+ rec,
+ into_id=dst,
+ accepter=signer.name(repo_path),
+ kind=signer.kind,
+ accepter_session=signer.session,
+ agent_acceptance=granted,
)
except ValueError as exc:
emit_refusal("merge_refused", str(exc), fmt, decision_id=src)
diff --git a/packages/core/src/repowise/core/analysis/decisions/lifecycle.py b/packages/core/src/repowise/core/analysis/decisions/lifecycle.py
index 9f4efc9fc..8e7db5aa8 100644
--- a/packages/core/src/repowise/core/analysis/decisions/lifecycle.py
+++ b/packages/core/src/repowise/core/analysis/decisions/lifecycle.py
@@ -195,11 +195,11 @@ UNRECORDED_ACCEPTER_KIND = ""
#: a longer id rather than hand Postgres a truncation error.
ACCEPTER_SESSION_MAX = 64
-#: What fixes a :func:`machine_grant_blocker` refusal. Addressed to a person,
-#: because the party reading it is the agent that was just refused.
+#: What fixes a :func:`machine_grant_blocker` refusal. The agent reading it
+#: cannot fix it alone: the repository switched agent grants off on purpose.
AGENT_ACCEPTANCE_REMEDY = (
- "Someone who owns this repository can allow it with "
- "`repowise decision config agent-acceptance --on`, or accept it themselves."
+ "Agent acceptance is off for this repository. Ask a person to accept it, or to "
+ "turn agent acceptance back on with `repowise decision config agent-acceptance --on`."
)
@@ -215,15 +215,16 @@ def accepter_kind_blocker(kind: str) -> str | None:
def machine_grant_blocker(kind: str, action: str, *, granted: bool) -> str | None:
"""Why an agent may not take *action*, or ``None``.
- A machine revokes but does not grant: withdrawing narrows what a record
- claims and re-accepting undoes it, while granting mints a constraint
- nobody agreed to. Stated rather than left true by omission.
+ Agents grant by default, signed as themselves. *granted* is ``False`` only
+ where the repository turned agent acceptance off: then an agent still
+ withdraws authority, since withdrawing narrows what a record claims and
+ re-accepting undoes it, but granting waits for a person.
"""
if kind != "agent" or action not in GRANTING_ACTIONS or granted:
return None
return (
- f"an agent may not record a {action!r} acceptance: machines withdraw "
- "authority but do not grant it"
+ f"an agent may not record a {action!r} acceptance here: agent acceptance "
+ "is off for this repository"
)
diff --git a/packages/core/src/repowise/core/analysis/decisions/policy.py b/packages/core/src/repowise/core/analysis/decisions/policy.py
index 58d5bc3eb..93c485123 100644
--- a/packages/core/src/repowise/core/analysis/decisions/policy.py
+++ b/packages/core/src/repowise/core/analysis/decisions/policy.py
@@ -344,10 +344,10 @@ class DecisionPolicy:
sources: dict[str, SourceSetting]
discovery: DiscoveryBudget = _DEFAULT_DISCOVERY
harnesses: tuple[str, ...] = DEFAULT_HARNESSES
- #: Whether an agent may grant authority, not merely withdraw it. The only
- #: setting here that lets something other than a person create a
- #: constraint, so it ships off and no preset turns it on.
- agent_acceptance: bool = False
+ #: Whether an agent may grant authority, not merely withdraw it. On by
+ #: default: agents do most of the reviewing, and every grant is signed
+ #: as the agent's, never a person's. ``--off`` restores a person-only gate.
+ agent_acceptance: bool = True
#: Whether the commit hook asks the agent to record a decision. An agent
#: cannot decline a hook, so this ships off and no preset turns it on.
capture_prompt: bool = False
@@ -497,8 +497,8 @@ class DecisionPolicy:
block["discovery"] = self.discovery.to_dict()
if self.harnesses != DEFAULT_HARNESSES:
block["harnesses"] = list(self.harnesses)
- if self.agent_acceptance:
- block["agent_acceptance"] = True
+ if not self.agent_acceptance:
+ block["agent_acceptance"] = False
if self.capture_prompt:
block["capture_prompt"] = True
return block
@@ -782,13 +782,15 @@ def resolve_policy(repo_config: dict[str, Any] | None) -> PolicyResolution:
discovery = _resolve_discovery(raw.get("discovery"), warnings)
harnesses = _resolve_harnesses(raw.get("harnesses"), warnings)
- # A non-boolean warns rather than grants: the failure this must not have
- # is reading as on.
+ # Absent means the default, on. Present but not a boolean (a quoted "no")
+ # was written by someone saying something, so it reads as off, not on.
agent_acceptance = _as_bool(raw.get("agent_acceptance"))
if agent_acceptance is None:
- if "agent_acceptance" in raw:
- warnings.append("`decisions.agent_acceptance` is not a boolean; ignoring it.")
- agent_acceptance = False
+ agent_acceptance = "agent_acceptance" not in raw
+ if not agent_acceptance:
+ warnings.append(
+ "`decisions.agent_acceptance` is not a boolean; treating it as false."
+ )
capture_prompt = _as_bool(raw.get("capture_prompt"))
if capture_prompt is None:
diff --git a/packages/core/src/repowise/core/generation/templates/_editor_block.j2 b/packages/core/src/repowise/core/generation/templates/_editor_block.j2
index eb0eb452c..e0076d8f1 100644
--- a/packages/core/src/repowise/core/generation/templates/_editor_block.j2
+++ b/packages/core/src/repowise/core/generation/templates/_editor_block.j2
@@ -70,7 +70,7 @@ Fix first:
- **A zero carries its basis.** An empty `callers`/`callees`/`used_by` comes with a `*_basis` saying how much of that language's calls the graph resolved, so read it before concluding nothing calls a symbol. On `get_answer`, `_meta.scope_hint` names the areas the answer did not touch.
- **Pre-edit, not instead-of-edit.** These tools decide *which* files to read and edit. {{ read_note }}
- **Noisy commands** (tests, builds, `git log`/`diff`, searches, listings): prefer `repowise distill <cmd>`, the same command with its exit code preserved and errors-first output. A `[repowise#<ref>: N lines omitted]` marker is recoverable via `repowise expand <ref>` (add `-q <regex>` to filter); never re-run the command to see omitted output.
-- **Recording a decision** you had to reason out: `repowise decision add --agent <your slug> --title T --decision D --rationale '<why, what you rejected>' --affects <path>` records it without prompting and prints the id (`--format json` to parse it back); the slug names you, e.g. `claude_code`. It lands as a candidate for review and never governs until accepted; `repowise decision candidates` lists what each candidate still needs.
+- **Recording a decision** you had to reason out: `repowise decision add --agent <your slug> --title T --decision D --rationale '<why, what you rejected>' --affects <path>` records it without prompting and prints the id (`--format json` to parse it back); the slug names you, e.g. `claude_code`. It lands as a candidate for review and never governs until accepted. You may review and accept candidates: `repowise decision candidates` lists what each still needs, `repowise decision confirm <id> --agent <your slug>` accepts one (add `--reason`, `--scope`, `--evidence` or `--decision` for a missing part), and `dismiss`, `merge` and `deprecate` take `--agent` too. Acceptances are signed as yours; a repository with agent acceptance off refuses them.
{% elif 'how_to_work' in s %}
### How to work in this repo
@@ -80,7 +80,7 @@ Fix first:
- **No model on this index.** `get_answer` replies are low confidence by design, so open its top `best_guesses` / `candidate_files` rows; `search_codebase` is full-text only, so `[fts]` hits are normal. The user adds a model with a provider key and `{{ data.model_command }}`; suggest it, do not run it.
{% endif %}
- **Noisy commands** (tests, builds, `git log`/`diff`): prefer `repowise distill <cmd>`, same exit code, errors first. Recover a `[repowise#<ref>: N lines omitted]` marker with `repowise expand <ref>` (`-q <regex>` filters); never re-run the command.
-- **Record a decision** you reasoned out: `repowise decision add --agent <your slug> --title T --decision D --rationale '<why>' --affects <path>` (lands as a candidate for review).
+- **Record a decision** you reasoned out: `repowise decision add --agent <your slug> --title T --decision D --rationale '<why>' --affects <path>` (lands as a candidate; accept candidates with `repowise decision confirm <id> --agent <your slug>`).
{% endif %}
{% if 'tools' in s %}
diff --git a/packages/server/src/repowise/server/mcp_server/_helpers.py b/packages/server/src/repowise/server/mcp_server/_helpers.py
index 9ed3dafb7..ceaab9ee1 100644
--- a/packages/server/src/repowise/server/mcp_server/_helpers.py
+++ b/packages/server/src/repowise/server/mcp_server/_helpers.py
@@ -569,7 +569,8 @@ def _compute_alignment(
"This file is ungoverned — it may be an outlier or simply undocumented."
if currencies
else "This index holds no accepted decisions, so no file is governed "
- "yet; a person accepts a candidate with `repowise decision confirm <id>`."
+ "yet; review `repowise decision candidates` and accept one with "
+ "`repowise decision confirm <id> --agent <your slug>`."
)
return {
"score": "none",
diff --git a/packages/server/src/repowise/server/mcp_server/tool_why/path_mode.py b/packages/server/src/repowise/server/mcp_server/tool_why/path_mode.py
index 0deda6978..43297595b 100644
--- a/packages/server/src/repowise/server/mcp_server/tool_why/path_mode.py
+++ b/packages/server/src/repowise/server/mcp_server/tool_why/path_mode.py
@@ -263,11 +263,12 @@ def _add_review_lanes(
result_data["candidates_note"] = (
f"{len(candidates)} candidate(s) mention this path and none of them "
"govern it. Nobody has accepted them, so they are a review "
- "request, not a rule. A person accepts one with "
- "`repowise decision confirm <id> --scope <path>`. An agent "
- "cannot, unless this repository has allowed it; where it has, "
- "pass `--agent <your slug>` so the acceptance is not recorded "
- "under a person's name."
+ "request, not a rule. You may review and accept one with "
+ "`repowise decision confirm <id> --agent <your slug> --scope <path>` "
+ "(add `--reason` or `--evidence` if it lacks them), or dismiss it "
+ "with `repowise decision dismiss <id> --agent <your slug> --yes`. "
+ "The acceptance is signed as yours, not a person's; a repository "
+ "with agent acceptance off refuses it."
)
if retired:
diff --git a/packages/server/src/repowise/server/schemas/decisions.py b/packages/server/src/repowise/server/schemas/decisions.py
index e1c66bd08..dcb76e5c0 100644
--- a/packages/server/src/repowise/server/schemas/decisions.py
+++ b/packages/server/src/repowise/server/schemas/decisions.py
@@ -352,9 +352,9 @@ class DecisionSettings(BaseModel):
#: default | off | local_only | balanced | full | custom
preset: str = "default"
#: Whether an agent may grant a decision authority, as against withdrawing
- #: it. False is the shipped posture, so a settings form that omits this
- #: field is reporting the default rather than hiding a grant.
- agent_acceptance: bool = False
+ #: it. True is the shipped posture; every agent grant is signed as the
+ #: agent's, so a person-only gate is the opt-out.
+ agent_acceptance: bool = True
discovery: DecisionDiscoveryBudget = DecisionDiscoveryBudget()
sources: list[DecisionSourceState] = []
provider_available: bool = True
diff --git a/packages/ui/__tests__/decisions/decision-capture-settings.test.tsx b/packages/ui/__tests__/decisions/decision-capture-settings.test.tsx
index b947be598..810d36f6f 100644
--- a/packages/ui/__tests__/decisions/decision-capture-settings.test.tsx
+++ b/packages/ui/__tests__/decisions/decision-capture-settings.test.tsx
@@ -28,7 +28,7 @@ function settings(overrides: Partial<DecisionSettings> = {}): DecisionSettings {
enabled: true,
llm: true,
preset: "default",
- agent_acceptance: false,
+ agent_acceptance: true,
discovery: { max_sessions: 12, max_input_tokens: 30000 },
sources: [source()],
provider_available: true,
diff --git a/packages/ui/src/decisions/decision-capture-settings.tsx b/packages/ui/src/decisions/decision-capture-settings.tsx
index 856fbe272..a88040dcd 100644
--- a/packages/ui/src/decisions/decision-capture-settings.tsx
+++ b/packages/ui/src/decisions/decision-capture-settings.tsx
@@ -183,7 +183,7 @@ export function DecisionCaptureSettings({
them because this is the page for what the layer may do alone. */}
<Toggle
label="Let agents accept decisions"
- description="Off, an agent can propose and withdraw but never grant authority. On, its acceptances are recorded as an agent's, with the session that signed."
+ description="On by default: an agent's acceptances are recorded as the agent's, with the session that signed. Off, an agent can propose and withdraw but never grant authority."
checked={settings.agent_acceptance}
disabled={locked || busy("agent_acceptance")}
{...(readOnlyReason ? { reason: readOnlyReason } : {})}
diff --git a/plugins/claude-code/commands/decision.md b/plugins/claude-code/commands/decision.md
index f3874d082..54848ada0 100644
--- a/plugins/claude-code/commands/decision.md
+++ b/plugins/claude-code/commands/decision.md
@@ -45,12 +45,16 @@ unless the repository turns it on.
awaiting review, each with its id and the `blockers` that stop it being accepted.
- **confirm** — `repowise decision confirm <id>...` — accept candidates so they
govern. `--decision`, `--reason`, `--scope <path>` and
- `--evidence <commit|file|link>` fill the blockers. An agent signs with `--agent <slug>`, which works only where
- the repository has run `repowise decision config agent-acceptance --on`;
- otherwise leave acceptance to a person.
+ `--evidence <commit|file|link>` fill the blockers. An agent may review and
+ accept: it signs with `--agent <slug>` (plus `--session <id>` if known), and
+ the acceptance is recorded as the agent's, not a person's. A repository that
+ ran `repowise decision config agent-acceptance --off` refuses it; then leave
+ acceptance to a person.
+- **merge** — `repowise decision merge <id> <into-id>` — fold a duplicate
+ candidate into an accepted decision instead of accepting it twice.
- **deprecate / dismiss** — `repowise decision deprecate <id>` (optionally
`--superseded-by <id>`) or `repowise decision dismiss <id> --reason ...`.
- An agent passes `--agent <slug>` here too.
+ An agent passes `--agent <slug>` to merge, deprecate and dismiss too.
## Notes
diff --git a/plugins/claude-code/skills/architectural-decisions/SKILL.md b/plugins/claude-code/skills/architectural-decisions/SKILL.md
index 1a23789aa..8e7546d8e 100644
--- a/plugins/claude-code/skills/architectural-decisions/SKILL.md
+++ b/plugins/claude-code/skills/architectural-decisions/SKILL.md
@@ -61,6 +61,10 @@ When you settle an architectural choice yourself (you weighed options and picked
`repowise decision add --agent <your slug> --title "..." --decision "..." --rationale "<why, and what you rejected>" --affects <path>`
-Add `--evidence-commit <sha>` once it is committed. The record lands as a candidate: it never governs until accepted, so recording is safe. Accept it yourself with `repowise decision confirm <id> --agent <your slug>` only if the repository allows agent acceptance; otherwise leave it for a person and mention it.
+Add `--evidence-commit <sha>` once it is committed. The record lands as a candidate: it never governs until accepted, so recording is safe.
+
+## Reviewing candidates
+
+You may review and accept candidates yourself. `repowise decision candidates --format json` lists each with its `blockers`. Accept one with `repowise decision confirm <id> --agent <your slug>`, adding `--reason`, `--scope <path>`, `--evidence <commit|file|link>` or `--decision` for whatever a blocker names. Dismiss a wrong one with `repowise decision dismiss <id> --agent <your slug> --reason ... --yes`, fold a duplicate with `repowise decision merge <id> <into-id> --agent <your slug>`, and retire one with `repowise decision deprecate <id> --agent <your slug>`. Your acceptances are recorded as yours, never a person's. If the repository turned agent acceptance off, the confirm is refused; leave it for a person and mention it.
If the user states a decision, offer to record it the same way without `--agent`.
diff --git a/plugins/codex/skills/architectural-decisions/SKILL.md b/plugins/codex/skills/architectural-decisions/SKILL.md
index 75ec5fcef..b698788c1 100644
--- a/plugins/codex/skills/architectural-decisions/SKILL.md
+++ b/plugins/codex/skills/architectural-decisions/SKILL.md
@@ -55,6 +55,10 @@ When you settle an architectural choice yourself (you weighed options and picked
`repowise decision add --agent <your slug> --title "..." --decision "..." --rationale "<why, and what you rejected>" --affects <path>`
-Add `--evidence-commit <sha>` once it is committed. The record lands as a candidate: it never governs until accepted, so recording is safe. Accept it yourself with `repowise decision confirm <id> --agent <your slug>` only if the repository allows agent acceptance; otherwise leave it for a person and mention it.
+Add `--evidence-commit <sha>` once it is committed. The record lands as a candidate: it never governs until accepted, so recording is safe.
+
+## Reviewing candidates
+
+You may review and accept candidates yourself. `repowise decision candidates --format json` lists each with its `blockers`. Accept one with `repowise decision confirm <id> --agent <your slug>`, adding `--reason`, `--scope <path>`, `--evidence <commit|file|link>` or `--decision` for whatever a blocker names. Dismiss a wrong one with `repowise decision dismiss <id> --agent <your slug> --reason ... --yes`, fold a duplicate with `repowise decision merge <id> <into-id> --agent <your slug>`, and retire one with `repowise decision deprecate <id> --agent <your slug>`. Your acceptances are recorded as yours, never a person's. If the repository turned agent acceptance off, the confirm is refused; leave it for a person and mention it.
If the user states a decision, offer to record it the same way without `--agent`.
diff --git a/plugins/shared/commands/decision.md b/plugins/shared/commands/decision.md
index 7c1ccb115..b4fa8d6a2 100644
--- a/plugins/shared/commands/decision.md
+++ b/plugins/shared/commands/decision.md
@@ -46,12 +46,16 @@ unless the repository turns it on.
awaiting review, each with its id and the `blockers` that stop it being accepted.
- **confirm** — `repowise decision confirm <id>...` — accept candidates so they
govern. `--decision`, `--reason`, `--scope <path>` and
- `--evidence <commit|file|link>` fill the blockers. An agent signs with `--agent <slug>`, which works only where
- the repository has run `repowise decision config agent-acceptance --on`;
- otherwise leave acceptance to a person.
+ `--evidence <commit|file|link>` fill the blockers. An agent may review and
+ accept: it signs with `--agent <slug>` (plus `--session <id>` if known), and
+ the acceptance is recorded as the agent's, not a person's. A repository that
+ ran `repowise decision config agent-acceptance --off` refuses it; then leave
+ acceptance to a person.
+- **merge** — `repowise decision merge <id> <into-id>` — fold a duplicate
+ candidate into an accepted decision instead of accepting it twice.
- **deprecate / dismiss** — `repowise decision deprecate <id>` (optionally
`--superseded-by <id>`) or `repowise decision dismiss <id> --reason ...`.
- An agent passes `--agent <slug>` here too.
+ An agent passes `--agent <slug>` to merge, deprecate and dismiss too.
## Notes
diff --git a/plugins/shared/skills/architectural-decisions.md b/plugins/shared/skills/architectural-decisions.md
index b4476391c..9691db8ab 100644
--- a/plugins/shared/skills/architectural-decisions.md
+++ b/plugins/shared/skills/architectural-decisions.md
@@ -69,6 +69,10 @@ When you settle an architectural choice yourself (you weighed options and picked
`repowise decision add --agent <your slug> --title "..." --decision "..." --rationale "<why, and what you rejected>" --affects <path>`
-Add `--evidence-commit <sha>` once it is committed. The record lands as a candidate: it never governs until accepted, so recording is safe. Accept it yourself with `repowise decision confirm <id> --agent <your slug>` only if the repository allows agent acceptance; otherwise leave it for a person and mention it.
+Add `--evidence-commit <sha>` once it is committed. The record lands as a candidate: it never governs until accepted, so recording is safe.
+
+## Reviewing candidates
+
+You may review and accept candidates yourself. `repowise decision candidates --format json` lists each with its `blockers`. Accept one with `repowise decision confirm <id> --agent <your slug>`, adding `--reason`, `--scope <path>`, `--evidence <commit|file|link>` or `--decision` for whatever a blocker names. Dismiss a wrong one with `repowise decision dismiss <id> --agent <your slug> --reason ... --yes`, fold a duplicate with `repowise decision merge <id> <into-id> --agent <your slug>`, and retire one with `repowise decision deprecate <id> --agent <your slug>`. Your acceptances are recorded as yours, never a person's. If the repository turned agent acceptance off, the confirm is refused; leave it for a person and mention it.
If the user states a decision, offer to record it the same way without `--agent`.
diff --git a/tests/unit/analysis/test_decision_policy.py b/tests/unit/analysis/test_decision_policy.py
index 2927fda5c..e46a385bd 100644
--- a/tests/unit/analysis/test_decision_policy.py
+++ b/tests/unit/analysis/test_decision_policy.py
@@ -613,29 +613,46 @@ def test_conventions_runs_with_no_model_once_it_is_switched_on():
# ---------------------------------------------------------------------------
-def test_agent_acceptance_is_off_in_every_preset():
- """The one setting that lets something other than a person grant authority."""
+def test_agent_acceptance_is_on_in_every_preset():
+ """Agents accept by default, signed as themselves; a preset is capture only."""
for name in PRESET_NAMES:
- assert preset_policy(name).agent_acceptance is False
+ assert preset_policy(name).agent_acceptance is True
-def test_a_non_boolean_agent_acceptance_does_not_grant():
- resolution = resolve_policy({"decisions": {"agent_acceptance": "yes"}})
+def test_agent_acceptance_is_on_with_no_block():
+ assert resolve_policy({}).policy.agent_acceptance is True
+
+
[email protected]("value", ["no", "yes", 0])
+def test_a_non_boolean_agent_acceptance_reads_as_off(value):
+ """Someone wrote something there; a quoted "no" must not grant."""
+ resolution = resolve_policy({"decisions": {"agent_acceptance": value}})
assert resolution.policy.agent_acceptance is False
assert any("agent_acceptance" in w for w in resolution.warnings)
-def test_turning_agent_acceptance_off_again_actually_writes_it(tmp_path):
- """``to_config_block`` omits a defaulted setting, so a merging write kept
- the stored ``true`` and ``--off`` changed nothing at all."""
- write_policy(tmp_path, preset_policy("default").with_agent_acceptance(True))
- assert load_policy(tmp_path).policy.agent_acceptance is True
+def test_an_explicit_off_persists(tmp_path):
+ """The block omits a defaulted setting, so off has to be written out or a
+ reload would read the default back on."""
+ from repowise.core.repo_config import load_repo_config
- write_policy(tmp_path, load_policy(tmp_path).policy.with_agent_acceptance(False))
+ write_policy(tmp_path, preset_policy("default").with_agent_acceptance(False))
+
+ assert load_repo_config(tmp_path)["decisions"]["agent_acceptance"] is False
+ assert load_policy(tmp_path).policy.agent_acceptance is False
+
+def test_turning_agent_acceptance_back_on_actually_writes_it(tmp_path):
+ """A merging write would keep the stored ``false`` and ``--on`` would change
+ nothing, so the policy's keys are replaced, not merged."""
+ write_policy(tmp_path, preset_policy("default").with_agent_acceptance(False))
assert load_policy(tmp_path).policy.agent_acceptance is False
+ write_policy(tmp_path, load_policy(tmp_path).policy.with_agent_acceptance(True))
+
+ assert load_policy(tmp_path).policy.agent_acceptance is True
+
def test_a_policy_write_keeps_unrelated_keys_under_decisions(tmp_path):
"""The replace is scoped to the keys the policy owns, not the whole block."""
@@ -661,9 +678,9 @@ def test_the_agent_switch_does_not_rewrite_the_stored_preset(tmp_path):
from repowise.core.repo_config import load_repo_config
write_policy(tmp_path, preset_policy("balanced"))
- write_policy(tmp_path, load_policy(tmp_path).policy.with_agent_acceptance(True))
+ write_policy(tmp_path, load_policy(tmp_path).policy.with_agent_acceptance(False))
resolved = load_policy(tmp_path).policy
- assert resolved.agent_acceptance is True
+ assert resolved.agent_acceptance is False
assert resolved.preset_name() == "balanced"
assert load_repo_config(tmp_path)["decisions"]["preset"] == "balanced"
diff --git a/tests/unit/cli/test_decision_agent_acceptance.py b/tests/unit/cli/test_decision_agent_acceptance.py
index 78bc905fa..dabe36fa1 100644
--- a/tests/unit/cli/test_decision_agent_acceptance.py
+++ b/tests/unit/cli/test_decision_agent_acceptance.py
@@ -2,8 +2,8 @@
Without ``--agent`` the identity resolves to the repository's git name, so an
agent confirming a decision signed the maintainer's. These hold the flag's
-contract: it is refused unless the repository turned agent acceptance on, and
-when it is allowed the record says an agent signed it.
+contract: an agent accepts by default and the record says an agent signed it,
+and it is refused only where the repository turned agent acceptance off.
"""
from __future__ import annotations
@@ -40,12 +40,21 @@ def _run(repo: Path, *args: str):
return CliRunner().invoke(cli, ["decision", *args, str(repo), "--format", "json"])
-def _allow_agents(repo: Path) -> None:
- result = _run(repo, "config", "agent-acceptance", "--on")
+def _forbid_agents(repo: Path) -> None:
+ result = _run(repo, "config", "agent-acceptance", "--off")
assert result.exit_code == 0, result.output
-def test_an_agent_is_refused_on_a_repository_that_did_not_allow_it(repo: Path) -> None:
+def test_an_agent_accepts_with_no_config(repo: Path) -> None:
+ result = _run(repo, "confirm", "aaaa", "--agent", "claude_code")
+
+ assert result.exit_code == 0, result.output
+ shown = json.loads(_run(repo, "show", "aaaa").output)["decision"]["signature"]
+ assert (shown["kind"], shown["accepter"]) == ("agent", "claude_code")
+
+
+def test_an_agent_is_refused_on_a_repository_that_turned_it_off(repo: Path) -> None:
+ _forbid_agents(repo)
result = _run(repo, "confirm", "aaaa", "--agent", "claude_code")
assert result.exit_code == 1, result.output
@@ -58,15 +67,14 @@ def test_the_refusal_leads_with_the_switch_it_was_refused_by(repo: Path) -> None
"""The flags remedy stays, because one run can refuse two ids for two
reasons, but it must not be the first thing an agent reads: nothing is
missing from this record."""
+ _forbid_agents(repo)
result = _run(repo, "confirm", "aaaa", "--agent", "claude_code")
remedy = json.loads(result.output)["remedy"]
- assert remedy.startswith("Someone who owns this repository")
-
+ assert remedy.startswith("Agent acceptance is off")
-def test_an_allowed_agent_signs_as_itself(repo: Path) -> None:
- _allow_agents(repo)
+def test_an_agent_signs_as_itself(repo: Path) -> None:
result = _run(repo, "confirm", "aaaa", "--agent", "claude_code", "--session", "s-1")
assert result.exit_code == 0, result.output
@@ -79,9 +87,7 @@ def test_an_allowed_agent_signs_as_itself(repo: Path) -> None:
def test_confirming_without_the_flag_still_signs_as_a_person(repo: Path) -> None:
- """Turning the switch on must not change what an unflagged confirm records."""
- _allow_agents(repo)
-
+ """Agent acceptance must not change what an unflagged confirm records."""
assert _run(repo, "confirm", "aaaa").exit_code == 0
shown = json.loads(_run(repo, "show", "aaaa").output)["decision"]["signature"]
@@ -95,24 +101,25 @@ def test_a_candidate_reports_no_signer(repo: Path) -> None:
def test_a_batch_refusal_still_names_the_switch(repo: Path) -> None:
"""The remedy reached only the one-id path, so a scripted confirm of two
ids was refused without ever being told which switch to turn on."""
+ _forbid_agents(repo)
result = _run(repo, "confirm", "aaaa", "bbbb", "--agent", "claude_code")
assert result.exit_code == 1, result.output
assert "agent-acceptance --on" in json.loads(result.output)["remedy"]
-def test_the_remedy_is_addressed_to_a_person(repo: Path) -> None:
- """The party reading it is the one that was just refused. Worded as its
- own next step, it would hand an agent the command that grants it."""
+def test_the_remedy_sends_the_agent_to_a_person(repo: Path) -> None:
+ """The repository switched agent grants off on purpose, so the agent's next
+ step is a person, not the command that undoes the switch."""
+ _forbid_agents(repo)
remedy = json.loads(_run(repo, "confirm", "aaaa", "--agent", "claude_code").output)["remedy"]
assert "yourself" not in remedy
- assert "owns this repository" in remedy
+ assert "Ask a person" in remedy
def test_a_withdrawal_is_not_reported_as_an_acceptance(repo: Path) -> None:
"""The same log records both, so the verb comes from the action."""
- _allow_agents(repo)
assert _run(repo, "confirm", "aaaa").exit_code == 0
assert _run(repo, "dismiss", "aaaa", "--yes").exit_code == 0
@@ -124,6 +131,7 @@ def test_a_withdrawal_is_not_reported_as_an_acceptance(repo: Path) -> None:
def test_an_agent_signs_its_withdrawals_without_the_switch(repo: Path) -> None:
"""Withdrawing needs no policy, so it is the action an agent is most
likely to take — and the one it would otherwise take under your name."""
+ _forbid_agents(repo)
assert _run(repo, "confirm", "aaaa").exit_code == 0
result = _run(repo, "dismiss", "aaaa", "--yes", "--agent", "claude_code", "--session", "s-9")
@@ -181,6 +189,54 @@ def test_the_flag_is_checked_before_anything_is_written(
assert json.loads(_run(repo, "show", "aaaa").output)["decision"]["signature"] is None
+# --- decision merge --agent --------------------------------------------------
+
+
+def test_an_agent_signs_a_merge(repo: Path) -> None:
+ assert _run(repo, "confirm", "bbbb").exit_code == 0
+
+ result = CliRunner().invoke(
+ cli,
+ [
+ "decision", "merge", "aaaa", "bbbb", str(repo),
+ "--agent", "claude_code", "--session", "s-3", "--format", "json",
+ ],
+ )
+ assert result.exit_code == 0, result.output
+
+ signed = json.loads(_run(repo, "show", "bbbb").output)["decision"]["signature"]
+ assert (signed["kind"], signed["accepter"], signed["session"], signed["action"]) == (
+ "agent",
+ "claude_code",
+ "s-3",
+ "merged",
+ )
+
+
+def test_an_agent_merge_is_refused_where_agent_acceptance_is_off(repo: Path) -> None:
+ assert _run(repo, "confirm", "bbbb").exit_code == 0
+ _forbid_agents(repo)
+
+ result = CliRunner().invoke(
+ cli,
+ ["decision", "merge", "aaaa", "bbbb", str(repo), "--agent", "claude_code",
+ "--format", "json"],
+ )
+
+ assert result.exit_code == 1, result.output
+ assert "agent acceptance is off" in json.loads(result.output)["message"]
+
+
+def test_a_merge_without_the_flag_signs_as_a_person(repo: Path) -> None:
+ assert _run(repo, "confirm", "bbbb").exit_code == 0
+
+ result = _run(repo, "merge", "aaaa", "bbbb")
+ assert result.exit_code == 0, result.output
+
+ signed = json.loads(_run(repo, "show", "bbbb").output)["decision"]["signature"]
+ assert (signed["kind"], signed["action"]) == ("person", "merged")
+
+
# --- decision add --agent ----------------------------------------------------
diff --git a/tests/unit/server/test_decisions_provenance_api.py b/tests/unit/server/test_decisions_provenance_api.py
index 8f8467f7f..94a81e08a 100644
--- a/tests/unit/server/test_decisions_provenance_api.py
+++ b/tests/unit/server/test_decisions_provenance_api.py
@@ -145,17 +145,17 @@ async def test_settings_report_the_agent_grant_and_can_change_it(
repo = await create_test_repo(client)
before = (await client.get(f"/api/repos/{repo['id']}/decisions/settings")).json()
- assert before["agent_acceptance"] is False
+ assert before["agent_acceptance"] is True
after = await client.put(
f"/api/repos/{repo['id']}/decisions/settings",
- json={"agent_acceptance": True, "etag": before["etag"]},
+ json={"agent_acceptance": False, "etag": before["etag"]},
)
assert after.status_code == 200, after.text
- assert after.json()["agent_acceptance"] is True
+ assert after.json()["agent_acceptance"] is False
reread = (await client.get(f"/api/repos/{repo['id']}/decisions/settings")).json()
- assert reread["agent_acceptance"] is True
+ assert reread["agent_acceptance"] is False
@pytest.mark.asyncio
@@ -165,18 +165,18 @@ async def test_a_capture_preset_does_not_revoke_the_agent_grant(
"""A preset names source membership. Authority is not membership."""
repo = await create_test_repo(client)
first = (await client.get(f"/api/repos/{repo['id']}/decisions/settings")).json()
- on = await client.put(
+ off = await client.put(
f"/api/repos/{repo['id']}/decisions/settings",
- json={"agent_acceptance": True, "etag": first["etag"]},
+ json={"agent_acceptance": False, "etag": first["etag"]},
)
after = await client.put(
f"/api/repos/{repo['id']}/decisions/settings",
- json={"preset": "balanced", "etag": on.json()["etag"]},
+ json={"preset": "balanced", "etag": off.json()["etag"]},
)
assert after.status_code == 200, after.text
- assert after.json()["agent_acceptance"] is True
+ assert after.json()["agent_acceptance"] is False
@pytest.mark.asyncio