Skip to content

Keep the time shape of a column placed after another - #44

Merged
jarichb merged 1 commit into
mainfrom
claude/time-shape-after-dependency-8df1db
Oct 6, 2026
Merged

jarichb merged 1 commit into
mainfrom
claude/time-shape-after-dependency-8df1db

Conversation

@jarichb

@jarichb jarichb commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Problem

A date/timestamp column with a dependency (an explicit after, or a created/updated/closed name pair) lost its time shape: order_row_times replaced its drawn value with latest_required + expovariate(mean 3 days), so business_hours on the column (or --business-hours) had no effect. A gap past the window was clamped to as-of midnight, piling rows onto one timestamp.

Repro (5,000 rows, seed 1, as-of 2026-10-01; scheduled_for has after: booked_at + business_hours: true):

before after
scheduled_for in weekday 08:00–17:59 28.9% (uniform) 71.8% (shaped_alone: 73.2%)
with --business-hours ~29% 72.7%
rows at exactly 2026-10-01 00:00:00 57 0
rows before booked_at 0 0
median gap ~2 days ~2 days

Fix

  • New place_after in generate/timeline.py: the gap still decides roughly when. With business hours (the column's own hint or the run's), weekends are kept 3 in 10 and a timestamp's hour is drawn from HOUR_WEIGHTS on the gap's day. A draw past the window is drawn again; after 20 tries the value is placed evenly between the column it follows and the window end.
  • order_row_times takes the run's time_profile. when columns filled on day 0 (_moment, settle) use the same helper.
  • A dependent column still takes growth and seasonality from the column it follows.

Determinism

The README's promise is now per version: same model, seed, --as-of and options give the same bytes on any machine and any day with the same model2data version. A release that changes what a seed produces says so in the changelog. tests/test_determinism.py still fails on any unintended byte change; its docstring and message say when re-recording is allowed.

Only one recorded case changed (skew: saas_platform with --skew 0.8), because the cases run at 40 rows. Real models of a few hundred rows or more with a timestamp chain will change, and the CHANGELOG says so.

Tests

  • New tests in tests/test_timeline.py: business hours kept under after (column hint and run-level), no pile-up at as-of midnight, place_after bounds.
  • Full suite: 1,841 passed. ruff clean; ty diagnostics unchanged at 34.

🤖 Generated with Claude Code

A column with an `after` (or a created/updated/closed name pair) was set
to what it follows plus a random gap, discarding the draw its
business_hours had shaped, and a gap past --as-of was clamped to as-of
midnight. The gap now decides roughly when and business_hours the weekday
and hour; a gap past the window is drawn again. `when` columns filled on
day 0 are placed the same way.

The README's determinism promise is now per version: a release may change
what a seed produces, and the changelog says so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@codecov

codecov Bot commented Oct 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@jarichb
jarichb merged commit 8848269 into main Oct 6, 2026
15 of 21 checks passed
@jarichb jarichb mentioned this pull request Oct 6, 2026
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.

1 participant