Skip to content

#478 (2): checkpoint time window and latest-first on flows (audit consumption pattern) - #489

Merged
lsulak merged 10 commits into
feature/478-better-reader-capabilityfrom
feature/adr02-audit-time-window
Oct 16, 2026
Merged

lsulak merged 10 commits into
feature/478-better-reader-capabilityfrom
feature/adr02-audit-time-window

Conversation

@lsulak

@lsulak lsulak commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Overview

Adding a server-side process start time window and latest-first on flows.

JFYI this is Stacked on #488. The base is feature/478-better-reader-capability; retarget to master once #488 is merged.

Release Notes

  • Server: checkpoints of a partitioning and of a flow can be limited to a process start time window with the from (inclusive) and to (exclusive) query parameters
  • Server: latest-first query parameter supported by the flow checkpoints endpoint
  • Reader: CheckpointFilter supports from, to and latestFirst
  • Database: new index on runs.checkpoints (fk_partitioning, process_start_time)

Related

Follow-up of #478 / #488

@lsulak
lsulak force-pushed the feature/adr02-audit-time-window branch 2 times, most recently from fce14fa to 8305398 Compare October 9, 2026 16:45
@lsulak
lsulak marked this pull request as ready for review October 9, 2026 16:53
Copilot AI balanced review requested due to automatic review settings October 9, 2026 16:53

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

The synchronous reader can overflow the JVM stack across many pages, and key database behavior lacks effective integration coverage.

6 open findings
What changed in this PR

Adds audit-oriented checkpoint time-window filtering, flow ordering, and all-page reader retrieval.

Changes:

  • Adds from, to, and flow latest-first query support across server layers.
  • Extends readers with filtering and getAllCheckpoints.
  • Adds a supporting database index, tests, and ADR 02.
File Description
server/​src/​test/​.../​CheckpointItemWithPartitioningFromDBUnitTests.scala Tests preservation of database order.
server/​src/​test/​.../​service/​FlowServiceUnitTests.scala Updates flow service mocks.
server/​src/​test/​.../​service/​CheckpointServiceUnitTests.scala Updates checkpoint service mocks.
server/​src/​test/​.../​repository/​FlowRepositoryUnitTests.scala Updates flow repository tests.
server/​src/​test/​.../​repository/​CheckpointRepositoryUnitTests.scala Updates checkpoint repository tests.
server/​src/​test/​.../​http/​GetPartitioningCheckpointsEndpointUnitTests.scala Tests partitioning time-window requests.
server/​src/​test/​.../​http/​GetFlowCheckpointsEndpointUnitTests.scala Tests flow windows and ordering.
server/​src/​test/​.../​controller/​FlowControllerUnitTests.scala Updates flow controller calls.
server/​src/​test/​.../​controller/​CheckpointControllerUnitTests.scala Updates checkpoint controller mocks.
server/​src/​test/​.../​runs/​functions/​GetPartitioningCheckpointsIntegrationTests.scala Adds partitioning window binding coverage.
server/​src/​test/​.../​flows/​functions/​GetFlowCheckpointsIntegrationTests.scala Adds flow filter binding coverage.
server/​src/​main/​.../​CheckpointItemWithPartitioningFromDB.scala Preserves database checkpoint ordering.
server/​src/​main/​.../​service/​FlowServiceImpl.scala Forwards flow filters.
server/​src/​main/​.../​service/​FlowService.scala Extends flow service API.
server/​src/​main/​.../​service/​CheckpointServiceImpl.scala Forwards partitioning windows.
server/​src/​main/​.../​service/​CheckpointService.scala Extends checkpoint service API.
server/​src/​main/​.../​repository/​FlowRepositoryImpl.scala Binds flow query arguments.
server/​src/​main/​.../​repository/​FlowRepository.scala Extends flow repository API.
server/​src/​main/​.../​repository/​CheckpointRepositoryImpl.scala Binds partitioning windows.
server/​src/​main/​.../​repository/​CheckpointRepository.scala Extends checkpoint repository API.
server/​src/​main/​.../​http/​Endpoints.scala Defines and validates query parameters.
server/​src/​main/​.../​controller/​FlowControllerImpl.scala Forwards flow endpoint filters.
server/​src/​main/​.../​controller/​FlowController.scala Extends flow controller API.
server/​src/​main/​.../​controller/​CheckpointControllerImpl.scala Forwards partitioning windows.
server/​src/​main/​.../​controller/​CheckpointController.scala Extends checkpoint controller API.
server/​src/​main/​.../​runs/​functions/​GetPartitioningCheckpoints.scala Binds database window arguments.
server/​src/​main/​.../​flows/​functions/​GetFlowCheckpoints.scala Binds flow ordering and windows.
reader/​src/​test/​.../​requests/​CheckpointFilterUnitTests.scala Tests filter serialization.
reader/​src/​test/​.../​PartitioningReaderUnitTests.scala Tests partitioning paging and filters.
reader/​src/​test/​.../​FlowReaderUnitTests.scala Tests flow paging and filters.
reader/​src/​main/​.../​requests/​QueryParamNames.scala Adds new query parameter names.
reader/​src/​main/​.../​requests/​CheckpointFilter.scala Adds time and ordering filters.
reader/​src/​main/​.../​PartitioningReader.scala Adds all-page checkpoint retrieval.
reader/​src/​main/​.../​FlowReader.scala Adds all-page flow retrieval.
reader/​src/​main/​.../​core/​Reader.scala Implements page accumulation.
database/​src/​main/​postgres/​runs/​V0.8.0.4__checkpoints_partitioning_start_time_index.ddl Adds the supporting composite index.
adrs/​02-consumption-pattern-for-audits.md Documents the audit consumption design.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@lsulak
lsulak force-pushed the feature/adr02-audit-time-window branch from 8305398 to 248695b Compare October 9, 2026 17:12
@lsulak
lsulak requested a balanced review from Copilot October 9, 2026 18:41

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.

@lsulak
lsulak force-pushed the feature/adr02-audit-time-window branch from 2a8052d to 1e9fbf9 Compare October 9, 2026 18:48
lsulak and others added 2 commits October 9, 2026 20:49
…and latest-first on flows

Builds on the #478 reader capability work and exposes what ADR 02 section 4 needs for audits:

- server: optional `from` / `to` (half-open window on process_start_time, from < to validated) on
  GET /partitionings/{id}/checkpoints and GET /flows/{id}/checkpoints, and `latest-first` on the
  flows endpoint; wired through controllers, services, repositories and DB function wrappers
- server: flow checkpoints keep the DB order instead of re-sorting by start time, so latest-first=false works
- reader: CheckpointFilter.from / to / latestFirst, getAllCheckpoints on FlowReader and PartitioningReader
  (Reader.queryAllPages), new query parameter names
- db: V0.8.0.4 composite index runs.checkpoints (fk_partitioning, process_start_time) for the time window
- ADR 02 - consumption pattern for audits

The DB function signatures (i_from_time / i_to_time) already landed with #478, so no function is re-created here.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
queryAllPages recursed through flatMap, which for strict effects (e.g.
Identity) runs the continuation right away, adding stack frames per page.
The continuation now hands the collected records over to a tail-recursive
loop when it runs synchronously, and recurses within the effect otherwise
(asynchronous or lazy effects), the hand-over being atomic.

ADR 02: a flow checkpoints page item is one checkpoint with its
measurements nested (processStartTime, measurements, partitioning), and
parent -> child edges cannot be reconstructed today (Bet 3).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lsulak
lsulak force-pushed the feature/adr02-audit-time-window branch from 1e9fbf9 to 03ac8f3 Compare October 9, 2026 18:50
@lsulak lsulak self-assigned this Oct 13, 2026
@lsulak lsulak changed the title ADR 02: checkpoint time window and latest-first on flows (audit consumption pattern) checkpoint time window and latest-first on flows (audit consumption pattern) Oct 15, 2026
@lsulak lsulak changed the title checkpoint time window and latest-first on flows (audit consumption pattern) #478 (2): checkpoint time window and latest-first on flows (audit consumption pattern) Oct 15, 2026
Move LIMIT/OFFSET inside the counted subquery so nonzero offsets
cannot discard the aggregate row and return NULL for has_more.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

The concurrent index migration and cross-layer query changes require integration validation and human sign-off.

1 open finding

🧠 Review effort: Balanced

Comment thread README.md Resolved
Clarify requirements for Reader features and server compatibility.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@salamonpavel salamonpavel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM (read the code)

@lsulak
lsulak merged commit ab4383b into feature/478-better-reader-capability Oct 16, 2026
3 checks passed
@lsulak
lsulak deleted the feature/adr02-audit-time-window branch October 16, 2026 13:44
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.

3 participants