feat(ingest): distinguish T3 app Codex sessions - #633
Conversation
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
Warning Review limit reached
Next review available in: 50 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 20e0108. Configure here.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 20e0108fa0
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for batch_start in range(0, len(candidates), batch_size): | ||
| batch = candidates[batch_start : batch_start + batch_size] | ||
| connection.executemany( | ||
| "UPDATE chunks SET provenance_class = ? WHERE id = ?", |
There was a problem hiding this comment.
Guard retags with the selected provenance
When the watcher or enrichment changes a candidate after _candidates() reads it but before this batch executes, the unconditional update overwrites that newer provenance with t3-app-session. The busy timeout only serializes individual SQLite statements, while each batch commit leaves a race across the scan-to-update interval; add the expected codex-session value to the WHERE clause or hold the repository's writer lock for the operation.
AGENTS.md reference: AGENTS.md:L28-L30
Useful? React with 👍 / 👎.
| else {} | ||
| ) | ||
| existing.update(dict(candidates)) | ||
| with path.open("w", encoding="utf-8") as artifact: |
There was a problem hiding this comment.
Preserve existing rollback artifacts atomically
When --apply is rerun with an existing artifact, this "w" open truncates the only rollback record before the preserved entries are rewritten. A crash, interruption, or ENOSPC during that rewrite can therefore destroy recovery data for rows changed by the earlier run even though the merge behavior explicitly supports artifact reuse; write a temporary file and atomically replace the artifact instead.
AGENTS.md reference: AGENTS.md:L5-L8
Useful? React with 👍 / 👎.
| pre_restore_path.parent.mkdir(parents=True, exist_ok=True) | ||
| with pre_restore_path.open("x", encoding="utf-8") as artifact: | ||
| for chunk_id, _ in candidates: | ||
| artifact.write(json.dumps({"id": chunk_id, "provenance_class": current_values[chunk_id]}) + "\n") |
There was a problem hiding this comment.
Handle deleted chunks in pre-restore snapshots
If any chunk recorded in an older rollback artifact has since been deleted, current_values has no entry for that ID and this lookup raises KeyError. Because the pre-restore file has already been opened with "x", the failed rollback also leaves an empty or partial artifact that blocks retry, so later rollback of the remaining rows cannot proceed without manual cleanup; skip absent IDs or represent their absence explicitly.
AGENTS.md reference: AGENTS.md:L5-L8
Useful? React with 👍 / 👎.
|
VERDICT: ITERATE |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_c56bff01-49fd-4531-a378-51d94e69a48a) |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_4d748502-2014-4a2e-9860-6aa39a776b64) |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
@codex review CI compatibility follow-up: constrain MCP to the supported 1.x API range after MCP 2.0 removed Server.list_tools. |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_5db5e816-8ed7-4cde-a982-9766c34634e5) |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 17e293b630
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| is_t3_app_initiated_codex_session( | ||
| source_file, | ||
| state_db=t3_state_db, | ||
| linked_session_ids=t3_linked_session_ids, |
There was a problem hiding this comment.
Cache T3 linkage for the report scan
When a T3 state DB exists, scripts/provenance_classify_report.py:32-37 calls classify_provenance once for every chunk without supplying t3_linked_session_ids, so every Codex chunk reaching this branch reopens and rescans provider_session_runtime. Since a single session can contain hundreds of chunks, the canonical report now performs O(C×R) SQLite work and may classify one session inconsistently if T3 state changes mid-scan; load the linked IDs once in build_report and pass that set to each classification.
Useful? React with 👍 / 👎.

What broke and how it was found
T3-app-initiated Codex transcripts were indistinguishable from ordinary terminal Codex sessions: provenance_class LIKE %t3% returned 0. The explicit discriminator is provider_session_runtime.resume_cursor_json.threadId in the read-only T3 state DB.
Evidence
Review
This branch was pair-reviewed by a separate agent under the taste gate: smallest correct solution, behavioural tests, and no speculative machinery.
Provenance-column warning
chunks.provenance_class currently serves both as a trust ladder and a source class, with independent writers and no precedence rule. This PR is correct, but enrichment can overwrite its source tag until that collision is resolved. See design collision.
Enrichment and drain are currently disabled with launchctl to stop that decay; re-enable deliberately only after the column question is settled.
Note
Medium Risk
Changes provenance classification and can bulk-update
chunks.provenance_class; incorrect T3 linkage or retag misuse could mislabel searchable memory, though rollback and schema-drift alarms mitigate operational risk.Overview
Codex transcripts started from the T3 Code app are now labeled
t3-app-sessioninstead of genericcodex-session, using explicit linkage from the read-only T3 runtime DB (provider_session_runtime.resume_cursor_json.threadId).Ingest path: New
t3_provenancehelpers resolve linked session IDs;classify_provenancechecks T3 linkage before recon-agent and default Codex rules, and the realtime watcher loads linked IDs once per flush (viaBRAINLAYER_T3_STATE_DB). Missing T3 state is ignored; present DB with bad schema or invalid cursor JSON raises alarms rather than silently mis-tagging.Backfill:
scripts/retag_t3_app_provenance.pydry-runs or batch-updates existingcodex-sessionrows for linked sessions, with JSONL rollback/restore and optimisticWHERE provenance_class = ?guards.Other:
mcpis capped at<2; pytest autouse fixture pointsBRAINLAYER_T3_STATE_DBat a non-existent path so tests never hit a developer’s live T3 DB.Reviewed by Cursor Bugbot for commit 17e293b. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Tag Codex sessions initiated by the T3 app with a distinct 't3-app-session' provenance
t3_provenance.pywith utilities to extract Codex session IDs from filenames and query the T3 runtime SQLite state DB for linked session IDs.classify_provenanceinagent_provenance.pyto returnt3-app-session(withKEEPsearch policy) for Codex sessions linked by the T3 runtime, taking precedence over recon-agent signatures.watcher_bridge.pyto load T3-linked session IDs once per flush and pass them toclassify_provenance, avoiding repeated DB queries.retag_t3_app_provenance.py, a CLI script to retroactively re-tag existingcodex-sessionchunks tot3-app-sessionwith dry-run, rollback artifact, and batched conditional UPDATE support.Macroscope summarized 17e293b.