fix(java): upgrade Bridge IR to v1.1.0 9-field shape (task #222)#97
Conversation
Replace the 4-field Bridge record (sourceSymbol, sourceContractCid, targetContractCid, evidence) with the 9-field BridgeDeclaration defined by IR formal grammar v1.1.0: name, sourceSymbol, sourceLayer, sourceContractCid, targetContractCid, targetProofCid, targetLayer, notes (optional). Declaration.Bridge#toJson now emits JCS-canonical bytes in alphabetical key order matching the bridge_decl conformance fixture. Adds testBridgeJcsRoundtripV110 asserting byte-equality against the fixture literal so the IR types alone (not a hand-rolled JCS path) satisfy conformance. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 9 minutes and 37 seconds.Comment |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Pull request overview
Upgrades the Java Bridge IR declaration to the v1.1.0 shape and updates serialization to match the conformance fixture/JCS ordering used across other language kits.
Changes:
- Replaces the legacy 4-field
Declaration.Bridgewith the v1.1.0 BridgeDeclaration shape (addsname,sourceLayer,targetProofCid,targetLayer, optionalnotes; removesevidence). - Updates
Declaration.Bridge#toJson()to emit keys in the canonical fixture order and omitnoteswhen null. - Updates Java tests to assert bridge serialization matches the
conformance/fixtures.tomlbridge_declliteral.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| implementations/java/provekit-ir/src/main/java/com/provekit/ir/Declaration.java | Updates Bridge record shape and JCS-ordered JSON serialization logic. |
| implementations/java/provekit-ir/src/main/java/com/provekit/ir/IrDocument.java | Replaces legacy builder bridge overloads with v1.1.0 overloads (with/without notes). |
| implementations/java/provekit-ir/src/test/java/com/provekit/ir/IrDocumentTest.java | Updates bridge tests and adds exact-match fixture roundtrip assertion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public void testBridge() { | ||
| IrDocument doc = IrDocument.builder() | ||
| .bridge("parseInt", "bafy...js", "bafy...java") | ||
| .build(); | ||
| Declaration.Bridge bridge = new Declaration.Bridge( | ||
| "myBridge", | ||
| "source", | ||
| "c-kit", | ||
| "bafySource", | ||
| "bafyTarget", | ||
| "bafyProof", | ||
| "coq", | ||
| null | ||
| ); | ||
|
|
||
| String json = doc.toJson(); | ||
| String json = bridge.toJson(); | ||
| assertTrue(json.contains("\"kind\":\"bridge\"")); | ||
| assertTrue(json.contains("\"sourceSymbol\":\"parseInt\"")); | ||
| assertTrue(json.contains("\"name\":\"myBridge\"")); | ||
| assertTrue(json.contains("\"sourceSymbol\":\"source\"")); | ||
| assertTrue(json.contains("\"sourceLayer\":\"c-kit\"")); | ||
| assertTrue(json.contains("\"targetProofCid\":\"bafyProof\"")); | ||
| assertTrue(json.contains("\"targetLayer\":\"coq\"")); | ||
| } |
| public void testBridgeJcsRoundtripV110() { | ||
| Declaration.Bridge bridge = new Declaration.Bridge( | ||
| "myBridge", | ||
| "source", | ||
| "c-kit", | ||
| "bafySource", | ||
| "bafyTarget", | ||
| "bafyProof", | ||
| "coq", | ||
| "some notes" | ||
| ); | ||
|
|
||
| String got = bridge.toJson(); | ||
| String expected = "{\"kind\":\"bridge\",\"name\":\"myBridge\",\"notes\":\"some notes\",\"sourceContractCid\":\"bafySource\",\"sourceLayer\":\"c-kit\",\"sourceSymbol\":\"source\",\"targetContractCid\":\"bafyTarget\",\"targetLayer\":\"coq\",\"targetProofCid\":\"bafyProof\"}"; | ||
|
|
||
| assertEquals(expected, got, "Bridge JCS bytes must match conformance/fixtures.toml bridge_decl"); |
| /** v1.1.0 9-field bridge with no notes. */ | ||
| public Builder bridge( | ||
| String name, | ||
| String sourceSymbol, | ||
| String sourceLayer, | ||
| String sourceContractCid, | ||
| String targetContractCid, | ||
| String targetProofCid, | ||
| String targetLayer | ||
| ) { | ||
| declarations.add(new Declaration.Bridge( | ||
| name, sourceSymbol, sourceLayer, | ||
| sourceContractCid, targetContractCid, targetProofCid, targetLayer, | ||
| null)); | ||
| return this; | ||
| } | ||
| public Builder bridge(String sourceSymbol, String sourceCid, String targetCid, String evidence) { | ||
| declarations.add(new Declaration.Bridge(sourceSymbol, sourceCid, targetCid, evidence)); | ||
| /** v1.1.0 9-field bridge including optional notes. */ | ||
| public Builder bridge( | ||
| String name, | ||
| String sourceSymbol, | ||
| String sourceLayer, | ||
| String sourceContractCid, | ||
| String targetContractCid, | ||
| String targetProofCid, | ||
| String targetLayer, | ||
| String notes | ||
| ) { | ||
| declarations.add(new Declaration.Bridge( | ||
| name, sourceSymbol, sourceLayer, | ||
| sourceContractCid, targetContractCid, targetProofCid, targetLayer, | ||
| notes)); | ||
| return this; |
| * targetContractCid, targetProofCid, targetLayer. | ||
| * Optional: notes (omitted from output when null). | ||
| * | ||
| * JCS canonical key order (RFC 8785, alphabetical by code unit): |
Java JNI is the third per-host FFI pathway after Go cgo (#127) and Python ctypes (#131). Each FFI host has different load conventions (cgo preamble / LDFLAGS, ctypes CDLL, JNI System.loadLibrary) and naming (C.foo, lib.foo, native method + class prefix); each requires its own resolver. The lifter is per-host; ProvekIt IR is the common substrate beneath them all. This PR adds: - CallEdgeDecl.java: JCS-canonical call-edge memento type in provekit-ir, matching Go's CallEdgeDeclaration.MarshalJSON key order (callSiteLocus, evidenceTerm, kind, schemaVersion, sourceContractCid, targetContractCid, targetSymbol) and Locus key order (column, file, line). - JniResolver.java: AST walker using JavaParser to detect System.loadLibrary("name") / System.load("/path") in static initializers, native method declarations, and call sites invoking native methods. Resolves library names to kit prefixes: rust* -> rust-kit, system libs (c, m, pthread, ssl, etc.) -> libc-system, other -> cpp-kit, empty/unknown -> resolver-error:<symbol> (fail-loud per #97 R2). Emits CallEdgeDecl with targetContractCid=null and targetSymbol="<kit>:<ClassName>.<method>" for linker resolution per R3. - LiftHandler.java: extended lift() response to include a callEdges array alongside the existing ir array, invoking JniResolver per file. - JniResolverTest.java: 9 tests in integration-tests module covering rust-kit edge, cpp-kit edge, libc-system edge, no-native guard, resolver-error for unknown library, System.load absolute path, byte-determinism, and stripLibName/resolveKit unit tests. - path-to-default.md: one sentence noting Java JNI as a shipped FFI pathway alongside Go cgo and Python ctypes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Java JNI is the third per-host FFI pathway after Go cgo (#127) and Python ctypes (#131). Each FFI host has different load conventions (cgo preamble / LDFLAGS, ctypes CDLL, JNI System.loadLibrary) and naming (C.foo, lib.foo, native method + class prefix); each requires its own resolver. The lifter is per-host; ProvekIt IR is the common substrate beneath them all. This PR adds: - CallEdgeDecl.java: JCS-canonical call-edge memento type in provekit-ir, matching Go's CallEdgeDeclaration.MarshalJSON key order (callSiteLocus, evidenceTerm, kind, schemaVersion, sourceContractCid, targetContractCid, targetSymbol) and Locus key order (column, file, line). - JniResolver.java: AST walker using JavaParser to detect System.loadLibrary("name") / System.load("/path") in static initializers, native method declarations, and call sites invoking native methods. Resolves library names to kit prefixes: rust* -> rust-kit, system libs (c, m, pthread, ssl, etc.) -> libc-system, other -> cpp-kit, empty/unknown -> resolver-error:<symbol> (fail-loud per #97 R2). Emits CallEdgeDecl with targetContractCid=null and targetSymbol="<kit>:<ClassName>.<method>" for linker resolution per R3. - LiftHandler.java: extended lift() response to include a callEdges array alongside the existing ir array, invoking JniResolver per file. - JniResolverTest.java: 9 tests in integration-tests module covering rust-kit edge, cpp-kit edge, libc-system edge, no-native guard, resolver-error for unknown library, System.load absolute path, byte-determinism, and stripLibName/resolveKit unit tests. - path-to-default.md: one sentence noting Java JNI as a shipped FFI pathway alongside Go cgo and Python ctypes. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
Upgrades Java's Bridge IR record at
implementations/java/provekit-ir/src/main/java/com/provekit/ir/Declaration.javafrom the legacy 4-field shape (sourceSymbol,sourceContractCid,targetContractCid,evidence) to the v1.1.0 9-fieldBridgeDeclarationdefined byprotocol/specs/2026-04-30-ir-formal-grammar.md.Fields added
name(required)sourceLayer(required)targetProofCid(required, the proof-pinning CID)targetLayer(required)notes(optional, omitted when null)Fields renamed/removed
evidence(legacy field, replaced by the proof-pinning CID model).property.go), Zig (root.zig) Bridge serializers and thebridge_declconformance fixture.Serialization
Declaration.Bridge#toJsonemits JCS-canonical bytes in alphabetical key order:kind, name, [notes,] sourceContractCid, sourceLayer, sourceSymbol, targetContractCid, targetLayer, targetProofCid. This matches thebridge_declJCS literal inconformance/fixtures.tomlexactly.Round-trip test result
New
testBridgeJcsRoundtripV110constructs a Bridge with all 9 fields (notes set to "some notes") and asserts byte-equality against the fixture literal.IrDocument.Builderships two newbridge(...)overloads matching the new shape.Full reactor
cd implementations/java && mvn testis green across all 13 modules.Test plan
cd implementations/java/provekit-ir && mvn test(4/4)cd implementations/java && mvn test(full reactor green)🤖 Generated with Claude Code