Skip to content

audit.py's hub_last_change() reads whatever branch ROOT is on, not main #1017

Description

@ptr727

_git_revisions() (spec/audit.py) runs git log/git show with cwd=ROOT, where ROOT = pathlib.Path(__file__).resolve().parent.parent — i.e. whatever branch the invoking checkout happens to have checked out, not necessarily main. hub_last_change() (used by check_intent_staleness) walks that same HEAD-relative history to find the hub canonical's newest effective change.

Per AGENTS.md/AUDIT.md's own principle, the hub's main branch is ground truth for what's actually been promoted. If the audit is run from a checkout on develop or a feature branch (a common case — this repo's own working checkouts are routinely on develop), hub_last_change() can return a commit that hasn't reached main yet, and check_intent_staleness can then mark a downstream copy as "possibly trailing" a canonical version that main doesn't actually contain.

Raised by CodeRabbit on PR #1016 (develop -> main promotion), against pre-existing code (not introduced there): #1016 (comment) (approximate; see PR #1016 review thread on spec/audit.py:1732).

Fix direction per the reviewer: read the hub's canonical history from an audit-owned checkout fetched fresh from main, immediately before reading (the same pattern AUDIT.md already documents for reaching the hub as a checkout of one's own), rather than trusting the invoking process's own working-directory branch. Flagged as a heavy lift, deferred rather than fixed inline on the promotion PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions