Nothing in the crate names a moment in time #55
Labels
No labels
kind
bug
kind
enhancement
kind
refactor
workflow
needs-info
workflow
needs-triage
workflow
ready-for-agent
workflow
ready-for-human
workflow
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
rosa/lucre#55
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The crate names no point in time. #48 needs to file each quotation under the
moment it was made, and there is no type for that moment. No dependency
supplies one either:
jiff,chrono, andtimeare all below 1.0, so puttingany of them in the public API binds this crate's breaking releases to theirs.
Proposal
A
Timestampin theexchangemodule: a point in UTC, ordered, read andwritten as RFC 3339. Conversion to and from
jiff,chrono, andtimesitsbehind an optional feature each.
Settled in triage.
docs/adr/0004-a-timestamp-is-the-crates-own-type.mdrecords why the crate writes the type rather than taking one, and
CONTEXT.mddefines the term.
Out of scope
Historyand dated lookup, which are #48. Calendar arithmetic, durations,timezone conversion, and formatting options — a caller who needs those has a
date library already.
Agent Brief
Category: enhancement
Summary: Add
Timestamp, a UTC point in time read and written as RFC 3339,in the
exchangemodule.Current behavior:
Nothing in the crate names a point in time.
Quotationholds a pair and itsprices with no notion of when it was made, and the
Quotationdeserializerdocuments that it skips any field it does not know, naming the time the price
was observed as an example. No dependency supplies a date type, and none should
—
jiff(0.2),chrono(0.4), andtime(0.3) are all below 1.0.Desired behavior:
lucre::exchange::Timestampnames one moment in UTC. It orders, compares,prints, and reads RFC 3339, and does nothing else. Callers who need calendar
arithmetic, durations, timezone conversion, or formatting options use the date
library they already have and convert.
Reading accepts a full RFC 3339 string with any offset and normalizes it to
UTC, because feeds publish in local time. Writing always ends in
Z.Four inputs are refused rather than repaired:
2026-08-14. A day holds many moments, and choosing oneis the caller's policy.
stated.
:60, so ordering stays total.The year bound is what makes
Displayand serialization total: RFC 3339 outputis always four digits, so no accessor returns a
Result. This is the trade ADR0002 made for prices, applied here.
Key interfaces:
Timestamp—Copy,Clone,Debug,Eq,Ord,Hash. Ordering is bythe moment, so a
BTreeMapkeyed by it ranges correctly.Debugshouldprint the moment, following the precedent set by #27 for
Pair.the Unix epoch, each returning a
Resultwith one error type in the shapethe crate's other errors take (
thiserrorplusmiette::Diagnostic, avariant per rejection above, each carrying what it read — see #13 and #19).
FromStrandDisplay, matching howPairandCurrencyread and printtext.
Displaywrites RFC 3339 ending inZ.SerializeandDeserializebehind theserdefeature, in the crate'ssingle serde module, writing the same text
Displaydoes.jiff,chrono,time. Each givesFrom/TryFromboth ways against thatcrate's UTC instant type. These were approved in triage; do not add any
other dependency.
Acceptance criteria:
Timestampparses2026-08-14T16:00:00Z,2026-08-14T18:00:00+02:00,and
2026-08-14T16:00:00.123456789Z, and the first two compare equal.DisplayandSerializewrite the same RFC 3339 text, always ending inZ, and a value round-trips through both.a year of 0 or 10000, each with its own error variant naming what it read.
BTreeMapkeyed byTimestampreturns the expected entries from a..=range.jiff,chrono, andtimefeatures converts both wayswithout losing a nanosecond, and the crate builds with each on alone.
mise run cipasses. Clippy and the tests run twice, with no featuresand with all of them.
docs/agents/codebase-map.mdlists the new module and the three newfeatures.
Out of scope:
Historyand dated lookup. That is #48, which builds on this.Quotation,Exchange, orPair.Quotationgains notimestamp field; the history keys on one instead.
parsing any format other than RFC 3339.
Timestampat the crate root. Triage settled that it lives in theexchangemodule, because that is the only thing that uses it and the crate is not
offering a general datetime.
Changed my mind, I'm just going to use the
timecrate.