Skip to content

Time-Based Policies Documentation: (time field, Timestamp, CronSpan) - #752

Open
omkarshanbhag wants to merge 5 commits into
mainfrom
omkar/time-based-policies
Open

Time-Based Policies Documentation: (time field, Timestamp, CronSpan)#752
omkarshanbhag wants to merge 5 commits into
mainfrom
omkar/time-based-policies

Conversation

@omkarshanbhag

@omkarshanbhag omkarshanbhag commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR contains documentation for time based policies (introduced via a new top level field on policies called time)

Overall Summary of new functionality added:

  • New ### Time keyword subsection documenting time.now (type timestamp, single trusted server-time value per request).
  • New timestamp primitive type row (Timestamp('<rfc3339>'), UTC-only).
  • New comprehensive ## Time section covering:
    • who/what/when framing; time must eval to bool; evaluated against trusted server time; absent/empty = always active, false = policy skipped (not a deny).
    • time.now and Timestamp('<rfc3339>') (UTC only — Z; non-zero offsets rejected).
    • Time-bound (one-shot) policies: time.now >= Timestamp(start) && time.now < Timestamp(end) (start-incl, end-excl).
    • Active time spans (recurring) via CronSpan('<cron>', '<duration>', '<tz>') — fire + duration union model, strict 5-field cron subset (no */n, @macros, names, seconds), Go-style d/h/m duration ≤ 7 days, IANA tz / DST-aware.
    • Correct 9-to-5: CronSpan('0 9 * * 1-5', '8h', 'America/New_York'), with a callout warning against the hour-range (0 9-17 ...) form.
    • Overnight/midnight-crossing windows, composability (&&/||/!), and combining time with consensus + condition.

🤖 Generated with Claude Code

@mintlify

mintlify Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
turnkey-docs 🟢 Ready View Preview Aug 4, 2026, 3:47 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@omkarshanbhag omkarshanbhag changed the title Document time-based policies (time field, Timestamp, CronSpan) Time-Based Policies Documentation: (time field, Timestamp, CronSpan) Aug 4, 2026
@andrewkmin
andrewkmin requested a review from Copilot August 4, 2026 22:24

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.

Pull request overview

Adds documentation for the new top-level policy time field and its related language constructs so authors can gate policy evaluation by trusted server time, including one-shot timestamp windows and recurring cron-based spans.

Changes:

  • Added a new “Time-based policies” authoring guide covering time.now, Timestamp(...), and CronSpan(...) with examples.
  • Extended the policy language reference with timestamp, time.now, and function signatures for Timestamp / CronSpan.
  • Added a new time-based section to the access-control examples and linked the new page into the docs sidebar.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
features/policies/time-based-policies.mdx New authoring guide for the time policy field with one-shot and recurring window examples.
features/policies/language.mdx Adds time keywords/types/functions to the policy language reference and links to time docs.
features/policies/examples/access-control.mdx Adds practical time-based policy examples to the access-control examples page.
docs.json Registers the new time-based policies page in the documentation sidebar/navigation.
Suppressed comments (1)

features/policies/language.mdx:86

  • The timestamp type row points readers to the Time keyword section, but the UTC-only Timestamp(...) construction details live under the time function reference. After adding ## Time expressions, link there to avoid sending readers to an unrelated section.
| **timestamp** | Timestamp('2025-01-01T00:00:00Z')       | a point in time; construct with `Timestamp('<rfc3339>')`, UTC only (see [Time](#time)) |

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread features/policies/language.mdx
Comment thread features/policies/time-based-policies.mdx Outdated
Comment thread features/policies/examples/access-control.mdx Outdated
Comment thread features/policies/language.mdx
Comment thread features/policies/language.mdx
Comment thread features/policies/examples/access-control.mdx Outdated
Comment thread features/policies/time-based-policies.mdx Outdated
Comment thread features/policies/time-based-policies.mdx Outdated
Comment thread features/policies/time-based-policies.mdx Outdated
Comment thread features/policies/time-based-policies.mdx Outdated
Comment thread features/policies/time-based-policies.mdx Outdated

@andrewkmin andrewkmin 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.

Verified these points against tkhq/mono release v2026.8.0 and reproduced the boundary behavior with the real TimeEvaluator.

Comment thread features/policies/time-based-policies.mdx Outdated
Comment thread features/policies/time-based-policies.mdx
Comment thread features/policies/time-based-policies.mdx Outdated
Comment thread features/policies/time-based-policies.mdx Outdated

@grahamritter grahamritter 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.

looks good to me!!

`condition`, it is written in the policy language and must evaluate to a `bool`. When `time` is not
specified, the policy is always active. When the current time falls within the defined window, the
expression evaluates to `true` and the policy participates in evaluation as usual. When it falls
outside the window, the expression evaluates to `false` and the policy is skipped for that request.

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.

do we want to include the symptom of this? ie ..._INACTIVE?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will include in follow up


#### Grant a user temporary access for a fixed window (one-shot)

This policy allows the user to sign transactions only during January 2025 (UTC). The window is

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.

tiny nit: can use a more recent timestamp

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.

4 participants