Skip to content

Add per-script record TTL for written relationships#50

Merged
ostafen merged 4 commits into
mainfrom
feat/record-ttl
Jun 30, 2026
Merged

Add per-script record TTL for written relationships#50
ostafen merged 4 commits into
mainfrom
feat/record-ttl

Conversation

@ostafen

@ostafen ostafen commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Description

Introduce an optional top-level recordTtl duration on scripts. When greater than zero, every relationship written by the script's WriteRelationships steps is given an expiration of recordTtl from the moment it is written (via Relationship.OptionalExpiresAt). The expiry is computed at write time so each relationship lives for the full TTL rather than expiring at a fixed prepare-time instant.

Set recordTtl: 10m on some-data.yaml.

Testing

References

Introduce an optional top-level `recordTtl` duration on scripts. When
greater than zero, every relationship written by the script's
WriteRelationships steps is given an expiration of `recordTtl` from the
moment it is written (via Relationship.OptionalExpiresAt). The expiry is
computed at write time so each relationship lives for the full TTL rather
than expiring at a fixed prepare-time instant.

Set recordTtl: 10m on some-data.yaml.
Comment thread internal/config/types.go
Comment thread README.md
Comment thread internal/thumperrunner/prepare.go
ostafen added 2 commits June 30, 2026 12:49
A variant of schema.yaml that declares `use expiration` and marks every
relation `with expiration`, requiring a TTL on all writes against it. The
script sets recordTtl: 10m, which the runner applies to every
WriteRelationships step (including the seed step via the migrate/RunOnce
path), so the seed fixtures are written with the same expiration.

Verified the rendered schema compiles with the SpiceDB schema compiler.
Add `use expiration` and declare every relation in both plain and
`with expiration` forms (e.g. `user | user with expiration`). This lets
the same relation accept writes with or without a TTL: existing non-TTL
writes still match the plain form, while scripts that set recordTtl
(e.g. some-data.yaml) match the `with expiration` form.

Removes the separate expirable-schema.yaml in favor of extending the
existing schema. Verified the rendered schema compiles with the SpiceDB
schema compiler.
vroldanbet
vroldanbet previously approved these changes Jun 30, 2026
Note that recordTtl is useful for sustained write-oriented load while
keeping datastore disk usage bounded -- expired relationships are
garbage-collected, so the store reaches a steady state instead of
growing unboundedly.
@ostafen ostafen merged commit c34d99c into main Jun 30, 2026
7 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants