refactor: by-value Copy types, public fields, Nonce rename, internal/ policy#72
Conversation
Adds internal/ (gitignored) for untracked papers and private docs. Adds rules to CLAUDE.md: no internal paths in code, restate content explicitly rather than linking to files, agents follow the same rules. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Return Identifier and MembershipVector by value (both are Copy) - Accept Copy types by value in method signatures throughout - Make IdSearchReq/IdSearchRes fields public, remove getters and new() constructors (no invariants to protect on plain data structs) - Rename RequestId to Nonce (clearer: randomly generated correlation token used once to match response to request) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors several core skip-graph model types to be passed by value (for small Copy types), simplifies the search request/response API by using public fields, and renames RequestId to Nonce for clarity. It also updates tests and network/node plumbing accordingly, and adds an internal-reference policy to prevent leaking internal document paths into source code.
Changes:
- Switched
Identifier/MembershipVectorusage to by-value APIs and updated call sites. - Refactored ID search request/response to plain structs with public fields and renamed
RequestId→Nonce. - Updated node/network code and tests to match the new signatures and struct-literal construction patterns.
Reviewed changes
Copilot reviewed 22 out of 25 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_debug_hex_format.rs | Updates tests to match by-value Identity construction and formatting style. |
| src/node/skip_graph_integration_test.rs | Updates integration tests to use Nonce and struct-literal IdSearchReq. |
| src/node/search_by_id_test.rs | Updates networking integration tests for IdSearchReq/Res public fields and Nonce. |
| src/node/core.rs | Changes Core trait APIs to by-value and updates search implementation to use public fields. |
| src/node/core_test.rs | Updates core tests to the new IdSearchReq/Res API and by-value IDs. |
| src/node/base_node.rs | Updates request correlation map to Nonce and refactors search/relay logic to by-value requests. |
| src/network/processor.rs | Formatting/import adjustments; keeps processor API consistent with by-value identifiers. |
| src/network/mod.rs | Minor import ordering and enum formatting cleanup. |
| src/network/mock/network.rs | Formatting/import adjustments in mock network implementation. |
| src/network/mock/network_test.rs | Updates tests for import ordering/formatting and minor cleanup. |
| src/lib.rs | Reorders module declarations. |
| src/core/testutil/fixtures.rs | Updates fixtures to construct identities by value; minor formatting refactors. |
| src/core/model/search.rs | Renames RequestId → Nonce; makes IdSearchReq/Res plain structs with public fields. |
| src/core/model/memvec.rs | Changes common_prefix_bit to take MembershipVector by value; updates tests. |
| src/core/model/identity.rs | Changes Identity::new, id(), and mem_vec() to by-value APIs. |
| src/core/model/direction.rs | Whitespace/formatting fix. |
| src/core/model/address.rs | Import ordering tweak. |
| src/core/lookup/mod.rs | Whitespace/formatting cleanup. |
| src/core/lookup/array_lookup_table.rs | Expands tracing call for readability. |
| src/core/lookup/array_lookup_table_test.rs | Import ordering and minor formatting cleanup. |
| src/core/context/mod.rs | Whitespace/formatting cleanup. |
| src/core/context/context_test.rs | Formatting cleanup in async tests. |
| CLAUDE.md | Adds “internal references” policy guidance. |
| .gitignore | Adds internal/ to gitignore with policy comments. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -117,8 +123,8 @@ impl BaseNode { | |||
| .map_err(|_| anyhow!("failed to receive response for search by id"))?; | |||
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Prevents a map entry leak when the response channel disconnects before a result is delivered. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
The action's built-in default model (claude-sonnet-4-20250514) has been retired and now returns a 404 not_found_error, failing the @claude job. Pin an explicit, current Opus model. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude (@claude) perform a review for any critical flaws, code smells or bugs introduced in this PR. |
|
Claude finished TheP2P (@thep2p)'s task —— View job Code ReviewI reviewed the core changes for critical flaws, bugs, and code smells. Overall this is a clean, well-structured refactor — by-value Critical / Correctness1. 2. Code Smells / Minor3. 4. 5. Things that look correct / good
SummaryNo blocking bugs introduced by this PR. The most important issue is the unbounded blocking
|
Tracked in #74
As mentioned, astronomically unlikely, hence we avoid the overhead of adding belt-and-suspender for statistically improbable events.
Fixed in da13d00 |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… policy (#72) Co-authored-by: yahya <19204398+yhassanzadeh13@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
… policy (#72) Co-authored-by: yahya <19204398+yhassanzadeh13@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Summary
skip-graphs-paper.pdftointernal/(gitignored); adds rules toCLAUDE.md— no internal paths in source, restate content explicitly, agents follow the same rules.IdentifierandMembershipVectorare 32-byteCopytypes; methods now return and accept them by value throughout the codebase, eliminating unnecessary lifetime friction.IdSearchReqandIdSearchReshave no invariants to protect — converted to plain structs with public fields, removing boilerplate getters andnew()constructors. Callers use struct literal syntax.RequestId→Nonce: clearer name for a randomly generated token used once to correlate a response back to its originating request.Test plan
cargo test— all 58 tests pass, no regressionsmake lint— no clippy warnings🤖 Generated with Claude Code