@mostlyrightmd/core 0.1.0-rc.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/dist/discovery/index.cjs +1646 -0
  4. package/dist/discovery/index.cjs.map +1 -0
  5. package/dist/discovery/index.d.cts +313 -0
  6. package/dist/discovery/index.d.ts +313 -0
  7. package/dist/discovery/index.mjs +1609 -0
  8. package/dist/discovery/index.mjs.map +1 -0
  9. package/dist/formats/index.cjs +498 -0
  10. package/dist/formats/index.cjs.map +1 -0
  11. package/dist/formats/index.d.cts +97 -0
  12. package/dist/formats/index.d.ts +97 -0
  13. package/dist/formats/index.mjs +465 -0
  14. package/dist/formats/index.mjs.map +1 -0
  15. package/dist/index.cjs +1624 -0
  16. package/dist/index.cjs.map +1 -0
  17. package/dist/index.d.cts +559 -0
  18. package/dist/index.d.ts +559 -0
  19. package/dist/index.global.js +1582 -0
  20. package/dist/index.global.js.map +1 -0
  21. package/dist/index.mjs +1557 -0
  22. package/dist/index.mjs.map +1 -0
  23. package/dist/internal/bounds.cjs +125 -0
  24. package/dist/internal/bounds.cjs.map +1 -0
  25. package/dist/internal/bounds.d.cts +36 -0
  26. package/dist/internal/bounds.d.ts +36 -0
  27. package/dist/internal/bounds.mjs +81 -0
  28. package/dist/internal/bounds.mjs.map +1 -0
  29. package/dist/internal/cache/fs.cjs +217 -0
  30. package/dist/internal/cache/fs.cjs.map +1 -0
  31. package/dist/internal/cache/fs.d.cts +57 -0
  32. package/dist/internal/cache/fs.d.ts +57 -0
  33. package/dist/internal/cache/fs.mjs +179 -0
  34. package/dist/internal/cache/fs.mjs.map +1 -0
  35. package/dist/internal/cache/index.browser.cjs +1184 -0
  36. package/dist/internal/cache/index.browser.cjs.map +1 -0
  37. package/dist/internal/cache/index.browser.d.cts +20 -0
  38. package/dist/internal/cache/index.browser.d.ts +20 -0
  39. package/dist/internal/cache/index.browser.mjs +36 -0
  40. package/dist/internal/cache/index.browser.mjs.map +1 -0
  41. package/dist/internal/cache/index.cjs +1389 -0
  42. package/dist/internal/cache/index.cjs.map +1 -0
  43. package/dist/internal/cache/index.d.cts +16 -0
  44. package/dist/internal/cache/index.d.ts +16 -0
  45. package/dist/internal/cache/index.mjs +40 -0
  46. package/dist/internal/cache/index.mjs.map +1 -0
  47. package/dist/internal/chunk-PKJXHY27.mjs +1137 -0
  48. package/dist/internal/chunk-PKJXHY27.mjs.map +1 -0
  49. package/dist/internal/convert.cjs +161 -0
  50. package/dist/internal/convert.cjs.map +1 -0
  51. package/dist/internal/convert.d.cts +44 -0
  52. package/dist/internal/convert.d.ts +44 -0
  53. package/dist/internal/convert.mjs +117 -0
  54. package/dist/internal/convert.mjs.map +1 -0
  55. package/dist/internal/fs-O6XR4WWW.mjs +183 -0
  56. package/dist/internal/fs-O6XR4WWW.mjs.map +1 -0
  57. package/dist/internal/keys-B7C8C88N.d.cts +191 -0
  58. package/dist/internal/keys-B7C8C88N.d.ts +191 -0
  59. package/dist/internal/merge/index.cjs +75 -0
  60. package/dist/internal/merge/index.cjs.map +1 -0
  61. package/dist/internal/merge/index.d.cts +74 -0
  62. package/dist/internal/merge/index.d.ts +74 -0
  63. package/dist/internal/merge/index.mjs +46 -0
  64. package/dist/internal/merge/index.mjs.map +1 -0
  65. package/dist/internal/pairs.cjs +328 -0
  66. package/dist/internal/pairs.cjs.map +1 -0
  67. package/dist/internal/pairs.d.cts +105 -0
  68. package/dist/internal/pairs.d.ts +105 -0
  69. package/dist/internal/pairs.mjs +298 -0
  70. package/dist/internal/pairs.mjs.map +1 -0
  71. package/dist/qc/index.cjs +247 -0
  72. package/dist/qc/index.cjs.map +1 -0
  73. package/dist/qc/index.d.cts +140 -0
  74. package/dist/qc/index.d.ts +140 -0
  75. package/dist/qc/index.mjs +212 -0
  76. package/dist/qc/index.mjs.map +1 -0
  77. package/dist/temporal/index.cjs +504 -0
  78. package/dist/temporal/index.cjs.map +1 -0
  79. package/dist/temporal/index.d.cts +121 -0
  80. package/dist/temporal/index.d.ts +121 -0
  81. package/dist/temporal/index.mjs +474 -0
  82. package/dist/temporal/index.mjs.map +1 -0
  83. package/dist/transforms/index.cjs +399 -0
  84. package/dist/transforms/index.cjs.map +1 -0
  85. package/dist/transforms/index.d.cts +193 -0
  86. package/dist/transforms/index.d.ts +193 -0
  87. package/dist/transforms/index.mjs +362 -0
  88. package/dist/transforms/index.mjs.map +1 -0
  89. package/dist/validator.cjs +1870 -0
  90. package/dist/validator.cjs.map +1 -0
  91. package/dist/validator.d.cts +30 -0
  92. package/dist/validator.d.ts +30 -0
  93. package/dist/validator.mjs +1843 -0
  94. package/dist/validator.mjs.map +1 -0
  95. package/package.json +115 -0
@@ -0,0 +1,121 @@
1
+ /**
2
+ * UTC-aware timestamp wrapper.
3
+ *
4
+ * Equivalent to Python's `mostlyright.core.TimePoint`. Constructed from either
5
+ * a `Date` (rejects NaN/Infinity) or a tz-aware ISO 8601 string (rejects
6
+ * naive / date-only inputs). Internally stored as an epoch-ms Date (for
7
+ * display/timezone ops) PLUS an epoch-µs `bigint` (used for comparisons).
8
+ *
9
+ * Immutable: the underlying Date is hidden behind a private `#utc` field
10
+ * and `toUTCDate()` returns a defensive copy so callers cannot mutate the
11
+ * wrapped instant. The `#epochMicros` field carries full µs precision
12
+ * captured from string inputs with 4-6 digit fractional seconds.
13
+ */
14
+ declare class TimePoint {
15
+ #private;
16
+ constructor(value: Date | string);
17
+ /** Return a defensive copy of the underlying UTC Date. */
18
+ toUTCDate(): Date;
19
+ /**
20
+ * Return the epoch microseconds as a `bigint`.
21
+ *
22
+ * Iter-11 C13: this is the comparison-safe accessor. JS `Date` only
23
+ * carries ms precision, so callers comparing `toUTCDate().getTime()`
24
+ * across two TimePoints constructed from `.123456Z` and `.123789Z`
25
+ * would see them as equal — they're not. Use `equals`/`before`/`after`
26
+ * (or this accessor directly) to compare with full µs precision.
27
+ */
28
+ toEpochMicros(): bigint;
29
+ /** Return the canonical ISO 8601 UTC string (always ends in 'Z'). */
30
+ toISOString(): string;
31
+ /**
32
+ * Return the Python-compatible ISO 8601 UTC string.
33
+ *
34
+ * Where {@link toISOString} emits the JS-native `"...Z"` suffix and
35
+ * forces `.000` millisecond padding, this method matches Python's
36
+ * `datetime.isoformat()` output for a UTC-tz-aware datetime:
37
+ *
38
+ * - tz suffix is `+00:00`, never `Z`
39
+ * - subsecond portion is omitted when zero (`"...T12:00:00+00:00"`)
40
+ * - microsecond portion appears as 6 digits when non-zero
41
+ * (`"...T12:00:00.123456+00:00"`); built from the µs-precision
42
+ * `#epochMicros` field so 4-6 digit fractional inputs round-trip
43
+ * exactly (iter-11 C13 fix).
44
+ *
45
+ * Used by error payloads (LeakageError.toDict, sample violations) so
46
+ * MCP clients comparing the on-wire string across the Python and TS
47
+ * SDKs see byte-equivalent values. Iter-1 H1 fix; iter-11 C13 extends
48
+ * to full µs precision.
49
+ */
50
+ toPythonIso(): string;
51
+ /**
52
+ * Format this instant in an IANA timezone via Intl.DateTimeFormat.
53
+ * Display helper only — canonical storage stays UTC.
54
+ *
55
+ * Uses `en-CA` locale for a YYYY-MM-DD, HH:MM:SS shape that's easy to grep
56
+ * in logs. The exact output format may vary slightly across Node releases;
57
+ * callers writing tests should use loose contains-style assertions.
58
+ */
59
+ asZone(tz: string): string;
60
+ equals(other: TimePoint): boolean;
61
+ before(other: TimePoint): boolean;
62
+ after(other: TimePoint): boolean;
63
+ /** Return a TimePoint for the current UTC instant. */
64
+ static now(): TimePoint;
65
+ }
66
+
67
+ /**
68
+ * A filtered, knowledge-time-bounded view over an array of rows.
69
+ *
70
+ * @template Row — caller's row type. Must have a string `knowledge_time` field.
71
+ */
72
+ declare class KnowledgeView<Row extends {
73
+ knowledge_time: string;
74
+ }> {
75
+ #private;
76
+ constructor(rows: ReadonlyArray<Row>, asOf: TimePoint);
77
+ /**
78
+ * Return a freshly filtered array — only rows where
79
+ * `knowledge_time <= asOf`. The returned array is a NEW reference each
80
+ * call (defensive copy semantics), so callers can mutate it without
81
+ * affecting subsequent calls.
82
+ */
83
+ rows(): ReadonlyArray<Row>;
84
+ /** The as-of cutoff supplied at construction. */
85
+ get asOf(): TimePoint;
86
+ }
87
+
88
+ /**
89
+ * Throw {@link LeakageError} if any row's `knowledge_time` is strictly
90
+ * greater than `asOf`. Leak-free input returns void.
91
+ *
92
+ * Loudly rejects rows whose `knowledge_time` is missing, not a string,
93
+ * or not a tz-aware ISO 8601 datetime — these surface as
94
+ * {@link SchemaValidationError} (rule: `required` /
95
+ * `datetime_dtype` / `tz_aware_utc`), mirroring Python's
96
+ * `assert_no_leakage` validation contract.
97
+ *
98
+ * @template Row — caller's row type. Must have a string `knowledge_time` field.
99
+ */
100
+ declare function assertNoLeakage<Row extends {
101
+ knowledge_time: string;
102
+ }>(rows: ReadonlyArray<Row>, asOf: TimePoint): void;
103
+ /**
104
+ * Convenience wrapper for repeated leakage checks against a fixed `asOf`.
105
+ *
106
+ * ```ts
107
+ * const detector = new LeakageDetector(asOf);
108
+ * detector.check(trainingRows);
109
+ * detector.check(featureRows);
110
+ * ```
111
+ */
112
+ declare class LeakageDetector {
113
+ #private;
114
+ constructor(asOf: TimePoint);
115
+ get asOf(): TimePoint;
116
+ check<Row extends {
117
+ knowledge_time: string;
118
+ }>(rows: ReadonlyArray<Row>): void;
119
+ }
120
+
121
+ export { KnowledgeView, LeakageDetector, TimePoint, assertNoLeakage };
@@ -0,0 +1,121 @@
1
+ /**
2
+ * UTC-aware timestamp wrapper.
3
+ *
4
+ * Equivalent to Python's `mostlyright.core.TimePoint`. Constructed from either
5
+ * a `Date` (rejects NaN/Infinity) or a tz-aware ISO 8601 string (rejects
6
+ * naive / date-only inputs). Internally stored as an epoch-ms Date (for
7
+ * display/timezone ops) PLUS an epoch-µs `bigint` (used for comparisons).
8
+ *
9
+ * Immutable: the underlying Date is hidden behind a private `#utc` field
10
+ * and `toUTCDate()` returns a defensive copy so callers cannot mutate the
11
+ * wrapped instant. The `#epochMicros` field carries full µs precision
12
+ * captured from string inputs with 4-6 digit fractional seconds.
13
+ */
14
+ declare class TimePoint {
15
+ #private;
16
+ constructor(value: Date | string);
17
+ /** Return a defensive copy of the underlying UTC Date. */
18
+ toUTCDate(): Date;
19
+ /**
20
+ * Return the epoch microseconds as a `bigint`.
21
+ *
22
+ * Iter-11 C13: this is the comparison-safe accessor. JS `Date` only
23
+ * carries ms precision, so callers comparing `toUTCDate().getTime()`
24
+ * across two TimePoints constructed from `.123456Z` and `.123789Z`
25
+ * would see them as equal — they're not. Use `equals`/`before`/`after`
26
+ * (or this accessor directly) to compare with full µs precision.
27
+ */
28
+ toEpochMicros(): bigint;
29
+ /** Return the canonical ISO 8601 UTC string (always ends in 'Z'). */
30
+ toISOString(): string;
31
+ /**
32
+ * Return the Python-compatible ISO 8601 UTC string.
33
+ *
34
+ * Where {@link toISOString} emits the JS-native `"...Z"` suffix and
35
+ * forces `.000` millisecond padding, this method matches Python's
36
+ * `datetime.isoformat()` output for a UTC-tz-aware datetime:
37
+ *
38
+ * - tz suffix is `+00:00`, never `Z`
39
+ * - subsecond portion is omitted when zero (`"...T12:00:00+00:00"`)
40
+ * - microsecond portion appears as 6 digits when non-zero
41
+ * (`"...T12:00:00.123456+00:00"`); built from the µs-precision
42
+ * `#epochMicros` field so 4-6 digit fractional inputs round-trip
43
+ * exactly (iter-11 C13 fix).
44
+ *
45
+ * Used by error payloads (LeakageError.toDict, sample violations) so
46
+ * MCP clients comparing the on-wire string across the Python and TS
47
+ * SDKs see byte-equivalent values. Iter-1 H1 fix; iter-11 C13 extends
48
+ * to full µs precision.
49
+ */
50
+ toPythonIso(): string;
51
+ /**
52
+ * Format this instant in an IANA timezone via Intl.DateTimeFormat.
53
+ * Display helper only — canonical storage stays UTC.
54
+ *
55
+ * Uses `en-CA` locale for a YYYY-MM-DD, HH:MM:SS shape that's easy to grep
56
+ * in logs. The exact output format may vary slightly across Node releases;
57
+ * callers writing tests should use loose contains-style assertions.
58
+ */
59
+ asZone(tz: string): string;
60
+ equals(other: TimePoint): boolean;
61
+ before(other: TimePoint): boolean;
62
+ after(other: TimePoint): boolean;
63
+ /** Return a TimePoint for the current UTC instant. */
64
+ static now(): TimePoint;
65
+ }
66
+
67
+ /**
68
+ * A filtered, knowledge-time-bounded view over an array of rows.
69
+ *
70
+ * @template Row — caller's row type. Must have a string `knowledge_time` field.
71
+ */
72
+ declare class KnowledgeView<Row extends {
73
+ knowledge_time: string;
74
+ }> {
75
+ #private;
76
+ constructor(rows: ReadonlyArray<Row>, asOf: TimePoint);
77
+ /**
78
+ * Return a freshly filtered array — only rows where
79
+ * `knowledge_time <= asOf`. The returned array is a NEW reference each
80
+ * call (defensive copy semantics), so callers can mutate it without
81
+ * affecting subsequent calls.
82
+ */
83
+ rows(): ReadonlyArray<Row>;
84
+ /** The as-of cutoff supplied at construction. */
85
+ get asOf(): TimePoint;
86
+ }
87
+
88
+ /**
89
+ * Throw {@link LeakageError} if any row's `knowledge_time` is strictly
90
+ * greater than `asOf`. Leak-free input returns void.
91
+ *
92
+ * Loudly rejects rows whose `knowledge_time` is missing, not a string,
93
+ * or not a tz-aware ISO 8601 datetime — these surface as
94
+ * {@link SchemaValidationError} (rule: `required` /
95
+ * `datetime_dtype` / `tz_aware_utc`), mirroring Python's
96
+ * `assert_no_leakage` validation contract.
97
+ *
98
+ * @template Row — caller's row type. Must have a string `knowledge_time` field.
99
+ */
100
+ declare function assertNoLeakage<Row extends {
101
+ knowledge_time: string;
102
+ }>(rows: ReadonlyArray<Row>, asOf: TimePoint): void;
103
+ /**
104
+ * Convenience wrapper for repeated leakage checks against a fixed `asOf`.
105
+ *
106
+ * ```ts
107
+ * const detector = new LeakageDetector(asOf);
108
+ * detector.check(trainingRows);
109
+ * detector.check(featureRows);
110
+ * ```
111
+ */
112
+ declare class LeakageDetector {
113
+ #private;
114
+ constructor(asOf: TimePoint);
115
+ get asOf(): TimePoint;
116
+ check<Row extends {
117
+ knowledge_time: string;
118
+ }>(rows: ReadonlyArray<Row>): void;
119
+ }
120
+
121
+ export { KnowledgeView, LeakageDetector, TimePoint, assertNoLeakage };