STET

agent_patch

runs/2026-02-27__21-30-28__gpt-5-3-codex/flux-commit-7af773c0/flux-commit-7af773c0.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/agent-logs/agent.patch

12131 bytes

Back to adjudication
diff --git a/app/src/codegen.ts b/app/src/codegen.ts
new file mode 100644
index 0000000..3a9c964
--- /dev/null
+++ b/app/src/codegen.ts
@@ -0,0 +1,154 @@
+import * as z from './types/base';
+
+type TypeResult = {
+  id: string;
+  schema: z.ZodType<any, any>;
+  type: Identity<string>;
+  complete: boolean;
+};
+
+type Identity<T> = T;
+
+const isOptional = (schema: z.ZodType<any, any>): boolean => {
+  const def: any = schema._def;
+  if (!def) return false;
+
+  if (def.t === z.ZodTypes.undefined) {
+    return true;
+  }
+
+  if (def.t === z.ZodTypes.intersection) {
+    return isOptional(def.left) || isOptional(def.right);
+  }
+
+  if (def.t === z.ZodTypes.union) {
+    return def.options.some((option: z.ZodType<any, any>) => isOptional(option));
+  }
+
+  return false;
+};
+
+export class ZodCodeGenerator {
+  seen: TypeResult[] = [];
+  serial: number = 1;
+
+  static create = () => new ZodCodeGenerator();
+
+  private nextId = () => {
+    return `Type${this.serial++}`;
+  };
+
+  findBySchema = (schema: z.ZodType<any, any>) => {
+    return this.seen.find(item => item.schema === schema);
+  };
+
+  findById = (id: string) => {
+    return this.seen.find(item => item.id === id);
+  };
+
+  setType = (target: TypeResult, type: string) => {
+    target.type = type;
+    target.complete = type !== '__INCOMPLETE__';
+    return target;
+  };
+
+  generate = (schema: z.ZodType<any, any>): TypeResult => {
+    const found = this.findBySchema(schema);
+    if (found) {
+      return found;
+    }
+
+    const result: TypeResult = {
+      id: this.nextId(),
+      schema,
+      type: '__INCOMPLETE__',
+      complete: false,
+    };
+    this.seen.push(result);
+
+    const def: any = schema._def;
+    switch (def.t) {
+      case z.ZodTypes.string:
+        return this.setType(result, 'string');
+      case z.ZodTypes.number:
+        return this.setType(result, 'number');
+      case z.ZodTypes.bigint:
+        return this.setType(result, 'bigint');
+      case z.ZodTypes.boolean:
+        return this.setType(result, 'boolean');
+      case z.ZodTypes.date:
+        return this.setType(result, 'Date');
+      case z.ZodTypes.undefined:
+        return this.setType(result, 'undefined');
+      case z.ZodTypes.null:
+        return this.setType(result, 'null');
+      case z.ZodTypes.void:
+        return this.setType(result, 'void');
+      case z.ZodTypes.any:
+        return this.setType(result, 'any');
+      case z.ZodTypes.unknown:
+        return this.setType(result, 'unknown');
+      case z.ZodTypes.literal:
+        return this.setType(result, JSON.stringify(def.value));
+      case z.ZodTypes.enum:
+        return this.setType(result, def.values.map((value: string) => JSON.stringify(value)).join(' | '));
+      case z.ZodTypes.array: {
+        const itemType = this.generate(def.type);
+        return this.setType(result, `(${itemType.id})[]`);
+      }
+      case z.ZodTypes.object: {
+        const shape = def.shape();
+        const objectLines: string[] = [];
+        for (const key of Object.keys(shape)) {
+          const childSchema = shape[key];
+          const childType = this.generate(childSchema);
+          const OPTKEY = isOptional(childSchema) ? '?' : '';
+          objectLines.push(`${key}${OPTKEY}: ${childType.id}`);
+        }
+        return this.setType(result, `{ ${objectLines.join('; ')} }`);
+      }
+      case z.ZodTypes.union: {
+        const options = def.options.map((option: z.ZodType<any, any>) => this.generate(option));
+        return this.setType(result, options.map((option: TypeResult) => option.id).join(' | '));
+      }
+      case z.ZodTypes.intersection: {
+        const left = this.generate(def.left);
+        const right = this.generate(def.right);
+        return this.setType(result, `${left.id} & ${right.id}`);
+      }
+      case z.ZodTypes.tuple: {
+        const items = def.items.map((item: z.ZodType<any, any>) => this.generate(item));
+        return this.setType(result, `[${items.map((item: TypeResult) => item.id).join(', ')}]`);
+      }
+      case z.ZodTypes.record: {
+        const valueType = this.generate(def.valueType);
+        return this.setType(result, `{ [k: string]: ${valueType.id} }`);
+      }
+      case z.ZodTypes.lazy: {
+        const inner = this.generate(def.getter());
+        return this.setType(result, inner.id);
+      }
+      case z.ZodTypes.promise: {
+        const inner = this.generate(def.type);
+        return this.setType(result, `Promise<${inner.id}>`);
+      }
+      case z.ZodTypes.function: {
+        const args = this.generate(def.args);
+        const returns = this.generate(def.returns);
+        return this.setType(result, `(...args: ${args.id}) => ${returns.id}`);
+      }
+      default:
+        return this.setType(result, 'any');
+    }
+  };
+
+  dump = () => {
+    const lines: string[] = ['type Identity<T> = T;'];
+    for (const item of this.seen) {
+      lines.push(`type ${item.id} = Identity<${item.type}>;`);
+    }
+    return lines.join('\n');
+  };
+}
+
+export { TypeResult };
diff --git a/tmp/agent-patch-flux-commit-7af773c0.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/app/src/index.ts b/app/src/index.ts
index 480ceff..95eedc6 100644
--- a/tmp/agent-patch-flux-commit-7af773c0.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/app/src/index.ts
+++ b/app/src/index.ts
@@ -21,8 +21,10 @@ import { ZodLazy, ZodLazyDef } from './types/lazy';
 import { ZodLiteral, ZodLiteralDef } from './types/literal';
 import { ZodEnum, ZodEnumDef } from './types/enum';
 import { ZodPromise, ZodPromiseDef } from './types/promise';
-import { TypeOf, ZodType, ZodTypeAny } from './types/base';
-import { ZodError } from './ZodError';
+import { TypeOf, ZodType, ZodTypeAny, ZodTypeDef, ZodTypes } from './types/base';
+import { ZodError, ZodErrorCode } from './ZodError';
+import { ErrorMap } from './errorMap';
+import { ZodCodeGenerator } from './codegen';
 
 import { toZod } from './toZod';
 // import { ZodLazyObject, ZodLazyObjectDef } from './types/lazyobject';
@@ -164,8 +166,13 @@ export {
   ZodTypeAny,
   ZodDef,
   ZodError,
+  ZodErrorCode,
+  ErrorMap,
+  ZodCodeGenerator,
 };
 
+export { ZodTypeDef, ZodTypes };
+
 export type lazyobject<T extends object> = ZodObject<{ [k in keyof T]: ZodType<T[k], any> }>;
 // export namespace lazy {
 //   export type objectType<T extends object> = ZodObject<{ [k in keyof T]: ZodType<T[k]> }>;
diff --git a/tmp/agent-patch-flux-commit-7af773c0.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/app/src/toZod.ts b/app/src/toZod.ts
index 9ae5fc5..ef657ba 100644
--- a/tmp/agent-patch-flux-commit-7af773c0.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/app/src/toZod.ts
+++ b/app/src/toZod.ts
@@ -3,7 +3,6 @@ import * as z from '.';
 type isAny<T> = [any extends T ? 'true' : 'false'] extends ['true'] ? true : false;
 type nonoptional<T> = T extends undefined ? never : T;
 type nonnullable<T> = T extends null ? never : T;
-// type arrayelement<T extends any[]> = T extends (infer U)[] ? U : never;
 type equals<X, Y> = [X] extends [Y] ? ([Y] extends [X] ? true : false) : false;
 
 export type toZod<T> = {
@@ -16,13 +15,13 @@ export type toZod<T> = {
   number: z.ZodNumber;
   boolean: z.ZodBoolean;
   date: z.ZodDate;
-  object: T extends { [k: string]: any } ? z.ZodObject<{ [k in keyof T]: toZod<T[k]> }> : never;
+  object: z.ZodObject<{ [k in keyof T]: toZod<T[k]> }, { strict: true }, T>;
   rest: never;
 }[zodKey<T>];
 
 type zodKey<T> = isAny<T> extends true
   ? 'any'
-  : equals<T, boolean> extends true //[T] extends [booleanUtil.Type]
+  : equals<T, boolean> extends true
   ? 'boolean'
   : [undefined] extends [T]
   ? 'optional'
@@ -32,40 +31,12 @@ type zodKey<T> = isAny<T> extends true
   ? 'array'
   : equals<T, string> extends true
   ? 'string'
-  : equals<T, bigint> extends true //[T] extends [bigintUtil.Type]
+  : equals<T, bigint> extends true
   ? 'bigint'
-  : equals<T, number> extends true //[T] extends [numberUtil.Type]
+  : equals<T, number> extends true
   ? 'number'
-  : equals<T, Date> extends true //[T] extends [dateUtil.Type]
+  : equals<T, Date> extends true
   ? 'date'
-  : T extends { [k: string]: any } //[T] extends [structUtil.Type]
+  : T extends { [k: string]: any }
   ? 'object'
   : 'rest';
-
-type User = {
-  name: string;
-  age: number | undefined;
-  active: boolean | null;
-  posts: Post[];
-};
-
-type Post = {
-  content: string;
-  author: User;
-};
-
-const User: toZod<User> = z.lazy.object(() => ({
-  name: z
-    .string()
-    .min(5)
-    .max(2314)
-    .refine(() => false, 'asdf'),
-  age: z.number().optional(),
-  active: z.boolean().nullable(),
-  posts: z.array(
-    z.object({
-      content: z.string(),
-      author: User,
-    }),
-  ),
-}));
diff --git a/tmp/agent-patch-flux-commit-7af773c0.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/app/src/types/array.ts b/app/src/types/array.ts
index 1f64c2b..cbad534 100644
--- a/tmp/agent-patch-flux-commit-7af773c0.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/app/src/types/array.ts
+++ b/app/src/types/array.ts
@@ -13,6 +13,10 @@ export interface ZodArrayDef<T extends z.ZodTypeAny = z.ZodTypeAny> extends z.Zo
 }
 
 export class ZodArray<T extends z.ZodTypeAny> extends z.ZodType<T['_type'][], ZodArrayDef<T>> {
+  get element() {
+    return this._def.type;
+  }
+
   toJSON = () => {
     return {
       t: this._def.t,
diff --git a/tmp/agent-patch-flux-commit-7af773c0.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/app/src/types/object.ts b/app/src/types/object.ts
index b864d22..e109b50 100644
--- a/tmp/agent-patch-flux-commit-7af773c0.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/app/src/types/object.ts
+++ b/app/src/types/object.ts
@@ -61,10 +61,11 @@ type ZodObjectType<T extends z.ZodRawShape, Params extends ZodObjectParams> = Pa
   ? objectUtil.ObjectType<T>
   : objectUtil.Flatten<objectUtil.ObjectType<T> & { [k: string]: any }>;
 
-export class ZodObject<T extends z.ZodRawShape, Params extends ZodObjectParams = { strict: true }> extends z.ZodType<
-  ZodObjectType<T, Params>, // { [k in keyof T]: T[k]['_type'] },
-  ZodObjectDef<T, Params>
-> {
+export class ZodObject<
+  T extends z.ZodRawShape,
+  Params extends ZodObjectParams = { strict: true },
+  Type extends ZodObjectType<T, Params> = ZodObjectType<T, Params>
+> extends z.ZodType<Type, ZodObjectDef<T, Params>> {
   readonly _shape!: T;
   readonly _params!: Params;
 
diff --git a/app/src/types/void.ts b/app/src/types/void.ts
new file mode 100644
index 0000000..7834df1
--- /dev/null
+++ b/app/src/types/void.ts
@@ -0,0 +1,22 @@
+import * as z from './base';
+import { ZodUndefined } from './undefined';
+import { ZodNull } from './null';
+import { ZodUnion } from './union';
+
+export interface ZodVoidDef extends z.ZodTypeDef {
+  t: z.ZodTypes.void;
+}
+
+export class ZodVoid extends z.ZodType<void, ZodVoidDef> {
+  toJSON = () => this._def;
+
+  optional: () => ZodUnion<[this, ZodUndefined]> = () => ZodUnion.create([this, ZodUndefined.create()]);
+
+  nullable: () => ZodUnion<[this, ZodNull]> = () => ZodUnion.create([this, ZodNull.create()]);
+
+  static create = (): ZodVoid => {
+    return new ZodVoid({
+      t: z.ZodTypes.void,
+    });
+  };
+}
diff --git a/app/src/userpost.ts b/app/src/userpost.ts
new file mode 100644
index 0000000..249574c
--- /dev/null
+++ b/app/src/userpost.ts
@@ -0,0 +1,39 @@
+import * as z from '.';
+import { util } from './helpers/util';
+
+type User = {
+  name: string;
+  age?: number | undefined;
+  active: boolean | null;
+  posts: Post[];
+};
+
+type Post = {
+  content: string;
+  author: User;
+};
+
+const User: z.ZodType<User> = z.lazy.object(() => ({
+  name: z
+    .string()
+    .min(5)
+    .max(2314)
+    .refine(() => false, 'asdf'),
+  age: z.number().optional(),
+  active: z.boolean().nullable(),
+  posts: z.array(Post),
+}));
+
+const Post: z.ZodType<Post> = z.lazy.object(() => ({
+  content: z.string(),
+  author: User,
+}));
+
+type genUser = z.infer<typeof User>;
+type genPost = z.infer<typeof Post>;
+
+const t1: util.AssertEqual<User, genUser> = true;
+const t2: util.AssertEqual<Post, genPost> = true;
+
+t1;
+t2;