refactor(#5082): make writeTo() the sole header authority in PackStreamStructure - #5112
Conversation
…treamStructure Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…gnature/getFieldCount Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…amStructure Remove getSignature()/getFieldCount() from the PackStreamStructure interface and all seven implementers; inline the header write in BoltPointStructure.writeTo (its only internal consumer). writeTo() is now the single source of truth for structure headers, which the version-gated structs already require since only the writer carries the negotiated Bolt version. No wire change on any version (3.0-5.4). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Tick the box to add this pull request to the merge queue (same as
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Code Review
This pull request refactors the Bolt protocol serialization layer by removing the getSignature() and getFieldCount() methods from the PackStreamStructure interface and all of its implementers, establishing writeTo() as the sole authority for structure-header emission. Corresponding unit tests have been updated to assert on serialized wire bytes or specific properties instead of the removed accessors. Feedback suggests removing a redundant assertion on p.getZ() in BoltTypeRoundTripTest.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
Code Review: PR 5112 — writeTo() sole header authority Reviewed the full diff, the remaining getSignature()/getFieldCount() call sites, and the writer's default version. This is a clean, low-risk refactor and I'd be comfortable merging it. Correctness ✅
Test coverage ✅
Minor observations (non-blocking)
Style / conventions ✅
Nice work. The 'no wire-behavior change, dead-accessor removal' framing is accurate, and the compile-time safety net (any missed caller becomes a build error) plus the real-driver ITs make this about as safe as a refactor gets. |
Fold the 2D/3D signature-intent comment onto the existing z-value assertions instead of a separate redundant getZ() check. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Both observations are non-blocking and neither needs a code change - reasoning below. 1. if (fieldCount < 16) {
out.writeByte(TINY_STRUCT | fieldCount);
} else {
throw new IOException("Structure field count too large: " + fieldCount);
}
out.writeByte(signature);So any serializable Bolt structure has a one-byte marker at 2. The independent confirmation of the |
Review:
|
|
/gemini review |
|
Claude finished @robfrank's task in 59s —— View job Re-review: updated head
|
There was a problem hiding this comment.
Code Review
This pull request refactors the Bolt serialization layer by removing the getSignature() and getFieldCount() methods from the PackStreamStructure interface and its seven implementing classes, establishing writeTo() as the sole authority for structure-header emission. The tests have been updated to assert on serialized wire bytes instead of using the removed accessors. The review feedback suggests enhancing the test coverage in BoltTypeRoundTripTest by explicitly verifying the serialized wire bytes (the TINY_STRUCT marker and signature) for both 2D and 3D points to prevent silent regressions.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
…level Add a boltMajorVersion(5) wireHeader variant and assert Node 3->4, Relationship 5->8, UnboundRelationship 3->4 element_id header widening - the exact case the removed accessors got wrong - so a version-gate regression fails fast in unit tests rather than only in the real-driver ITs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Nit 1 (5.x unit coverage) implemented in b67f0a7 - it's the right call, since 4.x-only unit assertions left the exact regression the PR targets guarded only by the ITs. Added
The Nit 2 (superpowers docs) is the same point from the first pass - intentional per the repo convention (committed within the feature PR, as with the sibling Bolt cert PRs); maintainer's call on whether to keep them in history. |
|
/gemini review |
|
Claude finished @robfrank's task in 1m 27s —— View job Re-review: latest head
|
There was a problem hiding this comment.
Code Review
This pull request refactors the PackStreamStructure interface and its seven implementers by removing the getSignature() and getFieldCount() methods, making writeTo() the sole authority for Bolt structure-header emission. The signature and field count logic for BoltPointStructure has been inlined directly into its writeTo() method. Additionally, the unit tests have been updated to assert on the serialized wire bytes or specific properties instead of using the removed accessors, and design/plan documentation has been added. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
BoltPointStructure.writeTo is the one production header path this PR inlined, so pin its emitted marker + signature bytes directly (Point2D 0xB3/0x58, Point3D 0xB4/0x59) alongside the getZ() value checks. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
🟢 Coverage 100.00% diff coverage · -7.54% coverage variation
Metric Results Coverage variation ✅ -7.54% coverage variation Diff coverage ✅ 100.00% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (38489b0) 136228 101912 74.81% Head commit (6ca0816) 168054 (+31826) 113043 (+11131) 67.27% (-7.54%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#5112) 3 3 100.00% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
Review: refactor(#5082) - make writeTo() the sole header authority in PackStreamStructure Reviewed the full diff and cross-checked against the current source. This is a well-scoped, low-risk cleanup and the reasoning in the PR description holds up against the code. Recommend merge. What is good
Minor / non-blocking
Verification I ran
Nice, surgical change with a net improvement in test fidelity. |
|
Review: refactor of PackStreamStructure — writeTo() as sole header authority Reviewed the full diff, the two remaining getSignature()/getFieldCount() call sites, PackStreamWriter, and the DateTime test coverage. This is a clean, low-risk, well-motivated refactor. Recommendation: approve. What is good
Minor notes (non-blocking)
Test coverage Adequate and improved. Wire-byte assertions at both Bolt 4.x and 5.x, plus the existing real-driver ITs across negotiated 3.0-5.4, cover the behavior-preservation claim. The one flake called out in the description (concurrentSessions schema-update race) is pre-existing and unrelated to serialization. Nice, surgical change with the reasoning fully documented. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5112 +/- ##
============================================
- Coverage 65.83% 65.44% -0.39%
+ Complexity 909 906 -3
============================================
Files 1692 1692
Lines 136228 136216 -12
Branches 29113 29114 +1
============================================
- Hits 89680 89141 -539
- Misses 34355 34877 +522
- Partials 12193 12198 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Closes #5082. Follow-up to #5001 (PR #5059). Part of the Bolt certification epic #4882 / tracking issue #4890.
Removes
getSignature()andgetFieldCount()from thePackStreamStructureinterface and all seven implementers, makingwriteTo()the sole authority for Bolt structure-header emission. After #5001 added Bolt 5.x version-gated encoding, these no-arg accessors became inconsistent withwriteTo()on version-gated structs (they cannot see the negotiated version - only the writer carries it), leaving a latent footgun: any futurewriteStructureHeader(getSignature(), getFieldCount())call site would emit a header/body mismatch and corrupt the stream on a 5.x connection.No wire-behavior change on any negotiated Bolt version (3.0-5.4) - this is dead-accessor removal, not a re-encode. No
writeTo()body logic changed.Changes
Production
PackStreamStructurereduced to a single-method contract:void writeTo(PackStreamWriter).BoltPointStructure.writeTo(the only internal consumer of thewriteStructureHeader(getSignature(), getFieldCount())idiom) now inlines its version-invariant signature (z == null ? 0x58 : 0x59) and field count (3/4) locally.BoltNode,BoltRelationship,BoltUnboundRelationship,BoltPath,BoltTemporalStructure,BoltDateTimeStructuredrop the two now-unused overrides; theirwriteTo()bodies already wrote headers with inline literals and are untouched.Not touched (verified different types, each keeps its own methods):
PackStreamReader.StructureValueandBoltMessage(the inbound-decode + message paths inBoltStructureMapper.fromInboundStructure/BoltMessage.parse).Tests - accessor assertions on interface implementers converted to stronger, wire-truth assertions:
BoltStructureTest(Node/Rel/UnboundRel/Path): assert the serializedTINY_STRUCTmarker + signature bytes.BoltTypeRoundTripTest: TYPE-011 relies on the existing wire round-trip (drops redundant pre-wire asserts); TYPE-012 Point usesgetZ()null-ness (the sole determinant of the 2D/3D signature).Bolt4998PathMappingTest: TYPE-012 Point →getZ().BoltDateTimeStructureTestneeded no change - all itsgetSignature()calls are on thePackStreamReader.StructureValuereturned by itsroundTrip()/mapperRoundTrip()helpers, which already serialize throughwriteTo().Verification
mvn -pl bolt verify- BUILD SUCCESS, 275 unit tests pass.mvn -pl bolt verify -DskipITs=false- real-driver ITs (neo4j-java-driveragainst a live server across negotiated Bolt 3.0-5.4, incl.BoltProtocolIT,RemoteBoltDatabaseIT,BoltVersionNegotiationTest, temporal/point/path/counters ITs) all pass. The one flake observed -BoltProtocolIT.concurrentSessionsfailing withUser 'root' is not allowed to update schema- is a pre-existing concurrent-schema-creation race unrelated to serialization; it passed on isolated re-run.getSignature()/getFieldCount()references remain instructure/or the interface.Acceptance criteria
PackStreamStructureno longer exposesgetSignature()/getFieldCount();writeTo()is the only header contract.@Overrideaccessor remains on any of the seven implementers.mvn -pl bolt verifygreen.🤖 Generated with Claude Code