Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions tests/codex-prompt-route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync,
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
import { handleManagementAPI } from "../src/server/management-api";
import { encodeBasicString, LAYER_INVENTORY, readPromptLayers } from "../src/codex/prompt-layers";
import { LAYER_INVENTORY, readPromptLayers } from "../src/codex/prompt-layers";
import {
promptTextProbeSpawnAttemptsForTests,
resetPromptTextProbeForTests,
Expand Down Expand Up @@ -1132,17 +1132,19 @@ describe("020 coverage completions", () => {
*/
test("34. editing an external base prompt invalidates an in-flight text probe", async () => {
const fx = fixture("model = \"x\"\n");
// A literal backslash makes the Windows path condition reproducible on POSIX:
// interpolating this path raw would create an invalid TOML escape and make the
// fingerprint silently classify the selection as default.
// On Windows the backslash is a separator; on POSIX it is a legal filename
// character that deterministically exercises the same TOML escaping boundary.
const externalPath = join(fx.decoyHome, "external\\base.md");
mkdirSync(dirname(externalPath), { recursive: true });
writeFileSync(externalPath, "old-external", "utf8");
await call("PUT", "/api/codex-prompt/base/select", fx, {
kind: "external", path: externalPath, revision: await revision(fx),
});
// Selection through the route is not assumed: the fixture config is what the
// fingerprint reads, so assert the state this case depends on.
writeFileSync(fx.configPath, `model_instructions_file = ${encodeBasicString(externalPath)}\n`, "utf8");
// JSON string encoding is an independent, compatible encoding for this TOML
// basic string, so the fixture does not use the production encoder as its oracle.
writeFileSync(fx.configPath, `model_instructions_file = ${JSON.stringify(externalPath)}\n`, "utf8");
expect(readPromptLayers({
configPath: fx.configPath,
storePath: fx.storePath,
baseVariantDir: fx.baseVariantDir,
}).baseSelection).toEqual({ kind: "external", path: externalPath });

const startedPath = join(fx.decoyHome, "external-probe-starts.txt");
const source = [
Expand Down
Loading