Fix: commit score/tailor/cover-letter results incrementally instead of in one final batch - #90
Open
mprecilio20 wants to merge 1 commit into
Open
Conversation
…nal batch Each of these three stages previously accumulated all results in memory and only wrote/committed to the database once, after every job in the batch had been processed. On a run of any real size this means a crash, kill, or interruption partway through loses all progress for that stage, even though most of the work (LLM calls, resume/cover-letter files already written to disk) had already completed successfully. This also made `applypilot status` misleading mid-run: scored/tailored/ cover-letter counts stayed at zero for the entire duration of a stage, even while it was actively making progress, since nothing had been committed yet for status to see. Each stage now commits right after processing each individual job. Since the job-selection queries already filter on the relevant column being NULL (fit_score, tailored_resume_path, cover_letter_path), a rerun after an interruption naturally skips already-completed jobs with no changes needed there -- this was already the intended resume behavior, it just wasn't reachable in practice. No behavior change on a clean, uninterrupted run other than `status` reflecting progress in real time. Per-row commits add negligible overhead relative to the LLM call each row already waits on.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
score,tailor, andcoverpipeline stages each accumulate all per-job results in memory and only write/commit to the database once, after every job in the batch has finished — not incrementally per job.This causes two real problems on any run of meaningful size:
applypilot statusis misleading while a stage is running. Scored/tailored/cover-letter counts stay at zero for the entire duration of a stage, even while it's actively making progress, because nothing has been committed yet forstatusto read. It looks like the pipeline is stuck when it isn't.Fix
Each stage now commits immediately after processing each individual job, instead of accumulating and writing once at the end.
The "don't reprocess already-completed jobs" behavior needed no new logic — it already existed via the job-selection queries filtering on the relevant column being
NULL(fit_score,tailored_resume_path,cover_letter_path). It just wasn't reachable in practice, since nothing was ever committed for those filters to see mid-run. Restarting after an interruption now naturally resumes from where it left off.Scope
Deliberately narrow — just the three
run_scoring/run_tailoring/run_cover_lettersfunctions inscoring/scorer.py,scoring/tailor.py,scoring/cover_letter.py. No behavior change on a clean, uninterrupted run, other thanstatusreflecting real progress instead of zeros throughout.Test plan
ast.parse)pending_scorequery (confirms resume-skip behavior works)applypilot statusmid-run before and after the fix — before: stuck at 0 scored for the entire stage; after: count increments in real time as each job completestailor/cover_letter's attempt-counter semantics, since those two also increment a retry counter for failed jobs (unchanged behavior, just moved inside the loop)Per-row commits add negligible overhead relative to the LLM call each row already waits on (milliseconds vs. seconds-to-minutes).