Skip to content

fix(hr): compute tenure_years / time_off.days via daysBetween (#3306)#94

Draft
os-zhuang wants to merge 1 commit into
mainfrom
claude/hr-formula-daysBetween-3306
Draft

fix(hr): compute tenure_years / time_off.days via daysBetween (#3306)#94
os-zhuang wants to merge 1 commit into
mainfrom
claude/hr-formula-daysBetween-3306

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Refs objectstack-ai/objectstack#3306. Draft — blocked on framework #3348 publishing.

The last two shipped hr formula fields that silently evaluate to null on the pinned runtime — the date-math ones explicitly left for the framework fix (siblings fixed in #92/#93):

Field Before After
hr_time_off_request.days (end_date - start_date) + 1 daysBetween(start_date, end_date) + 1
hr_employee.tenure_years floor((today() - hire_date) / 365) daysBetween(hire_date, today()) / 365

Both Timestamp − Timestamp (→ a Duration, no Duration + int overload) and floor (unregistered) faulted → null. The rewrites use the catalog date helpers + the null-guard idiom. Verified against the fixed engine: days = 5 (inclusive), tenure_years = 6.

⚠️ Blocked — merge checklist

These rewrites need the null-guard fix (cond ? <int> : null, framework #3348) that lands in @objectstack 16.x. On the current pin (15.1.1) they still null (and CI's objectstack build may reject the ternary). So:

  • framework #3348 merges and @objectstack/* 16.x publishes
  • bump @objectstack/* deps in packages/hr (and the workspace) to that release
  • confirm CI build (runs validateStackExpressions) is green

Once bumped, the existing objectstack build step is the regression gate the issue asked for — no new CI step needed. Framework #3348 makes it catch the date − date silent hole (os build now exits 1 on date arithmetic in a formula), so a broken date formula can never ship green again.

🤖 Generated with Claude Code

The last two shipped formula fields that silently evaluated to null on the
pinned runtime — the date-math ones left for the framework fix in #92/#93:

- hr_time_off_request.days: `(end_date - start_date) + 1` (Timestamp−Timestamp
  → Duration, no `Duration + int`) → `daysBetween(start_date, end_date) + 1`.
- hr_employee.tenure_years: `floor((today() - hire_date) / 365)` (unregistered
  `floor` + Timestamp−Timestamp) → `daysBetween(hire_date, today()) / 365`
  (integer division floors for a non-negative tenure).

Both use the catalog date helpers and the null-guard idiom. Verified against
the fixed engine: days=5 (inclusive), tenure=6.

BLOCKED on framework#3348 publishing: these rewrites need the null-guard fix
(`cond ? <int> : null`) that lands in @objectstack 16.x — on 15.1.1 they still
null. Unblock: bump @objectstack/* deps to the release with #3348, then CI's
`objectstack build` step (which runs validateStackExpressions) goes green and
becomes the standing regression gate.

Refs #3306.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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