Skip to content

fix(code): add missing tag categories to _get_tag() - #49

Open
sumanjeet0012 wants to merge 1 commit into
multiformats:masterfrom
sumanjeet0012:fix-issue-1-missing-tags
Open

fix(code): add missing tag categories to _get_tag()#49
sumanjeet0012 wants to merge 1 commit into
multiformats:masterfrom
sumanjeet0012:fix-issue-1-missing-tags

Conversation

@sumanjeet0012

@sumanjeet0012 sumanjeet0012 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Closes #37.

What was changed:

  • Added the 6 missing tag categories (multikey, multisig, nonce, shelter, softhash, vlad) to _get_tag() in multicodec/code.py.
  • Reordered the multisig block to precede multihash to ensure correct tag extraction for overlapping names.
  • Added comprehensive unit tests in tests/test_code.py to verify each of these new tag categories.

Why the change was needed:

  • The Go reference implementation supports these tags, but py-multicodec was previously categorizing these codecs as "<unknown>".
  • Ensures feature parity and spec compliance within the Python implementation.

How it was verified:

  • Verified by adding new tag classification tests in test_code.py using prefixes like 0xA000, 0xD01300, 0x1A44, 0x123B, 0x511E00, 0xCC01, and 0x1207.
  • Executed make pr locally to ensure formatting (ruff), linting (pre-commit), typechecking (mypy), and unit testing (pytest) all pass correctly.

@acul71 acul71 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() in multicodec/code.py
  • Places multisig matching before multihash so names containing both patterns are classified correctly
  • Adds unit assertions in tests/test_code.py for 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/master succeeded (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 multisig before multihash (important for -msig / lamport-*-sig names)
  • 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 (or 37.misc.rst if preferred) with a short user-facing ReST description ending in a newline, e.g. that Code.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

⚠️ BLOCKER

  • Severity: CRITICAL / BLOCKER
  • Issue: No newsfragments/37.*.rst file present; PR correctly references Closes #37
  • Impact: Cannot approve until a valid newsfragment exists
  • Suggestion:
    1. Issue link is fine (Closes #37)
    2. Add newsfragments/37.bugfix.rst with a user-facing description and trailing newline
  • 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

  1. Add newsfragments/37.bugfix.rst (blocker)
  2. 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
  3. Consider parametrizing the new tests for maintainability

10. Questions for the Author

  1. Have you confirmed these six categories match go-multicodec’s Tag() exactly for all codecs in each category (not only the sample codes)?
  2. How do you intend to reconcile this PR with #50, which also edits _get_tag() and tag tests?
  3. Is 37.bugfix.rst the intended newsfragment type, or do you prefer misc/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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_get_tag() missing 6 tags present in go-multicodec

2 participants