Skip to content

fix: record optional Codex profile metadata without changing delivery - #1549

Merged
fujibee merged 3 commits into
mainfrom
codex/main-codex-home-record
Oct 2, 2026
Merged

fujibee merged 3 commits into
mainfrom
codex/main-codex-home-record

Conversation

@fujibee

@fujibee fujibee commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

Extract only the optional Codex profile metadata from #1504 for the maintenance release. When the effective CODEX_HOME (or the default HOME/.codex) resolves to a physical absolute directory, record it as an optional codex_home field alongside the existing thread, type, project, and owner. Missing directories, control characters, relative paths, or failed resolution omit only this new field; they do not skip writing the existing session record.

Keep rollout discovery at HOME/.codex/sessions. Thread selection, app-server probing, bridge requests, and the existing best-effort record-writing behavior retain their main-branch behavior. The Codex template describes optional profile metadata without implying a routing change.

Evidence that existing features are unaffected

  1. This change records metadata only. rg -l 'codex_home' scripts reports exactly scripts/drivers/types/codex/codex-record-session.sh and scripts/lib/role-session.sh: the producer, its optional argument, and its conditional field write. There is no reader of the stored field in main's bridge, hook, watch, send, or receive paths. Existing CODEX_HOME environment handling elsewhere does not read this new record field.
  2. Unresolved profile paths become an empty optional value and execution continues through the original thread-discovery and record-writing paths. The record writer retains its existing best-effort behavior, including returning success when its directory or temporary file cannot be written; the caller's existing || true is unchanged. The existing unavailable-run-directory regression still passes. No new directory is created for a profile.
  3. All 35 existing Codex resume tests and all 22 existing role-session tests pass unchanged, alongside two added regressions. The new tests check selected/default profile recording and continued recording without a profile field for unresolved paths, including unchanged legacy rollout discovery. Existing thread ambiguity, reseating, fallback, bridge-seat probing, and record-write failure cases remain covered.

The spawn reader-inventory test explicitly allows CODEX_HOME because spawned Codex seats intentionally inherit the same profile. Spawn already preserved this variable; only the test inventory changes now that the recorder reads it.

Validation

  • bats tests/test_codex_resume.bats tests/test_role_session.bats: 59/59 PASS (35 existing resume + 2 new resume + 22 existing role-session checks).
  • Template wording follow-up: bats --filter "codex template:" tests/test_codex_resume.bats: 1/1 PASS.
  • Spawn shim reader-inventory regression: 1/1 PASS.
  • Shellcheck at warning severity with existing SC1091/SC2034 exclusions: PASS.
  • Enforced-assertion and guarded-environment checks: PASS without baseline changes.
  • git diff --check: PASS.

Validation uses the existing isolated test fixtures on macOS. No live service, message queue, or user profile settings were changed. The existing Bats minimum-version warning remains in an unchanged test.

Targets main from bb94ebe. Review should specifically assess whether existing features retain their behavior. Merge requires separate explicit approval.

@fujibee
fujibee merged commit ca70e42 into main Oct 2, 2026
27 checks passed
@fujibee fujibee mentioned this pull request Oct 2, 2026
2 tasks done
fujibee added a commit that referenced this pull request Oct 2, 2026
## Summary

Merge `main` (1.5.2) into `integration/agmsgd-beta`. Main now carries the optional Codex profile field in the seat record (#1549), which overlaps this branch's profile recording (#1504).

Conflict resolution:

- `scripts/drivers/types/codex/codex-record-session.sh`: one profile resolution instead of two. A missing, relative or malformed profile no longer skips the seat record (main's behavior): the record is written without the profile, and rollout discovery falls back to `$HOME/.codex` as before. A resolved profile is still used for rollout discovery and stored for delivery.
- `scripts/drivers/types/codex/template.md`: keep this branch's wording, since here the profile routes notices.
- `tests/test_spawn.bats`: take main's equivalent `CODEX_HOME` keep entry.

## Test plan

- [x] `bats tests/test_codex_resume.bats`: 37/37 locally, including main's "unresolved profile omits only the field" case and this branch's profile discovery cases.
- [x] `bats tests/test_role_session.bats` (22) and the spawn reader-inventory test pass locally.
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.

1 participant