not->toBeFalse(); $route = (string)$route; expect($route) ->toContain('$linked_order_ids_by_wash_id = []') ->and($route)->toContain('array_key_exists($wash_id, $linked_order_ids_by_wash_id)') ->and($route)->toContain('selectByWashId($wash_id)') ->and($route)->toContain("'linked_order_id' => \$linked_order_id") ->and($route)->toContain("'usage_log_id' => \$id"); }); it('limits the usage-logs endpoint to the reviewer permission set', function (): void { $route = file_get_contents(WD . '/routes/xlvaskUsageLogsRoute.php'); expect($route)->not->toBeFalse(); $route = (string)$route; expect($route) ->toContain("list_xlvask_usage_orders_own") ->toContain("list_xlvask_usage_orders_all") ->not->toContain('xlvask_autopilot_service') ->not->toContain('xlvask_automation_service') ->not->toContain('xlvask_automation_policy_service') ->not->toContain('manage_xlvask_usage_automation') ->not->toContain('evaluateUsageLogRow') ->not->toContain('source_hash') ->not->toContain('source_revision') ->not->toContain('import_state') ->not->toContain('resolution_state') ->not->toContain('certainty') ->not->toContain('planned_action') ->not->toContain('expected_version') ->not->toContain('last_run_id'); expect($route) ->toContain("if (\$allowedHallIds === [])") ->toContain("No XL Vask hall scope is available', 403") ->not->toContain('__no_authorized_xlvask_hall__'); }); it('returns cached amount summaries on XL Vask usage order rows without widening the usage-log object payload', function (): void { $route = file_get_contents(WD . '/routes/xlvaskUsageLogsRoute.php'); expect($route)->not->toBeFalse(); $route = (string)$route; expect($route) ->toContain('$amount_summary = $xlvask_usage_logs->getAmountSummaryReadOnly($log)') ->and($route)->toContain("\$usage_log_payload = array_intersect_key(\$log, array_flip([") ->and($route)->toContain("\$tmp->setProperties(\$usage_log_payload)") ->and($route)->toContain("\$tmp_res['order']['total_net_amount'] = \$amount_summary['total_net_amount']") ->and($route)->toContain("\$tmp_res['order']['xlvask_primary_product_name'] = \$amount_summary['primary_product_name']") ->and($route)->toContain("\$tmp_res['order']['xlvask_amount_cached'] = \$amount_summary['cached']"); }); it('keeps ignore metadata out of the strict legacy XL Vask helper payload', function (): void { $route = file_get_contents(WD . '/routes/xlvaskUsageLogsRoute.php'); expect($route)->not->toBeFalse(); $route = (string)$route; expect($route) ->not->toContain("'source_hash'") ->not->toContain("'source_revision'") ->not->toContain("'import_state'") ->not->toContain("'resolution_state'") ->not->toContain("'certainty'") ->not->toContain("'planned_action'") ->not->toContain("'expected_version'") ->not->toContain("'last_run_id'"); }); it('exposes review, accept, reject and ignore endpoints gated on review_xlvask_usage_order', function (): void { $route = file_get_contents(WD . '/routes/xlvaskUsageLogsRoute.php'); expect($route)->not->toBeFalse(); $route = (string)$route; expect($route) ->toContain("patch('/modules/xlvask/services/usage/orders/{id}/ignore'") ->toContain("post('/modules/xlvask/services/usage/orders/{id}/unignore'") ->toContain("post('/modules/xlvask/services/usage/orders/{id}/accept'") ->toContain("post('/modules/xlvask/services/usage/orders/{id}/reject'") ->toContain("requirePermission('review_xlvask_usage_order')") ->toContain("'ignored_at' => \$log['ignored_at'] ?? null") ->toContain("'ignored_by' => isset(\$log['ignored_by']) ? (int)\$log['ignored_by'] : null") ->toContain("'ignored_reason' => \$log['ignored_reason'] ?? null") ->not->toContain('Ignored at server-generated automation decision preview'); }); it('exposes a reviewer summary endpoint that does not invoke the autopilot service', function (): void { $route = file_get_contents(WD . '/routes/xlvaskUsageLogsRoute.php'); expect($route)->not->toBeFalse(); $route = (string)$route; expect($route) ->toContain("get('/modules/xlvask/services/usage/orders/summary'") ->toContain('(new xlvask_usage_logs_o())->summarizeUsageOrdersReadOnly(') ->not->toContain('xlvask_autopilot_service()->getSummary('); }); it('routes legacy autopilot, calibration and policy transition paths through 410 Gone stubs', function (): void { $route = file_get_contents(WD . '/routes/xlvaskUsageLogsRoute.php'); expect($route)->not->toBeFalse(); $route = (string)$route; expect($route) ->not->toContain("'/modules/xlvask/services/usage/autopilot-runs'") ->not->toContain("'/modules/xlvask/services/usage/autopilot-runs/active'") ->not->toContain("'/modules/xlvask/services/usage/automation/admin/policy/previews'") ->not->toContain("'/modules/xlvask/services/usage/automation/admin/policy/apply'") ->not->toContain("'/modules/xlvask/services/usage/automation/admin/halt'") ->not->toContain("'/modules/xlvask/services/usage/automation/admin/calibrations/backtest'") ->not->toContain("'/modules/xlvask/services/usage/automation/admin/calibrations/labels'") ->not->toContain("'/modules/xlvask/services/usage/automation/admin/calibrations/{id}/activate'") ->not->toContain("'/modules/xlvask/services/usage/automation/admin/wash-id-uniqueness/activate'") ->not->toContain("'/modules/xlvask/services/usage/automation/decisions/preview'") ->not->toContain("'/modules/xlvask/services/usage/automation/decisions/apply'") ->not->toContain("'/modules/xlvask/services/usage/automation/capabilities'") ->not->toContain("'/modules/xlvask/services/usage/automation/admin/readiness'"); }); it('allows all-only permission and uses every configured scanner hall for all scope', function (): void { $route = file_get_contents(WD . '/routes/xlvaskUsageLogsRoute.php'); expect($route)->not->toBeFalse(); $route = (string)$route; expect($route) ->toContain("if (!\$this->hasPermission(\$permission_list_all))") ->toContain("if (\$this->hasPermission('list_xlvask_usage_orders_all'))") ->toContain("if (!\$this->hasPermission('list_xlvask_usage_orders_all'))") ->toContain('private function allowedHallIdsForUser(object $user): array') ->not->toContain('private static function allowedHallIdsForUser') ->toContain('SELECT DISTINCT HallId FROM plate_scanners'); }); it('does not let pending automation schema block ordinary invoice period operations', function (): void { $bootstrap = (string)file_get_contents(WD . '/classes/invoice_period_flag_schema_bootstrap.php'); expect($bootstrap) ->not->toContain('xlvask_usage_logs_schema_bootstrap::ensureTables()') ->toContain('XL Vask automation migration is pending'); }); it('does not invoke the autopilot service anywhere on the usage-log listing path', function (): void { $route = file_get_contents(WD . '/routes/xlvaskUsageLogsRoute.php'); $object = file_get_contents(WD . '/objects/xlvask_usage_logs_o.php'); expect($route) ->not->toBeFalse() ->and($object)->not->toBeFalse(); expect((string)$route) ->not->toContain('xlvask_autopilot_service') ->not->toContain('xlvask_automation_policy_service') ->not->toContain('readAutomationStateByUsageLogId') ->not->toContain('evaluateUsageLogRow'); expect((string)$object) ->toContain('summarizeUsageOrdersReadOnly') ->toContain('getAmountSummaryReadOnly'); }); it('removes the AI autopilot and policy service files entirely', function (): void { expect(file_exists(WD . '/classes/xlvask_autopilot_service.php'))->toBeFalse(); expect(file_exists(WD . '/classes/xlvask_automation_service.php'))->toBeFalse(); expect(file_exists(WD . '/classes/xlvask_automation_policy_service.php'))->toBeFalse(); expect(file_exists(WD . '/classes/minimax.php'))->toBeFalse(); expect(is_dir(WD . '/modules/miniMax'))->toBeFalse(); expect(file_exists(WD . '/modules/xlvask/AUTOMATION_RUNBOOK.md'))->toBeFalse(); expect(file_exists(WD . '/cron/EnsureXLVaskAutomationSchema.php'))->toBeFalse(); }); it('removes the MiniMax config endpoints from moduleConfigRoute and the cli migrate command', function (): void { $route = (string)file_get_contents(WD . '/routes/moduleConfigRoute.php'); expect($route) ->not->toContain("'/minimax/config'") ->not->toContain('modules_minimax_config') ->not->toContain('MiniMax config'); $cli = (string)file_get_contents(WD . '/cli.php'); expect($cli) ->not->toContain("'xlvask-automation-migrate'") ->not->toContain('EnsureXLVaskAutomationSchema.php'); }); it('exposes the simplified operator flow in OpenAPI and removes the AI autopilot surface', function (): void { $openApi = file_get_contents(WD . '/openapi.yaml'); expect($openApi)->not->toBeFalse(); $openApi = (string)$openApi; expect($openApi) ->toContain('/modules/xlvask/services/usage/orders/summary:') ->toContain('/modules/xlvask/services/usage/orders/{id}/ignore:') ->toContain('/modules/xlvask/services/usage/orders/{id}/unignore:') ->toContain('/modules/xlvask/services/usage/orders/{id}/accept:') ->toContain('/modules/xlvask/services/usage/orders/{id}/reject:') ->not->toContain('/modules/xlvask/services/usage/autopilot-runs:') ->not->toContain('/modules/xlvask/services/usage/automation/decisions/preview:') ->not->toContain('/modules/xlvask/services/usage/automation/decisions/apply:') ->not->toContain('/modules/xlvask/services/usage/automation/admin/readiness:') ->not->toContain('/modules/xlvask/services/usage/automation/admin/policy/previews:') ->not->toContain('/modules/xlvask/services/usage/automation/admin/policy/apply:') ->not->toContain('/modules/xlvask/services/usage/automation/admin/halt:') ->not->toContain('/modules/xlvask/services/usage/automation/admin/calibrations/') ->not->toContain('/modules/xlvask/services/usage/automation/admin/wash-id-uniqueness/') ->not->toContain('/modules/xlvask/services/usage/automation/capabilities:') ->not->toContain('/modules/xlvask/services/usage/autopilot-runs/{id}:') ->not->toContain('/modules/xlvask/services/usage/autopilot-runs/active:') ->not->toContain('xlvaskAutomationPolicyService') ->not->toContain('xlvaskAutomationService') ->not->toContain('xlvaskAutopilotService'); });