fix: real timestamps on claude preamble steps; validate asserts schema formats#120
Open
od0 wants to merge 1 commit into
Open
fix: real timestamps on claude preamble steps; validate asserts schema formats#120od0 wants to merge 1 commit into
od0 wants to merge 1 commit into
Conversation
…a formats Claude Code writes several headerless session-log lines with no timestamp field (last-prompt, ai-title, custom-title; a headless `claude -p` run produces them every time). toolpath-claude stamped the derived claude-preamble-N steps with `"timestamp": ""`, which the schema forbids ($defs/timestamp is format: date-time) but `path p validate` silently accepted, because JSON Schema draft 2020-12 treats format as annotation-only unless the validator opts in. Fix both ends: - toolpath-claude (0.12.1): a step derived from a timestamp-less preamble line resolves its timestamp from the nearest real source — the entry the line references (leafUuid / messageId), else the previous preamble line, else the session's first timestamped entry. Only the derived step's identity changes; the source line still rides verbatim in the step's structural change (extra["raw"]), so projecting back to Claude JSONL is unaffected. - path-cli (0.15.0): `path p validate` opts into format assertion, so format: date-time on step timestamps and format: uri on meta.kind / path-ref $ref / signature href are enforced instead of ignored. Documents imported with an older toolpath-claude may now fail validation on their empty preamble timestamps; re-importing the session fixes them. (toolpath-cli 0.15.0 tracks the bump.) Regression tests at every layer: resolution priority + projection purity (provider), a last-prompt fixture session (derive), the real captured session (integration), empty-timestamp rejection (schema), and an end-to-end import→validate round trip that fails without the provider fix. Fixes #119
|
🔍 Preview deployed: https://5e25fb26.toolpath.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes #119.
Claude Code writes several headerless session-log lines with no
timestampfield (last-prompt,ai-title,custom-title; a headlessclaude -prun produces them every time).toolpath-claudestamped the derivedclaude-preamble-Nsteps with"timestamp": "", which the schema forbids ($defs/timestampisformat: date-time) — butpath p validateaccepted anyway, because JSON Schema draft 2020-12 treatsformatas annotation-only unless the validator opts in. This PR fixes both ends.toolpath-claude(0.12.1): a step derived from a timestamp-less preamble line resolves its timestamp from the nearest real source — the entry the line references (leafUuid, which reallast-promptlines carry, ormessageIdonfile-history-snapshot), else the previous preamble line's resolved time, else the session's first timestamped entry. Only the derived step's identity changes; the source line still rides verbatim in the step's structural change (extra["raw"]), so projecting back to Claude JSONL is unaffected — a test proves the raw lines gain no timestamp on the way out.path-cli(0.15.0):p validateopts into format assertion, soformat: date-timeon step timestamps andformat: urionmeta.kind/ path-ref$ref/ signaturehrefare enforced instead of ignored. On a pre-fix import this produces exactly the failure from Claude imports emit empty timestamps on preamble steps, and validate doesn't catch them #119 — aoneOfviolation at/paths/0. Documents cached by oldertoolpath-claudereleases may now fail validation on their empty preamble timestamps; re-importing the session fixes them.Tests
last-promptentry — every derived step parses as RFC 3339, and thelast-promptstep carries theleafUuid-referenced entry's time.last-prompt+ 4ai-titlelines) derives with all-valid timestamps./paths/0.p import claude→p validateon a preamble-bearing fixture — verified red without the provider fix, green with it.Verification
A fresh headless-session import validates. A real ~300-preamble-line session went from ~300 empty timestamps to zero and validates; a pre-fix import of the same session now fails with the
oneOf-at-/paths/0signature from the issue. All 12 example documents and a live Codex import still validate under format assertion.cargo test --workspace(57 targets),cargo clippy --workspace -- -D warnings, the out-of-workspacetoolpath-clishim build, and the site build (11 pages) are all green.Scope
toolpath-claude(conversation_to_view), one inpath-cli(schema.rsopts into format assertion), plus tests.toolpath-claude0.12.0 → 0.12.1(patch),path-cli0.14.0 → 0.15.0(validate behavior change; pre-1.0 minor),toolpath-clishim tracking0.15.0— with the workspace / crates.json / CHANGELOG / CLAUDE.md updates.toolpath-cursorbuilds turn timestamps withcreated_at.unwrap_or_default()and could emit the same class of empty timestamp if a bubble ever lackscreatedAt.Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.