Skip to content

[spec-enforcer] Enforce specifications for github, typeutil#39219

Merged
pelikhan merged 1 commit into
mainfrom
spec-enforce-github-typeutil-20260614-3b03d0951ac704b2
Jun 14, 2026
Merged

[spec-enforcer] Enforce specifications for github, typeutil#39219
pelikhan merged 1 commit into
mainfrom
spec-enforce-github-typeutil-20260614-3b03d0951ac704b2

Conversation

@github-actions

@github-actions github-actions Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds spec-driven tests for the pkg/github and pkg/typeutil packages, enforcing their documented public APIs against the package READMEs.


Changes

pkg/github/spec_test.goAdded (292 lines)

New spec test file for pkg/github. All tests are tagged //go:build !integration and derive from pkg/github/README.md, not from implementation source.

Coverage:

Test What it pins
TestSpec_Constants_ObjectiveValues All named ObjectiveValue* constants match README table values (Critical=100, Bug=60, Documentation=5, etc.)
TestSpec_Constants_ZeroValueLabels ai-generated, ai-inspected, smoke-copilot, question, good-first-issue all map to 0
TestSpec_Constants_MultiLabelLogic MultiLabelLogicMax/Sum/First string values
TestSpec_PublicAPI_ComputeObjectiveValue max (default), sum, first multi-label logic; nil receiver returns 0; empty logic falls back to max
TestSpec_PublicAPI_GetObjectiveLabels Returns only labels present in LabelToValue; empty/nil input returns empty slice
TestSpec_PublicAPI_ValidateLabelExists Returns error for missing label; no error for present label
TestSpec_PublicAPI_GetAllLabels Returns all keys from LabelToValue
TestSpec_PublicAPI_MarshalJSON Round-trips an ObjectiveMapping through JSON
TestSpec_PublicAPI_String String() returns valid JSON
TestSpec_DefaultObjectiveMapping Default mapping is non-nil, has non-empty LabelToValue, and MultiLabelLogic == "max"
TestSpec_LoadObjectiveMappingFromConfig Config-precedence fallback: explicit config wins; missing/empty config falls back to default

⚠ SPEC_MISMATCH documented in test:
The README usage examples reference labels (critical, p0, security-fix) that are not present in the built-in DefaultObjectiveMapping. The test records this discrepancy as an expected future reconciliation item.


pkg/typeutil/spec_test.goModified (+2 test functions)

Two new test functions appended to the existing spec test file.

Test What it pins
TestSpec_KMSuffix_ParseInt64KMSuffix Positive (1K→1000, 2M→2,000,000), zero, negative (-1K), empty string, and math.MaxInt64 overflow cases for ParseInt64KMSuffix
TestSpec_KMSuffix_NormalizeInt64KMSuffix Round-trip normalization of values with K/M suffix via NormalizeInt64KMSuffix, including zero and negative inputs

Test impact

  • No production code changed. All changes are test-only (spec_test.go files).
  • New tests will fail fast if constant values, function signatures, or documented behaviours drift from the package README — providing a living contract between spec and implementation.
  • Existing tests in both packages are unaffected.

Notes

  • The SPEC_MISMATCH in pkg/github/spec_test.go is intentional and is expected to be resolved in a follow-up by either updating the README examples or extending DefaultObjectiveMapping to include the referenced labels.
  • Both test files use //go:build !integration and have no external dependencies beyond testify/assert and testify/require.

Generated by PR Description Updater for issue #39219 · 125.1 AIC · ⌖ 13.5 AIC · ⊞ 19.9K ·

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>
@pelikhan pelikhan merged commit 9079c56 into main Jun 14, 2026
@pelikhan pelikhan deleted the spec-enforce-github-typeutil-20260614-3b03d0951ac704b2 branch June 14, 2026 14:38
@github-actions

Copy link
Copy Markdown
Contributor Author

``
@copilot refresh the branch and rerun checks, then summarize any remaining blockers.

Generated by 👨‍🍳 PR Sous Chef · 70.9 AIC · ⌖ 0.96 AIC · ⊞ 17.4K ·

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant