// engine/handoff-artifacts/version-policy.ts — SPEC-725: Version compatibility resolver
/**
 * Resolve compatibility between a payload's schema_version and the current code's version.
 *
 * Rules:
 * - Same major.minor.patch → 'exact', ok
 * - Same major, payload minor > current minor → 'forward-minor', ok with FORWARD_COMPAT_MINOR warning
 * - Same major, payload minor ≤ current minor (patch diff only) → 'exact', ok
 * - Different major → 'incompatible-major', not ok
 */
export function resolveCompat(payloadVersion, currentVersion) {
    const parseSemver = (v) => {
        const parts = v.split('.').map(Number);
        return [parts[0] ?? 0, parts[1] ?? 0, parts[2] ?? 0];
    };
    const [pMajor, pMinor] = parseSemver(payloadVersion);
    const [cMajor, cMinor] = parseSemver(currentVersion);
    if (pMajor !== cMajor) {
        return {
            ok: false,
            level: 'incompatible-major',
            warning: `Major version mismatch: payload has v${String(pMajor)}.x.x, current code expects v${String(cMajor)}.x.x`,
        };
    }
    if (pMinor > cMinor) {
        return {
            ok: true,
            level: 'forward-minor',
            warning: `FORWARD_COMPAT_MINOR: payload schema_version ${payloadVersion} is ahead of current ${currentVersion} — unknown fields may be ignored`,
        };
    }
    // Same major, payload minor ≤ current minor (patch differences are always ok)
    return { ok: true, level: 'exact' };
}
//# sourceMappingURL=version-policy.js.map