From d5e595475cad8137abf6485bfdfc548be6f5573c Mon Sep 17 00:00:00 2001 From: Claw Date: Fri, 6 Mar 2026 22:18:25 +0000 Subject: [PATCH] =?UTF-8?q?fix:=206h=20cooldown=20guard=20on=20searcher=20?= =?UTF-8?q?=E2=80=94=20prevents=20accidental=20re-runs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- job_searcher.mjs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/job_searcher.mjs b/job_searcher.mjs index a9fe5c0..999a9df 100644 --- a/job_searcher.mjs +++ b/job_searcher.mjs @@ -34,6 +34,24 @@ import { ensureLoggedIn } from './lib/session.mjs'; async function main() { const lock = acquireLock('searcher', resolve(__dir, 'data')); + + // Cooldown guard — never run more than once per 6 hours unless --force is passed + const MIN_HOURS_BETWEEN_RUNS = 6; + if (!process.argv.includes('--force')) { + const lastRunPath = resolve(__dir, 'data/searcher_last_run.json'); + if (existsSync(lastRunPath)) { + const lastRun = JSON.parse(readFileSync(lastRunPath, 'utf8')); + const lastRanAt = lastRun.finished_at || lastRun.started_at; + if (lastRanAt) { + const hoursSince = (Date.now() - new Date(lastRanAt).getTime()) / (1000 * 60 * 60); + if (hoursSince < MIN_HOURS_BETWEEN_RUNS) { + console.log(`⏳ Searcher ran ${hoursSince.toFixed(1)}h ago — cooldown (${MIN_HOURS_BETWEEN_RUNS}h min). Use --force to override.`); + process.exit(0); + } + } + } + } + console.log('🔍 claw-apply: Job Searcher starting\n'); let totalAdded = 0, totalSeen = 0;