Files
ai-exchange/SESSION.md
T
2026-05-12 08:11:16 +08:00

18 KiB

ai-exchange Session

Current Goal

Automation execution-layer P17 is closed locally. P17 adds a structured visual trigger ROI router so ordinary observe/monitoring states skip visual review with an auditable reason, while actionable or degraded events create policy-backed visual watch requests and expose trigger/skip counters in runtime and quality summaries. The default next action is P18 Visual Evidence Media Dispatch.

Current Branch

main

Last Updated

2026-05-12 UTC

Automation Status

  • state: automation_execution_layer_p17_visual_trigger_roi_router_closed
  • current_phase: P17 Visual Trigger ROI Router
  • latest_p7_selector_choice: continue_periodic_analysis_decision_monitoring_with_maturity_rollup
  • latest_p14_slice: webhook_transport_retry
  • latest_p15_pxx_tasklist_status: ready
  • latest_p15_pxx_tasklist_path: docs/AI_ICT_自动化执行层_P15-PXX闭环任务清单_v1.md
  • latest_p15_slice: alert_noise_policy_matrix
  • latest_alert_noise_policy_status: implemented
  • latest_alert_noise_policy_route_status: visible_existing_quality_summary
  • latest_alert_noise_policy_runtime_status: visible
  • latest_p16_slice: browser_screenshot_capture_adapter
  • latest_visual_browser_capture_status: implemented
  • latest_visual_browser_capture_smoke_status: captured
  • latest_visual_capture_script_noop_status: ignored_watch_run_missing
  • latest_p17_slice: visual_trigger_roi_router
  • latest_visual_trigger_policy_status: implemented
  • latest_visual_trigger_policy_smoke_status: idle_no_pending_watch_runs
  • latest_visual_trigger_runtime_status: visible
  • latest_visual_trigger_quality_summary_status: visible
  • next_execution_layer_phase: P18 Visual Evidence Media Dispatch
  • latest_visual_review_script_status: idle
  • latest_runtime_visual_watch_task_status: ok
  • latest_visual_capture_cleanup_task_status: ok
  • latest_runtime_watchdog_task_status: implemented
  • latest_runtime_visual_watch_state: idle
  • latest_visual_snapshot_capture_status: implemented
  • latest_visual_reviews_panel_status: visible
  • latest_visual_feedback_status: implemented
  • latest_visual_alert_evidence_dispatch_status: implemented_existing_channels
  • latest_alert_quality_summary_status: implemented
  • latest_review_packet_alert_quality_status: visible
  • latest_alert_quality_route_status: ok
  • latest_visual_capture_cleanup_status: implemented
  • latest_visual_capture_cleanup_route_status: ok
  • latest_runtime_watchdog_status: implemented
  • latest_runtime_watchdog_route_status: ok
  • latest_alert_silent_window_status: implemented
  • latest_alert_silent_window_route_status: ok
  • latest_alert_retry_recovery_status: implemented
  • latest_alert_transport_retry_status: implemented
  • latest_runtime_blockers: none
  • guards_unchanged: execution_allowed, real_live_ready, risk_governor, trust_bucket, operator_confirmation_protocol

Completed In This Run

  • Verified GSTACK_OK.
  • Promoted the visual-watch prewire into a P8 review loop slice.
  • Added VisualReviewService to review reserved watch runs, create optional snapshot records, create visual reviews, and mark watch runs reviewed.
  • Added scripts/run_visual_review.py for manual or automation-driven review processing.
  • Added VisualSnapshotCaptureService and scripts/run_visual_snapshot_capture.py for advisory review-packet snapshot capture.
  • Added API helpers and routes for POST /trading/visual-watch/review and POST /trading/visual-watch/review-pending.
  • Added a read-only workbench panel for recent visual reviews.
  • Added a runtime visual_watch task that processes pending visual-watch reviews without changing trading gates.
  • Added alert_feedback persistence and feedback service support for alert and visual-review labels.
  • Added visual-review feedback API routes and workbench actions for useful / misleading / actionable labels.
  • Extended alert dispatch messages and delivery payloads with the latest visual evidence for the decision packet.
  • Added AlertQualitySummaryService to aggregate recent alert deliveries, alert feedback, visual feedback, and visual-review states.
  • Added GET /trading/alerts/quality-summary and attached the same summary to review_packet.alert_quality_summary.
  • Added a dashboard Alert Quality panel with delivery success, alert usefulness, visual helpfulness, flags, and operator summary.
  • Applied local migrations through 042_create_alert_feedback.sql so P9 can be exercised on the current database.
  • Added VisualCaptureRetentionService to remove stale .claude/visual_watch/captures HTML/JSON artifacts by retention window.
  • Added scripts/run_visual_capture_cleanup.py and POST /trading/visual-watch/cleanup-captures.
  • Added runtime task visual_capture_cleanup and a workbench Cleanup Old Captures button in the Visual Reviews panel.
  • Added RuntimeTaskWatchdogService to detect runtime tasks that are overdue or running too long.
  • Added scripts/run_runtime_task_watchdog.py and GET /trading/runtime-watchdog.
  • Extended runtime_status and the runtime workbench panel with runtime_watchdog, stalled task names, and per-task stall details.
  • Added AlertSilentWindowService for configurable quiet-hour suppression of outbound non-workbench alerts.
  • Added scripts/run_alert_silent_window_status.py and GET /trading/alerts/silent-window-status.
  • Extended alert dispatch, alert quality summary, runtime alert_dispatch task details, and the Alert Quality panel with silent-window visibility and suppression counts.
  • Added failed-alert retry recovery to AlertDispatcherService with bounded retry attempts and retry backoff.
  • Added retry observability in dispatcher payloads, delivery summary fields, runtime alert_dispatch details, and Alert Quality delivery cards.
  • Added bounded webhook transport retry inside AlertDispatcherService._send so transient outbound failures can be retried before the alert is marked failed.
  • Added transport-retry observability in dispatcher payloads, delivery summary fields, and runtime alert_dispatch details.
  • Added focused unit tests for the service, script, API routing, and runtime task.
  • Added docs/AI_ICT_自动化执行层_P15-PXX闭环任务清单_v1.md to define a finite continuation queue from P15 through PXX.
  • Updated the state anchors so future continuation starts at P15 instead of inventing new unbounded phases.
  • Added alert noise policy matrix settings for external minimum severity, workbench-only alert types, suppressed duty modes, and suppressed operator modes.
  • Extended DeliveryPolicyService with evaluate_alert_delivery_policy() so alert status, silent window, alert type, severity, channel, duty mode, operator mode, and cooldown return a structured policy decision.
  • Extended AlertDispatcherService to persist delivery_policy metadata and expose policy_external_allowed, workbench_only, and suppressed_noise_policy counters.
  • Extended AlertQualitySummaryService, runtime alert_dispatch task details, run_alert_dispatcher.py, and the workbench Alert Quality panel with noise-policy visibility.
  • Added focused unit tests for policy matrix, dispatcher suppression, summary rollup, runtime details, and docs inventory alignment.
  • Added browser-backed screenshot capture support to VisualSnapshotCaptureService using local Edge/Chrome headless when available.
  • Extended visual capture payloads with html_path, screenshot_path, metadata_path, capture_url, browser_capture_status, and structured browser_capture details.
  • Extended scripts/run_visual_snapshot_capture.py, POST /trading/visual-watch/capture, and the workbench Visual Reviews panel with browser capture visibility.
  • Verified a real local browser screenshot smoke produced a PNG from a generated review-packet HTML artifact.
  • Added structured evaluate_visual_trigger_policy() for visual trigger/skip routing with auditable reason codes.
  • Wired decision alert payloads and reserved visual watch requests with visual_trigger_policy, visual_trigger_skip_reason, and visual_trigger_roi.
  • Extended runtime decision_packet and visual_watch task details with visual trigger policy statuses, skip reasons, trigger type counts, and review state counts.
  • Extended visual review payloads, alert quality summary, scripts/run_visual_review.py, and the workbench panels with trigger type and ROI visibility.

Current Working State

  • P7 is closed and remains a monitor-maturity routing layer, not a Research Council expansion.
  • P8 review/capture/feedback surfaces remain implemented and unchanged in their execution guards.
  • P9 quality rollup remains implemented and visible in both the dashboard and review packet.
  • P10 retention cleanup remains implemented and visible in runtime plus workbench flows.
  • P11 runtime watchdog remains implemented and visible in runtime status, API, script, and workbench flows.
  • P12 silent-window noise control remains implemented and visible in dispatcher, summary, runtime, and workbench flows.
  • P13 retry recovery remains implemented: failed alerts can be re-scanned, deferred during backoff, and stopped after bounded retry exhaustion.
  • P14 transport retry is implemented: single webhook send attempts can now be retried in-process before the alert falls back to failed delivery state.
  • P14 transport visibility is implemented: dispatcher results expose transport_attempt_count, delivery summary exposes transport_retried_delivery_count / transport_retry_failed_count, and runtime alert_dispatch details expose transport retry counters.
  • P15-PXX is now a finite known-scope queue: P15 noise policy matrix, P16 browser screenshot capture adapter, P17 visual trigger ROI router, P18 visual evidence media dispatch, P19 multi-channel routing, P20 operator digest/review queue, P21 runtime incident journal, P22 maintenance rollup, P23 unattended harness, P24 remote smoke, and PXX closure gate.
  • P15 noise policy matrix is implemented: external alert sends can be suppressed by severity, alert type, duty mode, operator mode, silent window, or cooldown while workbench visibility remains intact.
  • P15 visibility is implemented: dispatcher payloads include delivery_policy, delivery summary includes noise-policy/workbench-only/external-allowed counters, runtime alert_dispatch details expose policy counters, and the workbench Alert Quality panel displays them.
  • P16 browser screenshot capture is implemented: visual snapshot capture now writes HTML/JSON artifacts and, when browser capture is available, a PNG screenshot; when unavailable, it returns structured browser_capture_status=unavailable without interrupting the visual-watch flow.
  • P16 workbench visibility is implemented: Visual Reviews now expose browser capture status, image path, HTML path, and artifact path.
  • P17 visual trigger ROI routing is implemented: ordinary observe/monitoring states now produce observe_monitoring_not_high_value instead of reserving visual review, while actionable, blocked, market degraded, broker/reconciliation degraded, and council-recommended watch items produce explicit trigger types.
  • P17 visibility is implemented: decision alert payloads carry visual_trigger_policy/visual_trigger_roi, runtime exposes trigger/skip counts, visual review summaries count trigger types and review results, and the workbench displays trigger counters.
  • Latest scripts/run_visual_review.py smoke found no pending reviews: attempted=0, reviewed=0, status=idle.
  • Latest capture smoke returned status=ignored when no watch run was supplied, which is the expected safe no-op.
  • Latest cleanup smoke deleted one expired temporary artifact through scripts/run_visual_capture_cleanup.py.
  • Latest watchdog smoke returned stalled_task_count=0 through scripts/run_runtime_task_watchdog.py.
  • Latest silent-window smoke returned active=true through scripts/run_alert_silent_window_status.py and exposed the same state through /trading/alerts/silent-window-status.
  • Latest dispatcher smoke returned retry-related fields (retry_candidates=0, retried=0, deferred_retry_backoff=0, retry_exhausted=0) through scripts/run_alert_dispatcher.py.
  • Latest scripts/run_trading_runtime.py smoke returned blockers=none and includes a healthy visual_watch runtime task.
  • Latest local runtime smoke confirmed runtime_status.tasks.alert_dispatch.details now exposes retry and silent-window counters with blockers=none.

P17 Blockers

  • none

Current Risks Or Open Questions

  • Browser screenshot capture adapter is a future enhancement, not a P8 closure blocker. The current adapter is an advisory review-packet HTML capture, and the review loop can still use an existing snapshot, an explicit image_path, or write an unavailable structured review.
  • Visual review remains advisory and must not change execution permission, live readiness, trust bucket, risk governor, or operator confirmation.
  • Alert-quality statistics remain advisory and must not change execution permission, live readiness, trust bucket, risk governor, or operator confirmation.
  • Capture cleanup remains operational only and must not change execution permission, live readiness, trust bucket, risk governor, or operator confirmation.
  • Runtime watchdog remains operational only and must not change execution permission, live readiness, trust bucket, risk governor, or operator confirmation.
  • Silent-window suppression remains operational only and must not change execution permission, live readiness, trust bucket, risk governor, or operator confirmation.
  • Retry recovery remains operational only and must not change execution permission, live readiness, trust bucket, risk governor, or operator confirmation.
  • Transport retry remains operational only and must not change execution permission, live readiness, trust bucket, risk governor, or operator confirmation.
  • P15-PXX must remain automation execution-layer work and must not reopen Research Council phases or create new trading permissions.
  • P15 noise policy remains operational only and must not change execution permission, live readiness, trust bucket, risk governor, or operator confirmation.
  • P16 browser screenshot capture remains advisory evidence only and must not change execution permission, live readiness, trust bucket, risk governor, or operator confirmation.
  • P17 visual trigger routing remains advisory evidence routing only and must not change execution permission, live readiness, trust bucket, risk governor, or operator confirmation.
  • A final rerun of scripts/run_alert_dispatcher.py and scripts/run_trading_runtime.py hit local PostgreSQL connection timeout because nothing was listening on 127.0.0.1:5432; the P14 code path is still covered by full unit tests and earlier successful smoke during implementation.
  • P15 dispatcher smoke succeeded with suppressed_noise_policy, workbench_only, and policy_external_allowed counters present. P15 runtime smoke reached alert_dispatch successfully, but the overall runtime returned external environment blockers for market stream disconnected and OKX read transport connection refused.
  • P16 direct browser smoke succeeded locally with browser_capture_status=captured. Script-level capture without a watch run still returns safe no-op watch_run_missing.
  • P17 visual review smoke returned status=idle, skip_reason=no_pending_visual_watch_runs, and empty trigger/review counters, which is the expected safe no-op when no policy-backed visual watch is pending.
  • P17 quality-summary API smoke returned 200 and exposed visual_review_summary.trigger_type_counts / review_result_counts.
  • Latest P17 runtime smoke returned blockers=none and exposes decision_packet.details.visual_trigger_* plus visual_watch.details.skip_reason / trigger counts.
  • Real-live order submission remains intentionally disabled because the OKX order adapter is still not a real-live submitter.

Exact Next Step

P17 is locally closed. Default next action is P18 Visual Evidence Media Dispatch: promote visual evidence from paths/summaries into stable media evidence blocks for alert payloads and workbench consumption, with channel-safe fallback when external media attachment is unsupported.

Validation Commands Used Recently

D:\ai-exchange\.venv\Scripts\python.exe -m unittest tests.unit.test_visual_review_service tests.unit.test_run_visual_review tests.unit.test_trading_runtime_service tests.unit.test_api_and_main tests.unit.test_api_server
D:\ai-exchange\.venv\Scripts\python.exe scripts\run_script_static_checks.py
D:\ai-exchange\.venv\Scripts\python.exe -m unittest tests.unit.test_run_until_blocked tests.unit.test_monitoring_alert_rollout tests.unit.test_runtime_script_json
D:\ai-exchange\.venv\Scripts\python.exe scripts\run_visual_review.py
D:\ai-exchange\.venv\Scripts\python.exe scripts\run_visual_snapshot_capture.py
D:\ai-exchange\.venv\Scripts\python.exe scripts\run_visual_capture_cleanup.py
D:\ai-exchange\.venv\Scripts\python.exe scripts\run_runtime_task_watchdog.py
D:\ai-exchange\.venv\Scripts\python.exe scripts\run_alert_silent_window_status.py
D:\ai-exchange\.venv\Scripts\python.exe scripts\run_trading_runtime.py
D:\ai-exchange\.venv\Scripts\python.exe -m unittest tests.unit.test_visual_snapshot_capture_service tests.unit.test_run_visual_snapshot_capture tests.unit.test_api_static_server
D:\ai-exchange\.venv\Scripts\python.exe -m unittest tests.unit.test_visual_trigger_policy_service tests.unit.test_decision_packet_service tests.unit.test_research_council_decision_packet_fields tests.unit.test_visual_review_service tests.unit.test_alert_quality_summary_service tests.unit.test_trading_runtime_service tests.unit.test_run_visual_review
D:\ai-exchange\.venv\Scripts\python.exe -m unittest discover -s tests/unit
D:\ai-exchange\.venv\Scripts\python.exe scripts\run_visual_review.py