omnicell-router 0.2.0 → 0.3.1

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 (102) hide show
  1. package/backend/dist/budget/budget-manager.d.ts +25 -0
  2. package/backend/dist/budget/budget-manager.js +54 -0
  3. package/backend/dist/cli/clients/index.js +2 -0
  4. package/backend/dist/cli/clients/omp.d.ts +53 -0
  5. package/backend/dist/cli/clients/omp.js +664 -0
  6. package/backend/dist/cli/clients/pi.js +79 -32
  7. package/backend/dist/cli/index.js +2 -2
  8. package/backend/dist/cli/types.d.ts +1 -1
  9. package/backend/dist/config/governance-limits.d.ts +68 -0
  10. package/backend/dist/config/governance-limits.js +261 -0
  11. package/backend/dist/config/index.js +1 -1
  12. package/backend/dist/config/types.d.ts +15 -5
  13. package/backend/dist/flywheel/collector.d.ts +74 -0
  14. package/backend/dist/flywheel/collector.js +235 -0
  15. package/backend/dist/flywheel/dataset.d.ts +130 -0
  16. package/backend/dist/flywheel/dataset.js +638 -0
  17. package/backend/dist/flywheel/decision-capture.d.ts +68 -0
  18. package/backend/dist/flywheel/decision-capture.js +85 -0
  19. package/backend/dist/flywheel/prune.d.ts +133 -0
  20. package/backend/dist/flywheel/prune.js +495 -0
  21. package/backend/dist/flywheel/schema.d.ts +108 -0
  22. package/backend/dist/flywheel/schema.js +117 -0
  23. package/backend/dist/flywheel/trainer.d.ts +84 -0
  24. package/backend/dist/flywheel/trainer.js +198 -0
  25. package/backend/dist/harness/adapters/amp.js +1 -0
  26. package/backend/dist/harness/adapters/claude.js +1 -0
  27. package/backend/dist/harness/adapters/cline.js +3 -1
  28. package/backend/dist/harness/adapters/codex.js +3 -1
  29. package/backend/dist/harness/adapters/cursor.js +1 -0
  30. package/backend/dist/harness/adapters/declarative.d.ts +3 -1
  31. package/backend/dist/harness/adapters/declarative.js +15 -1
  32. package/backend/dist/harness/adapters/dsh.js +1 -1
  33. package/backend/dist/harness/adapters/gemini-cli.js +1 -0
  34. package/backend/dist/harness/adapters/github-copilot.js +1 -0
  35. package/backend/dist/harness/adapters/index.d.ts +11 -3
  36. package/backend/dist/harness/adapters/index.js +48 -1
  37. package/backend/dist/harness/adapters/omp.d.ts +11 -0
  38. package/backend/dist/harness/adapters/omp.js +22 -0
  39. package/backend/dist/harness/adapters/opencode.js +1 -0
  40. package/backend/dist/harness/adapters/pi.js +2 -1
  41. package/backend/dist/harness/adapters/types.d.ts +19 -4
  42. package/backend/dist/harness/adapters/windsurf.js +1 -0
  43. package/backend/dist/harness/adapters/zed.js +3 -1
  44. package/backend/dist/harness/hosts.js +1 -0
  45. package/backend/dist/harness/translation.js +12 -4
  46. package/backend/dist/harness/types.d.ts +2 -2
  47. package/backend/dist/harness/writers/skill.d.ts +1 -1
  48. package/backend/dist/opencode/agents.d.ts +7 -0
  49. package/backend/dist/opencode/agents.js +22 -3
  50. package/backend/dist/opencode/catalog/custom-store.d.ts +50 -0
  51. package/backend/dist/opencode/catalog/custom-store.js +144 -0
  52. package/backend/dist/opencode/credentials/push.d.ts +38 -0
  53. package/backend/dist/opencode/credentials/push.js +116 -0
  54. package/backend/dist/opencode/credentials/reconcile.d.ts +49 -0
  55. package/backend/dist/opencode/credentials/reconcile.js +216 -0
  56. package/backend/dist/opencode/sync.d.ts +29 -0
  57. package/backend/dist/opencode/sync.js +186 -0
  58. package/backend/dist/pipeline/account-selection.d.ts +101 -0
  59. package/backend/dist/pipeline/account-selection.js +112 -0
  60. package/backend/dist/pipeline/orchestrator.js +34 -3
  61. package/backend/dist/providers/systemone.d.ts +29 -0
  62. package/backend/dist/providers/systemone.js +170 -0
  63. package/backend/dist/ratelimit/duration.d.ts +24 -0
  64. package/backend/dist/ratelimit/duration.js +43 -0
  65. package/backend/dist/ratelimit/governance-runtime.d.ts +121 -0
  66. package/backend/dist/ratelimit/governance-runtime.js +183 -0
  67. package/backend/dist/ratelimit/index.d.ts +4 -0
  68. package/backend/dist/ratelimit/index.js +4 -0
  69. package/backend/dist/ratelimit/limiter.d.ts +157 -0
  70. package/backend/dist/ratelimit/limiter.js +244 -0
  71. package/backend/dist/ratelimit/sliding-window-counter.d.ts +63 -0
  72. package/backend/dist/ratelimit/sliding-window-counter.js +103 -0
  73. package/backend/dist/ratelimit/subject.d.ts +26 -0
  74. package/backend/dist/ratelimit/subject.js +28 -0
  75. package/backend/dist/resilience/account-state.d.ts +84 -0
  76. package/backend/dist/resilience/account-state.js +228 -0
  77. package/backend/dist/router/layer1-classifier.d.ts +111 -0
  78. package/backend/dist/router/layer1-classifier.js +467 -0
  79. package/backend/dist/router/layer2-judge.d.ts +111 -0
  80. package/backend/dist/router/layer2-judge.js +373 -0
  81. package/backend/dist/router/retry-escalation.d.ts +89 -0
  82. package/backend/dist/router/retry-escalation.js +99 -0
  83. package/backend/dist/routes/flywheel.d.ts +3 -0
  84. package/backend/dist/routes/flywheel.js +268 -0
  85. package/backend/dist/routes/harness.js +4 -1
  86. package/backend/dist/routes/systemone.d.ts +3 -0
  87. package/backend/dist/routes/systemone.js +90 -0
  88. package/backend/dist/server.d.ts +0 -15
  89. package/backend/dist/server.js +40 -43
  90. package/backend/dist/session/session-manager.d.ts +15 -0
  91. package/backend/dist/session/session-manager.js +17 -0
  92. package/backend/dist/session/session-row.d.ts +78 -0
  93. package/backend/dist/session/session-row.js +52 -0
  94. package/backend/dist/surfaces/governance-envelope.d.ts +34 -0
  95. package/backend/dist/surfaces/governance-envelope.js +47 -0
  96. package/backend/dist/utils/token-estimator.d.ts +7 -0
  97. package/backend/dist/utils/token-estimator.js +20 -0
  98. package/bin/ocr.js +2 -2
  99. package/frontend/dist/assets/{index-DvXKvNxl.js → index-B7GKsUyU.js} +264 -244
  100. package/frontend/dist/assets/{index-1o7qI-KJ.css → index-DLKLOkQJ.css} +1 -1
  101. package/frontend/dist/index.html +2 -2
  102. package/package.json +1 -1
@@ -0,0 +1,74 @@
1
+ import { RoutingDecision, TierLevel } from '../types/router.js';
2
+ import { ChatCompletionRequest } from '../types/openai.js';
3
+ import { FlywheelConfig } from '../config/types.js';
4
+ export interface FlywheelStats {
5
+ totalSamples: number;
6
+ tierDistribution: Record<string, number>;
7
+ layerDistribution: Record<'layer0' | 'layer1' | 'layer2', number>;
8
+ fallbackCount: number;
9
+ }
10
+ /** Retention sweep bookkeeping surfaced on GET /api/admin/flywheel/stats. */
11
+ export interface FlywheelRetentionState {
12
+ retentionDays: number;
13
+ maxFileSizeMB: number;
14
+ enabled: boolean;
15
+ lastSweepAt: string | null;
16
+ lastRemoved: number | null;
17
+ }
18
+ export declare class FlywheelCollector {
19
+ private config;
20
+ private datasetPath;
21
+ private retentionDays;
22
+ private maxFileSizeMB;
23
+ private retentionTimer?;
24
+ private retentionState;
25
+ private runtimeArmed;
26
+ private stats;
27
+ constructor(config?: FlywheelConfig);
28
+ /** Live collection gate — a config-save flip applies without a restart. */
29
+ isEnabled(): boolean;
30
+ /**
31
+ * One-shot lazy arming for a collector that booted disabled and was
32
+ * hot-enabled through the config save path (the console collection
33
+ * toggle): create the dataset directory and arm the retention sweep +
34
+ * timer exactly as the constructor would have. Idempotent; no-op when
35
+ * booted enabled.
36
+ */
37
+ private armRuntime;
38
+ private retentionActive;
39
+ /**
40
+ * Boot + hourly retention sweep body. Failures only warn — the timer must
41
+ * survive a bad pass (same posture as CaptureRecorder.sweep). The sweep
42
+ * never consults the trainer: sync fs means it cannot interleave with the
43
+ * training loop, and landing in a setImmediate gap merely re-indexes before
44
+ * trainingSamples() (design doc D5).
45
+ */
46
+ private runRetentionSweep;
47
+ /** Idempotent hourly retention sweep timer (unref'd, never blocks exit). */
48
+ private startRetentionTimer;
49
+ /** Effective knobs + last sweep outcome, for the stats endpoint. */
50
+ getRetentionState(): FlywheelRetentionState;
51
+ private ensureDirectory;
52
+ /**
53
+ * Record one end-to-end execution turn into the data flywheel dataset.
54
+ *
55
+ * The feature vector is captured HERE, at request time, because the 8
56
+ * features the trainer consumes are computed from the full request and
57
+ * cannot be reconstructed later from a truncated (or redacted) prompt.
58
+ */
59
+ record(params: {
60
+ requestId: string;
61
+ request: ChatCompletionRequest;
62
+ decision: RoutingDecision;
63
+ tierUsed: TierLevel;
64
+ modelUsed: string;
65
+ fallbackOccurred: boolean;
66
+ fallbackReason?: string;
67
+ latencyMs: number;
68
+ /** Test-bench traffic marker; overrides the built-in fingerprint heuristic. */
69
+ synthetic?: boolean;
70
+ }): Promise<void>;
71
+ /** In-memory counters for the current process lifetime (reset on restart). */
72
+ getStats(): FlywheelStats;
73
+ getDatasetPath(): string;
74
+ }
@@ -0,0 +1,235 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { getEnvRootDir } from '../config/env.js';
4
+ import { Layer1Classifier } from '../router/layer1-classifier.js';
5
+ import { applyRetention } from './prune.js';
6
+ import { FLYWHEEL_SCHEMA_VERSION, deriveDefaultLabel, detectSynthetic, } from './schema.js';
7
+ /**
8
+ * Clamp a retention knob: 0/undefined = disabled (backward compat); negative
9
+ * or otherwise unusable values clamp to 0 with one warn (design doc D4 — the
10
+ * knobs are restart-scoped, so construction is the single validation point).
11
+ */
12
+ function clampRetentionKnob(key, value) {
13
+ if (value === undefined)
14
+ return 0;
15
+ if (!Number.isFinite(value) || value < 0) {
16
+ console.warn(`[Flywheel] Invalid flywheel.${key}=${String(value)} — clamped to 0 (disabled).`);
17
+ return 0;
18
+ }
19
+ return value;
20
+ }
21
+ export class FlywheelCollector {
22
+ config;
23
+ datasetPath;
24
+ retentionDays;
25
+ maxFileSizeMB;
26
+ retentionTimer;
27
+ retentionState = {
28
+ lastSweepAt: null,
29
+ lastRemoved: null,
30
+ };
31
+ runtimeArmed = false;
32
+ stats = {
33
+ totalSamples: 0,
34
+ tierDistribution: {},
35
+ layerDistribution: { layer0: 0, layer1: 0, layer2: 0 },
36
+ fallbackCount: 0,
37
+ };
38
+ constructor(config) {
39
+ // Default matches DEFAULT_CONFIG.flywheel: opt-in. Tests that build an
40
+ // orchestrator with a hand-rolled config object (no `flywheel` field) must
41
+ // not silently start collecting into the production dataset path.
42
+ this.config = config ?? { enabled: false, datasetPath: './data/flywheel.jsonl' };
43
+ // Relative dataset paths resolve against the ACTIVE ENVIRONMENT's root
44
+ // (<home>/envs/<name>), so "./data/flywheel.jsonl" always lands inside the
45
+ // book-set that is running — never in the shell's cwd.
46
+ this.datasetPath = path.resolve(getEnvRootDir(), this.config.datasetPath || './data/flywheel.jsonl');
47
+ this.ensureDirectory();
48
+ // Retention sweep (design doc D4, exact CaptureRecorder pattern): only
49
+ // when collection is enabled AND a knob is set; disabled knobs mean zero
50
+ // fs writes, and disabling never deletes anything.
51
+ this.retentionDays = clampRetentionKnob('retentionDays', this.config.retentionDays);
52
+ this.maxFileSizeMB = clampRetentionKnob('maxFileSizeMB', this.config.maxFileSizeMB);
53
+ if (this.config.enabled && this.retentionActive()) {
54
+ this.runRetentionSweep();
55
+ this.startRetentionTimer();
56
+ }
57
+ // Booted enabled = the runtime side effects above are already armed;
58
+ // booted disabled they arm lazily on the first record() after a
59
+ // hot-applied config save flips the gate (see armRuntime).
60
+ this.runtimeArmed = this.config.enabled === true;
61
+ }
62
+ /** Live collection gate — a config-save flip applies without a restart. */
63
+ isEnabled() {
64
+ return this.config.enabled === true;
65
+ }
66
+ /**
67
+ * One-shot lazy arming for a collector that booted disabled and was
68
+ * hot-enabled through the config save path (the console collection
69
+ * toggle): create the dataset directory and arm the retention sweep +
70
+ * timer exactly as the constructor would have. Idempotent; no-op when
71
+ * booted enabled.
72
+ */
73
+ armRuntime() {
74
+ if (this.runtimeArmed)
75
+ return;
76
+ this.runtimeArmed = true;
77
+ this.ensureDirectory();
78
+ if (this.retentionActive()) {
79
+ this.runRetentionSweep();
80
+ this.startRetentionTimer();
81
+ }
82
+ }
83
+ retentionActive() {
84
+ return this.retentionDays > 0 || this.maxFileSizeMB > 0;
85
+ }
86
+ /**
87
+ * Boot + hourly retention sweep body. Failures only warn — the timer must
88
+ * survive a bad pass (same posture as CaptureRecorder.sweep). The sweep
89
+ * never consults the trainer: sync fs means it cannot interleave with the
90
+ * training loop, and landing in a setImmediate gap merely re-indexes before
91
+ * trainingSamples() (design doc D5).
92
+ */
93
+ runRetentionSweep() {
94
+ // Hot-applied gate: a hot-disabled collector pauses retention too. The
95
+ // sweep must never keep deleting while getRetentionState() reports the
96
+ // retention block as disabled — and this matches the boot-disabled
97
+ // posture (zero fs writes) the constructor promises.
98
+ if (!this.config.enabled)
99
+ return;
100
+ try {
101
+ const outcome = applyRetention(this.datasetPath, {
102
+ retentionDays: this.retentionDays,
103
+ maxFileSizeMB: this.maxFileSizeMB,
104
+ });
105
+ this.retentionState = { lastSweepAt: new Date().toISOString(), lastRemoved: outcome.removed };
106
+ }
107
+ catch (err) {
108
+ console.warn(`[Flywheel] Retention sweep failed on ${this.datasetPath}: ${err?.message || String(err)}`);
109
+ }
110
+ }
111
+ /** Idempotent hourly retention sweep timer (unref'd, never blocks exit). */
112
+ startRetentionTimer() {
113
+ if (this.retentionTimer)
114
+ return;
115
+ this.retentionTimer = setInterval(() => this.runRetentionSweep(), 3_600_000);
116
+ this.retentionTimer.unref?.();
117
+ }
118
+ /** Effective knobs + last sweep outcome, for the stats endpoint. */
119
+ getRetentionState() {
120
+ return {
121
+ retentionDays: this.retentionDays,
122
+ maxFileSizeMB: this.maxFileSizeMB,
123
+ enabled: this.config.enabled === true && this.retentionActive(),
124
+ ...this.retentionState,
125
+ };
126
+ }
127
+ ensureDirectory() {
128
+ if (!this.config.enabled)
129
+ return;
130
+ const dir = path.dirname(this.datasetPath);
131
+ if (!fs.existsSync(dir)) {
132
+ try {
133
+ fs.mkdirSync(dir, { recursive: true });
134
+ }
135
+ catch {
136
+ // Ignore mkdir errors
137
+ }
138
+ }
139
+ }
140
+ /**
141
+ * Record one end-to-end execution turn into the data flywheel dataset.
142
+ *
143
+ * The feature vector is captured HERE, at request time, because the 8
144
+ * features the trainer consumes are computed from the full request and
145
+ * cannot be reconstructed later from a truncated (or redacted) prompt.
146
+ */
147
+ async record(params) {
148
+ if (!this.config.enabled)
149
+ return;
150
+ // Hot-applied enable (booted disabled, gate flipped via a config save):
151
+ // arm the directory + retention side effects on first use.
152
+ this.armRuntime();
153
+ // Redaction and truncation only affect the human-readable copy — the
154
+ // feature vector below is what training actually consumes, so a redacted
155
+ // dataset still trains fine.
156
+ const messages = params.request.messages || [];
157
+ const lastUserMsg = [...messages].reverse().find(m => m.role === 'user');
158
+ let promptText = typeof lastUserMsg?.content === 'string'
159
+ ? lastUserMsg.content
160
+ : Array.isArray(lastUserMsg?.content)
161
+ ? lastUserMsg.content.map(p => p.text || '').join(' ')
162
+ : '';
163
+ if (this.config.logUserPrompt === false) {
164
+ promptText = `[PROMPT_REDACTED_${params.decision.features.tokenCountEstimate}_TOKENS]`;
165
+ }
166
+ else if (promptText.length > 2000) {
167
+ promptText = promptText.slice(0, 2000) + '...[TRUNCATED]';
168
+ }
169
+ const extracted = Layer1Classifier.extractFeatures(params.request);
170
+ // The label is what actually SERVED the request, not what the router
171
+ // asked for. Copying `decision.targetTier` into the label (the v1 bug)
172
+ // made every non-fallback row self-labelled and erased the strongest
173
+ // signal in the dataset: 73% of rows had targetTier != tierUsed.
174
+ const isSynthetic = params.synthetic ?? detectSynthetic(params.requestId, params.modelUsed, params.fallbackReason);
175
+ const targetTier = params.decision.targetTier;
176
+ const record = {
177
+ v: FLYWHEEL_SCHEMA_VERSION,
178
+ id: params.requestId,
179
+ timestamp: new Date().toISOString(),
180
+ input: {
181
+ userPrompt: promptText,
182
+ featureVector: extracted.vector,
183
+ featureNames: extracted.featureNames,
184
+ tokenCount: extracted.metrics.tokenCount,
185
+ turnCount: extracted.metrics.turnCount,
186
+ },
187
+ decision: {
188
+ targetTier,
189
+ confidence: params.decision.confidence,
190
+ layerUsed: params.decision.layerUsed || 'layer0',
191
+ reason: params.decision.reason || '',
192
+ reasonCode: params.decision.reasonCode,
193
+ reasonParams: params.decision.reasonParams,
194
+ },
195
+ execution: {
196
+ tierUsed: params.tierUsed,
197
+ modelUsed: params.modelUsed,
198
+ fallbackOccurred: params.fallbackOccurred,
199
+ fallbackReason: params.fallbackReason,
200
+ latencyMs: params.latencyMs,
201
+ isSynthetic,
202
+ },
203
+ label: deriveDefaultLabel({
204
+ targetTier,
205
+ tierUsed: params.tierUsed,
206
+ fallbackOccurred: params.fallbackOccurred,
207
+ }),
208
+ };
209
+ // Update memory stats
210
+ this.stats.totalSamples++;
211
+ if (record.label.tier) {
212
+ this.stats.tierDistribution[record.label.tier] = (this.stats.tierDistribution[record.label.tier] || 0) + 1;
213
+ }
214
+ const layer = record.decision.layerUsed;
215
+ this.stats.layerDistribution[layer]++;
216
+ if (params.fallbackOccurred) {
217
+ this.stats.fallbackCount++;
218
+ }
219
+ // Asynchronously append to JSONL file
220
+ try {
221
+ const line = JSON.stringify(record) + '\n';
222
+ await fs.promises.appendFile(this.datasetPath, line, 'utf8');
223
+ }
224
+ catch (err) {
225
+ console.warn(`[Flywheel] Failed to write sample to ${this.datasetPath}: ${err.message}`);
226
+ }
227
+ }
228
+ /** In-memory counters for the current process lifetime (reset on restart). */
229
+ getStats() {
230
+ return { ...this.stats };
231
+ }
232
+ getDatasetPath() {
233
+ return this.datasetPath;
234
+ }
235
+ }
@@ -0,0 +1,130 @@
1
+ import { TierLevel } from '../types/router.js';
2
+ import { FlywheelRecord, FlywheelLabelSource } from './schema.js';
3
+ export interface DatasetSummary {
4
+ total: number;
5
+ trainable: number;
6
+ synthetic: number;
7
+ humanLabeled: number;
8
+ unlabeled: number;
9
+ trainableByTier: Record<string, number>;
10
+ sourceDistribution: Record<string, number>;
11
+ datasetPath: string;
12
+ labelsPath: string;
13
+ fileBytes: number;
14
+ firstTimestamp: string | null;
15
+ lastTimestamp: string | null;
16
+ }
17
+ export interface SampleQuery {
18
+ limit?: number;
19
+ offset?: number;
20
+ tier?: TierLevel | 'none' | 'any';
21
+ source?: FlywheelLabelSource | 'any';
22
+ includeSynthetic?: boolean;
23
+ trainableOnly?: boolean;
24
+ search?: string;
25
+ }
26
+ export interface SampleRow {
27
+ id: string;
28
+ timestamp: string;
29
+ userPrompt: string;
30
+ tokenCount: number;
31
+ featureVector: number[] | null;
32
+ decision: FlywheelRecord['decision'];
33
+ execution: FlywheelRecord['execution'];
34
+ label: FlywheelRecord['label'];
35
+ }
36
+ export declare class FlywheelDataset {
37
+ private datasetPath;
38
+ private labelsPath;
39
+ private n;
40
+ private cap;
41
+ private ids;
42
+ private idToIdx;
43
+ private offsets;
44
+ private tsMs;
45
+ private vectors;
46
+ private tierIdx;
47
+ private srcIdx;
48
+ private flags;
49
+ private modelPool;
50
+ private modelIdx;
51
+ private promptPrefix;
52
+ private indexedBytes;
53
+ private indexedIno;
54
+ private indexVersion;
55
+ private overrides;
56
+ private labelsLoaded;
57
+ private summaryCache;
58
+ constructor(datasetPath: string);
59
+ getDatasetPath(): string;
60
+ getLabelsPath(): string;
61
+ /** Drop all in-memory state; the next access re-reads from scratch. */
62
+ invalidate(): void;
63
+ /**
64
+ * Index the dataset to completion, synchronously. Cheap when the index is
65
+ * current (only new bytes are parsed); expensive only on a cold start over a
66
+ * large pre-existing file. The HTTP layer should prefer `warmup()`.
67
+ */
68
+ ensureIndexed(): void;
69
+ /**
70
+ * Walk a cold start down in event-loop-friendly slices. Resolves once the
71
+ * index covers the whole file. Safe to call repeatedly / concurrently —
72
+ * concurrent callers just await the same walk.
73
+ */
74
+ private warmupPromise;
75
+ warmup(): Promise<void>;
76
+ private fileSize;
77
+ /** Parse a block of complete newline-terminated lines into the index. */
78
+ private indexLines;
79
+ private indexOne;
80
+ private grow;
81
+ private loadOverrides;
82
+ private writeOverrides;
83
+ /** Effective label for row i: the overlay if present, else the observed derivation. */
84
+ private effectiveLabel;
85
+ /**
86
+ * Set or clear an operator label. Returns the row's effective label after
87
+ * the change (human override or re-derived observation), or null when the
88
+ * id does not exist in the dataset. Targets the most recent row with that id.
89
+ */
90
+ setLabel(id: string, tier: TierLevel | null): FlywheelRecord['label'] | null;
91
+ /** Clear every operator label (does not touch the append-only dataset). */
92
+ clearOverrides(): number;
93
+ /** Read one full record back off disk by index position (lazy detail). */
94
+ private readRow;
95
+ summary(): DatasetSummary;
96
+ /** Effective tier for row i — the overlay if present, else the indexed value. */
97
+ private effTier;
98
+ /** Effective label source for row i — 'human' when an overlay exists. */
99
+ private effSource;
100
+ private matchesIndex;
101
+ /**
102
+ * Filter over the columnar index (fast, no file I/O), then materialize only
103
+ * the returned page by reading those lines back off disk. Rows come back in
104
+ * append order, newest last-position first — for gateway traffic the append
105
+ * order IS the chronological order.
106
+ */
107
+ query(query?: SampleQuery): {
108
+ rows: SampleRow[];
109
+ total: number;
110
+ offset: number;
111
+ limit: number;
112
+ };
113
+ /**
114
+ * Materialize trainable samples straight from the index — no file I/O at
115
+ * all, the feature vectors are columns. Synthetic rows, unlabelled rows and
116
+ * rows whose feature vector is missing are dropped here, so the console and
117
+ * the trainer always agree on the eligible pool.
118
+ */
119
+ trainingSamples(options?: {
120
+ includeSynthetic?: boolean;
121
+ minSource?: FlywheelLabelSource;
122
+ }): {
123
+ samples: Array<{
124
+ features: number[];
125
+ targetTier: TierLevel;
126
+ }>;
127
+ featureDimensions: number;
128
+ skipped: Record<string, number>;
129
+ };
130
+ }