all() as $sid => $s) { if ($sid === 'wrap_up') continue; // Pull stored autocheck results from session data (we get session_state passed in). $stored = $session_state['autocheck'][$sid] ?? null; if ($stored && !empty($stored['findings'])) { foreach ($stored['findings'] as $finding) { $label = $s->title() . ' → ' . $finding['label']; if ($finding['level'] === 'bad') $bad[] = $label . ' (' . $finding['value'] . ')'; if ($finding['level'] === 'warn') $warn[] = $label . ' (' . $finding['value'] . ')'; } } $step_state = $session_state['steps'][$sid] ?? null; if (is_array($step_state) && ($step_state['status'] ?? '') === 'blocked') { $blocked[] = $s->title(); } } $f = []; $f[] = $this->finding( 'bad_count', count($bad) > 0 ? 'bad' : 'ok', 'Critical findings', (string) count($bad), $bad ? implode(' · ', array_slice($bad, 0, 6)) . (count($bad) > 6 ? ' …' : '') : 'No bad-level findings across steps.' ); $f[] = $this->finding( 'warn_count', count($warn) > 0 ? 'warn' : 'ok', 'Warnings', (string) count($warn), $warn ? implode(' · ', array_slice($warn, 0, 8)) . (count($warn) > 8 ? ' …' : '') : '' ); $f[] = $this->finding( 'blocked_steps', count($blocked) > 0 ? 'bad' : 'ok', 'Blocked steps', (string) count($blocked), $blocked ? implode(', ', $blocked) : '' ); $f[] = $this->finding( 'tip_copy', 'info', 'Tip', 'paste this into the client record', 'Click Copy to clipboard on the finish screen — the full Markdown report is also downloadable.' ); return $f; } };