Harden read-only thread handling and refresh Android releases

This commit is contained in:
kris
2026-04-06 13:26:48 +08:00
parent 9d7d2f4d17
commit 3564aeaf2e
18 changed files with 346 additions and 27 deletions

View File

@@ -63,7 +63,7 @@ async function createCodexStateDb(threads) {
id, rollout_path, created_at, updated_at, source, model_provider, cwd, title,
sandbox_policy, approval_mode, tokens_used, has_user_event, archived,
cli_version, first_user_message, agent_nickname, agent_role, memory_mode, model, reasoning_effort
) VALUES (?, ?, ?, ?, 'desktop', 'openai', ?, ?, 'workspace-write', 'never', 0, 1, 0, '0.118.0', '', '', '', 'enabled', 'gpt-5.4', 'medium')
) VALUES (?, ?, ?, ?, 'desktop', 'openai', ?, ?, ?, 'never', 0, 1, 0, '0.118.0', '', '', '', 'enabled', 'gpt-5.4', 'medium')
`);
for (const thread of threads) {
insertThread.run(
@@ -73,6 +73,7 @@ async function createCodexStateDb(threads) {
1774845618,
thread.cwd,
thread.title ?? thread.id,
thread.sandboxPolicy ?? '{"type":"workspace-write"}',
);
}
db.close();
@@ -283,3 +284,37 @@ test("conversation reply preflight fails closed when target cwd mismatches the l
assert.match(result.error.message, /LOCAL_AGENT_CODEX_THREAD_BINDING_MISMATCH/);
assert.match(result.error.message, /project-live/);
});
test("conversation reply preflight fails closed when target Codex thread is read-only", async () => {
const root = await ensureRuntimeRoot();
const readonlyCwd = path.join(root, "project-readonly");
await mkdir(readonlyCwd, { recursive: true });
const stateDbPath = await createCodexStateDb([
{
id: "019d-thread-readonly",
cwd: readonlyCwd,
title: "Read-only thread",
sandboxPolicy: '{"type":"read-only"}',
},
]);
const result = await prepareCodexTaskExecution(
{
masterAgentWorkdir: "/Users/kris/code/boss",
masterAgentSandbox: "workspace-write",
codexStateDbPath: stateDbPath,
},
{
taskType: "conversation_reply",
executionPrompt: "请继续开发",
targetCodexThreadRef: "019d-thread-readonly",
targetCodexFolderRef: readonlyCwd,
},
"/tmp/reply.txt",
);
assert.equal(result.ok, false);
assert.equal(result.error.code, "LOCAL_AGENT_CODEX_THREAD_READ_ONLY");
assert.match(result.error.message, /LOCAL_AGENT_CODEX_THREAD_READ_ONLY/);
assert.match(result.error.message, /read-only/);
});