// engine/execution-plan/mobile-dist/native-steps.ts — SPEC-013
// Distribution steps for native iOS and Android release specs.
function buildSignedBuildStep(isIOS, order) {
    return {
        order,
        title: 'Signed build',
        description: isIOS
            ? 'Build signed IPA via Fastlane gym or Xcode Archive. Verify provisioning profile and signing certificate are valid.'
            : 'Build signed AAB via `./gradlew bundleRelease`. Verify keystore and signing config in build.gradle.',
        files: isIOS ? ['Fastfile', 'Gymfile'] : ['app/build.gradle', 'keystore.properties'],
        dependsOn: [],
        verification: isIOS
            ? 'IPA file exists in build/. `codesign -dv` shows valid signature.'
            : 'AAB exists in app/build/outputs/bundle/release/. `jarsigner -verify` passes.',
        estimatedMinutes: 20,
        canRollback: false,
    };
}
function buildBetaUploadStep(isIOS, order) {
    return {
        order,
        title: isIOS ? 'Upload to TestFlight' : 'Upload to Firebase App Distribution',
        description: isIOS
            ? 'Upload IPA to TestFlight via `fastlane pilot upload` or `xcrun altool`. Assign internal testers.'
            : 'Upload AAB/APK to Firebase App Distribution via `fastlane supply` or Firebase CLI. Assign tester groups.',
        files: isIOS ? ['Fastfile'] : ['Fastfile', '.firebaserc'],
        dependsOn: [],
        verification: isIOS
            ? 'Build appears in TestFlight internal builds. Testers receive email notification.'
            : 'Build appears in Firebase console. Testers receive download link.',
        estimatedMinutes: 15,
        canRollback: false,
    };
}
function buildSmokeTestStep(isIOS, order) {
    return {
        order,
        title: 'Smoke test on real device',
        description: isIOS
            ? 'Install TestFlight build on physical iPhone/iPad. Verify core flows: launch, auth, primary feature, crash-free session.'
            : 'Install APK/AAB on physical Android device (or Firebase Test Lab). Verify core flows.',
        files: [],
        dependsOn: [],
        verification: 'App launches without crash. Core user flow completes successfully. No regressions vs previous build.',
        estimatedMinutes: 30,
        canRollback: false,
    };
}
function buildStoreSubmitStep(isIOS, order) {
    return {
        order,
        title: isIOS ? 'Submit to App Store' : 'Submit to Google Play Store',
        description: isIOS
            ? 'Submit to App Store Review via `fastlane deliver` or App Store Connect. Complete: screenshots, privacy manifest (PrivacyInfo.xcprivacy), export compliance, age rating.'
            : 'Submit AAB to Play Store internal/production track via `fastlane supply` or Play Console. Complete: content rating, target API level check, 64-bit compliance.',
        files: isIOS ? ['fastlane/metadata/', 'PrivacyInfo.xcprivacy'] : ['fastlane/metadata/android/'],
        dependsOn: [],
        verification: isIOS
            ? 'App Store Connect shows build in "Waiting for Review" or "In Review" state.'
            : 'Play Console shows bundle in selected track. Status: "In Review" or "Published".',
        estimatedMinutes: 30,
        canRollback: false,
    };
}
function buildPhasedRolloutStep(isIOS, order) {
    return {
        order,
        title: 'Phased rollout',
        description: isIOS
            ? 'Enable phased release in App Store Connect: Pricing & Availability → Phased Release. Monitor over 7 days (1% → 100%).'
            : 'Configure phased rollout in Play Console: 1% → 5% → 10% → 20% → 50% → 100% over 7 days. Halt if ANR rate > 0.47% or crash rate > 1.09%.',
        files: [],
        dependsOn: [],
        verification: isIOS
            ? 'Phased release activated in App Store Connect. Crash-free rate stable > 99.5%.'
            : 'Phased rollout percentage set in Play Console. Android Vitals within acceptable thresholds.',
        estimatedMinutes: 15,
        canRollback: true,
    };
}
function buildCrashMonitorStep(isIOS, order) {
    return {
        order,
        title: 'Post-release crash monitoring',
        description: isIOS
            ? 'Monitor Crashlytics dashboard for 24h post-release. Alert threshold: crash-free rate < 99.5%. Check Firebase Performance for launch time regressions.'
            : 'Monitor Crashlytics and Play Store Android Vitals for 24h. Alert threshold: ANR rate > 0.47%, crash rate > 1.09% (Play Store policy limits).',
        files: [],
        dependsOn: [],
        verification: 'Crash-free sessions > 99.5% after 1h live. No P0 crashes in top 5 flows. Rollback plan ready if thresholds exceeded.',
        estimatedMinutes: 60,
        canRollback: true,
    };
}
export function generateNativeDistributionPhase(spec, startOrder) {
    const isIOS = spec.target === 'ios';
    let order = startOrder;
    return [
        buildSignedBuildStep(isIOS, order++),
        buildBetaUploadStep(isIOS, order++),
        buildSmokeTestStep(isIOS, order++),
        buildStoreSubmitStep(isIOS, order++),
        buildPhasedRolloutStep(isIOS, order++),
        buildCrashMonitorStep(isIOS, order),
    ];
}
//# sourceMappingURL=native-steps.js.map