Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to the Toolpath workspace are documented here.

## Pi: skip unparseable lines instead of failing the read — 2026-07-08

- **`toolpath-pi`** (0.6.1): Crashed or truncated Pi session files now load
gracefully. Previously, a truncated final line (invalid JSON) would fail
the entire session read; now unparseable lines are skipped with a warning
(matching `toolpath-codex`'s documented safe-reader policy). Header parsing
remains a hard error — a session without a parseable header has no identity.

## Derive: resolve duplicate step ids — 2026-07-01

- **`toolpath-convo`** (0.11.1): `derive_path` now guarantees the derived
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ toolpath-cursor = { version = "0.2.0", path = "crates/toolpath-cursor" }
toolpath-github = { version = "0.6.0", path = "crates/toolpath-github" }
toolpath-dot = { version = "0.5.0", path = "crates/toolpath-dot" }
toolpath-md = { version = "0.7.0", path = "crates/toolpath-md" }
toolpath-pi = { version = "0.6.0", path = "crates/toolpath-pi" }
toolpath-pi = { version = "0.6.1", path = "crates/toolpath-pi" }
path-cli = { version = "0.14.0", path = "crates/path-cli" }
pathbase-client = { version = "0.2.0", path = "crates/pathbase-client" }

Expand Down
2 changes: 1 addition & 1 deletion crates/toolpath-pi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "toolpath-pi"
version = "0.6.0"
version = "0.6.1"
edition.workspace = true
license.workspace = true
repository = "https://github.com/empathic/toolpath"
Expand Down
57 changes: 53 additions & 4 deletions crates/toolpath-pi/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,12 @@ pub fn read_session_from_file(path: &Path) -> Result<PiSession> {
continue;
}
Err(_) => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we print the actual error? Also, this reader isn't the right place to make the decision on whether to strictly skip or not, depending on the error. We should probably bubble the set of errors found up to the caller to make a decision as to how to handle it.

return Err(PiError::invalid_session_file(
path.to_path_buf(),
format!("line {line_no}: {parse_err}"),
));
eprintln!(
"warning: skipping unparseable line at {}:{} (truncated write?): {parse_err}",
path.display(),
line_no
);
continue;
}
}
}
Expand Down Expand Up @@ -837,6 +839,53 @@ mod tests {
let ids: Vec<&str> = s.message_entries().map(|(b, _)| b.id.as_str()).collect();
assert_eq!(ids, vec!["a", "b"]);
}

#[test]
fn truncated_final_line_is_skipped_with_warning() {
let tmp = TempDir::new().unwrap();
let path = tmp.path().join("s.jsonl");
// valid header + one valid entry + a truncated JSON fragment
let content = format!(
"{}\n{}\n{{\"type\":\"mess",
header_line("sess-1"),
msg_line("a", None, "2026-04-16T00:00:01Z", "hi")
);
fs::write(&path, content).unwrap();
let session = read_session_from_file(&path).unwrap();
// Header + 1 message; truncated line skipped
assert_eq!(session.entries.len(), 2);
}

#[test]
fn garbage_mid_file_line_is_skipped_and_later_entries_survive() {
let tmp = TempDir::new().unwrap();
let path = tmp.path().join("s.jsonl");
write_jsonl(
&path,
&[
&header_line("sess-1"),
"not json at all",
&msg_line("a", None, "2026-04-16T00:00:01Z", "hi"),
],
);
let session = read_session_from_file(&path).unwrap();
// Header + 1 message; garbage line skipped
assert_eq!(session.entries.len(), 2);
}

#[test]
fn malformed_header_still_hard_fails() {
let tmp = TempDir::new().unwrap();
let path = tmp.path().join("s.jsonl");
// first non-empty line is invalid JSON -> Err (unchanged behavior)
fs::write(&path, "not json at all").unwrap();
let err = read_session_from_file(&path).unwrap_err();
// Should be an InvalidSessionFile or MalformedHeader error
assert!(matches!(
err,
PiError::InvalidSessionFile { .. } | PiError::MalformedHeader(_)
));
}
}

// Small fallback helper for tests to set mtimes without adding a new dep.
Expand Down
2 changes: 1 addition & 1 deletion site/_data/crates.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
},
{
"name": "toolpath-pi",
"version": "0.6.0",
"version": "0.6.1",
"description": "Derive Toolpath provenance documents from Pi (pi.dev) agent session logs",
"docs": "https://docs.rs/toolpath-pi",
"crate": "https://crates.io/crates/toolpath-pi",
Expand Down
Loading