Skip to content

Hashless Codex journal can overwrite later settings and become trusted on reinjection #4005

Description

@luvs01

Client or integration

Other

Area

Other

Summary

A Codex journal without recorded injected-state hashes can overwrite later native configuration edits or delete a later profile. restoreJournalState() currently treats a missing hash as evidence that the current artifact is unchanged, then restores the saved original. This state can be produced by a legacy record or an interruption between writeJournal() and markJournalInjectedState().

There is a second path: reinjection over a routed, hashless journal keeps its older original but assigns the new injected configuration's hash to it. A later restore can then accept that old original as if the new configuration belonged to the old snapshot. Native-restore and reconcile callers also need to distinguish an unverified snapshot from a verified partial restore.

Refs #2948. This is a reproducible narrower defect in the current source; it does not establish the cause of that historical machine's shutdowns or justify treating every restore log line as a configuration overwrite.

Reproduction

Use an isolated Codex home with the current dev source:

  1. Write a native config.toml, call writeJournal(), and do not call markJournalInjectedState().
  2. Change the config to another native configuration, adding a different user-selected model. Calling restoreJournalState() overwrites those new bytes with the old original and reports completion.
  3. In a separate case, create a profile after the snapshot. Restoration deletes that new profile because the snapshot recorded no original profile and no injected profile hash.
  4. For the reinjection case, place recognizable routed configuration plus new user settings over the same hashless snapshot. Current preflight accepts it and injection can fill the missing hash while retaining the older original.

The prepared regressions use temporary config/profile files and mock/local execution only. The proposed policy keeps a changed file and the journal when that file lacks its own injection hash, accepts already-original files without rewriting them, and permits a genuinely native configuration to establish a new snapshot. Routed reinjection must verify the retained snapshot before writing.

Version

402be7c; Bun 1.4.0 (34cbb9a40)

Operating system

Microsoft Windows 11 Pro, version 10.0.26200 (build 26200)

Provider and model

Not provider-specific. No live account, provider request, or reset credit is used.

Logs or error output

hashless interrupted snapshot preserves later native config edits:
  expected current user settings; received the earlier original config
hashless interrupted snapshot preserves a later profile:
  expected the current profile; received null
hashless native restore refuses instead of reporting an uncertain snapshot as restored:
  expected success=false; received true
hashless routed snapshot is not promoted by reinjection after user edits:
  expected preflight.success=false; received true

Six regressions failed against unchanged base source, including redundant rewriting and loss of an empty original profile's presence. The proposed correction preserves empty files separately from absent files.

Screenshots and supporting files

A focused source/test/documentation pull request will link this issue. This is a filesystem-state defect; no screenshot is needed to reproduce it.

Redacted configuration

model_provider = "openai"
model = "user-selected-model"

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglanded-via-maintainerOriginal PR closed after landing via a maintainer merge train

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions