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
3 changes: 2 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,10 @@ tasks:
- bash test/claude-code/unit/skills_test.sh

test:copilot-unit:
desc: 'Docker-free tests of the copilot Feature''s agent-adapter-copilot (src/copilot) with a fake `copilot` and no login: new and resume (--name and --resume by session name, AGENT_SESSION_NAME or the handle, a tab falling back), run-once (the prompt from stdin as -p with --silent --no-ask-user --no-auto-update, args passed through, --allow-all-tools only when asked, an empty or over-long prompt refused, --session-id a stable UUID only with AGENT_ADAPTER_COPILOT_CONTINUE=1, copilot''s stdout and exit code kept), mcp-attach (remove then add through copilot mcp, no token or --env, idempotent, nothing with no facilitator on PATH, a missing copilot or other target refused, a private COPILOT_HOME made), every other verb exit 3, and supports agreeing with the verbs; AGENT_MODEL (0.2.0) as --model on new and resume in place of a --model or --model= in the args, said, a value that is not one word left out, run-once unchanged; skills (0.3.0, ADR-0077) in a temp COPILOT_HOME: bad use without COMPONENT_REGISTRY_SKILLS (nothing created), one agent''s view personal and marked owned, two views split into the shared personal folder and each agent''s own .github/skills, an unowned skill never touched, a project skill clash said, --add-dir its own folder last and once on new, resume and run-once and none without a folder, the start line, skills-show, shared, off and forget. The contract tests run the real adapter too (test:agents-contract).'
desc: 'Docker-free tests of the copilot Feature''s agent-adapter-copilot (src/copilot) with a fake `copilot` and no login: new and resume (--name and --resume by session name, AGENT_SESSION_NAME or the handle, a tab falling back), run-once (the prompt from stdin as -p with --silent --no-ask-user --no-auto-update, args passed through, --allow-all-tools only when asked, an empty or over-long prompt refused, --session-id a stable UUID only with AGENT_ADAPTER_COPILOT_CONTINUE=1, copilot''s stdout and exit code kept), mcp-attach (remove then add through copilot mcp, no token or --env, idempotent, nothing with no facilitator on PATH, a missing copilot or other target refused, a private COPILOT_HOME made), every other verb exit 3, and supports agreeing with the verbs; AGENT_MODEL (0.2.0) as --model on new and resume in place of a --model or --model= in the args, said, a value that is not one word left out, run-once unchanged; skills (0.3.0, ADR-0077) in a temp COPILOT_HOME: bad use without COMPONENT_REGISTRY_SKILLS (nothing created), one agent''s view personal and marked owned, two views split into the shared personal folder and each agent''s own .github/skills, an unowned skill never touched, a project skill clash said, --add-dir its own folder last and once on new, resume and run-once and none without a folder, the start line, skills-show, shared, off and forget. The contract tests run the real adapter too (test:agents-contract). And copilot-home (home_test.sh) over temp folders with a fake sudo: a mounted state folder kept at mode 700 with ~/.copilot linked to it (a real ~/.copilot copied in without overwriting and kept aside), no mount with root (the Feature path replaced by a link to ~/.copilot, what the image folder held kept, run twice), no mount without root (~/.copilot as the path, the hint only without --quiet), a repo''s own COPILOT_HOME, an unusable mount (one actionable line), never fatal.'
cmds:
- bash test/copilot/unit/adapter_test.sh
- bash test/copilot/unit/home_test.sh

test:phi-check-unit:
desc: 'Docker-free tests of the phi-check Feature (src/phi-check): every rule with a positive and a near-miss case (never-issued SSN ranges, a lower-case MBI, an ICD code list, an NPI, a date, a name or a diagnosis word alone, an anchor outside the three-line window), no output line in any format holding the matched value, a binary or missing path failing closed, exit 2 on bad usage, the exceptions file skipping only the listed path and reporting a malformed line, --no-exceptions, standard input with --stdin-filename, the importable module; then a mutation check that three deliberately broken patterns each fail the suite; part of lint. Needs python3.'
Expand Down
30 changes: 30 additions & 0 deletions src/copilot/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,36 @@ of the Feature and whether they must act (an option renamed, a task removed, a r
The version in `devcontainer-feature.json` is bumped in the same change that adds its entry
here; `task lint` fails when the entry is missing.

## [0.5.0] - 2026-12-02

### Fixed

- A first `copilot` run no longer fails with "Failed to initialize session: ... failed to register
ownership for session ...: Permission denied (os error 13)" where the image was built without the
Feature's volume (Envbuilder ignores Feature mounts and runs no Feature hook), so `COPILOT_HOME`
named a folder that did not exist or was root's. Nothing to do in a consuming repo: drop any
hand-written `mkdir ~/.copilot` step once you are on 0.5.0.

### Added

- `copilot-home`, used by `copilot-setup` (post-create, `task copilot:setup`) and by the new
login-shell snippet `/etc/profile.d/copilot-home.sh`: the state folder exists, belongs to the
remote user and is mode 700. The Feature's volume when it is mounted (with `~/.copilot` linked to
it; a real `~/.copilot` is copied in without overwriting and kept as
`~/.copilot.before-copilot-feature`); else `~/.copilot`, with `/var/lib/devcontainer-features/copilot`
turned into a link to it when root or passwordless sudo is there, so `COPILOT_HOME` holds for every
process. Without root, login shells export `COPILOT_HOME=~/.copilot` and `copilot-setup` says in one
line how to make it hold everywhere (`remoteEnv`, or mount a volume). A folder that stays unusable
is said in one line with the command that fixes it.
- `install.sh` creates the state folder empty, owned by the build's remote user and mode 700, so a
new named volume starts with that owner and mode.

### Changed

- `copilot-setup` run as root (a builder that runs hooks as root) works for the remote user recorded
at build, leaves nothing root-owned, and runs the rest (the version, `attach`) as that user. The state
folder is now mode 700 (was: `go-w` on the top level).

## [0.4.1] - 2026-11-30

This change was first numbered 0.4.0; ghcr already serves a 0.4.0 published by `nabil-becker/the-stockroom`, so it is 0.4.1 (ADR 0089).
Expand Down
42 changes: 35 additions & 7 deletions src/copilot/NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

| Data | Where it lives | Storage tier |
| --- | --- | --- |
| Login (when made with `copilot login`), settings, session history, the facilitator MCP entry | named volume at `COPILOT_HOME` (`/var/lib/devcontainer-features/copilot`); a repo may bind-mount a host folder there | 4 working set |
| Login (when made with `copilot login`), settings, session history, the facilitator MCP entry | named volume at `COPILOT_HOME` (`/var/lib/devcontainer-features/copilot`); a repo may bind-mount a host folder there. Where no mount is applied (Envbuilder), `~/.copilot`, with the Feature path linked to it (0.5.0) | 4 working set |
| Registry skills (0.3.0, with the component-registry Feature 2.1.0): shared ones in `$COPILOT_HOME/skills`, each agent's own in `$COPILOT_HOME/registry-agents/<agent>.<sum>/`, each copy marked `.component-registry` | the same volume, owner-only | 4 working set |
| Agent list (with `participants: true`) | `.devcontainer/participants.yml` in the repository | 1 git |
| Leases and start markers (with `participants: true`) | `/var/lib/devcontainer-features/agents`, not a volume; a lease must not survive a rebuild | 4 working set |
Expand All @@ -36,8 +36,9 @@ nothing. What it adds:
- **`participants`**, the participant component, exactly as `claude-code` installs it, into one shared
place.
- **`attach`**, the facilitator's MCP entry, registered through Copilot's own command.
- **`COPILOT_HOME` as a named volume**, so a login survives a rebuild, made usable and private by a
post-create hook (`copilot-setup`).
- **`COPILOT_HOME` as a named volume**, so a login survives a rebuild, made usable and private by
`copilot-home` (0.5.0), which the post-create hook (`copilot-setup`) and a login-shell snippet run;
where the volume is not mounted (Envbuilder) the state goes to `~/.copilot` (below).
- The Feature Taskfile (`copilot:version`, `login`, `config`, `setup`, `attach`).

## The CLI comes from the official Feature (`dependsOn`)
Expand Down Expand Up @@ -256,10 +257,37 @@ harness's choice, not this Feature's; for the facilitator's pump the Operator's
from OpenBao into the environment of `facilitator serve`.

`COPILOT_HOME` must not be writable by group or other: Copilot refuses to write to one that is ("The
storage directory is writable by group or other users"; found while building this Feature). Docker
volumes arrive owned by root and mode 755, so `copilot-setup` hands the folder to the remote user with
`dcf-persist` and runs `chmod go-w` on its top level. A bind mount a repo puts on the same target is
treated the same.
storage directory is writable by group or other users"; found while building this Feature). And it must
exist and be the user's: otherwise the first session fails with "Failed to initialize session: ...
failed to register ownership for session ...: Permission denied (os error 13)" (seen in a Coder
workspace built by Envbuilder; it shows with no login, which the `home_as_user` scenario uses).

## The state folder (`copilot-home`, 0.5.0)

`copilot-home` makes the folder exist, belong to the remote user and be mode 700. It runs from
`copilot-setup` (post-create and `task copilot:setup`) and from `/etc/profile.d/copilot-home.sh` in
every login shell, so a builder that runs no Feature hook still gets a working first terminal. It is
idempotent, never fatal, and prints no token. Where the state goes, in order:

| Case | `COPILOT_HOME` | What `copilot-home` does |
| --- | --- | --- |
| A repo sets `COPILOT_HOME` to another path | that path | creates it, the user's, mode 700 |
| The Feature path is mounted (the devcontainer CLI: the named volume, or a repo's bind mount) | `/var/lib/devcontainer-features/copilot` | hands it to the user (`chown -R` with root or sudo), mode 700; links `~/.copilot` to it (a real `~/.copilot` is copied in without overwriting and kept as `~/.copilot.before-copilot-feature`) |
| Not mounted (Envbuilder ignores Feature mounts), root or passwordless sudo available | `/var/lib/devcontainer-features/copilot`, now a link to `~/.copilot` | makes `~/.copilot` (mode 700), copies in what the image folder held, replaces the image folder with the link, so every process that reads `containerEnv` agrees |
| Not mounted, no root | `~/.copilot` in login shells | makes `~/.copilot`; `copilot-setup` says in one line to set `"COPILOT_HOME": "<home>/.copilot"` in the repo's `remoteEnv` (or mount a volume) so processes that are not login shells agree |
| Mounted but owned by someone else, and no root to fix it | `~/.copilot` in login shells | one line on stderr with the `sudo chown` that fixes it |

The user is the caller; run as root, it is the remote user `install.sh` recorded from `_REMOTE_USER`
(else `_CONTAINER_USER`) in `/usr/local/share/copilot-feature/options.env`, else the account with uid
1000. A root-run `copilot-setup` prepares the folder for that user and then runs the rest as them
(`runuser`, else `su`), so nothing is left root-owned. `install.sh` also creates the folder empty, the
user's and mode 700, when the user exists at build: a new named volume starts with that owner and mode.

Under Envbuilder the state lives in `~/.copilot`, so it survives a restart only where the home folder
is persistent (a Coder workspace's home volume). To keep it on the Feature path instead, the consuming
template mounts a volume at `/var/lib/devcontainer-features/copilot` (ADR 0095 has the same advice for
open-model-agent). The login-shell snippet covers `bash -l` and shells that read `/etc/profile`; a zsh
that does not is covered by the link where root was available, else by `remoteEnv`.

## What works without a login, and what needs one

Expand Down
Loading