Repository navigation
style(goast): the go-style debt measured and 1,530 cleared, and star searches where the design says (#964) - #991
Merged
Conversation
… neither #938 nor --fix (#964) Ruled 2026-09-29: the 5,455 go-style violations across 848 files are mine to address. Measured before proposing anything, because the shape decides the work: 3,901 in _test.go, 778 in generated files, 1,508 in ordinary .go. Phase 4 said "star lint go-style --fix over the tree, after #938 lands". That is right for most of it and wrong for the largest single block, so it splits three ways. 4a is the templates, and it is unblocked. 778 violations are in generated files that say DO NOT EDIT, so they can be neither swept nor hand-edited -- they are fixed where they are emitted, and three templates emit all of them. The repetition proves it: providerReceiverType, newCtx, getCompensable, getAction and dryRunCtx each appear 58 times and init 46, which is one template across 29 providers. A doc comment in the template interpolates the method name, so what it generates is specific rather than filler. This was sitting behind a dependency on #938 that does not apply to it. 4b narrows the test-function rule in config. 1,204 Parameters and 404 Returns violations are on functions whose only parameter is t *testing.T, and documenting it 1,204 times adds nothing a reader wants. It is a narrowing rather than an exemption: a test still needs a doc comment, because a test's name is not its purpose and the 2,293 missing ones are worth writing, and it does not need the sections. Every file stays linted. 4c is the sweep and still waits on #938, which is what stops --fix emitting Parameters and Returns from signatures today. The division: 778 by template, 1,608 by config, 1,311 by --fix, and 2,490 written by hand. Only the last is unavoidable prose.
…templates -- phases 4a and 4b (#964) 5,455 to 3,927. Two hand-written files, and not one generated file edited by hand. 4b first, because doing 4a first would have added doc comments to test entry points and left their Parameters violations standing, so the number would not have moved cleanly. 4b is the exemption approved 2026-09-29. SourceFile.isTestEntryPoint exempts a Test, Benchmark, Fuzz or Example function in a _test.go file from the Parameters section, and from nothing else: 5,455 to 4,701, 754 cleared. It is in code rather than config because CheckCompliance takes no configuration today, and inventing a knob for one rule would have been a larger change than the rule. The figure was 1,608 until the boundary was measured. That lumped test-file helpers in with framework entry points, and a helper keeps the full rule -- lineOf(t, path, number) has parameters worth documenting. The remaining 303 Parameters and 259 Returns on test-file helpers are debt, not exemption. TestCheckComplianceExemptsTestEntryPoints is what stops it widening, in six cases: an entry point needs no Parameters; Benchmark, Fuzz and Example count too; an entry point still needs a doc comment; a helper in a test file is NOT exempt; a Test-prefixed function in ordinary source is NOT exempt; and an entry point that returns something still needs Returns. It loads through Provider.LoadSourceFile, because that is the only path that sets filename -- parseSourceFile leaves it empty, so a test built on that would have passed while the real linter did something else. 4a is the templates, and the plan had two things wrong about it. There are SIX, not three: receiver_type.gen_test.go.template 377, action.gen_test.go.template 239, module.gen_test.go.template 116, provider.gen.go.template 29, resource.gen.go.template 8, dependent_type.gen.go.template 9 -- 778 exactly. And make generate was not enough. The codegen rules depend on each provider's source, not on the templates, so editing a template marks nothing stale: make generate reported only the inventories and the count did not move. make regenerate exists for this, "ignoring mtimes", and rewrote 131 files. A template edit producing no output, silently, is a trap the next person will also fall into; it is recorded in the plan rather than filed unilaterally. Pre-existing and untouched: pkg/op/provider/shell fails TestExec_Success and TestExec_Failure on this host, and develop at ea5cebd fails the same two identically with none of these changes.
…prefix (#989) star installs its extensions to $PREFIX/share/devlore/star/extensions and searched a list written independently of that. The two matched exactly two prefixes by coincidence -- ~/.local through XDG_DATA_HOME, and /usr/local through a string literal -- so an install to any other prefix went somewhere nothing looked while make install reported success. Four defects. There was no exe-relative probe: the loader now derives <dir of star>/../share/devlore/star/ extensions from os.Executable(), and since the binary lands at $PREFIX/bin/star that one probe is the install target whatever the prefix was. The installer already had the same arithmetic at root.go:382 for unpacked release archives; the loader did not. findExtensionsDir resolved its source relative to the working directory, so self install found the repository's extensions only when run from the repository root. It now uses config.GitWorkspaceRoot, which the loader already used one file away and which handles a linked worktree's .git file rather than assuming a directory. /usr/local/share was a string literal while xdg.DataDirs() sat unused, so /usr/share was never searched and XDG_DATA_DIRS was ignored -- the specification's user half was honored here and its system half was not. The system probes now come from DataDirs(). Source labels were assigned by index against a three-entry array, so ${XDG_DATA_HOME}/star/extensions was reported as `system`; adding probes would have shifted every later label. sourceOf now classifies a path by what it is, which matters because the label is what someone reads when an extension resolved from somewhere they did not expect. Prior art converges on deriving from the binary and letting the environment override: git's --exec-path, Python's sys.prefix, Go's GOROOT, clang's resource directory, and the XDG specification itself. TestDefaultSearchPaths_FindsAnInstallUnderAnyPrefix is the regression test, on a prefix that is neither of the two the old list knew. TestSourceOf pins the labels, including that an install into a prefix under $HOME is the user's. TestDefaultSearchPaths_HasNoDuplicates covers the overlap a longer list creates, since an exe-relative path for a ~/.local install names the same directory XDG_DATA_HOME does. Three tests in cmd/star/star asserted the working-directory behavior and now set the root with config.SetGitWorkspaceRoot, which is how the loader's own tests already controlled scope. The coupling was not incidental: GitWorkspaceRoot caches through a sync.Once, so a Chdir after anything else has resolved it changes nothing, and the old tests passed only because they ran before anything else asked.
…nts agree (#989, #990) This commit exists because I implemented against a design document without reading it. docs/architecture/9-star-extensions.md defines four extension scopes -- project, user, system, embedded -- and says which tool writes each. It was ruled 2026-09-22. Commit 4a86d4c added a fifth search path derived from the running binary, <dir of star>/../share/devlore/star/extensions, without consulting it. That path serves no scope. It existed to find what star self install writes to $PREFIX/share/devlore/star/extensions, and self install should write no extensions at all: builtin extensions are embedded and travel in the binary, and everything else is placed deliberately, by writ at user scope or by the repository at project scope. The prefix payload it searched for is itself the defect, filed as #990. The search was widened to accommodate a breach instead of the design being read and the breach found. Three of #989's four fixes survive, each sanctioned by the design rather than merely plausible. findExtensionsDir resolves project scope through config.GitWorkspaceRoot, which the document names as how project scope resolves. The system paths come from xdg.DataDirs(), because the document's system row is XDG's and a literal covered half of it. Source labels are derived from the path rather than its array index, because the document says each extension records the scope it came from, which a positional label makes untrue. Four documents now agree where they did not. 9-star-extensions.md returns to six search rows, loses the binary-derived path, and gains a Packaging section stating the rule -- star self install installs no extensions -- and saying plainly that the code does not yet match it. #989 withdraws its first defect at the top with the reason. #990 is unchanged; it was already right. And this branch's plan opens its Issue 989 section by naming that the implementation came before the reading. The design document is left asserting that the code is wrong. That is true until #990 lands, and a design that describes intent while the code silently diverges is how this happened in the first place. Rule 12, one commit late: a document a commit makes stale is corrected in that commit. 4a86d4c changed the search path and left the table describing the old one.
…without a scope (#989) `sourceOf` read a path's SHAPE to label it, which broke `NewLoaderWithPaths`, whose contract is that the caller declares the order. A `t.TempDir()` standing in for a checkout is under neither a repository nor the home directory, so it was labeled `system`, and `TestLifecycle_DeduplicationProjectOverridesEmbedded` failed on all four CI platforms. Carrying the path and its label in parallel slices fixed that and panicked `TestConfigIntegration`: a `Loader` built as a struct literal -- which `Application.LoadExtensionsFrom` does in PRODUCTION code, so the panic shipped -- filled one slice and not the other. Both literals now go through `NewLoaderWithPaths`, and each entry is one `searchPath{dir, source}`, so the two cannot fall out of step and no literal can hold a path whose scope is missing. Neither failure was reachable from the package that changed: only `-tags integration,e2e` builds either test, and `go test ./cmd/star/extension/...` reported green twice while CI was red. This script's pre-flight now runs `make test-race` and `make lint-all` -- what CI runs -- in place of a hand-picked package list. Also here: three plan checkboxes still claimed the exe-relative probe that 2ec0da4 reverted, and six golangci-lint findings in this branch's own code -- three British spellings and three gocritic suggestions -- which `go vet` alone never saw.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 4 of #964, and #989 in full. Does not close #964 -- Phase 4c waits on #938 and Phase 3 waits on
lanes 2 and 3 of noblefactor-ops#232.
5,455 go-style violations to 3,925. Two hand-written source files; 131 generated files regenerated from
templates; not one generated file edited by hand.
The debt was measured before anything was proposed
_test.go.gen.go,gen_test.go.goThe plan said "
star lint go-style --fixover the tree, after #938". That is right for most of it and wrongfor the largest single block, so Phase 4 split three ways. 4a and 4b are here; 4c still waits on #938.
4a: six templates, 774 cleared
778 violations are in generated files that say
DO NOT EDIT. They can be neither swept nor hand-edited;they are fixed where they are emitted. Six templates emit all of them, and the repetition is the proof --
providerReceiverType,newCtx,getCompensable,getActionanddryRunCtxappear 58 times each,init46: one template across 29 providers.Two things the plan had wrong, both corrected in it:
make generatewas not enough. The codegen rules depend on each provider's SOURCE, not on thetemplates (
$(P)/json/gen/provider.gen.go &: $(P)/json/provider.go | $(STAR)--$(STAR)is order-only),so editing a template marks nothing stale and
make generatereported only the inventories.make regenerateexists for exactly this, "ignoring mtimes", and rewrote 131 files. That trap is Codegen runs only when Make thinks it is stale, so CI validations fire nondeterministically #702,closed, and cited in the Makefile comment.
4b: the test-entry-point exemption, 754 cleared
Approved 2026-09-29, and the one exception asked for against "everything is linted, always". A
Test,Benchmark,FuzzorExamplefunction in a_test.gofile does not need aParameters:section: thesignature is fixed by the framework, so the section restates the same thing 754 times.
The figure was 1,608 until the boundary was measured. That lumped test-file helpers in with framework
entry points, and a helper keeps the full rule --
lineOf(t, path, number)has parameters worthdocumenting. 303
Parametersand 259Returnson test-file helpers remain debt, and so do 2,293 missingdoc comments: a test's name is not its purpose.
TestCheckComplianceExemptsTestEntryPointsis what stops it widening, in six cases -- including that ahelper in a test file is NOT exempt and that a
Test-prefixed function in ordinary source is NOT exempt. Itloads through
Provider.LoadSourceFile, because that is the only path that setsfilename;parseSourceFileleaves it empty, so a test built on that would pass while the real linter did somethingelse.
#989: extensions searched where they are installed
Three fixes, each sanctioned by
docs/architecture/9-star-extensions.md:findExtensionsDirresolves project scope throughconfig.GitWorkspaceRoot, which the document names ashow project scope resolves. It previously used the working directory, so
self installfound therepository's extensions only when run from the repository root -- and a linked worktree, whose
.gitis afile rather than a directory, is exactly what a naive walk gets wrong.
xdg.DataDirs(). The document's system row is XDG's, and a literal covered/usr/local/shareand never/usr/share, ignoringXDG_DATA_DIRSentirely.Sourcelabels derive from the path, not its array index. The document says each extension "records thescope it came from", which a positional label made untrue --
${XDG_DATA_HOME}/star/extensionsreported assystem.A fourth fix was implemented, committed, and reverted here. It added a search path derived from the
running binary, to find what
star self installwrites to$PREFIX/share/devlore/star/extensions. Thatpath serves no scope in the design:
self installshould write no extensions at all. The prefix payload itlooked for is itself the defect, now #990. The search was widened to accommodate a breach instead of the
design being read and the breach found.
9-star-extensions.mdis corrected here rather than left stale behind the commit that made it so -- rule12, one commit late. It returns to six search rows and gains a Packaging section stating the rule, and
saying plainly that the code does not yet match it. That last part is deliberate: it is true until #990
lands, and a design that describes intent while the code silently diverges is how this happened.
Verified
gofmtclean,go build ./...andgo vet ./cmd/... ./pkg/...exit 0, the affected packages pass, andstar lint starlarkstill resolves extensions project-local -- which is the proof the search works from acheckout, since this edits the code that finds them.
Pre-existing and untouched:
pkg/op/provider/shellfailsTestExec_SuccessandTestExec_FailureonWindows. Checked against the main clone on develop with none of these changes; it fails the same two
identically.
Closes #989
Time
Computed by the algorithm of noblefactor-ops#188 at merge.