Skip to content

Commit 2303996

Browse files
authored
Merge pull request #5 from easy-4-java/feature/REQ-20261118-wandl-opencli-contracts-20
Integrate OpenCLI C01/C02 contracts on current 2.0 feature branch
2 parents 196206d + 7f4210b commit 2303996

180 files changed

Lines changed: 17387 additions & 1332 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.

‎.gitattributes‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# The last TSV field intentionally encodes an empty argv token. Do not trim it.
2+
src/test/resources/opencli-contracts/v1/argv.tsv whitespace=-blank-at-eol

‎.github/workflows/ci.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ jobs:
3434
java-version: '17'
3535
cache: maven
3636

37+
- name: Verify shared contract fixtures and source lock
38+
working-directory: src/test/resources/opencli-contracts/v1
39+
run: sha256sum --strict -c SHA256SUMS
40+
41+
- name: Verify pinned structured help samples
42+
working-directory: src/test/resources/opencli-contracts/v1/structured-help-1.8.8
43+
run: sha256sum --strict -c SHA256SUMS
44+
45+
- name: Verify pinned browser output samples
46+
working-directory: src/test/resources/opencli-contracts/v1/browser-output-1.8.8
47+
run: sha256sum --strict -c SHA256SUMS
48+
3749
- name: Build and verify with JaCoCo coverage
3850
run: ./mvnw -B --no-transfer-progress clean verify
3951

‎.github/workflows/contracts.yml‎

Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
name: OpenCLI Contracts
2+
3+
on:
4+
push:
5+
branches:
6+
- 'feature/1.0.x'
7+
- 'feature/2.0.x'
8+
- 'feature/3.0.x'
9+
- 'feature/*-contract-hardening'
10+
- 'feature/REQ-20261118-wandl-opencli-contracts-20'
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
specification:
18+
name: OpenSpec strict and evidence-runner tests
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 10
21+
env:
22+
OPENSPEC_TELEMETRY: '0'
23+
DO_NOT_TRACK: '1'
24+
CI: 'true'
25+
steps:
26+
- uses: actions/checkout@v7
27+
- uses: actions/setup-node@v4
28+
with:
29+
node-version: '22'
30+
- name: Verify report runner and shared fixture hashes
31+
run: |
32+
python3 -m unittest discover -s scripts/tests -v
33+
(cd src/test/resources/opencli-contracts/v1 && sha256sum -c SHA256SUMS)
34+
(cd src/test/resources/opencli-contracts/v1/structured-help-1.8.8 && sha256sum --strict -c SHA256SUMS)
35+
(cd src/test/resources/opencli-contracts/v1/browser-output-1.8.8 && sha256sum --strict -c SHA256SUMS)
36+
- name: Install pinned official OpenSpec
37+
run: npm install --prefix "$RUNNER_TEMP/opencli-openspec" --ignore-scripts --no-audit --no-fund @fission-ai/openspec@1.13.1
38+
- name: Validate all proposals and each change with strict mode
39+
shell: bash
40+
run: |
41+
export PATH="$RUNNER_TEMP/opencli-openspec/node_modules/.bin:$PATH"
42+
mkdir -p spec-evidence
43+
openspec --version | tee spec-evidence/version.txt
44+
openspec list --json > spec-evidence/list.json
45+
failed=0
46+
for path in openspec/changes/*; do
47+
[[ -d "$path" && "$(basename "$path")" != archive ]] || continue
48+
change="$(basename "$path")"
49+
if openspec validate "$change" --strict --no-interactive > "spec-evidence/$change.log" 2>&1; then
50+
printf '%s\tPASS\n' "$change"
51+
else
52+
cat "spec-evidence/$change.log"
53+
failed=1
54+
fi
55+
done
56+
if ! openspec validate --all --strict --no-interactive > spec-evidence/all.log 2>&1; then
57+
cat spec-evidence/all.log
58+
failed=1
59+
fi
60+
exit "$failed"
61+
- name: Upload specification evidence
62+
if: always()
63+
uses: actions/upload-artifact@v7
64+
with:
65+
name: openspec-strict-${{ github.sha }}
66+
path: spec-evidence
67+
if-no-files-found: error
68+
69+
jvm:
70+
name: Branch-specific JVM contract verification
71+
runs-on: ubuntu-latest
72+
timeout-minutes: 30
73+
steps:
74+
- uses: actions/checkout@v7
75+
- name: Select declared branch line
76+
id: line
77+
shell: bash
78+
run: |
79+
case "$GITHUB_REF_NAME" in
80+
feature/REQ-20261118-wandl-opencli-contracts-20) echo 'java=17' >> "$GITHUB_OUTPUT" ;;
81+
feature/1.0.x*) echo 'java=8' >> "$GITHUB_OUTPUT" ;;
82+
feature/2.0.x*) echo 'java=17' >> "$GITHUB_OUTPUT" ;;
83+
feature/3.0.x*) echo 'java=21' >> "$GITHUB_OUTPUT" ;;
84+
*) echo 'Unsupported branch line' >&2; exit 1 ;;
85+
esac
86+
- uses: actions/setup-java@v5
87+
with:
88+
distribution: temurin
89+
java-version: ${{ steps.line.outputs.java }}
90+
cache: maven
91+
- name: Record exact source and actual tools
92+
run: |
93+
mkdir -p contract-evidence
94+
git rev-parse HEAD > contract-evidence/head.txt
95+
git archive -o contract-evidence/source.tar HEAD
96+
sha256sum contract-evidence/source.tar > contract-evidence/source.sha256
97+
java -version > contract-evidence/java.txt 2>&1
98+
if ! bash ./mvnw -version > contract-evidence/maven.txt 2>&1; then
99+
cat contract-evidence/maven.txt
100+
exit 1
101+
fi
102+
cat contract-evidence/java.txt contract-evidence/maven.txt
103+
- name: Full clean verify using this branch wrapper
104+
id: verify
105+
shell: bash
106+
run: |
107+
set +e
108+
bash ./mvnw -B --no-transfer-progress clean verify > contract-evidence/maven.log 2>&1
109+
result=$?
110+
printf '%s\n' "$result" > contract-evidence/maven.exit
111+
tail -100 contract-evidence/maven.log
112+
exit "$result"
113+
- name: Require nonempty, non-skipped contract evidence
114+
if: always()
115+
shell: bash
116+
run: |
117+
test -f contract-evidence/maven.exit
118+
python3 scripts/contract_report.py \
119+
--reports target/surefire-reports \
120+
--trace openspec/changes/enforce-opencli-branch-contract-parity/evidence/final-requirement-trace.md \
121+
--head "$(cat contract-evidence/head.txt)" \
122+
--branch "$GITHUB_REF_NAME" \
123+
--java-version-file contract-evidence/java.txt \
124+
--maven-version-file contract-evidence/maven.txt \
125+
--exit-code "$(cat contract-evidence/maven.exit)" \
126+
--suite enumeration=io.github.easy4j.opencli.contract.OpenCliStructuredHelpFixtureTest \
127+
--suite enumeration=io.github.easy4j.opencli.contract.OpenCliHelpParserTest \
128+
--suite enumeration=io.github.easy4j.opencli.capability.OpenCliCapabilityDiscoveryTest \
129+
--suite argv=io.github.easy4j.opencli.capability.OpenCliCapabilityCommandTest \
130+
--suite argv=io.github.easy4j.opencli.contract.OpenCliArgvContractTest \
131+
--suite argv=io.github.easy4j.opencli.contract.OpenCliStructuredArgvContractTest \
132+
--suite process=io.github.easy4j.opencli.contract.OpenCliProcessContractTest \
133+
--suite process=io.github.easy4j.opencli.contract.OpenCliProcessBoundaryTest \
134+
--suite process=io.github.easy4j.opencli.core.support.SubprocessCleanupFaultTest \
135+
--suite process=io.github.easy4j.opencli.core.support.SubprocessCompletionRaceTest \
136+
--suite process=io.github.easy4j.opencli.core.support.SubprocessStreamFailureTest \
137+
--suite process=io.github.easy4j.opencli.core.OpenCliProcessPrivacyTest \
138+
--suite protocol=io.github.easy4j.opencli.center.ws.OpenCliWsReverseAgentSessionTest \
139+
--suite protocol=io.github.easy4j.opencli.center.ws.OpenCliWsCollectRequestsTest \
140+
--suite protocol=io.github.easy4j.opencli.remote.OpenCliRemoteAgentHttpClientTest \
141+
--suite protocol=io.github.easy4j.opencli.contract.OpenCliErrorEnvelopeTest \
142+
--suite typed-result=io.github.easy4j.opencli.contract.OpenCliBrowserResultTest \
143+
--suite typed-result=io.github.easy4j.opencli.contract.OpenCliBrowserEvidenceResultTest \
144+
--suite typed-result=io.github.easy4j.opencli.capability.OpenCliDiagnosticsTest \
145+
--suite argv=io.github.easy4j.opencli.capability.OpenCliInvocationContextTest \
146+
--suite argv=io.github.easy4j.opencli.core.OpenCliArgSupportTest \
147+
--suite process=io.github.easy4j.opencli.core.support.SubprocessExecutionSupportTest \
148+
--suite protocol=io.github.easy4j.opencli.remote.OpenCliArgvToCollectParserFullTest \
149+
--suite typed-result=io.github.easy4j.opencli.core.OpenCliDiagnosticExportTest \
150+
--output contract-evidence/report.json
151+
- name: Upload actual JVM evidence
152+
if: always()
153+
uses: actions/upload-artifact@v7
154+
with:
155+
name: contracts-jdk-${{ steps.line.outputs.java }}-${{ github.sha }}
156+
path: |
157+
contract-evidence
158+
target/surefire-reports
159+
target/site/jacoco
160+
if-no-files-found: error
161+
162+
process-platform:
163+
name: Subprocess contracts (${{ matrix.os }})
164+
if: github.ref_name == 'feature/REQ-20261118-wandl-opencli-contracts-20'
165+
strategy:
166+
fail-fast: false
167+
matrix:
168+
os: [macos-latest, macos-15-intel, windows-latest]
169+
runs-on: ${{ matrix.os }}
170+
timeout-minutes: 15
171+
defaults:
172+
run:
173+
shell: bash
174+
steps:
175+
- uses: actions/checkout@v7
176+
- uses: actions/setup-java@v5
177+
with:
178+
distribution: temurin
179+
java-version: '17'
180+
cache: maven
181+
- uses: actions/setup-python@v7
182+
with:
183+
python-version: '3.13'
184+
- uses: actions/setup-node@v4
185+
if: runner.os == 'Windows'
186+
with:
187+
node-version: '22'
188+
- name: Exercise real subprocess contracts
189+
run: |
190+
mkdir -p platform-evidence
191+
if [[ "$RUNNER_OS" == Windows ]]; then
192+
OPENCLI_CONTRACT_NODE_EXECUTABLE="$(node -p 'process.execPath')"
193+
export OPENCLI_CONTRACT_NODE_EXECUTABLE
194+
fi
195+
java -version > platform-evidence/java.txt 2>&1
196+
mvn -version > platform-evidence/maven.txt 2>&1
197+
result=0
198+
mvn -B --no-transfer-progress \
199+
-Dtest=OpenCliCapabilityDiscoveryTest,OpenCliCapabilityCommandTest,OpenCliErrorEnvelopeTest,OpenCliBrowserResultTest,OpenCliBrowserEvidenceResultTest,OpenCliDiagnosticsTest,OpenCliInvocationContextTest,OpenCliArgvContractTest,OpenCliStructuredArgvContractTest,OpenCliProcessContractTest,OpenCliProcessBoundaryTest,SubprocessCleanupFaultTest,SubprocessCompletionRaceTest,SubprocessStreamFailureTest,OpenCliWsReverseAgentSessionTest,OpenCliWsCollectRequestsTest,OpenCliRemoteAgentHttpClientTest,OpenCliProcessPrivacyTest,OpenCliArgSupportTest#shouldKeepConversionExceptionAndNestedCausePrivate,SubprocessExecutionSupportTest#shouldKeepNativePathOutOfDefaultHandlerException+legacyOutputStreamsAllowBoundedWritesWithoutChangingExecutionDetails,OpenCliStructuredHelpFixtureTest,OpenCliHelpParserTest,OpenCliArgvToCollectParserFullTest,OpenCliDiagnosticExportTest \
200+
test > platform-evidence/maven.log 2>&1 || result=$?
201+
tail -100 platform-evidence/maven.log
202+
python scripts/contract_report.py \
203+
--reports target/surefire-reports \
204+
--trace openspec/changes/enforce-opencli-branch-contract-parity/evidence/final-requirement-trace.md \
205+
--head "$(git rev-parse HEAD)" \
206+
--branch "$GITHUB_REF_NAME" \
207+
--java-version-file platform-evidence/java.txt \
208+
--maven-version-file platform-evidence/maven.txt \
209+
--exit-code "$result" \
210+
--suite enumeration=io.github.easy4j.opencli.contract.OpenCliHelpParserTest \
211+
--suite enumeration=io.github.easy4j.opencli.contract.OpenCliStructuredHelpFixtureTest \
212+
--suite enumeration=io.github.easy4j.opencli.capability.OpenCliCapabilityDiscoveryTest \
213+
--suite argv=io.github.easy4j.opencli.capability.OpenCliCapabilityCommandTest \
214+
--suite argv=io.github.easy4j.opencli.contract.OpenCliArgvContractTest \
215+
--suite argv=io.github.easy4j.opencli.contract.OpenCliStructuredArgvContractTest \
216+
--suite process=io.github.easy4j.opencli.contract.OpenCliProcessContractTest \
217+
--suite process=io.github.easy4j.opencli.contract.OpenCliProcessBoundaryTest \
218+
--suite process=io.github.easy4j.opencli.core.support.SubprocessCleanupFaultTest \
219+
--suite process=io.github.easy4j.opencli.core.support.SubprocessCompletionRaceTest \
220+
--suite process=io.github.easy4j.opencli.core.support.SubprocessStreamFailureTest \
221+
--suite protocol=io.github.easy4j.opencli.remote.OpenCliArgvToCollectParserFullTest \
222+
--suite protocol=io.github.easy4j.opencli.center.ws.OpenCliWsReverseAgentSessionTest \
223+
--suite protocol=io.github.easy4j.opencli.center.ws.OpenCliWsCollectRequestsTest \
224+
--suite protocol=io.github.easy4j.opencli.remote.OpenCliRemoteAgentHttpClientTest \
225+
--suite process=io.github.easy4j.opencli.core.OpenCliProcessPrivacyTest \
226+
--suite argv=io.github.easy4j.opencli.core.OpenCliArgSupportTest \
227+
--suite process=io.github.easy4j.opencli.core.support.SubprocessExecutionSupportTest \
228+
--suite protocol=io.github.easy4j.opencli.contract.OpenCliErrorEnvelopeTest \
229+
--suite typed-result=io.github.easy4j.opencli.core.OpenCliDiagnosticExportTest \
230+
--suite typed-result=io.github.easy4j.opencli.contract.OpenCliBrowserResultTest \
231+
--suite typed-result=io.github.easy4j.opencli.contract.OpenCliBrowserEvidenceResultTest \
232+
--suite typed-result=io.github.easy4j.opencli.capability.OpenCliDiagnosticsTest \
233+
--suite argv=io.github.easy4j.opencli.capability.OpenCliInvocationContextTest \
234+
--output platform-evidence/report.json
235+
exit "$result"
236+
- name: Verify npm-installed OpenCLI on Windows
237+
if: runner.os == 'Windows'
238+
run: bash scripts/run_installed_contracts.sh mvn
239+
- name: Upload platform subprocess evidence
240+
if: always()
241+
uses: actions/upload-artifact@v7
242+
with:
243+
name: subprocess-${{ matrix.os }}-${{ github.sha }}
244+
path: |
245+
platform-evidence
246+
target/surefire-reports
247+
if-no-files-found: error
248+
249+
250+
browser-bridge:
251+
name: Real Browser Bridge (${{ matrix.os }})
252+
if: github.ref_name == 'feature/REQ-20261118-wandl-opencli-contracts-20'
253+
strategy:
254+
fail-fast: false
255+
matrix:
256+
os: [ubuntu-latest, windows-latest]
257+
runs-on: ${{ matrix.os }}
258+
timeout-minutes: 15
259+
defaults:
260+
run:
261+
shell: bash
262+
steps:
263+
- uses: actions/checkout@v7
264+
- uses: actions/setup-java@v5
265+
with:
266+
distribution: temurin
267+
java-version: '17'
268+
cache: maven
269+
- uses: actions/setup-python@v7
270+
with:
271+
python-version: '3.13'
272+
- uses: actions/setup-node@v4
273+
with:
274+
node-version: '24.18.0'
275+
- name: Install the published OpenCLI in the runner's temporary directory
276+
run: npm install --prefix "$RUNNER_TEMP/opencli-browser-cli" --ignore-scripts --no-audit --no-fund @jackwener/opencli@1.8.8
277+
- name: Exercise the real Chrome extension against the loopback daemon
278+
run: |
279+
python scripts/run_browser_bridge_contracts.py \
280+
--cli-entry "$RUNNER_TEMP/opencli-browser-cli/node_modules/@jackwener/opencli/dist/src/main.js" \
281+
--evidence browser-bridge-evidence -- mvn
282+
- name: Upload real Bridge evidence
283+
if: always()
284+
uses: actions/upload-artifact@v7
285+
with:
286+
name: browser-bridge-${{ matrix.os }}-${{ github.sha }}
287+
path: browser-bridge-evidence
288+
if-no-files-found: error

‎.github/workflows/repro-bundle.yml‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Offline contract reproduction bundle
2+
on:
3+
push:
4+
branches: ['feature/2.0.x-contract-hardening', 'feature/REQ-20261118-wandl-opencli-contracts-20']
5+
paths: ['.github/workflows/repro-bundle.yml']
6+
workflow_dispatch:
7+
permissions:
8+
contents: read
9+
jobs:
10+
bundle:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 15
13+
steps:
14+
- uses: actions/checkout@v7
15+
- uses: actions/setup-java@v5
16+
with:
17+
distribution: temurin
18+
java-version: '17'
19+
cache: maven
20+
- name: Verify baseline and resolve the proposed safe YAML parser
21+
run: |
22+
bash ./mvnw -B --no-transfer-progress clean verify
23+
bash ./mvnw -B --no-transfer-progress org.apache.maven.plugins:maven-dependency-plugin:3.8.1:get -Dartifact=org.yaml:snakeyaml:2.6
24+
- name: Package only public Maven artifacts and distribution
25+
shell: bash
26+
run: |
27+
mkdir -p repro-bundle
28+
git rev-parse HEAD > repro-bundle/source-head.txt
29+
java -version > repro-bundle/java.txt 2>&1
30+
bash ./mvnw -version > repro-bundle/maven.txt 2>&1
31+
# Never include settings.xml, toolchains.xml, Git credentials or environment dumps.
32+
tar -czf repro-bundle/maven-repository.tar.gz -C "$HOME/.m2" repository
33+
distribution="$(find "$HOME/.m2/wrapper/dists" -type d -name apache-maven-3.9.16 -print -quit)"
34+
test -n "$distribution"
35+
tar -czf repro-bundle/maven-distribution.tar.gz -C "$(dirname "$distribution")" apache-maven-3.9.16
36+
(cd repro-bundle && sha256sum ./*.tar.gz > SHA256SUMS)
37+
- uses: actions/upload-artifact@v7
38+
with:
39+
name: opencli-offline-repro-${{ github.sha }}
40+
path: repro-bundle
41+
retention-days: 3
42+
if-no-files-found: error

0 commit comments

Comments
 (0)