Skip to content

feat: report unique resource IDs - #2769

Open
rsynek wants to merge 1 commit into
TimefoldAI:mainfrom
rsynek:feat/unique-entity-metering
Open

rsynek wants to merge 1 commit into
TimefoldAI:mainfrom
rsynek:feat/unique-entity-metering

Conversation

@rsynek

@rsynek rsynek commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes https://github.com/TimefoldAI/timefold-solver-enterprise/issues/930.

The PR covers resource reporting for standard operations.

  • POST compute or solve
  • POST score analysis

Also model-specific operations are covered by exposing the UniqueResourceReporter bean to send the data.

Related:
https://github.com/TimefoldAI/timefold-solver-enterprise/pull/948

@rsynek
rsynek requested review from a team, cristianonicolai and mswiderski and a balanced review from Copilot October 21, 2026 11:24
@rsynek
rsynek requested a review from triceo as a code owner October 21, 2026 11:24
@rsynek
rsynek force-pushed the feat/unique-entity-metering branch from 93c9a7d to 3c82c2e Compare October 21, 2026 11:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Reporter exceptions can mark valid datasets as failed and prevent normal completion.

1 open issue
What changed in this PR

Adds unique resource ID reporting to the service layer for usage metering.

Changes:

  • Adds resource collection and reporting APIs.
  • Reports resources after worker output computation.
  • Adds event definitions and tests for resource collection behavior.
File Description
service/​worker/​src/​main/​java/​ai/​timefold/​solver/​service/​worker/​impl/​SolverWorker.java Reports resources after computation.
service/​definition/​src/​test/​java/​ai/​timefold/​solver/​service/​definition/​api/​usage/​UniqueResourcesTest.java Tests deduplication, immutability, builders and JSON.
service/​definition/​src/​main/​java/​ai/​timefold/​solver/​service/​definition/​internal/​events/​UniqueResourceReportEvent.java Adds the resource reporting event.
service/​definition/​src/​main/​java/​ai/​timefold/​solver/​service/​definition/​internal/​events/​SolverChannels.java Defines the reporting channel.
service/​definition/​src/​main/​java/​ai/​timefold/​solver/​service/​definition/​internal/​events/​AbstractEvent.java Permits the new event type.
service/​definition/​src/​main/​java/​ai/​timefold/​solver/​service/​definition/​api/​usage/​UniqueResources.java Stores immutable, deduplicated resource IDs.
service/​definition/​src/​main/​java/​ai/​timefold/​solver/​service/​definition/​api/​usage/​UniqueResourceReporter.java Defines reporting methods.
service/​definition/​src/​main/​java/​ai/​timefold/​solver/​service/​definition/​api/​usage/​UniqueResourceAware.java Lets models expose their resources.

Review effort: Balanced

}

if (uniqueResources != null) {
uniqueResourceReporter.reportUniqueResources(OperationId.SCHEDULE, datasetId, uniqueResources);
Copilot AI balanced review requested due to automatic review settings October 21, 2026 11:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Worker reporting and its fallback paths need regression tests before approval.

2 open issues

Review effort: Balanced

extractOutputMetrics(solverModel));

// We report the unique resources once we compute the outputs of the valid dataset.
reportUniqueResources(id, solverModel);
@timefold-automations

Copy link
Copy Markdown
Contributor

This pull request, as it stands, would leave the Solver documentation stale in the place below. An automated check found this and can be wrong.

  1. Code change: timefold-solver, service/definition/src/main/java/ai/timefold/solver/service/definition/api/usage/UniqueResources.java:13 (and the added UniqueResourceAware.java:6 and UniqueResourceReporter.java:6) — added public usage-metering API types, including UniqueResources.from, UniqueResources.builder, UniqueResourceAware#getUniqueResources, and UniqueResourceReporter#reportUniqueResources.
    Docs location: no mention found under docs/src/modules/ROOT/pages/.
    Confidence: high.
    Suggested edit: Add a short service-specific section, for example to pages/running-timefold-solver/service/overview.adoc:

    [#uniqueResourceReporting]
    == Reporting unique resources
    
    A service model can implement `UniqueResourceAware` to identify the unique resources used by an operation:
    
    [source,java]
    ----
    public class EmployeeSchedule implements UniqueResourceAware {
        @Override
        public UniqueResources getUniqueResources() {
            return UniqueResources.from("employee", employeeIds);
        }
    }
    ----
    
    Use the injected `UniqueResourceReporter` to report resources for model-specific operations. Use `UniqueResources.builder()` when a model has multiple resource types.

The documentation fix belongs in this pull request. A new commit on the branch updates this comment, and drift that is still there when the group merges gets a docs pull request against main.

Generated by Solver Docs Drift Review · copilot · gpt56 · 11.3 AIC · ⌖ 2.99 AIC · ⊞ 25.2K · ◷

This branch was successfully deployed

1 active deployment
internal — 3c82c2ec Deployed Oct 21, 2026 by rsynek via approval_required #1086
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants