Skip to content

perf: anonymize traces inline during extraction instead of a second pass#25

Merged
armand0e merged 2 commits into
TeichAI:mainfrom
CompactAIOfficial:perf/extract-inline-anonymize
Jul 10, 2026
Merged

perf: anonymize traces inline during extraction instead of a second pass#25
armand0e merged 2 commits into
TeichAI:mainfrom
CompactAIOfficial:perf/extract-inline-anonymize

Conversation

@CompactAIOfficial

Copy link
Copy Markdown
Contributor

teich extract (and the studio extraction flow) wrote every trace to disk, then anonymize_path(output, output, in_place=True) re-read and rewrote the entire output directory. Every trace was read twice and written twice.

This threads an optional inline anonymizer through extraction's copy/write helpers so each trace is anonymized as it is first written — one read, one write:

  • extract_local_sessions gains anonymize: bool = False; ExtractResult gains anonymize_totals for the CLI/studio summary lines
  • the jsonl copy path (_copy_provider_jsonl) streams source → anonymized destination instead of shutil.copy2 + rewrite
  • the hermes/cursor row-writing paths anonymize events before serialization
  • scoping is unchanged: one TraceAnonymizer per output file (consistent within a trace, fresh across traces)
  • teich anonymize and its --in-place behavior are untouched; --no-anon still skips everything

One test fake updated to accept the new keyword.

Testing

  • pytest — same results as main (the handful of pre-existing test_runner.py/integration failures reproduce on a clean checkout; everything else passes, 530+)
  • end-to-end check: extraction with anonymize=True scrubs seeded key/email/home-path and reports correct totals; anonymize=False leaves data raw and totals None

🤖 Generated with Claude Code

teich extract wrote every trace to disk and then re-read and rewrote
the whole output directory with anonymize_path. Extraction now threads
an optional inline anonymizer through the copy and write helpers, so
each trace is anonymized as it is first written — one read and one
write per file instead of two. Scoping is unchanged: one
TraceAnonymizer per output file.

extract_local_sessions gains an anonymize flag and reports totals on
ExtractResult; the CLI and studio extraction flows use it and drop
their post-pass. teich anonymize is untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9bc627e496

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/teich/cli.py
@armand0e
armand0e merged commit 1d7ba7c into TeichAI:main Jul 10, 2026
3 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