@akagilnc/pi-workflow-roles 0.1.5216 → 0.1.5241

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.
@@ -154,7 +154,7 @@ export async function readEngineDetourToolUsage(input) {
154
154
  ...(input.cwd === undefined ? {} : { cwd: input.cwd }),
155
155
  });
156
156
  const { records } = await readSitianRecords(recordFile);
157
- const calls = [];
157
+ const callsByToolCallId = new Map();
158
158
  for (const record of records) {
159
159
  if (record.kind !== ENGINE_DETOUR_CALL_KIND)
160
160
  continue;
@@ -176,8 +176,10 @@ export async function readEngineDetourToolUsage(input) {
176
176
  const fact = callFactFromSitianPayload(record.payload, pointer);
177
177
  if (fact === undefined)
178
178
  continue;
179
- calls.push(fact);
179
+ // ADR 0086: Reader deduplicates by toolCallId within the invocation scope
180
+ callsByToolCallId.set(fact.toolCallId, fact);
180
181
  }
182
+ const calls = Array.from(callsByToolCallId.values());
181
183
  return { callCount: calls.length, calls };
182
184
  }
183
185
  /**
@@ -226,20 +228,6 @@ export async function readInvocationEngineMounted(runDirectory) {
226
228
  return false;
227
229
  return typeof raw.engine === "string" && raw.engine.trim() !== "";
228
230
  }
229
- /**
230
- * Selected host from the admission invocation page — for post-admission
231
- * host-transition classification only. In-turn tools take host from the shared
232
- * Host envelope (RoleTurnRequest / HostContext), never this reader.
233
- * Undefined when absent — callers must not invent "pi".
234
- */
235
- export function readInvocationSelectedHost(runDirectory) {
236
- const raw = readInvocationRecord(runDirectory);
237
- if (raw === undefined)
238
- return undefined;
239
- return typeof raw.host === "string" && raw.host.trim() !== ""
240
- ? raw.host.trim()
241
- : undefined;
242
- }
243
231
  /** Merge usage into decisiveFacts without touching role payloads. */
244
232
  export function withEngineDetourToolUsageFact(outcome, usage) {
245
233
  if (usage === undefined)