fix(code): add missing tag categories to _get_tag() - #49
Conversation
acul71
left a comment
There was a problem hiding this comment.
AI PR Review: #49 — fix(code): add missing tag categories to _get_tag()
Reviewer: acul71 (maintainer)
PR: #49
Author: sumanjeet0012
Date: 2026-09-07
1. Summary of Changes
This PR addresses Closes #37: _get_tag() was missing six category tags present in go-multicodec (multikey, multisig, nonce, shelter, softhash, vlad), so matching codecs returned "<unknown>".
Changes:
- Adds the six missing tag branches to
_get_tag()inmulticodec/code.py - Places
multisigmatching beforemultihashso names containing both patterns are classified correctly - Adds unit assertions in
tests/test_code.pyfor each new category
Modules/files: multicodec/code.py, tests/test_code.py
Breaking changes / deprecations: None
2. Branch Sync Status and Merge Conflicts
Branch Sync Status
- Status: Ahead of
origin/master(in sync on the behind axis) - Details:
branch_sync_status.txt=0 1→ 0 commits behind, 1 commit ahead
Merge Conflict Analysis
- Conflicts Detected: No conflicts
- Test merge against
origin/mastersucceeded (Already up to date/ clean abort path)
✅ No merge conflicts detected. The PR branch can be merged cleanly into origin/master.
3. Strengths
- Directly mirrors the issue’s proposed Go-parity tags with clear comments
- Correct ordering of
multisigbeforemultihash(important for-msig/lamport-*-signames) - Focused tests covering each new tag with representative codec codes from the issue
- Local CI suite green: lint, typecheck, 689 tests, docs build
4. Issues Found
Critical
- File:
newsfragments/(missing) - Line(s): N/A
- Issue: Missing mandatory newsfragment for issue #37
- Suggestion: Add
newsfragments/37.bugfix.rst(or37.misc.rstif preferred) with a short user-facing ReST description ending in a newline, e.g. thatCode.tag()now returns the correct categories for multikey/multisig/nonce/shelter/softhash/vlad codecs.
Major
- File:
tests/test_code.py - Line(s): ~120–145
- Issue: New tag checks are appended inside an existing test method rather than a dedicated parametrized test; coverage is spot-check only (one code per category)
- Suggestion: Prefer a parametrized table (as in PR #50) so all codecs in each category can be asserted; at minimum keep this PR’s checks but ensure they do not conflict with #50 when both land
Minor
- File:
multicodec/code.py - Line(s): Multisig / shelter branches
- Issue: Hardcoded name heuristics remain fragile if upstream naming drifts
- Suggestion: Acceptable for parity with Go; longer-term, consider deriving tags from the upstream table when #51’s spec submodule lands
5. Security Review
No security concerns identified. Changes are pure classification of already-registered codec integers/names; no new I/O, subprocess, or unvalidated external input paths.
- Risk: None material
- Impact: None
- Mitigation: N/A
6. Documentation and Examples
No public API surface change beyond corrected Code.tag() return values for previously "<unknown>" codecs. Docstring/README updates are not strictly required; a newsfragment is the appropriate user-facing note.
7. Newsfragment Requirement
- Severity: CRITICAL / BLOCKER
- Issue: No
newsfragments/37.*.rstfile present; PR correctly references Closes #37 - Impact: Cannot approve until a valid newsfragment exists
- Suggestion:
- Issue link is fine (
Closes #37) - Add
newsfragments/37.bugfix.rstwith a user-facing description and trailing newline
- Issue link is fine (
- Action Required: Add newsfragment before approval
8. Tests and Validation
Linting (make lint)
- Exit code: 0
- All pre-commit hooks passed (yaml, toml, EOF, whitespace, pyupgrade, ruff, ruff format, mypy)
Type Checking (make typecheck)
- Exit code: 0 — mypy passed
Test Execution (make test)
- Exit code: 0
- Summary: 689 passed, 0 failed, 0 skipped in ~0.27s
- New tag assertions exercised successfully
Documentation Build (make docs-ci)
- Exit code: 0 — Sphinx HTML build succeeded with
-W
GitHub CI
- All reported tox/windows checks on the PR are SUCCESS
9. Recommendations for Improvement
- Add
newsfragments/37.bugfix.rst(blocker) - Coordinate with PR #50 (same files:
code.py,test_code.py). #50 expands tag coverage and also patches more unmapped tags. Prefer merge order: land #49 first then rebase #50, or close #49 if #50 fully subsumes these six categories after verification - Consider parametrizing the new tests for maintainability
10. Questions for the Author
- Have you confirmed these six categories match go-multicodec’s
Tag()exactly for all codecs in each category (not only the sample codes)? - How do you intend to reconcile this PR with #50, which also edits
_get_tag()and tag tests? - Is
37.bugfix.rstthe intended newsfragment type, or do you prefermisc/internal?
11. Overall Assessment
- Quality Rating: Good
- Security Impact: None
- Merge Readiness: Needs fixes (missing newsfragment; coordinate with #50)
- Confidence: High
Verdict: REQUEST_CHANGES — solid, focused fix that addresses #37, but blocked on the mandatory newsfragment and should be sequenced with #50.
Closes #37.
What was changed:
multikey,multisig,nonce,shelter,softhash,vlad) to_get_tag()inmulticodec/code.py.multisigblock to precedemultihashto ensure correct tag extraction for overlapping names.tests/test_code.pyto verify each of these new tag categories.Why the change was needed:
py-multicodecwas previously categorizing these codecs as"<unknown>".How it was verified:
test_code.pyusing prefixes like0xA000,0xD01300,0x1A44,0x123B,0x511E00,0xCC01, and0x1207.make prlocally to ensure formatting (ruff), linting (pre-commit), typechecking (mypy), and unit testing (pytest) all pass correctly.