Skip to content

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

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

suryanshxharma wants to merge 9 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 potentially sensitive local chat content into the server after client-side redaction; incorrect redaction or policy bypass could leak secrets or store data when recording is off.

Overview
Extends loom ingest-transcript so local Claude Code and Codex sessions can be discovered, parsed, and batch-imported into Loom conversations—not only single markdown/JSON files.

--discover lists projects under ~/.claude/projects and ~/.codex/sessions. --project (repeatable) imports matching sessions; --newest caps how many recent sessions are taken; --retention-days drops old sessions (defaulting to the namespace’s retention from namespace.get). --file now accepts .jsonl transcripts with auto-detected format.

New module server/cli/_transcripts.py parses JSONL (active Claude branch via parentUuid / logicalParentUuid, strips injected client tags and tool results), aggregates discovery by project, and redact_secrets scrubs tokens, JWTs, keys, and similar patterns (plus the caller’s token) before any upload.

Import paths verify conversation recording is enabled on the namespace, abort if policy lookup fails, and post turns via shared _post_turns that treats conversation.append duplicate acks as idempotent re-runs. Imported rows get metadata such as source_class: imported, source, project, and session_ts.

Reviewed by Cursor Bugbot for commit 151ae7e. 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 4, 2026 7:31pm UTC
loom-telemetry Ready Ready Preview Dec 4, 2026 7:31pm 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
…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>
@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
Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>
@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
Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>
@suryanshxharma
suryanshxharma force-pushed the feat/ingest-transcript-import branch from 64e0100 to 945e3ee Compare December 4, 2026 17:23
Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>
… dedup

Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>
@suryanshxharma
suryanshxharma force-pushed the feat/ingest-transcript-import branch 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.

r"""|access[_-]?key|private[_-]?key)\b["']?\s*[=:]\s*)("[^"]*"|'[^']*'|[^\s"'\\,;}]+)""",
re.IGNORECASE | re.ASCII,
)
_JWT_RE = re.compile(r"\beyJ[\w-]{0,512}\.[\w-]{1,8192}\.[\w-]{0,1024}", re.ASCII)

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 — With re.ASCII on the whole expression, Bearer followed by a non-breaking space and a credential no longer matches. Scope ASCII to the boundary with (?a:\b), preserve Unicode whitespace in the assignment and Basic auth expressions too, and cover the outgoing batch 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.

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

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

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

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