Skip to content

Add the spec inventory gate (keywords/attributes/CLI/modules vs spec tables) #410

Closed

Description

@ehartford

Summary

Add an automated spec inventory gate so drift in keywords, user-facing attributes, CLI commands/flags, and stdlib module names is caught by with build :test instead of rediscovered during requirements audits.

Spec

The inventory should be derived from the normative spec tables:

  • docs/with-specification.md:9608-9634 for CLI commands and stable flags.
  • docs/with-specification.md:9922-9967 for stdlib layering and module map.
  • docs/with-specification.md:11179-11208 for the user-facing and implementation-internal attribute index.
  • Section 29.11 for the keyword inventory.

Current state

There is already a precedent for build-time spec drift checks. build.w:457-463 defines requirements-informative-check, and build.w:923 makes the test group depend on it.

The compiler's keyword set is in src/Token.w:26-68. Attribute parsing currently accepts user-facing and internal attributes in src/Parser.w:520-667, including internal entries such as bench, stack_size, callconv, and compiler_hook. The CLI command table and help text live in src/main.w:601-742 and src/main.w:2485-2564. The checked-in stdlib module files are under lib/std/.

No single gate currently compares those implementation inventories to the spec tables.

Implementation plan

  1. Add scripts/check-spec-inventory.py.
  2. Parse docs/with-specification.md for:
    • keyword table in §29.11,
    • attribute table in §29.14 plus the internal-attribute note,
    • CLI tool table and additional stable flags in §18.5,
    • stdlib module map and layer-1 std.os requirement in §18.6.
  3. Parse implementation inventories from:
    • src/Token.w keyword token names,
    • src/Parser.w accepted @[...] attribute names,
    • src/main.w command dispatch/help and stable flags,
    • lib/std/*.w module filenames.
  4. Include a narrow allowlist for implementation-internal diagnostic surfaces called out by the spec, not a generic ignore bucket.
  5. Wire the script into build.w beside requirements-informative-check and make :test depend on it.

Test plan

  • Run the new script directly and verify it fails on a deliberately edited temporary mismatch.
  • Run with build :test after wiring to confirm the gate is part of the normal test graph.
  • Add focused script-level fixtures if the project already has script tests; otherwise keep the parser small and deterministic enough that the build target is the test.

Acceptance criteria

  • Drift between the spec inventories and implementation inventories fails loudly.
  • Internal commands/attributes are allowed only when the spec marks them implementation-internal.
  • The gate is included in with build :test.
  • with build, with build :fixpoint, with build :test, and with build :test-green pass before this issue is closed.

Dependencies

Related to #386 because a regenerated requirements file makes the same source-of-truth relationship explicit, but this gate should read the spec directly rather than trusting stale requirements output.

Activity

  1. ehartford commented on Jun 10, 2026

    @ehartford
    ContributorAuthor

    Implemented in 6b8b2a6. Added the spec inventory gate, wired it into :test, documented current internal attributes, added std.testing facade coverage, and regenerated requirements.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions