iterate.com / git

git clone https://git.iterate.com/repos/git

A member's git signs in with the iterate CLI, and nothing says whether a repo exists

Git's three requests now read the boundary's stamp, as a page does. A member's git gets a
token of the app's own on the way to Artifacts: the kept read token for a fetch, a write
token minted for the one request of a push. The member's own credential is a token of the
mind for this host (`npx iterate git setup <host>`, in the kernel), and it never leaves.

A request that is no member's gets one answer whether the repo is there or not:
- a credential that nobody took: 401, "this sign-in has ended", so git forgets the token;
- no credential and the helper's marker: 401 with a Basic challenge, so git asks the helper;
- no credential and no marker: 404, with the setup command. Git shows a 404's words and
  never a first 401's.
Before, a repo that is not public answered 401 and a missing one 404 with its name.

Who pushed which refs is written on the repo's log, `git/pushed { by, refs }`.

A caller's own Artifacts token is still passed on, so an agent that mints one is served as
before; a refused one gets the answer that names no repo.

Needs the kernel's host tokens and Basic at the boundary.

Session: claude 4bfd7dc5-ae25-44a2-9e97-71e8cda6eb3a on beelink
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NCuxgW9h7bArbVFYcg6ShA

Jonas Templestein, 2026-11-26 12:48 UTC · bc38a07eb93f62d00845a5a235aba295e0def5a1 · parent 86ecd7b

3 files changed

M README.md
@@ -17,6 +17,29 @@
 /repos/<name>/pull/<number>        one pull: its conversation and what it changes
 ```
 
+## Git on your computer
+
+A public repo is cloned with no sign-in. Any other repo, and every push, is for a member of the
+mind. Set git up once on a computer (it needs Node 22 or newer):
+
+```sh
+npx iterate git setup git.<domain>
+```
+
+It signs you in to the mind if this computer is not signed in (in a browser here, or with a link
+and a code for a browser on another device), and sets git's credential helper for this one host.
+After that, plain `git clone`, `git pull` and `git push` work, and nothing asks for a password.
+
+- A git that was never set up gets "there is no repo here that you can read" with that command,
+  for a repo that is not public and for a repo that does not exist alike.
+- When the sign-in has ended (it ends after seven days without use, or when a member ends it on
+  the mind's `/sessions` page), git says so and names the same command. With a person at the
+  terminal, git signs in again by itself and then goes on.
+- Git gets a token that is for this host alone and lasts an hour at most. No Artifacts token
+  leaves the mind: the app adds its own on the way to Artifacts.
+- An agent that still sends an Artifacts token of its own (`itx.cfArtifacts`) is served as before.
+- Who pushed which refs is on the repo's log: `git/pushed { by, refs }`.
+
 ## Propose a change
 
 ```sh
M app.ts
@@ -19,20 +19,33 @@
 // (what a pull is), and public/ (what the browser runs).
 //
 // WHO MAY READ. A repo that worker.ts lists as public is for anyone: its pages, its pulls, and a
-// clone with no credential. Any other repo's pages are for a member of the mind, and git needs
-// the caller's own Artifacts token for it. A push needs that token for every repo.
+// clone with no credential. Any other repo's pages, and git on it, are for a member of the mind.
+// A push is a member's, on every repo.
 //
 // WHO MAY WRITE. A member alone opens a pull, comments and merges: the page does each through the
 // member's own `itx` (public/mind.js, over the socket that `host.auth.memberPage` answers), so the
 // platform records who did it. This file writes nothing of a pull.
 //
-// THE REMOTE IS A PASS-THROUGH. Each of git's three requests goes to the repo's Cloudflare
-// Artifacts remote as it came, body streamed, answer streamed back. The app adds three things.
-// The address is the mind's own. For a public repo it adds a read token of its own, minted once
-// and kept while it lasts. And after a push that moved `main` it tells the mind's repo, which is
-// how the mind comes to publish a push to a repo that was made after the deploy. Artifacts checks
-// every token, not this file.
+// WHO GIT IS. The platform says it, as for a page: git sends a token of the mind for this one
+// host, which the `iterate` CLI's credential helper hands it (`npx iterate git setup <host>`),
+// and the boundary checks that token on every request and stamps the member. This file reads the
+// stamp. A sign-in that ended, or a member who was removed, has no stamp at the next request.
 //
+// THE REMOTE. Each of git's three requests goes to the repo's Cloudflare Artifacts remote, body
+// streamed, answer streamed back, WITH A TOKEN OF THE APP'S OWN: a read token that is minted once
+// and kept while it lasts, or a write token that is minted for the one request of a push. A
+// member's git never sees an Artifacts token. After a push the app writes who pushed which refs
+// on the repo's log (`git/pushed`), and after one that moved `main` it tells the mind's repo,
+// which is how the mind comes to publish a push to a repo that was made after the deploy.
+//
+// A CALLER'S OWN ARTIFACTS TOKEN IS STILL PASSED ON, as before the helper: an agent that minted
+// one with `itx.cfArtifacts` sends it as its credential, and Artifacts checks it. That way out
+// goes when no agent uses it any more.
+//
+// WHAT A REQUEST WITH NO SIGN-IN IS TOLD is the same for a repo that is not public and for no
+// repo at all, so the answer says nothing of what exists (`refusal`). Every refusal is on git's
+// first request and is plain text: git shows those words, and shows none for a later request.
+//
 // THE READ TOKEN IS KEPT IN THE MIND'S KV, not in memory: most connections get a new isolate, so
 // memory alone would mint a token for almost every clone. A kv read takes 12 to 32 ms, a mint 150
 // (measured on tthq.app, 24 Nov 2026). What stops a push is Artifacts' own limit of 64 MiB a
@@ -71,23 +84,30 @@
 const GIT_PATH =
   /^(\/repos\/[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*?)\/(info\/refs|git-upload-pack|git-receive-pack)$/;
 
-/** What git sends that Artifacts needs. A cookie or a stamp of the mind's never leaves. */
+/** What git sends that Artifacts needs. A cookie or a stamp of the mind's never leaves, and the
+ *  credential that goes is set by `remote`. */
 const REQUEST_HEADERS = [
   "accept",
   "accept-encoding",
-  "authorization",
   "content-encoding",
   "content-type",
   "git-protocol",
   "user-agent",
 ];
-const ANSWER_HEADERS = ["cache-control", "content-type", "expires", "pragma", "www-authenticate"];
+/** Never Artifacts' own challenge: it would have git ask a person for a password. */
+const ANSWER_HEADERS = ["cache-control", "content-type", "expires", "pragma"];
 
-/** A mint is billed: one token serves every anonymous read of the repo for this long. */
+/** A mint is billed: one token serves every read of the repo for this long. */
 const READ_TOKEN_SECONDS = 3600;
+/** A write token is for the one request it was minted for, and is kept nowhere. */
+const WRITE_TOKEN_SECONDS = 300;
 
+/** The header that `iterate git setup` has git send (iterate/cli git.ts `GIT_MARKER_HEADER`): this
+ *  git has the credential helper. It is public and proves nothing. */
+const HELPER_MARKER = "x-iterate-git";
+
 /** What the app keeps of a repo, in the mind's kv under `git-app:<repo>`: where Artifacts serves
- *  it, and for a public repo a read token and the moment that token ends. */
+ *  it, and a read token with the moment that token ends. */
 const Kept = z.object({
   remote: z.string(),
   readToken: z.object({ authorization: z.string(), until: z.number() }).optional(),
@@ -172,30 +192,36 @@
   const service = verb === "info/refs" ? url.searchParams.get("service") : verb;
   if (service !== "git-upload-pack" && service !== "git-receive-pack")
     return new Response("git: only smart HTTP is served here\n", { status: 403 });
+  const write = service === "git-receive-pack";
 
+  // a member, as the boundary stamped them; another mind's stamp is no member's
+  const stamped = host.auth.principal(request);
+  const member = stamped && stamped.kind !== "mind" ? stamped : null;
+  // what the boundary did not take as a token of its own is still here
+  const presented = request.headers.get("authorization");
+  const ownToken = !member && presented && isArtifactsToken(presented) ? presented : null;
+  const anonymousRead = !write && publicRepos.includes(repo);
+  if (!member && !ownToken && !anonymousRead) return refusal(request, url, presented);
+
   const headers = new Headers();
   for (const name of REQUEST_HEADERS) {
     const value = request.headers.get(name);
     if (value) headers.set(name, value);
   }
-  const anonymousRead =
-    !headers.has("authorization") && service === "git-upload-pack" && publicRepos.includes(repo);
-
   const now = Date.now();
-  let kept: z.infer<typeof Kept>;
+  let target: string;
   try {
     using itx = host.getItx();
     const text = await itx.kv.get(`git-app:${repo}`);
     const found = text ? Kept.parse(JSON.parse(text)) : null;
     // a token that ends within a minute could end in the middle of this clone
     const tokenLasts = Boolean(found?.readToken && found.readToken.until > now + 60_000);
-    // a request with its own token needs the remote alone; an anonymous read needs the token too
-    const enough = anonymousRead ? tokenLasts : true;
-    if (found && enough) kept = found;
-    else {
+    const needsReadToken = !write && !ownToken;
+    let kept = found;
+    if (!kept || (needsReadToken && !tokenLasts)) {
       const artifacts = await itx.cfArtifacts.get(repo);
       kept = { remote: found ? found.remote : await artifacts.remote() };
-      if (anonymousRead) {
+      if (needsReadToken) {
         const token = await artifacts.createToken("read", READ_TOKEN_SECONDS);
         kept.readToken = {
           authorization: `Basic ${btoa(`x:${token.plaintext}`)}`,
@@ -204,34 +230,99 @@
       }
       await itx.kv.put(`git-app:${repo}`, JSON.stringify(kept));
     }
+    target = kept.remote;
+    if (ownToken) headers.set("authorization", ownToken);
+    else if (write) {
+      const token = await (await itx.cfArtifacts.get(repo)).createToken("write", WRITE_TOKEN_SECONDS);
+      headers.set("authorization", `Basic ${btoa(`x:${token.plaintext}`)}`);
+    } else headers.set("authorization", kept.readToken!.authorization);
   } catch (error) {
+    // only a member is told that a repo is not there, or was not read
+    if (!member) return refusal(request, url, presented);
     const message = error instanceof Error ? error.message : String(error);
     return new Response(`git: no repo at ${repo} (${message})\n`, {
       status: /not found|10200/i.test(message) ? 404 : 502,
     });
   }
-  if (anonymousRead && kept.readToken) headers.set("authorization", kept.readToken.authorization);
 
-  const upstream = await fetch(`${kept.remote}/${verb}${url.search}`, {
+  const upstream = await fetch(`${target}/${verb}${url.search}`, {
     method: request.method,
     headers,
     body: request.body,
     redirect: "manual",
   });
+  // Artifacts refused the caller's own token: the app's answer, which names no repo
+  if (ownToken && [401, 403, 404].includes(upstream.status)) return refusal(request, url, presented);
   const answerHeaders = new Headers();
   for (const name of ANSWER_HEADERS) {
     const value = upstream.headers.get(name);
     if (value) answerHeaders.set(name, value);
   }
-  // A PUSH THAT MOVED MAIN: the repo is told, so the mind publishes what was pushed. Git's report
-  // of a push is small, so it is read whole and passed on as it came.
+  // A PUSH: git's report is small, so it is read whole and passed on as it came. Who pushed is
+  // written on the repo's log, and a push that moved main is told to the repo, so the mind
+  // publishes what was pushed.
   if (verb === "git-receive-pack" && upstream.ok) {
     const report = await upstream.arrayBuffer();
-    if (new TextDecoder().decode(report).includes("ok refs/heads/main\n"))
-      await tellOfNewTip(host, repo);
+    const refs = [...new TextDecoder().decode(report).matchAll(/ok (refs\/\S+)\n/g)].map(
+      (line) => line[1]!,
+    );
+    if (member && refs.length > 0) await recordPush(host, repo, member.email || member.actor, refs);
+    if (refs.includes("refs/heads/main")) await tellOfNewTip(host, repo);
     return new Response(report, { status: upstream.status, headers: answerHeaders });
   }
   return new Response(upstream.body, { status: upstream.status, headers: answerHeaders });
+}
+
+/** Whether a credential is a Cloudflare Artifacts token (`art_…`), as a bearer or as the password
+ *  of Basic: the one credential of a caller's own that the app passes on. */
+function isArtifactsToken(authorization: string): boolean {
+  const [scheme, value = ""] = authorization.split(/ +/, 2);
+  if (scheme?.toLowerCase() === "bearer") return value.startsWith("art_");
+  if (scheme?.toLowerCase() !== "basic") return false;
+  try {
+    const pair = atob(value);
+    return pair.slice(pair.indexOf(":") + 1).startsWith("art_");
+  } catch {
+    return false;
+  }
+}
+
+/** WHAT A REQUEST THAT IS NO MEMBER'S IS TOLD, the same whether the repo is there or not:
+ *
+ *    a credential came, and nobody took it    401, "this sign-in has ended": git forgets the token
+ *    no credential, the helper's marker       401 with a challenge: git asks the helper
+ *    no credential, no marker                 404, with the command that sets the helper up
+ *
+ *  Git shows a 404's words and a refused credential's, and never a first 401's: so a git with no
+ *  helper gets the 404, which is the only way to put its next step on the screen. The challenge
+ *  is `Basic`, never the platform's `Bearer realm="iterate"`, which the boundary would turn into
+ *  a sign-in page. */
+function refusal(request: Request, url: URL, presented: string | null): Response {
+  const setup = `  npx iterate git setup ${url.hostname}\n`;
+  const plain = { "content-type": "text/plain; charset=utf-8", "cache-control": "no-store" };
+  const challenge = { ...plain, "www-authenticate": 'Basic realm="iterate git"' };
+  if (presented)
+    return new Response(
+      `iterate: this sign-in has ended or was taken away.\nSign in again, then run the same command:\n${setup}`,
+      { status: 401, headers: challenge },
+    );
+  if (request.headers.has(HELPER_MARKER))
+    return new Response("iterate: sign in to read this repo\n", { status: 401, headers: challenge });
+  return new Response(
+    `iterate: there is no repo here that you can read.\nIf it is private, sign in once, then run the same command again:\n${setup}`,
+    { status: 404, headers: plain },
+  );
+}
+
+/** Writes who pushed which refs on the repo's log. Artifacts knows a token and no person, so
+ *  nothing else says it. A failure is reported and the push stands. */
+async function recordPush(host: Host, repo: string, by: string, refs: string[]): Promise<void> {
+  try {
+    using itx = host.getItx();
+    await itx.cd(repo).append({ type: "git/pushed", payload: { by, refs } });
+  } catch (error) {
+    reportIssue("git-app.push-not-recorded", error, { repo });
+  }
 }
 
 /** Tells a repo of the mind that its main has a new tip. Cloudflare tells the mind of a push too,
M tests/app.test.mjs
@@ -47,27 +47,18 @@
   assert.deepEqual(Object.keys(mind.kv), ["git-app:/repos/kernel"]);
 });
 
-test("a repo that is not listed as public is read with the caller's own token, and with none it gets the remote's 401", async () => {
+test("a member's git reads a repo that is not public with a read token of the app's own, and the member's credential never leaves", async () => {
   await using remote = await artifactsRemote();
   const mind = fakeMind(remote);
   const git = gitApp({ public: ["/repos/kernel"], ...look });
 
-  const refused = await git.fetch(
-    new Request("https://git.example.com/repos/config/info/refs?service=git-upload-pack"),
-    mind,
-  );
-  assert.equal(refused.status, 401);
-  // git asks for a password when it reads this header
-  assert.equal(refused.headers.get("www-authenticate"), 'Basic realm="artifacts"');
-
-  const own = `Basic ${btoa("misha:the-callers-own-token")}`;
-  const allowed = await git.fetch(
+  const refs = await git.fetch(
     new Request("https://git.example.com/repos/config.git/info/refs?service=git-upload-pack", {
-      headers: { authorization: own, cookie: "session=of-the-mind", "git-protocol": "version=2" },
+      headers: { ...asMember, cookie: "session=of-the-mind", "git-protocol": "version=2" },
     }),
     mind,
   );
-  assert.equal(allowed.status, 200);
+  assert.equal(refs.status, 200);
   assert.deepEqual(
     remote.requests.map(({ url, authorization, cookie, gitProtocol }) => ({
       url,
@@ -78,53 +69,169 @@
     [
       {
         url: "/remote/config/info/refs?service=git-upload-pack",
-        authorization: undefined,
-        cookie: undefined,
-        gitProtocol: undefined,
-      },
-      {
-        url: "/remote/config/info/refs?service=git-upload-pack",
-        authorization: own,
+        authorization: `Basic ${btoa("x:read-token-1-of-/repos/config")}`,
         // a cookie of the mind's never leaves; what git says of its protocol does
         cookie: undefined,
         gitProtocol: "version=2",
       },
     ],
   );
-  assert.deepEqual(mind.minted, []);
+  assert.deepEqual(mind.minted, [{ repo: "/repos/config", scope: "read", ttlSeconds: 3600 }]);
 });
 
-test("a push needs the caller's own token, to a public repo too: the app adds none", async () => {
+test("a member's push goes with a write token minted for that one request, and the repo's log says who pushed what", async () => {
   await using remote = await artifactsRemote();
   const mind = fakeMind(remote);
   const git = gitApp({ public: ["/repos/kernel"], ...look });
 
-  const refused = await git.fetch(
-    new Request("https://git.example.com/repos/kernel/info/refs?service=git-receive-pack"),
+  const refs = await git.fetch(
+    new Request("https://git.example.com/repos/kernel/info/refs?service=git-receive-pack", {
+      headers: asMember,
+    }),
     mind,
   );
-  assert.equal(refused.status, 401);
-
-  const own = `Basic ${btoa("x:a-write-token")}`;
+  assert.equal(refs.status, 200);
   const pushed = await git.fetch(
     new Request("https://git.example.com/repos/kernel/git-receive-pack", {
       method: "POST",
-      headers: { authorization: own },
-      body: "the pack",
+      headers: asMember,
+      body: "the pack, for refs/heads/add-b",
     }),
     mind,
   );
-  assert.equal(await pushed.text(), "unpack ok\n");
+  assert.equal(await pushed.text(), "unpack ok\nok refs/heads/add-b\n");
   assert.deepEqual(
     remote.requests.map(({ url, authorization }) => ({ url, authorization })),
     [
-      { url: "/remote/kernel/info/refs?service=git-receive-pack", authorization: undefined },
-      { url: "/remote/kernel/git-receive-pack", authorization: own },
+      {
+        url: "/remote/kernel/info/refs?service=git-receive-pack",
+        authorization: `Basic ${btoa("x:write-token-1-of-/repos/kernel")}`,
+      },
+      {
+        url: "/remote/kernel/git-receive-pack",
+        authorization: `Basic ${btoa("x:write-token-2-of-/repos/kernel")}`,
+      },
     ],
   );
+  assert.deepEqual(mind.minted, [
+    { repo: "/repos/kernel", scope: "write", ttlSeconds: 300 },
+    { repo: "/repos/kernel", scope: "write", ttlSeconds: 300 },
+  ]);
+  // no write token is kept
+  assert.doesNotMatch(JSON.stringify(mind.kv), /write-token/);
+  assert.deepEqual(mind.appended, [
+    {
+      path: "/repos/kernel",
+      event: { type: "git/pushed", payload: { by: "ada@example.com", refs: ["refs/heads/add-b"] } },
+    },
+  ]);
+});
+
+test("with no sign-in, a repo that is not public and a repo that is not there get the same answer, and so does a push", async () => {
+  await using remote = await artifactsRemote();
+  const mind = fakeMind(remote);
+  const git = gitApp({ public: ["/repos/kernel"], ...look });
+  const asked = async (path, headers = {}) => {
+    const answer = await git.fetch(new Request(`https://git.example.com${path}`, { headers }), mind);
+    return {
+      status: answer.status,
+      challenge: answer.headers.get("www-authenticate"),
+      type: answer.headers.get("content-type"),
+      text: await answer.text(),
+    };
+  };
+  const read = "/info/refs?service=git-upload-pack";
+
+  // A GIT WITH NO HELPER: a 404, whose words git shows, with the command to run
+  const fresh = await asked(`/repos/config${read}`);
+  assert.deepEqual(fresh, {
+    status: 404,
+    challenge: null,
+    type: "text/plain; charset=utf-8",
+    text: "iterate: there is no repo here that you can read.\nIf it is private, sign in once, then run the same command again:\n  npx iterate git setup git.example.com\n",
+  });
+  assert.deepEqual(await asked(`/repos/missing${read}`), fresh);
+  assert.deepEqual(await asked("/repos/kernel/info/refs?service=git-receive-pack"), fresh);
+
+  // A GIT WITH THE HELPER and no credential yet: a 401, so git asks the helper
+  const marked = { "x-iterate-git": "1" };
+  const challenged = await asked(`/repos/config${read}`, marked);
+  assert.deepEqual(
+    { status: challenged.status, challenge: challenged.challenge },
+    { status: 401, challenge: 'Basic realm="iterate git"' },
+  );
+  assert.deepEqual(await asked(`/repos/missing${read}`, marked), challenged);
+
+  // A CREDENTIAL THAT THE BOUNDARY DID NOT TAKE (a sign-in that ended): a 401 with words, and git
+  // forgets the token
+  const ended = { ...marked, authorization: `Basic ${btoa("iterate:a-token-that-ended")}` };
+  const refused = await asked(`/repos/config${read}`, ended);
+  assert.deepEqual(refused, {
+    status: 401,
+    challenge: 'Basic realm="iterate git"',
+    type: "text/plain; charset=utf-8",
+    text: "iterate: this sign-in has ended or was taken away.\nSign in again, then run the same command:\n  npx iterate git setup git.example.com\n",
+  });
+  assert.deepEqual(await asked(`/repos/missing${read}`, ended), refused);
+
+  // nothing was asked of Artifacts, and nothing was minted or kept
+  assert.deepEqual(remote.requests, []);
   assert.deepEqual(mind.minted, []);
+  assert.deepEqual(mind.kv, {});
 });
 
+test("a public repo is still read by a git whose sign-in ended", async () => {
+  await using remote = await artifactsRemote();
+  const mind = fakeMind(remote);
+  const git = gitApp({ public: ["/repos/kernel"], ...look });
+
+  const refs = await git.fetch(
+    new Request("https://git.example.com/repos/kernel/info/refs?service=git-upload-pack", {
+      headers: { authorization: `Basic ${btoa("iterate:a-token-that-ended")}` },
+    }),
+    mind,
+  );
+  assert.equal(refs.status, 200);
+  assert.equal(remote.requests[0].authorization, `Basic ${btoa("x:read-token-1-of-/repos/kernel")}`);
+});
+
+test("a caller's own Artifacts token is passed on as it came, and one that Artifacts refuses gets the answer that names no repo", async () => {
+  await using remote = await artifactsRemote();
+  const mind = fakeMind(remote);
+  const git = gitApp({ public: [], ...look });
+  const own = "Bearer art_v2_the-callers-own";
+
+  const pushed = await git.fetch(
+    new Request("https://git.example.com/repos/kernel/git-receive-pack", {
+      method: "POST",
+      headers: { authorization: own },
+      body: "the pack, for refs/heads/main",
+    }),
+    mind,
+  );
+  assert.equal(await pushed.text(), "unpack ok\nok refs/heads/main\n");
+  assert.equal(remote.requests[0].authorization, own);
+  assert.deepEqual(mind.minted, []);
+  // Artifacts knows a token and no person: nobody is written as the one who pushed
+  assert.deepEqual(mind.appended, []);
+  assert.deepEqual(mind.announced, ["/repos/kernel"]);
+
+  const read = "/info/refs?service=git-upload-pack";
+  const refusedBy = async (path) => {
+    const answer = await git.fetch(
+      new Request(`https://git.example.com${path}`, {
+        headers: { authorization: `Basic ${btoa("x:art_v2_refused")}` },
+      }),
+      mind,
+    );
+    return [answer.status, await answer.text()];
+  };
+  const refused = await refusedBy(`/repos/config${read}`);
+  assert.equal(refused[0], 401);
+  assert.match(refused[1], /^iterate: this sign-in has ended/);
+  assert.deepEqual(await refusedBy(`/repos/missing${read}`), refused);
+});
+
 test("a push that moved main tells the mind's repo, so the mind publishes what was pushed; a push of another branch tells it nothing", async () => {
   await using remote = await artifactsRemote();
   const mind = fakeMind(remote);
@@ -133,7 +240,7 @@
     git.fetch(
       new Request("https://git.example.com/repos/kernel/git-receive-pack", {
         method: "POST",
-        headers: { authorization: `Basic ${btoa("x:a-write-token")}` },
+        headers: asMember,
         body: `the pack, for ${ref}`,
       }),
       mind,
@@ -149,7 +256,7 @@
   assert.deepEqual(mind.announced, ["/repos/kernel"]);
 });
 
-test("a push stands when the mind's repo could not be told: git gets the remote's report", async () => {
+test("a push stands when the mind's repo could not be told, or its log not written: git gets the remote's report", async () => {
   await using remote = await artifactsRemote();
   const mind = fakeMind(remote);
   mind.away.add("/repos/kernel");
@@ -158,7 +265,7 @@
   const pushed = await git.fetch(
     new Request("https://git.example.com/repos/kernel/git-receive-pack", {
       method: "POST",
-      headers: { authorization: `Basic ${btoa("x:a-write-token")}` },
+      headers: asMember,
       body: "the pack, for refs/heads/main",
     }),
     mind,
@@ -167,6 +274,7 @@
   assert.equal(pushed.status, 200);
   assert.equal(await pushed.text(), "unpack ok\nok refs/heads/main\n");
   assert.deepEqual(mind.announced, []);
+  assert.deepEqual(mind.appended, []);
 });
 
 test("a read token that is about to end is replaced, and the repo's remote is not asked for again", async () => {
@@ -210,13 +318,15 @@
   assert.deepEqual(mind.kv, {});
 });
 
-test("a repo the mind does not have is not found", async () => {
+test("a member is told when the mind has no such repo", async () => {
   await using remote = await artifactsRemote();
   const mind = fakeMind(remote);
   const git = gitApp({ public: ["/repos/kernel"], ...look });
 
   const answer = await git.fetch(
-    new Request("https://git.example.com/repos/missing/info/refs?service=git-upload-pack"),
+    new Request("https://git.example.com/repos/missing/info/refs?service=git-upload-pack", {
+      headers: asMember,
+    }),
     mind,
   );
   assert.equal(answer.status, 404);
@@ -229,14 +339,20 @@
 /** What worker.ts hands the app for its pages, which no test here reads. */
 const look = { icon: () => new Response("the icon") };
 
+/** A request that the boundary stamped as a member's: the fake mind reads this header in the
+ *  stamp's place (`fakeMind`). */
+const asMember = { "x-test-member": "ada@example.com" };
+
 /** The mind as the app reaches it: a kv, and the Artifacts repos `kernel` and `config`, served
  *  by `remote`. It records each token it mints, each repo whose remote it was asked for, and each
- *  repo that was told its main has a new tip. A repo in `away` throws when it is told. */
+ *  repo that was told its main has a new tip, and each event appended to a repo's log. A repo in
+ *  `away` throws when it is told or written to. */
 function fakeMind(remote) {
   const kv = {};
   const minted = [];
   const remotesAsked = [];
   const announced = [];
+  const appended = [];
   const away = new Set();
   const repos = ["/repos/kernel", "/repos/config"];
   const itx = {
@@ -269,6 +385,12 @@
         },
       }),
     },
+    cd: (path) => ({
+      append: async (event) => {
+        if (away.has(path)) throw new Error(`the repo ${path} is away`);
+        appended.push({ path, event });
+      },
+    }),
     [Symbol.dispose]() {},
   };
   // what is no git request is asked whether it is a member's socket: here none is
@@ -277,15 +399,23 @@
     minted,
     remotesAsked,
     announced,
+    appended,
     away,
     getItx: () => itx,
-    auth: { memberPage: () => null },
+    auth: {
+      memberPage: () => null,
+      // the boundary's stamp, which the tests write as a header of their own
+      principal: (request) => {
+        const email = request.headers.get("x-test-member");
+        return email ? { actor: "user_ada", email } : null;
+      },
+    },
   };
 }
 
 /** A repo's Artifacts remote: a server on this machine that records each request and answers as
- *  git's smart HTTP does in outline. A request with no credential gets Artifacts' own 401, but
- *  for a read with a read token or any request with a caller's token. */
+ *  git's smart HTTP does in outline. A request with no credential, or with the one token that
+ *  the tests call refused, gets Artifacts' own 401. */
 async function artifactsRemote() {
   // Node's fetch wants `duplex: "half"` said for a body that is a stream, which the app's is.
   // workerd, where the app runs, takes a stream as it is.
@@ -304,7 +434,9 @@
       cookie: request.headers.cookie,
       gitProtocol: request.headers["git-protocol"],
     });
-    if (!request.headers.authorization) {
+    const credential = request.headers.authorization || "";
+    const refused = credential.includes("refused") || credential === `Basic ${btoa("x:art_v2_refused")}`;
+    if (!credential || refused) {
       response.writeHead(401, { "www-authenticate": 'Basic realm="artifacts"' }).end();
       return;
     }