Skip to content

fix(op): slice accessors return copies; drop a gen group member the generator retired - #640

Merged
David-Noble-at-work merged 1 commit into
developfrom
graph-accessor-and-gen-group-hygiene
Aug 24, 2026
Merged

David-Noble-at-work merged 1 commit into
developfrom
graph-accessor-and-gen-group-hygiene

Conversation

@David-Noble-at-work

Copy link
Copy Markdown
Contributor

Two verified defects from the epic audit. Closes #532 and #572.

#532 — slice accessors aliased the graph's internal storage

Graph.Edges, Subgraph.Edges, and Subgraph.Children returned the graph's own slices, so a caller
outside pkg/op could rewrite which edges and children the graph records — leaving the construction
checksum describing contents that no longer exist. Subgraph.Edges documented the defect rather than
fixing it: "The returned slice aliases the underlying storage; callers must not mutate it directly."

All three now slices.Clone. External mutation becomes impossible rather than discouraged, and the
elements inside stay shared — exactly the sharing the rule permits. The three "must not mutate" comments
are gone because they are no longer true.

Pinned as the issue's exit asks: each accessor is written through with a deliberately wrong value and the
graph is asserted unmoved, plus a check that the units themselves are still shared so only the slice
header is defended.

#572 — a grouped-target member the generator can never emit

Every provider's grouped generation target listed gen/node_builder.gen_test.go, whose emission was
retired with NodeBuilder in phase 5. Under GNU Make 4.4.1's grouped-target (&:) semantics a member that
can never appear leaves the whole group permanently stale, so codegen re-ran on every single build.
Removed from all 16 groups, and the comment block above them corrected to describe what is actually
emitted — with the reason recorded, so the next member added is checked against the generator.

Verified rather than assumed: a second consecutive make build now runs zero codegen invocations.
Before the fix every group was stale, so it ran them all, every time.

The issue's second half — "the groups are also missing a member in the other direction" — is already
correct
in the tree: all 19 providers that emit gen/module.gen_test.go list it. Only the
node_builder half was live.

What this does not fix

GOOS=linux make build still fails, and it is a separate defect, now filed as #639: GOOS/GOARCH
are ambient, so cross-compiling the product also cross-compiles the build tools — go run ./cmd/devlore-inventory produces a Linux binary and then tries to execute it on the host. The standing
cross-platform gate never caught it because make vet compiles without running anything.

Gate: make test 103 ok / 0 fail; make vet clean under darwin, windows, and linux; gofmt -l clean.

@David-Noble-at-work David-Noble-at-work self-assigned this Aug 24, 2026
@David-Noble-at-work
David-Noble-at-work merged commit f2bfff4 into develop Aug 24, 2026
8 checks passed
@David-Noble-at-work
David-Noble-at-work deleted the graph-accessor-and-gen-group-hygiene branch August 24, 2026 15:56
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.

Slice accessors alias the graph's internal storage

1 participant