Add per-script record TTL for written relationships#50
Merged
Conversation
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.
vroldanbet
reviewed
Jun 30, 2026
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
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.
vroldanbet
approved these changes
Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Introduce an optional top-level
recordTtlduration on scripts. When greater than zero, every relationship written by the script's WriteRelationships steps is given an expiration ofrecordTtlfrom 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