Axiomatic Reasoning for LLMs

Implementation Plan on Java

1. Target Architecture

This plan defines a Java implementation of Deep Coding based on three core layers:

2. Phase 1: Structural Specification

2.1. API Contract

2.2. Data Structure Contract

2.3. Domain Contract

2.4. Module Contract

3. Phase 2: Generative Conformance

3.1. Build-Time Code Generation

Generator Input Output Plugin
OpenAPI Generator OpenAPI YAML API interfaces, DTOs openapi-generator-maven-plugin
jsonschema2pojo JSON Schema POJOs jsonschema2pojo-maven-plugin
Custom annotation processor Java annotations Validators, monitors maven-compiler-plugin (built-in)

3.2. Incremental Generation

3.3. Generation Rules

4. Phase 3: Skeleton–Tissue Separation

4.1. Skeleton Layer Implementation

Pattern Java Construct Role
Template Method abstract class with final template method Immutable algorithm structure
Interface Contract Generated API interfaces Invariant operation signatures
Module Boundary module-info.java Physical encapsulation

4.2. Tissue Layer Implementation

4.3. Dependency Direction Enforcement

Use ArchUnit to enforce:

5. Phase 4: Validation Gates

5.1. Compile-Time Gates

Gate Tool Enforced Property
Module integrity JPMS No cyclic dependencies; exported packages only
Null safety Checker Framework (NullnessChecker) @NonNull/@Nullable contracts
Type state Checker Framework (OptionalChecker) Correct Optional usage
Custom constraints Annotation processors State transitions, business rules

Configure Checker Framework in Maven:

<plugin>
    <groupId>org.checkerframework</groupId>
    <artifactId>checkerframework-maven-plugin</artifactId>
    <configuration>
        <processors>
            <processor>org.checkerframework.checker.nullness.NullnessChecker</processor>
        </processors>
    </configuration>
</plugin>

5.2. Test-Time Gates

Use ArchUnit to enforce:

Example ArchUnit test:

@Test
void generated_packages_are_not_manually_modified() {
    JavaClasses classes = new ClassFileImporter().importPackages("com.example");
    ArchRule rule = noClasses()
        .that().resideInAPackage("..generated..")
        .should().beAnnotatedWith(NotGenerated.class);
    rule.check(classes);
}

5.3. CI/CD Integration

6. Phase 5: Recursive Refinement

6.1. Specification Change Workflow

  1. Modify structural specification (OpenAPI YAML, JSON Schema, annotations).
  2. Rebuild — triggers code regeneration.
  3. Compile — any conformance violation (e.g., missing method in implementation) becomes a compilation error.
  4. Fix — update tissue implementations to match the regenerated skeleton.
  5. Re-run validation gates — ensure all architectural rules still hold.

6.2. Handling Non-Generated Code

6.3. Rollback

7. Technology Stack Summary

Layer Recommended Alternative
Framework Quarkus (compile-time DI) Spring Boot with AOT enabled
Build Tool Gradle (incremental builds, task dependencies) Maven with incremental build plugin
Specification OpenAPI + JSON Schema + custom annotations
Code Generation OpenAPI Generator + jsonschema2pojo + annotation processors
Static Analysis Checker Framework + ArchUnit Error Prone + SpotBugs
Module System JPMS (Java 9+) Package conventions (if JPMS not feasible)

8. Constraints and Limitations

Constraint Mitigation
Reflection-heavy frameworks (Spring traditional) Use constructor injection; limit Deep Coding scope to contract layer
Bytecode manipulation tools (Lombok) Avoid; replace with explicit code or MapStruct (generated, visible sources)
Existing legacy codebases Apply Deep Coding only to new modules; incrementally extract structural specifications from legacy code
Cross-team coordination Enforce only interface-level contracts; allow internal implementation flexibility

9. Implementation Checklist