Skip to content
Open
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
19 changes: 19 additions & 0 deletions docs/capability-parity-audit.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,25 @@ conversion of each veto is delivered by the issue or change it links. The
vetoes no earlier issue tracked link a child issue of #450, #455 to #459: see
[child issues](#child-issues).

## Ordinary read conversions (#524)

These refine the existing PA rows, rather than adding a new restriction.
`tests/test_read_parity.py` runs direct Bash baselines and the actual subprocess
hook with both executor labels; fixture provider output is not native evidence.
The separate Claude/Codex comparison remains required and is recorded as
`not_verified` when the enclosing executor cannot launch a nested native run.

| Converted refusal | Existing rows | Result and retained boundary |
|---|---|---|
| Git diff forms and `git -C <worktree> diff` | PA-18, PA-20, PA-43 | Automatic reads, including outside-workspace selectors; output and credential guards remain |
| Git grep and plain grep with `scripts/*.py` | PA-18, PA-19 | Read globs resolve before path checks; substitutions and executable segments still need consent |
| `merge-base`, upstream `rev-parse`, `git show … \| grep …` | PA-19, PA-20 | Recognized read segments run without consent; write segments do not |
| PR head/check queries and paginated comments API | PA-21 | Read flags and repository-scoped GET; fields, bodies and mutations retain guards |
| SSH transport `printenv` | PA-18 | Only the two named variables; other environment disclosure retains consent |
| Configured unittest variants and native Read in TMPDIR | PA-18 | Configured roles and dispatch temp evidence; no broader test or file-write authority |
| Issue snapshot `git -C` and isolated JSON inspection | PA-20, PA-43 | Read selector and validated pure JSON/argv expressions; arbitrary code and credential paths retain consent |
| Executor-layer refusal and recovered accessory reads | PA-36 | Layer and governing settings retained in log and stop reason; completed auxiliary reads create no pending decision |

## Inventory

`stage_permissions` means `scripts/stage_permissions.py`. Function names are
Expand Down
49 changes: 47 additions & 2 deletions docs/host-permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,50 @@ confined clone is never routed to Orca.

## The stage table

### Ordinary inspection without consent (#524)

Every stage may run Git `status`, `diff`, `log`, `rev-parse`, `show`,
`merge-base`, `ls-files`, `grep` and `blame`. Literal `git -C <dir>` selectors
may precede these reads, including a directory outside the workspace; credential
paths remain guarded. Options such as `--stat`, pathspecs and `@{u}` keep their
normal meaning. Read pipelines such as `git show <sha>:<path> | grep …` and
path globs such as `git grep -n -E "pattern" -- docs/ skills/ scripts/*.py`
or `grep -n pattern scripts/*.py` need no consent. Every pipeline segment must
be a recognized read, with no substitution, control flow, or redirection.

All stages may also use `gh pr view <n> --json … --jq …`, and
`gh api repos/<configured-owner>/<configured-repo>/issues/<n>/comments --paginate --jq …`.
The comments API accepts GET only, with no fields or input body, and remains
scoped to this repository. `printenv GIT_SSH_COMMAND GIT_SSH` reads only those
transport settings; bare `printenv` and other environment names retain consent.

`python3 -I -c …` data inspection accepts imports of `json` and `sys`, read-only
`open` on a literal path or indexed `sys.argv`, JSON loading and pure data
expressions (`get`, `keys`, `list`, `type`, `isinstance`, `print`). It never
executes code while validating. Other imports, code loaders, writes, computed
file paths and arbitrary interpreter programs retain consent. Credential-store
reads keep their guard even in this inspection form.

| Role | Verification without a new question |
|---|---|
| `implement`, `resolve`, `review`, `rereview`, `verify` | Configured exact test and configured verification prefixes; here `python3 -m unittest discover -s tests`, `python3 scripts/validate-package.py`, `python3 -m unittest` (including `tests.<module>`), and `basedpyright` |
| `issue_review`, `security`, `bootstrap`, `coordinate` | Inspection only; no project test execution is added |

The current dispatch's `$TMPDIR` files may be read by native `Read`, including
diff evidence. Claude receives dispatch-only `--allowedTools` entries for
Git selectors/pipelines, isolated inspection and the comments API; the immutable
hook still validates each operation. This changes no global permission file.
Git output paths and shell redirections outside `$TMPDIR`, credential reads,
and provider mutations retain refusal or consent. Codex retains its existing
filesystem and credential isolation; no command table is added to Codex.

An executor refusal is attributed to `claude_permission`, with
`--allowedTools` and `permissions.allow/deny` (including managed settings) in
the reason and journal. A toolkit grant cannot override those settings.
Auxiliary refusals after completed stages and observed successful retries stay
in the refusal log but do not create unanswered decisions. Required checks and
unresolved essential operations keep their existing decision path.

The table is the default. Explicit `code_cycle.user_choices` extend executable,
command and integration access without another confirmation; unknown names are
not a reason to block. Direct Git, code-host publication and Docker invocations
Expand Down Expand Up @@ -167,7 +211,7 @@ for consent. See [Configuration → Allowed commands](configuration.md#allowed-c

The table remains the default. Git forms outside it (`ls-tree`, `stash`,
`worktree add`, other fetch/pull forms), Git global and executing options
(`-c`, `-C`, `--upload-pack`, `grep -O`, `--output` outside `$TMPDIR`),
(`-c`, `--upload-pack`, `grep -O`, `--output` outside `$TMPDIR`),
program-selecting environment prefixes, and `gh` reads outside the table or
repository receive an exact consent question. The question names the command
and its target and warns that options can execute programs or write files.
Expand Down Expand Up @@ -249,7 +293,8 @@ used by CI do not establish native parity.

The hook validates arguments, not only the program:

- simple literal commands use the table. Chaining (`&&`, `;`, `|`), heredocs,
- simple literal commands and the guarded inspection forms above use the table.
Other chaining (`&&`, `;`, `|`), heredocs,
substitutions, other expansions and globs use shell-operation consent,
with every visible segment checked against the concrete guards (#439);
- `$TMPDIR` is the only expansion, and only when it is the dispatch's own
Expand Down
26 changes: 21 additions & 5 deletions scripts/command_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
#: Top-level keys only the runtime writes into a stage's result, after the agent
#: produced it. They are the consent record, not part of any role's contract.
RUNTIME_RESULT_KEYS = ("permission_outcomes", "essential_permission", "stop_reason", "reconciliation")
EXECUTOR_PERMISSION_SETTING = "Claude --allowedTools and permissions.allow/deny (including managed settings)"


def refusal_reason(event: dict[str, Any], decision: Any) -> str:
if event.get("layer") == "claude_permission":
return f"Claude's permission layer refused the operation; governed by {EXECUTOR_PERMISSION_SETTING}"
return decision.reason if not decision.allowed else "executor permission layer refused the operation"
#: Where an agent-supplied value of a runtime-owned key is kept apart. It is
#: outside every closed contract, so a closed contract still rejects it.
AGENT_KEY_PREFIX = "agent_"
Expand Down Expand Up @@ -213,7 +220,7 @@ def _refused_operation(denials: object, policy: Any, broker: Any, executor: str,
command = str(data.get("command", ""))
decision = (check(command, observed_policy, cwd=cwd) if tool == "Bash"
else check_file_edit(tool, data, observed_policy, cwd=cwd))
reason = decision.reason if not decision.allowed else "executor permission layer refused the operation"
reason = refusal_reason(event, decision)
guard = protected_reason(tool, data, observed_policy, cwd)
if guard is not None:
continue
Expand Down Expand Up @@ -527,7 +534,8 @@ def _denial_records(denials: object, policy: Any, executor: str,
identifier. Recording a denial never authorizes the operation, and nothing
is skipped: a refusal the runtime cannot classify is `unknown`, not absent.
"""
from stage_permissions import FILE_EDIT_TOOLS, check, check_file_edit, denial_operation_id
from stage_permissions import (FILE_EDIT_TOOLS, check, check_file_edit, denial_operation_id,
_inspection_python, command_parts)
records: dict[tuple[str, str], dict[str, Any]] = {}
for event in denials if isinstance(denials, list) else []:
if isinstance(event, str):
Expand All @@ -550,9 +558,12 @@ def _denial_records(denials: object, policy: Any, executor: str,
decision = (check(command, observed, cwd=cwd) if tool == "Bash"
else check_file_edit(tool, data, observed, cwd=cwd))
rule = event.get("rule") or (decision.rule if not decision.allowed else "")
reason = decision.reason if not decision.allowed else "executor permission layer refused the operation"
reason = refusal_reason(event, decision)
inspection = (tool == "Bash" and _inspection_python(
command_parts(parse_command(command, observed.tmpdir).words)[1], observed, cwd))
except Exception:
rule, reason = event.get("rule") or "", "the refusal could not be re-evaluated"
inspection = False
try:
requested = event.get("operation") or operation(tool, data, observed, cwd)
except (ValueError, TypeError, OSError):
Expand All @@ -565,6 +576,7 @@ def _denial_records(denials: object, policy: Any, executor: str,
"rule": rule or "executor_permission_layer", "operation": identity,
"target": target if isinstance(target, str) else None,
"tmpdir": observed.tmpdir,
"inspection": inspection,
"intent": event.get("intent") if isinstance(event.get("intent"), dict) else None,
"class": UNKNOWN_DENIAL, "why": "not classified"})
return list(records.values())
Expand Down Expand Up @@ -602,6 +614,8 @@ def classify_denial(record: dict[str, Any], payload: dict[str, Any] | None, *,
or any(isinstance(check, dict) and same_command(check.get("command"), command)
and check.get("required") is not False for check in checks or [])):
return ESSENTIAL_PERMISSION, "the refused command is a mandatory check"
if record.get("inspection") is True:
return AUXILIARY_DENIAL, "the command only inspects JSON/argv data"
if record["tool"] != "Bash":
target = record.get("target")
tmpdir = record.get("tmpdir")
Expand Down Expand Up @@ -656,12 +670,14 @@ def classify_denials(records: list[dict[str, Any]], payload: dict[str, Any] | No
record["class"], record["why"] = classify_denial(record, payload, **evidence)
# TMPDIR is classification input, not a durable permission artifact.
record.pop("tmpdir", None)
record.pop("inspection", None)
return records


def _compact(record: dict[str, Any]) -> dict[str, Any]:
return {key: (str(record[key])[:300] if key in {"command", "reason", "why"} else record[key])
for key in ("command", "stage", "reason", "rule", "operation", "class", "why")}
for key in ("command", "stage", "reason", "rule", "operation", "class", "why", "layer")
if key in record}


def has_open_questions(payload: dict[str, Any]) -> bool:
Expand Down Expand Up @@ -737,7 +753,7 @@ def _reconcile_blocked(payload: dict[str, Any], role: str, completed: frozenset[
if claimed not in completed:
reason = f"the block declares no completion status valid for the {role} role"
elif serious is not None:
reason = f"{serious['class']} denial: {serious['command']}"
reason = f"{serious['class']} denial: {serious['command']}; {serious.get('layer')}: {serious['reason']}"
elif payload.get("publication_pending") is True:
reason = "the result says its publication is pending"
elif payload.get("environment_blocker") or payload.get("essential_permission"):
Expand Down
14 changes: 12 additions & 2 deletions scripts/cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from typing import Any, cast

from cycle_journal import Journal, redact
from execution_plan import RoleContract, role_contracts
from execution_plan import RoleContract, role_contracts, completion_statuses
from executors import (
Availability,
DispatchOutcome,
Expand Down Expand Up @@ -1232,6 +1232,14 @@ def _find_blocker(self, run: _StageRun, attempt: _Attempt,
classify_denials(
records, payload, publication=publication, cwd=cwd, environment=sandbox_commands,
mandatory=lambda command: _is_verification_command(command, command_policy))
# Completed stages can omit accessory operations; otherwise require
# an observed retry. Configured checks keep their own obligations.
from command_permissions import same_command, RECONCILABLE_DENIALS
executions = result.artifacts.get("command_executions") or []
for record in records:
record["worked_around"] = (record.get("class") in RECONCILABLE_DENIALS
and (payload.get("status") in completion_statuses().get(run.role, ())
or any(same_command(record["command"], command) for command in executions)))
if records:
result = replace(result, artifacts={**result.artifacts, "denial_records": records})
configured_checks = tuple(command for command, item in grantable.items() if item.get("check"))
Expand Down Expand Up @@ -1629,7 +1637,8 @@ def observation(name, status, observed=None, detail=None):
self._journal("refusal", role=role, attempt_id=attempt_id,
component="claude_permission", status="denied",
command=denial.get("command") or denial.get("tool"),
reason=f"Claude's permission layer denied {denial.get('tool')}",
reason=(f"Claude's permission layer denied {denial.get('tool')}; governed by "
"--allowedTools and permissions.allow/deny (including managed settings)"),
correlation={"tool_use_id": denial.get("tool_use_id"), "layer": "claude_permission"})
from command_permissions import _result_block
result_block = _result_block(result.agent_output)
Expand All @@ -1646,6 +1655,7 @@ def observation(name, status, observed=None, detail=None):
"operation": record.get("operation"),
"stage": record.get("stage")})
if (self.consent is not None and self.consent.prompt is None and not reconciled
and not record.get("worked_around")
and record.get("class") != "unverifiable_check"):
# No human channel (`--detach`, no terminal): the refusal is a
# denial that grants nothing, and the question it would have
Expand Down
2 changes: 1 addition & 1 deletion scripts/fast-path-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"capability-parity-documentation": {
"paths": ["AGENTS.md", "docs/host-permissions.md", "docs/capability-parity-audit.md", "docs/ROADMAP_V2.md"],
"tests": ["test_capability_parity_audit", "test_consent_variants.ConsentVariantsTests.test_ac12_documentation_contract", "test_precheck_causes.PrecheckCauseTests.test_every_broad_handler_has_an_inventory_row", "test_table_consent.TableConsentTests.test_documentation_tracks_all_converted_rows", "test_sensitive_consent.SensitiveConsentTests.test_documentation_and_reduced_roadmap_scope"]
"tests": ["test_capability_parity_audit", "test_consent_variants.ConsentVariantsTests.test_ac12_documentation_contract", "test_precheck_causes.PrecheckCauseTests.test_every_broad_handler_has_an_inventory_row", "test_table_consent.TableConsentTests.test_documentation_tracks_all_converted_rows", "test_sensitive_consent.SensitiveConsentTests.test_documentation_and_reduced_roadmap_scope", "test_read_parity.ReadParityTests.test_read_documentation_covers_converted_refusals"]
},
"spike-fixtures": {
"paths": ["docs/spikes/**"],
Expand Down
Loading
Loading