test: verify Code.tag() returns correct tags for all codecs - #50
test: verify Code.tag() returns correct tags for all codecs#50sumanjeet0012 wants to merge 1 commit into
Conversation
5abe732 to
54c7c0d
Compare
Also adds test_no_unknown_tags and fixes unmapped tags.
54c7c0d to
87f7e27
Compare
acul71
left a comment
There was a problem hiding this comment.
AI PR Review: #50 — test: verify Code.tag() returns correct tags for all codecs
Reviewer: acul71 (maintainer)
PR: #50
Author: sumanjeet0012
Date: 2026-09-07
1. Summary of Changes
This PR addresses Closes #42: tag tests previously covered only 4 codecs / 4 tags. It adds broader category coverage and ensures no registered codec returns "<unknown>".
Changes:
- Expands
_get_tag()mappings inmulticodec/code.py(same six tags as #49, plus many additional name matches across key/libp2p/multiaddr/multiformat/multihash/namespace/serialization/transport) - Adds inline assertions for the six previously missing tags in
test_code_tag - Adds parametrized
test_code_tag_all_categories(22 cases covering known tag categories) - Adds
test_no_unknown_tags()iteratingCODECS
Modules/files: multicodec/code.py, tests/test_code.py
Breaking changes / deprecations: None (behavior change: fewer "<unknown>" tags — desirable)
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.
Overlap with PR #49
Both PRs modify the same files. PR #50 fully subsumes PR #49’s six-tag additions (multikey, multisig, nonce, shelter, softhash, vlad) and goes further with additional mappings required for test_no_unknown_tags to pass.
Recommendation: Prefer merging #50 (after newsfragment) and closing or superseding #49, rather than merging both sequentially. If both must land, merge #49 first then rebase #50 (expect conflicts in code.py / test_code.py).
3. Strengths
- Implements the issue’s proposed parametrized coverage + no-unknown invariant
- Fixes the root cause of
"<unknown>"tags beyond the six categories from #37/#49 - Correct
multisigordering beforemultihash - Local validation: lint, typecheck, 712 tests passed, docs build OK; GitHub CI green
4. Issues Found
Critical
- File:
newsfragments/(missing) - Issue: Missing mandatory newsfragment for issue #42
- Suggestion: Add
newsfragments/42.misc.rstor42.bugfix.rstdescribing thatCode.tag()coverage/tests ensure all registered codecs map to recognized tags
Major
-
File:
tests/test_code.py -
Line(s):
TAG_TEST_CASES/test_code_tag -
Issue: Duplication: the six new tags are tested both inline in
test_code_tagand again via parametrize (plus #49 overlap) -
Suggestion: Keep parametrized +
test_no_unknown_tagsas the source of truth; drop redundant inline asserts to reduce maintenance cost -
File:
multicodec/code.py -
Line(s): Multiformat list includes
"multisig"/"multikey"while later branches also return those tags for other names -
Issue: Easy to misread; the multiformat entries are for codecs literally named
multisig/multikey, whilechacha20-poly1305/*-msiguse dedicated branches — this matches Go-style dual use but deserves a short comment -
Suggestion: Add a one-line comment clarifying codec-name vs category-tag matching
Minor
- File:
tests/test_code.py - Issue: Parametrized list still samples one codec per category rather than “all 603 codecs” as the issue title suggests;
test_no_unknown_tagscloses that gap for unknown detection but does not assert the expected tag string per codec against an external oracle - Suggestion: Acceptable for #42’s proposed solution; fuller oracle checks belong with #51’s table.csv work if tags are present upstream
5. Security Review
No security concerns. Classification-only changes over static codec tables.
6. Documentation and Examples
No API docs required beyond newsfragment for user-visible tag corrections.
7. Newsfragment Requirement
- Severity: CRITICAL / BLOCKER
- Issue: No
newsfragments/42.*.rst; PR correctly references Closes #42 - Suggestion: Add
newsfragments/42.bugfix.rst(or.misc.rst) with user-facing note thatCode.tag()now returns recognized tags for all registered codecs / expanded categories - Action Required: Newsfragment before approval
8. Tests and Validation
Linting (make lint)
- Exit 0 — all hooks passed
Type Checking (make typecheck)
- Exit 0 — mypy passed
Test Execution (make test)
- Exit 0 — 712 passed (up from 689 on master/#49), 0 failed
Documentation Build (make docs-ci)
- Exit 0 — Sphinx
-Wsucceeded
GitHub CI
- All tox/windows checks SUCCESS
9. Recommendations for Improvement
- Add newsfragment
42.*.rst(blocker) - Coordinate with #49: recommend supersede #49 with this PR (or close #49 after #50 merges)
- Deduplicate inline vs parametrized tag assertions
- Optional comment on multiformat vs category
multikey/multisignames
10. Questions for the Author
- Should #49 be closed as superseded by this PR?
- Preferred newsfragment type:
bugfixvsmisc? - Were the additional name mappings (aes-*, provenance-log, silverpine, etc.) cross-checked against go-multicodec
Tag()?
11. Overall Assessment
- Quality Rating: Good
- Security Impact: None
- Merge Readiness: Needs fixes (newsfragment; clarify relationship to #49)
- Confidence: High
Verdict: REQUEST_CHANGES — strong improvement that subsumes #49 and addresses #42, blocked only on newsfragment (and process clarity vs #49).
Closes #42.
What was changed:
test_code_tag_all_categoriestotests/test_code.pythat verifies the tags of 22 codecs covering all known tags.test_no_unknown_tags()to verify that no codec inCODECSreturns"<unknown>"as its tag.multicodec/code.py(likeprovenance-log,aes-128, etc.) which causedtest_no_unknown_tagsto fail, ensuring all 603 codecs have correct recognized tags.Why the change was needed:
How it was verified:
make prwhich invokespytest. All tests pass successfully, confirming thatCode.tag()properly maps all codecs inmulticodec/constants.py.