Repository source: docs/plans/archive/cron_task_queue_step4_implementation_summary.md
Cron Task Queue — Step 4: Implementation Summary
Stage 1 - Durable task lifecycle
Changes:
Added a private SQLite-backed internal task store, independent of the rebuildable read model.
Restricted initial enqueueing to
rebuild_read_model, with outstanding-task deduplication, atomic claims, bounded attempts, terminal results, and abandoned-claim recovery.Added focused task-store coverage to the test runner.
Verification:
php -l src/ForumRewrite/TaskQueue/SqliteTaskQueueStore.phpphp -l tests/TaskQueueStoreTest.phpphp tests/run.php TaskQueueStoreTest— 5 tests passed.
Notes:
Queue rows remain in their own database, so a read-model rebuild cannot erase a claimed task or its outcome.
Stage 2 - Allowlisted rebuild worker
Changes:
Added the bounded task worker and an explicit
rebuild_read_modeldispatch path.Added the rebuild handler, which reuses the canonical rebuild builder, stale-marker clearing, and read-model execution lock.
Unknown tasks now become terminal failures without invoking a handler; rebuild failures retry only within the queue’s attempt limit.
Verification:
php -l src/ForumRewrite/TaskQueue/TaskQueueWorker.phpphp -l src/ForumRewrite/TaskQueue/ReadModelRebuildTaskHandler.phpphp -l tests/TaskQueueWorkerTest.phpphp tests/run.php TaskQueueStoreTest TaskQueueWorkerTest— 8 tests passed.
Notes:
A disposable live-rebuild smoke command was not run because its temporary-directory cleanup was blocked by the execution environment; the focused tests cover successful dispatch, retry/failure bounds, and refusal of unknown tasks.
Stage 3 - Cron and operator commands
Changes:
Added private queue-path configuration, the
./v3 task-queuecommand family, and a cron-reference command.Added enqueue, bounded worker-run, dry-run, and status operations using a non-overlapping queue-worker lock.
Documented the private queue path, cron worker, and queue-assisted recovery in production and operator runbooks.
Verification:
php -l src/ForumRewrite/TaskQueue/TaskQueueDatabaseConfig.phpphp -l scripts/task_queue.phpphp -l tests/TaskQueueCommandTest.phpbash -n v3php tests/run.php TaskQueueStoreTest TaskQueueWorkerTest TaskQueueCommandTest— 12 tests passed../v3 task-queue cron --log=/tmp/forum-task-queue-smoke.log— printed the expected once-per-minute bounded worker entry; it did not modify crontab.
Notes:
The queue database path may be overridden with
FORUM_TASK_QUEUE_DATABASE_PATH; its default remains private runtime state.
Stage 4 - Forte capability recovery
Changes:
Added explicit Commits-capability inspection, independent of read-model metadata versioning.
Forte Activity now keeps its five ordinary views available, omits unavailable Commit history, shows a safe update notice, and queues one deduplicated rebuild task.
Commit pagination/detail APIs now return the stable
read_model_capability_unavailableresponse instead of reaching SQLite errors.Extended read-model status with capability, rebuild-required, and private queue summary fields.
Verification:
php -l src/ForumRewrite/Application.phpphp -l src/ForumRewrite/ReadModel/ReadModelCapabilityInspector.phpphp -l tests/ForteActivityReadModelRecoveryTest.phpphp tests/run.php ForteActivityReadModelRecoveryTest TaskQueueStoreTest TaskQueueWorkerTest TaskQueueCommandTest— 14 tests passed.php tests/run.php ForteActivityReadModelRecoveryTest WriteApiSmokeTest— new recovery coverage passed and the smoke suite ran through its queue/activity cases.
Notes:
WriteApiSmokeTest::testIncrementalApprovalMatchesFreshRebuildForTransitiveApprovalAndScoreRefreshstill fails on an existing classic-Activity ordering mismatch between two same-second approval records after rebuild. This feature does not change that classic query or ordering path.