Skip to content

advanceDateCursor

function advanceDateCursor(args: {
anyFailed: boolean;
inclusive?: boolean;
maxIso: string | undefined;
previous: Cursor | undefined;
}): Cursor | undefined;

The date cursor to return from a run whose sub-sources (feeds, sections, tickers, channels, meeting types) may have individually failed.

Two safety rules, both protecting the invariant that a date cursor never moves past unfetched work:

  1. Hold on failure. When any sub-source failed, return the previous cursor unchanged. Advancing on the healthy sub-sources’ max date would permanently skip the failed sub-source’s items older than that date — per-sub-source try/catch “resilience” silently trading availability for data loss. Held back, the next run re-fetches the window and the platform’s (feed, id) dedup absorbs the re-emitted documents.

  2. Clamp to now. A future-dated item (a scheduled meeting, a post-dated article) must not drag the cursor past the present, which would make everything published between now and that future date invisible.

ParameterTypeDescription
args{ anyFailed: boolean; inclusive?: boolean; maxIso: string | undefined; previous: Cursor | undefined; }The decision’s inputs.
args.anyFailedbooleanWhether any sub-source failed this run.
args.inclusive?booleanSee dateCursor.
args.maxIsostring | undefinedThe maximum ISO date across this run’s items, if any.
args.previousCursor | undefinedThe incoming ctx.cursor, returned unchanged when holding.

Cursor | undefined

The cursor to return from sync — a new cursor when it is safe to advance, otherwise exactly what was passed in.