Files
Igor Šćekić 94de3e0eea refactor(docs-sync): declare the headless agent scope in the committed policy (#16405)
* refactor(docs-sync): declare the headless agent scope in the committed policy

Each headless pass now states its tool and path scope in configuration the CLI
enforces. agent-permissions.json holds two modes; agent-policy.mjs turns a mode
into KILO_CONFIG_CONTENT and lib.mjs applies it to every spawned run.

The gateway credentials now sit on the four steps that call the CLI, and the
checkout keeps no git credential: the fetch and push steps authenticate from
their own environment.

* fix(docs-sync): narrow the agent scope and keep attachment delivery

- `read` is allowed in both modes, because the CLI reads a `-f` attachment
  through the read tool.
- `docs-write` names every permission it needs, with a catch-all deny first.
- Edits cover the docs pages and navigation directories.
- The allowlist drops `sed`, `uniq` and `diff`, which each have a form that
  writes a file or runs a command.
- The rebuild step's comment describes the rebuild only.

* test(docs-sync): guard the command allowlist

The policy test records the allowlist the docs passes rely on, so a later edit
that changes it has to update this expectation too.

* fix(docs-sync): restrict docs edits to markdown and pin the mode tests

- The pages allow names the `.md` extension, so the Next.js app modules and API
  routes beside the docs stay out of reach.
- The mode tests compare against literal expectations instead of the map they
  read, so a new allow fails the test.
- The triage comment matches the mode it describes.

* test(docs-sync): cover sort in the allowlist guard

sort can write a file with -o and run a program with --compress-program, so the
guard that keeps such commands out of the allowlist names it too.

* test(docs-sync): drop an assertion the exact list already covers

The edit-scope test pins the exact allow list, so a second shape check could not
fail; the label and a comment now state what the list enforces.

* docs(docs-sync): describe the repair step's scope accurately

The comment on the repair step now names the paths and commands the mode
declares, so it matches agent-permissions.json.

* fix(docs-sync): require a valid agent policy before each run

Every mode is now checked as it becomes KILO_CONFIG_CONTENT: the first rule
must be the catch-all deny, and each rule and pattern must state a known
action. A mode that does not meet that requirement stops the run, so every
run carries the scope its mode declares.

The repair step builds the policy into a variable and checks it before
`kilo run`, so the pass starts only when its policy is present.

* test(docs-sync): pin the docs typecheck grant in the policy guard

* fix(docs-sync): let the mode own the emitted permission map

Each mode now supplies `permission` outright, so a run always evaluates the
rule map the mode declares, with the catch-all deny first. Provider and model
settings from the calling environment still pass through.

* fix(docs-sync): give each agent run its own step environment

- agent-policy.env() passes each pass the gateway credentials and its inputs,
  and leaves the variables a step sets for its own gh and git calls on the step.
- The edit pass prints through the same line filter as the repair step, and the
  re-verify step carries the same 10-minute build ceiling.
- The no-base config check passes an explicit empty base, so it no longer
  depends on the environment it runs in.

* fix(docs-sync): filter the agent environment by credential name

- The child environment of a kilo run keeps the caller's provider and model
  settings and drops credential-shaped names, instead of naming a fixed list.
- The gateway credentials stay, and the policy test pins a credential-shaped
  key from a step that does not exist yet.

* docs(docs-sync): state the name rule at the scope the filter applies

* fix(docs-sync): complete the read-only bash scope of the docs agent

The docs-write permission map now denies every form of an allowed inspection
command that leaves the read-only scope. A guard check pins each such deny entry
after the allow rule it qualifies, because permission evaluation takes the last
matching rule.

* fix(docs-sync): refuse an ask in a mode's rule map

A headless pass cannot answer a permission prompt, so a mode that leaves one
open fails at that tool call instead of before the model starts. Restrict the
accepted actions to allow and deny, name them in both validation messages, and
pin the rejection at a whole rule and at one pattern.

* test(docs-sync): wrap the new assertion to the file's width
2026-11-22 04:29:06 +01:00
..