@akagilnc/pi-workflow-roles 0.1.4889 → 0.1.4905

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.
@@ -14649,13 +14649,16 @@ async function rewriteOfficerPointerFile(path7, rewrites) {
14649
14649
  const page = JSON.parse(await readFile2(path7, "utf8"));
14650
14650
  if (!isPlainObject(page)) return;
14651
14651
  if (page.kind !== "direct-officer-run-pointer") return;
14652
+ const before = JSON.stringify(page);
14652
14653
  rewriteRunDirectoryPathFieldsAgainstRewrites(
14653
14654
  page,
14654
14655
  OFFICER_POINTER_FIELDS,
14655
14656
  rewrites
14656
14657
  );
14657
- await writeFile(path7, `${JSON.stringify(page)}
14658
+ if (JSON.stringify(page) !== before) {
14659
+ await writeFile(path7, `${JSON.stringify(page)}
14658
14660
  `, "utf8");
14661
+ }
14659
14662
  }
14660
14663
  async function rewriteSitianRecordsJsonl(path7, rewrites) {
14661
14664
  if (!existsSync(path7)) return;
@@ -14802,28 +14805,27 @@ async function rewriteRoleRunDurablePages(input) {
14802
14805
  const admittedPath = join4(pagesDirectory, "admitted-request.json");
14803
14806
  if (existsSync(admittedPath)) {
14804
14807
  const page = JSON.parse(await readFile2(admittedPath, "utf8"));
14808
+ const before = JSON.stringify(page);
14805
14809
  rewriteAdmittedRoleRunPage(page, rewrites);
14806
- await writeFile(admittedPath, `${JSON.stringify(page, null, 2)}
14810
+ if (JSON.stringify(page) !== before) {
14811
+ await writeFile(admittedPath, `${JSON.stringify(page, null, 2)}
14807
14812
  `, "utf8");
14813
+ }
14808
14814
  }
14809
14815
  const invocationPath = join4(pagesDirectory, "invocation.json");
14810
14816
  if (existsSync(invocationPath)) {
14811
14817
  const page = JSON.parse(await readFile2(invocationPath, "utf8"));
14812
- rewriteRunDirectoryPathFieldsAgainstRewrites(
14813
- page,
14814
- INVOCATION_PAGE_FIELDS,
14815
- rewrites
14816
- );
14817
- await writeFile(
14818
- invocationPath,
14819
- `${JSON.stringify(page, null, 2)}
14820
- `,
14821
- "utf8"
14822
- );
14818
+ const before = JSON.stringify(page);
14819
+ rewriteRunDirectoryPathFieldsAgainstRewrites(page, INVOCATION_PAGE_FIELDS, rewrites);
14820
+ if (JSON.stringify(page) !== before) {
14821
+ await writeFile(invocationPath, `${JSON.stringify(page, null, 2)}
14822
+ `, "utf8");
14823
+ }
14823
14824
  }
14824
14825
  const statePath = join4(pagesDirectory, "run-state.json");
14825
14826
  if (existsSync(statePath)) {
14826
14827
  const page = JSON.parse(await readFile2(statePath, "utf8"));
14828
+ const before = JSON.stringify(page);
14827
14829
  rewriteRunDirectoryPathFieldsAgainstRewrites(
14828
14830
  page,
14829
14831
  RUN_STATE_PAGE_FIELDS,
@@ -14839,8 +14841,10 @@ async function rewriteRoleRunDurablePages(input) {
14839
14841
  if (isPlainObject(page.currentCourt)) {
14840
14842
  rewriteSummonsMaterials(page.currentCourt.summons, rewrites);
14841
14843
  }
14842
- await writeFile(statePath, `${JSON.stringify(page, null, 2)}
14844
+ if (JSON.stringify(page) !== before) {
14845
+ await writeFile(statePath, `${JSON.stringify(page, null, 2)}
14843
14846
  `, "utf8");
14847
+ }
14844
14848
  }
14845
14849
  await rewriteNestedMachinePathPages(pagesDirectory, rewrites);
14846
14850
  }
@@ -279872,8 +279876,7 @@ async function relocateBoardBoundUnboundRunsInBook(bookDirectory) {
279872
279876
  ticketNumber: move.ticketNumber
279873
279877
  }));
279874
279878
  }
279875
- async function relocateBoardBoundUnboundRunsInBooks(booksDirectory, env2 = process.env) {
279876
- await assertBookTopologyMigrationPrerequisites(booksDirectory, env2);
279879
+ async function relocateBoardBoundUnboundRunsInBooks(booksDirectory) {
279877
279880
  const relocated = [];
279878
279881
  for (const bookKey of await listMigrationBookKeys(booksDirectory)) {
279879
279882
  const batch = await relocateBoardBoundUnboundRunsInBook(
@@ -155,8 +155,11 @@ async function rewriteOfficerPointerFile(path, rewrites) {
155
155
  // Only the typed direct-officer pointer shape — never arbitrary .pointer.json.
156
156
  if (page.kind !== "direct-officer-run-pointer")
157
157
  return;
158
+ const before = JSON.stringify(page);
158
159
  rewriteRunDirectoryPathFieldsAgainstRewrites(page, OFFICER_POINTER_FIELDS, rewrites);
159
- await writeFile(path, `${JSON.stringify(page)}\n`, "utf8");
160
+ if (JSON.stringify(page) !== before) {
161
+ await writeFile(path, `${JSON.stringify(page)}\n`, "utf8");
162
+ }
160
163
  }
161
164
  async function rewriteSitianRecordsJsonl(path, rewrites) {
162
165
  if (!existsSync(path))
@@ -320,18 +323,25 @@ export async function rewriteRoleRunDurablePages(input) {
320
323
  const admittedPath = join(pagesDirectory, "admitted-request.json");
321
324
  if (existsSync(admittedPath)) {
322
325
  const page = JSON.parse(await readFile(admittedPath, "utf8"));
326
+ const before = JSON.stringify(page);
323
327
  rewriteAdmittedRoleRunPage(page, rewrites);
324
- await writeFile(admittedPath, `${JSON.stringify(page, null, 2)}\n`, "utf8");
328
+ if (JSON.stringify(page) !== before) {
329
+ await writeFile(admittedPath, `${JSON.stringify(page, null, 2)}\n`, "utf8");
330
+ }
325
331
  }
326
332
  const invocationPath = join(pagesDirectory, "invocation.json");
327
333
  if (existsSync(invocationPath)) {
328
334
  const page = JSON.parse(await readFile(invocationPath, "utf8"));
335
+ const before = JSON.stringify(page);
329
336
  rewriteRunDirectoryPathFieldsAgainstRewrites(page, INVOCATION_PAGE_FIELDS, rewrites);
330
- await writeFile(invocationPath, `${JSON.stringify(page, null, 2)}\n`, "utf8");
337
+ if (JSON.stringify(page) !== before) {
338
+ await writeFile(invocationPath, `${JSON.stringify(page, null, 2)}\n`, "utf8");
339
+ }
331
340
  }
332
341
  const statePath = join(pagesDirectory, "run-state.json");
333
342
  if (existsSync(statePath)) {
334
343
  const page = JSON.parse(await readFile(statePath, "utf8"));
344
+ const before = JSON.stringify(page);
335
345
  rewriteRunDirectoryPathFieldsAgainstRewrites(page, RUN_STATE_PAGE_FIELDS, rewrites);
336
346
  if (isPlainObject(page.principal)) {
337
347
  rewriteRunDirectoryPathFieldsAgainstRewrites(page.principal, ["sessionDirectory", "sessionFile"], rewrites);
@@ -340,7 +350,9 @@ export async function rewriteRoleRunDurablePages(input) {
340
350
  if (isPlainObject(page.currentCourt)) {
341
351
  rewriteSummonsMaterials(page.currentCourt.summons, rewrites);
342
352
  }
343
- await writeFile(statePath, `${JSON.stringify(page, null, 2)}\n`, "utf8");
353
+ if (JSON.stringify(page) !== before) {
354
+ await writeFile(statePath, `${JSON.stringify(page, null, 2)}\n`, "utf8");
355
+ }
344
356
  }
345
357
  await rewriteNestedMachinePathPages(pagesDirectory, rewrites);
346
358
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akagilnc/pi-workflow-roles",
3
- "version": "0.1.4889",
3
+ "version": "0.1.4905",
4
4
  "description": "Soul-bound workflow roles for Pi",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -17,7 +17,6 @@ import {
17
17
  resolveMigratingRunTicket,
18
18
  } from "./book-topology-migration-placement.ts";
19
19
  import {
20
- assertBookTopologyMigrationPrerequisites,
21
20
  reconcileMigrationPartition,
22
21
  type BookTopologyMigrationContext,
23
22
  type BookTopologyPartitionMigrator,
@@ -378,13 +377,11 @@ export async function relocateBoardBoundUnboundRunsInBook(
378
377
 
379
378
  /**
380
379
  * Walk every book under `booksDirectory` and relocate board-bound unbound
381
- * runs in place. Requires zero live writer locks (same gate as topology migrate).
380
+ * runs in place without the whole-books topology migration's in-flight gate.
382
381
  */
383
382
  export async function relocateBoardBoundUnboundRunsInBooks(
384
383
  booksDirectory: string,
385
- env: NodeJS.ProcessEnv = process.env,
386
384
  ): Promise<readonly BoardBoundUnboundRelocation[]> {
387
- await assertBookTopologyMigrationPrerequisites(booksDirectory, env);
388
385
  const relocated: BoardBoundUnboundRelocation[] = [];
389
386
  for (const bookKey of await listMigrationBookKeys(booksDirectory)) {
390
387
  const batch = await relocateBoardBoundUnboundRunsInBook(
@@ -227,12 +227,15 @@ async function rewriteOfficerPointerFile(
227
227
  if (!isPlainObject(page)) return;
228
228
  // Only the typed direct-officer pointer shape — never arbitrary .pointer.json.
229
229
  if (page.kind !== "direct-officer-run-pointer") return;
230
+ const before = JSON.stringify(page);
230
231
  rewriteRunDirectoryPathFieldsAgainstRewrites(
231
232
  page,
232
233
  OFFICER_POINTER_FIELDS,
233
234
  rewrites,
234
235
  );
235
- await writeFile(path, `${JSON.stringify(page)}\n`, "utf8");
236
+ if (JSON.stringify(page) !== before) {
237
+ await writeFile(path, `${JSON.stringify(page)}\n`, "utf8");
238
+ }
236
239
  }
237
240
 
238
241
  async function rewriteSitianRecordsJsonl(
@@ -422,26 +425,21 @@ export async function rewriteRoleRunDurablePages(input: {
422
425
  string,
423
426
  unknown
424
427
  >;
428
+ const before = JSON.stringify(page);
425
429
  rewriteAdmittedRoleRunPage(page, rewrites);
426
- await writeFile(admittedPath, `${JSON.stringify(page, null, 2)}\n`, "utf8");
430
+ if (JSON.stringify(page) !== before) {
431
+ await writeFile(admittedPath, `${JSON.stringify(page, null, 2)}\n`, "utf8");
432
+ }
427
433
  }
428
434
 
429
435
  const invocationPath = join(pagesDirectory, "invocation.json");
430
436
  if (existsSync(invocationPath)) {
431
- const page = JSON.parse(await readFile(invocationPath, "utf8")) as Record<
432
- string,
433
- unknown
434
- >;
435
- rewriteRunDirectoryPathFieldsAgainstRewrites(
436
- page,
437
- INVOCATION_PAGE_FIELDS,
438
- rewrites,
439
- );
440
- await writeFile(
441
- invocationPath,
442
- `${JSON.stringify(page, null, 2)}\n`,
443
- "utf8",
444
- );
437
+ const page = JSON.parse(await readFile(invocationPath, "utf8")) as Record<string, unknown>;
438
+ const before = JSON.stringify(page);
439
+ rewriteRunDirectoryPathFieldsAgainstRewrites(page, INVOCATION_PAGE_FIELDS, rewrites);
440
+ if (JSON.stringify(page) !== before) {
441
+ await writeFile(invocationPath, `${JSON.stringify(page, null, 2)}\n`, "utf8");
442
+ }
445
443
  }
446
444
 
447
445
  const statePath = join(pagesDirectory, "run-state.json");
@@ -450,6 +448,7 @@ export async function rewriteRoleRunDurablePages(input: {
450
448
  string,
451
449
  unknown
452
450
  >;
451
+ const before = JSON.stringify(page);
453
452
  rewriteRunDirectoryPathFieldsAgainstRewrites(
454
453
  page,
455
454
  RUN_STATE_PAGE_FIELDS,
@@ -466,7 +465,9 @@ export async function rewriteRoleRunDurablePages(input: {
466
465
  if (isPlainObject(page.currentCourt)) {
467
466
  rewriteSummonsMaterials(page.currentCourt.summons, rewrites);
468
467
  }
469
- await writeFile(statePath, `${JSON.stringify(page, null, 2)}\n`, "utf8");
468
+ if (JSON.stringify(page) !== before) {
469
+ await writeFile(statePath, `${JSON.stringify(page, null, 2)}\n`, "utf8");
470
+ }
470
471
  }
471
472
 
472
473
  await rewriteNestedMachinePathPages(pagesDirectory, rewrites);