@mostlyrightmd/core/temporal
Classes
Section titled “Classes”KnowledgeView<Row>
Section titled “KnowledgeView<Row>”A filtered, knowledge-time-bounded view over an array of rows.
Type Parameters
Section titled “Type Parameters”• Row extends object
— caller’s row type. Must have a string knowledge_time field.
Constructors
Section titled “Constructors”new KnowledgeView()
Section titled “new KnowledgeView()”new KnowledgeView<
Row>(rows,asOf):KnowledgeView<Row>
Parameters
Section titled “Parameters”readonly Row[]
Returns
Section titled “Returns”KnowledgeView<Row>
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get asOf():
TimePoint
The as-of cutoff supplied at construction.
Returns
Section titled “Returns”Methods
Section titled “Methods”rows()
Section titled “rows()”rows(): readonly
Row[]
Return a freshly filtered array — only rows where
knowledge_time <= asOf. The returned array is a new reference each
call (defensive copy semantics), so callers can mutate it without
affecting subsequent calls.
Returns
Section titled “Returns”readonly Row[]
LeakageDetector
Section titled “LeakageDetector”Convenience wrapper for repeated leakage checks against a fixed asOf.
const detector = new LeakageDetector(asOf);detector.check(trainingRows);detector.check(featureRows);Constructors
Section titled “Constructors”new LeakageDetector()
Section titled “new LeakageDetector()”new LeakageDetector(
asOf):LeakageDetector
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get asOf():
TimePoint
Returns
Section titled “Returns”Methods
Section titled “Methods”check()
Section titled “check()”check<
Row>(rows):void
Type Parameters
Section titled “Type Parameters”• Row extends object
Parameters
Section titled “Parameters”readonly Row[]
Returns
Section titled “Returns”void
checkIssuedAt()
Section titled “checkIssuedAt()”checkIssuedAt<
Row>(rows):void
Defensive non-null check for issuedAt.
Independent of asOf — the bound cutoff is irrelevant when the row
carries no model-run time at all. Throws IssuedAtMissingError
if any row’s issuedAt is null/undefined/empty.
Type Parameters
Section titled “Type Parameters”• Row extends object
Parameters
Section titled “Parameters”readonly Row[]
Returns
Section titled “Returns”void
TimePoint
Section titled “TimePoint”UTC-aware timestamp wrapper.
Equivalent to Python’s mostlyright.core.TimePoint. Constructed from either
a Date (rejects NaN/Infinity) or a tz-aware ISO 8601 string (rejects
naive / date-only inputs). Stored as an epoch-ms Date (for
display/timezone operations) plus an epoch-µs bigint (for comparisons).
Immutable: the underlying Date is hidden behind a private #utc field
and toUTCDate() returns a defensive copy so callers cannot mutate the
wrapped instant. The #epochMicros field carries full µs precision
captured from string inputs with 4-6 digit fractional seconds.
Constructors
Section titled “Constructors”new TimePoint()
Section titled “new TimePoint()”new TimePoint(
value):TimePoint
Parameters
Section titled “Parameters”string | Date
Returns
Section titled “Returns”Methods
Section titled “Methods”after()
Section titled “after()”after(
other):boolean
Parameters
Section titled “Parameters”Returns
Section titled “Returns”boolean
asZone()
Section titled “asZone()”asZone(
tz):string
Format this instant in an IANA timezone via Intl.DateTimeFormat. Display helper only — canonical storage stays UTC.
Uses en-CA locale for a YYYY-MM-DD, HH:MM:SS shape that’s easy to grep
in logs. The exact output format may vary slightly across Node releases;
callers writing tests should use loose contains-style assertions.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”string
before()
Section titled “before()”before(
other):boolean
Parameters
Section titled “Parameters”Returns
Section titled “Returns”boolean
equals()
Section titled “equals()”equals(
other):boolean
Parameters
Section titled “Parameters”Returns
Section titled “Returns”boolean
staticnow():TimePoint
Return a TimePoint for the current UTC instant.
Returns
Section titled “Returns”toEpochMicros()
Section titled “toEpochMicros()”toEpochMicros():
bigint
Return the epoch microseconds as a bigint.
This is the comparison-safe accessor. JS Date only
carries ms precision, so callers comparing toUTCDate().getTime()
across two TimePoints constructed from .123456Z and .123789Z
would see them as equal — they’re not. Use equals/before/after
(or this accessor directly) to compare with full µs precision.
Returns
Section titled “Returns”bigint
toISOString()
Section titled “toISOString()”toISOString():
string
Return the canonical ISO 8601 UTC string (always ends in ‘Z’).
Returns
Section titled “Returns”string
toPythonIso()
Section titled “toPythonIso()”toPythonIso():
string
Return the Python-compatible ISO 8601 UTC string.
Where toISOString emits the JS-native "...Z" suffix and
forces .000 millisecond padding, this method matches Python’s
datetime.isoformat() output for a UTC-tz-aware datetime:
- tz suffix is
+00:00, neverZ - subsecond portion is omitted when zero (
"...T12:00:00+00:00") - microsecond portion appears as 6 digits when non-zero
(
"...T12:00:00.123456+00:00"); built from the µs-precision#epochMicrosfield so 4-6 digit fractional inputs round-trip exactly.
Used by error payloads (LeakageError.toDict, sample violations) so MCP clients comparing the on-wire string across the Python and TS SDKs see byte-equivalent values with full microsecond precision.
Returns
Section titled “Returns”string
toUTCDate()
Section titled “toUTCDate()”toUTCDate():
Date
Return a defensive copy of the underlying UTC Date.
Returns
Section titled “Returns”Date
Functions
Section titled “Functions”assertIssuedAtPopulated()
Section titled “assertIssuedAtPopulated()”assertIssuedAtPopulated<
Row>(rows):void
Throw IssuedAtMissingError if any row’s
issuedAt is null/undefined/empty.
Mirrors Python assert_issued_at_populated(). A forecast row has to
carry its model-run time to be leakage-safe; a missing issuedAt leaves
no way to verify the cycle predated the asOf cutoff. The Open-Meteo
fetcher derives issuedAt for every row it emits, so this check is a
defensive net rather than an expected failure path.
Type Parameters
Section titled “Type Parameters”• Row extends object
Parameters
Section titled “Parameters”readonly Row[]
Returns
Section titled “Returns”void
assertNoLeakage()
Section titled “assertNoLeakage()”assertNoLeakage<
Row>(rows,asOf):void
Throw LeakageError if any row’s knowledge_time is strictly
greater than asOf. Leak-free input returns void.
Loudly rejects rows whose knowledge_time is missing, not a string,
or not a tz-aware ISO 8601 datetime — these raise
SchemaValidationError (rule: required /
datetime_dtype / tz_aware_utc), mirroring Python’s
assert_no_leakage validation contract.
Type Parameters
Section titled “Type Parameters”• Row extends object
— caller’s row type. Must have a string knowledge_time field.
Parameters
Section titled “Parameters”readonly Row[]
Returns
Section titled “Returns”void