Skip to content

fix(server): keep Codex shadow memories private - #147

Merged
chrisohearn merged 6 commits into
integration/mcp-events-20261109from
sync/upstream-20261119-memories-v2
Nov 19, 2026
Merged

chrisohearn merged 6 commits into
integration/mcp-events-20261109from
sync/upstream-20261119-memories-v2

Conversation

@chrisohearn

@chrisohearn chrisohearn commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Codex CLI 0.170 creates memories_v2 in the shared home while each shadow may retain its own real directory. Older setup treated a real shadow directory as a conflict and left legacy links to shared memories in place.

This change:

  • treats memories_v2 as shadow-local, preserving shared contents and real per-instance memory;
  • removes only legacy links to the shared target, after conflict checks pass;
  • keeps startup and crash-loop rollback on a trusted build that can open the database, preferring builds with a positive shadow preflight and never downgrading to an unknown legacy report;
  • clears caller-only CODEX_HOME and CODEX_SQLITE_HOME from release preflight so an agent shell cannot redirect the check.

Release note:
Codex memories now stay private to each shadow home. Older releases may refuse to start that Codex instance after local memories_v2 has been created; upgrade to this release to restore the instance. Shared memories are preserved.

Closes #146

Validation:

  • bash scripts/fork/host/t3-update-guard/test-guard.sh — passed, including launch, rollback, legacy-preflight, and shadow-only snapshot cases.
  • pnpm exec vp test run apps/server/src/provider/Drivers/CodexHomeLayout.test.ts apps/server/src/cloud/codexShadowPreflight.test.ts — 32/32 passed.
  • pnpm exec vp run check:changed origin/integration/mcp-events-20261109 — all stages passed (format, lint, knip, GraphQL, typecheck, 34 tests across 3 files).
  • scripts/fork/test-upstream-stable-tag.sh — passed.
  • No upstream migration files or ids changed.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-19T18:47:24.916750Z
We couldn’t complete this review. Comment @codex review to try again.
7b44017 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chrisohearn chrisohearn left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Independent review of record (fallback for the hosted Codex review, which failed on a usage limit)

Scope. I reviewed head e2b59e5e414bf0b1b3b6c877525474d5226eff9d against base 7ab03827a574f7fe767f8a91afa54a5e2b20f60a. I fetched refs/pull/147/head and integration/mcp-events-20261109 into an isolated clone, confirmed both SHAs, and confirmed the merge base is the base commit. I read the full diff (11 files, +766/−39), FORK.md at the head, and the surrounding code in CodexHomeLayout.ts, codexShadowPreflight.ts, CodexDriver.ts and the update guard.

Verification.

  • CI: every check on this head passed: Build and Typecheck, Lint, Test, Test Server 1–8, Release Smoke, Update guard tests, Upstream stable tag tests and Agent context budget. Mobile, Web and Rust were skipped.
  • Local runs: test-guard.sh and test-upstream-stable-tag.sh both passed (rc=0).

Verdict: no blocking findings.

Findings

P2 (nonblocking): a shadow redirect during an update leaves the outage clock open

  • Where: scripts/fork/host/t3-update-guard/guard:1120 (outage_begin "update $cur -> $latest") and the redirect branch at guard:1189-1195.
  • What happens: when launch sends the update to a known-ready build, cmd_update writes the rejected marker, calls report and returns 1, but never calls outage_end. The fallback build's prove can't close the outage either: it runs about 75 s after the start, while cmd_update still holds $LOCK, so it takes the early-return branch at guard:550 before it reaches outage_end. No later prove runs, because the guard doesn't restart the fallback.
  • Impact: outage-since stays on disk while the fallback is serving normally. Because the redirect's report touches outage-reported, the next prove can report an inflated recovery duration and attribute unrelated fatal breadcrumbs to this stale outage.
  • Fix: call outage_end "$selected" before notify/report in the redirect branch. Extend the redirect test to keep the real outage functions and assert that $OUTAGE is gone after cmd_update returns.

P3 (nonblocking nit): the release-note banner never retires

  • Where: scripts/fork/publish-release.sh:13-15.
  • What happens: the “Codex shadow compatibility” paragraph is added to every future release's notes unless the caller's notes already contain it. It stays relevant only while a downgrade to a pre-#147 build is plausible.
  • Fix: gate it so it appears only in the first release containing this change, or record in FORK.md when to remove it.

Focus areas checked, no issues

  • Migration namespace: the database check is unchanged in substance. It moved into preflight_allows_database, and the launcher-protocol exemption is kept.
  • Shadow-home setup and refusal order: the refusal now happens before unlinking or moving anything. Moving removePrivateSymlink after the refusal is safe because the inspect step skips private entry names, so no refusal depended on those links being gone first.
    • Adding memories_v2 to the shadow-local entry names stops new builds from linking it.
    • removeSharedMemoriesV2Link removes the link only when it resolves to the shared memories_v2 (directly or by real path). It never touches the shared target or a real local directory.
    • When the shadow directory isn't writable, the link is correctly reported as not settleable. Tests cover keeping local data, unlinking with shared content intact, and refusing without touching anything.
  • Database incompatibility vs shadow readiness: can_start returns 0 (ready), 1 (positive conflict), 2 (database incompatible) or 3 (unknown), and the guard keeps these apart. A shadow-only failure never restores the pre-update snapshot. Unknown preflight keeps the active build that can open the database and never downgrades on that basis.
  • Launch and rollback availability: every launch path still ends in exec. Rollback prefers a healthy build reported ready, then falls back to any build that can open the database, so service stays up. Older builds without a shadow report are never preferred over the active build.
  • Update after a launch redirect: the redirect requires the selected build to be serving the port, up at least 60 s, trusted and healthy, able to open the database, and the new release still to report a positive conflict. It marks the release rejected on this host only and returns without stopping or restarting the fallback.
  • Preflight CODEX_HOME: !config.homePath?.trim() && environment.CODEX_HOME now matches the runtime's home-path selection. This fixes the mismatch when a shadow home was set but homePath was absent.
  • Release gate and upstream sync: env -u CODEX_HOME -u CODEX_SQLITE_HOME prevents a caller's shell from steering __service-preflight, while per-instance settings still apply. The gate still requires codexShadowHomes == ready, and an auto-settle instance rolls up to ready. Stable-tag-only targeting is unchanged, and its suite passes.
  • Documentation: FORK.md and the guard README match the behavior, including the documented trade-off that an older build may refuse a Codex instance once it has local memories_v2 data.

Close the update outage clock when a shadow conflict redirects to the known-serving fallback, and cover the real recovery path in the guard test. Retire the compatibility note after the first release containing its marker.

GPT-6 Luna in T3 Code (Codex harness).

@chrisohearn chrisohearn left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Independent review of record (fallback for the hosted Codex review, which failed on a usage limit)

Scope. Reviewed PR #147 at head f8ea21009dc5247c6dd05bca4e02e41d4310d2f3 against base 7ab03827a574f7fe767f8a91afa54a5e2b20f60a (integration/mcp-events-20261109). The reviewer confirmed the merge base equals the base and examined the full PR diff and FORK.md.

Provenance. The review ran as Claude Opus 5.5. The delegated request specified high effort and the T3 dispatch returned effort=high; the reviewer reports its native session header showed a numeric setting of 15 and could not independently confirm that label mapping. This review is posted with that limitation disclosed.

Verification.

  • All 20 checks passed on this head: Build and Typecheck, Lint, Test, Test Server 1–8, Release Smoke, Fork host update guard, Upstream stable tag tests, and Agent Context Budget. Mobile, Web and Rust were skipped.
  • Reviewer ran test-guard.sh and test-upstream-stable-tag.sh from an exported copy of the head; both passed.
  • The regression checks fail if either repair is removed.

Verdict: no blocking findings.

Previous findings resolved

  • P2, outage clock after shadow redirect: guard:1193 now calls outage_end "$selected" before notification/reporting. The redirect test runs the real outage/report functions and asserts the outage file and report marker are cleared and recovery is logged on the fallback.
  • P3, compatibility note repeated in later releases: publish-release.sh checks the publisher marker on the previous preview tag. The fixture proves the first release includes the note and a later release retires it.

Nonblocking follow-ups

  • The redirect recovery duration includes the candidate health-wait interval, even though the fallback was already serving. Filed as #148.
  • The v*-preview.* tag glob can include upstream preview tags; if one later sorts above the newest fork preview, the compatibility note could return. Filed as #149.

A separate canary-failure branch at guard:1206 was present in the base and is outside this PR.

@chrisohearn
chrisohearn merged commit 2b0622c into integration/mcp-events-20261109 Nov 19, 2026
20 checks passed
@chrisohearn
chrisohearn deleted the sync/upstream-20261119-memories-v2 branch November 19, 2026 22:18
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