{
  "schemaVersion": 1,
  "operation": "production-advisory-review",
  "repository": "colinhacks/zod",
  "baseSha": "ccc1514404929ce5df69f3ceb105a8ddd1ebdc07",
  "headSha": "b1077f05f85450cf53108714973bf7c8d9e3c35d",
  "model": "gpt-6.1-sol",
  "memory": "enabled",
  "performedAt": "2026-10-28T20:43:13.266Z",
  "manifest": [
    {
      "path": "packages/zod/src/v4/core/core.ts",
      "sha": "ccc1514404929ce5df69f3ceb105a8ddd1ebdc07",
      "sha256": "2b8f68a8ad2e753fb72437254ef0eb27e9eb1f69f955098600e4288e01a34df7"
    },
    {
      "path": "packages/zod/src/v4/core/util.ts",
      "sha": "ccc1514404929ce5df69f3ceb105a8ddd1ebdc07",
      "sha256": "85f50e21ac890d44e66d2306bb11218c518f3b66869929e68895c1d4bc1e11d6"
    },
    {
      "path": "packages/zod/src/v4/core/schemas.ts",
      "sha": "ccc1514404929ce5df69f3ceb105a8ddd1ebdc07",
      "sha256": "f61ff33ef3d5c87ca9bcd87c138ebf04df57883ea01f0839899d3b611a574c29"
    },
    {
      "path": "packages/zod/src/v4/classic/tests/optin-ladder.test.ts",
      "sha": "ccc1514404929ce5df69f3ceb105a8ddd1ebdc07",
      "sha256": "5a75e1d595e6e9f85dc9e488976afb8e5d739bb96050340b63607448904d5211"
    },
    {
      "path": "packages/zod/src/v4/classic/tests/lazy.test.ts",
      "sha": "ccc1514404929ce5df69f3ceb105a8ddd1ebdc07",
      "sha256": "4136e711b5e496f94c3e5c7befc8f6909a6dc3750696ce40e1f0a67d27be7342"
    }
  ],
  "changedFiles": [
    {
      "path": "packages/zod/src/v4/classic/tests/lazy.test.ts",
      "sha": "d7d4d4efd67a76f1df75ce0ee7b9b2a9017a9c6e",
      "patchSha256": "1ef8eb15157e76de364f1d6f58cbf01ada817a86f77b8f7a0fa5f294cb8924b7"
    },
    {
      "path": "packages/zod/src/v4/core/core.ts",
      "sha": "1d65cc812437a24a616a6e7476c88574e7fb8842",
      "patchSha256": "800cab8c8df9f9abc721ccfedffcce010ba4d109ef9f64416e6e492757d888dd"
    },
    {
      "path": "packages/zod/src/v4/core/schemas.ts",
      "sha": "7dc010402dbefd758725868e7cb204ac2f9a1130",
      "patchSha256": "ec79376572036b79019ca042cd01b616d4f816f83cb0682fef8c7b1359760886"
    },
    {
      "path": "packages/zod/src/v4/core/util.ts",
      "sha": "a57f9c9f66bfbd304004f8784495ade8eee049e5",
      "patchSha256": "df6e685b2971d80f7ac9936214c8eb19aaaa20292dfce60f431c1e721514a12c"
    }
  ],
  "configuration": "Production reviewPullRequestWithAI + deterministic checks; bounded pre-existing base-test context; no history miner, runtime detector, future fix, labels or ground-truth harness. Memory variants differ only by base-only discovered guards. API timeout 90s; transport retries disabled.",
  "limitation": "One historical change; correlated case outcomes. Review-level advisory detection, not verified runtime behavior or broad production accuracy.",
  "usage": {
    "provider": "openai",
    "operation": "pr_review",
    "model": "gpt-6.1-sol",
    "responseId": "resp_01bad037799dc2d4006ae25e61875487d196e6e377955cf66e",
    "inputTokens": 9922,
    "cachedInputTokens": 1757,
    "cacheWriteInputTokens": 8162,
    "outputTokens": 1119,
    "reasoningTokens": 476,
    "totalTokens": 11041,
    "estimatedCostUsd": 0.0317767,
    "inputPricePerMillionUsd": 2,
    "cachedInputPricePerMillionUsd": 0.1,
    "cacheWritePricePerMillionUsd": 2.5,
    "outputPricePerMillionUsd": 10,
    "longContextApplied": false,
    "pricingVersion": "2026-10-08"
  },
  "status": "completed",
  "result": {
    "findings": [
      {
        "ruleId": "ai-incomplete_refactor",
        "category": "reliability",
        "behaviorCategory": "changed_data_semantics",
        "severity": "warning",
        "title": "Preserve exactOptional overrides of optional metadata",
        "description": "$ZodExactOptional initializes $ZodOptional first, which now installs values and pattern on the same constructor-specific internals prototype. Its subsequent override calls return immediately because those keys already exist, leaving metadata that includes undefined even though exactOptional parsing explicitly delegates to the inner schema without undefined handling.",
        "behaviorChange": {
          "before": "exactOptional replaces optional's values and pattern with the inner schema's metadata.",
          "after": "exactOptional retains optional's undefined-inclusive values and optional pattern whenever the inner metadata exists.",
          "impact": "Consumers of derived values or patterns receive metadata inconsistent with the inputs exactOptional accepts."
        },
        "intent": "likely_unintentional",
        "evidence": "defineLazyInternal returns when `key in proto`; $ZodExactOptional calls $ZodOptional.init before attempting to override the same values and pattern keys, explicitly labeled 'Override values/pattern to NOT add undefined'.",
        "protectedBehaviorKey": null,
        "filePath": "packages/zod/src/v4/core/util.ts",
        "lineStart": 1074,
        "lineEnd": 1074,
        "codeSnippet": null,
        "suggestedFix": "Allow exactOptional to replace the metadata installed by optional initialization.\n\nChanges:\n\n1. Provide an explicit override mechanism for prototype-derived internals and use it for exactOptional's values and pattern.\n2. Retain one-time installation for ordinary repeated constructor initialization.\n\nVerify:\n\n- For inner schemas with values and pattern metadata, verify exactOptional exposes the inner metadata without adding undefined or making the pattern optional.\n- Verify ordinary optional schemas still add undefined and retain optional patterns, regardless of construction order.",
        "fixSearchText": null,
        "fixReplacementText": null,
        "fixEdits": []
      }
    ],
    "behaviorOutcomes": [
      {
        "behaviorGuardId": "base-guard-11",
        "behaviorKey": "base-guard-11",
        "behavior": "Lazy schemas pass through the inner schema's defaulted input status and required output status.",
        "status": "preserved",
        "before": "Lazy optin and optout derive from the resolved inner schema.",
        "after": "The shared accessors derive optin and optout from the receiving internals object's resolved inner schema.",
        "impact": "Defaulted input and required output metadata remain instance-specific.",
        "evidence": "$ZodLazy's new callbacks read `zod.innerType?._zod?.optin` and `zod.innerType?._zod?.optout`, preserving the previous derivation.",
        "filePath": "packages/zod/src/v4/core/schemas.ts",
        "intent": null
      }
    ],
    "behaviorDiscoveries": []
  },
  "durationMs": 25492
}
