Skip to content

fix(csv_export): key sessions by (project, session_file, session_id) - #20

Open
serendipity-zk wants to merge 2 commits into
uw-syfi:mainfrom
serendipity-zk:fix-session-identity
Open

fix(csv_export): key sessions by (project, session_file, session_id)#20
serendipity-zk wants to merge 2 commits into
uw-syfi:mainfrom
serendipity-zk:fix-session-identity

Conversation

@serendipity-zk

Copy link
Copy Markdown
Collaborator

Session grouping in artifacts/trace_facts/csv_export/convert.py uses session_id alone, but that id is not unique in the source.

Per artifacts/utils/DB_SCHEMA.md, 16 ids in the public trace span more than one session file — 1,216 rounds — and (session_id, round_index) has 514 duplicates.

Grouping on the id alone merges unrelated conversations into a single session, interleaves their rounds by round_index, and then hides the merge behind the contiguous round_idx the converter re-derives. The exported prefix chain for those sessions describes a conversation that never happened, which matters for anyone using the CSV to reason about prefix reuse.

The fix widens the grouping key to (project, session_file, session_id).

Downstream only consumes .values(), and the emitted id column is a fresh ordinal from enumerate, so no output column changes for any session that was already unambiguous.

🤖 Generated with Claude Code

`session_id` is not unique in the source. 16 ids in the public trace span more
than one session file, covering 1,216 rounds, and `(session_id, round_index)`
has 514 duplicates — see `artifacts/utils/DB_SCHEMA.md`.

Grouping on the id alone merges unrelated conversations into one, interleaves
their rounds by `round_index`, and then hides the merge behind the contiguous
`round_idx` this converter re-derives. The exported prefix chain for those
sessions describes a conversation that never happened.

Only `.values()` is consumed downstream and the emitted `id` column is a fresh
ordinal from `enumerate`, so widening the key changes no output column for any
session that was already unambiguous.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
serendipity-zk added a commit to serendipity-zk/TraceLab that referenced this pull request Aug 13, 2026
The replay client was a request frontend sharing a directory with a corpus.
Nothing else here referenced it: the top-level README never mentioned `replay`,
`session_runner`, or `tracegen`, and its Cargo.toml already declared an empty
`[workspace]` so it would not inherit a host repo.

It now lives at serendipity-zk/req-frontend, carrying the full history of the
21 commits that touched this directory. The skill that documented it goes with
it. PR uw-syfi#19, which would have landed this crate upstream, is
closed; its one dataset-level fix is re-sent standalone as uw-syfi#20.

The contract between the two repos is unchanged and unidirectional: this repo's
`artifacts/trace_facts/csv_export/convert.py` exports raw session rounds, and
`tracegen` over there materializes them into a canonical execution trace.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`session_file` is optional in this schema — `cache_replay/analyze.py` already
says so at its column projection ("present in some traces, absent in others")
and projects it defensively. The v0.0.2 release DuckDB does not have the
column, so selecting it unconditionally aborts the export with a binder error.

Probe `information_schema.columns` and substitute a NULL literal when it is
missing. The key then degrades to `(project, session_id)`, which is still
strictly narrower than grouping on the id alone.

Verified both ways: v0.0.1 has the column and reproduces the expected export
byte-for-byte; v0.0.2 does not and now exports instead of crashing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant