@akagilnc/pi-workflow-roles 0.1.5406 → 0.1.5475

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.
Files changed (93) hide show
  1. package/CLAUDE.md +1 -1
  2. package/README.md +42 -55
  3. package/README.zh-CN.md +59 -73
  4. package/THIRD_PARTY_NOTICES.md +4 -7
  5. package/dist/acp-host/production-host.js +8261 -9073
  6. package/dist/collector-tool-schemas.js +1 -1
  7. package/dist/compliance-transport.js +2 -5
  8. package/dist/engine-detour-usage.js +3 -30
  9. package/dist/gatekeeper-role.js +4 -18
  10. package/dist/headless-host/description.js +0 -209
  11. package/dist/headless-host/production-host.js +6973 -8035
  12. package/dist/host-contracts.js +8 -0
  13. package/dist/migrate-book-topology.js +30 -27
  14. package/dist/packaged-role-registry.js +1 -9
  15. package/dist/pi/role-turn-host.js +37 -19
  16. package/dist/public-cli/auto-resume.js +29 -66
  17. package/dist/public-cli/countersign-run.js +4 -18
  18. package/dist/public-cli/instruction-seat-run.js +59 -76
  19. package/dist/public-cli/main.js +9844 -10720
  20. package/dist/public-cli/option-definitions.js +1 -1
  21. package/dist/public-cli/post-admission.js +204 -285
  22. package/dist/public-cli/process-cancel.js +8 -0
  23. package/dist/public-cli/run-lifecycle.js +24 -94
  24. package/dist/public-cli/settlement.js +614 -1524
  25. package/dist/public-cli/terminal.js +23 -53
  26. package/dist/public-role-summons.js +3 -8
  27. package/dist/receipt-delivery-policy.js +11 -12
  28. package/dist/run-terminal-artifacts.js +19 -14
  29. package/dist/serialize-thrown-value.js +7 -1
  30. package/dist/submission-ledger.js +21 -89
  31. package/package.json +1 -1
  32. package/packets/fixer-repair.md +3 -1
  33. package/packets/judge-apply.md +7 -16
  34. package/packets/judge-authority.md +7 -17
  35. package/packets/judge-plan.md +7 -18
  36. package/packets/judge-review.md +8 -22
  37. package/packets/judge-submission.md +4 -7
  38. package/resources/collector-bot-handbook.md +2 -2
  39. package/resources/diarist-collect.md +2 -2
  40. package/resources/engine-dispatch.md +2 -2
  41. package/resources/navigator-route-playbook.md +1 -1
  42. package/resources/secretariat-ticket-identity.md +1 -1
  43. package/scripts/build-package.mjs +0 -2
  44. package/souls/coder-output-guide.md +3 -3
  45. package/souls/coder.md +2 -3
  46. package/souls/doctor-auditor.md +0 -3
  47. package/souls/fixer-auditor.md +0 -2
  48. package/souls/fixer-output-guide.md +3 -3
  49. package/souls/fixer.md +2 -2
  50. package/souls/gate-output-guide.md +1 -1
  51. package/souls/quality-law.md +2 -0
  52. package/src/acp-host/role-turn-host.ts +168 -75
  53. package/src/collector-tool-schemas.ts +1 -1
  54. package/src/compliance-transport.ts +3 -6
  55. package/src/engine-detour-usage.ts +3 -33
  56. package/src/external-host-turn-loop.ts +81 -36
  57. package/src/gatekeeper-role.ts +5 -20
  58. package/src/headless-host/description.ts +4 -214
  59. package/src/headless-host/production-host.ts +2 -1
  60. package/src/headless-host/role-turn-host.ts +153 -186
  61. package/src/host-contracts.ts +13 -10
  62. package/src/navigator-public-session.ts +1 -1
  63. package/src/navigator-session-contracts.ts +1 -1
  64. package/src/package-contracts/gatekeeper-output.ts +1 -1
  65. package/src/package-contracts/navigator-output.ts +1 -1
  66. package/src/package-contracts/terminating-infrastructure.ts +1 -1
  67. package/src/packaged-role-registry.ts +2 -10
  68. package/src/pi/adapter.ts +0 -3
  69. package/src/pi/role-turn-host.ts +42 -28
  70. package/src/prepared-role-turn.ts +2 -0
  71. package/src/public-cli/auto-resume.ts +27 -66
  72. package/src/public-cli/countersign-run.ts +4 -22
  73. package/src/public-cli/instruction-seat-run.ts +79 -80
  74. package/src/public-cli/option-definitions.ts +1 -1
  75. package/src/public-cli/post-admission.ts +264 -340
  76. package/src/public-cli/process-cancel.ts +9 -0
  77. package/src/public-cli/run-lifecycle.ts +25 -126
  78. package/src/public-cli/settlement.ts +792 -1912
  79. package/src/public-cli/terminal.ts +29 -69
  80. package/src/public-role-summons.ts +3 -8
  81. package/src/receipt-delivery-policy.ts +11 -12
  82. package/src/role-envelope.ts +16 -9
  83. package/src/role-runtime.ts +14 -81
  84. package/src/run-terminal-artifacts.ts +21 -17
  85. package/src/serialize-thrown-value.ts +7 -1
  86. package/src/submission-ledger.ts +30 -116
  87. package/dist/audit-escalation.js +0 -7
  88. package/dist/pi/known-failure.js +0 -51
  89. package/dist/typed-provider-http.js +0 -57
  90. package/dist/upstream-error-testimony.js +0 -19
  91. package/src/pi/known-failure.ts +0 -76
  92. package/src/typed-provider-http.ts +0 -89
  93. package/src/upstream-error-testimony.ts +0 -45
@@ -1,3 +1,4 @@
1
+ import { serializeThrownValue } from "../serialize-thrown-value.js";
1
2
  /** Encode one free-text Terminal cell. JSON string form cannot embed raw tab/newline. */
2
3
  export function encodeTerminalField(value) {
3
4
  return JSON.stringify(value);
@@ -10,36 +11,15 @@ export function exitCodeForTerminalOutcome(outcome) {
10
11
  return isLawfulTypedTerminalOutcome(outcome) ? 0 : 1;
11
12
  }
12
13
  /**
13
- * One admitted Role run's typed Terminal aggregate.
14
- * Resumable failures carry `resume` and must not re-disclose the run ID via
15
- * top-level `runId` or public artifact path components — only `resume.command`.
16
- * #416: autoResumeCount (0..2) is a call-local observation of how many in-place
17
- * auto-resumes occurred during this single LLM call; it is not persisted to
18
- * run-state.json and does not participate in limit decisions.
14
+ * Parent-facing current reply: a court's own accepted/audit payloads only.
15
+ * Run-scoped history stays on TerminalResult.submissions (#879 / #836), and a
16
+ * failure face never answers as this court's reply (#953).
19
17
  */
20
- /**
21
- * Current-result payloads on a terminal — accepted/audit role result, or a
22
- * rare intentional failure face. Run history is TerminalResult.submissions
23
- * (#836 / #953), not this helper.
24
- */
25
- export function roleResultPayloads(outcome) {
26
- if (outcome.kind === "accepted" || outcome.kind === "audit_escalation")
27
- return outcome.payloads ?? [];
28
- if (outcome.kind === "failure")
29
- return outcome.payloads ?? [];
30
- return [];
31
- }
32
- /**
33
- * Prefer non-empty current-result payloads; an empty array must not shadow
34
- * top-level submissions (#953 / #836). Callers that need failure history must
35
- * read TerminalResult.submissions directly — do not coalesce into failure.payloads.
36
- */
37
- export function coalesceSubmissionRows(payloads, submissions) {
38
- if (payloads !== undefined && payloads.length > 0)
39
- return payloads;
40
- if (submissions !== undefined && submissions.length > 0)
41
- return submissions;
42
- return payloads ?? submissions ?? [];
18
+ export function currentReplyRows(terminal) {
19
+ const outcome = terminal?.roleOutcome;
20
+ return outcome?.kind === "accepted" || outcome?.kind === "audit_escalation"
21
+ ? outcome.payloads ?? []
22
+ : [];
43
23
  }
44
24
  /**
45
25
  * Build an advice navigator fact (#959). Prose is presented as submitted;
@@ -87,7 +67,7 @@ export function formatTerminalResult(result) {
87
67
  for (const [key, value] of Object.entries(facts)) {
88
68
  if (value === undefined)
89
69
  continue;
90
- const rendered = typeof value === "string" ? value : JSON.stringify(value);
70
+ const rendered = typeof value === "string" ? value : serializeThrownValue(value);
91
71
  lines.push(`fact\t${encodeTerminalField(key)}\t${encodeTerminalField(rendered)}`);
92
72
  }
93
73
  }
@@ -126,11 +106,7 @@ export function formatTerminalResult(result) {
126
106
  }
127
107
  }
128
108
  }
129
- if (result.resume !== undefined) {
130
- // Resumable failure: run ID is revealed only inside the complete resume command.
131
- lines.push(`resume\t${encodeTerminalField(result.resume.command)}`);
132
- }
133
- else if (result.runId !== undefined) {
109
+ if (result.runId !== undefined) {
134
110
  lines.push(`run\t${encodeTerminalField(result.runId)}`);
135
111
  }
136
112
  if (result.autoResumeCount !== undefined) {
@@ -138,25 +114,19 @@ export function formatTerminalResult(result) {
138
114
  }
139
115
  // Role-result block: original payloads, newest first for humans (#961).
140
116
  // Typed payloads/submissions stay ledger order; only this presentation reverses.
141
- // #953: failure history is the top-level submissions carrier (#836) — present
142
- // as recorded-submission, never as this-turn submission/receipt.
143
- if (result.roleOutcome.kind === "failure") {
144
- const recorded = result.submissions ?? [];
145
- for (let i = recorded.length - 1; i >= 0; i -= 1) {
146
- const payload = recorded[i];
147
- const rendered = typeof payload === "string" ? payload : JSON.stringify(payload);
148
- lines.push(`recorded-submission\t${encodeTerminalField(rendered)}`);
149
- }
150
- }
151
- else {
152
- const payloads = result.roleOutcome.kind === "accepted" ||
153
- result.roleOutcome.kind === "audit_escalation"
154
- ? coalesceSubmissionRows(result.submissions, result.roleOutcome.payloads)
155
- : result.submissions ?? [];
156
- for (let i = payloads.length - 1; i >= 0; i -= 1) {
157
- const payload = payloads[i];
117
+ // Present the current result and the run history on distinct faces (#879 / #836).
118
+ // Neither a prior court's submission nor a failed turn's history is this reply.
119
+ const current = result.roleOutcome.kind === "failure"
120
+ ? result.roleOutcome.payloads ?? []
121
+ : currentReplyRows(result);
122
+ for (const [label, rows] of [
123
+ ["submission", current],
124
+ ["recorded-submission", result.submissions ?? []],
125
+ ]) {
126
+ for (let i = rows.length - 1; i >= 0; i -= 1) {
127
+ const payload = rows[i];
158
128
  const rendered = typeof payload === "string" ? payload : JSON.stringify(payload);
159
- lines.push(`submission\t${encodeTerminalField(rendered)}`);
129
+ lines.push(`${label}\t${encodeTerminalField(rendered)}`);
160
130
  }
161
131
  }
162
132
  return `${lines.join("\n")}\n`;
@@ -4,6 +4,7 @@ import { realpath } from "node:fs/promises";
4
4
  import { join } from "node:path";
5
5
  import { promisify } from "node:util";
6
6
  import { isRecord, errorText } from "./unknown-value.js";
7
+ import { serializeThrownValue } from "./serialize-thrown-value.js";
7
8
  const AK_ROLE_PACKAGE_ROOT_ENV = "AK_ROLE_PACKAGE_ROOT";
8
9
  const execFileAsync = promisify(execFile);
9
10
  function createCapturingIo() {
@@ -288,15 +289,9 @@ async function resolveReviewerGitToplevel(projectRoot) {
288
289
  )).stdout.trim());
289
290
  }
290
291
  async function summonParallelReviewerLenses(options) {
291
- const describeFailure = (error) => {
292
- if (error instanceof AggregateError) {
293
- return [error.message, ...error.errors.map(describeFailure)].join("\n");
294
- }
295
- return errorText(error);
296
- };
297
292
  const failedResult = (error) => ({
298
293
  exitCode: 1,
299
- stderr: describeFailure(error)
294
+ stderr: serializeThrownValue(error)
300
295
  });
301
296
  const dualFailure = (error) => {
302
297
  const failure = failedResult(error);
@@ -399,7 +394,7 @@ async function summonParallelReviewerLenses(options) {
399
394
  }
400
395
  } catch (error) {
401
396
  sealDiagnostic = `Reviewer target final seal failed:
402
- ${describeFailure(error)}`;
397
+ ${serializeThrownValue(error)}`;
403
398
  }
404
399
  if (sealDiagnostic !== void 0) {
405
400
  const withSealFailure = (result) => ({
@@ -30,18 +30,13 @@ function parseNoReceiptLifecycleFacts(input) {
30
30
  if (!isRecord(input) || typeof input.terminalToolCalled !== "boolean" || input.sessionCompletion !== "settled-without-accepted-receipt" || input.acceptedReceipt !== false || typeof input.runPointer !== "string" || input.runPointer.trim() === "" || typeof input.attemptPointer !== "string" || input.attemptPointer.trim() === "" || !Array.isArray(input.rejectedReceipts) || !input.rejectedReceipts.every((item) => isRecord(item) && typeof item.reason === "string")) {
31
31
  throw new TypeError("malformed no-receipt lifecycle facts");
32
32
  }
33
- return {
33
+ return noReceiptLifecycleFacts({
34
34
  terminalToolCalled: input.terminalToolCalled,
35
- rejectedReceipts: input.rejectedReceipts.map((item) => ({
36
- reason: item.reason,
37
- diagnosticAvailable: item.reason.trim() !== ""
38
- })),
35
+ rejectedReceipts: input.rejectedReceipts,
39
36
  deliveryTurns: deliveryTurnsFact(input.deliveryTurns),
40
- sessionCompletion: "settled-without-accepted-receipt",
41
37
  runPointer: input.runPointer,
42
- attemptPointer: input.attemptPointer,
43
- acceptedReceipt: false
44
- };
38
+ attemptPointer: input.attemptPointer
39
+ });
45
40
  }
46
41
  function noReceiptLifecycleFacts(input) {
47
42
  return {
@@ -106,9 +101,13 @@ function createReceiptDeliveryPolicy(limit) {
106
101
  * already sent, and adding the two counts would bill one send twice.
107
102
  */
108
103
  recordNestedNoReceipt(facts) {
109
- terminalToolCalled = terminalToolCalled || facts.terminalToolCalled;
110
- rejectedReceipts.push(...facts.rejectedReceipts);
111
- deliveryTurns = Math.max(deliveryTurns, facts.deliveryTurns);
104
+ if (typeof facts.terminalToolCalled === "boolean") {
105
+ terminalToolCalled = terminalToolCalled || facts.terminalToolCalled;
106
+ }
107
+ if (facts.rejectedReceipts !== void 0) {
108
+ rejectedReceipts.push(...facts.rejectedReceipts);
109
+ }
110
+ if (facts.deliveryTurns !== void 0) deliveryTurns = Math.max(deliveryTurns, facts.deliveryTurns);
112
111
  closed = true;
113
112
  },
114
113
  nextAction() {
@@ -1,18 +1,23 @@
1
1
  /**
2
- * Canonical reader for run-directory typed terminal artifacts.
3
- * Layout owner is settlement publish*Artifacts (report.json / error.json /
4
- * audit-incomplete.json under artifacts/, plus the same publisher's durable
5
- * failure fallbacks). This module only reads presence and structural
2
+ * Canonical layout and reader for run-directory typed terminal artifacts.
3
+ * Settlement publish*Artifacts uses these names (report.json / error.json /
4
+ * audit-incomplete.json under artifacts/, plus durable failure fallbacks).
5
+ * The reader only checks presence and structural
6
6
  * readability — it does not re-derive role outcomes or invent a second
7
7
  * candidate algorithm.
8
8
  */
9
+ import { randomUUID } from "node:crypto";
9
10
  import { readdir, readFile } from "node:fs/promises";
10
11
  import { basename, dirname, join } from "node:path";
11
12
  import { roleRunArtifactsDirectory } from "./role-run-placement.js";
12
13
  import { isRecord, errorText, isMissingPathError } from "./unknown-value.js";
14
+ export const RUN_TERMINAL_REPORT_FILE = "report.json";
15
+ export const RUN_TERMINAL_ERROR_FILE = "error.json";
16
+ export const RUN_TERMINAL_EVIDENCE_FILE = "evidence.json";
17
+ export const RUN_TERMINAL_ERROR_SETTLEMENT_FILE = "error.settlement.json";
13
18
  export const RUN_TERMINAL_ARTIFACT_FILES = [
14
- "report.json",
15
- "error.json",
19
+ RUN_TERMINAL_REPORT_FILE,
20
+ RUN_TERMINAL_ERROR_FILE,
16
21
  "audit-incomplete.json",
17
22
  ];
18
23
  /**
@@ -22,11 +27,15 @@ export const RUN_TERMINAL_ARTIFACT_FILES = [
22
27
  * Relative to the run directory.
23
28
  */
24
29
  export const RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS = [
25
- "artifacts/error.settlement.json",
26
- "error.settlement.json",
30
+ `artifacts/${RUN_TERMINAL_ERROR_SETTLEMENT_FILE}`,
31
+ RUN_TERMINAL_ERROR_SETTLEMENT_FILE,
27
32
  ];
28
- /** Unique open-ended failure names: error.<uuid>.json (publisher stem + uuid). */
29
- const UNIQUE_ERROR_FALLBACK_NAME = /^error\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.json$/i;
33
+ /** Publisher and reader share the open-ended error face stem. */
34
+ export const UNIQUE_ERROR_FALLBACK_STEM = "error";
35
+ export function uniqueErrorFallbackName() {
36
+ return `${UNIQUE_ERROR_FALLBACK_STEM}.${randomUUID()}.json`;
37
+ }
38
+ const UNIQUE_ERROR_FALLBACK_NAME = new RegExp(`^${UNIQUE_ERROR_FALLBACK_STEM}\\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\.json$`, "i");
30
39
  /**
31
40
  * Minimum producer-owned face shared by settlement terminal artifacts
32
41
  * (report / error / audit-incomplete). Consumer-driven: enough to identify a
@@ -219,7 +228,3 @@ export async function readRunTerminalArtifact(runDirectory) {
219
228
  }
220
229
  return { status: "absent" };
221
230
  }
222
- /** Test/helper: basename face of a unique fallback path, if any. */
223
- export function isUniqueErrorFallbackName(name) {
224
- return UNIQUE_ERROR_FALLBACK_NAME.test(basename(name));
225
- }
@@ -1,5 +1,11 @@
1
1
  import { inspect } from "node:util";
2
2
  /** Record the whole thrown value without invoking its getters or custom formatter. */
3
3
  export function serializeThrownValue(value) {
4
- return inspect(value, { depth: 10, showHidden: true, customInspect: false });
4
+ return inspect(value, {
5
+ depth: null,
6
+ maxArrayLength: null,
7
+ maxStringLength: null,
8
+ showHidden: true,
9
+ customInspect: false,
10
+ });
5
11
  }
@@ -79,11 +79,6 @@ function resolveReadScope(homeOrScope) {
79
79
  return { home: homeOrScope };
80
80
  return homeOrScope;
81
81
  }
82
- function recordsForAttempt(owned, attemptId) {
83
- // #836: courtAttempt is a recording tag for new courts, not a visibility gate.
84
- void attemptId;
85
- return owned;
86
- }
87
82
  /** Recording tag a row was written under — subject first, historical payload fallback. */
88
83
  function recordAttemptId(record) {
89
84
  if (typeof record.subject === "object" && record.subject !== null) {
@@ -98,30 +93,6 @@ function recordAttemptId(record) {
98
93
  }
99
94
  return undefined;
100
95
  }
101
- /**
102
- * True when the given attemptId itself already produced a sealed or
103
- * audit-escalation submission (#836 r12 class 2). This is a separate
104
- * freshness signal, not a presentation filter — `recordsForAttempt` above
105
- * stays a pass-through so every original payload keeps presenting honestly
106
- * (#836: attemptId is a recording tag, not a visibility gate). Settlement
107
- * consumes this only to stop a prior attempt's stale acceptance from
108
- * outranking the current attempt's own real host-turn failure signal
109
- * (#637 original intent, restored narrowly).
110
- */
111
- export async function hasFreshAttemptSubmission(cwd, runId, attemptId, homeOrScope) {
112
- const { owned } = await readOwnedSubmissionRecords(cwd, runId, resolveReadScope(homeOrScope));
113
- return owned.some((record) => {
114
- if (recordAttemptId(record) !== attemptId)
115
- return false;
116
- if (record.kind === "sealed")
117
- return true;
118
- if (record.kind === "outcome") {
119
- const payload = record.payload;
120
- return payload?.type === "outcome" && payload.outcome === "audit-escalation";
121
- }
122
- return false;
123
- });
124
- }
125
96
  function isTerminalRoleName(value) {
126
97
  return typeof value === "string" && value.length > 0;
127
98
  }
@@ -215,49 +186,31 @@ function mapOwnedToSubmissionRows(owned) {
215
186
  out.push(row);
216
187
  };
217
188
  for (const record of scoped) {
218
- const attemptId = recordAttemptId(record);
219
- if (record.kind === "candidate") {
220
- const payload = record.payload;
221
- if (payload?.type !== "candidate" || payload.params === undefined)
222
- continue;
223
- const callKey = typeof payload.toolCallId === "string"
224
- ? submissionCallKey(attemptId, payload.toolCallId)
225
- : undefined;
226
- const fallback = callKey !== undefined ? roleByCall.get(callKey) : undefined;
227
- take(rowFromPayload("candidate", payload, payload.params, fallback), callKey);
228
- continue;
189
+ const payload = record.payload;
190
+ let kind;
191
+ let original;
192
+ if (record.kind === "candidate" && payload?.type === "candidate") {
193
+ kind = "candidate";
194
+ original = payload.params;
229
195
  }
230
- if (record.kind === "sealed") {
231
- const payload = record.payload;
232
- if (payload?.type !== "sealed" || payload.accepted === undefined)
233
- continue;
234
- const callKey = typeof payload.toolCallId === "string"
235
- ? submissionCallKey(attemptId, payload.toolCallId)
236
- : undefined;
237
- const fallback = callKey !== undefined ? roleByCall.get(callKey) : undefined;
238
- take(rowFromPayload("accepted", payload, payload.accepted, fallback), callKey);
239
- continue;
196
+ else if (record.kind === "sealed" && payload?.type === "sealed") {
197
+ kind = "accepted";
198
+ original = payload.accepted;
240
199
  }
241
- if (record.kind !== "outcome")
242
- continue;
243
- const payload = record.payload;
244
- if (payload?.type !== "outcome" || payload.accepted === undefined)
245
- continue;
246
- const outcome = payload.outcome;
247
- const kind = outcome === "audit-escalation"
248
- ? "audit-escalation"
249
- : outcome === "correctable-rejection"
250
- ? "correctable-rejection"
251
- : outcome === "infrastructure"
252
- ? "infrastructure"
253
- : undefined;
254
- if (kind === undefined)
200
+ else if (record.kind === "outcome" && payload?.type === "outcome") {
201
+ kind = payload.outcome === "audit-escalation" ? "audit-escalation"
202
+ : payload.outcome === "correctable-rejection" ? "correctable-rejection"
203
+ : payload.outcome === "infrastructure" ? "infrastructure"
204
+ : undefined;
205
+ original = payload.accepted;
206
+ }
207
+ if (kind === undefined || original === undefined || payload === undefined)
255
208
  continue;
256
209
  const callKey = typeof payload.toolCallId === "string"
257
- ? submissionCallKey(attemptId, payload.toolCallId)
210
+ ? submissionCallKey(recordAttemptId(record), payload.toolCallId)
258
211
  : undefined;
259
- const fallback = callKey !== undefined ? roleByCall.get(callKey) : undefined;
260
- take(rowFromPayload(kind, payload, payload.accepted, fallback), callKey);
212
+ const fallback = callKey === undefined ? undefined : roleByCall.get(callKey);
213
+ take(rowFromPayload(kind, payload, original, fallback), callKey);
261
214
  }
262
215
  return out;
263
216
  }
@@ -270,8 +223,7 @@ function mapOwnedToSubmissionRows(owned) {
270
223
  export async function readRecordedSubmissionRows(cwd, runId, homeOrScope) {
271
224
  const scope = resolveReadScope(homeOrScope);
272
225
  const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope);
273
- const scoped = recordsForAttempt(owned, scope.attemptId);
274
- return mapOwnedToSubmissionRows(scoped);
226
+ return mapOwnedToSubmissionRows(owned);
275
227
  }
276
228
  /**
277
229
  * Settlement-only this-court rows (#879 return path).
@@ -291,26 +243,6 @@ export async function readAttemptScopedSubmissionRows(cwd, runId, attemptId, hom
291
243
  export async function readRecordedSubmissions(cwd, runId, homeOrScope) {
292
244
  return (await readRecordedSubmissionRows(cwd, runId, homeOrScope)).map((row) => row.accepted);
293
245
  }
294
- /** True when the run has at least one recorded original payload (any outcome class). */
295
- export async function hasRecordedSubmission(cwd, runId, homeOrScope) {
296
- return (await readRecordedSubmissionRows(cwd, runId, homeOrScope)).length > 0;
297
- }
298
- /** Latest non-final outcome on the run ledger (settlement residual precedence). */
299
- export async function readLatestSubmissionOutcome(cwd, runId, homeOrScope) {
300
- const scope = resolveReadScope(homeOrScope);
301
- const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope);
302
- const scoped = recordsForAttempt(owned, scope.attemptId);
303
- for (let index = scoped.length - 1; index >= 0; index -= 1) {
304
- const record = scoped[index];
305
- if (record?.kind !== "outcome")
306
- continue;
307
- const payload = record.payload;
308
- if (payload?.type === "outcome" && typeof payload.outcome === "string") {
309
- return payload;
310
- }
311
- }
312
- return undefined;
313
- }
314
246
  async function restoreState(cwd, runId, scope) {
315
247
  const located = await readOwnedSubmissionRecords(cwd, runId, scope);
316
248
  if (located.file === undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akagilnc/pi-workflow-roles",
3
- "version": "0.1.5406",
3
+ "version": "0.1.5475",
4
4
  "description": "Soul-bound workflow roles for Pi",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -2,4 +2,6 @@
2
2
 
3
3
  Repair and verify the caller-assigned findings. Treat this document as opaque prose: its headings and wording have no machine semantics.
4
4
 
5
- Search the authorized scope for every same-pattern occurrence, preserve unrelated behavior, run the required checks, and report each finding class through the typed Fixer output.
5
+ Preserve unrelated behavior.
6
+
7
+ Repair method: [Fixer Soul](../souls/fixer.md). Report fields: [Fixer output contract](../src/package-contracts/fixer-output.ts).
@@ -1,18 +1,13 @@
1
1
  # Apply evidence packet (contributor template)
2
2
 
3
- This file is a **repository-contributor template** for a manually supplied Apply
4
- (executable-proof) artifact. The filename identifies an **evidence burden**, not
5
- a verdict, phase flag, transition, or required predecessor/successor.
6
-
7
- Selection, composition, and use are **caller-owned** (ADR 0010). Apply posture
8
- semantics remain solely in `souls/judge.md`. Git commit identity owns the code
9
- snapshot and any reviewed range. This template creates no receipt envelope,
10
- audit, runtime enforcement, trust tier, production hook, or package surface.
3
+ Repository-contributor template for manually supplied Apply evidence.
4
+ Template scope and preservation: [development closure](https://github.com/Akagilnc/ak-pi-workflow-roles/blob/main/docs/development-closure.md).
5
+ Composition: [ADR 0010](https://github.com/Akagilnc/ak-pi-workflow-roles/blob/main/docs/adr/0010-callers-own-role-composition-and-repetition.md).
6
+ Adjudication: [Judge Soul](../souls/judge.md).
11
7
 
12
8
  ## Sealed upstream identities
13
9
 
14
- Digests seal **artifact-byte identity only**. They do not prove truth,
15
- acceptance, or freshness.
10
+ Artifact identity and preservation: [development closure](https://github.com/Akagilnc/ak-pi-workflow-roles/blob/main/docs/development-closure.md#artifact-preservation-rules).
16
11
 
17
12
  | Artifact | Repository-relative path | SHA-256 of exact bytes |
18
13
  | --- | --- | --- |
@@ -36,6 +31,8 @@ Distinguish carefully:
36
31
 
37
32
  None of these alone proves truth or acceptance.
38
33
 
34
+ Adjudication duties: [Judge Soul](../souls/judge.md).
35
+
39
36
  ## Construction evidence
40
37
 
41
38
  ### Live code and tests
@@ -69,9 +66,3 @@ otherwise record `N/A — no guardrail added or approved` with disposition.
69
66
  | 1. Which real, reproducible failure proves this guardrail is needed? | |
70
67
  | 2. Which seam owns the invariant it protects? | |
71
68
  | 3. Why is deleting or simplifying the root cause insufficient for this failure class? | |
72
-
73
- ## Explicit non-claims
74
-
75
- - Filename is not a verdict and does not imply Apply convergence.
76
- - This template does not define or alter role receipts, Soul audit, or runtime gates.
77
- - Instantiation does not route work to any role or require a successor packet.
@@ -1,12 +1,9 @@
1
1
  # Authority evidence packet (contributor template)
2
2
 
3
- This file is a **repository-contributor template** for a manually supplied
4
- Authority-evidence artifact. The filename identifies an **evidence burden**, not
5
- a verdict, phase flag, transition, or required predecessor/successor.
6
-
7
- Selection, composition, and use are **caller-owned** (ADR 0010). This template
8
- does not restate or amend Judge law in `souls/judge.md`. It creates no routing,
9
- next-role, package memory, resume semantics, timeout budget, or trust tier.
3
+ Repository-contributor template for manually supplied Authority evidence.
4
+ Template scope and preservation: [development closure](https://github.com/Akagilnc/ak-pi-workflow-roles/blob/main/docs/development-closure.md).
5
+ Composition: [ADR 0010](https://github.com/Akagilnc/ak-pi-workflow-roles/blob/main/docs/adr/0010-callers-own-role-composition-and-repetition.md).
6
+ Adjudication: [Judge Soul](../souls/judge.md).
10
7
 
11
8
  ## Identity seal
12
9
 
@@ -17,15 +14,14 @@ Every supplied artifact is identified by:
17
14
  | Repository-relative path | |
18
15
  | SHA-256 of exact bytes | |
19
16
 
20
- A digest seals **identity only**. It does not prove truth, acceptance, or
21
- freshness. Judge independently checks claims against the supplied current
22
- target. This packet does **not** require Apply-level executable proof.
17
+ Artifact identity and preservation: [development closure](https://github.com/Akagilnc/ak-pi-workflow-roles/blob/main/docs/development-closure.md#artifact-preservation-rules).
18
+ Adjudication duties: [Judge Soul](../souls/judge.md).
23
19
 
24
20
  ## Authority items
25
21
 
26
22
  Record each item the contributor wants examined under the Authority burden.
27
23
  Do not invent Apply fixtures, blanket `file:line` demands, or implementation
28
- recipes here.
24
+ recipes here. This packet does **not** require Apply-level executable proof.
29
25
 
30
26
  ### Clauses
31
27
 
@@ -56,9 +52,3 @@ recipes here.
56
52
  | ID | Open choice | Options | Blocking? |
57
53
  | --- | --- | --- | --- |
58
54
  | U1 | | | |
59
-
60
- ## Explicit non-claims
61
-
62
- - Filename is not a verdict and does not imply convergence.
63
- - Instantiation does not start, order, or require any role call.
64
- - No mechanical schema/runtime enforcement is claimed by this template.
@@ -1,19 +1,15 @@
1
1
  # Plan evidence packet (contributor template)
2
2
 
3
- This file is a **repository-contributor template** for a manually supplied Plan
4
- (construction-readiness) artifact. The filename identifies an **evidence
5
- burden**, not a verdict, phase flag, transition, or required
6
- predecessor/successor.
7
-
8
- Selection, composition, and use are **caller-owned** (ADR 0010). Plan posture
9
- semantics remain solely in `souls/judge.md`. This template does not restate or
10
- amend that law. It creates no routing, topology, role-order, package memory, or
11
- proof that construction occurred.
3
+ Repository-contributor template for manually supplied Plan evidence.
4
+ This packet does not claim construction already happened.
5
+ Template scope and preservation: [development closure](https://github.com/Akagilnc/ak-pi-workflow-roles/blob/main/docs/development-closure.md).
6
+ Composition: [ADR 0010](https://github.com/Akagilnc/ak-pi-workflow-roles/blob/main/docs/adr/0010-callers-own-role-composition-and-repetition.md).
7
+ Adjudication: [Judge Soul](../souls/judge.md).
12
8
 
13
9
  ## Sealed authority identity
14
10
 
15
- Bind the authority materials this plan consumes. Digests seal identity only—not
16
- truth, acceptance, or freshness.
11
+ Bind the authority materials this plan consumes. Artifact identity and preservation:
12
+ [development closure](https://github.com/Akagilnc/ak-pi-workflow-roles/blob/main/docs/development-closure.md#artifact-preservation-rules).
17
13
 
18
14
  | Artifact | Repository-relative path | SHA-256 of exact bytes |
19
15
  | --- | --- | --- |
@@ -46,10 +42,3 @@ fixture pseudocode or blanket `file:line` here.
46
42
 
47
43
  Add P3… as needed. Every planned change must be reconcilable to the sealed
48
44
  authority identity above and must carry all five facts.
49
-
50
- ## Explicit non-claims
51
-
52
- - Filename is not a verdict and does not authorize or prove Apply success.
53
- - This packet does not claim construction already happened.
54
- - No orchestration, next-role, or stage-machine semantics arise from this file.
55
- - No mechanical schema/runtime enforcement is claimed by this template.
@@ -1,15 +1,10 @@
1
1
  # Review evidence packet (contributor template)
2
2
 
3
- This file is a **repository-contributor template** for a manually supplied
4
- Review (finding-adjudication) artifact. The filename identifies an **evidence
5
- burden**, not a verdict, phase flag, transition, or required
6
- predecessor/successor.
7
-
8
- Selection, composition, and use are **caller-owned** (ADR 0010). This template
9
- records adjudication evidence only. It does **not** define Reviewer protocol,
10
- alter Reviewer method/audit, or alter Collector ledger semantics. Judge Review
11
- posture meaning remains in `souls/judge.md`. No generic Reviewer/Collector
12
- provider law is introduced (ADR 0011).
3
+ Repository-contributor template for manually supplied Review evidence.
4
+ Template scope and preservation: [development closure](https://github.com/Akagilnc/ak-pi-workflow-roles/blob/main/docs/development-closure.md).
5
+ Composition: [ADR 0010](https://github.com/Akagilnc/ak-pi-workflow-roles/blob/main/docs/adr/0010-callers-own-role-composition-and-repetition.md).
6
+ Adjudication: [Judge Soul](../souls/judge.md).
7
+ External reviewer protocols: [ADR 0011](https://github.com/Akagilnc/ak-pi-workflow-roles/blob/main/docs/adr/0011-collector-adapts-to-documented-reviewer-protocols.md).
13
8
 
14
9
  ## Sealed authority identity
15
10
 
@@ -17,13 +12,12 @@ provider law is introduced (ADR 0011).
17
12
  | --- | --- | --- |
18
13
  | Authority materials | | |
19
14
 
20
- A digest seals identity only—not truth, acceptance, or freshness.
15
+ Artifact identity and preservation: [development closure](https://github.com/Akagilnc/ak-pi-workflow-roles/blob/main/docs/development-closure.md#artifact-preservation-rules).
21
16
 
22
17
  ## Fixed reviewed range
23
18
 
24
- Every finding and disposition in this packet concerns **one immutable range**
25
- and current target facts. A changed target or range requires a **new**
26
- artifact/digest; do not silently mutate this packet.
19
+ Identify the reviewed range and current target below. Amendment procedure:
20
+ [development closure](https://github.com/Akagilnc/ak-pi-workflow-roles/blob/main/docs/development-closure.md#artifact-preservation-rules).
27
21
 
28
22
  | Field | Full SHA |
29
23
  | --- | --- |
@@ -39,11 +33,3 @@ current facts. Every finding needs an explicit disposition.
39
33
  | Finding ID | Claim | Authority binding | Evidence on current target/range | Disposition | Disposition evidence |
40
34
  | --- | --- | --- | --- | --- | --- |
41
35
  | F1 | | | | sustained / rejected / deferred / other | |
42
-
43
- ## Explicit non-claims
44
-
45
- - Filename is not a verdict and does not imply Review convergence.
46
- - This packet defines no required review order, repetition count, or return path
47
- to any role.
48
- - No routing, next-role, stage machine, or provider-universal protocol arises here.
49
- - No mechanical schema/runtime enforcement is claimed by this template.
@@ -1,12 +1,9 @@
1
1
  # Submission-case evidence template (contributor template)
2
2
 
3
- This file is a **repository-contributor template** for the evidence record of a
4
- manually supplied Submission case (ticket face / plan / disposition ledger /
5
- constitutional review). The submission-case duty law is solely in
6
- `souls/judge.md`; this file supplies its evidence-record format.
7
-
8
- Selection, composition, and use are **caller-owned** (ADR 0010). This template
9
- creates no routing, topology, role-order, or package memory.
3
+ Repository-contributor template for manually supplied Submission-case evidence.
4
+ Template scope and preservation: [development closure](https://github.com/Akagilnc/ak-pi-workflow-roles/blob/main/docs/development-closure.md).
5
+ Composition: [ADR 0010](https://github.com/Akagilnc/ak-pi-workflow-roles/blob/main/docs/adr/0010-callers-own-role-composition-and-repetition.md).
6
+ Adjudication: [Judge Soul](../souls/judge.md).
10
7
 
11
8
  ## Identity seal
12
9
 
@@ -4,7 +4,7 @@
4
4
  内容是角色阅读与修正的工作记忆,不是代码状态规则;临时额度/故障不得固化为永久行为。
5
5
  参与者依本仓使用与现场活动辨认,不把下列名称当作全仓固定名单。
6
6
 
7
- #1088:用宿主 CLI(如 `gh`)自行取证与请求;代码不代收、不选择、不归并 finding。取证受限时如实报告。
7
+ #1088:用宿主 CLI(如 `gh`)自行取证与请求;代码不代收、不选择、不归并 finding。
8
8
 
9
9
  ## Codex(hosted GitHub connector)
10
10
 
@@ -31,7 +31,7 @@
31
31
 
32
32
  ## 工序
33
33
 
34
- 从任务材料与 `--pr` / `--request-manifest` 材料判定目标后,用宿主 CLI 读取有评审的 PR,按各 reviewer 已记录的完成形态收集 findings,整理并交卷。未绑定 PR 时用 `gh` 等自行定位;无法确定时不猜,交给调用方明确目标。交卷交按机器身份归组的出席、材料与 findings;没有 finding 就不要编一条。未完成写现场原因,不写成没问题。
34
+ 从任务材料与 `--pr` / `--request-manifest` 材料判定目标后,用宿主 CLI 读取有评审的 PR,按各 reviewer 已记录的完成形态收集 findings,整理并交卷。未绑定 PR 时用 `gh` 等自行定位;无法确定时不猜,交给调用方明确目标。证据归属与不确定性的报告原则见 [通进司 Soul](../souls/collector.md),字段见 [交卷契约](../src/package-contracts/collector-output.ts)。
35
35
 
36
36
  ## 修正规则
37
37