Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The new codec and application stack contain unresolved decoding, buffer sizing, reply-contract, and LP framing bugs.
Review effort: Balanced
Findings: 2
Open (7)
Include fragment payload length in LP packet length · New Validate fixed_len before sizing and encoding · New Handle missing fragments before parsing fragment type · New Return True after successfully sending the response · New Validate nested value against annotated model type · New Reject TLV values exceeding the remaining buffer · New Validate map value TLV type and bounds · New
What changed in this PR
Adds a parallel dataclass-based TLV encoding stack and migrates selected applications, commands, and examples to it.
Changes:
- Implements dataclass TLV encoding, parsing, maps, signatures, and schema caching.
- Adds dataclass packet, NDNLP, security, NFD management, and application modules.
- Migrates CLI tools/examples and adds compatibility and integration tests.
| File | Description |
|---|---|
tests/misc/security_v2_2_test.py |
Tests dataclass certificate and SafeBag support. |
tests/misc/nfd_mgmt_2_test.py |
Tests NFD management interoperability. |
tests/integration/app_v2_2_test.py |
Exercises the dataclass-based application stack. |
tests/encoding/tlv_model_v2_test.py |
Tests the new TLV codec. |
tests/encoding/ndnlp_v2_2_test.py |
Tests dataclass NDNLP handling. |
tests/encoding/ndn_format_0_3_2_test.py |
Tests packet encoding and signatures. |
src/ndn/transport/nfd_registerer.py |
Adds dataclass management registration. |
src/ndn/security/tpm/tpm_osx_keychain.py |
Formats key names in errors. |
src/ndn/encoding/tlv_model_v2.py |
Implements dataclass TLV serialization. |
src/ndn/encoding/ndnlp_v2_2.py |
Adds dataclass NDNLP models. |
src/ndn/encoding/ndn_format_0_3_2.py |
Adds dataclass packet models. |
src/ndn/encoding/__init__.py |
Exports the new TLV API. |
src/ndn/bin/sec/utils.py |
Uses dataclass security constants. |
src/ndn/bin/sec/cmd_sign_cert.py |
Migrates certificate signing. |
src/ndn/bin/sec/cmd_import_cert.py |
Migrates certificate importing. |
src/ndn/bin/sec/cmd_get_signreq.py |
Migrates signing requests. |
src/ndn/bin/sec/cmd_get_childitem.py |
Migrates certificate display. |
src/ndn/bin/nfdc/utils.py |
Uses the new application stack. |
src/ndn/bin/nfdc/cmd_set_strategy.py |
Migrates strategy commands. |
src/ndn/bin/nfdc/cmd_remove_strategy.py |
Migrates strategy removal. |
src/ndn/bin/nfdc/cmd_remove_route.py |
Migrates route removal. |
src/ndn/bin/nfdc/cmd_remove_face.py |
Migrates face removal. |
src/ndn/bin/nfdc/cmd_new_route.py |
Migrates route creation. |
src/ndn/bin/nfdc/cmd_new_face.py |
Migrates face creation. |
src/ndn/bin/nfdc/cmd_get_strategy.py |
Migrates strategy queries. |
src/ndn/bin/nfdc/cmd_get_status.py |
Migrates status queries. |
src/ndn/bin/nfdc/cmd_get_route.py |
Migrates route queries. |
src/ndn/bin/nfdc/cmd_get_face.py |
Migrates face queries. |
src/ndn/appv2_2.py |
Adds the dataclass-based application implementation. |
src/ndn/app_support/security_v2_2.py |
Adds dataclass security models. |
src/ndn/app_support/nfd_mgmt_2.py |
Adds dataclass NFD management models. |
src/ndn/app_support/light_versec/checker.py |
Uses dataclass certificate parsing. |
src/ndn/app_support/light_versec/binary.py |
Converts LVS models to dataclasses. |
examples/dpdk_experimental/udp_producer.py |
Migrates the DPDK producer. |
examples/dpdk_experimental/udp_consumer.py |
Migrates the DPDK consumer. |
examples/appv2/keychain_cert/keychain_register.py |
Migrates keychain registration. |
examples/appv2/keychain_cert/fetch_certificate.py |
Migrates certificate fetching. |
examples/appv2/forwarding_hint/producer.py |
Migrates the forwarding-hint producer. |
examples/appv2/forwarding_hint/consumer.py |
Migrates the forwarding-hint consumer. |
examples/appv2/basic_packets/producer.py |
Migrates the basic producer. |
examples/appv2/basic_packets/consumer.py |
Migrates the basic consumer. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+437
to
+439
| frag_l = len(data) | ||
| lp_l = len(pt_wire) + enc.get_tl_num_size(ndnlp.LpTypeNumber.FRAGMENT) + enc.get_tl_num_size(frag_l) | ||
| wire_l = enc.get_tl_num_size(ndnlp.LpTypeNumber.LP_PACKET) + enc.get_tl_num_size(lp_l) + lp_l |
Comment on lines
+452
to
+454
| if fixed_len is not None: | ||
| n = fixed_len | ||
| elif val <= 0xFF: |
Comment on lines
+262
to
+263
| data = lp_pkt.fragment | ||
| typ, _ = enc.parse_tl_num(data) |
Comment on lines
+366
to
+369
| if pit_token is None: | ||
| self._put_raw_packet(data) | ||
| else: | ||
| self._put_raw_packet_with_pit_token(data, pit_token) |
Comment on lines
+546
to
+548
| if kind == 'model': | ||
| inner_markers: dict = {} | ||
| length = _encoded_length_model(val, inner_markers) |
Comment on lines
+881
to
+882
| length, sz_l = parse_tl_num(mv, offset) | ||
| offset += sz_l |
Comment on lines
+924
to
+930
| _val_typ, _sz_t2 = parse_tl_num(mv, offset) | ||
| offset += _sz_t2 | ||
| length, _sz_l2 = parse_tl_num(mv, offset) | ||
| offset += _sz_l2 | ||
|
|
||
| val = _parse_value(f'{fname}[{idx}#v]', spec.val, | ||
| mv, offset, length, offset_btl, ignore_critical) |
zjkmxy
marked this pull request as ready for review
September 27, 2026 20:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Ref: #97
New wire format is longer but with advantage:
dataclasssupport, such as=,reprandasdict. Also, models can be easily encoded into JSON and other formats for human/subagents to read.Not so good points:
bytesfield could actually holdmemoryview. Need further effort to improve.I plan to replace old model with the new encoding model in a future breaking change. This diff adds new method as extra files for people to review.