gentle-pi 3.2.0 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,14 +20,14 @@ import {
20
20
  trustedSystemExtractor,
21
21
  } from "../scripts/gentle-ai-installer.mjs";
22
22
 
23
- // v3.1.0 digests pinned from the published release: archive digests verified
23
+ // v3.2.1 digests pinned from the published release: archive digests verified
24
24
  // against the minisign-signed checksums.txt and freshly computed hashes; binary
25
25
  // digests computed from the extracted executables.
26
26
  const EXPECTED_ASSETS = {
27
- "darwin/amd64": { name: "gentle-ai_3.1.0_darwin_amd64.tar.gz", sha256: "613f0e11adeebb421daae4c68cb9f207f55c559a70595549ff25f988559226e4", binarySha256: "98340df0102825072431a2c0373ea4d9db1bacafced234f51fb58661ed3d731f" },
28
- "darwin/arm64": { name: "gentle-ai_3.1.0_darwin_arm64.tar.gz", sha256: "bfcbf8df2682fcf1535b26c604e8dbb445df0ca00a651de204fdc2d013dfe472", binarySha256: "3cdc9689ea0d71186b896341b4181e2df13a82b64d236a26a3273171150d802f" },
29
- "linux/amd64": { name: "gentle-ai_3.1.0_linux_amd64.tar.gz", sha256: "dc55c44a2eb46212a38eca0dfd4d778481ec37e765f40d5a0752d03c28e1ee49", binarySha256: "70e335d25809a0d358c12f48b2f0d1da00741e725584ceeb8c1318c60d0a6e9e" },
30
- "linux/arm64": { name: "gentle-ai_3.1.0_linux_arm64.tar.gz", sha256: "3a89d5f5a549004cc2b01949014ed59f9c28e1ff0c9958531bb539504286e407", binarySha256: "6cf9f20fc390b13e2b9b427ca1c2df404d1bbb9248201f9a592c7f0a37ef5416" },
27
+ "darwin/amd64": { name: "gentle-ai_3.2.1_darwin_amd64.tar.gz", sha256: "1696a4852435920ebae351a5173adead6da17db6762359dcb12dc3971d983c3f", binarySha256: "ed7d18b7446c63f265a827a736ed4465ec562cc3c07c470743d3740fb4d2f4a9" },
28
+ "darwin/arm64": { name: "gentle-ai_3.2.1_darwin_arm64.tar.gz", sha256: "e3a991a03c6fb6373f6a254b808c3fabf36330634d93704c9d9ba365467fc6f8", binarySha256: "2ae66cfa11f8ab93ea46c20e79bd191dedde40a4898f0b312330a0790f802ca3" },
29
+ "linux/amd64": { name: "gentle-ai_3.2.1_linux_amd64.tar.gz", sha256: "e2e3171377c040c27a93ae66b4adf824626f23cacd398b3b652af0d87ff65807", binarySha256: "3464525775b60cad6358a589c298a2d4098466bc0a5ae5f0d1e578ab10134659" },
30
+ "linux/arm64": { name: "gentle-ai_3.2.1_linux_arm64.tar.gz", sha256: "342c7fc60cf062730c8f593f09269f75485b3b1fa2907b2b188eafded1a0e222", binarySha256: "d2c4d8ebfdc681ceece254d0d12cd04dd7af3b435c945e42623e3475981c2f8f" },
31
31
  } as const;
32
32
 
33
33
  test("default installer package root is the package containing scripts, not its parent", () => {
@@ -38,15 +38,15 @@ test("default installer package root is the package containing scripts, not its
38
38
  assert.notEqual(resolveGentleAiInstallerPackageRoot(), dirname(expectedPackageRoot));
39
39
  });
40
40
 
41
- test("release mapping selects only the supported official v3.1.0 assets and pinned digests", () => {
41
+ test("release mapping selects only the supported official v3.2.1 assets and pinned digests", () => {
42
42
  assert.deepEqual(
43
43
  Object.fromEntries(Object.entries(GENTLE_AI_RELEASE_ASSETS).map(([key, asset]) => [key, { name: asset.name, sha256: asset.sha256, binarySha256: asset.binarySha256 }])),
44
44
  EXPECTED_ASSETS,
45
45
  );
46
- assert.equal(resolveGentleAiReleaseAsset("linux", "x64").name, "gentle-ai_3.1.0_linux_amd64.tar.gz");
47
- assert.equal(resolveGentleAiReleaseAsset("darwin", "arm64").name, "gentle-ai_3.1.0_darwin_arm64.tar.gz");
46
+ assert.equal(resolveGentleAiReleaseAsset("linux", "x64").name, "gentle-ai_3.2.1_linux_amd64.tar.gz");
47
+ assert.equal(resolveGentleAiReleaseAsset("darwin", "arm64").name, "gentle-ai_3.2.1_darwin_arm64.tar.gz");
48
48
  for (const asset of Object.values(GENTLE_AI_RELEASE_ASSETS)) {
49
- assert.match(asset.url, /^https:\/\/github\.com\/Gentleman-Programming\/gentle-ai\/releases\/download\/v3\.1\.0\//);
49
+ assert.match(asset.url, /^https:\/\/github\.com\/Gentleman-Programming\/gentle-ai\/releases\/download\/v3\.2\.1\//);
50
50
  }
51
51
  });
52
52
 
@@ -56,7 +56,7 @@ test("raw release assets are admitted only under a prerelease pin", () => {
56
56
  assert.equal(gentleAiAssetForm("gentle-ai_2.5.0-rc.3_windows_amd64.exe", "2.5.0-rc.3"), "raw-binary");
57
57
  // A raw binary under a stable pin means the pin itself is wrong: stable
58
58
  // releases publish signed archives only, so this fails closed pre-download.
59
- assert.throws(() => gentleAiAssetForm("gentle-ai_3.1.0_linux_amd64", "3.1.0"), /only admitted for a prerelease pin/);
59
+ assert.throws(() => gentleAiAssetForm("gentle-ai_3.2.1_linux_amd64", "3.2.1"), /only admitted for a prerelease pin/);
60
60
  assert.throws(() => gentleAiAssetForm("gentle-ai.dmg", "2.5.0-rc.3"), /unsupported Gentle AI release asset form/);
61
61
  // The current stable pin admits every pinned asset row through the same
62
62
  // gate the installer uses at download time (default installerVersion
@@ -83,7 +83,7 @@ test("release digests are all-or-none and install fails closed while any digest
83
83
  }),
84
84
  /checksum mismatch/,
85
85
  );
86
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v3.1.0", "gentle-ai")), false);
86
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v3.2.1", "gentle-ai")), false);
87
87
  }
88
88
  });
89
89
 
@@ -112,7 +112,7 @@ function windowsGoFixture(fixtureOptions: WindowsGoFixtureOptions = {}) {
112
112
  const metadata = [
113
113
  "gentle-ai.exe: go1.25.10",
114
114
  "\tpath\tgithub.com/gentleman-programming/gentle-ai/v3/cmd/gentle-ai",
115
- `\tmod\tgithub.com/gentleman-programming/gentle-ai/v3\tv3.1.0\t${GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM}`,
115
+ `\tmod\tgithub.com/gentleman-programming/gentle-ai/v3\tv3.2.1\t${GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM}`,
116
116
  "\tbuild\t-buildmode=exe", "\tbuild\t-compiler=gc", "\tbuild\tCGO_ENABLED=0", `\tbuild\tGOARCH=${fixtureOptions.goArchitecture ?? "amd64"}`, "\tbuild\tGOOS=windows",
117
117
  ].join("\n");
118
118
  const run = async (file: string, arguments_: string[], options: WindowsGoCall["options"]) => {
@@ -130,7 +130,7 @@ function windowsGoFixture(fixtureOptions: WindowsGoFixtureOptions = {}) {
130
130
  return { stdout: "", stderr: "" };
131
131
  }
132
132
  if (file === goExecutable && arguments_[0] === "version" && arguments_[1] === "-m") return { stdout: metadata, stderr: "" };
133
- if (arguments_.length === 1 && arguments_[0] === "version") return { stdout: fixtureOptions.reportedVersion ?? "gentle-ai 3.1.0\n", stderr: "" };
133
+ if (arguments_.length === 1 && arguments_[0] === "version") return { stdout: fixtureOptions.reportedVersion ?? "gentle-ai 3.2.1\n", stderr: "" };
134
134
  throw new Error(`unexpected command: ${file} ${arguments_.join(" ")}`);
135
135
  };
136
136
  return { calls, run, setGoExecutable: (path: string) => { goExecutable = path; } };
@@ -146,7 +146,7 @@ test("win32 x64 and arm64 install the exact Go SumDB source tag without archive
146
146
  const result = await installGentleAi({ packageRoot, platform: "win32", arch, execFile: fixture.run, resolveGoExecutable: async () => goPath });
147
147
  assert.equal(result.installed, true);
148
148
  assert.deepEqual(fixture.calls.filter((call) => call.file === goPath).map((call) => call.arguments_.slice(0, 2)), [
149
- ["version"], ["install", "github.com/gentleman-programming/gentle-ai/v3/cmd/gentle-ai@v3.1.0"], ["version", "-m"],
149
+ ["version"], ["install", "github.com/gentleman-programming/gentle-ai/v3/cmd/gentle-ai@v3.2.1"], ["version", "-m"],
150
150
  ]);
151
151
  }
152
152
  });
@@ -165,7 +165,7 @@ test("Windows source install reports missing or too-old Go without publishing a
165
165
  () => installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: async () => goPath }),
166
166
  (error: unknown) => error instanceof Error && "code" in error && error.code === fixtureOptions.expectedCode,
167
167
  );
168
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v3.1.0", "gentle-ai.exe")), false);
168
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v3.2.1", "gentle-ai.exe")), false);
169
169
  assert.deepEqual((await readdir(packageRoot)).filter((entry) => entry.includes("install-")), []);
170
170
  }
171
171
  });
@@ -184,7 +184,7 @@ test("Windows source install cleans staging after Go failure or wrong built vers
184
184
  () => installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: async () => goPath }),
185
185
  (error: unknown) => error instanceof Error && "code" in error && error.code === fixtureOptions.expectedCode,
186
186
  );
187
- const runtimeDirectory = join(packageRoot, ".gentle-ai", "v3.1.0");
187
+ const runtimeDirectory = join(packageRoot, ".gentle-ai", "v3.2.1");
188
188
  assert.ok(fixture.calls.some((call) => call.arguments_[0] === "install"));
189
189
  assert.equal(existsSync(join(runtimeDirectory, "gentle-ai.exe")), false);
190
190
  assert.equal(existsSync(runtimeDirectory) && (await readdir(runtimeDirectory)).some((entry) => entry.startsWith(".go-install-") || entry.endsWith(".tmp")), false);
@@ -205,7 +205,7 @@ test("Windows source installs reuse only a fully verified package-local binary",
205
205
  assert.equal(reused.installed, false);
206
206
  assert.ok(reuse.calls.every((call) => call.file !== "gentle-ai"), "the installer must never fall back to ambient gentle-ai on PATH");
207
207
 
208
- await writeFile(join(packageRoot, ".gentle-ai", "v3.1.0", "integrity.json"), "{}\n");
208
+ await writeFile(join(packageRoot, ".gentle-ai", "v3.2.1", "integrity.json"), "{}\n");
209
209
  const repaired = windowsGoFixture();
210
210
  repaired.setGoExecutable(goPath);
211
211
  assert.equal((await installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: repaired.run, resolveGoExecutable: async () => goPath })).installed, true);
@@ -247,7 +247,7 @@ async function hardenedWindowsGoFixture(packageRoot: string, fixtureOptions: Har
247
247
  const metadata = fixtureOptions.metadataOverride ?? [
248
248
  "gentle-ai.exe: go1.25.10",
249
249
  "\tpath\tgithub.com/gentleman-programming/gentle-ai/v3/cmd/gentle-ai",
250
- `\tmod\tgithub.com/gentleman-programming/gentle-ai/v3\tv3.1.0\t${GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM}`,
250
+ `\tmod\tgithub.com/gentleman-programming/gentle-ai/v3\tv3.2.1\t${GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM}`,
251
251
  "\tbuild\t-buildmode=exe",
252
252
  "\tbuild\t-compiler=gc",
253
253
  "\tbuild\tCGO_ENABLED=0",
@@ -267,7 +267,7 @@ async function hardenedWindowsGoFixture(packageRoot: string, fixtureOptions: Har
267
267
  return { stdout: "", stderr: "" };
268
268
  }
269
269
  if (file === goPath && arguments_[0] === "version" && arguments_[1] === "-m") return { stdout: metadata, stderr: "" };
270
- if (arguments_.length === 1 && arguments_[0] === "version") return { stdout: "gentle-ai 3.1.0\n", stderr: "" };
270
+ if (arguments_.length === 1 && arguments_[0] === "version") return { stdout: "gentle-ai 3.2.1\n", stderr: "" };
271
271
  throw new Error(`unexpected command: ${file} ${arguments_.join(" ")}`);
272
272
  };
273
273
  return {
@@ -309,7 +309,7 @@ test("Windows source installation resolves one validated Go executable and seals
309
309
  const goCalls = fixture.calls.filter((call) => call.file === fixture.goPath);
310
310
  assert.deepEqual(goCalls.map((call) => call.arguments_.slice(0, 2)), [
311
311
  ["version"],
312
- ["install", "github.com/gentleman-programming/gentle-ai/v3/cmd/gentle-ai@v3.1.0"],
312
+ ["install", "github.com/gentleman-programming/gentle-ai/v3/cmd/gentle-ai@v3.2.1"],
313
313
  ["version", "-m"],
314
314
  ]);
315
315
  for (const call of goCalls) {
@@ -335,14 +335,14 @@ test("Windows source manifest binds verified Go metadata and architecture", asyn
335
335
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-provenance-"));
336
336
  const fixture = await hardenedWindowsGoFixture(packageRoot, { architecture: "arm64" });
337
337
  const result = await installGentleAi({ packageRoot, platform: "win32", arch: "arm64", execFile: fixture.run, resolveGoExecutable: fixture.resolveGoExecutable });
338
- const manifest = JSON.parse(await readFile(join(packageRoot, ".gentle-ai", "v3.1.0", "integrity.json"), "utf8")) as Record<string, string>;
338
+ const manifest = JSON.parse(await readFile(join(packageRoot, ".gentle-ai", "v3.2.1", "integrity.json"), "utf8")) as Record<string, string>;
339
339
  assert.equal(result.installed, true);
340
340
  assert.deepEqual(manifest, {
341
- version: "3.1.0",
341
+ version: "3.2.1",
342
342
  method: "go-sumdb-source-build",
343
343
  package: "github.com/gentleman-programming/gentle-ai/v3/cmd/gentle-ai",
344
344
  module: "github.com/gentleman-programming/gentle-ai/v3",
345
- tag: "v3.1.0",
345
+ tag: "v3.2.1",
346
346
  architecture: "arm64",
347
347
  binarySha256: createHash("sha256").update("trusted Windows source build").digest("hex"),
348
348
  moduleChecksum: GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM,
@@ -362,12 +362,12 @@ test("Windows source installation rejects Go metadata for a different architectu
362
362
  () => installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: fixture.resolveGoExecutable }),
363
363
  (error: unknown) => error instanceof Error && "code" in error && error.code === "GENTLE_AI_GO_INSTALL_FAILED",
364
364
  );
365
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v3.1.0", "gentle-ai.exe")), false);
365
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v3.2.1", "gentle-ai.exe")), false);
366
366
  });
367
367
 
368
368
  test("Windows source installation treats a fresh ownerless lock as active", async () => {
369
369
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-ownerless-lock-"));
370
- const lockPath = join(packageRoot, ".gentle-ai", ".v3.1.0.install.lock");
370
+ const lockPath = join(packageRoot, ".gentle-ai", ".v3.2.1.install.lock");
371
371
  await mkdir(lockPath, { recursive: true });
372
372
  const fixture = await hardenedWindowsGoFixture(packageRoot);
373
373
  await assertManualLockRecoveryRequired(packageRoot, fixture);
@@ -375,7 +375,7 @@ test("Windows source installation treats a fresh ownerless lock as active", asyn
375
375
 
376
376
  test("Windows source installation preserves a lock whose owner nonce changed before release", async () => {
377
377
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-owner-lock-"));
378
- const lockOwnerPath = join(packageRoot, ".gentle-ai", ".v3.1.0.install.lock", "owner.json");
378
+ const lockOwnerPath = join(packageRoot, ".gentle-ai", ".v3.2.1.install.lock", "owner.json");
379
379
  const fixture = await hardenedWindowsGoFixture(packageRoot);
380
380
  let replacedOwner = false;
381
381
  const run = async (...arguments_: Parameters<typeof fixture.run>) => {
@@ -392,7 +392,7 @@ test("Windows source installation preserves a lock whose owner nonce changed bef
392
392
  });
393
393
 
394
394
  async function assertManualLockRecoveryRequired(packageRoot: string, fixture: Awaited<ReturnType<typeof hardenedWindowsGoFixture>>, options: Record<string, unknown> = {}) {
395
- const lockPath = join(packageRoot, ".gentle-ai", ".v3.1.0.install.lock");
395
+ const lockPath = join(packageRoot, ".gentle-ai", ".v3.2.1.install.lock");
396
396
  await assert.rejects(
397
397
  () => installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: fixture.resolveGoExecutable, ...options }),
398
398
  (error: unknown) => error instanceof Error && error.message.includes(lockPath) && /confirm no installer is active.*remove.*manually/i.test(error.message),
@@ -402,18 +402,18 @@ async function assertManualLockRecoveryRequired(packageRoot: string, fixture: Aw
402
402
  }
403
403
 
404
404
  function tombstonePath(packageRoot: string, nonce: string): string {
405
- return join(packageRoot, ".gentle-ai", `.v3.1.0.install.tombstone-${nonce}`);
405
+ return join(packageRoot, ".gentle-ai", `.v3.2.1.install.tombstone-${nonce}`);
406
406
  }
407
407
 
408
408
  async function tombstones(packageRoot: string): Promise<string[]> {
409
409
  const runtimeRoot = join(packageRoot, ".gentle-ai");
410
410
  return existsSync(runtimeRoot)
411
- ? (await readdir(runtimeRoot)).filter((entry) => entry.startsWith(".v3.1.0.install.tombstone-"))
411
+ ? (await readdir(runtimeRoot)).filter((entry) => entry.startsWith(".v3.2.1.install.tombstone-"))
412
412
  : [];
413
413
  }
414
414
 
415
415
  function backupBundlePath(packageRoot: string, nonce: string): string {
416
- return join(packageRoot, ".gentle-ai", `.v3.1.0.backup-${nonce}`);
416
+ return join(packageRoot, ".gentle-ai", `.v3.2.1.backup-${nonce}`);
417
417
  }
418
418
 
419
419
  async function copyWindowsBundle(source: string, destination: string): Promise<void> {
@@ -424,7 +424,7 @@ async function copyWindowsBundle(source: string, destination: string): Promise<v
424
424
 
425
425
  test("Windows source installation fails closed for an ownerless lock even after the stale threshold", async () => {
426
426
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-ownerless-stale-lock-"));
427
- const lockPath = join(packageRoot, ".gentle-ai", ".v3.1.0.install.lock");
427
+ const lockPath = join(packageRoot, ".gentle-ai", ".v3.2.1.install.lock");
428
428
  await mkdir(lockPath, { recursive: true });
429
429
  const fixture = await hardenedWindowsGoFixture(packageRoot);
430
430
  await assertManualLockRecoveryRequired(packageRoot, fixture, { now: () => Date.now() + 10 * 60_000 });
@@ -432,7 +432,7 @@ test("Windows source installation fails closed for an ownerless lock even after
432
432
 
433
433
  test("Windows source installation fails closed for a stale owner lock", async () => {
434
434
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-stale-lock-"));
435
- const lockPath = join(packageRoot, ".gentle-ai", ".v3.1.0.install.lock");
435
+ const lockPath = join(packageRoot, ".gentle-ai", ".v3.2.1.install.lock");
436
436
  await mkdir(lockPath, { recursive: true });
437
437
  await writeFile(join(lockPath, "owner.json"), `${JSON.stringify({ createdAt: 0, nonce: "0".repeat(64) })}\n`);
438
438
  const fixture = await hardenedWindowsGoFixture(packageRoot);
@@ -484,7 +484,7 @@ test("Windows source acquisition fails closed when a tombstone appears after its
484
484
  (error: unknown) => error instanceof Error && error.message.includes(foreignTombstone),
485
485
  );
486
486
  assert.equal(existsSync(foreignTombstone), true);
487
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", ".v3.1.0.install.lock")), false);
487
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", ".v3.2.1.install.lock")), false);
488
488
  assert.equal(fixture.calls.some((call) => call.arguments_[0] === "install"), false);
489
489
  });
490
490
 
@@ -492,7 +492,7 @@ test("Windows source release deletes its matching tombstone and allows reuse", a
492
492
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-owned-lock-release-"));
493
493
  const fixture = await hardenedWindowsGoFixture(packageRoot);
494
494
  await installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: fixture.resolveGoExecutable });
495
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", ".v3.1.0.install.lock")), false);
495
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", ".v3.2.1.install.lock")), false);
496
496
  assert.deepEqual(await tombstones(packageRoot), []);
497
497
  const reuse = await hardenedWindowsGoFixture(packageRoot);
498
498
  assert.equal((await installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: reuse.run, resolveGoExecutable: reuse.resolveGoExecutable })).installed, false);
@@ -502,7 +502,7 @@ test("Windows source recovers a valid backup after a crash between publication r
502
502
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-backup-crash-"));
503
503
  const initial = await hardenedWindowsGoFixture(packageRoot);
504
504
  await installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: initial.run, resolveGoExecutable: initial.resolveGoExecutable });
505
- const live = join(packageRoot, ".gentle-ai", "v3.1.0");
505
+ const live = join(packageRoot, ".gentle-ai", "v3.2.1");
506
506
  const backup = backupBundlePath(packageRoot, "crash");
507
507
  await rename(live, backup);
508
508
  const recovery = await hardenedWindowsGoFixture(packageRoot);
@@ -538,7 +538,7 @@ test("Windows source cleans one validated backup only when the live bundle is va
538
538
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-backup-valid-live-"));
539
539
  const initial = await hardenedWindowsGoFixture(packageRoot);
540
540
  await installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: initial.run, resolveGoExecutable: initial.resolveGoExecutable });
541
- const live = join(packageRoot, ".gentle-ai", "v3.1.0");
541
+ const live = join(packageRoot, ".gentle-ai", "v3.2.1");
542
542
  const backup = backupBundlePath(packageRoot, "valid");
543
543
  await copyWindowsBundle(live, backup);
544
544
  const reuse = await hardenedWindowsGoFixture(packageRoot);
@@ -551,7 +551,7 @@ test("Windows source preserves a valid backup when the live bundle is invalid",
551
551
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-backup-invalid-live-"));
552
552
  const initial = await hardenedWindowsGoFixture(packageRoot);
553
553
  await installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: initial.run, resolveGoExecutable: initial.resolveGoExecutable });
554
- const live = join(packageRoot, ".gentle-ai", "v3.1.0");
554
+ const live = join(packageRoot, ".gentle-ai", "v3.2.1");
555
555
  const backup = backupBundlePath(packageRoot, "valid");
556
556
  await copyWindowsBundle(live, backup);
557
557
  await writeFile(join(live, "integrity.json"), "{}\n");
@@ -569,7 +569,7 @@ test("Windows concurrent installs fail closed until normal release, then reuse t
569
569
  const fixture = await hardenedWindowsGoFixture(packageRoot, { blockInstall: true });
570
570
  const first = installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: fixture.resolveGoExecutable });
571
571
  await fixture.waitForInstall();
572
- const lockPath = join(packageRoot, ".gentle-ai", ".v3.1.0.install.lock");
572
+ const lockPath = join(packageRoot, ".gentle-ai", ".v3.2.1.install.lock");
573
573
  await assert.rejects(
574
574
  () => installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: fixture.resolveGoExecutable }),
575
575
  (error: unknown) => error instanceof Error && error.message.includes(lockPath),
@@ -583,7 +583,7 @@ test("Windows concurrent installs fail closed until normal release, then reuse t
583
583
 
584
584
  test("Windows source publication rolls back a prior bundle when final directory swap fails", async () => {
585
585
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-rollback-"));
586
- const versionDirectory = join(packageRoot, ".gentle-ai", "v3.1.0");
586
+ const versionDirectory = join(packageRoot, ".gentle-ai", "v3.2.1");
587
587
  await mkdir(versionDirectory, { recursive: true });
588
588
  await writeFile(join(versionDirectory, "old.txt"), "previous bundle");
589
589
  const fixture = await hardenedWindowsGoFixture(packageRoot);
@@ -620,7 +620,7 @@ test("Darwin/Linux signed bundles retain their four-field manifest and reusable
620
620
  },
621
621
  };
622
622
  await installGentleAi(options);
623
- const manifestPath = join(packageRoot, ".gentle-ai", "v3.1.0", "integrity.json");
623
+ const manifestPath = join(packageRoot, ".gentle-ai", "v3.2.1", "integrity.json");
624
624
  const manifest = JSON.parse(await readFile(manifestPath, "utf8")) as Record<string, string>;
625
625
  assert.deepEqual(Object.keys(manifest), ["version", "asset", "assetSha256", "binarySha256"]);
626
626
  assert.equal((await installGentleAi({ ...options, download: async () => { throw new Error("signed bundle must be reused"); } })).installed, false);
@@ -633,7 +633,7 @@ test("a pinned asset falls back to its gentle-pi mirror only on download failure
633
633
  // under the current stable pin, whose form gate refuses raw binaries.
634
634
  const payload = Buffer.from("signed archive fixture");
635
635
  const binary = "mirrored binary";
636
- const baseAsset = { name: "gentle-ai_3.1.0_linux_amd64.tar.gz", sha256: createHash("sha256").update(payload).digest("hex"), binarySha256: createHash("sha256").update(binary).digest("hex"), url: "https://example.invalid/upstream", mirrorUrl: "https://example.invalid/mirror", executable: "gentle-ai" };
636
+ const baseAsset = { name: "gentle-ai_3.2.1_linux_amd64.tar.gz", sha256: createHash("sha256").update(payload).digest("hex"), binarySha256: createHash("sha256").update(binary).digest("hex"), url: "https://example.invalid/upstream", mirrorUrl: "https://example.invalid/mirror", executable: "gentle-ai" };
637
637
  const extractArchive = async (_archive: string, destination: string) => {
638
638
  await mkdir(destination, { recursive: true });
639
639
  await writeFile(join(destination, "gentle-ai"), binary);
@@ -751,7 +751,7 @@ test("checksum mismatch cleans temporary state without promoting a binary", asyn
751
751
  }),
752
752
  /checksum mismatch/,
753
753
  );
754
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v3.1.0", "gentle-ai")), false);
754
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v3.2.1", "gentle-ai")), false);
755
755
  assert.deepEqual((await readdir(packageRoot)).filter((entry) => entry.startsWith(".gentle-ai-install-")), []);
756
756
  });
757
757
 
@@ -773,7 +773,7 @@ test("installer promotes only the expected regular executable with executable PO
773
773
  await chmod(extracted, 0o700);
774
774
  },
775
775
  });
776
- const binary = join(packageRoot, ".gentle-ai", "v3.1.0", "gentle-ai");
776
+ const binary = join(packageRoot, ".gentle-ai", "v3.2.1", "gentle-ai");
777
777
  assert.equal(existsSync(binary), true);
778
778
  assert.equal(await readFile(binary, "utf8"), "native executable");
779
779
  assert.ok(((await stat(binary)).mode & 0o111) !== 0);
@@ -804,7 +804,7 @@ test("installer rejects an extracted binary that differs from its pinned digest"
804
804
  }),
805
805
  /binary checksum mismatch/,
806
806
  );
807
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v3.1.0", "gentle-ai")), false);
807
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v3.2.1", "gentle-ai")), false);
808
808
  });
809
809
 
810
810
  test("installer repairs a valid non-executable POSIX binary instead of reusing it", async (t) => {
@@ -827,7 +827,7 @@ test("installer repairs a valid non-executable POSIX binary instead of reusing i
827
827
  },
828
828
  };
829
829
  await installGentleAi(options);
830
- const binary = join(packageRoot, ".gentle-ai", "v3.1.0", "gentle-ai");
830
+ const binary = join(packageRoot, ".gentle-ai", "v3.2.1", "gentle-ai");
831
831
  await chmod(binary, 0o600);
832
832
  const repaired = await installGentleAi(options);
833
833
  assert.equal(repaired.installed, true);
@@ -864,7 +864,7 @@ test("installer rejects archives with multiple expected executable entries", asy
864
864
  }),
865
865
  /exactly one regular gentle-ai/,
866
866
  );
867
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v3.1.0", "gentle-ai")), false);
867
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v3.2.1", "gentle-ai")), false);
868
868
  });
869
869
 
870
870
  test("installer rejects an archive without the expected regular executable", async () => {
@@ -882,7 +882,7 @@ test("installer rejects an archive without the expected regular executable", asy
882
882
  }),
883
883
  /non-regular gentle-ai/,
884
884
  );
885
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v3.1.0", "gentle-ai")), false);
885
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v3.2.1", "gentle-ai")), false);
886
886
  });
887
887
 
888
888
  // #400: a clean Windows source build measured 232 s on a cold module cache,
@@ -6,7 +6,7 @@ import { join } from "node:path";
6
6
  import test from "node:test";
7
7
  import { initTheme, type ExtensionAPI, type ExtensionContext, type SlashCommandInfo, type SourceInfo } from "@earendil-works/pi-coding-agent";
8
8
  import type { TUI } from "@earendil-works/pi-tui";
9
- import installGentleShell, { buildShellBarModel, createActiveProfileReader, changesShortcut, devBinaryCard, fetchCodexUsage, loadFileDiff, shellGitRunner, openInExternalEditor, type GentlePromptEditor } from "../extensions/gentle-shell.ts";
9
+ import installGentleShell, { buildShellBarModel, createActiveProfileReader, changesShortcut, devBinaryCard, fetchCodexUsage, fetchNanUsage, loadFileDiff, shellGitRunner, openInExternalEditor, type GentlePromptEditor } from "../extensions/gentle-shell.ts";
10
10
  import { CHANGE_STATUS } from "../lib/shell-changes.ts";
11
11
  import { sidebarState, type SidebarRail } from "../lib/shell-sidebar.ts";
12
12
  import type { ShellBarTheme } from "../lib/shell-bar.ts";
@@ -715,9 +715,9 @@ const JWT = `h.${Buffer.from(JSON.stringify({ "https://api.openai.com/auth": { c
715
715
  const USAGE_PAYLOAD = { plan_type: "pro", rate_limit: { primary_window: { used_percent: 40, limit_window_seconds: 604_800, reset_at: 1_788_777_491 } } };
716
716
 
717
717
  function fakeFetch(payload: unknown = USAGE_PAYLOAD, ok = true) {
718
- const calls: Array<{ url: string; headers: Record<string, string> }> = [];
718
+ const calls: Array<{ url: string; headers: Record<string, string>; init: RequestInit }> = [];
719
719
  const fetchFn = (async (url: string | URL, init?: RequestInit) => {
720
- calls.push({ url: String(url), headers: (init?.headers ?? {}) as Record<string, string> });
720
+ calls.push({ url: String(url), headers: (init?.headers ?? {}) as Record<string, string>, init: init ?? {} });
721
721
  return { ok, json: async () => payload } as Response;
722
722
  }) as typeof fetch;
723
723
  return { fetchFn, calls };
@@ -738,6 +738,94 @@ test("fetchCodexUsage sends the token and account id and parses the payload", as
738
738
  assert.equal(await fetchCodexUsage(undefined, plain.fetchFn, 0), undefined);
739
739
  });
740
740
 
741
+ const NAN_QUOTA_PAYLOAD = {
742
+ periodEnd: "2026-10-01T00:00:00.000Z",
743
+ models: [
744
+ {
745
+ model: "glm5.3",
746
+ cap: 3_000_000_000,
747
+ fullCap: 3_000_000_000,
748
+ tokensUsed: 820_000_000,
749
+ windowHours: 4,
750
+ windowTokens: 400_000_000,
751
+ windowTokensUsed: 120_000_000,
752
+ windowResetsAt: 1_788_620_161,
753
+ },
754
+ ],
755
+ };
756
+
757
+ test("fetchNanUsage sends the key to the fixed quota origin and never follows a redirect", async () => {
758
+ const { fetchFn, calls } = fakeFetch(NAN_QUOTA_PAYLOAD);
759
+ const usage = await fetchNanUsage("sk-nan-secret", fetchFn, 1_788_600_000_000);
760
+ assert.equal(usage?.provider, "nan");
761
+ assert.equal(usage?.limits[0].name, "glm5.3");
762
+ assert.equal(calls.length, 1);
763
+ assert.equal(calls[0].url, "https://cloud-api.nan.builders/api/usage/quota");
764
+ assert.equal(calls[0].headers.Authorization, "Bearer sk-nan-secret");
765
+ assert.equal(calls[0].init.redirect, "error", "a redirect would forward the bearer to another origin");
766
+ assert.equal(calls[0].init.cache, "no-store");
767
+ assert.equal(JSON.stringify(usage).includes("sk-nan-secret"), false);
768
+ });
769
+
770
+ test("fetchNanUsage degrades to no snapshot without ever throwing", async () => {
771
+ const noKey = fakeFetch(NAN_QUOTA_PAYLOAD);
772
+ assert.equal(await fetchNanUsage(undefined, noKey.fetchFn, 0), undefined);
773
+ assert.equal(await fetchNanUsage("", noKey.fetchFn, 0), undefined);
774
+ assert.equal(noKey.calls.length, 0, "no key, no request");
775
+
776
+ assert.equal(await fetchNanUsage("sk-nan-secret", fakeFetch(NAN_QUOTA_PAYLOAD, false).fetchFn, 0), undefined, "a non-OK response is not a snapshot");
777
+ assert.equal(await fetchNanUsage("sk-nan-secret", fakeFetch({ models: [] }).fetchFn, 0), undefined, "an empty quota is not a snapshot");
778
+ assert.equal(await fetchNanUsage("sk-nan-secret", fakeFetch({ models: [{ model: "glm5.3", cap: 0, tokensUsed: 0 }] }).fetchFn, 0), undefined);
779
+ const refused = (async () => {
780
+ throw new TypeError("redirect mode is not supported");
781
+ }) as unknown as typeof fetch;
782
+ assert.equal(await fetchNanUsage("sk-nan-secret", refused, 0), undefined, "a refused redirect degrades silently");
783
+ });
784
+
785
+ test("gentleShell fetches NaN quota on session start and shows it in the bar", async () => {
786
+ const { pi, handlers } = fakePi();
787
+ const { fetchFn, calls } = fakeFetch(NAN_QUOTA_PAYLOAD);
788
+ gentleShell(pi, { GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" }, { fetch: fetchFn, now: () => 1_788_600_000_000 });
789
+ const { ctx, ui } = fakeContext({ token: "sk-nan-secret" });
790
+ (ctx as unknown as { model: { provider: string } }).model.provider = "nan";
791
+ await fire(handlers, "session_start", ctx);
792
+ await new Promise((resolve) => setTimeout(resolve, 0));
793
+ assert.equal(calls.length, 1);
794
+ assert.equal(calls[0].url, "https://cloud-api.nan.builders/api/usage/quota");
795
+ // The fixture's session model holds no NaN allowance of its own, so the
796
+ // account names the meter: a NaN payload of one model is still per-model data.
797
+ assert.match(renderFooter(ui), /\$0\.000 sub ⟡ nan total ▰+▱+ 27%/);
798
+
799
+ await fire(handlers, "agent_end", ctx);
800
+ await new Promise((resolve) => setTimeout(resolve, 0));
801
+ assert.equal(calls.length, 1, "agent_end must not refetch within the refresh window");
802
+ });
803
+
804
+ test("a failed NaN refresh keeps the last valid snapshot", async () => {
805
+ const { pi, handlers } = fakePi();
806
+ const calls: string[] = [];
807
+ let fail = false;
808
+ const fetchFn = (async (url: string | URL) => {
809
+ calls.push(String(url));
810
+ if (fail) throw new TypeError("network down");
811
+ return { ok: true, json: async () => NAN_QUOTA_PAYLOAD } as Response;
812
+ }) as typeof fetch;
813
+ let now = 1_788_600_000_000;
814
+ gentleShell(pi, { GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" }, { fetch: fetchFn, now: () => now });
815
+ const { ctx, ui } = fakeContext({ token: "sk-nan-secret" });
816
+ (ctx as unknown as { model: { provider: string } }).model.provider = "nan";
817
+ await fire(handlers, "session_start", ctx);
818
+ await new Promise((resolve) => setTimeout(resolve, 0));
819
+ assert.match(renderFooter(ui), /nan total ▰+▱+/);
820
+
821
+ fail = true;
822
+ now += 6 * 60_000;
823
+ await fire(handlers, "agent_end", ctx);
824
+ await new Promise((resolve) => setTimeout(resolve, 0));
825
+ assert.equal(calls.length, 2, "the refresh window elapsed, so the retry was attempted");
826
+ assert.match(renderFooter(ui), /nan total ▰+▱+/, "a failed refresh cannot erase the last valid snapshot");
827
+ });
828
+
741
829
  test("gentleShell fetches Codex usage on session start and shows it in the bar", async () => {
742
830
  const { pi, handlers } = fakePi();
743
831
  const { fetchFn, calls } = fakeFetch();
@@ -753,6 +841,24 @@ test("gentleShell fetches Codex usage on session start and shows it in the bar",
753
841
  assert.equal(calls.length, 1, "agent_end must not refetch within the refresh window");
754
842
  });
755
843
 
844
+ test("a provider switch refreshes the new provider inside the same window", async () => {
845
+ const { pi, handlers } = fakePi();
846
+ const { fetchFn, calls } = fakeFetch(NAN_QUOTA_PAYLOAD);
847
+ gentleShell(pi, { GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" }, { fetch: fetchFn, now: () => 1_788_600_000_000 });
848
+ const { ctx } = fakeContext({ token: JWT });
849
+ await fire(handlers, "session_start", ctx);
850
+ await new Promise((resolve) => setTimeout(resolve, 0));
851
+ assert.equal(calls.length, 1);
852
+
853
+ // The 5-minute rule is per provider: the timestamp one provider set cannot
854
+ // leave the next one waiting for a fetch it never made.
855
+ (ctx as unknown as { model: { provider: string } }).model.provider = "nan";
856
+ await fire(handlers, "agent_end", ctx);
857
+ await new Promise((resolve) => setTimeout(resolve, 0));
858
+ assert.equal(calls.length, 2, "a provider switch is a reason to fetch, not to wait");
859
+ assert.equal(calls[1].url, "https://cloud-api.nan.builders/api/usage/quota");
860
+ });
861
+
756
862
  test("gentleShell records SSE rate-limit headers from provider responses", async () => {
757
863
  const { pi, handlers } = fakePi();
758
864
  gentleShell(pi, { GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" }, { fetch: fakeFetch({}, false).fetchFn, now: () => 0 });
@@ -288,11 +288,24 @@ test("3.1.0 repeats 3.0.1 because the negotiated lane Pi consumes is unchanged",
288
288
  assert.deepEqual(contract, NATIVE_CLI_CONTRACTS["3.0.1"] as Record<string, boolean>);
289
289
  });
290
290
 
291
+ test("3.2.1 repeats 3.1.0 because the negotiated lane Pi consumes is unchanged", () => {
292
+ // v3.2.1 changed the ODD orchestrator contract only (gentle-ai #4714
293
+ // follow-up). Diffing contracts/review-integration/v2 and
294
+ // contracts/review-provider-contract between the v3.1.0 and v3.2.1 tags
295
+ // in the gentle-ai source tree showed zero byte changes (provider contract
296
+ // stays 1.2.0), so this row repeats 3.1.0. riskEvidence and hint remain
297
+ // dark because neither is proven to reach Pi's negotiated START path.
298
+ const contract = NATIVE_CLI_CONTRACTS["3.2.1"] as Record<string, boolean>;
299
+ assert.equal(contract.riskEvidence, false);
300
+ assert.equal(contract.hint, false);
301
+ assert.deepEqual(contract, NATIVE_CLI_CONTRACTS["3.1.0"] as Record<string, boolean>);
302
+ });
303
+
291
304
  test("no shipped version key was added beyond the pin bump", () => {
292
305
  // Rows are promises to consumers, so a new key only ever appears in a
293
306
  // dedicated commit alongside a pin bump, never as a side effect. v2.2.4 and
294
307
  // v2.3.0 shipped upstream while Pi stayed on 2.2.3 and were never pinned,
295
308
  // so they get no row: a row asserts ground truth measured against a binary
296
309
  // Pi actually ran, and the table only has to be ascending, not gapless.
297
- assert.deepEqual(Object.keys(NATIVE_CLI_CONTRACTS), [...DARK_VERSIONS, "2.2.0", "2.2.1", "2.2.2", "2.2.3", "2.4.0", "2.5.0-rc.3", "2.5.0", "2.6.0", "2.7.0", "2.8.0", "2.8.1", "2.8.2", "2.9.0", "2.9.1", "3.0.0", "3.0.1", "3.1.0"]);
310
+ assert.deepEqual(Object.keys(NATIVE_CLI_CONTRACTS), [...DARK_VERSIONS, "2.2.0", "2.2.1", "2.2.2", "2.2.3", "2.4.0", "2.5.0-rc.3", "2.5.0", "2.6.0", "2.7.0", "2.8.0", "2.8.1", "2.8.2", "2.9.0", "2.9.1", "3.0.0", "3.0.1", "3.1.0", "3.2.1"]);
298
311
  });