Skip to content

Fix index_timestamp returning window start instead of end for backward windows (start: end - Xh)#197

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-index-timestamp-issue
Draft

Fix index_timestamp returning window start instead of end for backward windows (start: end - Xh)#197
Copilot wants to merge 2 commits intomainfrom
copilot/fix-index-timestamp-issue

Conversation

Copy link

Copilot AI commented Feb 20, 2026

When a window is defined with start: end - Xh, end: trigger and index_timestamp: end, ACES incorrectly returned trigger - Xh (the window start) instead of trigger (the window end).

Root Cause

aggregate_temporal_window with a negative window_size places the anchor time in timestamp_at_start and the earlier boundary in timestamp_at_end — chronologically reversed relative to the field names. The index_timestamp extraction in query.py always accessed timestamp_at_{index_timestamp} without accounting for this.

This specifically affects windows where:

  • root_node == "end" (i.e., start references end)
  • start_endpoint_expr is a TemporalWindowBounds with window_size < 0

Changes

  • src/aces/query.py: When extracting index_timestamp, detect the reversed-timestamp case (negative TemporalWindowBounds on start_endpoint_expr) and flip the field lookup accordingly. Imports TemporalWindowBounds and timedelta to support the check.
# start: end - 24h, end: trigger, index_timestamp: end
# Before fix → index_timestamp = trigger - 24h  ✗
# After fix  → index_timestamp = trigger         ✓
  • Adds doctests for both index_timestamp: end and index_timestamp: start on a backward window to prevent regression.
Original prompt

This section details on the original issue you should resolve

<issue_title>Index timestamp being set as start of window when defined as end in config</issue_title>
<issue_description>With the following config, ACES yielded prediction_times corresponding to the start of the input window instead of the end as specified by the index_timestamp argument. Here is my conversation with codex about it -- it's suggestion for redefining the input window boundaries did indeed yield prediction times at the end of the input window. Below is the input window config which lead to the bug. Will have to investigate further in the future how to fix this in ACES.

trigger: cxr

windows:
   input:
    start: end - 24h
    end: trigger
    index_timestamp: end
    start_inclusive: True
    end_inclusive: True
    index_timestamp: end
    has:
      _ANY_EVENT: (5, None)
  target:
    start: input.end
    end: start + 1h
    start_inclusive: False
    end_inclusive: True
    label: pneumonia

Here is the suggested refactor of the input window which yielded correct prediction_times at the end of the window:

windows:
  input:
    start: trigger - 24h
    end: start + 24h
    start_inclusive: True
    end_inclusive: True
    index_timestamp: end
    has:
      _ANY_EVENT: (5, None)
  target:
    start: input.end
    end: start + 1h
    start_inclusive: False
    end_inclusive: True
    label: pneumonia
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…ard window (start: end - Xh)

Co-authored-by: justin13601 <52216145+justin13601@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix index timestamp issue in ACES configuration Fix index_timestamp returning window start instead of end for backward windows (start: end - Xh) Feb 20, 2026
Copilot AI requested a review from justin13601 February 20, 2026 23:38
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.

Index timestamp being set as start of window when defined as end in config

2 participants