Skip to main content

Module interp

Module interp 

Source
Expand description

The triplet interpreter (item 3) — apply(env, ctx) -> BuildSpec.

Walks the encoder phases over go list -deps -json output:

read-go-mod → go-list → parse-go-list → reject-cgo + reject-asm (Go-I12)
  → per-node: relative-path (Go-I3) → read-source + source_hash (Go-I8)
  → resolve-imports (Go-I1) → embed (Go-I9) → tree (Go-I2)
  → roots/members → compact target_resolves → go_sum tie (Go-I7)

Every side effect — the go list subprocess AND source-file reads — is abstracted behind the GoBuildEnv trait, so the whole encoder is driven by a MockGoBuildEnv in unit tests with ZERO go / filesystem dependency. The trait IS the testability contract (TYPED-SPEC + INTERPRETER TRIPLET). A phase that cannot complete returns a typed GomodError::Interp naming the phase — never a silent wrong answer, never a panic!.

Structs§

EncodeCtx
Encoder inputs: the module root + the single target tuple M1 builds.
RealGoBuildEnv
Production GoBuildEnv: shells go and reads the real filesystem. mod_mode defaults to "vendor" — the M1 hermetic contract (vendored tree, no proxy). The one legitimate non-vendor use is a dep-free module (nothing to vendor), which the integration test selects explicitly.

Traits§

GoBuildEnv
The Environment seam — the ONLY place the encoder touches the world. Real builds shell go list + read files; tests mock both.

Functions§

apply
The encoder. Produces a v2 Incremental BuildSpec — the per-package build graph — from go list output + go.mod, hashing every node’s sources for the incremental cache key.