Terminology (5)Terms used in this lesson
Term on the front, definition on the back. Paste with tabs between fields and a new line between cards, or import the download in Anki as Basic.
- Target
- The program or library a build command is asked to produce.
- Import closure
- A target plus every unit reachable from it through imports, directly or indirectly.
- Dependency-first order
- An order in which every unit comes after all of the units it imports.
- Stale
- Out of date: built from inputs that have since changed.
- Export data
- The compiled description of a Go package’s exported API that importers read.
A build starts from a target
A build command selects a target, such as an executable, and uses source files, dependency declarations and configuration to produce it. A direct dependency is named by the target; a transitive dependency is reached through another dependency. Together these relationships form a graph that helps explain which inputs belong to the selected work.
Build tools also decide which results they can reuse after an edit. That depends on their compilation units and cache rules: a source module, a package, a crate and a C++ translation unit are not interchangeable build units. We will first reason with an explicit project graph, then compare that model with the actual tool reports.
01Inputs
Which files does the build read?
The shipping team is adding pound support to its parcel quote command. The repository also contains a daily shipped-weight report, and both programs use shared weight constants. Before changing the CI job, establish what building the quote command selects and what a change to those constants requires it to redo.
The quote command is named app. It formats a parcel’s weight and calculates its price, using two helpers that share units. report is a separate program in the same repository. Start with the dependency declarations: does selecting app also select report, and can the build omit units because app never names it directly?
go build -o /dev/null ./app selects the main package in app/ and its imports. This recorded probe discards the executable; the explicit output path also avoids colliding with the app directory.
| Unit | Imports | Role |
|---|---|---|
| app | format, rates | The quote command: weight and price for one parcel |
| format | units | Formats parcel weights for quotes |
| rates | units | Prices a parcel by weight |
| report | units | The daily shipped-weight report, a second program |
| units | — | Shared weight constants; weights are stored in grams |
// shipping/app/main.go: the quote command, the main package that go build ./app compiles
package main
import (
"fmt"
"example.com/shipping/format"
"example.com/shipping/rates"
)
func main() {
const parcelGrams = 2500
fmt.Printf("%s: %d cents\n", format.Kilograms(parcelGrams), rates.PriceCents(parcelGrams))
}
go list -deps ./app && go build -v -o /dev/null ./app
The displayed files are excerpts from four complete offline projects with no external dependencies. The commands identify the input/order probes discussed here; the snippets alone are not complete projects. Reports were recorded on 1 November 2026 with Node 22.21, TypeScript 6.0.3, Go 1.27.3, Cargo 1.99.1 and Apple clang 17. No package installation or registry resolution is exercised.
02Order
In which order are units compiled?
The input list puts units under both format and rates. That raises a scheduling question for the CI job: must both helpers wait for units, and does one helper have to wait for the other? A dependency-first plan puts prerequisites before their dependents. To interpret an actual log, first establish what this tool treats as one compilation unit.
format imports units. go build -a -v -o /dev/null ./app prints the packages as it compiles them.
// shipping/format/format.go
package format
import (
"fmt"
"example.com/shipping/units"
)
func Kilograms(grams float64) string {
return fmt.Sprintf("%g kg", grams/units.GramsPerKilogram)
}
03Staleness
What does an edit make stale?
The CI input boundary is now clear. Pound support starts by adding an exported conversion constant to units. Both helpers depend on that unit, and app depends on the helpers. Does the quote job need new helper results, or can it reuse them? Compare this change with editing just the pricing helper.
Use a conservative unit model first: mark the edited unit stale, then any unit that depends on a stale result. Continue through the selected target’s closure. This follows dependents toward the target; it does not make the edited unit’s own prerequisites stale. The real tool may reuse results using finer evidence.
The proposed addition to units is an exported constant. The recorded comparison also includes a comment-only edit to the same package.
// shipping/units/units.go
// Package units holds the shared weight constants. Weights are stored in grams.
package units
const GramsPerKilogram = 1000
04Practice
Add a CI impact preview
The shipping team wants a reviewable plan for its label-printing job as well as its quote command. Extend a small CI preview that accepts a unit graph, a selected target and an edited unit. It reports direct dependencies, a stable dependency-first plan and the affected units. The preview uses the conservative model taught here; it does not execute builds or reproduce a native cache. Each task supplies the helpers outside its edit.
The CI impact preview
Read the job’s dependencies, produce its plan, then show the effect of an edit.
Sign in to keep your read marks on every device. Sign in
Was this helpful?