Skip to content

fix(tests): smoke_sha_gate main() tests drift with the real clock #374

Done

Description

@Jammy2211

Overview

Heart Tests on main fail since 2026-11-26 because two smoke_sha_gate main() tests use a fixed previous full-sweep timestamp (2026-11-18T03:00:00Z) while main() reads the real clock. Once that timestamp passed FULL_SWEEP_MAX_AGE_DAYS (7), the gate correctly forces a sweep and the tests' "no main moved" expectation fails. This is the Heart RED reason PyAutoHeart: Heart Tests failure on main, which blocks every Heart PR, including #373.

Plan

  • Make the two main() tests use a previous full-sweep time one day before the real now, so they test the "no main moved" path on any date.
  • Leave the gate and the 7-day rule untouched (test-only change).
  • Verify with the sha-gate tests, the full Heart suite, and the two tests rerun under a clock shifted weeks ahead.
  • Ship one corrective PR under AUTONOMY.md's "Corrective-PR exception for Heart RED".
  • Tier: effective level: human-required; merge mode: human /prm
Detailed implementation plan

Affected Repositories

  • PyAutoHeart (primary)

Branch Survey

Repository Current Branch Dirty?
./organs/PyAutoHeart main clean

Suggested branch: feature/smoke-sha-gate-date-drift

Implementation Steps

  1. tests/test_smoke_sha_gate.py: in test_main_writes_record_outputs_and_summary and test_main_reads_force_and_the_latest_run_from_the_environment, build the previous record with _previous(_shas(), full_ts=<real now - 1 day, %Y-%m-%dT%H:%M:%SZ>) via a small helper.
  2. Test: pytest tests/test_smoke_sha_gate.py, full pytest tests, plus the two tests with datetime shifted +30 days in the gate module to prove date independence.

Key Files

  • tests/test_smoke_sha_gate.py — the two main() tests (lines ~150-190)
  • .github/scripts/smoke_sha_gate.py — main() uses datetime.now(utc) (line 224); FULL_SWEEP_MAX_AGE_DAYS = 7 (unchanged)

Original Prompt

Click to expand starting prompt

Heart: smoke_sha_gate main() tests fail as the real clock passes their fixed dates

Type: bug
Target: PyAutoHeart
Repos:

  • @PyAutoHeart
    Themes:
  • ci
  • tests
    Difficulty: small
    Autonomy: human-required
    Priority: high
    Status: formalised
    Consequence: judge
    Review-minutes: 5
    Unattended: never
    Lane: any

Request (human, 2026-11-26, verbatim)

Do this task here: "Fix date drift in Heart smoke_sha_gate tests"

Diagnosis (2026-11-26)

Heart Tests on main fail since 2026-11-26 (last green 2026-11-24, run 45364461481):

  • tests/test_smoke_sha_gate.py::test_main_writes_record_outputs_and_summary
  • tests/test_smoke_sha_gate.py::test_main_reads_force_and_the_latest_run_from_the_environment[env2-no main moved since run 100]

.github/scripts/smoke_sha_gate.py main() passes datetime.now(utc) to the gate, which forces a
full sweep when the last one is >= FULL_SWEEP_MAX_AGE_DAYS (7) days old. Both tests build the
previous record with _previous()'s default full_ts="2026-11-18T03:00:00Z", which became 7 days
old on 2026-11-25, so main() now reports "...a full sweep runs at least every 7 days" instead of
"no main moved since run 100". The pure-function tests use a fixed NOW and are unaffected.

This is the Heart RED reason "PyAutoHeart: Heart Tests failure on main", which blocks merging
#373 (arcticpy 2.7 stopgap, issue PyAutoHeart#372).

Scope

Test-only: give the two main() tests a previous full-sweep timestamp relative to the real clock
(e.g. one day ago), so they keep exercising the "no main moved" path on any date. Do not change the
gate or loosen FULL_SWEEP_MAX_AGE_DAYS.

Activity

  1. Jammy2211 commented on Nov 26, 2026

    @Jammy2211
    ContributorAuthor

    Corrective-PR exception for Heart RED — authorization

    • RED reason (verbatim, pyauto-heart readiness --dev --repos PyAutoHeart, 2026-11-26): PyAutoHeart: Heart Tests failure on main
    • Authorization (live human, 2026-11-26, this session): asked "Approve the plan and the corrective-PR exception for this Heart RED?" and answered "Approve, corrective".
    • Causal mapping: reason → this issue → plan (test-only fix of the two main() tests in tests/test_smoke_sha_gate.py) → diff (that file only).
    • Permitted: commit, push, one PR. Merge stays a separate human /prm; release stays blocked while Heart is RED.
  2. Jammy2211 commented on Nov 26, 2026

    @Jammy2211
    ContributorAuthor

    Shipped

    Merged #375 (a8ac38b) via human /prm. The two smoke_sha_gate main() tests now use a full-sweep time one day before the real clock; full Heart suite 1523 passed, and the tests pass under a clock shifted +30/+365 days. This clears the Heart RED reason PyAutoHeart: Heart Tests failure on main once Heart Tests on main re-run green. Unblocks #373.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions