@akagilnc/pi-workflow-roles 0.1.4759 → 0.1.4772

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.
@@ -196,6 +196,29 @@ function rewriteSummonsMaterials(
196
196
  }
197
197
  }
198
198
 
199
+ /** Project one admitted page in memory after its containing run moved. */
200
+ export function rewriteAdmittedRoleRunPage(
201
+ page: Record<string, unknown>,
202
+ rewrites: readonly RunDirectoryPathRewrite[],
203
+ ): void {
204
+ rewriteRunDirectoryPathFieldsAgainstRewrites(page, ADMITTED_PAGE_FIELDS, rewrites);
205
+ rewriteSourceRunLocator(page.sourceRun, rewrites);
206
+ if (Array.isArray(page.attachments)) {
207
+ for (const attachment of page.attachments) {
208
+ if (isPlainObject(attachment)) {
209
+ rewriteRunDirectoryPathFieldsAgainstRewrites(attachment, ["frozenPath"], rewrites);
210
+ }
211
+ }
212
+ }
213
+ if (isPlainObject(page.principal)) {
214
+ rewriteRunDirectoryPathFieldsAgainstRewrites(
215
+ page.principal,
216
+ ["sessionDirectory", "sessionFile"],
217
+ rewrites,
218
+ );
219
+ }
220
+ }
221
+
199
222
  async function rewriteJsonObjectFile(
200
223
  path: string,
201
224
  fields: readonly string[],
@@ -394,9 +417,9 @@ async function rewriteNestedMachinePathPages(
394
417
  /**
395
418
  * Rewrite admitted-request / invocation / run-state path fields (attachment
396
419
  * frozenPath / summons.attachmentPaths pointers only), then nested package-owned
397
- * session seams, after the run directory has already been moved or copied.
398
- * `pagesDirectory` is where the pages now live; path strings still naming an
399
- * old run directory become the matching new directory. `crossRunRewrites`
420
+ * session seams. Callers may rewrite before or after the filesystem move/copy:
421
+ * `pagesDirectory` is where the pages currently live on disk; path strings that
422
+ * still name `oldRunDirectory` become `newRunDirectory`. `crossRunRewrites`
400
423
  * covers officer/parent pointers that landed under a different final placement.
401
424
  */
402
425
  export async function rewriteRoleRunDurablePages(input: {
@@ -414,33 +437,7 @@ export async function rewriteRoleRunDurablePages(input: {
414
437
  string,
415
438
  unknown
416
439
  >;
417
- rewriteRunDirectoryPathFieldsAgainstRewrites(
418
- page,
419
- ADMITTED_PAGE_FIELDS,
420
- rewrites,
421
- );
422
- // Nested notary typed locator — same value family as top-level sourceRunPath.
423
- rewriteSourceRunLocator(page.sourceRun, rewrites);
424
- if (Array.isArray(page.attachments)) {
425
- for (const attachment of page.attachments) {
426
- if (isPlainObject(attachment)) {
427
- // Pointer only — never open or mutate frozen attachment bytes.
428
- rewriteRunDirectoryPathFieldsAgainstRewrites(
429
- attachment,
430
- ["frozenPath"],
431
- rewrites,
432
- );
433
- }
434
- }
435
- }
436
- // Nested principal wire (sessionDirectory/sessionFile) when present.
437
- if (isPlainObject(page.principal)) {
438
- rewriteRunDirectoryPathFieldsAgainstRewrites(
439
- page.principal,
440
- ["sessionDirectory", "sessionFile"],
441
- rewrites,
442
- );
443
- }
440
+ rewriteAdmittedRoleRunPage(page, rewrites);
444
441
  await writeFile(admittedPath, `${JSON.stringify(page, null, 2)}\n`, "utf8");
445
442
  }
446
443