Skip to content

Hash the jobs a job needs into its hash - #30

Merged
ndbroadbent merged 1 commit into
mainfrom
providers/hash-needs
Dec 4, 2026
Merged

ndbroadbent merged 1 commit into
mainfrom
providers/hash-needs

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Rebased onto main after #28. A false skip in today's flow, found while designing the planner (#29). A job's hash covered its own inputs but not the jobs it needs. When test needs build and uses its artifact, a change to build's inputs alone made build run while test skipped on its unchanged hash.

What changed

  • A minimal diff, so tools' Add cigen explain <job>: what a job's hash covers #14 (which moves hashing into src/hashing/) can port it. hash_job stays where it is, and its digest computation becomes job_digest in the same file with the same steps. At the end, job_digest hashes in the whole digest of every job the job needs, through a small new src/commands/needs_hash.rs:
    • in sorted order and transitively;
    • a job it doesn't need stays out;
    • a cycle, which the loader already rejects, is an error naming the chain rather than infinite recursion (unit test).
  • The job being hashed still uses --modules-digest from its generated config. A needed job's module expansions are already covered by its derived inputs.
  • Hashes of jobs with needs change once (the cigen version is in every hash anyway). Generated output is unchanged.
  • Docs: inputs.md lists "the jobs it needs" among what a hash covers; jobs.md says so under needs. STATUS: "Derived inputs" says so, and a new known problem 22 is marked Resolved (PR Hash the jobs a job needs into its hash #30) (Match globs with :(glob) pathspecs: **/*.md now includes root files #28 took 20 and 21).

Testing

  • Test first: derived_inputs::changing_a_job_this_job_needs_makes_it_run (mockci). It failed before the change (build ran, test skipped) and passes now.
  • derived_inputs::a_job_hash_covers_the_jobs_it_needs_transitively_and_no_others: changing a job two steps upstream changes the hash, and changing an unrelated job doesn't.
  • task ci green.

#29 (the design) currently adds this as an open STATUS 20. I'll drop that from #29 when it rebases, so only this PR's Resolved entry remains.

A job's hash covered its own inputs but not the jobs it needs. When test
needs build and uses its artifact, a change to build's inputs alone made
build run while test skipped on its unchanged hash: a false skip.

hash_job's digest computation becomes job_digest (same place, same
steps), which now ends with the whole digest of every job the job needs,
in sorted order, transitively, through the small needs_hash module. A job
it doesn't need stays out. A cycle (which the loader already rejects) is
an error rather than a recursion.

Tests: a mockci scenario where changing build's input makes test run, and
a hash test for a two-step chain plus an unrelated job. STATUS 22 records
it as resolved; the inputs and jobs docs say what the hash now covers.
@ndbroadbent
ndbroadbent merged commit aedc397 into main Dec 4, 2026
8 checks passed
ndbroadbent added a commit that referenced this pull request Dec 4, 2026
Replaces DIRECTION's short "Pass-record stores" section with the design for
order-of-work item 4:

- cigen_plan hashes every job and looks them up in one batch; each job's if:
  reads its output, fail-open (anything but an exact "skip" runs).
- cigen_gate is the one required check, so no required check is ever
  "skipped"; the alternatives (early exit, posted statuses) and their costs.
- The PassStore trait and the HTTP protocol VisualCI's API is specified from:
  keys, lookup/record, scope decided by the server from OIDC claims, expiry,
  fail-open errors.
- How untrusted runs are kept from writing trusted passes, per backend.
- Why it can't skip falsely, the migration from the per-job flow, and what
  mockci needs.

Found while writing it: a job's hash didn't include the jobs it needs, a false
skip in today's flow, fixed separately in PR #30.
ndbroadbent added a commit that referenced this pull request Dec 4, 2026
Ports #30's needs hashing into hashing::hash_job: a job's hash covers the
hashes of the jobs it needs, transitively, and without --modules-digest it uses
the modules digest this cigen computes. cigen explain lists the needed jobs
with their hashes.
ndbroadbent added a commit that referenced this pull request Dec 4, 2026
Ports #30's needs hashing into hashing::hash_job: a job's hash covers the
hashes of the jobs it needs, transitively, and without --modules-digest it uses
the modules digest this cigen computes. cigen explain lists the needed jobs
with their hashes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant