Skip to content

Commit 77f668c

Browse files
committed
Merge pull request #98 from moderneinc/feature/update-prethink-context-no-ai
2 parents fd5ef77 + ed443de commit 77f668c

36 files changed

Lines changed: 5022 additions & 2 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dependency-reduced-pom.xml
1313
.project
1414
.vscode/
1515
.github/instructions/
16-
.moderne/
16+
.moderne/*
17+
!.moderne/context/
1718
!.moderne/moderne.yml
1819
!.moderne/context/

.moderne/context/api-contracts.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Api Contracts
2+
3+
## Endpoint contracts, DTO schemas, parameters, exception handlers, and fixture examples
4+
5+
Complete raw material for generating OpenAPI 3.0.3 specs and consumer/provider contract tests deterministically. Five CSVs: endpoint-request-response-schemas.csv (one row per endpoint*status, with request body FQN, response body FQN, collection flag), endpoint-parameters.csv (path/query/header/form params), dto-field-schemas.csv (per-field wire name, type, format, required flag, validation JSON, @Schema example), exception-handlers.csv (@ControllerAdvice + controller-local exception->status->body mappings), and field-example-values.csv (raw jsonPath->value rows mined from src/test/resources fixtures). Join endpoint tables via the endpointId column to service-endpoints.csv, and DTO tables via class FQN to data-assets.csv.
6+
7+
## Data Tables
8+
9+
### Endpoint request/response schemas
10+
11+
**File:** [`endpoint-schemas.csv`](endpoint-schemas.csv)
12+
13+
Per-endpoint request body and response body bindings, one row per (endpoint, status code) pair. Supports OpenAPI 3.0.3 generation by giving the LLM a full mapping from handler to body DTO FQNs.
14+
15+
| Column | Description |
16+
|--------|-------------|
17+
| Endpoint ID | Join key matching the 'Entity ID' column of service-endpoints.csv. |
18+
| Source path | The path to the source file containing the handler. |
19+
| Service class | The fully qualified name of the controller/resource class. |
20+
| Method name | The handler method name. |
21+
| HTTP method | The HTTP method (GET, POST, etc.). |
22+
| Path | The full request path including class-level prefix. |
23+
| Request body FQN | Fully qualified name of the request body DTO class, or null when the handler takes no body. |
24+
| Request body resolution | How the request body type was resolved: 'resolved' (FQN known), 'simple-name' (only the class simple name could be recovered), 'unresolved' (could not be determined), or 'none' (no request body). |
25+
| Request body required | Whether the request body is required (false only when @RequestBody(required=false)). |
26+
| Response status | HTTP status code for this response row (e.g. 200, 201, 400). |
27+
| Response body FQN | Fully qualified name of the response body DTO for this status, after unwrapping ResponseEntity/Mono/Optional/collection wrappers. |
28+
| Response body resolution | How the response body type was resolved: 'resolved' (FQN known), 'simple-name', 'unresolved', or 'none' (void return / no body). |
29+
| Response is collection | True when the response body is a collection type (List/Set/Page/Slice/array). |
30+
| Response source | Where this response row was derived: 'return-type', '@ResponseStatus', or '@ApiResponse'. |
31+
| Framework | The framework hosting the endpoint (Spring, JAX-RS, Micronaut). |
32+
33+
### Endpoint parameters
34+
35+
**File:** [`endpoint-parameters.csv`](endpoint-parameters.csv)
36+
37+
Per-parameter detail for REST endpoint handlers - path, query, header, form. Join to service-endpoints.csv via endpointId.
38+
39+
| Column | Description |
40+
|--------|-------------|
41+
| Endpoint ID | Join key matching the 'Entity ID' column of service-endpoints.csv. |
42+
| Parameter name | The wire-level parameter name (from @PathVariable(name=...), @RequestParam(name=...), etc.). |
43+
| Parameter kind | Where the parameter comes from: 'path', 'query', 'header', or 'form'. |
44+
| Type FQN | Fully qualified name of the parameter's Java type. |
45+
| Type resolution | How the parameter type was resolved: 'resolved' (FQN known), 'simple-name', or 'unresolved'. |
46+
| Format | OpenAPI 3.0.3 format (int32, int64, date-time, uuid, etc.) or null. |
47+
| Required | Whether the parameter is required. |
48+
| Default value | Default value if declared (e.g. @RequestParam(defaultValue = "0")), else null. |
49+
| Java parameter name | The original Java parameter name (may differ from wire name). |
50+
51+
### DTO field schemas
52+
53+
**File:** [`dto-field-schemas.csv`](dto-field-schemas.csv)
54+
55+
Per-field schema detail for request/response DTOs: wire name, type, required flag, OpenAPI format, validation constraints, and any @Schema(example=) example values.
56+
57+
| Column | Description |
58+
|--------|-------------|
59+
| Source path | The path to the source file containing the DTO class. |
60+
| Owner class FQN | Fully qualified name of the DTO class owning this field. Joins to data-assets.csv via 'Class name'. |
61+
| Field name | The Java field name. |
62+
| Serialized name | The JSON name on the wire, after applying @JsonProperty overrides and class-level @JsonNaming. |
63+
| Serialized name source | How the serialized name was derived: 'java-name' (no override), 'json-property' (@JsonProperty value), 'jackson-strategy' (recognized @JsonNaming applied), or 'unknown-strategy' (@JsonNaming present but strategy class isn't a known one - the Java field name is used as a best-effort fallback). |
64+
| Type FQN | Fully qualified name of the field's type (after unwrapping Optional/Collection wrappers). |
65+
| Type resolution | How confidently the type was resolved: 'resolved' (FQN known), 'simple-name' (only the class simple name could be recovered, may not uniquely identify the DTO), or 'unresolved' (the type could not be determined at all). |
66+
| Is collection | True when the declared type is a collection (List/Set/array/etc.) - the type FQN is then the element type. |
67+
| Is map | True when the declared type is a Map - the type FQN is then the value type. |
68+
| Is optional | True when the declared type is java.util.Optional. |
69+
| Format | OpenAPI 3.0.3 format (int32, int64, date-time, uuid, email, binary, ...) or null. |
70+
| Required | Whether the field is required. Set true for @NotNull/@NotBlank/@NotEmpty, primitives, and @JsonProperty(required=true). |
71+
| Validations JSON | JSON map of validation constraint simple name to argument map. Example: {"NotNull":{},"Size":{"min":1,"max":100}}. |
72+
| Example value | Example value from @Schema(example = "...") if declared on the field, else null. |
73+
74+
### Field example values
75+
76+
**File:** [`field-examples.csv`](field-examples.csv)
77+
78+
Raw (fixturePath, jsonPath, value, valueType) rows mined from JSON fixture files. Supply realistic example payloads for contract test generation. LLM correlates jsonPath to DTO fields at spec/contract generation time.
79+
80+
| Column | Description |
81+
|--------|-------------|
82+
| Fixture path | Relative path to the fixture file. |
83+
| JSON path | Dotted path to the leaf inside the fixture (e.g. 'user.address.street'). |
84+
| Value | The literal value at that path, rendered as a string. |
85+
| Value type | JSON type: 'string', 'number', 'boolean', 'null', 'array', or 'object'. |
86+

.moderne/context/architecture.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Architecture
2+
3+
## System Diagram
4+
5+
```mermaid
6+
flowchart LR
7+
subgraph wizard-registry["Wizard Registry Service"]
8+
wizard-import-resource["Wizard Import Resource"]
9+
wizard-report-resource["Wizard Report Resource"]
10+
wizard-resource["Wizard Resource"]
11+
end
12+
13+
wizard-registry-application-i-t-service["Wizard Registry Application I T Service"]
14+
15+
wizard-import-resource -->|HTTPS| wizard-registry-application-i-t-service
16+
```
17+
18+
## Components
19+
20+
### Services
21+
22+
- **WizardImportResource**: POST /api/wizards/import
23+
- **WizardReportResource**: GET /api/reports/{filename}
24+
- **WizardResource**: POST /api/wizards, GET /api/wizards/{id}, GET /api/wizards, +3 more
25+
26+
### External Services
27+
28+
- **Wizard Registry Application I T Service**: HTTPS service
29+
30+
## Reference
31+
32+
For the complete CALM (Common Architecture Language Model) schema, see [calm-architecture.json](calm-architecture.json).
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"nodes" : [ {
3+
"unique-id" : "create-wizard-request-data",
4+
"node-type" : "data-asset",
5+
"name" : "CreateWizardRequest",
6+
"description" : "DTO create wizard request with fields: firstName, lastName, dateOfBirth, house, patronus and 3 more"
7+
}, {
8+
"unique-id" : "update-wizard-request-data",
9+
"node-type" : "data-asset",
10+
"name" : "UpdateWizardRequest",
11+
"description" : "DTO update wizard request with fields: patronus, wandWood, wandCore, wandLengthInches"
12+
}, {
13+
"unique-id" : "wizard-import-resource",
14+
"node-type" : "service",
15+
"name" : "WizardImportResource",
16+
"description" : "REST API with endpoints: POST /api/wizards/import",
17+
"interfaces" : [ {
18+
"unique-id" : "wizard-import-resource-api",
19+
"port" : 8080
20+
} ]
21+
}, {
22+
"unique-id" : "wizard-registry",
23+
"node-type" : "system",
24+
"name" : "Wizard Registry Service",
25+
"description" : "Ministry of Magic — Registered Wizards Management Service"
26+
}, {
27+
"unique-id" : "wizard-registry-application-i-t-service",
28+
"node-type" : "service",
29+
"name" : "Wizard Registry Application I T Service",
30+
"description" : "External JAX-RS Client service"
31+
}, {
32+
"unique-id" : "wizard-report-resource",
33+
"node-type" : "service",
34+
"name" : "WizardReportResource",
35+
"description" : "REST API with endpoints: GET /api/reports/{filename}",
36+
"interfaces" : [ {
37+
"unique-id" : "wizard-report-resource-api",
38+
"port" : 8080
39+
} ]
40+
}, {
41+
"unique-id" : "wizard-resource",
42+
"node-type" : "service",
43+
"name" : "WizardResource",
44+
"description" : "REST API with endpoints: POST /api/wizards, GET /api/wizards/{id}, GET /api/wizards, PUT /api/wizards/{id}, PATCH /api/wizards/{id}/status and 1 more",
45+
"interfaces" : [ {
46+
"unique-id" : "wizard-resource-api",
47+
"port" : 8080
48+
} ]
49+
}, {
50+
"unique-id" : "wizard-response-data",
51+
"node-type" : "data-asset",
52+
"name" : "WizardResponse",
53+
"description" : "DTO wizard response with fields: id, firstName, lastName, dateOfBirth, house and 7 more"
54+
} ],
55+
"relationships" : [ {
56+
"unique-id" : "wizard-import-resource-uses-create-wizard-request-data",
57+
"relationship-type" : {
58+
"interacts" : {
59+
"actor" : "wizard-import-resource",
60+
"nodes" : [ "create-wizard-request-data" ]
61+
}
62+
}
63+
}, {
64+
"unique-id" : "wizard-registry-application-i-t-service-uses-create-wizard-request-data",
65+
"relationship-type" : {
66+
"interacts" : {
67+
"actor" : "wizard-registry-application-i-t-service",
68+
"nodes" : [ "create-wizard-request-data" ]
69+
}
70+
}
71+
}, {
72+
"unique-id" : "wizard-registry-application-i-t-service-uses-update-wizard-request-data",
73+
"relationship-type" : {
74+
"interacts" : {
75+
"actor" : "wizard-registry-application-i-t-service",
76+
"nodes" : [ "update-wizard-request-data" ]
77+
}
78+
}
79+
}, {
80+
"unique-id" : "wizard-registry-composed-of-services",
81+
"relationship-type" : {
82+
"composed-of" : {
83+
"container" : "wizard-registry",
84+
"nodes" : [ "wizard-import-resource", "wizard-report-resource", "wizard-resource" ]
85+
}
86+
}
87+
}, {
88+
"unique-id" : "wizard-resource-uses-wizard-response-data",
89+
"relationship-type" : {
90+
"interacts" : {
91+
"actor" : "wizard-resource",
92+
"nodes" : [ "wizard-response-data" ]
93+
}
94+
}
95+
} ],
96+
"$schema" : "https://calm.finos.org/draft/2025-03/meta/calm.json"
97+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Source path,Class name,Line count,Method count,Field count,WMC,LCOM4,TCC,CBO,Maintainability index
2+
src/main/java/org/ministry/magic/WizardRegistryApplication.java,org.ministry.magic.WizardRegistryApplication,79,5,0,5,5,0.0,30,57.747924551180596
3+
src/main/java/org/ministry/magic/WizardRegistryConfiguration.java,org.ministry.magic.WizardRegistryConfiguration,29,4,2,4,2,0.3333333333333333,0,76.75596862126785
4+
src/main/java/org/ministry/magic/api/CreateWizardRequest.java,org.ministry.magic.api.CreateWizardRequest,96,16,8,16,8,0.06666666666666667,0,78.54878756521178
5+
src/main/java/org/ministry/magic/api/UpdateWizardRequest.java,org.ministry.magic.api.UpdateWizardRequest,47,8,4,8,4,0.14285714285714285,0,78.74824091550704
6+
src/main/java/org/ministry/magic/api/WizardResponse.java,org.ministry.magic.api.WizardResponse,104,13,12,13,1,0.15384615384615385,1,69.4242484203022
7+
src/main/java/org/ministry/magic/bundle/LoggingConfigurationFactoryFactory.java,org.ministry.magic.bundle.LoggingConfigurationFactoryFactory,14,1,2,1,1,1.0,3,62.56336243557568
8+
src/main/java/org/ministry/magic/core/Wizard.java,org.ministry.magic.core.Wizard,119,26,12,26,12,0.04923076923076923,0,80.96069463581792
9+
src/main/java/org/ministry/magic/db/WizardDAO.java,org.ministry.magic.db.WizardDAO,143,11,2,14,1,1.0,14,59.5729005934848
10+
src/main/java/org/ministry/magic/db/WizardMapper.java,org.ministry.magic.db.WizardMapper,27,1,0,3,1,1.0,8,48.311182702241055
11+
src/main/java/org/ministry/magic/filter/AuditLogFilter.java,org.ministry.magic.filter.AuditLogFilter,35,3,1,3,1,1.0,6,63.727354204824756
12+
src/main/java/org/ministry/magic/health/DatabaseHealthCheck.java,org.ministry.magic.health.DatabaseHealthCheck,21,2,1,3,1,1.0,5,64.61781891317224
13+
src/main/java/org/ministry/magic/health/WizardRegistryHealthCheck.java,org.ministry.magic.health.WizardRegistryHealthCheck,18,2,1,3,1,1.0,2,67.96623080282816
14+
src/main/java/org/ministry/magic/managed/WizardRegistryManaged.java,org.ministry.magic.managed.WizardRegistryManaged,68,5,2,6,1,0.8,7,57.94733863335794
15+
src/main/java/org/ministry/magic/resources/WizardImportResource.java,org.ministry.magic.resources.WizardImportResource,59,3,1,11,1,0.3333333333333333,19,53.107856384354534
16+
src/main/java/org/ministry/magic/resources/WizardReportResource.java,org.ministry.magic.resources.WizardReportResource,21,1,1,3,1,1.0,5,54.351972671256306
17+
src/main/java/org/ministry/magic/resources/WizardResource.java,org.ministry.magic.resources.WizardResource,80,7,1,14,1,1.0,14,62.78971351367093
18+
src/main/java/org/ministry/magic/service/WizardAuthService.java,org.ministry.magic.service.WizardAuthService,35,4,3,6,3,0.0,6,66.76773689782739
19+
src/main/java/org/ministry/magic/service/WizardService.java,org.ministry.magic.service.WizardService,152,15,2,31,4,0.6285714285714286,14,63.403860569816004
20+
src/main/java/org/ministry/magic/servlet/MinistryStatusServlet.java,org.ministry.magic.servlet.MinistryStatusServlet,28,2,1,2,1,1.0,3,60.08141500837303
21+
src/test/java/org/ministry/magic/WizardRegistryApplicationIT.java,org.ministry.magic.WizardRegistryApplicationIT,187,13,2,13,1,0.5897435897435898,27,57.685314705389374
22+
src/test/java/org/ministry/magic/WizardRegistryConfigurationTest.java,org.ministry.magic.WizardRegistryConfigurationTest,36,3,2,3,3,0.0,12,61.071671783635
23+
src/test/java/org/ministry/magic/service/WizardServiceTest.java,org.ministry.magic.service.WizardServiceTest,126,10,2,10,1,0.8,19,59.35270131622701
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Class Quality Metrics
2+
3+
## Per-class cohesion, coupling, and complexity measurements
4+
5+
Per-class code quality metrics including Weighted Methods per Class (WMC), Lack of Cohesion (LCOM4), Tight Class Cohesion (TCC), Coupling Between Objects (CBO), and Maintainability Index. Use this to identify classes that should be split or refactored.
6+
7+
## Data Tables
8+
9+
### Class quality metrics
10+
11+
**File:** [`class-quality-metrics.csv`](class-quality-metrics.csv)
12+
13+
Per-class code quality metrics including WMC, LCOM4, TCC, CBO, and maintainability index.
14+
15+
| Column | Description |
16+
|--------|-------------|
17+
| Source path | The path to the source file containing the class. |
18+
| Class name | The fully qualified name of the class. |
19+
| Line count | Number of lines in the class. |
20+
| Method count | Number of methods defined in the class. |
21+
| Field count | Number of fields defined in the class. |
22+
| WMC | Weighted Methods per Class: sum of cyclomatic complexities of all methods. |
23+
| LCOM4 | Lack of Cohesion of Methods (Hitz-Montazeri): number of connected components in the method-field access graph. 1 = cohesive, >1 = should be split. |
24+
| TCC | Tight Class Cohesion: proportion of directly connected method pairs (sharing field access). 0.0-1.0, higher is more cohesive. |
25+
| CBO | Coupling Between Objects: number of distinct classes this class is coupled to. |
26+
| Maintainability index | Composite score (0-100) combining Halstead Volume, cyclomatic complexity, and LOC. Higher is more maintainable. |
27+

0 commit comments

Comments
 (0)