Skip to content

Commit 7f649c4

Browse files
authored
refactor: organize SDK by language (#27)
* docs: define language-first SDK layout * docs: plan SDK language layout migration * test: define SDK repository layout contract * refactor: move Rust SDK workspace under rust * refactor: move Java SDK module under java * ci: align automation with language directories * docs: document language-first SDK layout * fix: anchor documentation contract at repository root * docs: update layout plan after dependency fix * fix: preserve required Java CI check * fix: preserve repository-root path contracts
1 parent 05fcc65 commit 7f649c4

289 files changed

Lines changed: 720 additions & 113 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/dependabot.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
version: 2
22
updates:
3+
- package-ecosystem: cargo
4+
directory: /rust
5+
schedule:
6+
interval: weekly
7+
day: monday
8+
time: "08:30"
9+
timezone: Australia/Sydney
10+
open-pull-requests-limit: 5
11+
312
- package-ecosystem: maven
4-
directory: /
13+
directory: /java
514
schedule:
615
interval: weekly
716
day: monday

.github/pull_request_template.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88

99
## Verification
1010

11-
- [ ] `mvn test`
12-
- [ ] `mvn verify`
13-
- [ ] `mvn spotless:check`
14-
- [ ] `mvn checkstyle:check`
11+
- [ ] `cd java && mvn test`
12+
- [ ] `cd java && mvn verify`
13+
- [ ] `cd java && mvn spotless:check`
14+
- [ ] `cd java && mvn checkstyle:check`
15+
- [ ] `cd rust && cargo test`
1516
- [ ] Documentation updated, if behavior changed
1617

1718
## Contract Checklist

.github/workflows/ci.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,21 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
jobs:
17-
memtruth-sdk:
18-
name: memtruth-sdk (rust 1.95)
17+
repository-layout:
18+
name: repository layout
1919
runs-on: ubuntu-latest
2020

21+
steps:
22+
- uses: actions/checkout@v6
23+
24+
- name: Verify language-first layout
25+
run: scripts/check-repository-layout.sh
26+
27+
rust-sdk:
28+
name: Rust SDK (1.95)
29+
runs-on: ubuntu-latest
30+
needs: repository-layout
31+
2132
steps:
2233
- uses: actions/checkout@v6
2334

@@ -27,20 +38,21 @@ jobs:
2738
rustup default 1.95.0
2839
2940
- name: Format
30-
working-directory: memtruth-sdk
41+
working-directory: rust
3142
run: cargo fmt --check
3243

3344
- name: Test
34-
working-directory: memtruth-sdk
45+
working-directory: rust
3546
run: cargo test
3647

3748
- name: Clippy
38-
working-directory: memtruth-sdk
49+
working-directory: rust
3950
run: cargo clippy --all-targets -- -D warnings
4051

41-
build:
52+
java-sdk:
4253
name: build (${{ matrix.java }})
4354
runs-on: ubuntu-latest
55+
needs: repository-layout
4456
strategy:
4557
fail-fast: false
4658
matrix:
@@ -55,14 +67,18 @@ jobs:
5567
distribution: temurin
5668
java-version: ${{ matrix.java }}
5769
cache: maven
70+
cache-dependency-path: java/pom.xml
5871

5972
- name: Style and static checks
73+
working-directory: java
6074
run: mvn -B -ntp spotless:check checkstyle:check
6175

6276
- name: Verify (unit + integration + recorded LLM + coverage)
77+
working-directory: java
6378
run: mvn -B -ntp verify -P recorded
6479

6580
- name: Resolve project version
81+
working-directory: java
6682
run: echo "PROJECT_VERSION=$(mvn -q -DforceStdout help:evaluate -Dexpression=project.version)" >> "$GITHUB_ENV"
6783

6884
- name: Compile quickstart against packaged SDK
@@ -75,6 +91,7 @@ jobs:
7591
run: scripts/smoke-cli-release.sh --version "${PROJECT_VERSION}"
7692

7793
- name: Generate SBOM
94+
working-directory: java
7895
run: mvn -B -ntp -DskipTests cyclonedx:makeAggregateBom
7996

8097
- name: Upload surefire reports on failure

.github/workflows/javadocs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@ jobs:
3232
distribution: temurin
3333
java-version: '25'
3434
cache: maven
35+
cache-dependency-path: java/pom.xml
3536

3637
- name: Generate Javadocs
38+
working-directory: java
3739
run: mvn -B -ntp javadoc:javadoc
3840

3941
- name: Upload Pages artifact
4042
uses: actions/upload-pages-artifact@v5
4143
with:
42-
path: target/site/apidocs
44+
path: java/target/site/apidocs
4345

4446
- name: Deploy to GitHub Pages
4547
id: deployment

.github/workflows/nightly-live.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ jobs:
2727
distribution: temurin
2828
java-version: '25'
2929
cache: maven
30+
cache-dependency-path: java/pom.xml
3031

3132
- name: Run bounded live LLM smoke
33+
working-directory: java
3234
run: mvn -B -ntp -P live -Dit.test=ExternalLlmSmokeIT failsafe:integration-test failsafe:verify
3335
env:
3436
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}

.github/workflows/release.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ jobs:
2828
distribution: temurin
2929
java-version: '25'
3030
cache: maven
31+
cache-dependency-path: java/pom.xml
3132
server-id: central
3233
server-username: MAVEN_USERNAME
3334
server-password: MAVEN_PASSWORD
3435
gpg-private-key: ${{ secrets.OSSRH_GPG_PRIVATE_KEY }}
3536
gpg-passphrase: MAVEN_GPG_PASSPHRASE
3637

3738
- name: Verify release commit
39+
working-directory: java
3840
run: mvn -B -ntp spotless:check checkstyle:check verify -P recorded
3941

4042
- name: Package CLI release artifacts
@@ -44,11 +46,13 @@ jobs:
4446
run: scripts/smoke-cli-release.sh --version "${GITHUB_REF_NAME#v}"
4547

4648
- name: Generate CycloneDX SBOM
49+
working-directory: java
4750
run: |
4851
mvn -B -ntp -DskipTests cyclonedx:makeAggregateBom
49-
cp target/bom.json dist/doctruth-${GITHUB_REF_NAME#v}-sbom.cdx.json
52+
cp target/bom.json ../dist/doctruth-${GITHUB_REF_NAME#v}-sbom.cdx.json
5053
5154
- name: Deploy to Sonatype Central Portal
55+
working-directory: java
5256
run: mvn -B -ntp -P release deploy -DskipTests
5357
env:
5458
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
@@ -63,9 +67,9 @@ jobs:
6367
path: |
6468
dist/*
6569
dist/homebrew/*
66-
target/*.jar
67-
target/*.jar.asc
68-
target/*.pom
70+
java/target/*.jar
71+
java/target/*.jar.asc
72+
java/target/*.pom
6973
retention-days: 30
7074

7175
- name: Create GitHub Release

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- Repositioned the repository as Memtruth SDK while keeping the existing
1616
`doctruth` Java package, Maven coordinate, CLI command, and release artifact
1717
names as compatibility surfaces.
18+
- Organized the public SDK repository into `rust/` and `java/` language
19+
workspaces, with shared docs, examples, configuration, and release scripts at
20+
the root.
1821

1922
### Fixed
2023

CONTRIBUTING.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ Public API compatibility:
3737
public API, regenerate it with:
3838

3939
```bash
40+
cd java
4041
mvn -Dtest=ai.doctruth.PublicApiSnapshotTest -Ddoctruth.updatePublicApiSnapshot=true test
4142
```
4243

43-
Review `src/test/resources/ai/doctruth/public-api-snapshot.txt` before committing.
44+
Review `java/src/test/resources/ai/doctruth/public-api-snapshot.txt` before committing.
4445

4546
Scope boundaries:
4647

@@ -78,11 +79,21 @@ export PATH=$JAVA_HOME/bin:$PATH
7879
Build + test:
7980

8081
```bash
82+
cd java
8183
mvn test # unit tests only (~3s)
8284
mvn verify # unit + integration + JaCoCo coverage gate (~10s)
8385
mvn spotless:apply # auto-format
8486
```
8587

88+
Rust workspace:
89+
90+
```bash
91+
cd rust
92+
cargo fmt --check
93+
cargo test
94+
cargo clippy --all-targets -- -D warnings
95+
```
96+
8697
`mvn verify` runs the JaCoCo coverage check (line ≥ 90% and branch ≥ 79%
8798
bundle-wide, excluding `ai.doctruth.internal.providers.*` wire records). Lower
8899
the gate only by ADR.
@@ -96,11 +107,11 @@ OpenAI chat-completions shape. Add a new first-class provider only when the
96107
vendor has materially different structured-output semantics, authentication,
97108
retry behavior, or audit metadata.
98109

99-
1. **Wire records**`src/main/java/ai/doctruth/internal/providers/<vendor>/wire/` with one record per request/response shape (immutable, Jackson-annotated).
100-
2. **HTTP client**`<Vendor>HttpClient` in `src/main/java/ai/doctruth/internal/providers/<vendor>/`, hand-rolled on `java.net.http.HttpClient`. No vendor SDK on the classpath.
110+
1. **Wire records**`java/src/main/java/ai/doctruth/internal/providers/<vendor>/wire/` with one record per request/response shape (immutable, Jackson-annotated).
111+
2. **HTTP client**`<Vendor>HttpClient` in `java/src/main/java/ai/doctruth/internal/providers/<vendor>/`, hand-rolled on `java.net.http.HttpClient`. No vendor SDK on the classpath.
101112
3. **Sealed `LlmProvider`** — add the new permits clause. This is a public-API change → MAJOR version bump (or ship as a separate artifact post-1.0).
102113
4. **Public `<Vendor>Provider` class** — in `ai.doctruth` root package, delegating to the internal `<Vendor>HttpClient`. Mirror the OpenAI-compatible / Anthropic / Gemini shape where possible.
103-
5. **WireMock-backed test class**`<Vendor>ProviderHttpTest` exercising happy path, retry, HTTP errors, response validation. Recorded responses go in `src/test/resources/wiremock/<vendor>/`.
114+
5. **WireMock-backed test class**`<Vendor>ProviderHttpTest` exercising happy path, retry, HTTP errors, response validation. Recorded responses go in `java/src/test/resources/wiremock/<vendor>/`.
104115
6. **ADR update** — if the provider introduces an architecturally novel concern (e.g. multimodal request shape, server-sent events), update or add an ADR.
105116

106117
## How to add an SPI implementation
@@ -117,8 +128,8 @@ Default implementations stay conservative and no-op where appropriate. Custom im
117128

118129
Before opening a PR, confirm:
119130

120-
- [ ] `mvn test` is green
121-
- [ ] `mvn verify` is green (includes integration tests + JaCoCo gate)
131+
- [ ] `cd java && mvn test` is green
132+
- [ ] `cd java && mvn verify` is green (includes integration tests + JaCoCo gate)
122133
- [ ] No file exceeds 300 LOC; no method body exceeds 30 LOC
123134
- [ ] No new entries in `<dependencies>` without an ADR in the same PR
124135
- [ ] Public-API changes flagged in the PR title (e.g. `feat!:` or `BREAKING CHANGE:` footer)

README.es.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Memtruth Parse soporta exportaciones comunes de Pydantic v2 JSON Schema, incluye
126126
Herramienta de migración en build-time:
127127

128128
```bash
129-
java -jar target/doctruth-java-0.2.0-alpha-all.jar \
129+
java -jar java/target/doctruth-java-0.2.0-alpha-all.jar \
130130
migrate pydantic myapp.schemas:ResumeExtraction \
131131
-o schemas/resume.schema.json \
132132
--check
@@ -150,10 +150,10 @@ Los clientes usan `java.net.http.HttpClient` del JDK; no hay SDKs de proveedores
150150
## CLI
151151

152152
```bash
153-
mvn package -DskipTests
154-
java -jar target/doctruth-java-0.2.0-alpha-all.jar parse contract.pdf
155-
java -jar target/doctruth-java-0.2.0-alpha-all.jar schema contract.schema.json
156-
java -jar target/doctruth-java-0.2.0-alpha-all.jar extract contract.pdf -s contract.schema.json
153+
mvn -f java/pom.xml package -DskipTests
154+
java -jar java/target/doctruth-java-0.2.0-alpha-all.jar parse contract.pdf
155+
java -jar java/target/doctruth-java-0.2.0-alpha-all.jar schema contract.schema.json
156+
java -jar java/target/doctruth-java-0.2.0-alpha-all.jar extract contract.pdf -s contract.schema.json
157157
```
158158

159159
## Documentación

README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,21 @@ Memtruth Parse is for teams that need to answer one question reliably:
3838
3939
The core boundary is simple: source document in, validated structured output plus evidence trail out.
4040

41-
[`memtruth-sdk`](memtruth-sdk/) is the Rust SDK workspace for corpus contracts,
41+
[`rust`](rust/) is the Rust SDK workspace for corpus contracts,
4242
section-aware chunking, retrieval projection, and Vespa preflight diagnostics.
4343
It is intentionally separate from any server memory layer: document output
4444
should flow through stable evidence/corpus contracts instead of coupling
4545
storage, MCP behavior, or hosted services to parser internals.
4646

47+
## Repository Layout
48+
49+
| Path | Responsibility |
50+
| --- | --- |
51+
| [`rust/`](rust/) | Rust contracts, chunking, retrieval projection, and Vespa adapters |
52+
| [`java/`](java/) | Java SDK, CLI, packaging, and `ai.doctruth` compatibility surface |
53+
| [`docs/`](docs/) | Architecture, contracts, integration guides, and ADRs |
54+
| [`examples/`](examples/) | Runnable Java integration and no-LLM parsing examples |
55+
4756
Memtruth Parse is framework-agnostic and fits into plain Java, Spring Boot,
4857
LangChain4j, Spring AI, Quarkus, Micronaut, or any Java service that already
4958
calls OpenAI, Anthropic, Gemini, DeepSeek, or an OpenAI-compatible model
@@ -125,10 +134,10 @@ The CLI is for first-run inspection, parser debugging, schema checks, and CI
125134
smoke tests. Parser and schema inspection do not require an LLM key.
126135

127136
```bash
128-
mvn package -DskipTests
129-
java -jar target/doctruth-java-0.2.0-alpha-all.jar parse examples/no-llm-parse/sample-contract.csv
130-
java -jar target/doctruth-java-0.2.0-alpha-all.jar parse examples/no-llm-parse/sample-contract.csv --json -o parsed.json
131-
java -jar target/doctruth-java-0.2.0-alpha-all.jar schema examples/pydantic-interop/resume.schema.json
137+
mvn -f java/pom.xml package -DskipTests
138+
java -jar java/target/doctruth-java-0.2.0-alpha-all.jar parse examples/no-llm-parse/sample-contract.csv
139+
java -jar java/target/doctruth-java-0.2.0-alpha-all.jar parse examples/no-llm-parse/sample-contract.csv --json -o parsed.json
140+
java -jar java/target/doctruth-java-0.2.0-alpha-all.jar schema examples/pydantic-interop/resume.schema.json
132141
```
133142

134143
For a copy-pasteable Java parser example that also needs no provider key, see
@@ -258,9 +267,9 @@ doctruth audit .doctruth/runs/<run-id>/audit.json
258267

259268
`0.2.0-alpha` is an early public alpha. The API is usable, tested, and published for feedback, but may still change before `1.0`.
260269

261-
Current verification baseline: `mvn verify` passes with 703 unit tests and the
262-
tracked integration suite; optional local corpus tests run when `fixtures/` is
263-
present. Coverage gates are 90% line / 79% branch.
270+
Java CI runs `cd java && mvn verify -P recorded`; Rust CI runs format, test, and
271+
clippy gates from `rust/`. Optional local corpus tests run when `fixtures/` is
272+
present. Java coverage gates are 90% line / 79% branch.
264273

265274
## License
266275

0 commit comments

Comments
 (0)