Add time travel capability using @ syntax in query URIs#1088
Conversation
427d09b to
58134a7
Compare
Resolved conflicts: - transact.cljc: Used ledger-alias consistently with debug logging from main - nameservice/storage.cljc: Fixed local-filename to take single argument (ledger-alias already includes branch) - connection.cljc: Updated docstring to mention ledger/branch
Ensures storage paths don't include branch suffix (e.g., 'destined-for-drop' instead of 'destined-for-drop:main') to maintain backward compatibility with tests and existing storage structure
9738a09 to
d7891e7
Compare
dpetran
left a comment
There was a problem hiding this comment.
Could you expound a bit on why we need the new syntax instead of query params? I think we can still support sha t and iso via that syntax, and having two ways to do it makes users have to decide which to use, and I'm not clear that there's a technical benefit of one over the other.
I think the difference is probably bigger than it is, but query params are for queries... this is a concrete resource (a db), so using query parameters I think breaks the semantics of URLs and resources. With this change we can represent a db resource as a full IRI/URL when combined with a host... not that query params couldn't be used as well but I don't think that is the right way of doing it. I think we can use query params for lots of things... like some of the items we currently support in 'opts' could be great candidates and I think that would be a correct use of query params. But at least I don't believe it was a good use to identify a concrete resource. |
…rn values and usage
d7891e7 to
42af763
Compare
6b242ac to
c50e384
Compare
| (str/includes? ledger-alias "@")) | ||
| (subs ledger-alias (inc (str/last-index-of ledger-alias "@")))) | ||
| "main") | ||
| ledger-alias (get data "alias") ;; Already includes @branch |
There was a problem hiding this comment.
another nitpick, but i think this comment should end with :branch instead of @branch.
Time travel queries via @ syntax in FQL graph URIs
Sits on top of: #1087 (branch name consistency)
Prerequisite of: #1096 (branch implementation)
Prerequisite of: #1095 (brach merge, rebase, reset)
Summary
Adds time travel to database queries using
@infromandfrom-namedto select historical states by transaction number, ISO-8601 timestamp, or commit SHA.Motivation
@semantics and upcoming branching support.Supported formats
@t:<tx>: transaction numbermy-ledger@t:42@iso:<timestamp>: ISO-8601 wall-clock timemy-ledger@iso:2025-07-01T00:00:00Z@sha:<commit>: commit SHA (base32 SHA-256 with leadingb)my-ledger@sha:bb6rql...(full),my-ledger@sha:bb6rql(prefix, ≥6 chars)Works with branches:
my-ledger:main@t:42Works with federated datasets:
from-named: ["g1@t:10", "g2"]Behavior
b(51–52 chars).:db/ambiguous-commit-sha.:db/invalid-commit-sha.@t:,@iso:,@sha:) return 400:db/invalid-time-travel.tmust be ISO-8601 wall-clock time.@on each alias.Implementation details
sha->tfor SHA-based lookups.extract-query-string-tinfluree.db.query.apiparses@syntax onfrom/from-named.fluree:commit:sha256:bprefix form (when present) or a value starting withb.:and@to avoid ambiguity and reserve@for time travel.Testing
@t,@iso,@sha.Backward compatibility
@-based time travel is additive; legacy?t=remains supported but is superseded when@is present.