Skip to content

Commit 0adc11f

Browse files
edburnsCopilot
andcommitted
feat(java): embed Rust CLI runtime as native module
Squashed from PR #2295 (branch edburns/…-review-02). Includes Java multi-module Maven restructure, copilot-native submodule for bundling the Rust CLI runtime, codegen updates, and related workflow changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 90cbda40-cda3-4ecd-b381-9f9ba0573d0a
1 parent a6d3ed1 commit 0adc11f

1,595 files changed

Lines changed: 6718 additions & 926 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/codegen-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
- 'go/rpc/**'
1616
- 'rust/src/generated/**'
1717
- 'sdk-protocol-version.json'
18-
- 'java/src/main/java/com/github/copilot/SdkProtocolVersion.java'
18+
- 'java/sdk/src/main/java/com/github/copilot/SdkProtocolVersion.java'
1919
- '.github/workflows/codegen-check.yml'
2020
workflow_dispatch:
2121

@@ -84,7 +84,7 @@ jobs:
8484
- name: Verify Java protocol version matches
8585
run: |
8686
EXPECTED=$(jq -r '.version' sdk-protocol-version.json)
87-
ACTUAL=$(grep -oP 'LATEST\(\K[0-9]+' java/src/main/java/com/github/copilot/SdkProtocolVersion.java)
87+
ACTUAL=$(grep -oP 'LATEST\(\K[0-9]+' java/sdk/src/main/java/com/github/copilot/SdkProtocolVersion.java)
8888
if [ "$EXPECTED" != "$ACTUAL" ]; then
8989
echo "::error::Java SDK protocol version ($ACTUAL) does not match sdk-protocol-version.json ($EXPECTED). Java manages its own SdkProtocolVersion.java via java/scripts/codegen/. Update it to match."
9090
exit 1

.github/workflows/docs-validation.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ on:
99
- 'python/copilot/**'
1010
- 'go/**/*.go'
1111
- 'dotnet/src/**'
12-
- 'java/src/**'
12+
- 'java/sdk/src/**'
1313
- 'java/pom.xml'
14+
- 'java/sdk/pom.xml'
1415
- 'scripts/docs-validation/**'
1516
- '.github/workflows/docs-validation.yml'
1617
workflow_dispatch:

.github/workflows/java-adapt-handwritten-code-to-accept-upgrade-changes.lock.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/java-adapt-handwritten-code-to-accept-upgrade-changes.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@ You are an automation agent that fixes handwritten Java SDK source and test code
5151

5252
- The branch `${{ inputs.branch }}` already has:
5353
- Updated `java/scripts/codegen/package.json` with the new version
54-
- Regenerated `java/src/generated/java/` code that compiles successfully
54+
- Regenerated `java/sdk/src/generated/java/` code that compiles successfully
5555
- Updated the Java POM CLI/version pin property
5656
- Your job is ONLY to fix **handwritten** code, NOT generated code.
5757

5858
## Boundaries
5959

60-
- ❌ Do NOT edit anything under `java/src/generated/java/`
60+
- ❌ Do NOT edit anything under `java/sdk/src/generated/java/`
6161
- ❌ Do NOT edit `java/scripts/codegen/java.ts`
62-
- ❌ Do NOT create or modify tests in the `com.github.copilot.generated` test package (`java/src/test/java/com/github/copilot/sdk/generated/`)
63-
- ✅ DO edit `java/src/main/java/com/github/copilot/sdk/**`
64-
- ✅ DO edit `java/src/test/java/com/github/copilot/sdk/**` (excluding the `generated` subpackage)
62+
- ❌ Do NOT create or modify tests in the `com.github.copilot.generated` test package (`java/sdk/src/test/java/com/github/copilot/sdk/generated/`)
63+
- ✅ DO edit `java/sdk/src/main/java/com/github/copilot/sdk/**`
64+
- ✅ DO edit `java/sdk/src/test/java/com/github/copilot/sdk/**` (excluding the `generated` subpackage)
6565
- ✅ DO add new test methods or test classes if new user-facing API surface is introduced
6666

6767
## Instructions
@@ -146,7 +146,7 @@ mvn verify -Dskip.test.harness=true
146146
If this passes, commit and push:
147147

148148
```bash
149-
git add java/src/main/java java/src/test/java
149+
git add java/sdk/src/main/java java/sdk/src/test/java
150150
git commit -m "Fix handwritten Java code for @github/copilot schema changes
151151
152152
Adapt constructor calls, enum references, and test assertions to match

.github/workflows/java-codegen-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ on:
66
- main
77
paths:
88
- 'java/scripts/codegen/**'
9-
- 'java/src/generated/**'
9+
- 'java/sdk/src/generated/**'
1010
- '.github/workflows/java-codegen-check.yml'
1111
pull_request:
1212
paths:
1313
- 'java/scripts/codegen/**'
14-
- 'java/src/generated/**'
14+
- 'java/sdk/src/generated/**'
1515
- '.github/workflows/java-codegen-check.yml'
1616
workflow_dispatch:
1717

.github/workflows/java-codegen-fix.lock.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/java-codegen-fix.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ You are an automation agent that fixes Java compilation and test failures caused
5454

5555
A Dependabot PR bumped the `@github/copilot` npm dependency in `java/scripts/codegen/package.json`. The `java-codegen-check` workflow ran the code generator (`java/scripts/codegen/java.ts`) against the new schemas and `mvn verify` subsequently failed. Your job is to fix **both** the code generator script (if needed) and the handwritten SDK/test source code so the build passes.
5656

57-
**❌❌❌ YOU MUST NEVER EDIT any of the java source code in `java/src/generated/` directly.** ✅✅Rather, the way to affect changes in these files is to change the code generator script and re-generate the classes in `java/src/generated`.
57+
**❌❌❌ YOU MUST NEVER EDIT any of the java source code in `java/sdk/src/generated/` directly.** ✅✅Rather, the way to affect changes in these files is to change the code generator script and re-generate the classes in `java/sdk/src/generated`.
5858

5959
The branch to fix is: `${{ inputs.branch }}`
6060
The PR number is: `${{ inputs.pr_number }}`
@@ -66,7 +66,7 @@ ${{ inputs.error_summary }}
6666

6767
## Architecture overview
6868

69-
The code generator (`java/scripts/codegen/java.ts`) reads JSON schemas from `node_modules/@github/copilot/schemas/` and produces Java source files under `java/src/generated/java/`. These generated types are consumed by handwritten code in `java/src/main/java/` (primarily `CopilotSession.java`) and tested by handwritten tests in `java/src/test/java/`.
69+
The code generator (`java/scripts/codegen/java.ts`) reads JSON schemas from `node_modules/@github/copilot/schemas/` and produces Java source files under `java/sdk/src/generated/java/`. These generated types are consumed by handwritten code in `java/sdk/src/main/java/` (primarily `CopilotSession.java`) and tested by handwritten tests in `java/sdk/src/test/java/`.
7070

7171
When `@github/copilot` is bumped, the schemas may change in ways the code generator does not yet handle. Common schema changes include:
7272

@@ -126,7 +126,7 @@ Before making fixes, determine whether the failure is caused by:
126126
- New schemas exist but no corresponding Java types were generated
127127

128128
**(B) Handwritten code referencing old generated type names/shapes.** Signs:
129-
- Compilation errors in `java/src/main/java/` or `java/src/test/java/` referencing types that no longer exist
129+
- Compilation errors in `java/sdk/src/main/java/` or `java/sdk/src/test/java/` referencing types that no longer exist
130130
- Test data using old JSON field names
131131

132132
Often **both** (A) and (B) apply: the codegen needs fixing first, then handwritten code needs updating.
@@ -162,7 +162,7 @@ If the diagnosis shows the code generator does not handle the new schema format:
162162

163163
4. **Verify the generated output** looks reasonable:
164164
```bash
165-
git diff --stat java/src/generated/java/
165+
git diff --stat java/sdk/src/generated/java/
166166
```
167167

168168
**You may ONLY modify `java/scripts/codegen/java.ts`.** Do not modify `package.json`, `package-lock.json`, or any other file under `java/scripts/codegen/`.
@@ -179,12 +179,12 @@ For each attempt:
179179
2. **Read the generated types** to understand what changed. Check the generated files that the handwritten code references:
180180
```bash
181181
# Example: check what a generated type looks like now
182-
cat java/src/generated/java/com/github/copilot/generated/rpc/<TypeName>.java
182+
cat java/sdk/src/generated/java/com/github/copilot/generated/rpc/<TypeName>.java
183183
```
184184

185185
3. **Fix the affected source files.** You may modify files under:
186-
- `java/src/main/java/` — handwritten SDK source code
187-
- `java/src/test/java/` — handwritten test code
186+
- `java/sdk/src/main/java/` — handwritten SDK source code
187+
- `java/sdk/src/test/java/` — handwritten test code
188188

189189
Common fixes:
190190
- Update type references from old nested types to new standalone types (e.g. `SessionMcpListResultServersItem``McpServer`)
@@ -236,12 +236,12 @@ Do **NOT** push broken code.
236236

237237
## Important constraints
238238

239-
- **NEVER** hand-edit files under `java/src/generated/java/` — these are auto-generated. They are updated by running `cd java/scripts/codegen && npx tsx java.ts`.
240-
- **NEVER** modify `java/pom.xml` — build config is not in scope
239+
- **NEVER** hand-edit files under `java/sdk/src/generated/java/` — these are auto-generated. They are updated by running `cd java/scripts/codegen && npx tsx java.ts`.
240+
- **NEVER** modify `java/sdk/pom.xml` — build config is not in scope
241241
- **NEVER** modify `java/scripts/codegen/package.json` or `java/scripts/codegen/package-lock.json` — dependency versions are not in scope
242242
- **NEVER** modify files under `.github/` — workflow files are not in scope
243243
- You **MAY** modify `java/scripts/codegen/java.ts` to fix the code generator
244-
- You **MAY** modify files under `java/src/main/java/` and `java/src/test/java/` to fix handwritten code
244+
- You **MAY** modify files under `java/sdk/src/main/java/` and `java/sdk/src/test/java/` to fix handwritten code
245245
- Always run `cd java && mvn spotless:apply` before committing to ensure code formatting
246246
- Maximum 3 fix attempts before reporting failure via `noop`
247247
- Only push if `mvn verify` passes

.github/workflows/java-sdk-tests.yml

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,52 @@ permissions:
1717
contents: read
1818

1919
jobs:
20+
java-sdk-inprocess:
21+
name: "Java SDK InProcess Tests"
22+
if: github.event.repository.fork == false
23+
runs-on: ubuntu-latest
24+
continue-on-error: true
25+
defaults:
26+
run:
27+
shell: bash
28+
working-directory: ./java
29+
steps:
30+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
31+
with:
32+
persist-credentials: false
33+
34+
- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
35+
with:
36+
java-version: "25"
37+
distribution: "microsoft"
38+
cache: "maven"
39+
40+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
41+
with:
42+
node-version: 22
43+
44+
- name: Run Java SDK tests (InProcess)
45+
env:
46+
CI: "true"
47+
run: mvn clean verify -Pinprocess
48+
49+
- name: Generate Test Report Summary
50+
if: always()
51+
uses: ./.github/actions/java-test-report
52+
with:
53+
title: "Copilot Java SDK :: Test Results InProcess"
54+
55+
- name: Upload test results on failure
56+
if: failure()
57+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
58+
with:
59+
name: java-test-results-inprocess
60+
path: |
61+
java/sdk/target/surefire-reports/
62+
java/sdk/target/surefire-reports-isolated/
63+
java/sdk/target/failsafe-reports/
64+
retention-days: 7
65+
2066
java-sdk:
2167
name: "Java SDK Tests (JDK ${{ matrix.test-jdk }})"
2268
if: github.event.repository.fork == false
@@ -96,17 +142,17 @@ jobs:
96142
run: |
97143
echo "Running tests against JDK 25-built classes using JDK 17 runtime..."
98144
java -version
99-
mvn jacoco:prepare-agent@wire-up-coverage-instrumentation antrun:run@print-test-jdk-banner surefire:test failsafe:integration-test failsafe:verify jacoco:report@build-coverage-report-from-tests -Denforcer.skip=true
145+
mvn -pl sdk jacoco:prepare-agent@wire-up-coverage-instrumentation antrun:run@print-test-jdk-banner surefire:test failsafe:integration-test failsafe:verify jacoco:report@build-coverage-report-from-tests -Denforcer.skip=true
100146
101147
- name: Upload test results for site generation
102148
if: success() && github.ref == 'refs/heads/main' && matrix.test-jdk == '25'
103149
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
104150
with:
105151
name: test-results-for-site
106152
path: |
107-
java/target/jacoco-test-results/sdk-tests.exec
108-
java/target/surefire-reports/
109-
java/target/surefire-reports-isolated/
153+
java/sdk/target/jacoco-test-results/sdk-tests.exec
154+
java/sdk/target/surefire-reports/
155+
java/sdk/target/surefire-reports-isolated/
110156
retention-days: 1
111157

112158
- name: Generate Test Report Summary
@@ -121,7 +167,7 @@ jobs:
121167
with:
122168
name: java-test-results-jdk-${{ matrix.test-jdk }}
123169
path: |
124-
java/target/surefire-reports/
125-
java/target/surefire-reports-isolated/
126-
java/target/failsafe-reports/
170+
java/sdk/target/surefire-reports/
171+
java/sdk/target/surefire-reports-isolated/
172+
java/sdk/target/failsafe-reports/
127173
retention-days: 7

0 commit comments

Comments
 (0)