Skip to content

feat(cli): batch import local sessions with redaction, retention, and dedup - #2100

Open
suryanshxharma wants to merge 11 commits into
ClickHouse:mainfrom
suryanshxharma:feat/ingest-transcript-import
Open

suryanshxharma wants to merge 11 commits into
ClickHouse:mainfrom
suryanshxharma:feat/ingest-transcript-import

Conversation

@suryanshxharma

@suryanshxharma suryanshxharma commented Dec 3, 2026 •

Copy link
Copy Markdown

Part 2 of #2078 (builds on #2099).

  • Added --project, --newest, and --retention-days to loom ingest-transcript for batch-importing discovered Claude Code and Codex sessions.
  • Added client-side secret redaction (redact_secrets) matching the plugin hooks so credentials, tokens, JWTs, and private keys are scrubbed before leaving the machine.
  • Checks namespace.get for the namespace recording setting and retention window, and conversation.threads to skip already-imported session_id threads.
  • Prints how many sessions will be imported before writing, and tags imported turns with metadata.source_class="imported" and session_ts.
  • Added unit tests covering redaction, retention filtering, idempotent re-runs, and disabled recording, and updated CLI snapshots and docs/reference/cli.md.

Note

Medium Risk
Imports local chat transcripts into Loom with client-side redaction and namespace policy checks; mishandled secrets or policy bypass could leak credentials or store conversations when recording is intended to be off.

Overview
loom ingest-transcript now discovers and imports local Claude Code and Codex session JSONL under ~/.claude / ~/.codex, in addition to markdown and JSON files.

New flags: --discover lists sessions by project (no network); --project batch-imports matching projects; --newest caps how many sessions per run; --retention-days drops old sessions (defaults to the namespace’s conversation retention when unset). --namespace / --file are optional when using --discover alone.

Implementation adds server/cli/_transcripts.py: JSONL parsing (active branch / compaction-aware for Claude), injected-tag stripping, redact_secrets before any upload, and namespace.get gating (abort if policy lookup fails; skip when recording is off). Turns post via a shared _post_turns path with source_class: imported metadata, session_ts, and idempotent conversation.append dedup on duplicate msg_id. CLI reference and help snapshots are updated; unit tests cover parsers, discovery, redaction, retention, and policy failures.

Reviewed by Cursor Bugbot for commit a920bbe. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Dec 6, 2026 11:55am UTC
loom-telemetry Ready Ready Preview Dec 6, 2026 11:55am UTC

Request Review

@cursor cursor 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.

Stale Bugbot comment from a previous run.

Comment thread server/cli/shell.py Resolved
Comment thread server/cli/shell.py Resolved
Comment thread server/cli/shell.py Resolved
Comment thread server/cli/shell.py Resolved
@zlareb1 zlareb1 self-assigned this Dec 3, 2026

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Batch import needs to stop when recording policy cannot be verified and resume after a partial upload. The four commits on this head also need the required DCO sign-offs.

Comment thread server/cli/shell.py Resolved
Comment thread server/cli/shell.py Resolved

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The agent token-refusal and session delivery-census tests pass on the tested base and both fail on this exact CI merge. Failed job

Comment thread server/cli/shell.py Resolved
Comment thread server/cli/shell.py Resolved
@suryanshxharma
suryanshxharma force-pushed the feat/ingest-transcript-import branch from 2651263 to 5e627a3 Compare December 4, 2026 16:15

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The batch path stops on a failed policy request and uses per-turn IDs for retries. The focused import suite passed 16 tests. The retention decision still admits sessions that the conversation plane’s retention should exclude. The Unicode redaction finding in the shared parser also applies to this head.

Comment thread server/cli/shell.py
print(f"recording is disabled for namespace {namespace}; skipping import")
return 0

retention_days = int(getattr(args, "retention_days", 0) or 0) or ns_retention

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

P1 — This selects the CLI value ahead of the policy, and the policy lookup reads a namespace retention value. The conversation TTL uses the deployment’s retention_conversations_days, which NamespaceGetOutput never returns. A probe with a 30-day policy and --retention-days 90 posts a 60-day-old session. Read the effective conversation retention, let the CLI narrow that window, and cover the case with the real policy response shape.

Comment thread server/cli/shell.py Resolved
@suryanshxharma
suryanshxharma force-pushed the feat/ingest-transcript-import branch from 5e627a3 to 64e0100 Compare December 4, 2026 17:09

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 64e0100. Configure here.

Comment thread server/cli/_transcripts.py Resolved
Comment thread server/cli/_transcripts.py Resolved
@suryanshxharma
suryanshxharma force-pushed the feat/ingest-transcript-import branch 2 times, most recently from 945e3ee to 60c7ec9 Compare December 4, 2026 17:32

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The conversation-retention finding and the untyped callback return remain on this head. The redactor also skips credentials after Unicode whitespace.

Comment thread server/cli/_transcripts.py Resolved

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The Python SDK adapter job fails during test collection with agent-framework-core 1.26.0 and opentelemetry-api 1.46.0. Clean main fails with the same versions and traceback. A separate PR constrains the incompatible dependency. PR job · Main job · Fix #2164

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The batch callback now has a typed return. Two findings still block this head. The importer can accept sessions outside the effective conversation retention window, and the redactor can send credentials after Unicode whitespace. Retention thread · Redaction thread

Comment thread server/cli/shell.py Outdated
return 0


def _cmd_ingest_transcript(args: argparse.Namespace) -> int:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

P2 — _cmd_ingest_transcript is 225 lines, above the 200-line function limit. Extract the single-file parsing or upload path so the function passes the existing gate. Failed check

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The Postgres restore test fails before initialization starts. A controlled connection delay reproduces the same timeout on the CI base and on clean main. The repair starts the test deadline after Postgres reports the blocked query. Failed job · Repair #2181

@suryanshxharma
suryanshxharma force-pushed the feat/ingest-transcript-import branch from 151ae7e to b27c311 Compare December 6, 2026 07:36

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The Unicode whitespace regression is fixed. The retention finding still applies. The batch flag can widen the configured retention window, and the policy lookup still reads namespace retention in place of conversation retention. The function-length finding also remains.

)
_SECRET_ASSIGNMENT_RE = re.compile(
r"""(?a:\b)((?a:[\w.-]){0,64}?(?:password|passwd|secret|secret[_-]?key|token|api[_-]?key"""
r"""|access[_-]?key|private[_-]?key)(?a:\b)["']?\s*[=:]\s*)("[^"]*"|'[^']*'|[^\s"'\\,;}]+)""",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

P1 — The quoted value matcher ends at an escaped quote. A synthetic quoted password with an escaped quote keeps its suffix after redaction, and this result becomes the batch turn's outgoing content. Consume escaped characters inside quoted values and test the outgoing request.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Dependency review hits the 300-file limit while checking base-only changes. The same replay fails with the contributor diff removed on the CI base and on current main. Repair #2053 passes the replay using the tested merge. Failed job · Repair #2053

…o ingest-transcript

Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>
…SONL error

Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>
Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>
…k token before args

Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>
Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>
Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>
Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>
…ace redaction

Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>
… dedup

Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>
Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>
…gest_transcript under 200 lines

Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>
@suryanshxharma
suryanshxharma force-pushed the feat/ingest-transcript-import branch from b27c311 to a920bbe Compare December 6, 2026 11:52

This branch has not been deployed

No deployments
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