oh-my-codex 0.22.0 → 0.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +6 -6
- package/Cargo.toml +1 -1
- package/dist/cli/__tests__/plugin-cache-live-pin-3790.test.js +104 -3
- package/dist/cli/__tests__/plugin-cache-live-pin-3790.test.js.map +1 -1
- package/dist/cli/__tests__/question.test.js +33 -0
- package/dist/cli/__tests__/question.test.js.map +1 -1
- package/dist/cli/plugin-marketplace.d.ts.map +1 -1
- package/dist/cli/plugin-marketplace.js +11 -4
- package/dist/cli/plugin-marketplace.js.map +1 -1
- package/dist/cli/question.d.ts.map +1 -1
- package/dist/cli/question.js +8 -1
- package/dist/cli/question.js.map +1 -1
- package/dist/question/__tests__/ui.test.js +40 -1
- package/dist/question/__tests__/ui.test.js.map +1 -1
- package/dist/question/ui.d.ts.map +1 -1
- package/dist/question/ui.js +37 -7
- package/dist/question/ui.js.map +1 -1
- package/dist/team/__tests__/completion-evidence.test.js +31 -1
- package/dist/team/__tests__/completion-evidence.test.js.map +1 -1
- package/dist/team/__tests__/hook-primary-e2e-contract.test.js +9 -3
- package/dist/team/__tests__/hook-primary-e2e-contract.test.js.map +1 -1
- package/dist/team/__tests__/mcp-comm.test.js +25 -1
- package/dist/team/__tests__/mcp-comm.test.js.map +1 -1
- package/dist/team/__tests__/p1-safety.test.d.ts +2 -0
- package/dist/team/__tests__/p1-safety.test.d.ts.map +1 -0
- package/dist/team/__tests__/p1-safety.test.js +553 -0
- package/dist/team/__tests__/p1-safety.test.js.map +1 -0
- package/dist/team/__tests__/runtime.test.js +607 -53
- package/dist/team/__tests__/runtime.test.js.map +1 -1
- package/dist/team/__tests__/scaling.test.js +355 -4
- package/dist/team/__tests__/scaling.test.js.map +1 -1
- package/dist/team/__tests__/state.test.js +127 -5
- package/dist/team/__tests__/state.test.js.map +1 -1
- package/dist/team/completion-evidence.d.ts +2 -1
- package/dist/team/completion-evidence.d.ts.map +1 -1
- package/dist/team/completion-evidence.js +30 -7
- package/dist/team/completion-evidence.js.map +1 -1
- package/dist/team/mcp-comm.d.ts +5 -3
- package/dist/team/mcp-comm.d.ts.map +1 -1
- package/dist/team/mcp-comm.js +4 -0
- package/dist/team/mcp-comm.js.map +1 -1
- package/dist/team/runtime.d.ts.map +1 -1
- package/dist/team/runtime.js +244 -146
- package/dist/team/runtime.js.map +1 -1
- package/dist/team/scaling.d.ts +3 -3
- package/dist/team/scaling.d.ts.map +1 -1
- package/dist/team/scaling.js +73 -67
- package/dist/team/scaling.js.map +1 -1
- package/dist/team/state/tasks.d.ts +2 -0
- package/dist/team/state/tasks.d.ts.map +1 -1
- package/dist/team/state/tasks.js +28 -22
- package/dist/team/state/tasks.js.map +1 -1
- package/dist/team/state/types.d.ts +1 -0
- package/dist/team/state/types.d.ts.map +1 -1
- package/dist/team/state/types.js.map +1 -1
- package/dist/team/state.d.ts +1 -0
- package/dist/team/state.d.ts.map +1 -1
- package/dist/team/state.js +60 -11
- package/dist/team/state.js.map +1 -1
- package/dist/team/worker-bootstrap.js +2 -2
- package/dist/team/worktree.d.ts +1 -0
- package/dist/team/worktree.d.ts.map +1 -1
- package/dist/team/worktree.js +64 -11
- package/dist/team/worktree.js.map +1 -1
- package/package.json +1 -1
- package/plugins/oh-my-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/oh-my-codex/hooks/codex-native-hook.mjs +4 -1
|
@@ -7,7 +7,7 @@ import { join, relative, dirname } from 'path';
|
|
|
7
7
|
import { tmpdir } from 'os';
|
|
8
8
|
import { existsSync } from 'fs';
|
|
9
9
|
import { HUD_TMUX_TEAM_HEIGHT_LINES } from '../../hud/constants.js';
|
|
10
|
-
import { DEFAULT_MAX_WORKERS, initTeamState, createTask, writeWorkerInbox, readTeamConfig, saveTeamConfig, listMailboxMessages, sendDirectMessage, listDispatchRequests, listTasks, transitionDispatchRequest, updateWorkerHeartbeat, writeAtomic, readTask, readMonitorSnapshot, claimTask, transitionTaskStatus, readWorkerStatus, writeWorkerStatus, readTeamPhase, writeTeamPhase, } from '../state.js';
|
|
10
|
+
import { DEFAULT_MAX_WORKERS, initTeamState, createTask, writeWorkerInbox, readTeamConfig, readTeamManifestV2, saveTeamConfig, listMailboxMessages, sendDirectMessage, listDispatchRequests, listTasks, transitionDispatchRequest, updateWorkerHeartbeat, writeAtomic, readTask, readMonitorSnapshot, claimTask, transitionTaskStatus, releaseTaskClaim, readWorkerStatus, writeWorkerStatus, readTeamPhase, writeTeamPhase, } from '../state.js';
|
|
11
11
|
import { monitorTeam, shutdownTeam, resumeTeam, startTeam, assignTask, reassignTask, sendWorkerMessage, applyCreatedInteractiveSessionToConfig, reconcileStartupCleanupPanes, rethrowStartupRollbackProofDebt, resolveWorkerLaunchArgsFromEnv, resolveTeamWorkerCliForResolvedLaunchArgs, shouldPrekillInteractiveShutdownProcessTrees, waitForWorkerStartupEvidence, waitForClaudeStartupEvidence, cleanupTeamWorkerLaunchOrphanedMcpProcesses, settleStartupAttemptResults, setDetachedSessionDestroyAfterJournalHookForTest, setTerminalEpochStartedHookForTest, } from '../runtime.js';
|
|
12
12
|
import { resolveAgentReasoningEffort, resolveTeamLowComplexityDefaultModel, TEAM_WORKER_INHERITED_MODEL_ENV, } from '../model-contract.js';
|
|
13
13
|
import { readTeamEvents } from '../state/events.js';
|
|
@@ -3146,7 +3146,7 @@ esac
|
|
|
3146
3146
|
it('startTeam saves interactive pane ids before concurrent readiness attempts', async () => {
|
|
3147
3147
|
const source = await readFile(join(process.cwd(), 'src', 'team', 'runtime.ts'), 'utf-8');
|
|
3148
3148
|
const applyMatch = source.match(/applyCreatedInteractiveSessionToConfig\(\s*config,\s*createdSession,\s*workerPaneIds\s*\);/m);
|
|
3149
|
-
const saveMatch = source.match(/await
|
|
3149
|
+
const saveMatch = source.match(/await persistStartupTransport\(\);/m);
|
|
3150
3150
|
const readyMatch = source.match(/waitForWorkerReadyAsync\(/m);
|
|
3151
3151
|
const applyIndex = applyMatch?.index ?? -1;
|
|
3152
3152
|
const saveIndex = saveMatch?.index ?? -1;
|
|
@@ -3705,6 +3705,394 @@ esac
|
|
|
3705
3705
|
await rm(cwd, { recursive: true, force: true });
|
|
3706
3706
|
}
|
|
3707
3707
|
});
|
|
3708
|
+
for (const { partialFailure, followupDispatch } of [
|
|
3709
|
+
{ partialFailure: false, followupDispatch: undefined },
|
|
3710
|
+
{ partialFailure: true, followupDispatch: undefined },
|
|
3711
|
+
{ partialFailure: false, followupDispatch: 'gemini' },
|
|
3712
|
+
{ partialFailure: false, followupDispatch: 'codex-direct' },
|
|
3713
|
+
{ partialFailure: false, followupDispatch: 'codex-queued' },
|
|
3714
|
+
]) {
|
|
3715
|
+
it(followupDispatch
|
|
3716
|
+
? `startTeam preserves a follow-up inbox assigned after transport publication (${followupDispatch})`
|
|
3717
|
+
: `startTeam preserves early Gemini ownership changes ${partialFailure ? 'with partial-create proof debt' : 'before transport publication'}`, async () => {
|
|
3718
|
+
const cwd = await mkdtemp(join(tmpdir(), 'omx-runtime-early-startup-'));
|
|
3719
|
+
try {
|
|
3720
|
+
await withMockTmuxFixture({
|
|
3721
|
+
dirPrefix: 'omx-runtime-early-startup-bin-',
|
|
3722
|
+
tmuxScript: (tmuxLogPath) => `#!/bin/sh
|
|
3723
|
+
set -eu
|
|
3724
|
+
${tmuxOwnerProofShim}
|
|
3725
|
+
printf '%s\n' "$*" >> "${tmuxLogPath}"
|
|
3726
|
+
case "$1" in
|
|
3727
|
+
-V)
|
|
3728
|
+
echo "tmux 3.4"
|
|
3729
|
+
exit 0
|
|
3730
|
+
;;
|
|
3731
|
+
display-message)
|
|
3732
|
+
case "$*" in
|
|
3733
|
+
*"#{window_width}"*) echo "120" ;;
|
|
3734
|
+
*) echo "leader:0 %1" ;;
|
|
3735
|
+
esac
|
|
3736
|
+
exit 0
|
|
3737
|
+
;;
|
|
3738
|
+
list-panes)
|
|
3739
|
+
case "$*" in
|
|
3740
|
+
*"-a -F #{pane_id}"*)
|
|
3741
|
+
${followupDispatch ? `if [ -f "${cwd}/early-ownership.json" ] && [ ! -f "${cwd}/handoff-started" ]; then gemini handoff > /dev/null; fi` : ':'}
|
|
3742
|
+
if [ -f "${cwd}/partial-proof-failure" ]; then printf 'malformed-pane-snapshot\n'; exit 0; fi
|
|
3743
|
+
printf "%%1\t0\t2000004141\n"
|
|
3744
|
+
if [ -f "${cwd}/early-startup-w1" ]; then printf "%%2\t0\t2000004242\n"; fi
|
|
3745
|
+
if [ -f "${cwd}/early-startup-w2" ]; then printf "%%3\t0\t2000004343\n"; fi
|
|
3746
|
+
if [ -f "${cwd}/early-startup-hud" ]; then printf "%%4\t0\t2000004444\n"; fi
|
|
3747
|
+
;;
|
|
3748
|
+
*"pane_current_command"*)
|
|
3749
|
+
printf "%%1\tnode\t'codex'\n"
|
|
3750
|
+
if [ -f "${cwd}/early-startup-w1" ]; then printf "%%2\tcodex\tcodex\n"; fi
|
|
3751
|
+
if [ -f "${cwd}/early-startup-w2" ]; then printf "%%3\tcodex\tcodex\n"; fi
|
|
3752
|
+
if [ -f "${cwd}/early-startup-hud" ]; then printf "%%4\tnode\thud --watch\n"; fi
|
|
3753
|
+
;;
|
|
3754
|
+
*"#{pane_dead} #{pane_pid}"*) echo "0 2000004242" ;;
|
|
3755
|
+
*"#{pane_dead}"*) echo "0" ;;
|
|
3756
|
+
*"-t %2"*"#{pane_pid}"*) echo "2000004242" ;;
|
|
3757
|
+
*"-t %3"*"#{pane_pid}"*) echo "2000004343" ;;
|
|
3758
|
+
*"#{pane_pid}"*) echo "2000004141" ;;
|
|
3759
|
+
*) exit 0 ;;
|
|
3760
|
+
esac
|
|
3761
|
+
exit 0
|
|
3762
|
+
;;
|
|
3763
|
+
capture-pane)
|
|
3764
|
+
printf '${followupDispatch === 'codex-queued' ? 'plain shell\n' : 'OpenAI Codex\nmodel: test\n› \n'}'
|
|
3765
|
+
exit 0
|
|
3766
|
+
;;
|
|
3767
|
+
split-window)
|
|
3768
|
+
count_file="${cwd}/early-startup-split-count"
|
|
3769
|
+
count=0
|
|
3770
|
+
if [ -f "$count_file" ]; then count=$(cat "$count_file"); fi
|
|
3771
|
+
count=$((count + 1))
|
|
3772
|
+
printf '%s' "$count" > "$count_file"
|
|
3773
|
+
case "$count" in
|
|
3774
|
+
1)
|
|
3775
|
+
: > "${cwd}/early-startup-w1"
|
|
3776
|
+
gemini
|
|
3777
|
+
echo "%2"
|
|
3778
|
+
;;
|
|
3779
|
+
2) : > "${cwd}/early-startup-w2"; echo "%3" ;;
|
|
3780
|
+
*)
|
|
3781
|
+
: > "${cwd}/early-startup-hud"
|
|
3782
|
+
${partialFailure ? `: > "${cwd}/partial-proof-failure"` : ':'}
|
|
3783
|
+
echo "%4"
|
|
3784
|
+
;;
|
|
3785
|
+
esac
|
|
3786
|
+
exit 0
|
|
3787
|
+
;;
|
|
3788
|
+
set-hook|run-shell|select-layout|set-window-option|select-pane|send-keys|kill-pane|kill-session|resize-pane)
|
|
3789
|
+
exit 0
|
|
3790
|
+
;;
|
|
3791
|
+
*)
|
|
3792
|
+
exit 0
|
|
3793
|
+
;;
|
|
3794
|
+
esac
|
|
3795
|
+
`,
|
|
3796
|
+
binaries: [{ name: 'gemini', content: `#!/usr/bin/env node
|
|
3797
|
+
if (process.argv.includes('--version')) { console.log('gemini test'); process.exit(0); }
|
|
3798
|
+
(async () => {
|
|
3799
|
+
const { readdir, readFile, writeFile } = await import('node:fs/promises');
|
|
3800
|
+
const { join } = await import('node:path');
|
|
3801
|
+
const { readTeamConfig, claimTask, releaseTaskClaim, createTask, readTask, readTeamManifestV2, writeTeamManifestV2, writeWorkerStatus } = await import(${JSON.stringify(new URL('../state.js', import.meta.url).href)});
|
|
3802
|
+
const cwd = ${JSON.stringify(cwd)};
|
|
3803
|
+
const [name] = await readdir(join(cwd, '.omx/state/team'));
|
|
3804
|
+
if (process.argv.includes('handoff')) {
|
|
3805
|
+
const transport = await readTeamConfig(name, cwd);
|
|
3806
|
+
if (!transport.workers[0].pane_id) return;
|
|
3807
|
+
const assert = (await import('node:assert/strict')).default;
|
|
3808
|
+
assert.equal(transport.workers[0].pane_id, '%2');
|
|
3809
|
+
assert.equal(transport.workers[0].pid, 2000004242);
|
|
3810
|
+
assert.equal(transport.hud_pane_id, '%4');
|
|
3811
|
+
await writeFile(join(cwd, 'handoff-started'), '');
|
|
3812
|
+
const { created } = JSON.parse(await readFile(join(cwd, 'early-ownership.json'), 'utf8'));
|
|
3813
|
+
const { assignTask } = await import(${JSON.stringify(new URL('../runtime.js', import.meta.url).href)});
|
|
3814
|
+
await assignTask(name, 'worker-1', created.id, cwd);
|
|
3815
|
+
const assigned = await readTask(name, created.id, cwd);
|
|
3816
|
+
const inbox = await readFile(join(cwd, '.omx/state/team', name, 'workers/worker-1/inbox.md'), 'utf8');
|
|
3817
|
+
await writeFile(join(cwd, 'followup-assigned.json'), JSON.stringify({ transport, assigned, inbox }));
|
|
3818
|
+
return;
|
|
3819
|
+
}
|
|
3820
|
+
const before = await readTeamConfig(name, cwd);
|
|
3821
|
+
const identities = await Promise.all(before.workers.map(async (worker) => {
|
|
3822
|
+
try { return JSON.parse(await readFile(join(cwd, '.omx/state/team', name, 'workers', worker.name, 'identity.json'), 'utf8')); }
|
|
3823
|
+
catch (error) { if (error.code === 'ENOENT') return null; throw error; }
|
|
3824
|
+
}));
|
|
3825
|
+
const claim = await claimTask(name, '1', 'worker-1', null, cwd);
|
|
3826
|
+
if (!claim.ok) throw new Error('early_claim_failed');
|
|
3827
|
+
if (!(await releaseTaskClaim(name, '1', claim.claimToken, 'worker-1', cwd)).ok) throw new Error('early_release_failed');
|
|
3828
|
+
const created = await createTask(name, { subject: 'early followup', description: 'preserve task counter', status: 'pending' }, cwd);
|
|
3829
|
+
${followupDispatch ? `const manifest = await readTeamManifestV2(name, cwd);
|
|
3830
|
+
manifest.policy.dispatch_mode = 'transport_direct';
|
|
3831
|
+
await writeTeamManifestV2(manifest, cwd);
|
|
3832
|
+
for (const worker of before.workers) {
|
|
3833
|
+
await writeWorkerStatus(name, worker.name, { state: 'working', updated_at: new Date().toISOString() }, cwd);
|
|
3834
|
+
}` : ''}
|
|
3835
|
+
const released = await readTeamConfig(name, cwd);
|
|
3836
|
+
await writeFile(join(cwd, 'early-ownership.json'), JSON.stringify({ before, identities, released, created }));
|
|
3837
|
+
})().catch((error) => { console.error(error); process.exitCode = 1; });
|
|
3838
|
+
` }, { name: 'codex', content: fakeCodexNodeScript('process.stdin.resume();\n') }],
|
|
3839
|
+
env: {
|
|
3840
|
+
TMUX: undefined,
|
|
3841
|
+
TMUX_PANE: '%1',
|
|
3842
|
+
OMX_TEAM_WORKER_LAUNCH_MODE: 'interactive',
|
|
3843
|
+
OMX_TEAM_WORKER_CLI: followupDispatch?.startsWith('codex') ? 'codex' : 'gemini',
|
|
3844
|
+
OMX_TEAM_SKIP_READY_WAIT: followupDispatch === 'codex-queued' ? '1' : undefined,
|
|
3845
|
+
},
|
|
3846
|
+
}, async ({ tmuxLogPath }) => {
|
|
3847
|
+
const startup = withoutTeamWorkerEnv(() => startTeam('team-early-startup', 'initial prompt ownership changes', 'executor', 2, [
|
|
3848
|
+
{ subject: 'w1', description: 'worker one', owner: 'worker-1' },
|
|
3849
|
+
{ subject: 'w2', description: 'worker two', owner: 'worker-2' },
|
|
3850
|
+
], cwd));
|
|
3851
|
+
let teamName;
|
|
3852
|
+
if (partialFailure) {
|
|
3853
|
+
await assert.rejects(startup, (error) => {
|
|
3854
|
+
assert.ok(error instanceof Error);
|
|
3855
|
+
assert.match(error.message, /startup_rollback_pane_proof_unavailable:.*malformed_snapshot/);
|
|
3856
|
+
assert.match(error.message, /during startup_rollback of: create_team_session_cleanup_incomplete/);
|
|
3857
|
+
assert.doesNotMatch(error.message, /stale_generation/);
|
|
3858
|
+
assert.ok(error.cause instanceof Error);
|
|
3859
|
+
assert.match(error.cause.message, /create_team_session_cleanup_incomplete/);
|
|
3860
|
+
return true;
|
|
3861
|
+
});
|
|
3862
|
+
teamName = await resolveRuntimeTeamName(cwd, 'team-early-startup');
|
|
3863
|
+
}
|
|
3864
|
+
else {
|
|
3865
|
+
const runtime = await startup;
|
|
3866
|
+
teamName = runtime.teamName;
|
|
3867
|
+
assert.deepEqual(runtime.config, await readTeamConfig(teamName, cwd));
|
|
3868
|
+
}
|
|
3869
|
+
const { before, identities, released, created } = JSON.parse(await readFile(join(cwd, 'early-ownership.json'), 'utf8'));
|
|
3870
|
+
assert.deepEqual(before.workers.map((worker) => worker.assigned_tasks), [['1'], ['2']]);
|
|
3871
|
+
assert.deepEqual(identities.map((worker) => worker.assigned_tasks), [['1'], ['2']]);
|
|
3872
|
+
assert.ok(released.config_generation > before.config_generation);
|
|
3873
|
+
const canonical = await readTeamConfig(teamName, cwd);
|
|
3874
|
+
const manifest = await readTeamManifestV2(teamName, cwd);
|
|
3875
|
+
assert.ok(canonical);
|
|
3876
|
+
assert.deepEqual(canonical.workers.map((worker) => worker.assigned_tasks), [followupDispatch ? [created.id] : [], ['2']]);
|
|
3877
|
+
assert.equal(canonical.next_task_id, Number(created.id) + 1);
|
|
3878
|
+
assert.equal(canonical.next_task_id, released.next_task_id);
|
|
3879
|
+
assert.deepEqual(manifest?.workers, canonical.workers);
|
|
3880
|
+
assert.equal(manifest?.next_task_id, canonical.next_task_id);
|
|
3881
|
+
assert.equal(manifest?.config_generation, canonical.config_generation);
|
|
3882
|
+
assert.equal((await readTask(teamName, '1', cwd))?.owner, undefined);
|
|
3883
|
+
assert.equal((await readTask(teamName, created.id, cwd))?.subject, 'early followup');
|
|
3884
|
+
if (followupDispatch) {
|
|
3885
|
+
const handoff = JSON.parse(await readFile(join(cwd, 'followup-assigned.json'), 'utf8'));
|
|
3886
|
+
const assigned = await readTask(teamName, created.id, cwd);
|
|
3887
|
+
assert.equal(assigned?.status, 'in_progress');
|
|
3888
|
+
assert.equal(assigned?.owner, 'worker-1');
|
|
3889
|
+
assert.ok(assigned?.claim?.token);
|
|
3890
|
+
assert.equal(assigned.claim.token, handoff.assigned.claim.token);
|
|
3891
|
+
assert.deepEqual(assigned, handoff.assigned);
|
|
3892
|
+
const inbox = await readFile(join(cwd, '.omx/state/team', teamName, 'workers/worker-1/inbox.md'), 'utf8');
|
|
3893
|
+
assert.match(inbox, /early followup/);
|
|
3894
|
+
assert.match(inbox, new RegExp(`Task ${created.id}`));
|
|
3895
|
+
assert.equal(inbox, handoff.inbox, 'startup must preserve the entire current handoff, including any claim token');
|
|
3896
|
+
const requests = await listDispatchRequests(teamName, cwd);
|
|
3897
|
+
assert.ok(requests.some((request) => request.inbox_correlation_key === `assign:${created.id}:worker-1`));
|
|
3898
|
+
if (followupDispatch.startsWith('codex')) {
|
|
3899
|
+
const prefix = followupDispatch === 'codex-direct' ? 'startup-direct' : 'startup';
|
|
3900
|
+
assert.ok(requests.some((request) => request.inbox_correlation_key === `${prefix}:worker-1`), 'the later startup notification path must also preserve the follow-up inbox');
|
|
3901
|
+
}
|
|
3902
|
+
}
|
|
3903
|
+
if (partialFailure) {
|
|
3904
|
+
assert.equal(canonical.workers[0]?.pane_id, '%2');
|
|
3905
|
+
assert.equal(canonical.hud_pane_id, '%4');
|
|
3906
|
+
assert.ok((await readTeamEvents(teamName, cwd)).some((event) => event.reason?.startsWith('startup_create_session_cleanup_debt:')));
|
|
3907
|
+
}
|
|
3908
|
+
else {
|
|
3909
|
+
assert.doesNotMatch(await readFile(tmuxLogPath, 'utf8'), /^(?:kill-pane|kill-session|set-hook -u)\b/m);
|
|
3910
|
+
}
|
|
3911
|
+
for (const marker of ['early-startup-w1', 'early-startup-w2', 'early-startup-hud']) {
|
|
3912
|
+
assert.ok(existsSync(join(cwd, marker)));
|
|
3913
|
+
}
|
|
3914
|
+
});
|
|
3915
|
+
}
|
|
3916
|
+
finally {
|
|
3917
|
+
await rm(cwd, { recursive: true, force: true });
|
|
3918
|
+
}
|
|
3919
|
+
});
|
|
3920
|
+
}
|
|
3921
|
+
for (const failStartup of [false, true]) {
|
|
3922
|
+
it(failStartup
|
|
3923
|
+
? 'startTeam preserves ownership and rollback proof debt after concurrent startup failure'
|
|
3924
|
+
: 'startTeam preserves released assignments when ownership changes during concurrent startup', async () => {
|
|
3925
|
+
const cwd = await mkdtemp(join(tmpdir(), 'omx-runtime-startup-generation-'));
|
|
3926
|
+
const teamName = 'team-startup-generation';
|
|
3927
|
+
try {
|
|
3928
|
+
await withMockTmuxFixture({
|
|
3929
|
+
dirPrefix: 'omx-runtime-startup-generation-bin-',
|
|
3930
|
+
tmuxScript: (tmuxLogPath) => `#!/bin/sh
|
|
3931
|
+
set -eu
|
|
3932
|
+
${tmuxOwnerProofShim}
|
|
3933
|
+
printf '%s\n' "$*" >> "${tmuxLogPath}"
|
|
3934
|
+
case "$1" in
|
|
3935
|
+
-V)
|
|
3936
|
+
echo "tmux 3.4"
|
|
3937
|
+
exit 0
|
|
3938
|
+
;;
|
|
3939
|
+
display-message)
|
|
3940
|
+
case "$*" in
|
|
3941
|
+
*"#{window_width}"*) echo "120" ;;
|
|
3942
|
+
*) echo "leader:0 %1" ;;
|
|
3943
|
+
esac
|
|
3944
|
+
exit 0
|
|
3945
|
+
;;
|
|
3946
|
+
list-panes)
|
|
3947
|
+
case "$*" in
|
|
3948
|
+
*"-a -F #{pane_id}"*)
|
|
3949
|
+
if [ -f "${cwd}/rollback-proof-failure" ]; then printf 'malformed-pane-snapshot\n'; exit 0; fi
|
|
3950
|
+
printf "%%1\t0\t2000004141\n"
|
|
3951
|
+
if [ -f "${cwd}/startup-generation-w1" ]; then printf "%%2\t0\t2000004242\n"; fi
|
|
3952
|
+
if [ -f "${cwd}/startup-generation-w2" ]; then printf "%%3\t0\t2000004343\n"; fi
|
|
3953
|
+
if [ -f "${cwd}/startup-generation-hud" ]; then printf "%%4\t0\t2000004444\n"; fi
|
|
3954
|
+
;;
|
|
3955
|
+
*"pane_current_command"*)
|
|
3956
|
+
printf "%%1\tnode\t'codex'\n"
|
|
3957
|
+
if [ -f "${cwd}/startup-generation-w1" ]; then printf "%%2\tcodex\tcodex\n"; fi
|
|
3958
|
+
if [ -f "${cwd}/startup-generation-w2" ]; then printf "%%3\tcodex\tcodex\n"; fi
|
|
3959
|
+
if [ -f "${cwd}/startup-generation-hud" ]; then printf "%%4\tnode\thud --watch\n"; fi
|
|
3960
|
+
;;
|
|
3961
|
+
*"#{pane_dead} #{pane_pid}"*) echo "0 2000004242" ;;
|
|
3962
|
+
*"#{pane_dead}"*) echo "0" ;;
|
|
3963
|
+
*"-t %2"*"#{pane_pid}"*) echo "2000004242" ;;
|
|
3964
|
+
*"-t %3"*"#{pane_pid}"*) echo "2000004343" ;;
|
|
3965
|
+
*"#{pane_pid}"*) echo "2000004141" ;;
|
|
3966
|
+
*) exit 0 ;;
|
|
3967
|
+
esac
|
|
3968
|
+
exit 0
|
|
3969
|
+
;;
|
|
3970
|
+
capture-pane)
|
|
3971
|
+
printf 'OpenAI Codex\nmodel: test\n› \n'
|
|
3972
|
+
exit 0
|
|
3973
|
+
;;
|
|
3974
|
+
split-window)
|
|
3975
|
+
count_file="${cwd}/startup-generation-split-count"
|
|
3976
|
+
count=0
|
|
3977
|
+
if [ -f "$count_file" ]; then count=$(cat "$count_file"); fi
|
|
3978
|
+
count=$((count + 1))
|
|
3979
|
+
printf '%s' "$count" > "$count_file"
|
|
3980
|
+
case "$count" in
|
|
3981
|
+
1) : > "${cwd}/startup-generation-w1"; echo "%2" ;;
|
|
3982
|
+
2) : > "${cwd}/startup-generation-w2"; echo "%3" ;;
|
|
3983
|
+
*) : > "${cwd}/startup-generation-hud"; echo "%4" ;;
|
|
3984
|
+
esac
|
|
3985
|
+
exit 0
|
|
3986
|
+
;;
|
|
3987
|
+
set-hook|run-shell|select-layout|set-window-option|select-pane|send-keys|kill-pane|kill-session|resize-pane)
|
|
3988
|
+
exit 0
|
|
3989
|
+
;;
|
|
3990
|
+
*)
|
|
3991
|
+
exit 0
|
|
3992
|
+
;;
|
|
3993
|
+
esac
|
|
3994
|
+
`,
|
|
3995
|
+
binaries: [{ name: 'codex', content: fakeCodexNodeScript('process.stdin.resume();\n') }],
|
|
3996
|
+
env: {
|
|
3997
|
+
TMUX: undefined,
|
|
3998
|
+
TMUX_PANE: '%1',
|
|
3999
|
+
OMX_TEAM_WORKER_LAUNCH_MODE: 'interactive',
|
|
4000
|
+
OMX_TEAM_WORKER_CLI: 'codex',
|
|
4001
|
+
OMX_TEAM_READY_TIMEOUT_MS: '500',
|
|
4002
|
+
OMX_TEAM_STARTUP_EVIDENCE_TIMEOUT_MS: '50',
|
|
4003
|
+
OMX_TEAM_STARTUP_DISPATCH_RETRIES: '1',
|
|
4004
|
+
},
|
|
4005
|
+
}, async ({ tmuxLogPath }) => {
|
|
4006
|
+
let settled = false;
|
|
4007
|
+
const startup = withoutTeamWorkerEnv(() => startTeam(teamName, 'ownership changes during startup', 'executor', 2, [
|
|
4008
|
+
{ subject: 'w1', description: 'worker one', owner: 'worker-1' },
|
|
4009
|
+
{ subject: 'w2', description: 'worker two', owner: 'worker-2' },
|
|
4010
|
+
], cwd));
|
|
4011
|
+
void startup.then(() => { settled = true; }, () => { settled = true; });
|
|
4012
|
+
try {
|
|
4013
|
+
// Keep worker-2's hook receipt pending while worker-1 starts and releases its task.
|
|
4014
|
+
const deadline = Date.now() + 10_000;
|
|
4015
|
+
while (true) {
|
|
4016
|
+
const requests = await listDispatchRequests(await resolveRuntimeTeamName(cwd, teamName), cwd);
|
|
4017
|
+
if (['worker-1', 'worker-2'].every((worker) => requests.some((request) => request.to_worker === worker && request.inbox_correlation_key === `startup:${worker}`
|
|
4018
|
+
&& request.status === 'pending')))
|
|
4019
|
+
break;
|
|
4020
|
+
assert.equal(settled, false, 'startup must still be waiting for dispatch');
|
|
4021
|
+
assert.ok(Date.now() < deadline, 'both workers must reach startup dispatch');
|
|
4022
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
4023
|
+
}
|
|
4024
|
+
const canonicalName = await resolveRuntimeTeamName(cwd, teamName);
|
|
4025
|
+
await markPendingInboxDispatchesDelivered(canonicalName, cwd, { toWorker: 'worker-1' });
|
|
4026
|
+
const beforeRelease = await readTeamConfig(canonicalName, cwd);
|
|
4027
|
+
assert.ok(beforeRelease);
|
|
4028
|
+
const taskId = beforeRelease.workers[0].assigned_tasks[0];
|
|
4029
|
+
const claim = await claimTask(canonicalName, taskId, 'worker-1', null, cwd);
|
|
4030
|
+
assert.ok(claim.ok);
|
|
4031
|
+
assert.ok((await releaseTaskClaim(canonicalName, taskId, claim.claimToken, 'worker-1', cwd)).ok);
|
|
4032
|
+
const releasedConfig = await readTeamConfig(canonicalName, cwd);
|
|
4033
|
+
assert.ok(releasedConfig);
|
|
4034
|
+
assert.ok(releasedConfig.config_generation > beforeRelease.config_generation);
|
|
4035
|
+
assert.equal(settled, false, 'worker-2 dispatch must hold startup open through release');
|
|
4036
|
+
assert.ok((await listDispatchRequests(canonicalName, cwd)).some((request) => request.to_worker === 'worker-2' && request.status === 'pending'));
|
|
4037
|
+
if (failStartup) {
|
|
4038
|
+
const worker2Dispatch = (await listDispatchRequests(canonicalName, cwd)).find((request) => request.to_worker === 'worker-2' && request.status === 'pending');
|
|
4039
|
+
assert.ok(worker2Dispatch);
|
|
4040
|
+
await writeFile(join(cwd, 'rollback-proof-failure'), '');
|
|
4041
|
+
await transitionDispatchRequest(canonicalName, worker2Dispatch.request_id, 'pending', 'failed', {
|
|
4042
|
+
last_reason: 'hook_failed:test_startup_failure',
|
|
4043
|
+
}, cwd);
|
|
4044
|
+
await assert.rejects(startup, (error) => {
|
|
4045
|
+
assert.ok(error instanceof Error);
|
|
4046
|
+
assert.match(error.message, /startup_rollback_pane_proof_unavailable:%2:malformed_snapshot/);
|
|
4047
|
+
assert.doesNotMatch(error.message, /stale_generation/);
|
|
4048
|
+
return true;
|
|
4049
|
+
});
|
|
4050
|
+
const preserved = await readTeamConfig(canonicalName, cwd);
|
|
4051
|
+
const manifest = await readTeamManifestV2(canonicalName, cwd);
|
|
4052
|
+
assert.ok(preserved);
|
|
4053
|
+
assert.deepEqual(preserved.workers.map((worker) => worker.assigned_tasks), [[], beforeRelease.workers[1].assigned_tasks]);
|
|
4054
|
+
assert.equal(preserved.next_task_id, releasedConfig.next_task_id);
|
|
4055
|
+
assert.equal(preserved.workers[0]?.pane_id, '%2');
|
|
4056
|
+
assert.equal(preserved.hud_pane_id, '%4');
|
|
4057
|
+
assert.ok(preserved.resize_hook_name);
|
|
4058
|
+
assert.deepEqual(manifest?.workers, preserved.workers);
|
|
4059
|
+
assert.equal(manifest?.config_generation, preserved.config_generation);
|
|
4060
|
+
assert.ok(preserved.config_generation > releasedConfig.config_generation);
|
|
4061
|
+
assert.equal((await readTask(canonicalName, taskId, cwd))?.owner, undefined);
|
|
4062
|
+
assert.doesNotMatch(await readFile(tmuxLogPath, 'utf8'), /^(?:kill-pane|kill-session)\b/m);
|
|
4063
|
+
return;
|
|
4064
|
+
}
|
|
4065
|
+
await markPendingInboxDispatchesDelivered(canonicalName, cwd, { toWorker: 'worker-2' });
|
|
4066
|
+
const runtime = await startup;
|
|
4067
|
+
const canonical = await readTeamConfig(runtime.teamName, cwd);
|
|
4068
|
+
const manifest = await readTeamManifestV2(runtime.teamName, cwd);
|
|
4069
|
+
assert.deepEqual(runtime.config, canonical);
|
|
4070
|
+
assert.deepEqual(canonical, releasedConfig, 'startup must not rewrite canonical membership');
|
|
4071
|
+
assert.deepEqual(canonical?.workers.map((worker) => worker.assigned_tasks), [[], beforeRelease.workers[1].assigned_tasks]);
|
|
4072
|
+
assert.deepEqual(manifest?.workers, canonical?.workers);
|
|
4073
|
+
assert.equal(manifest?.config_generation, canonical?.config_generation);
|
|
4074
|
+
const releasedTask = await readTask(runtime.teamName, taskId, cwd);
|
|
4075
|
+
assert.equal(releasedTask?.status, 'pending');
|
|
4076
|
+
assert.equal(releasedTask?.owner, undefined);
|
|
4077
|
+
assert.equal(releasedTask?.claim, undefined);
|
|
4078
|
+
for (const worker of runtime.config.workers) {
|
|
4079
|
+
assert.ok(existsSync(join(cwd, '.omx/state/team', runtime.teamName, 'workers', worker.name, 'identity.json')));
|
|
4080
|
+
}
|
|
4081
|
+
for (const marker of ['startup-generation-w1', 'startup-generation-w2', 'startup-generation-hud']) {
|
|
4082
|
+
assert.ok(existsSync(join(cwd, marker)), 'created pane resources must remain');
|
|
4083
|
+
}
|
|
4084
|
+
assert.doesNotMatch(await readFile(tmuxLogPath, 'utf-8'), /^(?:kill-pane|kill-session|set-hook -u)\b/m);
|
|
4085
|
+
}
|
|
4086
|
+
finally {
|
|
4087
|
+
await startup.catch(() => { });
|
|
4088
|
+
}
|
|
4089
|
+
});
|
|
4090
|
+
}
|
|
4091
|
+
finally {
|
|
4092
|
+
await rm(cwd, { recursive: true, force: true });
|
|
4093
|
+
}
|
|
4094
|
+
});
|
|
4095
|
+
}
|
|
3708
4096
|
it('startTeam starts worker-2 readiness before delayed worker-1 readiness settles', async () => {
|
|
3709
4097
|
const cwd = await mkdtemp(join(tmpdir(), 'omx-runtime-parallel-ready-'));
|
|
3710
4098
|
const previousTmux = process.env.TMUX;
|
|
@@ -6307,6 +6695,7 @@ esac
|
|
|
6307
6695
|
worktree_created: false,
|
|
6308
6696
|
};
|
|
6309
6697
|
await saveTeamConfig(cfg, repo);
|
|
6698
|
+
await handOffVerifiedIntegrationTasks('team-integration-ledger', repo);
|
|
6310
6699
|
await monitorTeam('team-integration-ledger', repo);
|
|
6311
6700
|
const firstSnapshot = await readMonitorSnapshot('team-integration-ledger', repo);
|
|
6312
6701
|
assert.equal(firstSnapshot?.integrationByWorker?.['worker-1']?.last_seen_head, workerHead);
|
|
@@ -6339,52 +6728,216 @@ esac
|
|
|
6339
6728
|
await rm(repo, { recursive: true, force: true });
|
|
6340
6729
|
}
|
|
6341
6730
|
});
|
|
6342
|
-
|
|
6731
|
+
for (const mutation of ['tracked-edit', 'untracked-file', 'different-head', 'research-only', 'legacy-completion']) {
|
|
6732
|
+
it(`monitorTeam refuses publication without a matching clean code handoff (${mutation})`, async () => {
|
|
6733
|
+
const repo = await initRepo();
|
|
6734
|
+
let workerPath = '';
|
|
6735
|
+
try {
|
|
6736
|
+
const team = 'team-handoff-identity';
|
|
6737
|
+
workerPath = await addWorktree(repo, 'handoff-identity-worker', 'omx-runtime-handoff-identity-');
|
|
6738
|
+
await writeFile(join(workerPath, 'code.txt'), 'verified worker code\n');
|
|
6739
|
+
execFileSync('git', ['add', 'code.txt'], { cwd: workerPath });
|
|
6740
|
+
execFileSync('git', ['commit', '-m', 'verified worker commit'], { cwd: workerPath, stdio: 'ignore' });
|
|
6741
|
+
await initTeamState(team, 'handoff identity test', 'executor', 1, repo);
|
|
6742
|
+
const config = await readTeamConfig(team, repo);
|
|
6743
|
+
assert.ok(config);
|
|
6744
|
+
Object.assign(config.workers[0], { worktree_repo_root: repo, worktree_path: workerPath, worktree_branch: 'handoff-identity-worker' });
|
|
6745
|
+
await saveTeamConfig(config, repo);
|
|
6746
|
+
if (mutation === 'research-only') {
|
|
6747
|
+
const research = await createTask(team, { subject: 'research', description: 'read only', status: 'pending', requires_code_change: false }, repo);
|
|
6748
|
+
const claim = await claimTask(team, research.id, 'worker-1', null, repo);
|
|
6749
|
+
assert.ok(claim.ok);
|
|
6750
|
+
assert.ok((await transitionTaskStatus(team, research.id, 'in_progress', 'completed', claim.claimToken, repo, { result: 'Research complete; no code changes requested.' })).ok);
|
|
6751
|
+
await writeWorkerStatus(team, 'worker-1', { state: 'idle', updated_at: new Date().toISOString() }, repo);
|
|
6752
|
+
}
|
|
6753
|
+
else if (mutation === 'legacy-completion') {
|
|
6754
|
+
// Persisted legacy completions have no authoritative Git identity.
|
|
6755
|
+
await createTask(team, { subject: 'legacy code', description: 'old completion', status: 'completed', owner: 'worker-1', requires_code_change: true, result: 'Verification: PASS `npm test`.' }, repo);
|
|
6756
|
+
await writeWorkerStatus(team, 'worker-1', { state: 'idle', updated_at: new Date().toISOString() }, repo);
|
|
6757
|
+
}
|
|
6758
|
+
else {
|
|
6759
|
+
await handOffVerifiedIntegrationTasks(team, repo);
|
|
6760
|
+
if (mutation === 'untracked-file') {
|
|
6761
|
+
await writeFile(join(workerPath, 'later.txt'), 'unverified untracked content\n');
|
|
6762
|
+
}
|
|
6763
|
+
else {
|
|
6764
|
+
await writeFile(join(workerPath, 'code.txt'), 'later unverified tracked bytes\n');
|
|
6765
|
+
if (mutation === 'different-head') {
|
|
6766
|
+
execFileSync('git', ['add', 'code.txt'], { cwd: workerPath });
|
|
6767
|
+
execFileSync('git', ['commit', '-m', 'later unverified commit'], { cwd: workerPath, stdio: 'ignore' });
|
|
6768
|
+
}
|
|
6769
|
+
}
|
|
6770
|
+
}
|
|
6771
|
+
const git = (cwd, args) => execFileSync('git', args, { cwd, encoding: 'utf8' }).trim();
|
|
6772
|
+
if (mutation === 'legacy-completion' || mutation === 'different-head') {
|
|
6773
|
+
await createTask(team, { subject: 'leader follow-up', description: 'keep execution open for re-verification', status: 'pending' }, repo);
|
|
6774
|
+
}
|
|
6775
|
+
const leaderHead = git(repo, ['rev-parse', 'HEAD']);
|
|
6776
|
+
const workerHead = git(workerPath, ['rev-parse', 'HEAD']);
|
|
6777
|
+
const workerStatus = git(workerPath, ['status', '--porcelain']);
|
|
6778
|
+
await monitorTeam(team, repo);
|
|
6779
|
+
assert.equal(git(repo, ['rev-parse', 'HEAD']), leaderHead);
|
|
6780
|
+
assert.equal(git(workerPath, ['rev-parse', 'HEAD']), workerHead);
|
|
6781
|
+
assert.equal(git(workerPath, ['status', '--porcelain']), workerStatus);
|
|
6782
|
+
assert.equal(existsSync(join(repo, 'code.txt')), false);
|
|
6783
|
+
if (mutation === 'tracked-edit' || mutation === 'different-head')
|
|
6784
|
+
assert.equal(await readFile(join(workerPath, 'code.txt'), 'utf8'), 'later unverified tracked bytes\n');
|
|
6785
|
+
const events = await readTeamEvents(team, repo, { wakeableOnly: false });
|
|
6786
|
+
assert.equal(events.some((event) => ['worker_auto_commit', 'worker_merge_applied', 'worker_cherry_pick_applied', 'worker_cross_rebase_applied'].includes(event.type)), false);
|
|
6787
|
+
if (mutation === 'legacy-completion' || mutation === 'different-head') {
|
|
6788
|
+
// A fresh verified code task is the supported migration/reverification path.
|
|
6789
|
+
await handOffVerifiedIntegrationTasks(team, repo);
|
|
6790
|
+
await monitorTeam(team, repo);
|
|
6791
|
+
assert.equal(await readFile(join(repo, 'code.txt'), 'utf8'), mutation === 'different-head' ? 'later unverified tracked bytes\n' : 'verified worker code\n');
|
|
6792
|
+
}
|
|
6793
|
+
}
|
|
6794
|
+
finally {
|
|
6795
|
+
if (workerPath)
|
|
6796
|
+
await rm(workerPath, { recursive: true, force: true });
|
|
6797
|
+
await rm(repo, { recursive: true, force: true });
|
|
6798
|
+
}
|
|
6799
|
+
});
|
|
6800
|
+
}
|
|
6801
|
+
it('monitorTeam integrates verified B after public release and reassignment of bootstrap A', async () => {
|
|
6343
6802
|
const repo = await initRepo();
|
|
6344
6803
|
let workerPath = '';
|
|
6345
6804
|
try {
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
await
|
|
6349
|
-
await
|
|
6350
|
-
const
|
|
6351
|
-
assert.ok(
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
const
|
|
6368
|
-
assert.
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
assert.
|
|
6805
|
+
const team = 'team-transfer-handoff';
|
|
6806
|
+
workerPath = await addWorktree(repo, 'transfer-handoff-worker', 'omx-runtime-transfer-handoff-');
|
|
6807
|
+
await initTeamState(team, 'release A then verify B', 'executor', 2, repo);
|
|
6808
|
+
const taskA = await createTask(team, { subject: 'A', description: 'reassigned research', status: 'pending', requires_code_change: false }, repo);
|
|
6809
|
+
const config = await readTeamConfig(team, repo);
|
|
6810
|
+
assert.ok(config);
|
|
6811
|
+
Object.assign(config.workers[0], {
|
|
6812
|
+
assigned_tasks: [taskA.id], worktree_repo_root: repo,
|
|
6813
|
+
worktree_path: workerPath, worktree_branch: 'transfer-handoff-worker',
|
|
6814
|
+
});
|
|
6815
|
+
await saveTeamConfig(config, repo);
|
|
6816
|
+
const first = await claimTask(team, taskA.id, 'worker-1', null, repo);
|
|
6817
|
+
assert.ok(first.ok);
|
|
6818
|
+
assert.ok((await releaseTaskClaim(team, taskA.id, first.claimToken, 'worker-1', repo)).ok);
|
|
6819
|
+
const transferred = await claimTask(team, taskA.id, 'worker-2', null, repo);
|
|
6820
|
+
assert.ok(transferred.ok);
|
|
6821
|
+
assert.ok((await transitionTaskStatus(team, taskA.id, 'in_progress', 'completed', transferred.claimToken, repo, { result: 'Research A complete.' })).ok);
|
|
6822
|
+
await writeFile(join(workerPath, 'code-b.txt'), 'verified B after transferring A\n');
|
|
6823
|
+
execFileSync('git', ['add', 'code-b.txt'], { cwd: workerPath });
|
|
6824
|
+
execFileSync('git', ['commit', '-m', 'verified B'], { cwd: workerPath, stdio: 'ignore' });
|
|
6825
|
+
const taskB = await createTask(team, { subject: 'B', description: 'verified code', status: 'pending', requires_code_change: true }, repo);
|
|
6826
|
+
const claimB = await claimTask(team, taskB.id, 'worker-1', null, repo);
|
|
6827
|
+
assert.ok(claimB.ok);
|
|
6828
|
+
const verifiedHead = execFileSync('git', ['rev-parse', 'HEAD'], { cwd: workerPath, encoding: 'utf8' }).trim();
|
|
6829
|
+
await mkdir(join(workerPath, '.omx/evidence'), { recursive: true });
|
|
6830
|
+
await writeFile(join(workerPath, '.omx/evidence/b.json'), JSON.stringify({
|
|
6831
|
+
teamName: team, taskId: taskB.id,
|
|
6832
|
+
claimTokenSha256: createHash('sha256').update(claimB.claimToken).digest('hex'), verifiedHead,
|
|
6833
|
+
summary: 'Verified B', verification: [{ command: 'npm test', result: 'passed', output: 'B passed' }], unverified: [],
|
|
6834
|
+
}));
|
|
6835
|
+
const completed = await transitionTaskStatus(team, taskB.id, 'in_progress', 'completed', claimB.claimToken, repo, {
|
|
6836
|
+
result: 'Verification: PASS `npm test` for B.\nEVIDENCE_RECORDED: .omx/evidence/b.json',
|
|
6837
|
+
});
|
|
6838
|
+
assert.ok(completed.ok, JSON.stringify(completed));
|
|
6839
|
+
assert.equal(completed.task.verified_head, verifiedHead);
|
|
6840
|
+
await writeWorkerStatus(team, 'worker-1', { state: 'done', updated_at: new Date().toISOString() }, repo);
|
|
6841
|
+
assert.deepEqual((await readTeamConfig(team, repo))?.workers.map((worker) => worker.assigned_tasks), [[taskB.id], [taskA.id]]);
|
|
6842
|
+
await monitorTeam(team, repo);
|
|
6843
|
+
assert.equal(await readFile(join(repo, 'code-b.txt'), 'utf8'), 'verified B after transferring A\n');
|
|
6844
|
+
assert.ok((await readMonitorSnapshot(team, repo))?.integrationByWorker?.['worker-1']?.last_integrated_head);
|
|
6380
6845
|
}
|
|
6381
6846
|
finally {
|
|
6382
|
-
if (workerPath)
|
|
6847
|
+
if (workerPath)
|
|
6848
|
+
await rm(workerPath, { recursive: true, force: true });
|
|
6849
|
+
await rm(repo, { recursive: true, force: true });
|
|
6850
|
+
}
|
|
6851
|
+
});
|
|
6852
|
+
it('monitorTeam integrates verified code after exempt historical research completion', async () => {
|
|
6853
|
+
const repo = await initRepo();
|
|
6854
|
+
let workerPath = '';
|
|
6855
|
+
try {
|
|
6856
|
+
const team = 'team-research-code';
|
|
6857
|
+
workerPath = await addWorktree(repo, 'research-code-worker', 'omx-runtime-research-code-');
|
|
6858
|
+
await initTeamState(team, 'research then code', 'executor', 1, repo);
|
|
6859
|
+
const config = await readTeamConfig(team, repo);
|
|
6860
|
+
assert.ok(config);
|
|
6861
|
+
Object.assign(config.workers[0], { worktree_repo_root: repo, worktree_path: workerPath, worktree_branch: 'research-code-worker' });
|
|
6862
|
+
await saveTeamConfig(config, repo);
|
|
6863
|
+
const research = await createTask(team, { subject: 'research', description: 'read only', status: 'pending', requires_code_change: false }, repo);
|
|
6864
|
+
const claim = await claimTask(team, research.id, 'worker-1', null, repo);
|
|
6865
|
+
assert.ok(claim.ok);
|
|
6866
|
+
assert.ok((await transitionTaskStatus(team, research.id, 'in_progress', 'completed', claim.claimToken, repo, { result: 'Research findings delivered.' })).ok);
|
|
6867
|
+
await writeFile(join(workerPath, 'code.txt'), 'separately verified code\n');
|
|
6868
|
+
execFileSync('git', ['add', 'code.txt'], { cwd: workerPath });
|
|
6869
|
+
execFileSync('git', ['commit', '-m', 'verified code after research'], { cwd: workerPath, stdio: 'ignore' });
|
|
6870
|
+
await handOffVerifiedIntegrationTasks(team, repo);
|
|
6871
|
+
await monitorTeam(team, repo);
|
|
6872
|
+
assert.equal(await readFile(join(repo, 'code.txt'), 'utf8'), 'separately verified code\n');
|
|
6873
|
+
assert.ok((await readMonitorSnapshot(team, repo))?.integrationByWorker?.['worker-1']?.last_integrated_head);
|
|
6874
|
+
}
|
|
6875
|
+
finally {
|
|
6876
|
+
if (workerPath)
|
|
6383
6877
|
await rm(workerPath, { recursive: true, force: true });
|
|
6384
|
-
}
|
|
6385
6878
|
await rm(repo, { recursive: true, force: true });
|
|
6386
6879
|
}
|
|
6387
6880
|
});
|
|
6881
|
+
for (const scenario of ['working', 'idle-unfinished', 'idle-unverified', 'idle-missing-task', 'idle-other-owner', 'idle-unfinished-current', 'idle-unfinished-owned', 'idle-conflicting-claim']) {
|
|
6882
|
+
for (const dirty of [false, true]) {
|
|
6883
|
+
it(`monitorTeam leaves unfinished worker output local (${scenario}, ${dirty ? 'dirty' : 'clean'})`, async () => {
|
|
6884
|
+
const repo = await initRepo();
|
|
6885
|
+
let workerPath = '';
|
|
6886
|
+
try {
|
|
6887
|
+
const team = 'team-not-ready';
|
|
6888
|
+
workerPath = await addWorktree(repo, 'not-ready-worker', 'omx-runtime-not-ready-');
|
|
6889
|
+
await writeFile(join(workerPath, 'committed.txt'), 'not yet handed off\n');
|
|
6890
|
+
execFileSync('git', ['add', 'committed.txt'], { cwd: workerPath });
|
|
6891
|
+
execFileSync('git', ['commit', '-m', 'unfinished worker commit'], { cwd: workerPath, stdio: 'ignore' });
|
|
6892
|
+
await initTeamState(team, 'unsafe integration regression', 'executor', 1, repo);
|
|
6893
|
+
const task = await createTask(team, {
|
|
6894
|
+
subject: 'worker output', description: 'not safe until completed and verified',
|
|
6895
|
+
status: scenario === 'idle-unfinished' ? 'in_progress' : 'completed',
|
|
6896
|
+
owner: scenario === 'idle-other-owner' ? 'worker-2' : 'worker-1', requires_code_change: true,
|
|
6897
|
+
...(scenario === 'idle-unverified' ? {} : { result: 'Verification: PASS `npm test`.' }),
|
|
6898
|
+
...(scenario === 'idle-conflicting-claim' ? { claim: { owner: 'worker-2', token: 'other-claim', leased_until: new Date(Date.now() + 60_000).toISOString() } } : {}),
|
|
6899
|
+
}, repo);
|
|
6900
|
+
const extraTask = scenario === 'idle-unfinished-current' || scenario === 'idle-unfinished-owned'
|
|
6901
|
+
? await createTask(team, { subject: 'new ongoing work', description: 'must block integration', status: 'in_progress', ...(scenario === 'idle-unfinished-owned' ? { owner: 'worker-1' } : {}) }, repo)
|
|
6902
|
+
: undefined;
|
|
6903
|
+
const config = await readTeamConfig(team, repo);
|
|
6904
|
+
assert.ok(config);
|
|
6905
|
+
Object.assign(config.workers[0], {
|
|
6906
|
+
assigned_tasks: [scenario === 'idle-missing-task' ? 'missing' : task.id],
|
|
6907
|
+
worktree_repo_root: repo, worktree_path: workerPath, worktree_branch: 'not-ready-worker',
|
|
6908
|
+
});
|
|
6909
|
+
await saveTeamConfig(config, repo);
|
|
6910
|
+
if (scenario !== 'idle-unverified')
|
|
6911
|
+
await handOffVerifiedIntegrationTasks(team, repo);
|
|
6912
|
+
if (dirty)
|
|
6913
|
+
await writeFile(join(workerPath, 'dirty.txt'), 'half-written output\n');
|
|
6914
|
+
await writeWorkerStatus(team, 'worker-1', {
|
|
6915
|
+
state: scenario === 'working' ? 'working' : 'idle',
|
|
6916
|
+
...(scenario === 'idle-unfinished-current' ? { current_task_id: extraTask.id } : {}),
|
|
6917
|
+
updated_at: new Date().toISOString(),
|
|
6918
|
+
}, repo);
|
|
6919
|
+
const workerHead = execFileSync('git', ['rev-parse', 'HEAD'], { cwd: workerPath, encoding: 'utf8' }).trim();
|
|
6920
|
+
const leaderHead = execFileSync('git', ['rev-parse', 'HEAD'], { cwd: repo, encoding: 'utf8' }).trim();
|
|
6921
|
+
await monitorTeam(team, repo);
|
|
6922
|
+
assert.equal(execFileSync('git', ['rev-parse', 'HEAD'], { cwd: repo, encoding: 'utf8' }).trim(), leaderHead);
|
|
6923
|
+
assert.equal(execFileSync('git', ['rev-parse', 'HEAD'], { cwd: workerPath, encoding: 'utf8' }).trim(), workerHead);
|
|
6924
|
+
if (dirty) {
|
|
6925
|
+
assert.equal(await readFile(join(workerPath, 'dirty.txt'), 'utf8'), 'half-written output\n');
|
|
6926
|
+
assert.match(execFileSync('git', ['status', '--porcelain'], { cwd: workerPath, encoding: 'utf8' }), /dirty.txt/);
|
|
6927
|
+
}
|
|
6928
|
+
assert.equal(existsSync(join(repo, 'committed.txt')), false);
|
|
6929
|
+
assert.equal(existsSync(join(repo, 'dirty.txt')), false);
|
|
6930
|
+
const events = await readTeamEvents(team, repo, { wakeableOnly: false });
|
|
6931
|
+
assert.equal(events.some((event) => ['worker_auto_commit', 'worker_merge_applied', 'worker_cherry_pick_applied'].includes(event.type)), false);
|
|
6932
|
+
}
|
|
6933
|
+
finally {
|
|
6934
|
+
if (workerPath)
|
|
6935
|
+
await rm(workerPath, { recursive: true, force: true });
|
|
6936
|
+
await rm(repo, { recursive: true, force: true });
|
|
6937
|
+
}
|
|
6938
|
+
});
|
|
6939
|
+
}
|
|
6940
|
+
}
|
|
6388
6941
|
it('(#3717) monitorTeam does not commit runtime instructions to leader AGENTS.md', async () => {
|
|
6389
6942
|
const repo = await initRepo();
|
|
6390
6943
|
let workerPath = '';
|
|
@@ -6395,8 +6948,9 @@ esac
|
|
|
6395
6948
|
execFileSync('git', ['add', 'AGENTS.md'], { cwd: repo, stdio: 'ignore' });
|
|
6396
6949
|
execFileSync('git', ['commit', '-m', 'initial'], { cwd: repo, stdio: 'ignore' });
|
|
6397
6950
|
workerPath = await addWorktree(repo, 'wk1-agents-branch', 'omx-runtime-wk1-agents-');
|
|
6398
|
-
// Add uncommitted change in worker
|
|
6399
6951
|
await writeFile(join(workerPath, 'work.txt'), 'worker output\n', 'utf-8');
|
|
6952
|
+
execFileSync('git', ['add', 'work.txt'], { cwd: workerPath });
|
|
6953
|
+
execFileSync('git', ['commit', '-m', 'verified worker output'], { cwd: workerPath, stdio: 'ignore' });
|
|
6400
6954
|
await initTeamState('team-agents-check', 'agents regression test', 'executor', 1, repo);
|
|
6401
6955
|
const cfg = await readTeamConfig('team-agents-check', repo);
|
|
6402
6956
|
assert.ok(cfg);
|
|
@@ -6413,23 +6967,15 @@ esac
|
|
|
6413
6967
|
worktree_created: false,
|
|
6414
6968
|
};
|
|
6415
6969
|
await saveTeamConfig(cfg, repo);
|
|
6970
|
+
await handOffVerifiedIntegrationTasks('team-agents-check', repo);
|
|
6416
6971
|
await monitorTeam('team-agents-check', repo);
|
|
6417
6972
|
// Verify leader AGENTS.md is byte-identical to original
|
|
6418
6973
|
const leaderAgentsAfter = await readFile(join(repo, 'AGENTS.md'), 'utf-8');
|
|
6419
6974
|
assert.equal(leaderAgentsAfter, originalAgents, 'leader AGENTS.md should not be modified by team operations');
|
|
6420
|
-
|
|
6421
|
-
const log = execFileSync('git', ['log', '--
|
|
6422
|
-
assert.match(log, /
|
|
6423
|
-
|
|
6424
|
-
const autoCheckpointCommit = execFileSync('git', ['log', '--oneline', '--all'], { cwd: workerPath, encoding: 'utf-8' })
|
|
6425
|
-
.split('\n')
|
|
6426
|
-
.find((line) => line.includes('auto-checkpoint'));
|
|
6427
|
-
assert.ok(autoCheckpointCommit, 'auto-checkpoint commit should exist');
|
|
6428
|
-
if (autoCheckpointCommit) {
|
|
6429
|
-
const commitSha = autoCheckpointCommit.split(' ')[0];
|
|
6430
|
-
const diff = execFileSync('git', ['diff', `${commitSha}^..${commitSha}`, '--name-only'], { cwd: workerPath, encoding: 'utf-8' });
|
|
6431
|
-
assert.doesNotMatch(diff, /AGENTS\.md/, 'auto-checkpoint should not include AGENTS.md');
|
|
6432
|
-
}
|
|
6975
|
+
assert.equal(await readFile(join(repo, 'work.txt'), 'utf8'), 'worker output\n');
|
|
6976
|
+
const log = execFileSync('git', ['log', '--format=%s'], { cwd: repo, encoding: 'utf8' });
|
|
6977
|
+
assert.match(log, /merge/);
|
|
6978
|
+
assert.doesNotMatch(log, /auto-checkpoint/);
|
|
6433
6979
|
}
|
|
6434
6980
|
finally {
|
|
6435
6981
|
if (workerPath) {
|
|
@@ -6464,6 +7010,7 @@ esac
|
|
|
6464
7010
|
worktree_created: false,
|
|
6465
7011
|
};
|
|
6466
7012
|
await saveTeamConfig(cfg, repo);
|
|
7013
|
+
await handOffVerifiedIntegrationTasks('team-merge-clean', repo);
|
|
6467
7014
|
await monitorTeam('team-merge-clean', repo);
|
|
6468
7015
|
// Verify worker content is on leader
|
|
6469
7016
|
const content = await readFile(join(repo, 'feature.txt'), 'utf-8');
|
|
@@ -6511,6 +7058,7 @@ esac
|
|
|
6511
7058
|
worktree_created: false,
|
|
6512
7059
|
};
|
|
6513
7060
|
await saveTeamConfig(cfg, repo);
|
|
7061
|
+
await handOffVerifiedIntegrationTasks('team-merge-detached', repo);
|
|
6514
7062
|
await monitorTeam('team-merge-detached', repo);
|
|
6515
7063
|
const leaderHeadAfter = execFileSync('git', ['rev-parse', 'HEAD'], { cwd: repo, encoding: 'utf-8' }).trim();
|
|
6516
7064
|
assert.notEqual(leaderHeadAfter, leaderHeadBefore, 'leader HEAD should advance for detached worker integration');
|
|
@@ -6564,6 +7112,7 @@ esac
|
|
|
6564
7112
|
worktree_created: false,
|
|
6565
7113
|
};
|
|
6566
7114
|
await saveTeamConfig(cfg, repo);
|
|
7115
|
+
await handOffVerifiedIntegrationTasks('team-merge-noadvance', repo);
|
|
6567
7116
|
const realGit = execFileSync('bash', ['-lc', 'command -v git'], { encoding: 'utf-8' }).trim();
|
|
6568
7117
|
await writeFile(join(fakeBinDir, 'git'), `#!/usr/bin/env bash
|
|
6569
7118
|
set -euo pipefail
|
|
@@ -6632,6 +7181,7 @@ exec "${realGit}" "$@"
|
|
|
6632
7181
|
worktree_created: false,
|
|
6633
7182
|
};
|
|
6634
7183
|
await saveTeamConfig(cfg, repo);
|
|
7184
|
+
await handOffVerifiedIntegrationTasks('team-diverged', repo);
|
|
6635
7185
|
await monitorTeam('team-diverged', repo);
|
|
6636
7186
|
// Verify both contents are on leader
|
|
6637
7187
|
assert.equal(await readFile(join(repo, 'worker-file.txt'), 'utf-8'), 'worker content\n');
|
|
@@ -6691,6 +7241,7 @@ exec "${realGit}" "$@"
|
|
|
6691
7241
|
worktree_created: false,
|
|
6692
7242
|
};
|
|
6693
7243
|
await saveTeamConfig(cfg, repo);
|
|
7244
|
+
await handOffVerifiedIntegrationTasks('team-cross-rebase', repo);
|
|
6694
7245
|
// Set worker-2 status to idle (eligible for rebase)
|
|
6695
7246
|
await writeWorkerStatus('team-cross-rebase', 'worker-2', { state: 'idle', updated_at: new Date().toISOString() }, repo);
|
|
6696
7247
|
await monitorTeam('team-cross-rebase', repo);
|
|
@@ -6748,6 +7299,7 @@ exec "${realGit}" "$@"
|
|
|
6748
7299
|
};
|
|
6749
7300
|
await saveTeamConfig(cfg, repo);
|
|
6750
7301
|
await handOffVerifiedIntegrationTasks('team-conflict-resolve', repo);
|
|
7302
|
+
await handOffVerifiedIntegrationTasks('team-conflict-resolve', repo);
|
|
6751
7303
|
await monitorTeam('team-conflict-resolve', repo);
|
|
6752
7304
|
assert.equal(await readFile(join(repo, 'README.md'), 'utf-8'), 'leader version\n');
|
|
6753
7305
|
assert.equal(await readFile(join(workerPath, 'README.md'), 'utf-8'), 'worker version\n');
|
|
@@ -6807,6 +7359,7 @@ exec "${realGit}" "$@"
|
|
|
6807
7359
|
worktree_created: false,
|
|
6808
7360
|
};
|
|
6809
7361
|
await saveTeamConfig(cfg, repo);
|
|
7362
|
+
await handOffVerifiedIntegrationTasks('team-rebase-gate', repo);
|
|
6810
7363
|
// Set worker-2 status to "working" (NOT eligible for rebase)
|
|
6811
7364
|
await writeWorkerStatus('team-rebase-gate', 'worker-2', { state: 'working', updated_at: new Date().toISOString() }, repo);
|
|
6812
7365
|
await monitorTeam('team-rebase-gate', repo);
|
|
@@ -6867,6 +7420,7 @@ exec "${realGit}" "$@"
|
|
|
6867
7420
|
worktree_created: false,
|
|
6868
7421
|
};
|
|
6869
7422
|
await saveTeamConfig(cfg, repo);
|
|
7423
|
+
await handOffVerifiedIntegrationTasks('team-rebase-fail', repo);
|
|
6870
7424
|
// Set worker-2 status to idle (eligible for rebase attempt)
|
|
6871
7425
|
await writeWorkerStatus('team-rebase-fail', 'worker-2', { state: 'idle', updated_at: new Date().toISOString() }, repo);
|
|
6872
7426
|
await handOffVerifiedIntegrationTasks('team-rebase-fail', repo);
|