openclaw - ✅(Solved) Fix openclaw doctor state-integrity orphan transcript detection appears to ignore active *.trajectory.jsonl sidecars [2 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#71960Fetched 2026-04-27 05:36:49
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
cross-referenced ×2closed ×1commented ×1labeled ×1

openclaw doctor can report an active session trajectory sidecar as an orphan transcript and say it is safe to archive.

Root Cause

openclaw doctor can report an active session trajectory sidecar as an orphan transcript and say it is safe to archive.

Fix Action

Fixed

PR fix notes

PR #71971: fix(doctor): exclude trajectory sidecars from orphan transcript sweep (#71960)

Description (problem / solution / changelog)

Fixes #71960.

What

isPrimarySessionTranscriptFileName matches any *.jsonl that isn't a compaction checkpoint or archive artifact. Trajectory sidecars (<sessionId>.trajectory.jsonl) therefore look like primary session transcripts to doctor's orphan sweep, which only cross-references sessions.json. Sidecars are referenced via the sibling *.trajectory-path.json pointer instead, so an active session's sidecar gets reported as Found 1 orphan transcript file and offered for archival on every openclaw doctor run.

Fix

Add isTrajectorySidecarFileName (matches *.trajectory.jsonl) and short-circuit it from isPrimarySessionTranscriptFileName. Mirrors the existing isCompactionCheckpointTranscriptFileName carve-out.

Side effect (intentional)

The same classifier feeds src/config/sessions/disk-budget.ts's removable-file queue. Trajectory sidecars no longer end up there either — which is correct: sidecars belong to live sessions and should be cleaned up via the regular session lifecycle, not the budget sweep.

isUsageCountedSessionTranscriptFileName and parseUsageCountedSessionIdFromFileName also exclude sidecars now, which matches the prior intent (sidecars don't have user messages and shouldn't be billed as session transcripts).

Tests

  • src/config/sessions/artifacts.test.ts: assert sidecar names are excluded from the primary classifier and that the new helper recognizes them; existing tests stay green.
  • src/commands/doctor-state-integrity.test.ts: regression — drop <id>.trajectory.jsonl + <id>.trajectory-path.json into the sessions dir, run doctor, assert neither the orphan warning nor the archive prompt fires and the file survives.
pnpm test src/config/sessions src/commands/doctor-state-integrity.test.ts -- --run
# Test Files: 16 passed   Tests: 125 passed

Reporter's three suggested directions were "exclude *.trajectory.jsonl from primary orphan-transcript checks" / "include sidecars referenced through *.trajectory-path.json" / "soften the warning text". Excluding from the primary classifier is the smallest correct change and naturally covers both detection sites (doctor + disk-budget).

Changed files

  • src/commands/doctor-state-integrity.test.ts (modified, +25/-0)
  • src/config/sessions/artifacts.test.ts (modified, +16/-0)
  • src/config/sessions/artifacts.ts (modified, +15/-0)

PR #72047: fix(doctor): exclude trajectory sidecar files from orphan transcript detection [AI-assisted]

Description (problem / solution / changelog)

🤖 AI-assisted (built with Claude Code via Hermes orchestration). Test level: fully tested. Prompt summary available on request.

Summary

  • Problem: openclaw doctor state-integrity check falsely flags active *.trajectory.jsonl sidecar files as orphan transcripts, suggesting they can be safely archived while the session is still active.
  • Why it matters: Users may archive active trajectory data, potentially losing session trajectory history for a running session.
  • What changed: Added isTrajectoryJournalFileName() helper in artifacts.ts and excluded trajectory journal files from isPrimarySessionTranscriptFileName(), so they are never considered primary transcripts and never enter the orphan detection path.
  • What did NOT change (scope boundary): The orphan transcript detection logic itself is unchanged. Only the file classification predicate was tightened. No changes to trajectory recording, session management, or other doctor checks.

Change Type (select all)

  • Bug fix

Scope (select all touched areas)

  • CLI commands (src/commands/)
  • Session config (src/config/sessions/)

Linked Issue/PR

  • Closes #71960
  • This PR fixes a bug or regression

Root Cause

  • Root cause: isPrimarySessionTranscriptFileName() matched any *.jsonl file that wasn't a compaction checkpoint or archive artifact. Trajectory sidecar files (*.trajectory.jsonl) are a distinct artifact type but were not excluded, so they passed the primary transcript filter. Meanwhile, referencedTranscriptPaths only contained paths from sessions.json entries — not trajectory sidecar paths referenced via *.trajectory-path.json.
  • Missing detection / guardrail: No test verified that trajectory sidecar files would not be classified as primary transcripts.
  • Contributing context: Trajectory sidecars were added after the orphan transcript detection, and the classification predicate was not updated to account for the new file type.

Regression Test Plan

  • Coverage level that should have caught this:
    • Unit test
  • Target test or file: src/commands/doctor-state-integrity.test.ts, src/config/sessions/artifacts.test.ts
  • Scenario the test should lock in: A *.trajectory.jsonl file in the sessions directory must NOT be reported as an orphan transcript by doctor state-integrity.
  • Why this is the smallest reliable guardrail: Direct unit test on the classification helper + integration test on the doctor check — no runtime dependencies needed.
  • Existing test that already covers this: N/A

User-visible / Behavior Changes

openclaw doctor no longer warns about active trajectory sidecar files as orphan transcripts.

Diagram (if applicable)

N/A

Security Impact (required)

  • New permissions/capabilities? No
  • This fix tightens file classification to exclude trajectory sidecars from orphan detection. No new data exposure, no security-sensitive paths touched.

Changed files

  • src/commands/doctor-state-integrity.test.ts (modified, +14/-0)
  • src/config/sessions/artifacts.test.ts (modified, +10/-0)
  • src/config/sessions/artifacts.ts (modified, +7/-0)
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

openclaw doctor can report an active session trajectory sidecar as an orphan transcript and say it is safe to archive.

Steps to reproduce

  1. Run OpenClaw with an active session that has a live *.trajectory-path.json pointing to *.trajectory.jsonl.
  2. Run openclaw doctor --non-interactive.
  3. Observe an orphan transcript warning for the active trajectory sidecar.

Expected behavior

Doctor should not mark an active session trajectory sidecar as safely archivable orphan state.

Actual behavior

Doctor reported Found 1 orphan transcript file and suggested it could be safely archived, while sessions.json still referenced the active session, the trajectory-path.json still pointed to the flagged trajectory file, and the session lock was live for the active gateway PID.

OpenClaw version

2026.4.24

Operating system

macOS 26.4.1 (arm64)

Install method

mac app / LaunchAgent gateway

Model

openai-codex/gpt-5.4

Provider / routing chain

openclaw -> openai-codex

Additional provider/model setup details

Affected session was an active Discord channel session. The flagged file was b8fc0af0-1692-474b-b11e-636a8b8ab00f.trajectory.jsonl, and b8fc0af0-1692-474b-b11e-636a8b8ab00f.trajectory-path.json still pointed to it during the warning.

Logs, screenshots, and evidence

Impact and severity

Affected surface: doctor state-integrity guidance Severity: medium Frequency: observed on this active session Consequence: users may be told an active trajectory sidecar is safe to archive

Additional information

Likely fix directions: exclude *.trajectory.jsonl from primary orphan-transcript checks, include sidecars referenced through *.trajectory-path.json, or soften the warning text.

extent analysis

TL;DR

Exclude *.trajectory.jsonl files from primary orphan-transcript checks to prevent openclaw doctor from marking active session trajectory sidecars as safely archivable.

Guidance

  • Review the openclaw doctor's logic for identifying orphan transcripts to ensure it accounts for active sessions with live *.trajectory-path.json references.
  • Consider adding a check to ignore *.trajectory.jsonl files that are referenced by *.trajectory-path.json files to prevent false positives.
  • Update the warning text to reflect that an active session's trajectory sidecar should not be archived, even if reported as an orphan transcript.
  • Verify the fix by running openclaw doctor --non-interactive on an active session with a live *.trajectory-path.json reference to ensure no orphan transcript warning is reported.

Example

No code snippet is provided as the issue does not contain sufficient code details.

Notes

The provided information suggests that the issue is specific to the openclaw doctor's logic and may not be related to the OpenClaw version or operating system.

Recommendation

Apply workaround: exclude *.trajectory.jsonl files from primary orphan-transcript checks, as this is a targeted fix that addresses the reported issue without requiring a version upgrade.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Doctor should not mark an active session trajectory sidecar as safely archivable orphan state.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix openclaw doctor state-integrity orphan transcript detection appears to ignore active *.trajectory.jsonl sidecars [2 pull requests, 1 comments, 2 participants]