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
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ All code authored in or evaluated by DevOps CLI must strictly adhere to the foll
- **gh.** A gh child gets no `GH_TOKEN` and no `GITHUB_TOKEN`, as gh gives its environment to each `--jq` filter. For each gh child the runner makes a new folder (mode 0700), writes the token to its `hosts.yml` (mode 0600), sets `GH_CONFIG_DIR` and `GH_HOST=github.com`, and removes the folder when the child ends, also after an error, a timeout or a cancel. The folder goes directly into the runtime folder of the user (`platformdirs`), else directly into the temp folder of the system, else into `<data directory>/gh-config` when the data directory is absolute. No folder of devops-cli is between the runtime folder and the token folder, so no link below the runtime folder can move the token folder. A runtime folder or a `gh-config` folder that is a link, belongs to another user or that others can read is skipped. tempfile uses the current folder when it can write no temp folder, so a runtime or temp folder that resolves into the current folder is skipped too, unless the current folder is the root of the file system. Thus a token file goes into the current folder, which can be a working tree, only when `data.dir` names a folder there. When none works, the call stops with an error that names `XDG_RUNTIME_DIR`, `TMPDIR` and `data.dir`. An async call looks up the token in a thread and makes the folder in the thread of the event loop, so a cancelled call leaves no folder. A gh child reads no gh configuration of the person: no alias, pager, editor or `git_protocol`, and no login for a host other than github.com. The local gh commands (`gh auth`, version and help) get the tokens of the environment.
- **git.** Only a git child that reaches a remote (`push`, `fetch`, `pull`, `ls-remote`, `clone`, and `remote set-head`, `show`, `update` and `prune`) gets `GH_TOKEN`, which `gh auth git-credential` reads. A local git child, such as `git add` or `git commit`, gets none: a program that the configuration of its repository names runs as its child.
- **A timeout.** Each child that gets the session's token starts in a session of its own. A timeout kills its whole process group, so no helper that the child started, such as `git-remote-https`, keeps the token in its environment.
- **The implement job.** The agent of a step runs as the user of the Job, so it can write the git configuration of the home folder and of the clone, the hooks and the attribute files. Each git call of the job that reaches `origin` runs through `OriginGit` (`src/devops_cli/roadmap/implement/git_isolation.py`): in a new bare git folder that links the objects of the clone, with `GIT_CONFIG_GLOBAL=/dev/null`, `GIT_CONFIG_NOSYSTEM=1`, an empty home folder, an empty `credential.helper` before the trusted helper, no hooks, and the URL of `origin` that the job read before its first step. The job ends every leftover process before the check of the settings, before it makes the folder and again before the call. When each turn of the agent ends and before each such call, the job checks the git settings of the checkout, and a key, an attribute driver or an alternates file that it does not allow stops the item with the class `git_config`. A refused setting at a push in the middle of a turn stops the item at once. The new git folder gets a copy of the `shallow` file of a shallow clone, which the job opens with `O_NOFOLLOW`: a link there stops the item with `git_config`. A fetch that changes the file writes it back through a new file with a random name and `os.replace`, so the write follows no link. A verification command of a plan runs git only as the negative search `! git grep`, which reaches no remote: in the checkout, any other git call would read the configuration that the agent can write.
- **The implement job.** The agent of a step runs as the user of the Job, so it can write the git configuration of the home folder and of the clone, the hooks and the attribute files. Each git call of the job that reaches `origin` runs through `OriginGit` (`src/devops_cli/roadmap/implement/git_isolation.py`): in a new bare git folder that links the objects of the clone, with `GIT_CONFIG_GLOBAL=/dev/null`, `GIT_CONFIG_NOSYSTEM=1`, an empty home folder, an empty `credential.helper` before the trusted helper, no hooks, and the URL of `origin` that the job read before its first step. The job ends every leftover process before it makes the folder and again before the call. The new git folder gets a copy of the `shallow` file of a shallow clone, which the job opens with `O_NOFOLLOW`: a link there stops the item with `git_config`. A fetch that changes the file writes it back through a new file with a random name and `os.replace`, so the write follows no link. A verification command of a plan runs git only as the negative search `! git grep`, which reaches no remote: in the checkout, any other git call would read the configuration that the agent can write.
- **Every child with the token in a runner.** The job also runs code of the checkout that the agent wrote: the tests, the hooks of `pre-commit` and the exit checks. In a runner, the process runner ends every leftover process of the job before and after each child that gets the session's token (a gh child, or a git child that reaches a remote), and before the token folder of a gh child exists. The sweep ends every descendant of the job, so a runner runs its children that get the token one at a time. A process that survives stops the item.
- **Limits.** A target repository whose attributes name Git LFS (`filter=lfs`) or another filter, diff or merge driver that git does not define cannot use the implement Job: each item stops with `git_config`. Check the `.gitattributes` of a repository before the Service gets it. `devops roadmap eval implement` clones with `--shared`, which writes an alternates file, so it runs only outside a runner.
- **Limits.** A repository that keeps files in Git LFS cannot use the implement Job: `OriginGit` pushes with `core.hooksPath=/dev/null` and `--no-verify`, so no LFS object goes to the server, and the runner image sets up no `git-lfs`.
- **The risk that stays.** The token is in the environment or in a file of the same user while a child runs, so a process of that user could read it. The job ends every process that it started before and after such a child, and the root file system and the folders of `PATH` of the runner image are read-only. `ensure_checkout` and `plan_implement` fetch in the clone with the token, before any step of an agent runs. A process that is killed while a gh child runs can leave the folder of that call: in a runner it is on an `emptyDir` that ends with the pod, and on a workstation it stays until a person removes it. The two-container Job of #3700 moves the token out of the reach of the agent.
- **The tests.** `tests/core/test_process.py`, `tests/roadmap/implement/test_roadmap_implement_git_isolation.py` and `tests/roadmap/implement/test_roadmap_implement_token_isolation.py` fail when any of this breaks.

Expand Down
2 changes: 1 addition & 1 deletion docs/ERRORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Each exception class declares its `error_code` and `exit_code`. A command that a
| `GitHubUnauthenticatedError` | `GITHUB_UNAUTHENTICATED` | `1` | Git | Raised when the process has no GitHub identity, or GitHub refused its token (HTTP 401). |
| `GitHubUnreadError` | `GITHUB_UNREAD` | `1` | Git | Raised when no answer from GitHub could be read, so what the request did is unknown. |
| `GitOperationError` | `GIT_OPERATION_ERROR` | `1` | Git | Base exception for Git repository and branch operation failures. |
| `GitSettingsError` | `ROADMAP_IMPLEMENT_REFUSED` | `1` | Roadmap | Raised when the git settings of the checkout of the implement job hold a key, an attribute |
| `GitSettingsError` | `ROADMAP_IMPLEMENT_REFUSED` | `1` | Roadmap | Raised when the `shallow` file of the clone of the implement job is a link or is not a |
| `GiteaAccessBlocked` | `GITEA_ACCESS_BLOCKED` | `1` | Gitea | Raised when Cloudflare Access blocks a Gitea request with a redirect or challenge. |
| `GiteaError` | `GITEA_ERROR` | `1` | Gitea | Base exception for Gitea forge operations. |
| `HTTPTimeoutTypeError` | `VALIDATION_ERROR` | `1` | Devops_cli.http.client | Raised when an invalid timeout parameter type is provided. |
Expand Down
8 changes: 4 additions & 4 deletions docs/ROADMAP_WORKFLOW.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Each clear by digest adds an entry (the class, the new digest and the time) to `

## The failure classes

A stop has a class (`roadmap/failure.py`, #3065). A stop site that knows its cause passes the class itself (#3476): the classes `no_change_in_fix`, `tests_lost`, `head_moved`, `output_cap`, `limit_reached` and `outside_plan` come from the step, `git_config` comes from the check of the git settings, the step `fix-plan` gives `timeout` to an attempt that spent its time budget (#5363), the refine round gives `form_check` to a proposal that fails a form check (#6327), and no rule makes them. For any other stop, the classifier is a pure function of the error text, the exit status, the refusal of a tool, the name of the check and the log of the check. It never reads the last message of the agent, which is a claim that no check verified. A failure that no rule matches is `ci_infra`. The stop comment starts with the failed check and the end of its log, then names the class, the action taken and the action left. It shows the last message of the agent as a claim that no check verified. The Job log holds one line with the class and the action left. The Service adds 1 to `devops_cli_service_implement_failures_total` with the labels `class` and `repo` when a round reports the Job. A Job that left the Item with no result gets the class of the tail of its log.
A stop has a class (`roadmap/failure.py`, #3065). A stop site that knows its cause passes the class itself (#3476): the classes `no_change_in_fix`, `tests_lost`, `head_moved`, `output_cap`, `limit_reached` and `outside_plan` come from the step, `git_config` comes from a `shallow` file of the clone that is a link, the step `fix-plan` gives `timeout` to an attempt that spent its time budget (#5363), the refine round gives `form_check` to a proposal that fails a form check (#6327), and no rule makes them. For any other stop, the classifier is a pure function of the error text, the exit status, the refusal of a tool, the name of the check and the log of the check. It never reads the last message of the agent, which is a claim that no check verified. A failure that no rule matches is `ci_infra`. The stop comment starts with the failed check and the end of its log, then names the class, the action taken and the action left. It shows the last message of the agent as a claim that no check verified. The Job log holds one line with the class and the action left. The Service adds 1 to `devops_cli_service_implement_failures_total` with the labels `class` and `repo` when a round reports the Job. A Job that left the Item with no result gets the class of the tail of its log.

| Class | Default action | Meaning |
| :--- | :--- | :--- |
Expand All @@ -227,7 +227,7 @@ A stop has a class (`roadmap/failure.py`, #3065). A stop site that knows its cau
| `limit_reached` | `raise_limit` | A step spent a token budget or a time limit of `roadmap.implement`, or the one extension of its token budget. The reason names the setting and its value. See [the budgets](#checks-of-the-implement-job) |
| `read_only_path` | `wait` | A command wrote to a path that the Job mounts read-only. A new attempt or a new runner image writes to the same path, so a person fixes the cause |
| `outside_plan` | `wait` | A fix step changed, added or deleted a path that the plan does not name (a path in a code span of any group, or a file of the change folder). The stop names the paths and holds the discarded diff. A person decides whether the plan changes |
| `git_config` | `wait` | The git settings of the checkout hold a key that the job does not allow, an attribute names a filter, or a diff or merge driver that git does not define, or the clone has an alternates file. The job checks them when each turn of the agent ends and before each git call that reaches `origin`. The stop names each key, or each attribute and its first path, and no value, and pushes nothing. A person removes the setting and its cause |
| `git_config` | `wait` | The `shallow` file of the clone is a link or is not a regular file at a git call that reaches `origin`. git never makes the file a link. The stop names `shallow` and pushes nothing. A person removes the file and its cause |
| `plan_unreadable` | `wait` | The plan reader cannot read back the rendered files of a plan, or reads facts that differ from the proposal (#5214) |
| `form_check` | `retry` | A refine round wrote a proposal with an empty part that the schema allows: no problem statement, no existing-tool answer, or, for a proposal that fits one pull request, no criterion or a criterion with an empty part. A field that the schema refuses is `parser`. The result line names the failed parts (#6327) |

Expand Down Expand Up @@ -462,7 +462,7 @@ The runner Job runs the checks that a person runs in the devcontainer, from the
- **After the push.** The Job sets the title and the body of the draft, comments the steps on it, records `implement.result` as `drafted`, sets Status In Review and ends (#6559). It watches no check and marks nothing ready. The checks of the pull request stay the gate. Before the end, the Job asks `draft_readiness` with no check runs, as its step `ready` did: a missing change, a group that is not ticked, a change that is not archived or a stage prompt with no eval scores stops the item. In mode `on` of `roadmap.fix_checks.mode`, the watch row runs the ready path of the step `fix-checks` on a green draft and starts a fix-checks Job for a failed check whose name gives the class `test`, `lint` or `types`; modes `off` and `plan` leave a green draft a draft. A failed or cancelled check, or a conflict, has a repair owner only when the mode is `on`, the class is one of these, and the fix-checks unit of the head and the check has not ended with no repair. In each other case the watch row stops the item: Status Blocked, `implement.stopped` at `pull request`, the class, `implement.result` stopped, and one stop comment that names the check or the conflict. The row judges the latest run of each check name. It leaves a draft that an owner label claims. A stopped item gets no ready mark and no fix-checks Job until `implement: retry` clears the stop. A Staged item that delivers on its plan pull request gets the same rules.
- **Time.** The hooks add about 10 s to each step, and the install about 9 s. The scoped checks add about 35 s for the first two, and for the tests at most 30 test modules. On 2 CPUs, as in a Job, 12 test modules of the roadmap ran in 88 s, so the tests add at most about 3.5 minutes. The comment on the pull request gives the seconds of each scoped check.

- **Target repositories.** The Job refuses a filter, and a diff or merge driver that git does not define itself, in the attributes of the checkout (the class `git_config`). So a repository that uses Git LFS (`filter=lfs diff=lfs merge=lfs`), `merge=ours` or another driver of its own cannot use the implement Job: each item stops at its first turn. Check the `.gitattributes` of a repository before the Service gets it. A shallow clone, which a run with `--source` can name, works: the network calls copy its `shallow` file.
- **Target repositories.** A shallow clone, which a run with `--source` can name, works: the network calls copy its `shallow` file. A repository that keeps files in Git LFS cannot use the implement Job: `OriginGit` pushes with `core.hooksPath=/dev/null` and `--no-verify`, so no LFS object goes to the server, and the runner image sets up no `git-lfs`.
- **gh calls.** The Job, and each `devops` command, runs gh with a configuration folder of its own that holds only the token ([SECURITY.md](../SECURITY.md), item 15). A gh call reads no gh configuration of the person: no alias, pager, editor or `git_protocol`, and no login for a host other than github.com.

Tests hold the drift: each local hook runs a tool that the runner image holds, each scoped row is a row of `devops ci`, and the branches of the Job pass the branch-name hook.
Expand All @@ -484,7 +484,7 @@ The implement job has a baseline score. The command that gives it calls a model
| `no_scratch` | The diff adds no file at the root, under `.data/`, or with a scratch suffix |
| `tasks_ticked` | Every task of the group is ticked |

The report lists each property as pass, fail or skipped, the tokens, the model requests, the tool calls and the wall time of each fixture, and the property that failed first. A run writes the same report as JSON under `eval/implement` in the data directory. The command reads no GitHub state, writes none and pushes nothing. The scratch clone has no remote and goes away after the run. The scratch clone shares the objects of this repository (`git clone --shared`), which writes an alternates file. The check of the git settings refuses that file in a runner, so the command runs only outside a runner.
The report lists each property as pass, fail or skipped, the tokens, the model requests, the tool calls and the wall time of each fixture, and the property that failed first. A run writes the same report as JSON under `eval/implement` in the data directory. The command reads no GitHub state, writes none and pushes nothing. The scratch clone has no remote and goes away after the run. The scratch clone shares the objects of this repository (`git clone --shared`).

The fixtures hold the diffs of real runs: deliveries, and stops with a scratch file in the root. `--check-only` evaluates those recorded diffs with no model and no clone, and exits 1 when a diff fails other properties than its record says. `--check-only --run-commands` also applies each diff in a clone, runs the two properties that run commands, and compares all six with the record. A record may name a command property as failed. `--dry-run` lists the fixtures and the model requests, and makes no request. `--no-tools` runs the same fixtures with the remote MCP tools of the step disabled, so two runs of the eval on one fixture set measure the effect of the tools.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-11-21
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Design

## Decisions
- **`GitSettingsError` and `git_config` stay.** `_read_shallow` raises the error for a link, or anything but a regular file, at the `shallow` file of the clone. That handling stays until #3700, so the error, the class and the stop paths in `implement_run.py` stay for it. The tests of these stop paths now make the `shallow` file a link in place of a refused key.
- **One sweep before the folder.** `OriginGit` ran a sweep, the scan and a second sweep. With no scan, the two sweeps ran one after the other, so one goes. The sweep before the call with the token stays.
- **`_git` loses `isolated`.** Only the scan read the global and the system configuration (`isolated=False`). Each other call turns them off.

## Rejected alternatives
- **Keep the scan as a signal.** The audit of the git use of the roadmap Jobs and the owner decision on #6638 found that the scan protects no call with the token. It also starts a `core.fsmonitor` program before it refuses it, and it refuses Git LFS repositories, blobless clones and the `--shared` evaluation clone.
- **Delete `GitSettingsError` and `git_config` too.** `_read_shallow` still raises the error, and #6638 keeps the `shallow` file handling until #3700. A delete would leave a link at `shallow` with no class.
Loading