@akanjs/devkit 3.2.0-rc.19 → 3.2.0-rc.20

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.
package/CHANGELOG.md CHANGED
@@ -197,6 +197,7 @@
197
197
  - d12f556: The barrel-import rewrite maps a name that a barrel re-exports by name from another barrel (`export { migration } from "./migration"`) to the file that declares it, as it already did through `export *`. It used to stop at the inner barrel, so a page that imported one name loaded every module behind it.
198
198
  - a480576: A file moved since the fork point keeps its `akan.baseline.json` entries, whether it was moved with `git mv` or a plain rename. The growth check reads the committed entries under the path git pairs the file with, and `--fix` rewrites the working entries there, so moving a recorded file no longer fails as new debt. A move that also rewrote more than half the file, or left a file at the old path, still reads as new, since git no longer sees it as a move.
199
199
  - 1b04784: The dev build batch worker now waits for the runner to take its result before exiting, so a result can't be lost however fast the worker finishes. In the tests, workers that exited within milliseconds of starting could lose everything they sent and be reported as crashed.
200
+ - 7311978: The dev builder now uses a build batch's result once the worker has sent it, and ends a worker that is still running half a second later. Before, if the release never reached the worker, as may happen with Bun on Windows, each batch waited up to 5 s for the worker to exit before its result was used.
200
201
  - 0504209: `akan build <app> --env <env>` builds for an environment other than the workspace `.env`'s, the way the desktop and mobile builds already do. Before, the shell's `AKAN_PUBLIC_ENV` lost to the `.env`, so a new workspace could only build `local` without editing it. The local-build notice, the image guard and the README now say what a `local` build changes in a built server: no endpoint rate limits, and local defaults for Redis and the database mode. They no longer say the dev routes are served, which a built server never does.
201
202
  - bf872ce: A variable the shell sets now outranks the workspace `.env` when `akan` builds or runs an app, as dotenv and Bun's own `.env` loading do: `AKAN_PUBLIC_ENV=main akan build <app>` builds `main` where the `.env` says `local`. The order is `--env` (for `AKAN_PUBLIC_ENV`), then the process environment (the shell, and the `.env.local` and `.env.<NODE_ENV>` Bun loads into it), then the `.env`, then the defaults; an empty export counts as unset. The bundles, the bundled server env, `akan.env.json` and the Dockerfile still take one set of values. Where an exported value outranks the `.env`, `akan build` now warns with both values instead of the old warning that listed the values it ignored, and the server-env message, the `--env` help, the local-build notice, the README and the CLI reference state the new order.
202
203
 
@@ -249,6 +250,8 @@
249
250
  - 82d62b1: A CSR bundle and each MCP App view no longer carry the route-level boundary, which only a server render draws. The generated root layout's `LevelBoundary` export is now undefined in a CSR build, which MCP App views share, so their `import * as root` of the layout no longer keeps it. In `akan build minimal --fast` each MCP App view and the CSR `index.html` are about 0.45KB smaller raw. A server render is unchanged.
250
251
  - 1870fcd: `akan verify` adds a `fix:` line to a module file's two-parent import that names the layer barrel to import from instead, such as `import from "@apps/<app>/common"`. The lint message itself now points at the layer barrel too.
251
252
  - 5691327: `setErrorConstructor` on `FetchClient`, `HttpClient` and `WsClient`, `HttpClientOptions.ErrorCls` and `FetchClient.build`'s `Err` option are deprecated. Every dictionary's `Err` is `akanjs/common`'s `Err`, which a restored error already is, so they change nothing. They keep working. A generated `lib/sig.ts` no longer calls `fetch.setErrorConstructor(Err)`, and a generated `lib/useClient.ts` no longer passes `{ Err: pageProto.Err }`; `akan sync` rewrites both. No upgrade step is needed.
253
+ - 7311978: The dev server's verbose log now names the route of each page request it holds while the builder restarts, for example `holding build-route /:lang/second until the builder is ready (2 waiting)`.
254
+ - db414ba: Subspace sync passes the repository and branch to `git clone`, `fetch` and `push` after `--`, so neither can be read as a git option, and `subspace` config refuses a repo starting with `-`. The store-access scanner's form-setter check and the convention and AGENTS.md readers no longer backtrack quadratically on a long name or a long run of spaces.
252
255
  - 7c39aea: The 82 source files at the root of `@akanjs/devkit` now sit in folders by concern:
253
256
 
254
257
  - `quality/`: the maintainability gate and its scanners
@@ -272,6 +275,7 @@
272
275
  - 668a52d: Listing an app's or lib's modules (`SysExecutor.getModules`, and the constant-file readers built on it) no longer fails with `ENOENT` when the process runs outside the workspace root, and skips a dangling symlink instead of rejecting.
273
276
  - fa42f4e: A dev server about to idle-suspend now decides again once its idle watcher has started, and stays awake if a builder request or builder message came in while the watcher was starting, or if the builder or backend stopped being ready. It used to release the builder anyway, so a `build-graph` or route request sent in that window waited for the next wake or failed. A dev file watcher stopped in the middle of a scan no longer reports what that scan found, which the next idle wake used to replay as a stale change.
274
277
  - fd2c575: A dev server that stops no longer re-arms its idle-suspend timer or keeps a file watcher running. A wake that settles after the stop, a builder message or relayed request that arrives after it, and an idle watcher that finishes starting after it each used to re-arm the timer, report the host awake, or leave the watcher open. A request that reaches a host stopped while suspended is now refused at once instead of being held for a wake that never comes.
278
+ - 7311978: A dev server waking from idle suspend now applies every save made while it was suspended, including one its idle watcher was still scanning when a request woke it. Such a save used to be dropped, so an `akan.config.ts` change made just before a page request kept the old config until the next config save.
275
279
  - e2b809a: The typecheck behind `akan typecheck`, `akan verify` and `akan build` now uses its incremental cache. It wrote a `.tsbuildinfo` on every run, then checked every file again anyway, so a run with nothing changed cost as much as the first: about 8 seconds on a 2,400-file project. Now a run re-checks only the files that changed and the files they affect, and reads the rest from the cache. The same project's second run takes about 1.2 seconds. The diagnostics are the same, in the same order, as a full check: options, global, syntax, type and declaration errors, an edited file's new errors and the errors it causes in files that import it. `--clean` still clears the cache first.
276
280
  - bf28968: An app can now serve its default locale at unprefixed paths. Set `i18n.localePrefix` to `"as-needed"` in `akan.config.ts`, and `/books/OL45804W` is the English page itself. Before, every page lived under `/<locale>/…`, and an unprefixed path answered with a 307 to the locale the browser asked for. An app with one language, or with URLs fixed from outside (OAuth callbacks, QR codes, links in mail, a migrated site), could only meet them with raw `<a href>`s, which reloaded the whole page and went through that 307 on every click.
277
281
 
@@ -552,6 +556,7 @@
552
556
  - Updated dependencies [b3f85fa]
553
557
  - Updated dependencies [a707354]
554
558
  - Updated dependencies [4d61170]
559
+ - Updated dependencies [20b6a6c]
555
560
  - Updated dependencies [1ef031b]
556
561
  - Updated dependencies [c723713]
557
562
  - Updated dependencies [0351ad4]
@@ -571,6 +576,7 @@
571
576
  - Updated dependencies [96f9ff6]
572
577
  - Updated dependencies [0a81afa]
573
578
  - Updated dependencies [af7c411]
579
+ - Updated dependencies [6d449b1]
574
580
  - Updated dependencies [1ebc57a]
575
581
  - Updated dependencies [c3b5b3c]
576
582
  - Updated dependencies [dcb7e61]
@@ -583,7 +589,9 @@
583
589
  - Updated dependencies [ad09fac]
584
590
  - Updated dependencies [ae045d8]
585
591
  - Updated dependencies [d9eaacc]
592
+ - Updated dependencies [d79a206]
586
593
  - Updated dependencies [d9eaacc]
594
+ - Updated dependencies [0e5db0a]
587
595
  - Updated dependencies [c334caf]
588
596
  - Updated dependencies [170be15]
589
597
  - Updated dependencies [d9f5ad5]
@@ -607,6 +615,7 @@
607
615
  - Updated dependencies [4561152]
608
616
  - Updated dependencies [73e833b]
609
617
  - Updated dependencies [d6b3619]
618
+ - Updated dependencies [6cdfb73]
610
619
  - Updated dependencies [b24fef3]
611
620
  - Updated dependencies [465ccb9]
612
621
  - Updated dependencies [513e48d]
@@ -614,11 +623,13 @@
614
623
  - Updated dependencies [5cd1fc3]
615
624
  - Updated dependencies [f47cc82]
616
625
  - Updated dependencies [cf5eeff]
626
+ - Updated dependencies [228b6d7]
617
627
  - Updated dependencies [6b3b4e4]
618
628
  - Updated dependencies [7f0de74]
619
629
  - Updated dependencies [1f93507]
620
630
  - Updated dependencies [5d3cb3e]
621
631
  - Updated dependencies [ad4571f]
632
+ - Updated dependencies [5757156]
622
633
  - Updated dependencies [9a2a8c9]
623
634
  - Updated dependencies [9a9e1fa]
624
635
  - Updated dependencies [af133d7]
@@ -631,6 +642,7 @@
631
642
  - Updated dependencies [9055634]
632
643
  - Updated dependencies [3537448]
633
644
  - Updated dependencies [a373d51]
645
+ - Updated dependencies [99e3fd8]
634
646
  - Updated dependencies [c723e7a]
635
647
  - Updated dependencies [6c3a303]
636
648
  - Updated dependencies [eadb12a]
@@ -643,6 +655,7 @@
643
655
  - Updated dependencies [e3de9ef]
644
656
  - Updated dependencies [e3de9ef]
645
657
  - Updated dependencies [e3de9ef]
658
+ - Updated dependencies [ce35811]
646
659
  - Updated dependencies [463fd1e]
647
660
  - Updated dependencies [f923ffb]
648
661
  - Updated dependencies [802bffe]
@@ -30,6 +30,10 @@ mock.module("../frontendBuild/hmrWatcher", () => ({
30
30
  stop() {
31
31
  this.#watcher.stopped += 1;
32
32
  }
33
+ async close() {
34
+ this.stop();
35
+ return null;
36
+ }
33
37
  },
34
38
  }));
35
39
 
@@ -57,9 +57,8 @@ export class BuilderRequestRelay {
57
57
  // A returning builder is a gap, not a failure: hold the request (`BuilderRpc`'s timeout still bounds it).
58
58
  if (shouldHoldForReturningBuilder({ status, heldCount: this.#held.length })) {
59
59
  this.#held.push(message);
60
- this.#logger.verbose(
61
- `[builder] holding ${message.type} until the builder is ready (${this.#held.length} waiting)`,
62
- );
60
+ const request = message.type === "build-route" ? `build-route ${message.routeId}` : message.type;
61
+ this.#logger.verbose(`[builder] holding ${request} until the builder is ready (${this.#held.length} waiting)`);
63
62
  return;
64
63
  }
65
64
  if (this.#failRequest(message, `builder is ${status}; reload after the builder is ready`)) return;
@@ -27,6 +27,10 @@ mock.module("../frontendBuild/hmrWatcher", () => ({
27
27
  stop() {
28
28
  this.#record.stopped++;
29
29
  }
30
+ async close() {
31
+ this.#record.stopped++;
32
+ return null;
33
+ }
30
34
  },
31
35
  }));
32
36
 
@@ -81,12 +81,18 @@ export class DevIdleSuspend {
81
81
  if (!this.#suspended || this.#waking || this.#stopped) return;
82
82
  this.#waking = true;
83
83
  this.#cancel();
84
- this.#stopWatcher();
85
- const batch = this.#suspendedChanges;
86
- this.#suspendedChanges = null;
87
84
  const startedAtMono = performance.now();
88
85
  this.#logger.info(`[idle-suspend] waking (${reason})`);
86
+ const watcher = this.#watcher;
87
+ this.#watcher = null;
88
+ let batch: ChangeBatch | null = null;
89
89
  try {
90
+ //? Closed, not stopped: a save its last scan found, a config one included, has no other record once released.
91
+ const unreported = await watcher?.close();
92
+ if (unreported) this.#recordSuspendedChange(unreported);
93
+ batch = this.#suspendedChanges;
94
+ this.#suspendedChanges = null;
95
+ if (this.#stopped) return;
90
96
  await this.#links.wake(batch);
91
97
  this.#logger.info(`[idle-suspend] awake in ${Math.round(performance.now() - startedAtMono)}ms`);
92
98
  } catch (err) {
@@ -29,6 +29,8 @@ const makeRoot = tempDirs("akan-idle-suspend-watcher-");
29
29
 
30
30
  let previous: string | undefined;
31
31
  beforeEach(() => {
32
+ held.primes.length = 0;
33
+ held.scans.length = 0;
32
34
  previous = process.env.AKAN_DEV_IDLE_SUSPEND_MS;
33
35
  process.env.AKAN_DEV_IDLE_SUSPEND_MS = "5";
34
36
  });
@@ -71,7 +73,48 @@ test("a save while the idle watcher primes stays with the awake builder, and the
71
73
  held.primes[1].resolve();
72
74
  await tick();
73
75
  expect(released).toBe(1);
74
- await idle.wake("a route request");
76
+ const woken = idle.wake("a route request");
77
+ await tick();
78
+ held.scans[1].resolve([]);
79
+ await woken;
75
80
  expect(wokenWith).toEqual([null]);
76
81
  idle.stop();
77
82
  }, 15_000);
83
+
84
+ test("a config save found by the scan a wake interrupts reaches that wake", async () => {
85
+ root = await makeRoot();
86
+ const source = path.join(root, "lib/a.ts");
87
+ const config = path.join(root, "akan.config.ts");
88
+ await writeText(source, "export const x = 0;\n");
89
+ let released = 0;
90
+ const wokenWith: (ChangeBatch | null)[] = [];
91
+ const idle = new DevIdleSuspend(
92
+ {} as App,
93
+ { logger },
94
+ {
95
+ readiness: () => ({ builderReady: true, backendReady: true, buildFailed: false, restartPending: false }),
96
+ release: () => {
97
+ released++;
98
+ },
99
+ wake: async (batch) => {
100
+ wokenWith.push(batch);
101
+ },
102
+ wakeFailed: () => undefined,
103
+ flushHeld: () => undefined,
104
+ awake: () => undefined,
105
+ },
106
+ );
107
+ idle.arm();
108
+ while (held.primes.length === 0) await tick(5);
109
+ held.primes[0].resolve();
110
+ await tick();
111
+ expect(released).toBe(1);
112
+ expect(await saveUntil(source, () => held.scans.length > 0)).toBe(true);
113
+ const woken = idle.wake("a route request");
114
+ held.scans[0].resolve([config]);
115
+ await tick();
116
+ held.scans[1]?.resolve([]);
117
+ await woken;
118
+ expect(wokenWith).toEqual([{ files: [config], kinds: new Set(["config"]) }]);
119
+ idle.stop();
120
+ }, 15_000);
@@ -16,6 +16,7 @@ const logger = {
16
16
  error: () => undefined,
17
17
  } as unknown as Logger;
18
18
  const makeRoot = tempDirs("akan-hmr-watcher-stop-");
19
+ const tick = () => new Promise((resolve) => setTimeout(resolve, 0));
19
20
 
20
21
  describe("HmrWatcher stopped while a scan runs", () => {
21
22
  test("hands over no batch, though the scan settles with an edit made while it primed", async () => {
@@ -33,4 +34,30 @@ describe("HmrWatcher stopped while a scan runs", () => {
33
34
  await new Promise((resolve) => setTimeout(resolve, 0));
34
35
  expect(batches).toEqual([]);
35
36
  }, 15_000);
37
+
38
+ test("close hands back what the scan it interrupted found, though a later scan settles first", async () => {
39
+ held.primes.length = 0;
40
+ held.scans.length = 0;
41
+ const root = await makeRoot();
42
+ const source = path.join(root, "lib/a.ts");
43
+ const config = path.join(root, "akan.config.ts");
44
+ await writeText(source, "export const x = 0;\n");
45
+ const batches: ChangeBatch[] = [];
46
+ const watcher = new HmrWatcher({ roots: [root], logger, onBatch: (batch) => void batches.push(batch) });
47
+ const starting = watcher.start();
48
+ held.primes[0].resolve();
49
+ await starting;
50
+ expect(await saveUntil(source, () => held.scans.length > 0)).toBe(true);
51
+ const closing = watcher.close();
52
+ const settleLaterScans = async () => {
53
+ await tick();
54
+ for (const scan of held.scans.slice(1)) scan.resolve([]);
55
+ await tick();
56
+ };
57
+ await settleLaterScans();
58
+ held.scans[0].resolve([config]);
59
+ await settleLaterScans();
60
+ expect(await closing).toEqual({ files: [config], kinds: new Set(["config"]) });
61
+ expect(batches).toEqual([]);
62
+ }, 15_000);
36
63
  });
@@ -29,6 +29,7 @@ export class HmrWatcher {
29
29
  readonly #hinted = new Set<string>();
30
30
  readonly #classifier = new HmrChangeClassifier();
31
31
  readonly #index: SourceMtimeIndex;
32
+ readonly #scans = new Set<Promise<void>>();
32
33
  #timer: ReturnType<typeof setTimeout> | null = null;
33
34
  #verifyTimer: ReturnType<typeof setTimeout> | null = null;
34
35
  #windowStartedAt: number | null = null;
@@ -98,6 +99,18 @@ export class HmrWatcher {
98
99
  }
99
100
  }
100
101
 
102
+ //? A scan stop() interrupts keeps its finds unreported, and the scan has already moved their mtime baseline.
103
+ async close(): Promise<ChangeBatch | null> {
104
+ this.stop();
105
+ await Promise.all(this.#scans);
106
+ await this.#mergeDetectedChanges();
107
+ if (this.#pending.size === 0) return null;
108
+ const batch = { files: Array.from(this.#pending.keys()), kinds: new Set(this.#pending.values()) };
109
+ this.#pending.clear();
110
+ this.#hinted.clear();
111
+ return batch;
112
+ }
113
+
101
114
  /** Baseline the batch handler's own writes so the verification scan does not rebuild them a second time. */
102
115
  async absorb(paths: string[]): Promise<void> {
103
116
  if (paths.length === 0) return;
@@ -169,7 +182,13 @@ export class HmrWatcher {
169
182
  }
170
183
  }
171
184
 
172
- async #mergeDetectedChanges(): Promise<void> {
185
+ #mergeDetectedChanges(): Promise<void> {
186
+ const scan = this.#collectDetectedChanges().finally(() => this.#scans.delete(scan));
187
+ this.#scans.add(scan);
188
+ return scan;
189
+ }
190
+
191
+ async #collectDetectedChanges(): Promise<void> {
173
192
  const detected = await this.#index.collectChanges().catch((err) => {
174
193
  this.#logger.error(`[hmr] mtime scan failed: ${(err as Error).message}`);
175
194
  return [] as string[];
@@ -48,7 +48,7 @@ export const upsertAgentBlock = (existing: string, block: string): string => {
48
48
  if (startIndex >= 0 && endIndex > startIndex) {
49
49
  return `${existing.slice(0, startIndex)}${managed}${existing.slice(endIndex + AGENT_BLOCK_END.length)}`;
50
50
  }
51
- return `${existing.replace(/\s*$/, "")}\n\n${managed}\n`;
51
+ return `${existing.trimEnd()}\n\n${managed}\n`;
52
52
  };
53
53
 
54
54
  /** The content between the akan:agent markers, or null when the file carries no managed block. */
@@ -29,7 +29,7 @@ export class ConventionSet {
29
29
  const match: RegExpExecArray | null = /^---\n([\s\S]*?)\n---\n/.exec(text);
30
30
  if (!match) throw new Error(`Convention rule ${name} has no frontmatter`);
31
31
  const front = match[1] ?? "";
32
- const described: RegExpExecArray | null = /^description:\s*(.+)$/m.exec(front);
32
+ const described: RegExpExecArray | null = /^description:(.*)$/m.exec(front);
33
33
  const description = described?.[1]?.trim() ?? "";
34
34
  const paths = [...front.matchAll(/^\s+-\s+"([^"]+)"$/gm)].map((entry) => entry[1] ?? "");
35
35
  if (!description || paths.length === 0) throw new Error(`Convention rule ${name} needs a description and paths`);
@@ -1,10 +1,19 @@
1
1
  import { describe, expect, test } from "bun:test";
2
+ import { readFileSync } from "node:fs";
2
3
  import path from "node:path";
3
4
  import { createTempApp, tempRoots, writeText } from "../test/testHelpers";
4
5
  import type { BuildBatchMessage, BuildBatchRequest, BuildBatchResult } from "./buildBatchProtocol";
5
6
  import { BuildBatchRunner } from "./buildBatchRunner";
6
7
 
7
8
  const track = tempRoots();
9
+ const isAlive = (pid: number) => {
10
+ try {
11
+ process.kill(pid, 0);
12
+ return true;
13
+ } catch {
14
+ return false;
15
+ }
16
+ };
8
17
 
9
18
  describe("BuildBatchRunner", () => {
10
19
  test("reports a boot build the bundler refuses with where each reason sits in the workspace", async () => {
@@ -90,9 +99,46 @@ setTimeout(() => process.exit(1), 2_000).unref();
90
99
  artifactDir: path.join(appDir, ".akan/artifact"),
91
100
  });
92
101
  expect(result).toEqual({ generation: 3, errors: {} });
102
+ const deadline = Date.now() + 1_500;
103
+ while (!(await Bun.file(released).exists()) && Date.now() < deadline) await Bun.sleep(20);
93
104
  expect(await Bun.file(released).exists()).toBe(true);
94
105
  }, 30_000);
95
106
 
107
+ test("returns a result as it arrives from a worker the release never reaches, then kills that worker", async () => {
108
+ const { root } = track(await createTempApp("demo"));
109
+ const appDir = path.join(root, "apps/demo");
110
+ const sent = path.join(root, "sent");
111
+ await writeText(
112
+ path.join(root, "pkgs/@akanjs/devkit/incrementalBuilder/buildBatch.proc.ts"),
113
+ `import fs from "node:fs";
114
+ const { generation } = JSON.parse(process.argv[2]);
115
+ fs.writeFileSync(${JSON.stringify(sent)}, String(process.pid));
116
+ process.send({ type: "build-batch-result", data: { generation, errors: {} } });
117
+ setTimeout(() => process.exit(0), 5_000);
118
+ `,
119
+ );
120
+ const result = await new BuildBatchRunner({ workspaceRoot: root, cwd: appDir }).run({
121
+ appName: "demo",
122
+ workspaceRoot: root,
123
+ repoName: "repo",
124
+ generation: 5,
125
+ needs: ["pages"],
126
+ changedFiles: [],
127
+ pageKeys: null,
128
+ optimizedFonts: null,
129
+ cssAssets: null,
130
+ artifactDir: path.join(appDir, ".akan/artifact"),
131
+ });
132
+ //? Read before any await: the kill timer cannot fire until this turn's microtasks are done.
133
+ const pid = Number(readFileSync(sent, "utf8"));
134
+ const upAtReturn = isAlive(pid);
135
+ expect(result).toEqual({ generation: 5, errors: {} });
136
+ expect(upAtReturn).toBe(true);
137
+ const deadline = Date.now() + 3_000;
138
+ while (isAlive(pid) && Date.now() < deadline) await Bun.sleep(20);
139
+ expect(isAlive(pid)).toBe(false);
140
+ }, 30_000);
141
+
96
142
  test("the build worker stays up after reporting its result until its runner releases it", async () => {
97
143
  const { root } = track(await createTempApp("demo", path.join(import.meta.dir, "..", "local")));
98
144
  const appDir = path.join(root, "apps/demo");
@@ -7,6 +7,7 @@ import type { BuildBatchMessage, BuildBatchRequest, BuildBatchResult } from "./b
7
7
  // their own work (the slow lane, the css queue, the SSR registry's boot build beside them), so a few can overlap.
8
8
  // A worker that dies without reporting must not take the watcher down; its needs come back as errors.
9
9
  export class BuildBatchRunner {
10
+ static readonly #exitGraceMs = 500;
10
11
  #logger = new Logger("BuildBatchRunner");
11
12
  #entry: string | null = null;
12
13
  #workspaceRoot: string;
@@ -39,6 +40,7 @@ export class BuildBatchRunner {
39
40
  const started = Date.now();
40
41
  const entry = await this.#resolveEntry();
41
42
  let result: BuildBatchResult | null = null;
43
+ const resultArrived = Promise.withResolvers<null>();
42
44
  const reported = new Map<string, string | undefined>();
43
45
  const payload = request.trace ? { ...request, trace: { ...request.trace, spawnAt: Date.now() } } : request;
44
46
  // argv rather than IPC, so the worker starts on its first tick instead of waiting for a handshake.
@@ -53,13 +55,21 @@ export class BuildBatchRunner {
53
55
  result = message.data;
54
56
  // On Bun 1.4 a worker that exits within ms of spawning can lose everything it sent: it exits on this release.
55
57
  worker.disconnect();
58
+ //? Bun on Windows may never deliver that release; the worker would hold its arenas for its own 5 s bound.
59
+ const lingering = setTimeout(() => {
60
+ this.#logger.verbose(`[build-batch] worker still up ${BuildBatchRunner.#exitGraceMs}ms after its result`);
61
+ worker.kill("SIGKILL");
62
+ }, BuildBatchRunner.#exitGraceMs);
63
+ void worker.exited.then(() => clearTimeout(lingering));
64
+ resultArrived.resolve(null);
56
65
  } else {
57
66
  if (message.type === "build-status") reported.set(message.data.phase, message.data.message);
58
67
  onMessage(message);
59
68
  }
60
69
  },
61
70
  });
62
- const exitCode = await proc.exited;
71
+ //? On the result, not the exit: a worker the release never reaches would make each batch wait for the kill.
72
+ const exitCode = await Promise.race([proc.exited, resultArrived.promise]);
63
73
  if (result) {
64
74
  this.#logger.verbose(
65
75
  `[build-batch] generation=${request.generation} needs=${request.needs.join(",")} done in ${Date.now() - started}ms`,
@@ -676,16 +676,16 @@ describe("dev resource budgets", () => {
676
676
  const second = fetch(`http://127.0.0.1:${port}/second`, { signal: AbortSignal.timeout(WAIT_MS) }).then(
677
677
  async (response) => ({ status: response.status, html: await response.text() }),
678
678
  );
679
- // Two waiting are the drain request and this one; with the gate shut, an earlier answer is a refusal.
679
+ //? By route, not by order or count: the drain request's hold can land before or after this one's.
680
+ const holding = /holding build-route \S*\/second until the builder is ready/;
681
+ // With the gate shut, an answer before that hold is a refusal.
680
682
  const answeredUnheld = await Promise.race([
681
- host
682
- .waitForLogSince(start, /holding build-route until the builder is ready \(2 waiting\)/, WAIT_MS)
683
- .then(() => null),
683
+ host.waitForLogSince(start, holding, WAIT_MS).then(() => null),
684
684
  second.then((response) => response.status),
685
685
  ]);
686
686
  expect(answeredUnheld).toBeNull();
687
687
  await Bun.write(readyGate, "");
688
- const held = await host.waitForLogSince(start, /holding build-route until the builder is ready \(2 waiting\)/);
688
+ const held = await host.waitForLogSince(start, holding);
689
689
  const ready = await host.waitForLogSince(start, /builder ready after restart/, WAIT_MS);
690
690
  expect(ready.index ?? -1).toBeGreaterThan(held.index ?? Number.POSITIVE_INFINITY);
691
691
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/devkit",
3
- "version": "3.2.0-rc.19",
3
+ "version": "3.2.0-rc.20",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -205,7 +205,7 @@
205
205
  "./*": "./*.ts"
206
206
  },
207
207
  "dependencies": {
208
- "@akanjs/language": "3.2.0-rc.19",
208
+ "@akanjs/language": "3.2.0-rc.20",
209
209
  "@earendil-works/pi-agent-core": "1.3.0",
210
210
  "@earendil-works/pi-ai": "1.3.0",
211
211
  "@earendil-works/pi-codemode": "1.3.0",
@@ -214,7 +214,7 @@
214
214
  "@earendil-works/pi-tui": "1.3.0",
215
215
  "@inquirer/prompts": "^8.7.3",
216
216
  "@tailwindcss/node": "^4.3.3",
217
- "akanjs": "3.2.0-rc.19",
217
+ "akanjs": "3.2.0-rc.20",
218
218
  "chalk": "^6.0.1",
219
219
  "commander": "^15.0.0",
220
220
  "dayjs": "^1.11.23",
@@ -8,9 +8,22 @@ export interface StoreAccessCount {
8
8
  accessCount: number;
9
9
  }
10
10
 
11
+ const formSetterPrefixes = ["set", "add", "sub", "addOrSub", "upload"];
12
+ const startsUpper = (text: string) => /^[A-Z]/.test(text);
13
+
14
+ const isFormSetterName = (name: string) => {
15
+ if (!/^\w+$/.test(name)) return false;
16
+ if (name.startsWith("writeOn")) return startsUpper(name.slice("writeOn".length));
17
+ return formSetterPrefixes.some(
18
+ (prefix) =>
19
+ name.startsWith(prefix) &&
20
+ startsUpper(name.slice(prefix.length)) &&
21
+ /On[A-Z]/.test(name.slice(prefix.length + 1)),
22
+ );
23
+ };
24
+
11
25
  //? A generated form setter only binds a field to its control: a long form is a size breach, not a busy component.
12
26
  export class StoreAccessScanner {
13
- static readonly #formSetter = /^(?:(?:set|add|sub|addOrSub|upload)[A-Z]\w*On|writeOn)[A-Z]\w*$/;
14
27
  readonly #index: WritingActionIndex;
15
28
 
16
29
  constructor(index: WritingActionIndex) {
@@ -64,7 +77,7 @@ export class StoreAccessScanner {
64
77
  access.name.text === "do" &&
65
78
  ts.isPropertyAccessExpression(action) &&
66
79
  action.expression === access &&
67
- StoreAccessScanner.#formSetter.test(action.name.text) &&
80
+ isFormSetterName(action.name.text) &&
68
81
  !this.#index.isWritingAction(action.name.text)
69
82
  );
70
83
  }
@@ -486,6 +486,12 @@ describe("Subspace pull", () => {
486
486
  });
487
487
 
488
488
  describe("SubspaceConfig", () => {
489
+ test("refuses a repo that git would read as an option", () => {
490
+ expect(
491
+ () => new SubspaceConfig({ subspaces: [{ name: "a", repo: "--upload-pack=touch pwned", apps: ["one"] }] }),
492
+ ).toThrow(/reads as a git option/);
493
+ });
494
+
489
495
  test("refuses one app claimed by two subspaces", () => {
490
496
  expect(
491
497
  () =>
@@ -146,7 +146,7 @@ export class Subspace {
146
146
  if (remotes.includes(this.#remote)) await this.#git(["remote", "set-url", this.#remote, this.#declaration.repo]);
147
147
  else await this.#git(["remote", "add", this.#remote, this.#declaration.repo]);
148
148
  try {
149
- await this.#git(["fetch", "--quiet", this.#remote, branch]);
149
+ await this.#git(["fetch", "--quiet", "--", this.#remote, branch]);
150
150
  return true;
151
151
  } catch {
152
152
  //? A subspace that has never had this branch is not an error here — `push` refuses it by name.
@@ -53,9 +53,9 @@ export class SubspaceClone {
53
53
  if (!(await FileSys.dirExists(path.join(this.#clonePath, ".git")))) {
54
54
  await rm(this.#clonePath, { recursive: true, force: true });
55
55
  await mkdir(path.dirname(this.#clonePath), { recursive: true });
56
- await this.#workspace.spawn("git", ["clone", "--quiet", this.#declaration.repo, this.#clonePath]);
56
+ await this.#workspace.spawn("git", ["clone", "--quiet", "--", this.#declaration.repo, this.#clonePath]);
57
57
  }
58
- await this.#clone.spawn("git", ["fetch", "--quiet", "origin", branch]);
58
+ await this.#clone.spawn("git", ["fetch", "--quiet", "--", "origin", branch]);
59
59
  await this.#clone.spawn("git", ["checkout", "--quiet", "-f", "-B", branch, `origin/${branch}`]);
60
60
  await this.#clone.spawn("git", ["clean", "-qfd"]);
61
61
  }
@@ -116,7 +116,7 @@ export class SubspaceClone {
116
116
  const message = `${SubspaceClone.syncSubjectPrefix}${this.#workspace.repoName}@${sha}`;
117
117
  await this.#clone.spawn("git", ["commit", "--quiet", "-m", message]);
118
118
  //* Never force: a diverged subspace holds customer commits, and `pull` is how those come back.
119
- await this.#clone.spawn("git", ["push", "--quiet", "origin", branch]);
119
+ await this.#clone.spawn("git", ["push", "--quiet", "--", "origin", branch]);
120
120
  return (await this.#clone.spawn("git", ["rev-parse", "--short", "HEAD"])).trim();
121
121
  }
122
122
 
@@ -32,6 +32,10 @@ export class SubspaceConfig {
32
32
  for (const subspace of this.subspaces) {
33
33
  if (!subspace.name || !subspace.repo)
34
34
  throw new Error(`${SubspaceConfig.source}: every subspace needs a name and a repo`);
35
+ if (subspace.repo.startsWith("-"))
36
+ throw new Error(
37
+ `${SubspaceConfig.source}: subspace "${subspace.name}" repo "${subspace.repo}" reads as a git option`,
38
+ );
35
39
  //? The name is the clone folder under .akan/subspace, which a fresh clone empties first.
36
40
  if (!SubspaceConfig.namePattern.test(subspace.name))
37
41
  throw new Error(