Skip to content

fix(agent-core): report correct JSONL entry line after blank rows - #103645

Merged
steipete merged 3 commits into
openclaw:mainfrom
qingminglong:codex/fix-session-jsonl-blank-line-number
Jul 10, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
qingminglong:codex/fix-session-jsonl-blank-line-number

Conversation

@qingminglong

@qingminglong qingminglong commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where developers opening a JSONL-backed agent-core session would see an incorrect invalid-entry line number when the session file contained blank JSONL rows before the malformed entry.

Why This Change Was Made

JsonlSessionStorage already skips blank JSONL rows while loading sessions, so entry diagnostics should still point to the physical source line after those blanks are skipped. The parser now carries each retained row's original line number into entry validation without changing header parsing or storage semantics.

User Impact

Developers and operators can trust invalid JSONL session diagnostics to point at the actual malformed row, making session repair and support investigation less misleading.

Evidence

  • Claim proved: opening a real JSONL session file through JsonlSessionStorage.open now reports the malformed entry on physical line 3 when physical line 2 is blank.
  • Current head: e896a3a5fcafb912d7f2424cb06f10dc06dfa822.
  • Commands / artifacts:
    • node --import tsx --input-type=module - proof script wrote a temporary invalid-entry.jsonl, called JsonlSessionStorage.open(new NodeExecutionEnv(...), "invalid-entry.jsonl"), and asserted the corrected diagnostic.

    • Real session-open transcript:

      proof: JsonlSessionStorage.open real JSONL file
      session file lines: 1 header, 2 blank, 3 malformed JSON
      observed error: Invalid JSONL session file invalid-entry.jsonl: line 3 is not valid JSON
      
    • node scripts/run-vitest.mjs packages/agent-core/src/harness/session/jsonl-storage.test.ts passed with 1 test file and 7 tests.

    • git diff --check upstream/main...HEAD passed.

    • python .agents\skills\autoreview\scripts\autoreview --mode branch --base upstream/main passed with no accepted/actionable findings.

  • Observed result: the real file-backed session-open path and the focused regression both report line 3 is not valid JSON for an invalid entry that follows a blank JSONL row.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 10, 2026
@clawsweeper

clawsweeper Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 10, 2026, 9:20 AM ET / 13:20 UTC.

Summary
Preserve physical source line numbers for nonblank JSONL session rows so malformed-entry diagnostics remain accurate after skipped blank rows, with regression coverage.

PR surface: Source +3, Tests +16. Total +19 across 2 files.

Reproducibility: yes. from source inspection: current main filters blank rows before assigning entry diagnostic positions, so a malformed physical row after a blank is reported one line early; the contributor also provides a real after-fix file-open transcript.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: packages/agent-core/src/harness/session/jsonl-storage.test.ts, serialized state: packages/agent-core/src/harness/session/jsonl-storage.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Risk before merge

  • [P1] The PR branch is behind current main, although GitHub reports it mergeable and the focused diff against current main remains unchanged; landing should use refreshed exact-merge-head checks.

Maintainer options:

  1. Decide the mitigation before merge
    Merge the physical-line bookkeeping and regression test while preserving blank-row acceptance, then rely on the normal exact-merge-head gate to refresh the behind branch without broadening the parser change.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P2] No repair job is needed; maintainers can review and land the clean patch after the normal refreshed merge-head gate.

Security
Cleared: The parser-and-test-only diff introduces no dependency, workflow, secret, permission, package-resolution, download, lifecycle, or new code-execution concern.

Review details

Best possible solution:

Merge the physical-line bookkeeping and regression test while preserving blank-row acceptance, then rely on the normal exact-merge-head gate to refresh the behind branch without broadening the parser change.

Do we have a high-confidence way to reproduce the issue?

Yes from source inspection: current main filters blank rows before assigning entry diagnostic positions, so a malformed physical row after a blank is reported one line early; the contributor also provides a real after-fix file-open transcript.

Is this the best way to solve the issue?

Yes. Carrying the original physical line number through the existing load loop is the narrowest maintainable fix and avoids changing accepted input, header parsing, persistence, or session-tree semantics.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 328eaa3a23d6.

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body now contains after-fix terminal output from opening a real on-disk malformed JSONL file through JsonlSessionStorage.open at the reviewed head, and the repository proof check passes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body now contains after-fix terminal output from opening a real on-disk malformed JSONL file through JsonlSessionStorage.open at the reviewed head, and the repository proof check passes.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P3: This is a low-blast-radius diagnostic accuracy fix for malformed developer-facing session files.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body now contains after-fix terminal output from opening a real on-disk malformed JSONL file through JsonlSessionStorage.open at the reviewed head, and the repository proof check passes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body now contains after-fix terminal output from opening a real on-disk malformed JSONL file through JsonlSessionStorage.open at the reviewed head, and the repository proof check passes.
Evidence reviewed

PR surface:

Source +3, Tests +16. Total +19 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 6 3 +3
Tests 1 16 0 +16
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 22 3 +19

What I checked:

Likely related people:

  • bdjben: Git blame and history attribute the current agent-core JSONL loader and its adjacent tests in this checkout to the merged import commit associated with his recent session/Codex work. (role: recent area contributor; confidence: high; commits: 1f3ea6faaab0; files: packages/agent-core/src/harness/session/jsonl-storage.ts, packages/agent-core/src/harness/session/jsonl-storage.test.ts)
  • steipete: The introducing merge commit credits him as co-author, and he co-authored the hardened session-binding work in the linked merged PR that brought the current surface into main. (role: co-author and adjacent owner; confidence: medium; commits: 1f3ea6faaab0, b17a74ce3582; files: packages/agent-core/src/harness/session/jsonl-storage.ts, extensions/codex/src/migration/session-binding-sidecars.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-07-10T12:26:48.886Z sha e896a3a5fcafb912d7f2424cb06f10dc06dfa822 :: needs real behavior proof before merge. :: none

@qingminglong

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

I updated the PR body Evidence with a current-head real session-open transcript from JsonlSessionStorage.open using a temporary JSONL file on disk: header on line 1, blank line 2, malformed JSON on line 3. The observed diagnostic is now line 3 is not valid JSON at head e896a3a5fcafb912d7f2424cb06f10dc06dfa822.

@clawsweeper

clawsweeper Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 10, 2026
@steipete
steipete force-pushed the codex/fix-session-jsonl-blank-line-number branch from ab3c5a0 to af1fbbc Compare July 10, 2026 16:49
@steipete
steipete force-pushed the codex/fix-session-jsonl-blank-line-number branch from af1fbbc to fb1c6ec Compare July 10, 2026 16:57
@steipete

Copy link
Copy Markdown
Contributor

Land-ready proof for exact head fb1c6ec438b961ec44773a16da15e0374771a0c0:

  • Reworked the loader to scan the original split lines by physical index, avoiding the PR's per-row object allocation while preserving blank-row, header, tree, leaf, and append-parent semantics.
  • Added a real file-backed NodeExecutionEnv regression: whitespace-only CRLF and multiple blank rows, one valid entry, malformed physical line 6, plus a valid-session control with the same blank layout.
  • Sanitized AWS/public-network/no-hydration proof: pnpm test packages/agent-core/src/harness/session/jsonl-storage.test.ts passed 7/7 (run_ec012762e83d).
  • Sanitized exact-head changed gate: pnpm check:changed passed core/core-test types, lint, guards, and changed-surface checks (run_669d602cfb4d).
  • Hosted exact-head CI passed all 45 relevant jobs: https://github.com/openclaw/openclaw/actions/runs/29109338574
  • Fresh autoreview after the final lint-safe cleanup reported no accepted/actionable findings (0.99 confidence). git diff --check passed.

Known proof gaps: none.

@steipete
steipete merged commit 3a64889 into openclaw:main Jul 10, 2026
81 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 11, 2026
…enclaw#103645)

* fix(agent-core): report jsonl entry physical line numbers

* fix(agent-core): preserve physical JSONL line numbers

* test(agent-core): keep JSONL cleanup lint-safe

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants