tarlatan
    Preparing search index...

    Function ingestReading

    • Folds one reading into the current period of its window (design "Periods"):

      1. With no period yet, the reading opens period 1.
      2. A reading whose reset time is later than the period's by more than resetToleranceMillis opens the next period, with itself as the highest.
      3. A reading whose reset time is earlier by more than that belongs to an earlier period: it is listed in earlier and changes nothing else.
      4. Any other reading joins (see joined), including one without a reset time or one into a period that has none.

      Parameters

      • current: Option<WindowPeriod>
      • reading: {
            observedAt: number;
            observedMono: Option<{ bootId: string & Brand<"BootId">; micros: number }>;
            provider: "claude" | "codex";
            resetsAt: Option<number>;
            seq: number & Brand<"LedgerSeq">;
            source:
                | "claudeRateLimitEvent"
                | "claudeStatusline"
                | "claudeUsagePrompt"
                | "codexAppServer";
            usedPercent: number;
            window: "fiveHour"
            | "weekly";
        }
      • policy: {
            dropTolerancePoints: number;
            freshnessMillis: number;
            initialEstimate: number;
            minEstimatePoints: number;
            providers: {
                claude: {
                    windows: readonly {
                        reservePercent: number;
                        window: "fiveHour" | "weekly";
                    }[];
                };
                codex: {
                    windows: readonly {
                        reservePercent: number;
                        window: "fiveHour"
                        | "weekly";
                    }[];
                };
            };
            resetToleranceMillis: number;
        }

      Returns WindowPeriod