File size: 6,700 Bytes
981aa5d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
{
  "job_id": "work-2026-05-04-codexdashboard-validate-sqlite-tests",
  "status": "validated",
  "validated_at": "2026-05-04",
  "objective": "Validate that adding tests for SQLite schema drift / visible DB errors is narrow enough and identify exact files/tests. No implementation.",
  "repo": "/home/smlflg/Projekte/CodexDashBoard",
  "audit_input": "artifacts/codex-audit/result.json",
  "current_checks": [
    {
      "command": "python3 -m pytest",
      "exit_code": 0,
      "result": "16 passed in 0.28s"
    }
  ],
  "evidence": [
    "Audit top task rank 1 is 'Add Codex SQLite schema-drift coverage and user-visible data errors'.",
    "src/codex_dashboard/codex_data.py:list_threads catches FileNotFoundError/sqlite3.Error and returns []; get_stats returns zero DashboardStats; list_logs returns [].",
    "src/codex_dashboard/app.py refresh handlers treat returned empty lists/stats as successful refreshes and render 'No Codex sessions found' or 'No Codex logs found', so DB errors are not currently distinguishable from no data.",
    "tests/test_codex_data.py currently covers normal state.sqlite listing and missing stats DB only.",
    "tests/test_crash_safety.py currently covers locked/minimal DB returning empty quickly, but not real schema drift, malformed values, normal logs DB, or visible DB error state."
  ],
  "recommended_scope": {
    "size": "small_to_medium",
    "narrow_enough": true,
    "summary": "Keep the implementation limited to Codex SQLite data access error reporting and focused data-layer/UI-status tests. Do not combine with process matching, launch assets, GTK action refactors, or Claude helper cleanup.",
    "phases": [
      "Add focused failing tests for state.sqlite schema drift and logs_2.sqlite fixtures.",
      "Add/adjust a minimal data-access result/error seam so SQLite schema/permission/corruption failures remain crash-safe but are visible to callers.",
      "Add a narrow UI/status test seam or AST-level guard proving sessions/log refresh can present a data-access error distinct from empty data."
    ],
    "out_of_scope": [
      "GTK row rendering and button behavior beyond DB-error status visibility",
      "process scanner false-positive policy",
      "systemd/desktop relocatability",
      "Claude data helpers",
      "dependency installation or broad GUI integration testing"
    ],
    "production_code_likely_needs_change": true,
    "production_change_reason": "Tests can be added first, but user-visible DB errors cannot pass with tests alone because current codex_data functions collapse sqlite3.Error into empty results/zero stats and app.py marks those refreshes successful. A minimal non-crashing error state or result wrapper is likely needed."
  },
  "files_to_touch": [
    {
      "path": "src/codex_dashboard/codex_data.py",
      "purpose": "Likely add minimal error-reporting/data-result seam while preserving no-crash behavior for FileNotFoundError/sqlite3.Error."
    },
    {
      "path": "src/codex_dashboard/app.py",
      "purpose": "Likely teach refresh/status layer to distinguish empty data from data access errors for sessions/logs/overview."
    },
    {
      "path": "tests/test_codex_data.py",
      "purpose": "Add focused state.sqlite schema drift, malformed/null field, and stats error tests."
    },
    {
      "path": "tests/test_logs_data.py",
      "purpose": "New focused logs_2.sqlite fixture tests for normal list_logs/search and logs schema drift/corrupt DB handling."
    },
    {
      "path": "tests/test_crash_safety.py",
      "purpose": "Optionally keep/add crash-safety regression that DB failures return quickly and never raise; avoid broadening this file into schema fixture coverage."
    },
    {
      "path": "tests/test_data_error_visibility.py",
      "purpose": "Optional new narrow test module for app/status seam if UI visibility is not covered in codex_data tests."
    }
  ],
  "tests_to_add": [
    {
      "file": "tests/test_codex_data.py",
      "test": "test_list_threads_schema_drift_missing_timestamp_columns_reports_data_error",
      "intent": "Create a threads table missing created_at_ms/updated_at_ms and/or created_at/updated_at expected by the SELECT; assert the failure is represented as a data access error, not silently indistinguishable from no sessions."
    },
    {
      "file": "tests/test_codex_data.py",
      "test": "test_list_threads_schema_drift_missing_search_columns_reports_data_error",
      "intent": "Create a threads table missing title/first_user_message/cwd/git_branch and assert query/listing does not crash and exposes schema drift."
    },
    {
      "file": "tests/test_codex_data.py",
      "test": "test_list_threads_malformed_tokens_or_timestamps_are_bounded",
      "intent": "Use non-integer/null-heavy tokens_used and timestamp fields; assert either safe coercion or explicit row/data error behavior is defined and tested."
    },
    {
      "file": "tests/test_codex_data.py",
      "test": "test_get_stats_schema_drift_reports_error_without_exception",
      "intent": "Assert get_stats preserves crash safety while exposing database/schema failure instead of only DashboardStats(0,0,0,0,None)."
    },
    {
      "file": "tests/test_logs_data.py",
      "test": "test_list_logs_reads_codex_logs_fixture_and_searches",
      "intent": "Create logs table with id, ts, ts_nanos, level, target, thread_id, module_path, feedback_log_body; assert ordering, timestamp ms conversion, shortening/search."
    },
    {
      "file": "tests/test_logs_data.py",
      "test": "test_list_logs_schema_drift_missing_expected_columns_reports_data_error",
      "intent": "Create logs table missing module_path or feedback_log_body/ts_nanos; assert no exception and visible error state."
    },
    {
      "file": "tests/test_data_error_visibility.py",
      "test": "test_session_refresh_status_distinguishes_database_error_from_no_sessions",
      "intent": "Using a headless seam/mocked data function or extracted presenter, assert DB error maps to an error/degraded status rather than '0 sessions' and 'No Codex sessions found'."
    },
    {
      "file": "tests/test_data_error_visibility.py",
      "test": "test_log_refresh_status_distinguishes_database_error_from_no_logs",
      "intent": "Using the same seam, assert logs DB error maps to visible error status rather than '0 log rows' and 'No Codex logs found'."
    }
  ],
  "verifier_command": "test -s artifacts/codex-validate/sqlite-tests-validation.json",
  "notes": [
    "No source code was changed by this validation worker.",
    "The artifact recommends exact implementation/test scope only; it does not implement tests or production changes."
  ]
}