feat(status): add job status tracking with persistence #114

Merged
fuzzy merged 2 commits from feature/0068-add-job-status-tracking into main 2026-07-05 15:42:39 +00:00
Owner

What

Add job status tracking: persist run count, success/failure counts, and timestamps to status.json in each job directory. Display run count and last run in kronai list.

Why

Users can monitor job health and see when jobs last ran without checking logs.

Testing

  • 134 unit tests pass (9 new for status tracking)
  • Pre-commit hooks pass
  • Coverage: 88%

Breaking Changes

None.

Closes #0065
Closes #0066
Closes #0067
Closes #0068

## What Add job status tracking: persist run count, success/failure counts, and timestamps to `status.json` in each job directory. Display run count and last run in `kronai list`. ## Why Users can monitor job health and see when jobs last ran without checking logs. ## Testing - [x] 134 unit tests pass (9 new for status tracking) - [x] Pre-commit hooks pass - [x] Coverage: 88% ## Breaking Changes None. Closes #0065 Closes #0066 Closes #0067 Closes #0068
- JobStatus dataclass for run count, success/failure tracking
- load_status / save_status functions with JSON persistence
- run_job updates status on success and failure
- kronai list shows run count and last run timestamp
Closes #0065
Closes #0066
Closes #0067
Closes #0068
docs: mark Phase 5 Task 1 complete
All checks were successful
CI / test (pull_request) Successful in 50s
CI / lint (pull_request) Successful in 1m18s
1a074fe9f1
Job status tracking with run timestamps, success/failure
counts, and output storage done.
Closes #0068
the.auditor left a comment

Automated Review — PR #114

Result: APPROVED


Clean status tracking implementation. Persists run counts, success/failure tallies, and timestamps to status.json per job directory. Displayed in kronai list.

  • Correctness: save_status called on all exit paths (success, prompt error, MCP error, LLM error). UTC timestamps. Robust loading (handles missing file, corrupt JSON, OSError). save_status raises JobError on write failure.
  • Completeness: Closes #65–#68. ROADMAP updated.
  • Test coverage: 9 tests covering load (missing file, existing, invalid JSON, nonexistent path), save (creates file, increments success, increments failure, mixed runs, timestamps).
  • Maintainability: Clean 81-line module. Functions are focused and well-documented.

Suggestions (non-blocking)

  1. src/kronai/models.py:43-53JobStatus dataclass is defined but never used. status.py works with raw dict[str, Any] instead. Either wire it in or remove the dead code.

  2. src/kronai/cli.py:70last[:16] truncates the timestamp. Full UTC string 2026-07-05T15:30:00Z is 20 chars, so seconds are cut off. Consider a shorter format like %m-%d %H:%M or widen the column.

  3. src/kronai/engine.py:120-121 — For ephemeral jobs, save_status(job, success=True) is called before shutil.rmtree(job.path). The status file is written then immediately deleted with the directory. If persistence for ephemeral runs matters, consider skipping the write or writing to a separate store.

## Automated Review — PR #114 **Result: APPROVED** --- Clean status tracking implementation. Persists run counts, success/failure tallies, and timestamps to `status.json` per job directory. Displayed in `kronai list`. - **Correctness**: `save_status` called on all exit paths (success, prompt error, MCP error, LLM error). UTC timestamps. Robust loading (handles missing file, corrupt JSON, OSError). `save_status` raises `JobError` on write failure. - **Completeness**: Closes #65–#68. ROADMAP updated. - **Test coverage**: 9 tests covering load (missing file, existing, invalid JSON, nonexistent path), save (creates file, increments success, increments failure, mixed runs, timestamps). - **Maintainability**: Clean 81-line module. Functions are focused and well-documented. ### Suggestions (non-blocking) 1. **`src/kronai/models.py:43-53`** — `JobStatus` dataclass is defined but never used. `status.py` works with raw `dict[str, Any]` instead. Either wire it in or remove the dead code. 2. **`src/kronai/cli.py:70`** — `last[:16]` truncates the timestamp. Full UTC string `2026-07-05T15:30:00Z` is 20 chars, so seconds are cut off. Consider a shorter format like `%m-%d %H:%M` or widen the column. 3. **`src/kronai/engine.py:120-121`** — For ephemeral jobs, `save_status(job, success=True)` is called before `shutil.rmtree(job.path)`. The status file is written then immediately deleted with the directory. If persistence for ephemeral runs matters, consider skipping the write or writing to a separate store.
fuzzy merged commit 1a074fe9f1 into main 2026-07-05 15:42:39 +00:00
fuzzy deleted branch feature/0068-add-job-status-tracking 2026-07-05 15:42:39 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/kronai!114
No description provided.