[Arch] Duplicate scrape-result workflow (_apply_result vs scrape_single) with a live timestamp bug #54
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: High | Category: Domain
scheduler.py:240-331(_apply_result) andscheduler.py:448-622(scrape_single) duplicate ~80 lines of the same workflow. Perdocs/tech-debt.md, onlyscrape_singlewas fixed to use carrier event timestamps;_apply_result(the scheduled-cycle path, used for the majority of updates) still uses wall-clock time.Recommendation: Extract one internal function
_apply_scrape_result(shipment, result, *, trigger_source)called by both paths.Refactoring safety: Add characterization tests for both current behaviors first (per docs/architecture.md golden principle #4 — every bug fix gets a regression test).
Full detail:
docs/architecture-review.md§ C + § H.6Fixed on branch
architecture-rework, commitafcbbb9:_apply_resultandscrape_singlenow share onescheduler._apply_scrape_result().Correction while implementing: the specific wall-clock-timestamp bug this issue and
docs/tech-debt.mddescribed turned out to already be fixed independently in both copies (both already computedevent_occurred_atfrom carrier event dates) — the doc was just never updated.docs/tech-debt.mdhas been corrected to reflect this and to describe what was actually fixed.While merging the two copies, found a second, real bug from the same duplication root cause:
main.pyconstructedScraperScheduler(notifier=mqtt_notifier)before the full_CompositeNotifier(mqtt+webhook+ntfy) existed, so scheduled-cycle state-change notifications only ever reached MQTT, never webhook/ntfy. Fixed by reorderingmain.pyso the composite notifier is built first and passed directly. Verified via direct import:main.scheduler._notifier is main._notifieris nowTrue. Full suite: 252 passed at the time of this commit.