@afokapu/atdd-flow 0.3.79 → 0.3.80

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afokapu/atdd-flow",
3
- "version": "0.3.79",
3
+ "version": "0.3.80",
4
4
  "description": "Filesystem-first Desk registry for projects, seats, tasks, threads, and handoffs.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -30,6 +30,7 @@ export type StaleMainRecovery = {
30
30
  relocation?: Relocation;
31
31
  };
32
32
 
33
+ const LAUNCH_RECEIPT_SCHEMA = "atdd-flow/pi-runtime-launch-receipt/v1";
33
34
  export const MANUAL_REBINDING_SCHEMA = "atdd-flow/manual-pi-runtime-rebinding-receipt/v1";
34
35
  export const MANUAL_REBINDING_MODE = "operator-authorized-manual-in-place-adoption";
35
36
 
@@ -84,7 +85,7 @@ export function receiptProvesCanonical(receipt: PriorReceipt, seat: string, cano
84
85
  }
85
86
 
86
87
  function launchReceiptProvesCanonical(receipt: PriorReceipt, seat: string, canonical: StaleMainRecovery["canonical_source"]) {
87
- return receipt.schema === "atdd-flow/pi-runtime-launch-receipt/v1" && receipt.seat === seat
88
+ return receipt.schema === LAUNCH_RECEIPT_SCHEMA && receipt.seat === seat
88
89
  && receipt.pi_session === canonical.pi_session && receipt.pi_session_path === canonical.pi_session_path
89
90
  && receipt.herdr_session === canonical.herdr_session && receipt.pane === canonical.pane;
90
91
  }
@@ -264,12 +265,18 @@ export async function buildStaleMainRecovery(root: string, seat: string, intent:
264
265
 
265
266
  const refuse = (reason: string) => new Error(`Stale main relocation receipt recovery refused: ${reason}.`);
266
267
 
267
- /** True when the seat records a manual binding_mode or its launch receipt is a manual rebinding receipt, rather than a launcher receipt. */
268
+ /** The recorded receipt, or undefined when it is unreadable or malformed. */
269
+ async function readReceipt(path: string) {
270
+ try { return yaml.parse<PriorReceipt>(await readFile(path, "utf8")); } catch { return undefined; }
271
+ }
272
+
273
+ /** A launcher receipt is never manual, even if the seat retains a binding_mode; any other receipt is manual when it has the manual schema or the seat records a binding_mode. */
268
274
  export async function isManualRebindingReceipt(record: Seat) {
269
275
  const path = record.runtime?.launch_receipt;
270
276
  if (!path) return false;
271
- if (record.runtime?.binding_mode !== undefined) return true;
272
- try { return yaml.parse<PriorReceipt>(await readFile(path, "utf8")).schema === MANUAL_REBINDING_SCHEMA; } catch { return false; }
277
+ const schema = (await readReceipt(path))?.schema;
278
+ if (schema === LAUNCH_RECEIPT_SCHEMA) return false;
279
+ return record.runtime?.binding_mode !== undefined || schema === MANUAL_REBINDING_SCHEMA;
273
280
  }
274
281
 
275
282
  /** A backup file must hash to its recorded digest (and size, when recorded) and be the exact byte prefix of the adopted session transcript. */
@@ -390,10 +397,8 @@ export async function relocationFor(record: Seat, source: Source, target: Target
390
397
  }
391
398
 
392
399
  async function readLauncherReceipt(path: string) {
393
- try {
394
- const receipt = yaml.parse<PriorReceipt>(await readFile(path, "utf8"));
395
- return receipt.schema === "atdd-flow/pi-runtime-launch-receipt/v1" ? receipt : undefined;
396
- } catch { return undefined; }
400
+ const receipt = await readReceipt(path);
401
+ return receipt?.schema === LAUNCH_RECEIPT_SCHEMA ? receipt : undefined;
397
402
  }
398
403
 
399
404
  /** The launcher receipt names this seat's exact recorded Pi at a pane other than the seat's current locator. */