[spec-enforcer] Enforce specifications for stringutil, styles, testutil#29283
Closed
github-actions[bot] wants to merge 1 commit intomainfrom
Closed
[spec-enforcer] Enforce specifications for stringutil, styles, testutil#29283github-actions[bot] wants to merge 1 commit intomainfrom
github-actions[bot] wants to merge 1 commit intomainfrom
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Collaborator
|
@davidslater interresting |
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.
Caution
Security scanning requires review for Package Specification Enforcer
Details
Potential security threats were detected in the agent output. The workflow output should be reviewed before merging.
Review the workflow run logs for details.
Specification Test Enforcement
This PR adds/updates specification-driven tests for the following packages:
stringutilstylestestutilTest Derivation
All tests are derived from README.md specifications, not from implementation source code. Minimal source reads were limited to verifying function signatures and confirming SPEC_MISMATCHes.
pkg/stringutilUpdated 2 existing test functions:
TestSpec_PublicAPI_IsPositiveInteger— added"0"→falseand"007"→falsecases documented in the README ("Returns false for"","0", negative strings, strings with leading zeros").TestSpec_PublicAPI_NormalizeSafeOutputIdentifier— converted to table-driven and added period→underscore test case from the documented example:"executor-workflow.agent"→"executor_workflow_agent".Added 9 new
TestSpec_functions:TestSpec_PublicAPI_NormalizeWhitespace— validates documented behavior: trims trailing spaces/tabs from every line, ensures exactly one trailing newline (or empty for empty input), collapses multiple trailing newlines to one.TestSpec_PublicAPI_GetPATTypeDescription— validates that the function returns a non-empty human-readable description, and that a fine-grained PAT returns a description containing"fine-grained"as documented.TestSpec_PublicAPI_SanitizeIdentifierName— validates: invalid chars replaced with_, digit-starting identifiers prefixed with_, valid identifiers unchanged,extraAllowedfunction permits specified runes.TestSpec_PublicAPI_SanitizeParameterName— validates: hyphens replaced with_,$preserved,_preserved, spaces replaced with_, letters+digits preserved.TestSpec_PublicAPI_SanitizePythonVariableName— validates basic identifier sanitization (hyphens → underscores, valid chars preserved).TestSpec_PublicAPI_SanitizeToolID— skipped (see SPEC_MISMATCH below).TestSpec_PublicAPI_SanitizeForFilename— 2 passing cases (space→hyphen for lowercase input; already-safe string unchanged) + 1 skip for lowercasing mismatch.pkg/stylesAdded 1 new
TestSpec_function:TestSpec_Constants_RemainingAdaptiveColorHexValues— validates exact hex values for the 7 remaining documented adaptive color variables:ColorPurple,ColorYellow,ColorComment,ColorForeground,ColorBackground,ColorBorder,ColorTableAltRow. The README explicitly documents all 11 hex values and the design notes state "Colors are defined with both light and dark hex constants so tests can assert exact color values." The previous spec_test.go only asserted exact values for 4 of the 11.pkg/testutilNo changes needed. All 6 existing
TestSpec_functions comprehensively cover the 4 documented public functions (GetTestRunDir,TempDir,CaptureStderr,StripYAMLCommentHeader), including cleanup behavior and idempotency guarantees.Spec-Implementation Mismatches
stringutilSanitizeToolIDSanitizeToolIDas "Replaces characters that are not valid in identifiers with underscores" (identifier sanitization), but the implementation removes"mcp-"prefixes and"-mcp"suffixes from tool IDs — entirely different behavior.stringutilSanitizeForFilenameSanitizeForFilenameas "lowercasing and replacing non-alphanumeric characters with hyphens," but the implementation does not lowercase the output and also preserves_,., and-characters (which are non-alphanumeric).Round-Robin State
stringutil,styles,testutiltimeutil,tty,typesReferences:
Auto-generated by Package Specification Enforcer workflow