Skip to content

[spec-enforcer] Enforce specifications for console, envutil, stringutil#26194

Merged
pelikhan merged 1 commit intomainfrom
spec-enforcer/console-envutil-stringutil-2026-04-14-8674621b2ad15d48
Apr 14, 2026
Merged

[spec-enforcer] Enforce specifications for console, envutil, stringutil#26194
pelikhan merged 1 commit intomainfrom
spec-enforcer/console-envutil-stringutil-2026-04-14-8674621b2ad15d48

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Specification Test Enforcement

This PR adds specification-driven tests for the following packages, all derived from their README.md documentation (not from implementation source code).

Package Tests Added Tests Passing Spec Sections Covered
console 9 9 Public API, Types, Design Decisions
envutil 8 8 Public API, Boundary Behavior, Nil Logger
stringutil 14 14 General Utilities, ANSI, Identifiers, Sanitization, URLs, PAT Validation

Test Derivation

All tests are derived from README.md specifications. Each test cites the spec section it validates via Go doc comments. All test functions use the TestSpec_ prefix for easy identification.

Coverage Highlights

console (pkg/console/spec_test.go):

  • TestSpec_PublicAPI_FormatFileSize — validates documented examples (0 B, 1.5 KB, 2.0 MB)
  • TestSpec_Types_CompilerError — validates struct fields and documented Type values ("error", "warning", "info")
  • TestSpec_Types_TableConfig — validates ShowTotal, TotalRow fields
  • TestSpec_Types_FormField — validates documented Type values ("input", "password", "confirm", "select")
  • TestSpec_Types_TreeNode, TestSpec_Types_SelectOption — type structure compliance
  • TestSpec_DesignDecision_RenderStruct_SkipTag — validates console:"-" skips fields
  • TestSpec_DesignDecision_RenderStruct_OmitEmptyTag — validates omitempty zero-value behavior

envutil (pkg/envutil/spec_test.go):

  • 8 tests covering all documented GetIntFromEnv behaviors: unset var, non-integer, below-min, above-max, in-range, inclusive min/max boundaries, nil logger safety, and the README usage example

stringutil (pkg/stringutil/spec_test.go):

  • Tests for all 14 documented public functions across stringutil.go, ansi.go, identifiers.go, sanitize.go, urls.go, and pat_validation.go
  • PAT type constant values validated against documented string values

Spec-Implementation Observations

  • NormalizeWhitespace: The README describes the function as "Collapses multiple consecutive whitespace characters (spaces, tabs, newlines) into a single space and trims leading/trailing whitespace." The actual implementation trims trailing whitespace from each line and ensures exactly one trailing newline. The code-level docstring accurately describes the behavior; the README top-level description is misleading. Spec tests cover the correct implementation behavior and note the discrepancy.

Round-Robin State

  • Packages processed this run: console, envutil, stringutil
  • Next packages in rotation: agentdrain, constants, fileutil (indices 0, 2, 4 of eligible list)
  • Total eligible packages: 17 (with README.md)

Auto-generated by Package Specification Enforcer workflow — Run §24394751965

Warning

⚠️ Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

Generated by Package Specification Enforcer · ● 764.4K ·

  • expires on Apr 17, 2026, 11:01 AM UTC

…util

Adds spec_test.go files for three packages derived from their README.md
specifications, covering public API contracts, type structures, and
documented design decisions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@pelikhan pelikhan merged commit 535b0c2 into main Apr 14, 2026
@pelikhan pelikhan deleted the spec-enforcer/console-envutil-stringutil-2026-04-14-8674621b2ad15d48 branch April 14, 2026 11:22
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