iterate.com / kernel

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

The token verbs say what Artifacts did on a dev mind: the list holds live tokens, and a second revocation is true

Measured on blinvo.com, 26 Nov 2026: a token that ended by its date or by revokeToken is
not in listTokens, and revokeToken answers true again for it. So the second attempt after a
lost answer needs no read of the list, which could never have shown the token. The words of
the type, the description and the test's stand-in follow.

Session: claude 4bfd7dc5-ae25-44a2-9e97-71e8cda6eb3a on beelink

Tests: core/mind-worker/src/context/cf-artifacts.test.ts
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NCuxgW9h7bArbVFYcg6ShA

Jonas Templestein, 2026-11-26 17:07 UTC · a58025aafeff8181e269264024ecf62ccf1e993c · parent c0f9c35

4 files changed

M core/lib/src/api.ts
@@ -1073,7 +1073,7 @@
   expiresAt?: string;
 }
 
-/** What Artifacts keeps of a token after the mint: never its text. */
+/** What Artifacts says of a token after the mint: never its text. */
 export interface ArtifactTokenInfo {
   id: string;
   scope: "read" | "write";
@@ -1087,11 +1087,12 @@
  *  these, with the binding's own error. */
 export interface CfArtifactRepoApi {
   createToken(scope: "read" | "write", ttlSeconds: number): Promise<ArtifactToken>;
-  /** Every token of this repo, the ended ones too, with no token's text. */
+  /** The tokens of this repo that still open it, with no token's text. One that ended, by its
+   *  date or by `revokeToken`, is not listed. */
   listTokens(): Promise<{ tokens: ArtifactTokenInfo[]; total: number }>;
   /** Ends one token of this repo, by its id. A token's text is refused: pass none, a script's
-   *  source is on its caller's log. False when the repo has no token of that id that could be
-   *  ended. */
+   *  source is on its caller's log. True also for a token that has ended already; false when the
+   *  repo never had a token of that id. */
   revokeToken(id: string): Promise<boolean>;
   remote(): Promise<string>;
 }
M core/mind-worker/src/context/cf-artifacts.test.ts
@@ -1,5 +1,6 @@
 // A repo's tokens through `itx.cfArtifacts.get(path)` (./cf-artifacts.ts), against a stand-in for
-// the Artifacts binding that keeps each repo's tokens apart, as Artifacts does.
+// the Artifacts binding that answers as Artifacts did on a dev mind (26 Nov 2026): each repo's
+// tokens apart, an ended token not listed, and true again for a second revocation.
 import { expect, test } from "vitest";
 import { type ArtifactsNamespace, mindScopedArtifacts } from "./cf-artifacts.ts";
 
@@ -23,11 +24,9 @@
   expect(JSON.stringify(listed)).not.toContain("note");
 
   expect(await config.revokeToken(minted.id!)).toBe(true);
-  expect((await config.listTokens()).tokens.map(({ state }) => state)).toEqual([
-    "revoked",
-    "active",
-  ]);
-  // a second time, and an id that the repo never had: not found
+  // an ended token is not listed
+  expect((await config.listTokens()).tokens.map(({ id }) => id)).toEqual(["tok_2"]);
+  // an id that the repo never had: not found
   expect(await config.revokeToken("tok_9")).toBe(false);
 });
 
@@ -43,7 +42,7 @@
   expect((await config.listTokens()).tokens[0]!.state).toBe("active");
 });
 
-test("a revocation whose answer was lost is true when the token is ended, and false for an id that the repo has not", async () => {
+test("a revocation whose answer was lost is asked again, and is true for the token that the first attempt ended", async () => {
   const store = storeOf(["repos--config"]);
   const config = await mindScopedArtifacts({ namespace: store.namespace }).get("/repos/config");
   const minted = await config.createToken("write", 300);
@@ -89,6 +88,7 @@
     async get(name: string) {
       const rows = repos.get(name);
       if (!rows) throw new Error(`Repository not found: ${name}`);
+      const live = () => rows.filter((row) => row.state === "active");
       return {
         info: async () => ({ remote: `https://artifacts.test/${name}.git` }),
         async createToken(scope: "read" | "write") {
@@ -97,7 +97,7 @@
           return { id: row.id, plaintext: row.text, scope, expiresAt: EXPIRES };
         },
         listTokens: async () => ({
-          tokens: rows.map(({ id, scope, state }) => ({
+          tokens: live().map(({ id, scope, state }) => ({
             id,
             scope,
             state,
@@ -105,11 +105,11 @@
             expiresAt: EXPIRES,
             note: "a field of a later version",
           })),
-          total: rows.length,
+          total: live().length,
         }),
         async revokeToken(tokenOrId: string) {
           revokeAsked.push(tokenOrId);
-          const row = rows.find((row) => row.id === tokenOrId && row.state === "active");
+          const row = rows.find((row) => row.id === tokenOrId);
           if (row) row.state = "revoked";
           if (answerIsLost) {
             answerIsLost = false;
M core/mind-worker/src/context/cf-artifacts.ts
@@ -50,9 +50,10 @@
       ),
     );
   }
-  // What Artifacts keeps of each token of this repo, and never a token's text: Artifacts has none
-  // after the mint. Each row is copied field by field, so a field that Artifacts adds later does
-  // not leave the mind unread.
+  // The tokens of this repo that still open it, and never a token's text: Artifacts has none after
+  // the mint. A token that ended, by its date or by `revokeToken`, is not in the list (measured on
+  // a dev mind, 26 Nov 2026). Each row is copied field by field, so a field that Artifacts adds
+  // later does not leave the mind unread.
   async listTokens() {
     const { tokens, total } = await retryingOnePlatformFailure("listTokens", this.#name, () =>
       withArtifactRepoHandle(this.#namespace, this.#name, "listTokens", (handle) =>
@@ -73,30 +74,19 @@
   // BY ITS ID ALONE. The binding takes a token's text too, and this refuses one, so that no caller
   // learns to pass a token here: a script's source is on the caller's log before this runs, and
   // nothing here can take a token out of it. The handle is this repo's, so an id of another
-  // repo's token is not found here: false.
+  // repo's token is not found here: false. SAFE TO RUN TWICE: Artifacts answers true again for a
+  // token that has ended (measured on a dev mind, 26 Nov 2026), so a second attempt after a lost
+  // answer says the same as the first would have.
   async revokeToken(id: string) {
     if (typeof id !== "string" || !TOKEN_ID.test(id) || id.startsWith("art_"))
       throw refusal(
         "revokeToken takes a token's id, as listTokens() and createToken() answer it, and never the token itself",
       );
-    return await retryingOnePlatformFailure("revokeToken", this.#name, async (isRetry) => {
-      const revoked = await withArtifactRepoHandle(
-        this.#namespace,
-        this.#name,
-        "revokeToken",
-        (handle) => handle.revokeToken(id),
-      );
-      // The first attempt's answer was lost, and it may have landed: then the second finds
-      // nothing to end. The list says whether the token is ended.
-      if (revoked || !isRetry) return revoked;
-      const { tokens } = await withArtifactRepoHandle(
-        this.#namespace,
-        this.#name,
-        "listTokens",
-        (handle) => handle.listTokens(),
-      );
-      return tokens.some((token) => token.id === id && token.state === "revoked");
-    });
+    return await retryingOnePlatformFailure("revokeToken", this.#name, () =>
+      withArtifactRepoHandle(this.#namespace, this.#name, "revokeToken", (handle) =>
+        handle.revokeToken(id),
+      ),
+    );
   }
   async remote() {
     const { remote } = await retryingOnePlatformFailure("remote", this.#name, () =>
M core/mind-worker/src/itx-host.ts
@@ -138,7 +138,7 @@
       },
       cfArtifacts: {
         description:
-          "the Artifacts binding, mind-scoped (`repos` is the friendlier surface); a repo's tokens: `(await cfArtifacts.get(path)).createToken(scope, ttlSeconds)` · `listTokens()` → { tokens: [{ id, scope, state, createdAt, expiresAt }], total }, never a token's text · `revokeToken(id)`",
+          "the Artifacts binding, mind-scoped (`repos` is the friendlier surface); a repo's tokens: `(await cfArtifacts.get(path)).createToken(scope, ttlSeconds)` · `listTokens()` → { tokens: [{ id, scope, state, createdAt, expiresAt }], total }, the live ones, never a token's text · `revokeToken(id)`",
         build: () => mindScopedArtifacts({ namespace: env.ARTIFACTS }),
       },
       r2: {