test: spec compliance test validating constants.py against table.csv - #51
test: spec compliance test validating constants.py against table.csv#51sumanjeet0012 wants to merge 1 commit into
Conversation
974befd to
3e9de86
Compare
acul71
left a comment
There was a problem hiding this comment.
AI PR Review: #51 — test: spec compliance test validating constants.py against table.csv
Reviewer: acul71 (maintainer)
PR: #51
Author: sumanjeet0012
Date: 2026-09-07
1. Summary of Changes
This PR addresses Closes #41: there was no automated check that CODECS / NAME_TABLE / CODE_TABLE match the authoritative multicodec table.csv.
Changes:
- Adds git submodule
multicodec-spec→https://github.com/multiformats/multicodec - Adds
tests/test_spec.pycompleteness + consistency checks (skiptag == "none") - Updates
multicodec/constants.pyandmulticodec/code_table.pyto include missing upstream codecs (e.g.mldsa-*), bringing registry to 649 entries on this branch - CI (
tox.yml):actions/checkoutwithsubmodules: true - Excludes submodule from pre-commit / ruff /
make fix
Modules/files: .gitmodules, .github/workflows/tox.yml, .pre-commit-config.yaml, Makefile, pyproject.toml, multicodec-spec, multicodec/constants.py, multicodec/code_table.py, tests/test_spec.py
Breaking changes: None expected (additive codec registry expansion)
2. Branch Sync Status and Merge Conflicts
Branch Sync Status
- Status: Ahead of
origin/master - Details:
0 1→ 0 behind, 1 ahead
Merge Conflict Analysis
✅ No merge conflicts detected. The PR branch can be merged cleanly into origin/master.
3. Strengths
- Matches go-multicodec’s “validate against CSV” approach
- Immediately useful: caught missing codecs vs upstream
- CI correctly checks out submodules on Linux and Windows jobs
- Lint exclusions for the vendored subtree are appropriate
- Local validation: lint, typecheck, 736 tests passed (including
test_spec), docs OK; GitHub CI green
4. Issues Found
Critical
- File:
newsfragments/(missing) - Issue: Missing mandatory newsfragment for issue #41
- Suggestion: Add
newsfragments/41.feature.rst(or41.misc.rst) noting the spec compliance test and codec table sync with upstreamtable.csv
Major
-
File:
CONTRIBUTING.rst/README.rst -
Issue: Contributors cloning without
--recurse-submoduleswill failtest_spec/ local pytest when the submodule is empty -
Suggestion: Document
git clone --recurse-submodulesandgit submodule update --initin contributing docs -
File:
tests/test_spec.py -
Line(s): 14–43
-
Issue: Validates name/code bidirectional consistency but does not assert CSV
tag/status/ description fields (if those are represented elsewhere) or pin/document the expected submodule commit update process -
Suggestion: Acceptable v1 of the test per issue proposal; add a short note in CONTRIBUTING on how to bump the submodule when refreshing the table (and re-run
tools/update-table.pyif applicable) -
File:
pyproject.toml -
Line(s):
[tool.ruff.lint] ignore = ["RUF003"] -
Issue: New global ruff ignore appears unrelated to the submodule exclude; may weaken lint for the whole project
-
Suggestion: Prefer per-file ignore or justify why
RUF003must be ignored project-wide; keepextend-exclude = ["multicodec-spec"]only if that was the real goal
Minor
- File:
tests/test_spec.py - Issue: Uses
os.pathjoins; pathlib would match modern style - Suggestion: Optional cleanup
5. Security Review
- Risk: Submodule pulls third-party content into the tree; CI/runtime only reads
table.csvas data - Impact: Low (trusted multiformats org URL; no code execution from CSV)
- Mitigation: Keep submodule URL pinned to
multiformats/multicodec; continue excluding it from lint/format tools
No unsafe I/O beyond reading the CSV path under the repo.
6. Documentation and Examples
Missing contributor guidance for submodule init (see Major). Newsfragment should describe user-visible codec table additions if new public codec names/codes ship with this PR.
7. Newsfragment Requirement
- Severity: CRITICAL / BLOCKER
- Issue: No
newsfragments/41.*.rst; PR correctly references Closes #41 - Suggestion: Add fragment covering (1) spec compliance test and/or (2) newly registered codecs for users
- Action Required: Newsfragment before approval
8. Tests and Validation
Linting (make lint)
- Exit 0 — all hooks passed
Type Checking (make typecheck)
- Exit 0
Test Execution (make test)
- Exit 0 — 736 passed, including
tests/test_spec.py
Documentation Build (make docs-ci)
- Exit 0
GitHub CI
- SUCCESS with submodule checkout
9. Recommendations for Improvement
- Add
newsfragments/41.*.rst(blocker) - Document submodule clone/update for contributors
- Revisit global
RUF003ignore — scope it or remove - Optionally document submodule bump + table regeneration workflow
10. Questions for the Author
- Was
[tool.ruff.lint] ignore = ["RUF003"]required for the submodule, or accidental? - Should newly added codecs also get a dedicated user-facing newsfragment list, or is a single “synced to upstream table” note enough?
- Is the pinned submodule commit (
833c740…) intentional as the compatibility baseline?
11. Overall Assessment
- Quality Rating: Good
- Security Impact: Low
- Merge Readiness: Needs fixes (newsfragment; docs for submodule; clarify ruff ignore)
- Confidence: High
Verdict: REQUEST_CHANGES — valuable compliance infrastructure and table sync; blocked on newsfragment and a few process/docs cleanups.
Closes #41.
What was changed:
multiformats/multicodecas a git submodule inmulticodec-spec/.tests/test_spec.pythat validatesCODECS,CODE_TABLE, andNAME_TABLEagainst thetable.csvfile from the authoritative upstream spec.multicodec/constants.pyandmulticodec/code_table.pyto match the latest upstreamtable.csv..pre-commit-config.yamlandpyproject.tomlto appropriately exclude the submodule from linting.Makefileto exclude the submodule anddocs/conf.py(which previously failed due to import location) duringmake fix.Why the change was needed:
mldsa-44-pubetc) that had been added to upstream but not updated inpy-multicodec.How it was verified:
make pr, which runs theruffformatter/linter,mypytypechecks, and the full test suite.test_spec_table_completenesstest passes successfully.