Skip to content

[WRONG BRANCH] fix(prompt): preserve external TOML escaped paths - #396

Draft
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-toml-escape-handling-in-reader
Draft

[WRONG BRANCH] fix(prompt): preserve external TOML escaped paths#396
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-toml-escape-handling-in-reader

Conversation

@luvs01

@luvs01 luvs01 commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Motivation

  • A recent change made readModelInstructionsFile pass literals through a narrow decoder (decodeBasicString) which returns null for valid TOML escapes, causing present model_instructions_file keys to be treated as absent/default.
  • That misclassification allowed GUI-authorized writes to remove or replace an externally authored prompt setting instead of refusing the overwrite.
  • The goal is to preserve the original fail-closed protection for externally authored TOML basic-strings while keeping the existing narrow decoder as a fallback for malformed documents.

Description

  • Prefer the TOML-backed reader by calling rootValue(configBytes, "model_instructions_file") and return the parsed string when present, making standard TOML escapes (e.g. \uXXXX) survive decoding. (src/codex/prompt-layers.ts)
  • Keep the line-scanning fallback for documents the parser cannot parse, but return decodeBasicString(m[1]!) ?? m[1]! so that if the restricted decoder refuses an escape we preserve the literal rather than treating it as absent. (src/codex/prompt-layers.ts)
  • Treat a present-but-unreadable or non-string model_instructions_file as an unreadable external value (fail-closed) instead of returning null. (src/codex/prompt-layers.ts)
  • Add a regression test that supplies a Unicode-escaped TOML basic-string ("\u002Fetc\u002F...") and asserts it is classified as external, cannot be silently overwritten by selecting default, and that the file remains byte-identical. (tests/codex-prompt-base-variants.test.ts)

Testing

  • bun test tests/codex-prompt-base-variants.test.ts was run and all 15 tests passed.
  • bun run typecheck was run and succeeded.
  • bun run privacy:scan was run and succeeded.
  • A full bun run test was started as the review-ready gate but encountered existing, unrelated timeouts and HTTP-status expectation failures in other suites; these failures are pre-existing and not introduced by this focused change.

Codex Task

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-31T01:05:52.182481Z 3e28773 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.

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6f1438fa-a34c-49fe-b7d5-0693c5ef32b0


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3e28773209

ℹ️ 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".

return null;
// A present non-string value or unrecognised spelling fails closed. Only
// `undefined` above proves that the setting is absent.
return "<unreadable model_instructions_file>";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Distinguish parse failure from a missing setting

When rootValue returns PARSE_FAILED for a Codex-valid document that Bun cannot parse—such as the out-of-safe-range i64 case already documented in this module—and the document has no model_instructions_file, the fallback scan finds nothing and this unconditional sentinel classifies the absent key as external. Consequently, selectBaseVariant rejects every attempt to select a base variant with developer_instructions_not_owned; use scanHasRootKey on parse failure so only an actually present but unreadable assignment fails closed.

AGENTS.md reference: src/AGENTS.md:L10-L10

Useful? React with 👍 / 👎.

function readModelInstructionsFile(configBytes: string | null): string | null {
if (configBytes === null) return null;
const parsed = rootValue(configBytes, "model_instructions_file");
if (typeof parsed === "string") return parsed;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid Bun's nonconforming escape decoding

For externally authored basic strings containing valid \t or \f escapes, this returns Bun's decoded value even though this same module documents that supported Bun versions transpose those escapes relative to Codex's Rust TOML parser. The dashboard therefore reports the wrong path, and computePromptProbeStateFingerprint reads and hashes that wrong file, so editing the real external prompt may leave a cached probe result valid; decode these path literals with Codex-compatible TOML escape semantics rather than trusting Bun's parsed string.

AGENTS.md reference: src/AGENTS.md:L10-L10

Useful? React with 👍 / 👎.

@github-actions github-actions Bot added the bug Something isn't working label Aug 31, 2026
@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions github-actions Bot changed the title fix(prompt): preserve external TOML escaped paths [WRONG BRANCH] fix(prompt): preserve external TOML escaped paths Aug 31, 2026
@github-actions
github-actions Bot marked this pull request as draft August 31, 2026 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant