|
| 1 | +# AGENTS.md — Split Java SDK |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +Java SDK for [Split](https://www.split.io) — a Feature Delivery Platform. The SDK evaluates feature flags via the Split API, supporting both streaming (SSE) and polling synchronization modes, with optional pluggable storage backends (e.g., Redis). |
| 6 | + |
| 7 | +**Modules:** |
| 8 | +- `client/` — Core SDK (344+ Java files). Public API + evaluation engine. |
| 9 | +- `pluggable-storage/` — `CustomStorageWrapper` interface for custom storage backends. |
| 10 | +- `redis-wrapper/` — Redis implementation of `CustomStorageWrapper`. |
| 11 | +- `okhttp-modules/` — Optional OkHttp HTTP client (alternative to Apache). |
| 12 | +- `testing/` — Published test-support library (`SplitClientForTest`, JUnit 4 runner). |
| 13 | + |
| 14 | +## Build System |
| 15 | + |
| 16 | +- **Build tool**: Maven (multi-module parent POM at root) |
| 17 | +- **Java compatibility**: Java 8 (compiled with `-source 1.8 -target 1.8`) |
| 18 | +- **Build all modules**: `mvn --batch-mode clean install` |
| 19 | +- **Build single module**: `mvn -pl :client clean install -am` |
| 20 | +- **Skip tests**: `mvn clean install -DskipTests` |
| 21 | + |
| 22 | +## Testing |
| 23 | + |
| 24 | +- **Run all tests**: `mvn --batch-mode clean install` |
| 25 | +- **Run tests in one module**: `mvn -pl :client test` |
| 26 | +- **Run single test class**: `mvn -pl :client -Dtest=MyClassTest test` |
| 27 | +- **Test framework**: JUnit 4 (`junit:junit:4.13.1`) |
| 28 | +- **Note**: Tests in `client/` require a running Redis instance on `localhost:6379` for integration tests. |
| 29 | + |
| 30 | +## Linting & Formatting |
| 31 | + |
| 32 | +- **Lint check**: `mvn checkstyle:check` |
| 33 | +- **Style guide**: Google Java Style (`/.github/linter/google-java-style.xml`) |
| 34 | +- **Suppressions**: `/.github/linter/checkstyle-suppressions.xml` |
| 35 | +- **Runs automatically**: On every PR in CI for JDK 8 builds. |
| 36 | + |
| 37 | +## Git Workflow |
| 38 | + |
| 39 | +- **Default branch**: `master` |
| 40 | +- **Integration branch**: `development` (PRs target `development`, not `master`) |
| 41 | +- **Branch naming**: `FME-1234-short-description` (Jira ticket prefix + description) |
| 42 | +- **PR title format**: Match branch name or describe the change with Jira ticket |
| 43 | + |
| 44 | +## DOs |
| 45 | + |
| 46 | +- Always run `mvn checkstyle:check` before committing. |
| 47 | +- Follow the naming convention: interface `Foo`, implementation `FooImp` or `FooImpl`. |
| 48 | +- Keep DTOs in `client/dtos/` as pure wire-format classes — no business logic. |
| 49 | +- Call input validation via `inputValidation/` package before any public SDK operation. |
| 50 | +- Target PRs to the `development` branch, not `master`. |
| 51 | +- Match existing code style (Google Java Style). |
| 52 | + |
| 53 | +## DON'Ts |
| 54 | + |
| 55 | +- Never force push to `master` or `development`. |
| 56 | +- Never commit secrets, `.env` files, or credentials. |
| 57 | +- Never run `git commit --no-verify` (never skip hooks). |
| 58 | +- Never add business logic to DTO classes in `client/src/main/java/io/split/client/dtos/`. |
| 59 | +- Never add validation logic directly in `SplitClientImpl` — use `inputValidation/` package. |
| 60 | +- Never take runtime dependencies from the `testing/` module on `client/` internals. |
| 61 | + |
| 62 | +## Commands to Never Run |
| 63 | + |
| 64 | +- `git push --force origin master` |
| 65 | +- `git push --force origin development` |
| 66 | +- `git commit --no-verify` or `git push --no-verify` |
| 67 | +- `rm -rf` on any project directory without confirmation |
| 68 | + |
| 69 | +## Project Structure |
| 70 | + |
| 71 | +``` |
| 72 | +java-client/ |
| 73 | +├── client/ # Core SDK module (main artifact) |
| 74 | +│ └── src/main/java/io/split/ |
| 75 | +│ ├── client/ # Public API: SplitClient, SplitFactory, SplitClientConfig |
| 76 | +│ │ ├── impressions/ # Impression tracking (3 modes: DEBUG/OPTIMIZED/NONE) |
| 77 | +│ │ ├── dtos/ # Wire-format DTOs (51 classes, no business logic) |
| 78 | +│ │ ├── events/ # Event tracking |
| 79 | +│ │ └── api/ # SplitView and other public value objects |
| 80 | +│ ├── engine/ # Evaluation engine (most complex package) |
| 81 | +│ │ ├── evaluator/ # Core treatment resolution |
| 82 | +│ │ ├── experiments/ # ParsedSplit domain model + SplitFetcher |
| 83 | +│ │ ├── matchers/ # All matcher implementations (29 classes) |
| 84 | +│ │ ├── sse/ # SSE streaming subsystem (38 classes) |
| 85 | +│ │ ├── common/ # SyncManager: polling-vs-streaming orchestration |
| 86 | +│ │ └── segments/ # Segment sync tasks |
| 87 | +│ ├── storages/ # Storage abstraction (Consumer/Producer split) |
| 88 | +│ │ ├── memory/ # In-memory implementations |
| 89 | +│ │ └── pluggable/ # Adapters for CustomStorageWrapper backends |
| 90 | +│ ├── telemetry/ # SDK internal observability (not user-facing events) |
| 91 | +│ │ ├── domain/ # 23 domain classes for telemetry data |
| 92 | +│ │ ├── storage/ # TelemetryProducer/Consumer interfaces + impls |
| 93 | +│ │ └── synchronizer/ # Periodic telemetry flush to Split API |
| 94 | +│ ├── inputValidation/ # Defensive validators for all public API calls |
| 95 | +│ ├── grammar/ # Treatments constants (Treatments.java) |
| 96 | +│ ├── integrations/ # Third-party integrations (impression listeners) |
| 97 | +│ └── service/ # HTTP service layer |
| 98 | +├── pluggable-storage/ # CustomStorageWrapper contract (5 files) |
| 99 | +├── redis-wrapper/ # Redis storage impl (single + cluster + pipeline) |
| 100 | +├── okhttp-modules/ # Optional OkHttp HTTP client + Kerberos auth |
| 101 | +├── testing/ # Published test-support library (SplitClientForTest) |
| 102 | +└── pom.xml # Parent POM — manages versions and shared plugins |
| 103 | +``` |
| 104 | + |
| 105 | +## Important Packages |
| 106 | + |
| 107 | +Based on commit activity and architectural importance: |
| 108 | + |
| 109 | +| Package/Module | Role | |
| 110 | +|----------------|------| |
| 111 | +| `client/src/main/java/io/split/engine/` | Evaluation brain — the most algorithmically complex area | |
| 112 | +| `client/src/main/java/io/split/client/impressions/` | Impression tracking — wrong changes cause data loss | |
| 113 | +| `client/src/main/java/io/split/storages/` | Storage abstraction — Consumer/Producer interface hierarchy | |
| 114 | +| `client/src/main/java/io/split/telemetry/` | SDK observability — mirrors storage's producer/consumer pattern | |
| 115 | +| `pluggable-storage/` | Extension point for custom storage backends | |
| 116 | +| `redis-wrapper/` | Reference implementation of `CustomStorageWrapper` | |
| 117 | + |
| 118 | +## Language-Specific Guidelines |
| 119 | + |
| 120 | +This is a Java project. Invoke the `maf:java-conventions` skill for Java-specific patterns, build commands, and testing conventions. |
0 commit comments