Repository navigation
Description
Summary
Adding one engine setting touches about 12 files and 6 hand-maintained name tables (CLI flags, scan.Options, scan.Config, subenum.Config, TUI form fields, saved TUI config, settings tokens, completion metadata). Only one of these drifts is guarded by a test.
Where
main.go:117-160(cliFlags),main.go:174-211(flag defs),main.go:1067-1093(scanOptions)internal/scan/options.go:14-38,:69-95(Options->Config20-field copy)internal/scan/settings.go:15-32,:55-67(Settingconsts,FlagName)pkg/subenum/subenum.go:46-136(Config),:480-500,:564-575(configFields)internal/tui/form.go:24-44,:60-79,:442-529(formValues,settingLabel)internal/tui/config.go:11-30,:110-152(savedConfig,withSettings17-case switch)main_resume.go:110(unsavedSettings),main_completion.go:20-33(fileFlags,valueChoices)
Details
Grep for max-queries|MaxQueries|max_queries in non-test Go hits 10 files. withSettings is a switch on CLI flag strings that duplicates the flag table; FlagName, settingLabel and configFields are three more copies of the same mapping. withSettings silently ignores any flag not in its switch, so a SUBENUM_* default for a new flag never reaches the TUI and no test fails. The last two refactor commits (57d9258, 2edfd89) were exactly this kind of synchronisation.
Why it hurts now
A new engine knob needs roughly 15 edits across three front ends, and most omissions are silent.
Suggested plan (each step leaves the tree green)
- Add one table in
internal/scan/settings.go:type settingInfo struct{ Setting; Flag, Field, Label string }; deriveFlagName,configFields,settingLabelfrom it and delete the three maps. Test: everySettingsentry has all three names. - Make
scan.Options.Config()a trivial copy (onlyTimeoutMstranslated) or embedConfigto remove the 20-field copy. - Replace the
withSettingsswitch with a loop over the table keyed byFlag, plus a test asserting every flag fromparseFlags(nil)not in the output-only set is handled. - Derive
fileFlags/valueChoicesfrom flag metadata or assert coverage inmain_completiontests.
Tests to have first
TestSettingLabelsCoverEverySetting(form_test.go:233),TestCLIBuildsSharedConfig(main_test.go:218),TestFormBuildsSharedConfig(form_test.go:189),TestDefaultsMatchTheCLI(pkg)
Acceptance criteria
- One source of truth for setting token, flag name, config field and label
- A test fails when a flag is added without wiring it to the TUI config layer
Getting started
- Relevant files: see "Where"
- How to run tests:
go test ./... - Related docs:
docs/ARCHITECTURE.md
Filed by repo-audit/full-audit at 3139c44. Severity: medium. Effort: M. audit-key: tech-debt|internal/scan/settings.go|Setting
Activity
TMHSDigital commentedon Nov 10, 2026
Fixed in eb0193f.
internal/scan/settings.gonow has one table that gives each engine setting its flag (which is also the config file key and theSUBENUM_*suffix), itspkg/subenumConfig field and its TUI label.FlagName,FieldName,LabelandSettingsall come from that table. TheconfigFieldsmap,settingsWithoutFieldand theFlagNameswitch have been removed. TUI form fields that have a setting take their label and flag from the table. Each field points at itssavedConfigslot, sowithSettingsis now a loop overformFieldsinstead of the 17-case switch.New tests:
TestSettingTablechecks that every setting has a unique flag, field and label.TestSettingNamesAgreeAcrossFrontEnds(main) checks that every CLI flag is either wired into the TUI or listed intuiOmittedFlags, that every flag the TUI reads exists, and that every setting's flag is real.TestWithSettingsSeedsEveryFlaggedFieldchecks that each flag seeds its own form field and no other.Flag names, config keys, messages and TUI labels did not change. The existing docs, config and form-row tests pass without edits.
Verified with
go build,go vet,go test -race -shuffle=on ./...andgolangci-lint(0 issues).Not done here: steps 2 (the Options-to-Config copy) and 4 (completion metadata). Neither is part of the acceptance criteria.