<?php

declare(strict_types=1);

$root = getenv('POC_TARGET_ROOT');
if (!$root) exit(2);
$config = require $root . '/application/database.php';
foreach (['HOST' => 'hostname', 'PORT' => 'hostport', 'SCHEMA' => 'database',
    'USER' => 'username', 'PASSWORD' => 'password'] as $env => $key) {
    putenv('POC_' . $env . '=' . $config[$key]);
    putenv('POC_AI_' . $env . '=' . $config['ai_zhct'][$key]);
}
putenv('POC_APP_ROOT=' . $root);
putenv('POC_DIALECT=mysql');
$scriptMap = [
    'meal' => 'meal_order_read_export_probe.php',
    'payment_fixture' => 'http-harness/payment_fixture_rehearsal.php',
    'payment_readback' => 'http-harness/payment_readback.php',
    'shop_refund' => 'http-harness/shop_refund_http_probe.php',
    'shop_readback' => 'http-harness/shop_refund_readback.php',
    'inspect_fallback' => 'http-harness/inspect_shop_queue_fallback.php',
    'cleanup_work' => 'http-harness/cleanup_shop_test_work.php',
    'onecard_guard' => 'http-harness/onecard_msgid_guard_probe.php',
    'audit_commit' => 'http-harness/audit_commit_fault_cleanup.php',
    'device_weight' => 'http-harness/verify_device_weight_http.php',
    'mocatch_body' => 'http-harness/verify_mocatch_body_http.php',
    'mocatch_orphan' => 'http-harness/audit_mocatch_orphan.php',
    'device_recipe' => 'http-harness/verify_device_recipe_http.php',
    'device_push' => 'http-harness/verify_device_push_http.php',
    'device_charset' => 'http-harness/diagnose_device_charset.php',
];
$script = $scriptMap[(string)getenv('POC_PROBE')] ?? 'wallet_flow_read_probe.php';
require dirname(__DIR__) . '/' . $script;
