Skip to content

build graph: an input edited while its action runs is recorded with the post-edit fingerprint, so the stale output is marked fresh (build_cache_record fingerprints inputs after the run) #1654

Closed

Description

@ehartford

Observed while iterating on D66 with with build :dev: I edited src/compiler/FacadeRender.w about a minute into a running stage1 build. The build finished green with a stage1 compiled from the pre-edit source (its behavior proved it: the alias-chasing change was absent), and the next with build :dev reported everything fresh in 2.1s. touch did not help (content fingerprints); only a further content change forced the rebuild.

Mechanism (src/BuildGraphCache.w build_cache_record): the record is written after the action completes, and it fingerprints the inputs at record time —

pub fn build_cache_record(root, target, discovered_deps, effects):
    build_cache_forget_fingerprints()
    …
    let input_paths = build_cache_collect_input_paths(root, target)
    for idx in 0..input_paths.len() as i32:
        let hash = build_cache_fingerprint_file(path)      // <- after the run
        content = content ++ "in:" ++ path ++ ":" ++ hash ++ "\n"

so an input that changed between the action's start and its end is recorded with the content the action never saw. The freshness check then agrees with the stale record forever, silently (a tool that stayed silent while the bug existed). A long action (stage1 ≈ 3 min, the release build, the test lanes) plus an editor or an agent is the ordinary case.

Fix route: capture the input fingerprints when the action is dispatched (they are computed for the freshness check anyway — build_cache_freshness_reason) and hand those to build_cache_record; or re-fingerprint after the run and refuse to record (mark the target dirty, print which input moved) when any input's fingerprint differs from the pre-run one. The second is the loud form.

Activity

  1. ehartford commented on Sep 26, 2026

    @ehartford
    ContributorAuthor

    Fixed on main by #1705 (db89bc5): inputs are snapshotted at dispatch; an input that moved during the run is not recorded and the target re-runs.

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