Repository navigation
v0.7.0: policy travels — loops as an OCI artifact, and the image on GHCR - #24
Merged
Merged
Conversation
Two things, and the second one is mostly a design decision about what NOT to build. The image now ships. `release.yml` builds multi-arch (amd64 + arm64) and pushes to ghcr.io/shahcolate/docket-agent on every release tag, from the same commit as the npm package, with SBOM and provenance attestations attached. Until now the `before:docker:docket-agent` line in the README required everyone to `docker build` first, which made a documented deployment path a lie. arm64 matters specifically because a large share of people running an agent sandbox locally are on Apple Silicon, and an amd64-only interceptor would emulate on every tool call. The job pulls the published image afterward and runs the gate against a hostile call — the last chance to catch an image that builds but cannot refuse anything. `docket policy push/pull/inspect` publishes loops as an OCI artifact, one layer per loop file so each stays individually addressable and readable by generic tools. A zero-dependency distribution client: the token challenge, blob HEAD, the two-step upload, manifest put/get. Registries already have what policy distribution needs and a git submodule doesn't — immutable digests, tags that move deliberately, per-namespace access control, and a retention policy somebody else operates. Pull is the dangerous direction and is built like it. A loop file is not data; it is the artifact that decides what an agent may do, so fetching one from a network and installing it unattended IS the widening-your-own -permissions failure docket exists to prevent, wearing a supply chain as a disguise. Therefore: digests verified before a byte is written; every publisher-chosen filename validated against the loop-name grammar (a layer titled ../../../etc/cron.d/evil.loop.md is refused, and that is a test); artifact and layer media types checked so a container image can't be installed as policy; existing loops never silently replaced; a preview and a human keystroke before writing, refusing outright on non-interactive stdin without --yes; and the install on the record with its digest. What is deliberately NOT here: `extends:` cannot name a registry. A warrant check must never depend on the network. If a baseline could be fetched at check time, the question stops being "what is this agent allowed to do" and becomes "what does the gate do when the registry is down, or slow, or when the tag moved between two checks" — and every answer is worse than the problem. Fail open and the gate is decorative; fail closed and an outage stops all work; cache and the rules in force are whatever happened to be fetched first. Policy is pulled, vendored, and committed. That constraint is normative in the spec, not just a note in the code. The registry tests speak the real wire protocol to a real socket rather than stubbing functions, which is the only way a distribution client is worth testing — and it makes the hostile cases real: a registry that serves different bytes than the digest asked for, a traversal filename, an image posing as policy. Worth recording that the first version deadlocked: spawnSync blocks the event loop the mock registry runs on, so parent and child waited on each other forever. 213 tests. 10,614 red-team checks unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NvKRRHp1KYfc5foJ4CoeFt
Self-review of the v0.7.0 diff. One is a security hole I opened, one defeats the purpose of a feature in the same PR, two are robustness. 1. Credentials could go over plain HTTP. `--insecure` exists for a local registry and the test harness, but combined with a real DOCKET_REGISTRY_TOKEN it would have put that token on the wire in the clear against any host. Now refused outright rather than warned about, with loopback as the deliberate exception — that is what the flag is actually for. 2. A recorded policy install rendered as "(empty note)". The entry carried the source ref and the digest in its JSON, and the log — the thing anyone actually reads — showed nothing. Recording where your rules came from and then not displaying it is the same as not recording it. Reproduced before fixing; the line now names the files, the source, and the digest. 3. No request timeout. A registry that accepted the connection and then said nothing would hang the CLI forever. 4. `--dry-run` errored instead of answering when the pull would need --force. "What would this do?" is exactly the question someone asks when they already suspect a conflict, so refusing to answer made the flag useless precisely when it was most wanted. It now reports the conflict and exits 0. 217 tests. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NvKRRHp1KYfc5foJ4CoeFt
CI caught what local testing could not — the suite passed on Node 22 and failed on Node 18 with `ECONNREFUSED ::1`. The mock registry binds 127.0.0.1 but handed back a `localhost` auth realm. From Node 20 the request falls back to IPv4 (Happy Eyeballs is on by default); on Node 18 it does not, so the token exchange never connected. The realm now names the address the server actually listens on, which it always should have. The client half is a real gap, not just a test bug: package.json claims node >= 18, and a dual-stack registry whose AAAA record does not answer would fail there and succeed on 20. `autoSelectFamily: true` is now set explicitly on every request, so a registry behaves the same way on every Node this package supports. Verified on 18.20.8, 20.20.2, and 22.22.2 — 217/217 on each. Installing the older runtimes locally was the fix for the real problem, which was testing a >=18 package on one runtime. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NvKRRHp1KYfc5foJ4CoeFt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The two loose ends from #23. The second one is as much a decision about what not to build as what to build.
The image ships
release.ymlnow builds multi-arch (amd64 + arm64) and pushes toghcr.io/shahcolate/docket-agenton every release tag, from the same commit as the npm package, with SBOM and provenance attestations attached.Until now the
before:docker:docket-agentline in the README required everyone todocker buildfirst — a documented deployment path that didn't work off the shelf. arm64 matters specifically here: a large share of the people running an agent sandbox locally are on Apple Silicon, and an amd64-only interceptor would emulate on every tool call.The job pulls the published image afterward and runs the gate against a hostile call. That's the last chance to catch an image that builds fine but can't actually refuse anything.
A tool whose whole premise is "what was this allowed to do, and can you prove it?" should be able to answer the same question about itself:
$ gh attestation verify oci://ghcr.io/shahcolate/docket-agent:latest --owner shahcolatedocket policy push / pull / inspectextends:made one file govern forty loops. It doesn't help when the forty loops are in forty repos. So loops can now be published as an OCI artifact — one layer per loop file, annotated with its filename, so each stays individually addressable, readable in a registry UI, andoras pull-able by someone who's never heard of docket.A zero-dependency distribution client: the token challenge, blob HEAD, the two-step upload, manifest put/get. Registries already have what policy distribution needs and a git submodule doesn't — immutable digests, tags that move deliberately, per-namespace access control, and a retention policy somebody else operates. It's how the Docker MCP Catalog ships its server list, for the same reasons.
Pull is the dangerous direction, and it's built like it
A loop file isn't data. It's the artifact that decides what an agent may do. Fetching one off a network and installing it unattended is the widening-your-own-permissions failure docket exists to prevent, wearing a supply chain as a disguise. So:
../../../etc/cron.d/evil.loop.mdis refused, and that's a test, not an intention.--forcerequired, diff shown either way.--yes.What's deliberately not here:
extends:cannot name a registryThis is normative in the spec, not a note in the code. A warrant check must never depend on the network.
If a baseline could be fetched at check time, the question a reviewer has to answer stops being "what is this agent allowed to do" and becomes "what does the gate do when the registry is down, or slow, or when the tag moved between two checks" — and every honest answer is worse than the problem it solves. Fail open and the gate is decorative. Fail closed and an outage stops all work. Cache and the rules in force are whatever happened to be fetched first.
So distribution is a separate, explicit, human step. Policy is pulled, vendored, and committed; the warrant is always evaluated from local files a reviewer can read in a diff.
docket policy pullis a supply-chain step, not a runtime dependency.Testing
The registry tests speak the real wire protocol to a real socket rather than stubbing functions — the only way a distribution client is worth testing, and it's what lets the hostile cases be real: a registry that serves different bytes than the digest asked for, a traversal filename, an image posing as policy.
Worth recording: the first version of that test deadlocked.
spawnSyncblocks the event loop the in-process mock registry runs on, so the child's HTTP request could never be answered and the two processes waited on each other forever. Converted to asyncspawn; the reason is a comment in the test, because it's the kind of thing that gets reintroduced.npm test), up from 193.--yesrefusal on a pipe, and a pulled baseline actually denying throughextends:.Not verified locally: the GHCR push. No Docker daemon in this session, so the build/push/attest/pull-and-gate sequence runs in CI on the next release tag.
Generated by Claude Code