@akagilnc/pi-workflow-roles 0.1.5303 → 0.1.5307

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.
@@ -6,7 +6,7 @@
6
6
  * Registers by file drop under analyst-metric-families/ (A2 discovery).
7
7
  */
8
8
  import { medianNumber } from "../analyst-median.ts";
9
- import type { AnalystReadableRunFacts } from "../analyst-ledger.ts";
9
+ import { compareAnalystLegs, sumAnalystRunWallMs, type AnalystReadableRunFacts } from "../analyst-ledger.ts";
10
10
  import type { AnalystMetricFamilyModule } from "../analyst-metric-family.ts";
11
11
 
12
12
  /** One readable leg's session-frame wall clock (first usable → last usable). */
@@ -31,19 +31,12 @@ export type AnalystLegWallClockSection = {
31
31
  readonly totalElapsedMs: number;
32
32
  };
33
33
 
34
- function frameSpanWallMs(span: {
35
- readonly startedAt: string;
36
- readonly endedAt: string;
37
- }): number {
38
- return Date.parse(span.endedAt) - Date.parse(span.startedAt);
39
- }
40
-
41
34
  function projectEntry(facts: AnalystReadableRunFacts): AnalystLegWallClockEntry {
42
35
  return {
43
36
  runId: facts.runId,
44
37
  book: facts.book,
45
38
  role: facts.role,
46
- wallMs: frameSpanWallMs(facts.frameSpan),
39
+ wallMs: facts.frameSpan.wallMs,
47
40
  };
48
41
  }
49
42
 
@@ -52,9 +45,7 @@ function compareRankingDesc(
52
45
  b: AnalystLegWallClockEntry,
53
46
  ): number {
54
47
  if (b.wallMs !== a.wallMs) return b.wallMs - a.wallMs;
55
- if (a.book !== b.book) return a.book.localeCompare(b.book);
56
- if (a.role !== b.role) return a.role.localeCompare(b.role);
57
- return a.runId.localeCompare(b.runId);
48
+ return compareAnalystLegs(a, b);
58
49
  }
59
50
 
60
51
  /** Discovered by analyst-metric-families loader (default export). */
@@ -74,14 +65,11 @@ const legWallClockFamily: AnalystMetricFamilyModule = {
74
65
  return undefined;
75
66
  }
76
67
 
77
- let totalElapsedMs = 0;
78
- for (const wallMs of walls) totalElapsedMs += wallMs;
79
-
80
68
  const section: AnalystLegWallClockSection = {
81
69
  kind: "analyst-leg-wall-clock",
82
70
  ranking,
83
71
  medianWallMs,
84
- totalElapsedMs,
72
+ totalElapsedMs: sumAnalystRunWallMs(input.runs),
85
73
  };
86
74
  return { legWallClock: section };
87
75
  },
@@ -70,10 +70,6 @@ function isRecord(value: unknown): value is Record<string, unknown> {
70
70
  return typeof value === "object" && value !== null && !Array.isArray(value);
71
71
  }
72
72
 
73
- function wallMsFromSpan(startedAt: string, endedAt: string): number {
74
- return Date.parse(endedAt) - Date.parse(startedAt);
75
- }
76
-
77
73
  function readClassCount(body: Record<string, unknown>): number | undefined {
78
74
  if (!isRecord(body.outcome)) return undefined;
79
75
  if (!isRecord(body.outcome.decisiveFacts)) return undefined;
@@ -113,7 +109,7 @@ function projectRunRow(facts: AnalystReadableRunFacts): AnalystRoundTimelineRunR
113
109
  role: facts.role,
114
110
  startedAt,
115
111
  endedAt,
116
- wallMs: wallMsFromSpan(startedAt, endedAt),
112
+ wallMs: facts.frameSpan.wallMs,
117
113
  terminal: projectTerminal(facts),
118
114
  };
119
115
  }
@@ -11,7 +11,7 @@
11
11
  import { buildAcceptanceSuccessReworkSection } from "./analyst-metric-families/acceptance-success-rework.ts";
12
12
  import type { AnalystReadableRunFacts } from "./analyst-ledger.ts";
13
13
  import { medianNumber } from "./analyst-median.ts";
14
- import type { AnalystUnreadableRun } from "./analyst-page.ts";
14
+ import { sortUnreadable, type AnalystUnreadableRun } from "./analyst-page.ts";
15
15
 
16
16
  /** One raw model group with rates over legs in that group. */
17
17
  export type AnalystModelGroupRow = {
@@ -74,15 +74,6 @@ function displayNameFor(
74
74
  return aliased === undefined ? rawGroupKey : aliased;
75
75
  }
76
76
 
77
- function sortUnreadable(
78
- unreadable: readonly AnalystUnreadableRun[],
79
- ): AnalystUnreadableRun[] {
80
- return [...unreadable].sort((a, b) => {
81
- if (a.book !== b.book) return a.book.localeCompare(b.book);
82
- return a.runId.localeCompare(b.runId);
83
- });
84
- }
85
-
86
77
  /**
87
78
  * Legs with no usable session model identity cannot join any model group.
88
79
  * Reuse the typed unreadable path (locatable missing-source) — not an empty-key group.
@@ -15,7 +15,7 @@ import {
15
15
  ensureRealDirectoryTree,
16
16
  physicalPathIdentity,
17
17
  } from "./activation-ledger-topology.ts";
18
- import type { AnalystReadableRunFacts } from "./analyst-ledger.ts";
18
+ import { compareAnalystLegs, sumAnalystRunWallMs, type AnalystReadableRunFacts } from "./analyst-ledger.ts";
19
19
  import { loadAnalystIssueMetricFamilies } from "./analyst-metric-families.ts";
20
20
  import { composeAnalystMetricFamilySections } from "./analyst-metric-family.ts";
21
21
 
@@ -187,14 +187,10 @@ export function analystIssuePageAddressFromPage(
187
187
  }
188
188
 
189
189
  function sortLegs(legs: readonly AnalystLegEntry[]): AnalystLegEntry[] {
190
- return [...legs].sort((a, b) => {
191
- if (a.book !== b.book) return a.book.localeCompare(b.book);
192
- if (a.role !== b.role) return a.role.localeCompare(b.role);
193
- return a.runId.localeCompare(b.runId);
194
- });
190
+ return [...legs].sort(compareAnalystLegs);
195
191
  }
196
192
 
197
- function sortUnreadable(
193
+ export function sortUnreadable(
198
194
  unreadable: readonly AnalystUnreadableRun[],
199
195
  ): AnalystUnreadableRun[] {
200
196
  return [...unreadable].sort((a, b) => {
@@ -260,13 +256,6 @@ export function computeAnalystMsPerKLines(
260
256
  };
261
257
  }
262
258
 
263
- function frameSpanWallMs(span: {
264
- readonly startedAt: string;
265
- readonly endedAt: string;
266
- }): number {
267
- return Date.parse(span.endedAt) - Date.parse(span.startedAt);
268
- }
269
-
270
259
  /**
271
260
  * Σ readable wall clocks + max end-frame across ALL runs (C1 efficiency / index).
272
261
  * Unreadable runs never enter totalElapsedMs; their available lastFrameAt still
@@ -279,10 +268,9 @@ export function summarizeAnalystRunEfficiency(
279
268
  readonly totalElapsedMs: number;
280
269
  readonly lastActivityAt: AnalystOptionalTimestamp;
281
270
  } {
282
- let totalElapsedMs = 0;
271
+ const totalElapsedMs = sumAnalystRunWallMs(runs);
283
272
  let latestEndedAt: string | undefined;
284
273
  for (const run of runs) {
285
- totalElapsedMs += frameSpanWallMs(run.frameSpan);
286
274
  const endedAt = run.frameSpan.endedAt;
287
275
  if (latestEndedAt === undefined || endedAt > latestEndedAt) {
288
276
  latestEndedAt = endedAt;