oh-my-codex 0.21.48 → 0.22.1
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/README.md +15 -0
- package/crates/omx-mux/src/herdr.rs +481 -0
- package/crates/omx-mux/src/lib.rs +5 -0
- 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/__tests__/session-compare.test.d.ts +2 -0
- package/dist/cli/__tests__/session-compare.test.d.ts.map +1 -0
- package/dist/cli/__tests__/session-compare.test.js +183 -0
- package/dist/cli/__tests__/session-compare.test.js.map +1 -0
- package/dist/cli/__tests__/team.test.js +8 -0
- package/dist/cli/__tests__/team.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/cli/session-compare.d.ts +11 -0
- package/dist/cli/session-compare.d.ts.map +1 -0
- package/dist/cli/session-compare.js +172 -0
- package/dist/cli/session-compare.js.map +1 -0
- package/dist/cli/session-search.d.ts.map +1 -1
- package/dist/cli/session-search.js +7 -0
- package/dist/cli/session-search.js.map +1 -1
- package/dist/cli/team.d.ts.map +1 -1
- package/dist/cli/team.js +2 -0
- package/dist/cli/team.js.map +1 -1
- package/dist/config/__tests__/multiplexer.test.d.ts +2 -0
- package/dist/config/__tests__/multiplexer.test.d.ts.map +1 -0
- package/dist/config/__tests__/multiplexer.test.js +118 -0
- package/dist/config/__tests__/multiplexer.test.js.map +1 -0
- package/dist/config/multiplexer.d.ts +29 -0
- package/dist/config/multiplexer.d.ts.map +1 -0
- package/dist/config/multiplexer.js +91 -0
- package/dist/config/multiplexer.js.map +1 -0
- 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/scripts/__tests__/codex-native-hook.test.js +281 -1
- package/dist/scripts/__tests__/codex-native-hook.test.js.map +1 -1
- package/dist/scripts/codex-native-hook.d.ts.map +1 -1
- package/dist/scripts/codex-native-hook.js +8 -2
- package/dist/scripts/codex-native-hook.js.map +1 -1
- package/dist/scripts/notify-hook/team-worker-lease.d.ts +15 -0
- package/dist/scripts/notify-hook/team-worker-lease.d.ts.map +1 -0
- package/dist/scripts/notify-hook/team-worker-lease.js +63 -0
- package/dist/scripts/notify-hook/team-worker-lease.js.map +1 -0
- package/dist/scripts/notify-hook/team-worker-posttooluse.d.ts +1 -0
- package/dist/scripts/notify-hook/team-worker-posttooluse.d.ts.map +1 -1
- package/dist/scripts/notify-hook/team-worker-posttooluse.js +16 -5
- package/dist/scripts/notify-hook/team-worker-posttooluse.js.map +1 -1
- package/dist/scripts/notify-hook/team-worker.d.ts +12 -1
- package/dist/scripts/notify-hook/team-worker.d.ts.map +1 -1
- package/dist/scripts/notify-hook/team-worker.js +16 -4
- package/dist/scripts/notify-hook/team-worker.js.map +1 -1
- package/dist/session-history/__tests__/compare.test.d.ts +2 -0
- package/dist/session-history/__tests__/compare.test.d.ts.map +1 -0
- package/dist/session-history/__tests__/compare.test.js +257 -0
- package/dist/session-history/__tests__/compare.test.js.map +1 -0
- package/dist/session-history/compare.d.ts +74 -0
- package/dist/session-history/compare.d.ts.map +1 -0
- package/dist/session-history/compare.js +165 -0
- package/dist/session-history/compare.js.map +1 -0
- package/dist/team/__tests__/api-interop.test.js +3 -3
- 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__/cross-rebase-smoke.test.js +263 -31
- package/dist/team/__tests__/cross-rebase-smoke.test.js.map +1 -1
- package/dist/team/__tests__/herdr-session-realherdr.test.d.ts +2 -0
- package/dist/team/__tests__/herdr-session-realherdr.test.d.ts.map +1 -0
- package/dist/team/__tests__/herdr-session-realherdr.test.js +68 -0
- package/dist/team/__tests__/herdr-session-realherdr.test.js.map +1 -0
- package/dist/team/__tests__/herdr-session.test.d.ts +2 -0
- package/dist/team/__tests__/herdr-session.test.d.ts.map +1 -0
- package/dist/team/__tests__/herdr-session.test.js +228 -0
- package/dist/team/__tests__/herdr-session.test.js.map +1 -0
- 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__/idle-nudge.test.js +84 -0
- package/dist/team/__tests__/idle-nudge.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__/rebalance-policy.test.js +27 -9
- package/dist/team/__tests__/rebalance-policy.test.js.map +1 -1
- package/dist/team/__tests__/runtime-delivery.test.d.ts +2 -0
- package/dist/team/__tests__/runtime-delivery.test.d.ts.map +1 -0
- package/dist/team/__tests__/runtime-delivery.test.js +570 -0
- package/dist/team/__tests__/runtime-delivery.test.js.map +1 -0
- package/dist/team/__tests__/runtime.test.js +938 -70
- package/dist/team/__tests__/runtime.test.js.map +1 -1
- package/dist/team/__tests__/scaling.test.js +645 -1
- package/dist/team/__tests__/scaling.test.js.map +1 -1
- package/dist/team/__tests__/state-renewal.test.d.ts +2 -0
- package/dist/team/__tests__/state-renewal.test.d.ts.map +1 -0
- package/dist/team/__tests__/state-renewal.test.js +555 -0
- package/dist/team/__tests__/state-renewal.test.js.map +1 -0
- package/dist/team/__tests__/state.test.js +121 -2
- package/dist/team/__tests__/state.test.js.map +1 -1
- package/dist/team/__tests__/task-lease.test.d.ts +2 -0
- package/dist/team/__tests__/task-lease.test.d.ts.map +1 -0
- package/dist/team/__tests__/task-lease.test.js +179 -0
- package/dist/team/__tests__/task-lease.test.js.map +1 -0
- package/dist/team/__tests__/team-ops-contract.test.js +1 -0
- package/dist/team/__tests__/team-ops-contract.test.js.map +1 -1
- package/dist/team/__tests__/worker-bootstrap.test.js +2 -0
- package/dist/team/__tests__/worker-bootstrap.test.js.map +1 -1
- package/dist/team/api-interop.d.ts +1 -1
- package/dist/team/api-interop.d.ts.map +1 -1
- package/dist/team/api-interop.js +13 -1
- package/dist/team/api-interop.js.map +1 -1
- package/dist/team/completion-evidence.d.ts +1 -1
- package/dist/team/completion-evidence.d.ts.map +1 -1
- package/dist/team/completion-evidence.js +9 -0
- package/dist/team/completion-evidence.js.map +1 -1
- package/dist/team/goal-workflow.js +1 -1
- package/dist/team/herdr-session.d.ts +234 -0
- package/dist/team/herdr-session.d.ts.map +1 -0
- package/dist/team/herdr-session.js +489 -0
- package/dist/team/herdr-session.js.map +1 -0
- package/dist/team/idle-nudge.d.ts +16 -4
- package/dist/team/idle-nudge.d.ts.map +1 -1
- package/dist/team/idle-nudge.js +51 -19
- package/dist/team/idle-nudge.js.map +1 -1
- package/dist/team/mcp-comm.d.ts +6 -4
- 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/rebalance-policy.d.ts.map +1 -1
- package/dist/team/rebalance-policy.js +5 -2
- package/dist/team/rebalance-policy.js.map +1 -1
- package/dist/team/runtime.d.ts.map +1 -1
- package/dist/team/runtime.js +463 -166
- 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 +394 -200
- package/dist/team/scaling.js.map +1 -1
- package/dist/team/state/monitor.d.ts +3 -0
- package/dist/team/state/monitor.d.ts.map +1 -1
- package/dist/team/state/monitor.js +3 -0
- package/dist/team/state/monitor.js.map +1 -1
- package/dist/team/state/tasks.d.ts +4 -1
- package/dist/team/state/tasks.d.ts.map +1 -1
- package/dist/team/state/tasks.js +36 -5
- package/dist/team/state/tasks.js.map +1 -1
- package/dist/team/state/types.d.ts +9 -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 +15 -2
- package/dist/team/state.d.ts.map +1 -1
- package/dist/team/state.js +73 -5
- package/dist/team/state.js.map +1 -1
- package/dist/team/task-lease.d.ts +4 -0
- package/dist/team/task-lease.d.ts.map +1 -0
- package/dist/team/task-lease.js +74 -0
- package/dist/team/task-lease.js.map +1 -0
- package/dist/team/team-ops.d.ts +2 -1
- package/dist/team/team-ops.d.ts.map +1 -1
- package/dist/team/team-ops.js +1 -0
- package/dist/team/team-ops.js.map +1 -1
- package/dist/team/tmux-session.d.ts +1 -1
- package/dist/team/tmux-session.d.ts.map +1 -1
- package/dist/team/tmux-session.js +10 -2
- package/dist/team/tmux-session.js.map +1 -1
- package/dist/team/worker-bootstrap.d.ts.map +1 -1
- package/dist/team/worker-bootstrap.js +16 -3
- package/dist/team/worker-bootstrap.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
- package/plugins/oh-my-codex/skills/worker/SKILL.md +7 -1
- package/skills/worker/SKILL.md +7 -1
- package/src/scripts/__tests__/codex-native-hook.test.ts +279 -0
- package/src/scripts/codex-native-hook.ts +8 -2
- package/src/scripts/notify-hook/team-worker-lease.ts +69 -0
- package/src/scripts/notify-hook/team-worker-posttooluse.ts +16 -4
- package/src/scripts/notify-hook/team-worker.ts +15 -4
|
@@ -8,7 +8,7 @@ import { pathToFileURL } from "node:url";
|
|
|
8
8
|
import { afterEach, beforeEach, describe, it } from "node:test";
|
|
9
9
|
import { buildManagedCodexHooksConfig } from "../../config/codex-hooks.js";
|
|
10
10
|
import { DOCUMENT_REFRESH_EXEMPTION_PREFIX } from "../../document-refresh/enforcer.js";
|
|
11
|
-
import { initTeamState, readTeamLeaderAttention, readTeamPhase, writeTeamLeaderAttention, } from "../../team/state.js";
|
|
11
|
+
import { initTeamState, createTask, claimTask, withTeamTaskBarrier, transitionTaskStatus, writeWorkerStatus, readTeamLeaderAttention, readTeamPhase, writeTeamLeaderAttention, } from "../../team/state.js";
|
|
12
12
|
import { registerTeamNotice } from "../../team/notice-ledger.js";
|
|
13
13
|
import { dispatchCodexNativeHook, isSloppyFallbackTranscriptStartUsable, readUnambiguousSessionStartNativeId, resolvePersistedReopenRootContext, isCodexNativeHookMainModule, looksLikeGoalCompletionPrompt, mapCodexHookEventToOmxEvent, resolveSessionOwnerPidFromAncestry, } from "../codex-native-hook.js";
|
|
14
14
|
import { closeLaunchSessionBindingOnce, establishLaunchSessionBinding, finalizeBoundOnce, updateDetachedSessionMetadata, writeNativeSessionOwner, writeSessionStart, } from "../../hooks/session.js";
|
|
@@ -13263,6 +13263,286 @@ exit 0
|
|
|
13263
13263
|
await rm(cwd, { recursive: true, force: true });
|
|
13264
13264
|
}
|
|
13265
13265
|
});
|
|
13266
|
+
it("renews the captured claim on real-wire plain-string PostToolUse without checkpoint or dedupe", async () => {
|
|
13267
|
+
const cwd = await mkdtemp(join(tmpdir(), "omx-native-hook-real-wire-renewal-"));
|
|
13268
|
+
const teamName = "native-real-wire";
|
|
13269
|
+
const stateRoot = join(cwd, ".omx/state");
|
|
13270
|
+
try {
|
|
13271
|
+
await configureAuthoritativeTeamWorker(cwd, teamName);
|
|
13272
|
+
const task = await createTask(teamName, { subject: "work", description: "work", status: "pending" }, cwd);
|
|
13273
|
+
const claim = await claimTask(teamName, task.id, "worker-1", null, cwd);
|
|
13274
|
+
assert.ok(claim.ok);
|
|
13275
|
+
const workerRoot = join(stateRoot, "team", teamName, "workers/worker-1");
|
|
13276
|
+
await writeWorkerStatus(teamName, "worker-1", {
|
|
13277
|
+
state: "working", current_task_id: task.id, current_claim_token: claim.claimToken, updated_at: new Date().toISOString(),
|
|
13278
|
+
}, cwd);
|
|
13279
|
+
const result = await dispatchCodexNativeHook({
|
|
13280
|
+
hook_event_name: "PostToolUse", cwd, tool_name: "Bash", tool_use_id: "real-wire-renewal",
|
|
13281
|
+
tool_input: { command: "printf ok" }, tool_response: "ok\n",
|
|
13282
|
+
}, { cwd });
|
|
13283
|
+
assert.doesNotMatch(JSON.stringify(result.outputJson), /LEASE LOST|STOP editing/);
|
|
13284
|
+
const after = JSON.parse(await readFile(join(stateRoot, "team", teamName, "tasks", `task-${task.id}.json`), "utf8"));
|
|
13285
|
+
assert.equal(after.version, claim.task.version + 1);
|
|
13286
|
+
assert.equal(after.claim.token, claim.claimToken);
|
|
13287
|
+
assert.equal(JSON.parse(await readFile(join(workerRoot, "heartbeat.json"), "utf8")).source, "posttooluse");
|
|
13288
|
+
assert.equal(existsSync(join(workerRoot, "posttooluse-dedupe.json")), false);
|
|
13289
|
+
assert.equal(existsSync(join(cwd, ".omx/reports/team-commit-hygiene", `${teamName}.ledger.json`)), false);
|
|
13290
|
+
}
|
|
13291
|
+
finally {
|
|
13292
|
+
await rm(cwd, { recursive: true, force: true });
|
|
13293
|
+
}
|
|
13294
|
+
});
|
|
13295
|
+
for (const outcome of ['live', 'expired', 'wrong-token']) {
|
|
13296
|
+
it(`heartbeat directory does not bypass native PostToolUse ${outcome === 'live' ? 'renewal' : 'STOP'} for a ${outcome} claim`, async () => {
|
|
13297
|
+
const cwd = await mkdtemp(join(tmpdir(), "omx-native-hook-heartbeat-io-"));
|
|
13298
|
+
const teamName = "native-heartbeat-io";
|
|
13299
|
+
const stateRoot = join(cwd, ".omx/state");
|
|
13300
|
+
try {
|
|
13301
|
+
await configureAuthoritativeTeamWorker(cwd, teamName);
|
|
13302
|
+
const task = await createTask(teamName, { subject: "work", description: "work", status: "pending" }, cwd);
|
|
13303
|
+
const claim = await claimTask(teamName, task.id, "worker-1", null, cwd);
|
|
13304
|
+
assert.ok(claim.ok);
|
|
13305
|
+
const workerRoot = join(stateRoot, "team", teamName, "workers/worker-1");
|
|
13306
|
+
await writeWorkerStatus(teamName, "worker-1", {
|
|
13307
|
+
state: "working", current_task_id: task.id,
|
|
13308
|
+
current_claim_token: outcome === 'wrong-token' ? 'wrong-captured-token' : claim.claimToken,
|
|
13309
|
+
updated_at: new Date().toISOString(),
|
|
13310
|
+
}, cwd);
|
|
13311
|
+
await mkdir(join(workerRoot, "heartbeat.json"));
|
|
13312
|
+
const taskPath = join(stateRoot, "team", teamName, "tasks", `task-${task.id}.json`);
|
|
13313
|
+
if (outcome !== 'wrong-token') {
|
|
13314
|
+
await writeJson(taskPath, { ...claim.task, claim: { ...claim.task.claim, leased_until: new Date(outcome === 'expired' ? 0 : Date.now() + 60_000).toISOString() } });
|
|
13315
|
+
}
|
|
13316
|
+
const taskBefore = await readFile(taskPath, "utf8");
|
|
13317
|
+
const statusBefore = await readFile(join(workerRoot, "status.json"), "utf8");
|
|
13318
|
+
const git = (args) => execFileSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
13319
|
+
git(["init"]);
|
|
13320
|
+
git(["config", "user.email", "test@example.com"]);
|
|
13321
|
+
git(["config", "user.name", "Test User"]);
|
|
13322
|
+
await writeFile(join(cwd, "work.txt"), "before\n");
|
|
13323
|
+
git(["add", "work.txt"]);
|
|
13324
|
+
git(["commit", "-m", "initial"]);
|
|
13325
|
+
const head = git(["rev-parse", "HEAD"]);
|
|
13326
|
+
await writeFile(join(cwd, "work.txt"), "unverified output\n");
|
|
13327
|
+
const result = await dispatchCodexNativeHook({
|
|
13328
|
+
hook_event_name: "PostToolUse", cwd, tool_name: "Bash", tool_use_id: "heartbeat-io",
|
|
13329
|
+
tool_input: { command: "printf ok" }, tool_response: "plain stdout/stderr\n",
|
|
13330
|
+
}, { cwd });
|
|
13331
|
+
if (outcome === 'live') {
|
|
13332
|
+
assert.doesNotMatch(JSON.stringify(result.outputJson), /LEASE LOST|STOP editing/);
|
|
13333
|
+
const after = JSON.parse(await readFile(taskPath, "utf8"));
|
|
13334
|
+
assert.equal(after.version, claim.task.version + 1);
|
|
13335
|
+
assert.equal(after.claim.token, claim.claimToken);
|
|
13336
|
+
assert.ok(Date.parse(after.claim.leased_until) > Date.parse(JSON.parse(taskBefore).claim.leased_until));
|
|
13337
|
+
}
|
|
13338
|
+
else {
|
|
13339
|
+
const stop = outcome === 'expired' ? /lease_expired.*STOP editing/ : /claim_conflict.*STOP editing/;
|
|
13340
|
+
assert.match(String(result.outputJson?.systemMessage), stop);
|
|
13341
|
+
const hookOutput = result.outputJson?.hookSpecificOutput;
|
|
13342
|
+
assert.equal(hookOutput.additionalContext, result.outputJson?.systemMessage);
|
|
13343
|
+
assert.equal(await readFile(taskPath, "utf8"), taskBefore);
|
|
13344
|
+
assert.match(await readFile(join(workerRoot, "lease-loss.json"), "utf8"), stop);
|
|
13345
|
+
}
|
|
13346
|
+
assert.equal(await readFile(join(workerRoot, "status.json"), "utf8"), statusBefore);
|
|
13347
|
+
assert.equal(existsSync(join(workerRoot, "posttooluse-dedupe.json")), false);
|
|
13348
|
+
assert.equal(existsSync(join(cwd, ".omx/reports/team-commit-hygiene", `${teamName}.ledger.json`)), false);
|
|
13349
|
+
assert.equal(git(["rev-parse", "HEAD"]), head);
|
|
13350
|
+
assert.equal(git(["diff", "--cached"]), "");
|
|
13351
|
+
assert.equal(await readFile(join(cwd, "work.txt"), "utf8"), "unverified output\n");
|
|
13352
|
+
}
|
|
13353
|
+
finally {
|
|
13354
|
+
await rm(cwd, { recursive: true, force: true });
|
|
13355
|
+
}
|
|
13356
|
+
});
|
|
13357
|
+
}
|
|
13358
|
+
it("surfaces unexpected status I/O as native real-wire PostToolUse STOP without task mutation", async () => {
|
|
13359
|
+
const cwd = await mkdtemp(join(tmpdir(), "omx-native-hook-status-io-"));
|
|
13360
|
+
const teamName = "native-status-io";
|
|
13361
|
+
const stateRoot = join(cwd, ".omx/state");
|
|
13362
|
+
try {
|
|
13363
|
+
await configureAuthoritativeTeamWorker(cwd, teamName);
|
|
13364
|
+
const task = await createTask(teamName, { subject: "work", description: "work", status: "pending" }, cwd);
|
|
13365
|
+
const claim = await claimTask(teamName, task.id, "worker-1", null, cwd);
|
|
13366
|
+
assert.ok(claim.ok);
|
|
13367
|
+
const workerRoot = join(stateRoot, "team", teamName, "workers/worker-1");
|
|
13368
|
+
await mkdir(join(workerRoot, "status.json"));
|
|
13369
|
+
const taskPath = join(stateRoot, "team", teamName, "tasks", `task-${task.id}.json`);
|
|
13370
|
+
const taskBefore = await readFile(taskPath, "utf8");
|
|
13371
|
+
const git = (args) => execFileSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
13372
|
+
git(["init"]);
|
|
13373
|
+
git(["config", "user.email", "test@example.com"]);
|
|
13374
|
+
git(["config", "user.name", "Test User"]);
|
|
13375
|
+
await writeFile(join(cwd, "work.txt"), "before\n");
|
|
13376
|
+
git(["add", "work.txt"]);
|
|
13377
|
+
git(["commit", "-m", "initial"]);
|
|
13378
|
+
const head = git(["rev-parse", "HEAD"]);
|
|
13379
|
+
await writeFile(join(cwd, "work.txt"), "unverified output\n");
|
|
13380
|
+
const result = await dispatchCodexNativeHook({
|
|
13381
|
+
hook_event_name: "PostToolUse", cwd, tool_name: "Bash", tool_use_id: "status-io",
|
|
13382
|
+
tool_input: { command: "printf ok" }, tool_response: "plain stdout/stderr\n",
|
|
13383
|
+
}, { cwd });
|
|
13384
|
+
assert.match(String(result.outputJson?.systemMessage), /LEASE LOST:.*renewal_error:.*EISDIR.*STOP editing/);
|
|
13385
|
+
const hookOutput = result.outputJson?.hookSpecificOutput;
|
|
13386
|
+
assert.equal(hookOutput.additionalContext, result.outputJson?.systemMessage);
|
|
13387
|
+
assert.equal(await readFile(taskPath, "utf8"), taskBefore);
|
|
13388
|
+
assert.equal(existsSync(join(workerRoot, "posttooluse-dedupe.json")), false);
|
|
13389
|
+
assert.equal(existsSync(join(cwd, ".omx/reports/team-commit-hygiene", `${teamName}.ledger.json`)), false);
|
|
13390
|
+
assert.match(await readFile(join(workerRoot, "lease-loss.json"), "utf8"), /EISDIR.*STOP editing/);
|
|
13391
|
+
assert.equal(git(["rev-parse", "HEAD"]), head);
|
|
13392
|
+
assert.equal(git(["diff", "--cached"]), "");
|
|
13393
|
+
assert.equal(await readFile(join(cwd, "work.txt"), "utf8"), "unverified output\n");
|
|
13394
|
+
}
|
|
13395
|
+
finally {
|
|
13396
|
+
await rm(cwd, { recursive: true, force: true });
|
|
13397
|
+
}
|
|
13398
|
+
});
|
|
13399
|
+
it("surfaces lease loss from PostToolUse without checkpointing stale work", async () => {
|
|
13400
|
+
const cwd = await mkdtemp(join(tmpdir(), "omx-native-hook-lease-loss-"));
|
|
13401
|
+
const teamName = "native-lease-loss";
|
|
13402
|
+
const stateRoot = join(cwd, ".omx/state");
|
|
13403
|
+
try {
|
|
13404
|
+
await configureAuthoritativeTeamWorker(cwd, teamName);
|
|
13405
|
+
const task = await createTask(teamName, { subject: "work", description: "work", status: "pending" }, cwd);
|
|
13406
|
+
const claim = await claimTask(teamName, task.id, "worker-1", null, cwd);
|
|
13407
|
+
assert.ok(claim.ok);
|
|
13408
|
+
const workerRoot = join(stateRoot, "team", teamName, "workers/worker-1");
|
|
13409
|
+
await writeJson(join(workerRoot, "status.json"), {
|
|
13410
|
+
state: "working", current_task_id: task.id, current_claim_token: claim.claimToken,
|
|
13411
|
+
});
|
|
13412
|
+
const taskPath = join(stateRoot, "team", teamName, "tasks", `task-${task.id}.json`);
|
|
13413
|
+
await writeJson(taskPath, { ...claim.task, claim: { ...claim.task.claim, leased_until: new Date(0).toISOString() } });
|
|
13414
|
+
process.env.OMX_TEAM_INTERNAL_WORKER = `${teamName}/worker-1`;
|
|
13415
|
+
process.env.OMX_TEAM_WORKER = `${teamName}/worker-1`;
|
|
13416
|
+
process.env.OMX_TEAM_STATE_ROOT = stateRoot;
|
|
13417
|
+
const result = await dispatchCodexNativeHook({
|
|
13418
|
+
hook_event_name: "PostToolUse", cwd, tool_name: "Bash",
|
|
13419
|
+
tool_input: { command: "printf ok" }, tool_response: "ok\n",
|
|
13420
|
+
}, { cwd });
|
|
13421
|
+
assert.match(String(result.outputJson?.systemMessage), /LEASE LOST:.*lease_expired.*STOP editing/);
|
|
13422
|
+
const hookOutput = result.outputJson?.hookSpecificOutput;
|
|
13423
|
+
assert.equal(hookOutput.additionalContext, result.outputJson?.systemMessage);
|
|
13424
|
+
assert.equal(existsSync(join(workerRoot, "posttooluse-dedupe.json")), false);
|
|
13425
|
+
assert.equal(existsSync(join(workerRoot, "lease-loss.json")), true);
|
|
13426
|
+
}
|
|
13427
|
+
finally {
|
|
13428
|
+
await rm(cwd, { recursive: true, force: true });
|
|
13429
|
+
}
|
|
13430
|
+
});
|
|
13431
|
+
for (const terminalStatus of ['completed', 'failed']) {
|
|
13432
|
+
it(`allows separate idle status after native PostToolUse for an own ${terminalStatus} handoff without checkpointing`, async () => {
|
|
13433
|
+
const cwd = await mkdtemp(join(tmpdir(), "omx-native-hook-terminal-handoff-"));
|
|
13434
|
+
const teamName = "native-terminal-handoff";
|
|
13435
|
+
const stateRoot = join(cwd, ".omx/state");
|
|
13436
|
+
try {
|
|
13437
|
+
await configureAuthoritativeTeamWorker(cwd, teamName);
|
|
13438
|
+
const task = await createTask(teamName, { subject: "research", description: "no code", status: "pending", requires_code_change: false }, cwd);
|
|
13439
|
+
await createTask(teamName, { subject: "other ongoing work", description: "keep team active", status: "pending" }, cwd);
|
|
13440
|
+
const claim = await claimTask(teamName, task.id, "worker-1", null, cwd);
|
|
13441
|
+
assert.ok(claim.ok);
|
|
13442
|
+
await writeWorkerStatus(teamName, "worker-1", {
|
|
13443
|
+
state: "working", current_task_id: task.id, current_claim_token: claim.claimToken, updated_at: new Date().toISOString(),
|
|
13444
|
+
}, cwd);
|
|
13445
|
+
const workerRoot = join(stateRoot, "team", teamName, "workers/worker-1");
|
|
13446
|
+
const statusPath = join(workerRoot, "status.json");
|
|
13447
|
+
const taskPath = join(stateRoot, "team", teamName, "tasks", `task-${task.id}.json`);
|
|
13448
|
+
assert.ok((await transitionTaskStatus(teamName, task.id, "in_progress", terminalStatus, claim.claimToken, cwd, {
|
|
13449
|
+
result: "Research complete; no code changes.", error: "Research could not finish.",
|
|
13450
|
+
})).ok);
|
|
13451
|
+
const statusBefore = await readFile(statusPath, "utf8");
|
|
13452
|
+
const taskBefore = await readFile(taskPath, "utf8");
|
|
13453
|
+
const git = (args) => execFileSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
13454
|
+
git(["init"]);
|
|
13455
|
+
git(["config", "user.email", "test@example.com"]);
|
|
13456
|
+
git(["config", "user.name", "Test User"]);
|
|
13457
|
+
await writeFile(join(cwd, "work.txt"), "before\n");
|
|
13458
|
+
git(["add", "work.txt"]);
|
|
13459
|
+
git(["commit", "-m", "initial"]);
|
|
13460
|
+
const headBefore = git(["rev-parse", "HEAD"]);
|
|
13461
|
+
await writeFile(join(cwd, "work.txt"), "unverified terminal edits\n");
|
|
13462
|
+
const result = await dispatchCodexNativeHook({
|
|
13463
|
+
hook_event_name: "PostToolUse", cwd, tool_name: "Bash", tool_use_id: "terminal-handoff",
|
|
13464
|
+
tool_input: { command: "omx team api transition-task-status" }, tool_response: "handoff complete\n",
|
|
13465
|
+
}, { cwd });
|
|
13466
|
+
assert.doesNotMatch(JSON.stringify(result.outputJson), /LEASE LOST|STOP editing/);
|
|
13467
|
+
for (const file of ["lease-loss.json", "posttooluse-dedupe.json"])
|
|
13468
|
+
assert.equal(existsSync(join(workerRoot, file)), false);
|
|
13469
|
+
assert.equal(existsSync(join(cwd, ".omx/reports/team-commit-hygiene", `${teamName}.ledger.json`)), false);
|
|
13470
|
+
assert.equal(git(["rev-parse", "HEAD"]), headBefore);
|
|
13471
|
+
assert.equal(git(["diff", "--cached"]), "");
|
|
13472
|
+
assert.equal(await readFile(join(cwd, "work.txt"), "utf8"), "unverified terminal edits\n");
|
|
13473
|
+
assert.equal(await readFile(taskPath, "utf8"), taskBefore);
|
|
13474
|
+
assert.equal(await readFile(statusPath, "utf8"), statusBefore);
|
|
13475
|
+
await writeWorkerStatus(teamName, "worker-1", { state: "idle", updated_at: new Date().toISOString() }, cwd);
|
|
13476
|
+
const idle = await dispatchCodexNativeHook({
|
|
13477
|
+
hook_event_name: "PostToolUse", cwd, tool_name: "Bash", tool_response: "idle\n",
|
|
13478
|
+
tool_input: { command: "write idle worker status" },
|
|
13479
|
+
}, { cwd });
|
|
13480
|
+
assert.doesNotMatch(JSON.stringify(idle.outputJson), /LEASE LOST|STOP editing/);
|
|
13481
|
+
assert.equal(JSON.parse(await readFile(statusPath, "utf8")).state, "idle");
|
|
13482
|
+
}
|
|
13483
|
+
finally {
|
|
13484
|
+
await rm(cwd, { recursive: true, force: true });
|
|
13485
|
+
}
|
|
13486
|
+
});
|
|
13487
|
+
}
|
|
13488
|
+
it("surfaces a thrown automatic renewal membership timeout as native PostToolUse STOP without checkpoint or dedupe", async () => {
|
|
13489
|
+
const cwd = await mkdtemp(join(tmpdir(), "omx-native-hook-renewal-timeout-"));
|
|
13490
|
+
const teamName = "native-renewal-timeout";
|
|
13491
|
+
const stateRoot = join(cwd, ".omx/state");
|
|
13492
|
+
let release;
|
|
13493
|
+
let barrier;
|
|
13494
|
+
try {
|
|
13495
|
+
await configureAuthoritativeTeamWorker(cwd, teamName);
|
|
13496
|
+
const task = await createTask(teamName, { subject: "work", description: "work", status: "pending" }, cwd);
|
|
13497
|
+
const claim = await claimTask(teamName, task.id, "worker-1", null, cwd);
|
|
13498
|
+
assert.ok(claim.ok);
|
|
13499
|
+
const workerRoot = join(stateRoot, "team", teamName, "workers/worker-1");
|
|
13500
|
+
const statusPath = join(workerRoot, "status.json");
|
|
13501
|
+
await writeJson(statusPath, {
|
|
13502
|
+
state: "working", current_task_id: task.id, current_claim_token: claim.claimToken,
|
|
13503
|
+
});
|
|
13504
|
+
const taskPath = join(stateRoot, "team", teamName, "tasks", `task-${task.id}.json`);
|
|
13505
|
+
const taskBefore = await readFile(taskPath, "utf8");
|
|
13506
|
+
const statusBefore = await readFile(statusPath, "utf8");
|
|
13507
|
+
const git = (args) => execFileSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
13508
|
+
git(["init"]);
|
|
13509
|
+
git(["config", "user.email", "test@example.com"]);
|
|
13510
|
+
git(["config", "user.name", "Test User"]);
|
|
13511
|
+
await writeFile(join(cwd, "work.txt"), "before\n");
|
|
13512
|
+
git(["add", "work.txt"]);
|
|
13513
|
+
git(["commit", "-m", "initial"]);
|
|
13514
|
+
const headBefore = git(["rev-parse", "HEAD"]);
|
|
13515
|
+
await writeFile(join(cwd, "work.txt"), "unverified edits\n");
|
|
13516
|
+
process.env.OMX_TEAM_INTERNAL_WORKER = `${teamName}/worker-1`;
|
|
13517
|
+
process.env.OMX_TEAM_WORKER = `${teamName}/worker-1`;
|
|
13518
|
+
process.env.OMX_TEAM_STATE_ROOT = stateRoot;
|
|
13519
|
+
let acquired;
|
|
13520
|
+
const ready = new Promise((resolve) => { acquired = resolve; });
|
|
13521
|
+
const held = new Promise((resolve) => { release = resolve; });
|
|
13522
|
+
barrier = withTeamTaskBarrier(teamName, cwd, async () => { acquired(); await held; });
|
|
13523
|
+
await ready;
|
|
13524
|
+
// Dispatch outside the barrier callback so ALS reentrancy cannot bypass its deadline.
|
|
13525
|
+
const result = await dispatchCodexNativeHook({
|
|
13526
|
+
hook_event_name: "PostToolUse", cwd, tool_name: "Bash", tool_use_id: "renewal-timeout",
|
|
13527
|
+
tool_input: { command: "printf ok" }, tool_response: "plain stdout/stderr\n",
|
|
13528
|
+
}, { cwd });
|
|
13529
|
+
assert.match(String(result.outputJson?.systemMessage), /LEASE LOST:.*Timed out acquiring team task lock.*STOP editing/);
|
|
13530
|
+
const hookOutput = result.outputJson?.hookSpecificOutput;
|
|
13531
|
+
assert.equal(hookOutput.additionalContext, result.outputJson?.systemMessage);
|
|
13532
|
+
assert.equal(existsSync(join(workerRoot, "posttooluse-dedupe.json")), false);
|
|
13533
|
+
assert.equal(existsSync(join(cwd, ".omx/reports/team-commit-hygiene", `${teamName}.ledger.json`)), false);
|
|
13534
|
+
assert.equal(existsSync(join(workerRoot, "lease-loss.json")), true);
|
|
13535
|
+
assert.equal(git(["rev-parse", "HEAD"]), headBefore);
|
|
13536
|
+
assert.equal(git(["diff", "--cached"]), "");
|
|
13537
|
+
assert.equal(await readFile(taskPath, "utf8"), taskBefore);
|
|
13538
|
+
assert.equal(await readFile(statusPath, "utf8"), statusBefore);
|
|
13539
|
+
}
|
|
13540
|
+
finally {
|
|
13541
|
+
release?.();
|
|
13542
|
+
await barrier;
|
|
13543
|
+
await rm(cwd, { recursive: true, force: true });
|
|
13544
|
+
}
|
|
13545
|
+
});
|
|
13266
13546
|
it("rejects foreign explicit worker roots for completed Stop/PostToolUse and ignores malformed internal identity", async () => {
|
|
13267
13547
|
const cwd = await mkdtemp(join(tmpdir(), "omx-native-hook-team-worker-foreign-root-"));
|
|
13268
13548
|
const workerCwd = join(cwd, "worker");
|