@akagilnc/pi-workflow-roles 0.1.4204 → 0.1.4228

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.
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Same-directory temp + rename atomic file replace.
3
+ * Shared primitive for ledger-adjacent typed pages (analyst metrics, etc.).
4
+ * Does not open/truncate an existing destination inode, so hard-linked twins
5
+ * keep prior bytes until the directory entry is swapped.
6
+ * Parent directory must already exist — callers that write under the package
7
+ * ledger home own confinement via ensureRealDirectoryTree (ADR 0038).
8
+ */
9
+ import { randomUUID } from "node:crypto";
10
+ import { rename, rm, writeFile } from "node:fs/promises";
11
+ import { dirname, join } from "node:path";
12
+ export async function writeFileAtomically(destination, contents) {
13
+ const parent = dirname(destination);
14
+ const temporary = join(parent, `.atomic-write-${randomUUID()}.tmp`);
15
+ try {
16
+ await writeFile(temporary, contents);
17
+ await rename(temporary, destination);
18
+ }
19
+ catch (error) {
20
+ await rm(temporary, { force: true }).catch(() => undefined);
21
+ throw error;
22
+ }
23
+ }
@@ -1,12 +1,12 @@
1
1
  /**
2
- * Public 起居郎 (diarist) terminating receipt contracts — ADR 0075(起居郎是 LLM 角色)。
2
+ * Public 起居郎 (diarist) terminating receipt contracts — ADR 0075 `diarist-is-role` / #901.
3
3
  * Lawful explicit releases: completed (入录) | escalate (认不出本庭对象上抛).
4
- * Machine facts about the volume come from the mechanical sitian seam, never
4
+ * Machine facts about the volume come from the mechanical reproject seam, never
5
5
  * from model self-report (锚定宪法); this module owns the receipt shape only.
6
6
  *
7
- * #779: no frozen candidate catalog; LLM finds sources and submits whole blocks.
8
- * Mechanical layer does not judge LLM output (no quote/ticket/relevance verify).
7
+ * #901: LLM submits bounds (+ optional amendments); mechanical layer projects.
9
8
  */
9
+ import { projectTicketProvenanceAmendments, projectTicketProvenanceSessions, } from "./ticket-provenance-contracts.js";
10
10
  import { isSafePositiveTicketNumber, requireSafePositiveTicketNumber, } from "./run-ticket-number.js";
11
11
  export const DIARIST_OUTPUT_TOOL_NAME = "ak_diarist_output";
12
12
  export const DIARIST_ACCEPTED_TEXT = "起居郎回执已接受";
@@ -121,8 +121,22 @@ export function validateRecordedDiaristOutput(value) {
121
121
  }
122
122
  throw new Error("Diarist output has no execution discriminator");
123
123
  }
124
- /** Entries array as the diarist wrote it — no field rewrite (#836 B6.8/B6.9). */
125
- export function projectDiaristEntries(value) {
126
- const rows = value?.entries;
127
- return Array.isArray(rows) ? [...rows] : [];
124
+ /**
125
+ * Project sessions from a completed diarist payload.
126
+ * Absent key → empty (lawful). Present but unusable → undefined (caller reasks).
127
+ */
128
+ export function projectDiaristSessions(value) {
129
+ const raw = value?.sessions;
130
+ if (raw === undefined)
131
+ return [];
132
+ return projectTicketProvenanceSessions(raw);
133
+ }
134
+ /**
135
+ * Project optional amendments. Absent / non-array → empty (not a rejection).
136
+ */
137
+ export function projectDiaristAmendments(value) {
138
+ const raw = value?.amendments;
139
+ if (raw === undefined)
140
+ return [];
141
+ return projectTicketProvenanceAmendments(raw);
128
142
  }