[spec-enforcer] Enforce specifications for github, typeutil#39219
Merged
pelikhan merged 1 commit intoJun 14, 2026
Conversation
Add spec-driven tests derived from package README.md files:
- pkg/github/spec_test.go (new): constants, ObjectiveMapping methods,
ComputeObjectiveValue logic (max/sum/first), config precedence, and
documented String() format. Flags a SPEC_MISMATCH (usage examples vs
default mapping contents) and a SPEC_AMBIGUITY ("first" ordering).
- pkg/typeutil/spec_test.go: add missing tests for ParseInt64KMSuffix and
NormalizeInt64KMSuffix, now documented in the README.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 14, 2026
Closed
pelikhan
approved these changes
Jun 14, 2026
Contributor
Author
|
``
|
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.
Summary
Adds spec-driven tests for the
pkg/githubandpkg/typeutilpackages, enforcing their documented public APIs against the package READMEs.Changes
pkg/github/spec_test.go— Added (292 lines)New spec test file for
pkg/github. All tests are tagged//go:build !integrationand derive frompkg/github/README.md, not from implementation source.Coverage:
TestSpec_Constants_ObjectiveValuesObjectiveValue*constants match README table values (Critical=100, Bug=60, Documentation=5, etc.)TestSpec_Constants_ZeroValueLabelsai-generated,ai-inspected,smoke-copilot,question,good-first-issueall map to0TestSpec_Constants_MultiLabelLogicMultiLabelLogicMax/Sum/Firststring valuesTestSpec_PublicAPI_ComputeObjectiveValuemax(default),sum,firstmulti-label logic; nil receiver returns0; empty logic falls back tomaxTestSpec_PublicAPI_GetObjectiveLabelsLabelToValue; empty/nil input returns empty sliceTestSpec_PublicAPI_ValidateLabelExistsTestSpec_PublicAPI_GetAllLabelsLabelToValueTestSpec_PublicAPI_MarshalJSONObjectiveMappingthrough JSONTestSpec_PublicAPI_StringString()returns valid JSONTestSpec_DefaultObjectiveMappingLabelToValue, andMultiLabelLogic == "max"TestSpec_LoadObjectiveMappingFromConfig⚠ SPEC_MISMATCH documented in test:
The README usage examples reference labels (
critical,p0,security-fix) that are not present in the built-inDefaultObjectiveMapping. The test records this discrepancy as an expected future reconciliation item.pkg/typeutil/spec_test.go— Modified (+2 test functions)Two new test functions appended to the existing spec test file.
TestSpec_KMSuffix_ParseInt64KMSuffix1K→1000,2M→2,000,000), zero, negative (-1K), empty string, andmath.MaxInt64overflow cases forParseInt64KMSuffixTestSpec_KMSuffix_NormalizeInt64KMSuffixNormalizeInt64KMSuffix, including zero and negative inputsTest impact
spec_test.gofiles).Notes
SPEC_MISMATCHinpkg/github/spec_test.gois intentional and is expected to be resolved in a follow-up by either updating the README examples or extendingDefaultObjectiveMappingto include the referenced labels.//go:build !integrationand have no external dependencies beyondtestify/assertandtestify/require.