Time Travel#
Concourse automatically tracks every change to every piece of data, creating a complete version history. This enables you to query and read data as it existed at any point in the past.
Temporal Queries vs Temporal Reads#
There are two distinct ways to access historical data:
Temporal Queries#
A temporal query evaluates its selection criteria based on the version of data at a previous timestamp. The query returns the records that would have matched the criteria at that point in time.
1 2 3 4 5 | |
Temporal Reads#
A temporal read retrieves the version of the data that existed at a previous timestamp. The read returns what the data looked like at that point in time.
1 2 3 4 | |
Combining Both#
You can combine temporal queries and temporal reads in a single operation:
1 2 3 4 5 6 | |
Timestamps#
Most Concourse methods accept an optional Timestamp parameter
for time travel.
Creating Timestamps#
1 2 3 4 5 6 | |
Natural Language Timestamps#
Concourse supports natural language time expressions, which are especially convenient in the CaSH shell:
1 2 3 4 5 6 | |
1 2 3 | |
Per-Key Timestamps#
The trailing at / as of clause shown above pins every read
in an operation to a single timestamp. For mixed-time questions
— “give me a customer’s current tier alongside their
lifetime spend as of last quarter” — you can attach a
per-key timestamp directly to the key with bracket annotations.
Bracket Syntax#
Append [<timestamp>] to any key to pin that key’s read to a
specific moment:
1 2 3 | |
Bracket annotations work wherever a read or query accepts a key:
selection keys, leaf keys in where conditions, navigation stops,
and order by keys. The bracket value can be a numeric microsecond
timestamp or any natural-language expression that
Timestamp.fromString accepts:
1 2 3 4 | |
Precedence#
When both a bracket and a trailing at/as of are present, the
bracket always wins for the key it sits on. Unbracketed keys
default to the trailing at clause when one is supplied, or to the
present moment otherwise:
1 2 3 4 5 | |
This rule applies uniformly to selection keys, navigation stops, and
the leaf keys in where conditions.
Order keys behave differently across commands
order by keys have a known wrinkle today that may be reconciled
in a future release. On find and other condition-only commands,
an unbracketed sort key reads at the present moment regardless of
the trailing at. On select, get, and other commands that
materialize a result set, an unbracketed sort key inherits the
trailing at so the sort stays consistent with the materialized
values. To pin a sort read explicitly and uniformly across both
families, bracket the key directly
(order by name["last week"]) or pin the order clause
(order by name asc at "last week").
Mixed-Time Conditions#
Conditions in a where clause evaluate each leaf at its own pinned
moment, so a single query can match records by their state at
multiple points in time:
1 2 3 4 | |
Per-Stop Brackets on Navigation#
Each stop of a navigation path can carry its own bracket independently. The same precedence applies per stop:
1 2 3 4 5 6 7 8 9 | |
Where Brackets Are Rejected#
Bracket annotations are rejected on commands where a per-key point-in-time would be meaningless:
- Writes —
add,set,remove,clear,link,unlink,reconcile,verify_and_swap,verify_or_set,find_or_add,revert. - Range-history reads —
audit,chronicle,diff. These carry their time window in thefrom/toparameters, not on the key.
The server rejects bracket-bearing keys on these commands at parse time with an error that names both the command and the offending key.
Java API#
Brackets in CCL strings round-trip through the typed Java API unchanged:
1 2 3 4 | |
The Order builder exposes per-key timestamps programmatically:
1 2 3 | |
Audit#
The audit method returns a complete revision history for a
record or a specific field. Each entry maps a commit timestamp to
a list of human-readable descriptions of the changes made.
Audit an Entire Record#
1 2 3 | |
1 2 | |
Audit a Specific Key#
1 2 3 | |
1 2 | |
Audit a Time Range#
Restrict the audit to changes within a specific time window (start inclusive, end exclusive):
1 2 3 4 5 6 7 | |
Chronicle#
The chronicle method returns a time series of the values stored
for a key in a record after every change. Unlike audit, which
describes what changed, chronicle shows the state of the
field after each change.
1 2 3 4 5 | |
1 2 | |
Chronicle a Time Range#
1 2 3 4 | |
Diff#
The diff method returns the net changes between two points
in time. Unlike audit, which records every individual change,
diff computes the minimal set of additions and removals needed
to transition from the start state to the end state.
Diff a Field#
1 2 3 4 5 | |
Diff an Entire Record#
1 2 3 4 | |
Diff a Key Across All Records#
1 2 3 4 5 | |
Like browse, a diff of a key is a read across a key, so it treats
effectively equal values of different types as one representative
value. For example, if record 1 held 18 the whole time and record
2 gained 18.0, the diff shows one representative value that was
added to record 2 only.
Diff Between Two Timestamps#
All diff variants accept a start and optional end timestamp. If
only a start is provided, the diff covers from the start to the
present.
1 2 3 4 5 6 7 | |
Revert#
The revert method atomically restores a key in a record to its
state at a previous timestamp. Concourse computes the necessary
adds and removes to recreate the historical state, then applies
them as new revisions. The original history is preserved.
1 2 3 | |
1 2 | |
Revert Multiple Keys#
1 2 3 4 | |
Revert Across Multiple Records#
1 2 3 4 | |
Revert creates new revisions
Reverting does not delete history. Instead, it creates new revisions that undo the changes made since the target timestamp. The full audit trail, including the revert operations themselves, is preserved.
Historical Reads#
All standard read methods support a Timestamp parameter for
historical lookups:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
Historical Navigation#
Navigation and trace methods also support temporal lookups:
1 2 3 4 5 6 7 8 | |