test(ci): remove suite-order mock coupling
This commit is contained in:
@@ -149,7 +149,10 @@ describe("Atlas final-wave approval gate regressions", () => {
|
||||
- [ ] All tests pass
|
||||
`)
|
||||
|
||||
const hook = createAtlasHook(createMockPluginInput())
|
||||
const hook = createAtlasHook(createMockPluginInput(), {
|
||||
directory: testDirectory,
|
||||
isCallerOrchestrator: async () => true,
|
||||
})
|
||||
const toolOutput = {
|
||||
title: "Sisyphus Task",
|
||||
output: `Tasks [1/1 compliant] | Contamination [CLEAN] | Unaccounted [CLEAN] | VERDICT: APPROVE
|
||||
@@ -186,7 +189,10 @@ session_id: ses_nested_scope_review
|
||||
- [ ] F4. **Scope Fidelity Check** - \`deep\`
|
||||
`)
|
||||
|
||||
const hook = createAtlasHook(createMockPluginInput())
|
||||
const hook = createAtlasHook(createMockPluginInput(), {
|
||||
directory: testDirectory,
|
||||
isCallerOrchestrator: async () => true,
|
||||
})
|
||||
const firstThreeOutputs = [1, 2, 3].map((index) => ({
|
||||
title: `Final review ${index}`,
|
||||
output: `Reviewer ${index} | VERDICT: APPROVE
|
||||
|
||||
@@ -16,15 +16,7 @@ const collectGitDiffStatsMock = mock(() => ({
|
||||
insertions: 0,
|
||||
deletions: 0,
|
||||
}))
|
||||
|
||||
mock.module("../../shared/session-utils", () => ({
|
||||
isCallerOrchestrator: isCallerOrchestratorMock,
|
||||
}))
|
||||
|
||||
mock.module("../../shared/git-worktree", () => ({
|
||||
collectGitDiffStats: collectGitDiffStatsMock,
|
||||
formatFileChanges: mock(() => "No file changes"),
|
||||
}))
|
||||
const formatFileChangesMock = mock(() => "No file changes")
|
||||
|
||||
afterAll(() => { mock.restore() })
|
||||
|
||||
@@ -50,6 +42,7 @@ describe("createToolExecuteAfterHandler background launch detection", () => {
|
||||
|
||||
isCallerOrchestratorMock.mockClear()
|
||||
collectGitDiffStatsMock.mockClear()
|
||||
formatFileChangesMock.mockClear()
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
@@ -108,6 +101,9 @@ describe("createToolExecuteAfterHandler background launch detection", () => {
|
||||
pendingTaskRefs: new Map(),
|
||||
autoCommit: true,
|
||||
getState: () => ({ promptFailureCount: 0 }),
|
||||
isCallerOrchestrator: isCallerOrchestratorMock,
|
||||
collectGitDiffStats: collectGitDiffStatsMock as never,
|
||||
formatFileChanges: formatFileChangesMock as never,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -175,13 +171,21 @@ describe("createToolExecuteAfterHandler background launch detection", () => {
|
||||
serverUrl: new URL("https://example.com"),
|
||||
$: Bun.$,
|
||||
} satisfies PluginInput
|
||||
const beforeHandler = createToolExecuteBeforeHandler({ ctx, pendingFilePaths, pendingTaskRefs })
|
||||
const beforeHandler = createToolExecuteBeforeHandler({
|
||||
ctx,
|
||||
pendingFilePaths,
|
||||
pendingTaskRefs,
|
||||
isCallerOrchestrator: isCallerOrchestratorMock,
|
||||
})
|
||||
const afterHandler = createToolExecuteAfterHandler({
|
||||
ctx,
|
||||
pendingFilePaths,
|
||||
pendingTaskRefs,
|
||||
autoCommit: true,
|
||||
getState: () => ({ promptFailureCount: 0 }),
|
||||
isCallerOrchestrator: isCallerOrchestratorMock,
|
||||
collectGitDiffStats: collectGitDiffStatsMock as never,
|
||||
formatFileChanges: formatFileChangesMock as never,
|
||||
})
|
||||
|
||||
await beforeHandler(
|
||||
@@ -252,13 +256,21 @@ describe("createToolExecuteAfterHandler background launch detection", () => {
|
||||
serverUrl: new URL("https://example.com"),
|
||||
$: Bun.$,
|
||||
} satisfies PluginInput
|
||||
const beforeHandler = createToolExecuteBeforeHandler({ ctx, pendingFilePaths, pendingTaskRefs })
|
||||
const beforeHandler = createToolExecuteBeforeHandler({
|
||||
ctx,
|
||||
pendingFilePaths,
|
||||
pendingTaskRefs,
|
||||
isCallerOrchestrator: isCallerOrchestratorMock,
|
||||
})
|
||||
const afterHandler = createToolExecuteAfterHandler({
|
||||
ctx,
|
||||
pendingFilePaths,
|
||||
pendingTaskRefs,
|
||||
autoCommit: true,
|
||||
getState: () => ({ promptFailureCount: 0 }),
|
||||
isCallerOrchestrator: isCallerOrchestratorMock,
|
||||
collectGitDiffStats: collectGitDiffStatsMock as never,
|
||||
formatFileChanges: formatFileChangesMock as never,
|
||||
})
|
||||
|
||||
await beforeHandler(
|
||||
@@ -322,13 +334,21 @@ describe("createToolExecuteAfterHandler background launch detection", () => {
|
||||
serverUrl: new URL("https://example.com"),
|
||||
$: Bun.$,
|
||||
} satisfies PluginInput
|
||||
const beforeHandler = createToolExecuteBeforeHandler({ ctx, pendingFilePaths, pendingTaskRefs })
|
||||
const beforeHandler = createToolExecuteBeforeHandler({
|
||||
ctx,
|
||||
pendingFilePaths,
|
||||
pendingTaskRefs,
|
||||
isCallerOrchestrator: isCallerOrchestratorMock,
|
||||
})
|
||||
const afterHandler = createToolExecuteAfterHandler({
|
||||
ctx,
|
||||
pendingFilePaths,
|
||||
pendingTaskRefs,
|
||||
autoCommit: true,
|
||||
getState: () => ({ promptFailureCount: 0 }),
|
||||
isCallerOrchestrator: isCallerOrchestratorMock,
|
||||
collectGitDiffStats: collectGitDiffStatsMock as never,
|
||||
formatFileChanges: formatFileChangesMock as never,
|
||||
})
|
||||
|
||||
await beforeHandler(
|
||||
@@ -393,13 +413,21 @@ describe("createToolExecuteAfterHandler background launch detection", () => {
|
||||
serverUrl: new URL("https://example.com"),
|
||||
$: Bun.$,
|
||||
} satisfies PluginInput
|
||||
const beforeHandler = createToolExecuteBeforeHandler({ ctx, pendingFilePaths, pendingTaskRefs })
|
||||
const beforeHandler = createToolExecuteBeforeHandler({
|
||||
ctx,
|
||||
pendingFilePaths,
|
||||
pendingTaskRefs,
|
||||
isCallerOrchestrator: isCallerOrchestratorMock,
|
||||
})
|
||||
const afterHandler = createToolExecuteAfterHandler({
|
||||
ctx,
|
||||
pendingFilePaths,
|
||||
pendingTaskRefs,
|
||||
autoCommit: true,
|
||||
getState: () => ({ promptFailureCount: 0 }),
|
||||
isCallerOrchestrator: isCallerOrchestratorMock,
|
||||
collectGitDiffStats: collectGitDiffStatsMock as never,
|
||||
formatFileChanges: formatFileChangesMock as never,
|
||||
})
|
||||
|
||||
await beforeHandler(
|
||||
@@ -482,13 +510,21 @@ describe("createToolExecuteAfterHandler background launch detection", () => {
|
||||
serverUrl: new URL("https://example.com"),
|
||||
$: Bun.$,
|
||||
} satisfies PluginInput
|
||||
const beforeHandler = createToolExecuteBeforeHandler({ ctx, pendingFilePaths, pendingTaskRefs })
|
||||
const beforeHandler = createToolExecuteBeforeHandler({
|
||||
ctx,
|
||||
pendingFilePaths,
|
||||
pendingTaskRefs,
|
||||
isCallerOrchestrator: isCallerOrchestratorMock,
|
||||
})
|
||||
const afterHandler = createToolExecuteAfterHandler({
|
||||
ctx,
|
||||
pendingFilePaths,
|
||||
pendingTaskRefs,
|
||||
autoCommit: true,
|
||||
getState: () => ({ promptFailureCount: 0 }),
|
||||
isCallerOrchestrator: isCallerOrchestratorMock,
|
||||
collectGitDiffStats: collectGitDiffStatsMock as never,
|
||||
formatFileChanges: formatFileChangesMock as never,
|
||||
})
|
||||
|
||||
await beforeHandler(
|
||||
|
||||
@@ -15,15 +15,7 @@ const collectGitDiffStatsMock = mock(() => ({
|
||||
insertions: 0,
|
||||
deletions: 0,
|
||||
}))
|
||||
|
||||
mock.module("../../shared/session-utils", () => ({
|
||||
isCallerOrchestrator: isCallerOrchestratorMock,
|
||||
}))
|
||||
|
||||
mock.module("../../shared/git-worktree", () => ({
|
||||
collectGitDiffStats: collectGitDiffStatsMock,
|
||||
formatFileChanges: mock(() => "No file changes"),
|
||||
}))
|
||||
const formatFileChangesMock = mock(() => "No file changes")
|
||||
|
||||
afterAll(() => { mock.restore() })
|
||||
|
||||
@@ -47,6 +39,7 @@ describe("createToolExecuteAfterHandler task timers", () => {
|
||||
}
|
||||
isCallerOrchestratorMock.mockClear()
|
||||
collectGitDiffStatsMock.mockClear()
|
||||
formatFileChangesMock.mockClear()
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
@@ -104,6 +97,7 @@ describe("createToolExecuteAfterHandler task timers", () => {
|
||||
pendingFilePaths,
|
||||
pendingTaskRefs,
|
||||
pendingPlanSnapshots,
|
||||
isCallerOrchestrator: isCallerOrchestratorMock,
|
||||
}),
|
||||
afterHandler: createToolExecuteAfterHandler({
|
||||
ctx,
|
||||
@@ -112,6 +106,9 @@ describe("createToolExecuteAfterHandler task timers", () => {
|
||||
pendingPlanSnapshots,
|
||||
autoCommit: true,
|
||||
getState: () => ({ promptFailureCount: 0 }),
|
||||
isCallerOrchestrator: isCallerOrchestratorMock,
|
||||
collectGitDiffStats: collectGitDiffStatsMock as never,
|
||||
formatFileChanges: formatFileChangesMock as never,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,9 +129,13 @@ export function createToolExecuteAfterHandler(input: {
|
||||
autoCommit: boolean
|
||||
getState: (sessionID: string) => SessionState
|
||||
isCallerOrchestrator?: (sessionID: string | undefined) => Promise<boolean>
|
||||
collectGitDiffStats?: typeof collectGitDiffStats
|
||||
formatFileChanges?: typeof formatFileChanges
|
||||
}): (toolInput: ToolExecuteAfterInput, toolOutput: ToolExecuteAfterOutput | undefined) => Promise<void> {
|
||||
const { ctx, pendingFilePaths, pendingTaskRefs, pendingPlanSnapshots, autoCommit, getState } = input
|
||||
const resolveIsCallerOrchestrator = input.isCallerOrchestrator ?? ((sessionID) => isCallerOrchestrator(sessionID, ctx.client))
|
||||
const collectGitDiffStatsImpl = input.collectGitDiffStats ?? collectGitDiffStats
|
||||
const formatFileChangesImpl = input.formatFileChanges ?? formatFileChanges
|
||||
return async (toolInput, toolOutput): Promise<void> => {
|
||||
// Guard against undefined output (e.g., from /review command - see issue #1035)
|
||||
if (!toolOutput) {
|
||||
@@ -212,8 +216,8 @@ export function createToolExecuteAfterHandler(input: {
|
||||
if (toolOutput.output && typeof toolOutput.output === "string") {
|
||||
const worktreePath = boulderState?.worktree_path?.trim()
|
||||
const verificationDirectory = worktreePath ? worktreePath : ctx.directory
|
||||
const gitStats = collectGitDiffStats(verificationDirectory)
|
||||
const fileChanges = formatFileChanges(gitStats)
|
||||
const gitStats = collectGitDiffStatsImpl(verificationDirectory)
|
||||
const fileChanges = formatFileChangesImpl(gitStats)
|
||||
const extractedSessionId = metadataSessionId ?? extractSessionIdFromOutput(toolOutput.output)
|
||||
|
||||
if (boulderState) {
|
||||
|
||||
Reference in New Issue
Block a user