test: make unsafe test coercion explicit
Move test coercion out of a hidden global and require each test to import the helper so review tools and runtime scripts can see the unsafe boundary. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -2,6 +2,7 @@ const { describe, test, expect } = require("bun:test")
|
||||
|
||||
import type { DelegateTaskArgs, ToolContextWithMetadata } from "./types"
|
||||
import type { ParentContext } from "./executor-types"
|
||||
import { unsafeTestValue } from "../../../test-support/unsafe-test-value"
|
||||
|
||||
const MODEL = { providerID: "anthropic", modelID: "claude-sonnet-4-6" }
|
||||
|
||||
@@ -64,7 +65,7 @@ describe("taskId and backgroundTaskId metadata consistency", () => {
|
||||
load_skills: [], run_in_background: true, subagent_type: "explore",
|
||||
}
|
||||
|
||||
await executeBackgroundTask(args, ctx, testCoerce({
|
||||
await executeBackgroundTask(args, ctx, unsafeTestValue({
|
||||
manager: {
|
||||
launch: async () => ({
|
||||
id: "bg_abc123", description: "test", agent: "explore",
|
||||
@@ -98,7 +99,7 @@ describe("taskId and backgroundTaskId metadata consistency", () => {
|
||||
|
||||
await executeUnstableAgentTask(
|
||||
args, ctx,
|
||||
testCoerce({
|
||||
unsafeTestValue({
|
||||
manager: {
|
||||
launch: async () => launchedTask,
|
||||
getTask: () => launchedTask,
|
||||
@@ -136,7 +137,7 @@ describe("taskId and backgroundTaskId metadata consistency", () => {
|
||||
load_skills: [], run_in_background: true, task_id: "ses_resumed_x",
|
||||
}
|
||||
|
||||
await executeBackgroundContinuation(args, ctx, testCoerce({
|
||||
await executeBackgroundContinuation(args, ctx, unsafeTestValue({
|
||||
manager: {
|
||||
resume: async () => ({
|
||||
id: "bg_resumed_y", description: "continue", agent: "explore",
|
||||
@@ -160,7 +161,7 @@ describe("taskId and backgroundTaskId metadata consistency", () => {
|
||||
load_skills: [], run_in_background: true, task_id: "ses_resumed_x",
|
||||
}
|
||||
|
||||
await executeBackgroundContinuation(args, ctx, testCoerce({
|
||||
await executeBackgroundContinuation(args, ctx, unsafeTestValue({
|
||||
manager: {
|
||||
resume: async () => ({
|
||||
id: "bg_resumed_y", description: "continue", agent: "explore",
|
||||
@@ -187,7 +188,7 @@ describe("taskId and backgroundTaskId metadata consistency", () => {
|
||||
task_id: "ses_resumed_x",
|
||||
}
|
||||
|
||||
await executeBackgroundContinuation(args, ctx, testCoerce({
|
||||
await executeBackgroundContinuation(args, ctx, unsafeTestValue({
|
||||
manager: {
|
||||
resume: async () => ({
|
||||
id: "bg_resumed_y", description: "continue", agent: "explore",
|
||||
@@ -216,7 +217,7 @@ describe("taskId and backgroundTaskId metadata consistency", () => {
|
||||
fetchSyncResult: async () => ({ ok: true as const, textContent: "done" }),
|
||||
}
|
||||
|
||||
await executeSyncContinuation(args, ctx, testCoerce({
|
||||
await executeSyncContinuation(args, ctx, unsafeTestValue({
|
||||
client: {
|
||||
session: {
|
||||
messages: async () => ({
|
||||
@@ -246,7 +247,7 @@ describe("taskId and backgroundTaskId metadata consistency", () => {
|
||||
fetchSyncResult: async () => ({ ok: true as const, textContent: "done" }),
|
||||
}
|
||||
|
||||
await executeSyncContinuation(args, ctx, testCoerce({
|
||||
await executeSyncContinuation(args, ctx, unsafeTestValue({
|
||||
client: {
|
||||
session: {
|
||||
messages: async () => ({
|
||||
@@ -275,7 +276,7 @@ describe("taskId and backgroundTaskId metadata consistency", () => {
|
||||
fetchSyncResult: async () => ({ ok: true as const, textContent: "done" }),
|
||||
}
|
||||
|
||||
await executeSyncContinuation(args, ctx, testCoerce({
|
||||
await executeSyncContinuation(args, ctx, unsafeTestValue({
|
||||
client: {
|
||||
session: {
|
||||
messages: async () => ({
|
||||
@@ -309,7 +310,7 @@ describe("taskId and backgroundTaskId metadata consistency", () => {
|
||||
fetchSyncResult: async () => ({ ok: true as const, textContent: "done" }),
|
||||
}
|
||||
|
||||
await executeSyncContinuation(args, ctx, testCoerce({
|
||||
await executeSyncContinuation(args, ctx, unsafeTestValue({
|
||||
client: {
|
||||
session: {
|
||||
messages: async () => ({
|
||||
@@ -368,7 +369,7 @@ describe("taskId and backgroundTaskId metadata consistency", () => {
|
||||
run_in_background: true,
|
||||
}
|
||||
|
||||
await executeBackgroundTask(args, ctx, testCoerce({
|
||||
await executeBackgroundTask(args, ctx, unsafeTestValue({
|
||||
manager: {
|
||||
launch: async () => ({
|
||||
id: "bg_abc123", description: "test", agent: "Sisyphus-Junior",
|
||||
@@ -402,7 +403,7 @@ describe("taskId and backgroundTaskId metadata consistency", () => {
|
||||
|
||||
await executeUnstableAgentTask(
|
||||
args, ctx,
|
||||
testCoerce({
|
||||
unsafeTestValue({
|
||||
manager: {
|
||||
launch: async () => launchedTask,
|
||||
getTask: () => launchedTask,
|
||||
@@ -438,7 +439,7 @@ describe("taskId and backgroundTaskId metadata consistency", () => {
|
||||
load_skills: [], run_in_background: true, task_id: "ses_resume_title",
|
||||
}
|
||||
|
||||
await executeBackgroundContinuation(args, ctx, testCoerce({
|
||||
await executeBackgroundContinuation(args, ctx, unsafeTestValue({
|
||||
manager: {
|
||||
resume: async () => ({
|
||||
id: "bg_resume_title", description: "continue work", agent: "explore",
|
||||
@@ -460,7 +461,7 @@ describe("taskId and backgroundTaskId metadata consistency", () => {
|
||||
load_skills: [], run_in_background: false, task_id: "ses_sync_title",
|
||||
}
|
||||
|
||||
await executeSyncContinuation(args, ctx, testCoerce({
|
||||
await executeSyncContinuation(args, ctx, unsafeTestValue({
|
||||
client: {
|
||||
session: {
|
||||
messages: async () => ({
|
||||
@@ -500,8 +501,8 @@ describe("taskId and backgroundTaskId metadata consistency", () => {
|
||||
},
|
||||
}
|
||||
|
||||
const bgOutput = createBackgroundOutput(testCoerce(manager), testCoerce(client))
|
||||
await bgOutput.execute(testCoerce({ task_id: "bg_output_xyz" }), testCoerce(ctx))
|
||||
const bgOutput = createBackgroundOutput(unsafeTestValue(manager), unsafeTestValue(client))
|
||||
await bgOutput.execute(unsafeTestValue({ task_id: "bg_output_xyz" }), unsafeTestValue(ctx))
|
||||
|
||||
const meta = ctx.captured.find((m: any) => m.metadata?.backgroundTaskId)
|
||||
expect(meta).toBeDefined()
|
||||
|
||||
Reference in New Issue
Block a user