fix(hooks): recover Codex env sessions#72
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR adds environment-based fallback recovery for agent-note recording when ChangesEnvironment Fallback Feature
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/cli/src/commands/record.ts`:
- Around line 82-83: The code currently calls recordCommitEntry({
agentnoteDirPath, sessionId }) as soon as freshness passes; change this to first
verify commit-linked AI file evidence for the session before recording fallback
env. Implement a guard in the same scope that inspects the session/metadata for
AI file evidence (e.g., presence of commit-linked aiFiles/transcript entries)
and only call recordCommitEntry when that evidence is present; if not present,
skip recording and log or return a clear failure. Apply the same evidence check
at the other fallback recording site referenced (the block around lines 119-130)
so both places require commit-linked AI file/transcript evidence before invoking
recordCommitEntry.
- Around line 113-117: The sanitizeSessionId function currently accepts broad
identifiers; change it to enforce UUID v4 for environment session IDs (e.g.,
CODEX_THREAD_ID) by replacing the current SESSION_ID_SEGMENT_RE check with a
UUID v4 validation (either use a standard UUID v4 regex or a validator utility)
inside sanitizeSessionId; keep the existing trim and "."/".." null checks, and
return null unless the value strictly matches UUID v4 format so only valid v4
UUIDs are accepted as session IDs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 167b5e94-b38c-445d-a25e-a598ad49d0a5
⛔ Files ignored due to path filters (1)
packages/cli/dist/cli.jsis excluded by!**/dist/**,!**/dist/**
📒 Files selected for processing (8)
AGENTS.mdCLAUDE.mddocs/architecture.mddocs/knowledge/investigations.mdpackages/cli/src/commands/commit.tspackages/cli/src/commands/init.test.tspackages/cli/src/commands/init.tspackages/cli/src/commands/record.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/cli/package.json`:
- Line 54: The package currently depends on "@types/node": "^25.7.0" which
mismatches the declared runtime floor (engines.node >=20); update the dependency
in packages/cli/package.json to a Node 20-aligned types major (pin `@types/node`
to the v20 major, e.g. ^20.x) OR alternatively add Node 20 to the CI test matrix
so typings are validated against the declared minimum; change the entry for
"@types/node" and/or update CI workflow matrix entries to include node: 20 and
run the TypeScript checks there to ensure compatibility with engines.node >=20.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: c11b1e0a-4aab-4e5f-89f7-c2d8a7de6089
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (1)
packages/cli/package.json
Why Codex shell-only or host-mediated commits could have a trusted current transcript but no exact per-prompt file touch evidence. v1 guarded stale sessions correctly, but became too strict and lost the v0.2-era value of marking AI-assisted commit files. User impact Trusted current Codex tool-backed work now produces file-level AI Ratio again while keeping files_touched exact-only. Stale prompt-only active-session pointers and true human-only commits remain skipped. Verification npm run build npm run typecheck npm run lint npm test npm run build --prefix website Focused Codex shell-only and mid-session regression tests 576-case Codex shell-only fallback simulation
Why Codex sessions hosted by cmux can expose a fresh CODEX_THREAD_ID while the repository-local prompt log is stale. Large long-lived transcripts also exceeded eager read limits, and git note write failures could look like successful recording. User impact Codex/cmux commits can recover Agent Note output from the current transcript without reviving stale prompt windows or future debug turns. Failed note writes now surface as warnings instead of silent missing PR data. Verification npm run build npm run typecheck npm run lint npm test npm run build --prefix website Focused Codex environment fallback regression tests Manual dist CLI --fallback-env recovery for this branch Release note: Fixes Codex environment fallback recording for cmux-hosted sessions, large transcripts, and silent git-note write failures.
There was a problem hiding this comment.
Actionable comments posted: 6
♻️ Duplicate comments (1)
packages/cli/src/commands/record.ts (1)
134-138:⚠️ Potential issue | 🟠 Major | ⚡ Quick winEnforce UUID v4 validation for environment session IDs
sanitizeSessionId()currently accepts any segment-safe token; this violates the session ID validation invariant and broadens the fallback trust boundary.Suggested fix
+const UUID_V4_RE = + /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i; + function sanitizeSessionId(value: string | undefined): string | null { const sessionId = value?.trim(); if (!sessionId || sessionId === "." || sessionId === "..") return null; - return SESSION_ID_SEGMENT_RE.test(sessionId) ? sessionId : null; + return UUID_V4_RE.test(sessionId) ? sessionId.toLowerCase() : null; }As per coding guidelines: “Validate input: Session IDs must match UUID v4 format”.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/cli/src/commands/record.ts` around lines 134 - 138, sanitizeSessionId currently accepts any segment-safe token and must be tightened to only accept UUID v4; update the function (sanitizeSessionId) so after trimming it validates the value against a UUID v4 pattern (or a shared UUID v4 validator) instead of using SESSION_ID_SEGMENT_RE, returning null for non-matching values; ensure existing callers that expect string|null behavior remain unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/architecture.md`:
- Around line 391-392: The post-commit hook's fallback-env path is broken
because the hook template checks [ -n "$${ENV_CODEX_THREAD_ID}" ] (using literal
ENV_CODEX_THREAD_ID and $$) instead of the actual environment variable, so the
condition never becomes true; fix either the template substitution in init.ts so
ENV_CODEX_THREAD_ID is replaced with CODEX_THREAD_ID at render time, or change
the hook to check the real variable name (e.g., [ -n "$CODEX_THREAD_ID" ])
before setting SESSION_ID="--fallback-env" and calling agent-note record
--fallback-env; update the place that generates the script (init.ts and the
post-commit hook template) consistently so the symbol ENV_CODEX_THREAD_ID is not
left literal in the shipped hook.
In `@packages/cli/src/core/storage.test.ts`:
- Around line 87-90: The test for writeNote is matching locale/version-specific
git stderr text which makes CI flaky; update the assertion to only verify the
promise rejects (or rejects with an Error) instead of matching git output.
Locate the test using writeNote and replace the assert.rejects call that
supplies the regex (/failed to resolve|failed to write Agent Note git
note|ambiguous argument/i) with a simpler assertion such as assert.rejects(() =>
writeNote("not-a-commit", { v: 1 })) or assert.rejects(() =>
writeNote("not-a-commit", { v: 1 }), Error) so the test no longer depends on git
wording.
In `@website/src/content/docs/de/data-and-privacy.mdx`:
- Line 58: Replace the fragment on Line 58 ("Shell command output als file
evidence. Vertrauenswürdige Agent transcripts können trotzdem commit-level
attribution erzeugen.") with an explicit non-storage statement clarifying that
shell command output is not stored; e.g., reword to say that shell command
output is used as file evidence but wird nicht gespeichert / is not retained,
and keep the follow-up clause about trusted agent transcripts potentially
enabling commit-level attribution (so update the sentence containing that phrase
to read clearly and unambiguously that the data is not stored).
In `@website/src/content/docs/es/data-and-privacy.mdx`:
- Line 58: The sentence "Output de shell commands como file evidence. Los Agent
transcripts confiables aún pueden producir commit-level attribution." is
ambiguous; update it to explicitly state that shell command output is not stored
as file evidence by negating the claim and clarifying attribution limits (e.g.,
replace that fragment with a clear sentence such as "Shell command output is not
stored as file evidence; trusted Agent transcripts may still produce
commit-level attribution."). Ensure the revised line preserves the distinction
between "shell command output" and "Agent transcripts" and matches surrounding
locale and tone.
In `@website/src/content/docs/fr/data-and-privacy.mdx`:
- Line 58: Replace the fragment "Les outputs de shell commands comme file
evidence. Des Agent transcripts fiables peuvent quand même produire une
commit-level attribution." with an explicit French sentence stating that shell
command outputs are not stored as file evidence (e.g., "Les sorties des
commandes shell ne sont pas stockées comme pièces justificatives de fichier")
and then append the clarification that reliable agent transcripts can still
enable commit-level attribution; ensure the phrasing is natural French, matches
locale/tone of surrounding docs, and clearly separates user-facing privacy
guidance from maintainer details.
In `@website/src/content/docs/pt-br/data-and-privacy.mdx`:
- Line 58: Replace the fragment "Output de shell commands como file evidence."
with an explicit non-storage statement that makes clear these outputs are not
retained — e.g., change it to "Output de shell commands como file evidence não
são armazenados." Ensure the updated sentence appears in the pt-BR privacy
bullet and preserves locale/tense consistency with surrounding text.
---
Duplicate comments:
In `@packages/cli/src/commands/record.ts`:
- Around line 134-138: sanitizeSessionId currently accepts any segment-safe
token and must be tightened to only accept UUID v4; update the function
(sanitizeSessionId) so after trimming it validates the value against a UUID v4
pattern (or a shared UUID v4 validator) instead of using SESSION_ID_SEGMENT_RE,
returning null for non-matching values; ensure existing callers that expect
string|null behavior remain unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: b2515b78-00f6-4127-8ecb-65d4edbc4091
⛔ Files ignored due to path filters (1)
packages/cli/dist/cli.jsis excluded by!**/dist/**,!**/dist/**
📒 Files selected for processing (41)
AGENTS.mdCLAUDE.mddocs/architecture.mddocs/knowledge/agent-skill.mddocs/knowledge/agent-support-policy.mddocs/knowledge/investigations.mdpackages/cli/src/agents/codex.tspackages/cli/src/commands/codex.test.tspackages/cli/src/commands/init.test.tspackages/cli/src/commands/record.tspackages/cli/src/core/record.test.tspackages/cli/src/core/record.tspackages/cli/src/core/storage.test.tspackages/cli/src/core/storage.tspackages/cli/src/git.tswebsite/src/content/docs/agent-support.mdxwebsite/src/content/docs/data-and-privacy.mdxwebsite/src/content/docs/de/data-and-privacy.mdxwebsite/src/content/docs/de/how-it-works.mdxwebsite/src/content/docs/es/data-and-privacy.mdxwebsite/src/content/docs/es/how-it-works.mdxwebsite/src/content/docs/fr/data-and-privacy.mdxwebsite/src/content/docs/fr/how-it-works.mdxwebsite/src/content/docs/how-it-works.mdxwebsite/src/content/docs/id/data-and-privacy.mdxwebsite/src/content/docs/id/how-it-works.mdxwebsite/src/content/docs/it/data-and-privacy.mdxwebsite/src/content/docs/it/how-it-works.mdxwebsite/src/content/docs/ja/agent-support.mdxwebsite/src/content/docs/ja/data-and-privacy.mdxwebsite/src/content/docs/ja/how-it-works.mdxwebsite/src/content/docs/ko/data-and-privacy.mdxwebsite/src/content/docs/ko/how-it-works.mdxwebsite/src/content/docs/pt-br/data-and-privacy.mdxwebsite/src/content/docs/pt-br/how-it-works.mdxwebsite/src/content/docs/ru/data-and-privacy.mdxwebsite/src/content/docs/ru/how-it-works.mdxwebsite/src/content/docs/zh-cn/data-and-privacy.mdxwebsite/src/content/docs/zh-cn/how-it-works.mdxwebsite/src/content/docs/zh-tw/data-and-privacy.mdxwebsite/src/content/docs/zh-tw/how-it-works.mdx
There was a problem hiding this comment.
Actionable comments posted: 7
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/cli/src/agents/codex.ts (1)
167-170:⚠️ Potential issue | 🟠 Major | ⚡ Quick winSuggested fix introduces UTF-8 decoding errors; issue scope is limited by 256-file bound.
readTranscriptSessionId()does load entire files into memory before slicing, but the discovery is already bounded to 256 files maximum in a breadth-first scan. The real risk is if a single transcript file is extremely large (>100s MB).However, the suggested fix is incorrect:
readSync(fd, buf, 0, TRANSCRIPT_PREVIEW_CHARS, 0)reads exactly 4096 bytes, not characters. Decoding this withtoString("utf-8")will fail if a multi-byte UTF-8 character (e.g., "世" = 3 bytes) is split across the buffer boundary, causingUnicodeDecodeError.A safer approach would read more bytes than needed (e.g., 8KB) to ensure partial characters don't truncate critical metadata, or use a streaming line-by-line parser to avoid loading anything beyond the first complete line containing
session_meta. The current pattern works in practice for JSONL transcripts since metadata appears near the start, but the memory principle is worth addressing.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/cli/src/agents/codex.ts` around lines 167 - 170, The suggested change to use readSync into a byte buffer causes UTF-8 decoding errors when multi-byte characters are split; update readTranscriptSessionId to read a safe byte window instead of exactly TRANSCRIPT_PREVIEW_CHARS bytes: compute a byteLimit = max(8192, TRANSCRIPT_PREVIEW_CHARS * 4) (or similar) and read that many bytes from the file descriptor, then decode the buffer with utf-8 and slice by characters for preview; alternatively implement a lightweight streaming line-by-line read that stops after the first line containing "session_meta" to avoid loading large files — locate and modify readTranscriptSessionId, the TRANSCRIPT_PREVIEW_CHARS usage, and any temporary readSync/readFileSync logic accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/architecture.md`:
- Around line 391-392: Update the `pre-push` row to reflect that note pushing is
synchronous: change the description that currently says "Auto-pushes
`refs/notes/agentnote` to the actual remote (`$1`) in background" to indicate
the hook waits for the `push-notes` operation to complete (no backgrounding),
while retaining mention of the recursion guard via the `AGENTNOTE_PUSHING` env
var and that it targets `refs/notes/agentnote`; ensure the wording matches the
implemented `push-notes` behavior and remove any reference to background
execution.
In `@packages/cli/src/commands/init.test.ts`:
- Around line 31-35: Tests currently inherit process.env causing flakiness when
CODEX_THREAD_ID is present; update the test suite to use a sanitized environment
by default by calling or applying withoutCodexThreadEnv() as the default env
wrapper for the suite (e.g., use it in beforeEach or pass it into helper
invocations like runCli/init calls), and change only the env-fallback-specific
tests to explicitly set CODEX_THREAD_ID (opt-in) instead of relying on the real
process.env; locate usages around withoutCodexThreadEnv and the init tests (and
the region referenced 467-899) and replace direct process.env usage with the
sanitized env or pass sanitized env through helper functions that spawn the CLI.
In `@packages/cli/src/core/record.ts`:
- Around line 516-525: The fallback branch is using allInteractions directly
which can pick old mutating shell rows; before calling
selectTranscriptFallbackInteractions, filter allInteractions through
selectEnvironmentTranscriptSourceInteractions using parentCommitTimestampMs to
limit the source window to parent→HEAD. Replace the
selectTranscriptFallbackInteractions call to use the filtered list (e.g. let
envSource = selectEnvironmentTranscriptSourceInteractions(allInteractions,
parentCommitTimestampMs); then call
selectTranscriptFallbackInteractions(envSource, commitFileSet,
currentUnattributedToolPromptIds, { requireMutationTool:
opts.allowEnvironmentTranscriptFallback === true })). Ensure you preserve the
same requireMutationTool flag and assign the result back to interactions.
In `@website/src/content/docs/fr/data-and-privacy.mdx`:
- Line 58: Reformulez la phrase identifiée ("Les outputs de shell commands ne
sont pas stockés comme file evidence. Des Agent transcripts fiables peuvent
quand même produire une commit-level attribution.") en français naturel tout en
conservant le sens : indiquez clairement que les sorties de commandes shell ne
sont pas conservées comme preuves de fichier, mais que des transcriptions
d'agent fiables peuvent néanmoins permettre une attribution au niveau des
commits; remplacez le texte par une version fluide (par ex. « Les sorties des
commandes shell ne sont pas conservées comme preuves de fichier, mais des
transcriptions d'agent fiables peuvent toutefois permettre une attribution au
niveau des commits. »), assurez la cohérence de ton et de vocabulaire avec le
reste de la documentation FR et gardez la séparation nette entre conseils
destinés aux utilisateurs et éventuelles notes techniques destinées aux
mainteneurs.
In `@website/src/content/docs/id/data-and-privacy.mdx`:
- Around line 57-58: Merge the two redundant bullets about shell command output
in the "Yang tidak disimpan" list into a single, clear bullet that preserves the
clarification about commit-level attribution; update the bullet that currently
says "Semua output shell command." and the subsequent bullet mentioning that
shell output is not stored but trusted agent transcripts can produce
commit-level attribution by combining them into one sentence or a main bullet
with a short sub-note so the list is concise and the attribution caveat remains
visible.
In `@website/src/content/docs/it/data-and-privacy.mdx`:
- Around line 57-58: The two consecutive bullets that both mention shell command
output are redundant; update the bullet list in data-and-privacy.mdx by either
merging the two lines into one clear bullet that states "Shell command outputs
are not saved as evidence files, but reliable agent transcripts can still
provide commit-level attribution" or make the second line a sub-bullet/note
under the first to clarify it is an elaboration; locate the existing bullet
texts ("Tutti gli output dei shell command." and "Output dei shell command non
viene salvato come file evidence. Agent transcripts affidabili possono comunque
produrre commit-level attribution.") and apply the chosen merge or hierarchy
change.
In `@website/src/content/docs/pt-br/data-and-privacy.mdx`:
- Around line 57-58: Remove the redundant bullet "Todos os outputs de shell
command." and keep the more detailed bullet that starts "Output de shell
commands não é salvo como file evidence. Agent transcripts..." (or merge them
into a single concise bullet that states outputs of shell commands are not saved
and clarifies they are not stored as file evidence but may still produce
commit-level attribution); update the remaining bullet to be a single clear
Portuguese sentence without repeating the "not saved" message.
---
Outside diff comments:
In `@packages/cli/src/agents/codex.ts`:
- Around line 167-170: The suggested change to use readSync into a byte buffer
causes UTF-8 decoding errors when multi-byte characters are split; update
readTranscriptSessionId to read a safe byte window instead of exactly
TRANSCRIPT_PREVIEW_CHARS bytes: compute a byteLimit = max(8192,
TRANSCRIPT_PREVIEW_CHARS * 4) (or similar) and read that many bytes from the
file descriptor, then decode the buffer with utf-8 and slice by characters for
preview; alternatively implement a lightweight streaming line-by-line read that
stops after the first line containing "session_meta" to avoid loading large
files — locate and modify readTranscriptSessionId, the TRANSCRIPT_PREVIEW_CHARS
usage, and any temporary readSync/readFileSync logic accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: f48a6ad4-4455-452c-beae-aeab30055794
⛔ Files ignored due to path filters (2)
package-lock.jsonis excluded by!**/package-lock.jsonpackages/cli/dist/cli.jsis excluded by!**/dist/**,!**/dist/**
📒 Files selected for processing (20)
AGENTS.mdCLAUDE.mddocs/architecture.mddocs/knowledge/investigations.mdpackages/cli/package.jsonpackages/cli/src/agents/codex.test.tspackages/cli/src/agents/codex.tspackages/cli/src/agents/types.tspackages/cli/src/commands/init.test.tspackages/cli/src/commands/init.tspackages/cli/src/commands/record.tspackages/cli/src/core/record.tspackages/cli/src/core/storage.test.tswebsite/src/content/docs/de/data-and-privacy.mdxwebsite/src/content/docs/es/data-and-privacy.mdxwebsite/src/content/docs/fr/data-and-privacy.mdxwebsite/src/content/docs/id/data-and-privacy.mdxwebsite/src/content/docs/it/data-and-privacy.mdxwebsite/src/content/docs/pt-br/data-and-privacy.mdxwebsite/src/content/docs/ru/data-and-privacy.mdx
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (1)
website/src/content/docs/fr/data-and-privacy.mdx (1)
57-57:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winLisser la phrase FR pour éviter le franglais en prose
La formulation de la Line 57 est exacte sur le fond, mais reste hybride FR/EN et moins naturelle pour la documentation utilisateur.
✏️ Proposition
-- Les sorties des commandes shell ne sont pas stockées comme file evidence. Des Agent transcripts fiables peuvent quand même produire une commit-level attribution. +- Les sorties des commandes shell ne sont pas conservées comme preuves de fichier. Des transcriptions d’agent fiables peuvent toutefois permettre une attribution au niveau du commit.As per coding guidelines
website/**: Review documentation for implementation accuracy, natural language, locale parity, and clear separation between user-facing guidance and maintainer details.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@website/src/content/docs/fr/data-and-privacy.mdx` at line 57, La phrase "Les sorties des commandes shell ne sont pas stockées comme file evidence. Des Agent transcripts fiables peuvent quand même produire une commit-level attribution." mélange anglais et français ; remplace-la par une formulation entièrement en français et naturelle (par ex. : « Les sorties des commandes shell ne sont pas conservées comme éléments de preuve ; des transcriptions d'agents fiables peuvent toutefois permettre une attribution au niveau des commits. »). Modifie le texte correspondant dans le document (la phrase actuelle) en remplaçant l'anglais par la version française proposée ou une variante équivalente, en conservant le sens technique (shell outputs, agent transcripts, commit-level attribution).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/cli/src/core/record.ts`:
- Around line 814-820: selectEnvironmentTranscriptSourceInteractions currently
falls back to returning all interactions when
filterTranscriptInteractionsAfterParent yields an empty bounded set; change it
so it never expands scope — return the bounded array as-is (even if empty) to
ensure evidence is strictly limited to the parent-window filter. Update the
function selectEnvironmentTranscriptSourceInteractions to remove the fallback to
interactions and always return the result of
filterTranscriptInteractionsAfterParent, preserving attribution correctness.
In `@website/src/content/docs/data-and-privacy.mdx`:
- Line 69: Split the mixed sentence in the "What Is Not Stored" bullet so it
only states the negative fact that shell command output is not stored (e.g.,
keep "It does not store shell command output as file evidence"), then add a
separate explanatory Aside after the list clarifying transcript-based
attribution (use an <Aside> with text like the suggested refactor: explain that
trusted agent transcripts (e.g., Codex) may still enable commit-level
attribution by validating fresh transcript evidence recorded at commit time,
without relying on shell command output); update the "What Is Not Stored" bullet
and add the <Aside> element accordingly to preserve the section pattern and
avoid mixing negatives with capability notes.
---
Duplicate comments:
In `@website/src/content/docs/fr/data-and-privacy.mdx`:
- Line 57: La phrase "Les sorties des commandes shell ne sont pas stockées comme
file evidence. Des Agent transcripts fiables peuvent quand même produire une
commit-level attribution." mélange anglais et français ; remplace-la par une
formulation entièrement en français et naturelle (par ex. : « Les sorties des
commandes shell ne sont pas conservées comme éléments de preuve ; des
transcriptions d'agents fiables peuvent toutefois permettre une attribution au
niveau des commits. »). Modifie le texte correspondant dans le document (la
phrase actuelle) en remplaçant l'anglais par la version française proposée ou
une variante équivalente, en conservant le sens technique (shell outputs, agent
transcripts, commit-level attribution).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 5650e744-a255-4cd0-b83e-3e4b5b625553
⛔ Files ignored due to path filters (1)
packages/cli/dist/cli.jsis excluded by!**/dist/**,!**/dist/**
📒 Files selected for processing (15)
docs/architecture.mdpackages/cli/src/commands/init.test.tspackages/cli/src/core/record.tswebsite/src/content/docs/data-and-privacy.mdxwebsite/src/content/docs/de/data-and-privacy.mdxwebsite/src/content/docs/es/data-and-privacy.mdxwebsite/src/content/docs/fr/data-and-privacy.mdxwebsite/src/content/docs/id/data-and-privacy.mdxwebsite/src/content/docs/it/data-and-privacy.mdxwebsite/src/content/docs/ja/data-and-privacy.mdxwebsite/src/content/docs/ko/data-and-privacy.mdxwebsite/src/content/docs/pt-br/data-and-privacy.mdxwebsite/src/content/docs/ru/data-and-privacy.mdxwebsite/src/content/docs/zh-cn/data-and-privacy.mdxwebsite/src/content/docs/zh-tw/data-and-privacy.mdx
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@website/src/content/docs/pt-br/data-and-privacy.mdx`:
- Around line 60-62: Replace the current Portuguese Aside text with a more
natural PT-BR sentence that keeps canonically technical terms in crases;
specifically update the <Aside> content so non-technical words are translated to
natural Portuguese while preserving terms like `Agents`, `transcripts`, `Agent
Note`, `commit-level attribution`, `transcript evidence` and `shell command` in
backticks, and rephrase to something concise and idiomatic (e.g., "Com `Agents`
que expõem `transcripts` confiáveis, o `Agent Note` ainda pode gerar
`commit-level attribution` a partir de `transcript evidence` recentes
registradas no momento do commit, sem salvar o output de `shell command`.").
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: d1088928-6486-4e2f-8f0a-52313195cdfb
📒 Files selected for processing (12)
website/src/content/docs/data-and-privacy.mdxwebsite/src/content/docs/de/data-and-privacy.mdxwebsite/src/content/docs/es/data-and-privacy.mdxwebsite/src/content/docs/fr/data-and-privacy.mdxwebsite/src/content/docs/id/data-and-privacy.mdxwebsite/src/content/docs/it/data-and-privacy.mdxwebsite/src/content/docs/ja/data-and-privacy.mdxwebsite/src/content/docs/ko/data-and-privacy.mdxwebsite/src/content/docs/pt-br/data-and-privacy.mdxwebsite/src/content/docs/ru/data-and-privacy.mdxwebsite/src/content/docs/zh-cn/data-and-privacy.mdxwebsite/src/content/docs/zh-tw/data-and-privacy.mdx
Pull Request
Summary
Recover Agent Note recording for Codex sessions running inside agent-hosted terminals such as cmux, while keeping the stricter v1 stale-session safeguards.
This PR fixes the path where
CODEX_THREAD_IDis available but.git/agentnote/sessionis stale, missing, or points at a repo-local prompt-only session. The environment fallback now resolves the Codex transcript directly, streams large transcript files, selects only transcript rows that existed by the HEAD commit time, and ignores stale local prompt logs that would otherwise block the fresh transcript.It also restores v0.2-style commit-level attribution for trusted Codex transcript edits: exact
files_touchedstill requires exact transcript/file evidence, butfilesand AI Ratio can recover from the verified Codex transcript when the commit was made from the current Codex environment.What Was Broken
CODEX_THREAD_IDeven when Agent Note's repo-local active-session pointer is stale.git notes addfailures could be swallowed, making a record attempt look successful while the PR Report still showed—.Fixes
CODEX_THREAD_IDonly for the environment fallback path, not the stale active-session pointer.files_touchedexact-only while allowing broader verified commit-level attribution for AI Ratio.Type of Change
Checklist
Verification
npm run buildnpm run typechecknpm run lintnpm test -- --test-name-pattern "environment fallback|shell-only Codex|transcript-driven Codex gives|mid-session Codex|stale local prompts|gitSafe|writeNote"npm test(451 passed)npm run build --prefix websitegit diff --checkagent-note showNotes for Reviewers
The fallback remains intentionally conservative. Plain git hooks still do not trust prompt-only active sessions. The broader recovery only applies when the current process exposes a valid Codex environment session and the transcript evidence is bounded to the commit being recorded.
🧑💬🤖 Agent Note
Total AI Ratio: ████████ 100%
Model:
gpt-5.46efa40cfix(hooks): recover Codex env sessions8a61c4achore(cli): update development dependencies3b7d244fix(record): restore Codex commit-level attribution0342220fix(record): harden Codex env transcript fallback53261ddfix(record): address fallback review findings3c7be03fix(record): bound env fallback transcript windowc23bddafix(record): tighten env fallback attribution2baa245docs(record): clarify env fallback bounds008d08efix(record): harden env fallback review cases675213cdocs(website): clarify transcript attribution privacy6af2d1adocs(website): polish pt-br privacy wording💬 Prompts & Responses (12 total)
3b7d244fix(record): restore Codex commit-level attribution0342220fix(record): harden Codex env transcript fallback53261ddfix(record): address fallback review findings3c7be03fix(record): bound env fallback transcript windowc23bddafix(record): tighten env fallback attribution2baa245docs(record): clarify env fallback bounds008d08efix(record): harden env fallback review cases675213cdocs(website): clarify transcript attribution privacy6af2d1adocs(website): polish pt-br privacy wordingSummary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests
Chores