Skip to content

fix(java): upgrade Bridge IR to v1.1.0 9-field shape (task #222)#97

Merged
TSavo merged 1 commit into
mainfrom
fix/java-bridge-ir-v1-1-0-shape
May 3, 2026
Merged

fix(java): upgrade Bridge IR to v1.1.0 9-field shape (task #222)#97
TSavo merged 1 commit into
mainfrom
fix/java-bridge-ir-v1-1-0-shape

Conversation

@TSavo
Copy link
Copy Markdown
Owner

@TSavo TSavo commented May 3, 2026

Summary

Upgrades Java's Bridge IR record at implementations/java/provekit-ir/src/main/java/com/provekit/ir/Declaration.java from the legacy 4-field shape (sourceSymbol, sourceContractCid, targetContractCid, evidence) to the v1.1.0 9-field BridgeDeclaration defined by protocol/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

  • Removed evidence (legacy field, replaced by the proof-pinning CID model).
  • Field set now matches Go (property.go), Zig (root.zig) Bridge serializers and the bridge_decl conformance fixture.

Serialization

Declaration.Bridge#toJson emits JCS-canonical bytes in alphabetical key order: kind, name, [notes,] sourceContractCid, sourceLayer, sourceSymbol, targetContractCid, targetLayer, targetProofCid. This matches the bridge_decl JCS literal in conformance/fixtures.toml exactly.

Round-trip test result

New testBridgeJcsRoundtripV110 constructs a Bridge with all 9 fields (notes set to "some notes") and asserts byte-equality against the fixture literal. IrDocument.Builder ships two new bridge(...) overloads matching the new shape.

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.provekit.ir.IrDocumentTest
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.123 s -- in com.provekit.ir.IrDocumentTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] BUILD SUCCESS

Full reactor cd implementations/java && mvn test is green across all 13 modules.

Test plan

  • cd implementations/java/provekit-ir && mvn test (4/4)
  • cd implementations/java && mvn test (full reactor green)
  • Failing-first TDD: confirmed compile error against legacy 4-field record before changing source
  • No fixture, other-kit, or non-Bridge IR code modified

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings May 3, 2026 06:03
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 3, 2026

Warning

Rate limit exceeded

@TSavo has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 37 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 01279e55-1707-4288-b645-c04d0f8c7b85

📥 Commits

Reviewing files that changed from the base of the PR and between 9d7da9c and 1d7e812.

📒 Files selected for processing (3)
  • implementations/java/provekit-ir/src/main/java/com/provekit/ir/Declaration.java
  • implementations/java/provekit-ir/src/main/java/com/provekit/ir/IrDocument.java
  • implementations/java/provekit-ir/src/test/java/com/provekit/ir/IrDocumentTest.java
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/java-bridge-ir-v1-1-0-shape

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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 9 minutes and 37 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@TSavo TSavo merged commit 7fee2bc into main May 3, 2026
5 of 6 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.Bridge with the v1.1.0 BridgeDeclaration shape (adds name, sourceLayer, targetProofCid, targetLayer, optional notes; removes evidence).
  • Updates Declaration.Bridge#toJson() to emit keys in the canonical fixture order and omit notes when null.
  • Updates Java tests to assert bridge serialization matches the conformance/fixtures.toml bridge_decl literal.

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.

Comment on lines 41 to +60
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\""));
}
Comment on lines +68 to +83
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");
Comment on lines +41 to 72
/** 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):
TSavo added a commit that referenced this pull request May 3, 2026
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>
TSavo added a commit that referenced this pull request May 3, 2026
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>
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.

2 participants