Skip to content

feat(java): provekit-java-self-contracts module + RPC orchestrator + KIT_TABLE wiring (closes #207)#240

Merged
TSavo merged 1 commit into
mainfrom
worktree-agent-a79343d1ee6d40f66
May 4, 2026
Merged

feat(java): provekit-java-self-contracts module + RPC orchestrator + KIT_TABLE wiring (closes #207)#240
TSavo merged 1 commit into
mainfrom
worktree-agent-a79343d1ee6d40f66

Conversation

@TSavo
Copy link
Copy Markdown
Owner

@TSavo TSavo commented May 4, 2026

Summary

New Maven module provekit-java-self-contracts under implementations/java/ provides Side A substrate-driven conformance for the java kit per the (A)/(B) split (#176). Imports the just-landed provekit-claim-envelope (PR #228) for native BLAKE3 + JCS + Ed25519 + CBOR + envelope construction; no shell-out to another kit.

  • Module walks 6 slabs (blake3, cbor, claim_envelope, ed25519, jcs, proof_envelope) authoring 30 java_*-prefixed contracts about the kit's own public surface
  • Rpc.java: persistent-daemon NDJSON handler on stdio. initialize / lift / shutdown; only shutdown exits the loop. Matches PR feat(ts): wire --kit=ts to typescript-self-contracts surface + RPC mode (closes #204) #220's lifecycle pattern
  • Shaded fat jar via maven-shade-plugin (BouncyCastle + claim-envelope bundled, BC signature files stripped)
  • run-rpc.sh resolves java via $JAVA -> $JAVA_HOME -> PATH -> Homebrew openjdk fallback (works around the macOS /usr/bin/java stub which refuses to run when no JDK is registered in /Library/Java/JavaVirtualMachines/)
  • KIT_TABLE: ("java", "java", "java", "java") -> ("java", "java", "java-self-contracts", "java")
  • New mint_kit_integration test 9 pins JAVA_CONTRACT_SET_CID = blake3-512:a22c9736...; java moved from KITS_WITHOUT_LIFTERS to KITS_WITH_LIFTERS

Acceptance (closes #207)

  • Create implementations/java/provekit-java-self-contracts/ Maven module (registered in parent pom.xml)
  • Module walks the Java IR / kit's own contracts (via in-module slabs; the rust-style provekit-ir Collector surface is intentionally out of scope for the bootstrap)
  • Emit proof-envelope to stdout under canonical --rpc lift-protocol framing
  • Add java-self-contracts lift surface manifest at implementations/java/.provekit/lift/java-self-contracts/manifest.toml
  • Update KIT_TABLE in implementations/rust/provekit-cli/src/cmd_mint.rs
  • Add a pinned-CID test in mint_kit_integration.rs
  • make mint-java produces a content-meaningful contractSetCid
  • provekit prove implementations/java exits 0
  • Pinned-CID test passes

mint-java output

catalog cid:    blake3-512:93dd048300ce9db0454fae4dd9639deca7d200de2edc005672213aec492e75c95c342ad174e3850e8ec31cfe09403c8f772fafff778254ea246367648b3a0e39
contractSetCid: blake3-512:a22c97362e15faf1e848eeb7d668ba50eba8cfb851a72465f2cccb0ca9e12af198ec14cc0e65453a18b1e40bbd17497f8975b6e3625bbf2b6b31e6ca6aacb6e3
30 contracts across 6 slabs

KIT_TABLE diff

-    ("java",       "java",        "java",                 "java"),
+    ("java",       "java",        "java-self-contracts",  "java"),

Daemon-lifecycle adherence

Rpc.run() reads NDJSON in a while (line = readLine()) loop, dispatching initialize / lift / shutdown. Only shutdown returns from the loop. initialize and lift can be called any number of times before shutdown. Each lift mints into a fresh Files.createTempDirectory that's cleaned up before the response is emitted. This matches PR #220's "persistent-daemon-with-explicit-shutdown" contract.

Test plan

  • mvn -pl provekit-java-self-contracts -am test passes (5/5: mint determinism, contract uniqueness, slab structure, java_*-prefix invariant, content-meaningful CID)
  • cargo test -p provekit-cli --test mint_kit_integration java_kit_pins_expected_contract_set_cid passes
  • cargo test -p provekit-cli --test mint_kit_integration all_kits_mint_produces_valid_attestation_structure passes
  • cargo test -p provekit-cli --test mint_kit_integration kits_without_lifters_produce_empty_set_cid passes (java is no longer in that set)
  • cargo test -p provekit-cli --bin provekit cmd_mint 9/9 passes (including resolve_kit_all_11_kits)
  • make mint-java succeeds; verifier accepts the new signed attestation
  • RPC handshake smoke-tested: initialize / lift / shutdown via stdin pipe; bytes round-trip the rust dispatcher

Out-of-scope notes

  • Cross-kit lift_plugin_protocol bridges (the phase-2 closed-loop bridge dance go does in PASS 2) are NOT authored in this bootstrap. The Java kit's contract slab list is the kit-internal surface only, mirroring the csharp peer's pattern (substrate API contracts, not protocol-rule contracts). Rust authors catalog_format rules; csharp/cpp/go/ts do not. Java aligns with the larger group.
  • The 30 contracts are kit-internal; cross-language contract-set CID convergence happens at the per-kit provekit prove level, not at the contract-set CID level. Each kit's contractSetCid is its own content-address; the bridge layer is what connects them.

🤖 Generated with Claude Code

…KIT_TABLE wiring (closes #207)

New Maven module `provekit-java-self-contracts` under `implementations/java/`
provides the Side A substrate-driven conformance for the java kit per the
(A)/(B) split (#176). Imports the just-landed `provekit-claim-envelope`
(#208 / PR #228) for native BLAKE3 + JCS + Ed25519 + CBOR + envelope
construction; no shell-out to another kit.

## Module shape

- `Slab.java`: minimal in-module Collector + ContractDecl + JCS-Value
  formula DSL (var/const/ctor/atomic/forall/eq/gte/startsWith). Avoids
  building an authoring surface in `provekit-ir`; the bootstrap doesn't
  need one and rust hasn't lifted that surface yet.
- `JavaKitInvariants.java`: 6 slabs (blake3, cbor, claim_envelope,
  ed25519, jcs, proof_envelope), 30 `java_*`-prefixed contracts.
  Mirrors the cross-kit pattern (csharp `*Invariants.Register()`, rust
  `.invariant.rs` + orchestrator `#[path]`).
- `Orchestrator.java`: drains every slab, mints each contract via
  `ClaimEnvelope.mintContract`, builds the catalog via
  `ProofEnvelope.build`, computes `contractSetCid` with
  `ClaimEnvelope.computeContractSetCid`. Mirrors the C# `Program.MintOneRun`
  flow line-for-line.
- `Rpc.java`: lift-plugin protocol (`provekit-lift/1`) on stdio NDJSON.
  Persistent daemon (handles initialize/lift/N times/shutdown), only
  exits on shutdown. Matches the daemon-lifecycle pattern established
  by PR #220 (ts) and the csharp peer.
- `Main.java`: arg parse: `--rpc` -> Rpc.run(); else Orchestrator.runCli().
- `run-rpc.sh`: shell wrapper resolving java via `$JAVA`, `$JAVA_HOME`,
  `$PATH`, then Homebrew openjdk fallback (the macOS `/usr/bin/java`
  stub refuses to run when no JDK is registered in
  `/Library/Java/JavaVirtualMachines/`; we bypass it).
- Shaded jar via `maven-shade-plugin` (BouncyCastle + claim-envelope
  bundled, BC signature files stripped so verification doesn't reject
  the relocated classes).

## Acceptance (#207)

- [x] Maven module created, parent reactor updated.
- [x] Module walks the kit's own contracts via JavaKitInvariants slabs.
- [x] Emits proof-envelope to stdout under canonical `--rpc` framing.
- [x] Lift surface manifest at `implementations/java/.provekit/lift/java-self-contracts/manifest.toml`.
- [x] KIT_TABLE updated: `("java", "java", "java", "java")` -> `("java", "java", "java-self-contracts", "java")`.
- [x] Pinned-CID test 9 in `mint_kit_integration.rs`; java moved from KITS_WITHOUT_LIFTERS to KITS_WITH_LIFTERS.
- [x] `make mint-java` produces `contractSetCid: blake3-512:a22c9736...` (content-meaningful, not the empty-set sentinel `d53d18c2...`).
- [x] `provekit prove implementations/java` exits 0.
- [x] `mvn test` for the module: 5 passing (smoke tests for mint determinism + slab structure).

## mint-java output

```
catalog cid:    blake3-512:93dd048300ce9db0454fae4dd9639deca7d200de2edc005672213aec492e75c95c342ad174e3850e8ec31cfe09403c8f772fafff778254ea246367648b3a0e39
contractSetCid: blake3-512:a22c97362e15faf1e848eeb7d668ba50eba8cfb851a72465f2cccb0ca9e12af198ec14cc0e65453a18b1e40bbd17497f8975b6e3625bbf2b6b31e6ca6aacb6e3
30 contracts across 6 slabs
```

## KIT_TABLE diff

```
-    ("java",       "java",        "java",                 "java"),
+    ("java",       "java",        "java-self-contracts",  "java"),
```

## Daemon-lifecycle adherence

`Rpc.run()` reads NDJSON in a `while (line = readLine())` loop, dispatching
`initialize`/`lift`/`shutdown`. Only `shutdown` returns from the loop;
`initialize` and `lift` may be called any number of times before
shutdown. Each `lift` mints into a fresh `Files.createTempDirectory`
that's cleaned up before the response is emitted. Matches PR #220's
"persistent-daemon-with-explicit-shutdown" contract.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 4, 2026 07:06
@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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

Warning

Rate limit exceeded

@TSavo has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 58 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: cec65bb9-14d9-43aa-96b7-0d1ff301ae31

📥 Commits

Reviewing files that changed from the base of the PR and between 7f8c45f and 7f9604c.

📒 Files selected for processing (14)
  • .provekit/self-contracts-attestations/java.json
  • Makefile
  • implementations/java/.provekit/lift/java-self-contracts/manifest.toml
  • implementations/java/pom.xml
  • implementations/java/provekit-java-self-contracts/pom.xml
  • implementations/java/provekit-java-self-contracts/run-rpc.sh
  • implementations/java/provekit-java-self-contracts/src/main/java/com/provekit/selfcontracts/JavaKitInvariants.java
  • implementations/java/provekit-java-self-contracts/src/main/java/com/provekit/selfcontracts/Main.java
  • implementations/java/provekit-java-self-contracts/src/main/java/com/provekit/selfcontracts/Orchestrator.java
  • implementations/java/provekit-java-self-contracts/src/main/java/com/provekit/selfcontracts/Rpc.java
  • implementations/java/provekit-java-self-contracts/src/main/java/com/provekit/selfcontracts/Slab.java
  • implementations/java/provekit-java-self-contracts/src/test/java/com/provekit/selfcontracts/OrchestratorTest.java
  • implementations/rust/provekit-cli/src/cmd_mint.rs
  • implementations/rust/provekit-cli/tests/mint_kit_integration.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-agent-a79343d1ee6d40f66

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 12 minutes and 58 seconds.

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

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

Adds a Java “self-contracts” lifter surface that can mint a deterministic proof-envelope via lift-plugin RPC, then wires --kit=java in the Rust CLI to use that surface and pins the resulting Java contractSetCid in the Rust integration suite.

Changes:

  • Introduce new Maven module provekit-java-self-contracts with slab authoring, mint orchestrator, and NDJSON JSON-RPC (--rpc) server.
  • Wire Rust CLI KIT_TABLE so --kit=java routes to java-self-contracts, and add a pinned Java contractSetCid integration test.
  • Add build + manifest plumbing (Makefile target, lift manifest, and attestation JSON update) so make mint-java produces a content-meaningful CID.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
implementations/rust/provekit-cli/tests/mint_kit_integration.rs Adds Java to “kits with lifters” and introduces pinned JAVA_CONTRACT_SET_CID test.
implementations/rust/provekit-cli/src/cmd_mint.rs Routes --kit=java to the new java-self-contracts lift surface.
implementations/java/provekit-java-self-contracts/src/test/java/com/provekit/selfcontracts/OrchestratorTest.java Smoke tests for determinism, structure, and naming invariants of authored contracts.
implementations/java/provekit-java-self-contracts/src/main/java/com/provekit/selfcontracts/Slab.java Defines contract declaration model + small DSL for building JCS Value formula trees.
implementations/java/provekit-java-self-contracts/src/main/java/com/provekit/selfcontracts/Rpc.java Implements lift-plugin JSON-RPC (initialize/lift/shutdown) over NDJSON on stdio.
implementations/java/provekit-java-self-contracts/src/main/java/com/provekit/selfcontracts/Orchestrator.java Drives slab authoring, memento minting, proof-envelope build, and contractSetCid computation.
implementations/java/provekit-java-self-contracts/src/main/java/com/provekit/selfcontracts/Main.java Entrypoint supporting standalone mode and --rpc mode.
implementations/java/provekit-java-self-contracts/src/main/java/com/provekit/selfcontracts/JavaKitInvariants.java Authors the 6 slabs / 30 java_* kit-internal contracts.
implementations/java/provekit-java-self-contracts/run-rpc.sh Shell launcher that locates a usable java and executes the shaded jar.
implementations/java/provekit-java-self-contracts/pom.xml New shaded-jar module configuration and dependency on provekit-claim-envelope.
implementations/java/pom.xml Registers the new Maven module in the Java reactor build.
implementations/java/.provekit/lift/java-self-contracts/manifest.toml Declares the java-self-contracts lift surface manifest used by provekit-cli.
Makefile Adds build-java-self-contracts and wires it into build-java/mint-java.
.provekit/self-contracts-attestations/java.json Updates Java’s attestation to the newly minted cid/contractSetCid/signature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +44 to +47
private static final Pattern ID_FIELD = Pattern.compile(
"\"id\"\\s*:\\s*(\"[^\"]*\"|\\d+|null|true|false)");
private static final Pattern METHOD_FIELD = Pattern.compile(
"\"method\"\\s*:\\s*\"([^\"]*)\"");
Comment on lines +24 to +29
// Authoring surface: java-self-contracts. Slabs walked:
// - catalog_format 13 contracts mirroring rust catalog_format.rs
//
// Future slabs (lift_plugin_protocol cross-kit bridges, provekit-claim-envelope
// kit-internal invariants) are bootstrapped separately. This module ships
// with a content-meaningful contractSetCid as the first deliverable.
public final class Orchestrator {

public static final byte[] FOUNDATION_SEED = Ed25519.FOUNDATION_V0_SEED;
public static final String DECLARED_AT = "2026-04-30T18:00:00.000Z";
Comment on lines +604 to +612
let (ok, stdout, stderr) = run_mint("java");
if !ok {
eprintln!(
"java kit: mint failed (java/jar may not be available)\n stderr: {stderr}"
);
// Skip rather than fail -- jdk + built jar may not be present in
// every test environment. CI builds the jar via `make build-java-self-contracts`.
return;
}
@TSavo TSavo merged commit ec3d6cb into main May 4, 2026
8 checks passed
ConstCorrectness pushed a commit to ConstCorrectness/provekit that referenced this pull request May 6, 2026
…Savo#325)

Pre-fix: cmd_prove duplicated a hardcoded KIT_TABLE that mapped
kit_alias → surface=kit_alias (e.g. cpp → cpp). Post all the KIT_TABLE
updates in cmd_mint (PRs TSavo#176, TSavo#180, TSavo#183, TSavo#217, TSavo#234, TSavo#240, TSavo#243,
TSavo#272, etc.), the canonical mapping is kit_alias → <kit>-self-contracts.

Symptoms on main:
- prove-cpp: surface `cpp` not in capabilities.authoring_surfaces
  [`cpp-self-contracts`] — C4 verifier rejects.
- prove-swift: lifter binary `provekit-lift-swift` not found
  (Swift Package builds `mint-swift-self-contracts`, not that).

Fix:
- Make `cmd_mint::KIT_TABLE` and `cmd_mint::resolve_kit` `pub(crate)`
- Delete cmd_prove's duplicate hardcoded table
- cmd_prove::resolve_kit now adapts cmd_mint::resolve_kit (drops
  lang_key field — prove doesn't write attestations)
- capture_rpc loads the manifest at the correct surface path
  (manifest dispatch was already correct; only the surface name
  resolution was wrong)

Tests: 18/18 cmd_prove pass, including new regression tests:
- resolve_kit_cpp_uses_self_contracts_surface_issue_325
- resolve_kit_swift_uses_self_contracts_surface_issue_325
- resolve_kit_agrees_with_cmd_mint_for_all_kits (cross-check
  prove ↔ mint to prevent recurrence)
- swift_manifest_command_is_not_hardcoded_provekit_lift_swift

Closes TSavo#325.

Co-Authored-By: Claude Opus 4.7 (1M context) <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.

[kit:java][axis:A] Bootstrap provekit-java-self-contracts Maven module + RPC orchestrator

2 participants