feat(cost): persist run_id on generated posts + back-populate for v0.8.1 reaper
The orphan-research-row reaper (upcoming commit) needs a cheap way to answer "which posts belong to this run_id?" when amortizing a stranded `llm_research` row back to its siblings. Relying on the generation_log post_id column is circular: if the pipeline died before amortize_research ran, we'd trust the same table we're trying to repair. - `Publisher::build_meta()` now accepts `?string $run_id` and writes `_prautoblogger_run_id => $run_id` when non-empty. Null/empty preserves existing null-safe legacy behaviour. - `Publisher::create_post()` forwards the $run_id it already receives into build_meta — one-line plumbing, no new parameters at call sites. - `Activator::backpopulate_run_id_meta_v081()` runs once per site, gated by `prautoblogger_migrated_run_id_meta_v081` option. Walks `wp_prautoblogger_generation_log`, pairs (post_id, min(run_id)), writes `_prautoblogger_run_id` on any post that doesn't already have it. Uses `metadata_exists()` so it's a no-op on re-run. - Activator also schedules the new daily `prautoblogger_reap_orphan_research_rows` cron at 03:15 — 15 min after the primary generation cron — so live pipelines have time to finish amortizing cleanly before the reaper scans. - Deactivator unschedules the new hook alongside the existing cron hooks. No user-visible behaviour change yet. The reaper handler ships in the next commit; this one just ensures it will have the data + schedule it needs when it lands. Part of the v0.8.1 bundle (thread research-cost-reaper). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -36,6 +36,7 @@ class PRAutoBlogger_Deactivator {
|
||||
$hooks = [
|
||||
'prautoblogger_daily_generation',
|
||||
'prautoblogger_collect_metrics',
|
||||
'prautoblogger_reap_orphan_research_rows',
|
||||
];
|
||||
|
||||
foreach ( $hooks as $hook ) {
|
||||
|
||||
Reference in New Issue
Block a user