Repository navigation
feat: report unique resources - #2779
Conversation
mswiderski
left a comment
There was a problem hiding this comment.
nice work, especially around the Resolver
7668b6b to
41b2343
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The immutable image list breaks descriptor generation, and valid input structures can produce missing or incorrect resource paths.
5 open issues
Keep descriptor image list mutable during image collection · New Escape non-identifier JSON property names in generated paths · New Preserve generic type arguments during model traversal · New Traverse wildcard upper bounds when resolving resource IDs · New Resolve Jackson annotations from complete property accessors · New
What changed in this PR
This PR adds unique-resource metadata to service model descriptors. It derives resource types and JSONPath expressions from model-input annotations for downstream resource reporting.
Changes:
- Adds
@UniqueResourceIdand descriptor storage for resource types and paths. - Integrates build-time path discovery into Quarkus descriptor generation.
- Adds resolver tests and an end-to-end descriptor test.
| File | Description |
|---|---|
service/definition/src/main/java/ai/timefold/solver/service/definition/api/ModelDescriptor.java |
Stores and copies resource metadata; changes collection defaults. |
service/definition/src/main/java/ai/timefold/solver/service/definition/api/usage/UniqueResourceId.java |
Defines the resource-ID annotation. |
service/definition/src/main/java/ai/timefold/solver/service/definition/internal/descriptor/usage/UniqueResource.java |
Pairs a resource type with its JSONPath. |
service/quarkus/deployment/src/main/java/ai/timefold/solver/service/quarkus/deployment/TimefoldModelDescriptorProcessor.java |
Adds resource metadata during descriptor generation. |
service/quarkus/deployment/src/main/java/ai/timefold/solver/service/quarkus/deployment/descriptor/ResourceIdPathResolver.java |
Traverses indexed input fields to derive resource paths. |
service/quarkus/deployment/src/test/java/ai/timefold/solver/service/quarkus/deployment/ModelDescriptorUniqueResourcesTest.java |
Checks generated descriptor resource entries. |
service/quarkus/deployment/src/test/java/ai/timefold/solver/service/quarkus/deployment/descriptor/UniqueResourceIdPathResolverTest.java |
Tests traversal, field annotations, and blank resource types. |
service/quarkus/deployment/src/test/java/ai/timefold/solver/service/quarkus/deployment/testdata/uniqueresource/TestdataVisit.java |
Provides an annotated visit ID. |
service/quarkus/deployment/src/test/java/ai/timefold/solver/service/quarkus/deployment/testdata/uniqueresource/TestdataVehicle.java |
Provides an annotated vehicle ID and nested visits. |
service/quarkus/deployment/src/test/java/ai/timefold/solver/service/quarkus/deployment/testdata/uniqueresource/TestdataSolution.java |
Provides the test model input structure. |
service/quarkus/deployment/src/test/java/ai/timefold/solver/service/quarkus/deployment/testdata/uniqueresource/TestdataRest.java |
Supplies the test model REST interface. |
service/quarkus/deployment/src/test/java/ai/timefold/solver/service/quarkus/deployment/testdata/uniqueresource/TestdataConstraintProvider.java |
Supplies a constraint for the test deployment. |
Review effort: Balanced
|
This pull request, as it stands, would leave the Solver documentation stale in the places below. An automated check found them and can be wrong.
[#_unique_resource_ids]
== Unique resource IDs
Annotate each resource identifier that must be unique within its resource type with `@UniqueResourceId` from `ai.timefold.solver.service.definition.preview.api.usage`.
[source,java,options="nowrap"]
----
@UniqueResourceId(type = "vehicle")
private String id;
----
The generated model descriptor exposes these resources through `uniqueResources`.
Each entry contains `resourceType` and `resourceIdJsonPath`, such as `vehicle` and `$.vehicles[*].id`.The fix goes into this
|
41b2343 to
060e71e
Compare
060e71e to
c64bb63
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Resource ID discovery can silently miss IDs in application-defined containers due to the class loader choice and in renamed fields because special property names are not correctly quoted and escaped.
2 open issues
1 resolved since last review
Review effort: Balanced
c64bb63 to
9807fbd
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Resource ID resolution can miss IDs or select unrelated values because special JSON property names use unsafe dot notation and application-defined collections are misclassified during Quarkus augmentation.
2 open issues
1 resolved since last review
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed to evaluate an edge case where concrete collection subtypes are inspected as containers, causing annotated element IDs to be omitted from descriptors.
1 resolved since last review
Review effort: Balanced
|
The downstream failure is addressed by #2798. |
814dc13 to
a331792
Compare


Fixes https://github.com/TimefoldAI/timefold-solver-enterprise/issues/930.
An alternative to #2769.