Merge pull request #3052 from code-yeongyu/fix/p0-1-task-system-default-split-brain

fix: resolve task_system default split-brain
This commit is contained in:
YeonGyu-Kim
2026-04-03 18:52:40 +09:00
committed by GitHub
12 changed files with 135 additions and 12 deletions
@@ -0,0 +1,40 @@
import { describe, expect, test } from "bun:test"
import { REPLACEMENT_MESSAGE } from "./constants"
import { createTasksTodowriteDisablerHook } from "./hook"
describe("createTasksTodowriteDisablerHook", () => {
describe("#given experimental.task_system is omitted", () => {
test("#when TodoWrite runs #then it is allowed by default", async () => {
// given
const hook = createTasksTodowriteDisablerHook({})
// when
const result = hook["tool.execute.before"](
{ tool: "TodoWrite", sessionID: "ses_123", callID: "call_123" },
{ args: {} },
)
// then
await expect(result).resolves.toBeUndefined()
})
})
describe("#given experimental.task_system is enabled", () => {
test("#when TodoWrite runs #then it is blocked", async () => {
// given
const hook = createTasksTodowriteDisablerHook({
experimental: { task_system: true },
})
// when
const result = hook["tool.execute.before"](
{ tool: "TodoWrite", sessionID: "ses_123", callID: "call_123" },
{ args: {} },
)
// then
await expect(result).rejects.toThrow(REPLACEMENT_MESSAGE)
})
})
})
+3 -2
View File
@@ -1,3 +1,4 @@
import { isTaskSystemEnabled } from "../../shared";
import { BLOCKED_TOOLS, REPLACEMENT_MESSAGE } from "./constants";
export interface TasksTodowriteDisablerConfig {
@@ -9,14 +10,14 @@ export interface TasksTodowriteDisablerConfig {
export function createTasksTodowriteDisablerHook(
config: TasksTodowriteDisablerConfig,
) {
const isTaskSystemEnabled = config.experimental?.task_system ?? true;
const taskSystemEnabled = isTaskSystemEnabled(config);
return {
"tool.execute.before": async (
input: { tool: string; sessionID: string; callID: string },
_output: { args: Record<string, unknown> },
) => {
if (!isTaskSystemEnabled) {
if (!taskSystemEnabled) {
return;
}
@@ -78,7 +78,7 @@ describe("tasks-todowrite-disabler", () => {
).resolves.toBeUndefined()
})
test("should block TodoWrite when experimental is undefined because task_system defaults to enabled", async () => {
test("should not block TodoWrite when experimental is undefined because task_system defaults to disabled", async () => {
// given
const hook = createTasksTodowriteDisablerHook({})
const input = {
@@ -93,7 +93,7 @@ describe("tasks-todowrite-disabler", () => {
// when / then
await expect(
hook["tool.execute.before"](input, output)
).rejects.toThrow("TodoRead/TodoWrite are DISABLED")
).resolves.toBeUndefined()
})
test("should not block TodoRead when flag is false", async () => {