@thehammer/danx-session-telemetry 0.1.49 → 0.1.50

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/dist/.source-hash CHANGED
@@ -1 +1 @@
1
- b6fe84abf58a5a669072ebe58339676af7f647461c02913638f5756219baa2dc
1
+ 8a74b752a952b20290ec7229f71324868be0b38db9350ce55c6ef80c1ba1830f
@@ -348,20 +348,28 @@ const NEWLINE = "\n";
348
348
  * carrying a session id has no compaction boundary either, so it reports none.
349
349
  */
350
350
  export function reportCompactionsOfFreshTranscript(text) {
351
+ let found = null;
351
352
  for (const rawLine of text.split(NEWLINE)) {
352
353
  const trimmed = rawLine.trim();
353
354
  if (!trimmed)
354
355
  continue;
356
+ let sessionId;
355
357
  try {
356
- const sessionId = JSON.parse(trimmed).sessionId;
357
- if (typeof sessionId === "string" && sessionId.length > 0)
358
- return reportCompactionsOf(sessionId);
358
+ sessionId = JSON.parse(trimmed).sessionId;
359
359
  }
360
360
  catch {
361
- // a truncated line carries no session id; the next one may
361
+ continue; // a truncated line carries no session id; the next one may
362
362
  }
363
+ if (typeof sessionId !== "string" || sessionId.length === 0)
364
+ continue;
365
+ // DX-4940: the "fresh session" premise is enforced, not assumed: a transcript carrying a second session id has inherited lines
366
+ // (a fork or resume), and reading it as one session would report the parent's compactions as its own.
367
+ if (found !== null && sessionId !== found) {
368
+ throw new LedgerLineDataError(`reportCompactionsOfFreshTranscript: the transcript carries more than one session id (${JSON.stringify(found)}, ${JSON.stringify(sessionId)}), so it is not a fresh session`);
369
+ }
370
+ found = sessionId;
363
371
  }
364
- return REPORT_NO_COMPACTIONS;
372
+ return found === null ? REPORT_NO_COMPACTIONS : reportCompactionsOf(found);
365
373
  }
366
374
  /**
367
375
  * Parse one raw transcript line (a parsed JSONL object) of the fed set - assistant, user (tool_result and human
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thehammer/danx-session-telemetry",
3
- "version": "0.1.49",
3
+ "version": "0.1.50",
4
4
  "description": "Shared Claude Code transcript collector (DX-2962) — incremental JSONL tailing for the danxbot worker and the danx-dashboard-mcp MCP server's relay, so both run identical collector code.",
5
5
  "license": "MIT",
6
6
  "type": "module",