Skip to content

fix(trace): keep JSON export metadata reusable - #575

Merged
codelion merged 1 commit into
algorithmicsuperintelligence:mainfrom
Elon-Jiang:fix/json-export-metadata
Nov 1, 2026
Merged

codelion merged 1 commit into
algorithmicsuperintelligence:mainfrom
Elon-Jiang:fix/json-export-metadata

Conversation

@Elon-Jiang

Copy link
Copy Markdown
Contributor

Problem

Reusing a non-empty metadata dictionary across JSON trace exports produces stale export statistics. export_traces_json() inserts total_traces and exported_at directly into the caller's dictionary. A second export with two traces can consequently still claim one trace and the first export's timestamp.

Change

Copy the top-level metadata dictionary before adding export defaults. Each export gets fresh defaults, and the caller's dictionary stays reusable. Explicit caller-provided total_traces and exported_at overrides remain supported. Trace content and HDF5 encoding are unchanged.

Add real-file regression coverage for sequential exports with reused metadata, explicit statistics overrides, and empty/missing metadata. The clock is replaced only in the export module so logging uses its real clock.

Validation

Python 3.12.13, macOS arm64, current main cb49662150aa794149d477379c605a3bff0c08a2:

  • Before: the three new tests report 1 failed, 2 passed, because the second export reports total_traces=1 for two traces.
  • After: 3 passed.
  • OPENAI_API_KEY=test-key-for-unit-tests python -m unittest discover tests: 1,006 tests run, 2 skipped; all remaining tests pass.
  • Black and isort checks on both changed files, plus git diff --check: pass.

An initial full-suite run exposed a test-only clock mock affecting logging; isolating the module's clock fixed that interference, and the complete suite was rerun successfully. No live LLM/provider calls were made.

Prepared with AI assistance from an independent source review, and checked against actual files written by the public export function.

@codelion
codelion merged commit 48f0826 into algorithmicsuperintelligence:main Nov 1, 2026
5 checks passed
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.

2 participants