@akagilnc/pi-workflow-roles 0.1.5679 → 0.1.5698

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.
@@ -30,16 +30,17 @@ export async function resolveLiveRunDirectoryPath(recordedPath, home) {
30
30
  /**
31
31
  * Prefer the request path when it still exists; otherwise re-locate by run id
32
32
  * (resolveLiveRunDirectoryPath). Mutates the live request so later turn-record /
33
- * exit-copy / fault notes stay on the new leaf.
33
+ * exit-copy / fault notes stay on the new leaf. Authority is required so opaque
34
+ * principal wire is resealed — never shape-guessed in place (#1183).
34
35
  */
35
- export async function syncTurnRequestLivePlacement(request) {
36
+ export async function syncTurnRequestLivePlacement(request, authority) {
36
37
  const live = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
37
38
  if (live === undefined) {
38
39
  const parsed = parseRunLeaf(basename(request.runDirectory));
39
40
  throw new Error(`admitted run ${parsed?.runId ?? "(unparseable)"} missing after host turn; not found under ${request.home}`);
40
41
  }
41
42
  if (live !== request.runDirectory) {
42
- projectTurnRequestLiveRunDirectory(request, live);
43
+ projectTurnRequestLiveRunDirectory(request, live, authority);
43
44
  }
44
45
  return live;
45
46
  }
@@ -47,34 +48,51 @@ export async function syncTurnRequestLivePlacement(request) {
47
48
  * Soft live-path sync for cleanup / dossier work: lookup failure stays beside the
48
49
  * caller and never revives a vanished leaf. Same authority as syncTurnRequestLivePlacement.
49
50
  */
50
- export async function trySyncTurnRequestLivePlacement(request) {
51
+ export async function trySyncTurnRequestLivePlacement(request, authority) {
51
52
  try {
52
- return { runDirectory: await syncTurnRequestLivePlacement(request) };
53
+ return { runDirectory: await syncTurnRequestLivePlacement(request, authority) };
53
54
  }
54
55
  catch (resolveError) {
55
56
  return { resolveError };
56
57
  }
57
58
  }
58
59
  /**
59
- * Retain a package fault on the live leaf when locatable. Lookup failure must not
60
- * replace the original fault or block later cleanup — reuse retainPackageFault when
61
- * the leaf exists; otherwise present both causes on stderr (Pi transport path shape).
60
+ * Retain a package fault on the live leaf when locatable. Directory lookup only —
61
+ * does not mutate live principal identity (#1183). Lookup failure must not replace
62
+ * the original fault or block later cleanup.
62
63
  */
63
64
  export async function retainPackageFaultBesideLivePlacement(request, input) {
64
- const live = await trySyncTurnRequestLivePlacement(request);
65
- if ("resolveError" in live) {
66
- const resolveDiagnostic = `live run path resolve failed beside fault: ${describeErrorIdentity(live.resolveError)}`;
65
+ let runDirectory = request.runDirectory;
66
+ if (!existsSync(runDirectory)) {
67
67
  try {
68
- process.stderr.write(`${input.diagnostic}\n`);
69
- process.stderr.write(`${resolveDiagnostic}\n`);
68
+ const found = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
69
+ if (found === undefined) {
70
+ const resolveDiagnostic = `live run path resolve failed beside fault: admitted run missing under ${request.home}`;
71
+ try {
72
+ process.stderr.write(`${input.diagnostic}\n`);
73
+ process.stderr.write(`${resolveDiagnostic}\n`);
74
+ }
75
+ catch {
76
+ // Best-effort presentation beside an already-chosen terminal.
77
+ }
78
+ return;
79
+ }
80
+ runDirectory = found;
70
81
  }
71
- catch {
72
- // Best-effort presentation beside an already-chosen terminal.
82
+ catch (resolveError) {
83
+ const resolveDiagnostic = `live run path resolve failed beside fault: ${describeErrorIdentity(resolveError)}`;
84
+ try {
85
+ process.stderr.write(`${input.diagnostic}\n`);
86
+ process.stderr.write(`${resolveDiagnostic}\n`);
87
+ }
88
+ catch {
89
+ // Best-effort presentation beside an already-chosen terminal.
90
+ }
91
+ return;
73
92
  }
74
- return;
75
93
  }
76
94
  await retainPackageFault({
77
- runDirectory: live.runDirectory,
95
+ runDirectory,
78
96
  diagnostic: input.diagnostic,
79
97
  ...(Object.hasOwn(input, "error") ? { error: input.error } : {}),
80
98
  });