IF Commons GitHub

physical/collect

Written to: 1 requirement: 0 proved, 0 partly, 0 failing, 1 with no test recorded. 0005-planning-surfaces FR-003

Collecting (0037-planning FR-016, FR-034): each source of the configuration is read, reconciled with what the store holds and, where the run is to write, the events and traces are written. A source that cannot be read is reported and is not reconciled (a place that could not be read is not a place that is empty, so nothing is closed for it). Sources are taken one after the other so that what one makes is what the next reconciles with.

import { collect } from "./collect.ts";
// const r = await collect({ store, sources, policy, now, context, write: false });

Source: commons/planning/src/physical/collect.ts

0 of 10 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

physical.SourceReporttypeno test imports it
type SourceReport = {
  readonly name: string;
  readonly place: string;
  readonly observations: number;
  readonly classes: { readonly [C in BaselineClass]: number };
  readonly events: number;
  readonly conflicts: readonly Conflict[];
  readonly findings: readonly SourceFinding[];
  /** Why the place was not read, where it was not. */
  readonly unread?: string;
};

What one source came to.

physical.Collectedtypeno test imports it
type Collected = {
  readonly reports: readonly SourceReport[];
  readonly events: readonly ItemEvent[];
  readonly traces: readonly Trace[];
  readonly conflicts: readonly Conflict[];
  /** Whether anything would be written. */
  readonly changes: boolean;
  readonly clock: Clock;
};

What a collection came to.

physical.CollectInputtypeno test imports it
type CollectInput = {
  readonly store: PlanningStoreBackend;
  readonly sources: readonly Source[];
  readonly policy: Policy;
  readonly wallMs: number;
  readonly context: RunContext;
  readonly maxDriftMs?: number;
  readonly write: boolean;
};

What a collection is given.

physical.runClockfunctionno test imports it
function runClock(maxDriftMs: number | undefined, seed: Uint8Array<ArrayBufferLike>): Clock

A replica for the clock of a run: the same for the same folder is not needed, a run makes ids after every id it sees.

physical.collectfunctionno test imports it
function collect(input: CollectInput, clock0: Clock): Promise<Result<Collected, string>>

Reads each source, reconciles it with the store, and writes the result where the run is to write.

SourceReporttypeno test imports it
type SourceReport = {
  readonly name: string;
  readonly place: string;
  readonly observations: number;
  readonly classes: { readonly [C in BaselineClass]: number };
  readonly events: number;
  readonly conflicts: readonly Conflict[];
  readonly findings: readonly SourceFinding[];
  /** Why the place was not read, where it was not. */
  readonly unread?: string;
};

What one source came to.

Collectedtypeno test imports it
type Collected = {
  readonly reports: readonly SourceReport[];
  readonly events: readonly ItemEvent[];
  readonly traces: readonly Trace[];
  readonly conflicts: readonly Conflict[];
  /** Whether anything would be written. */
  readonly changes: boolean;
  readonly clock: Clock;
};

What a collection came to.

CollectInputtypeno test imports it
type CollectInput = {
  readonly store: PlanningStoreBackend;
  readonly sources: readonly Source[];
  readonly policy: Policy;
  readonly wallMs: number;
  readonly context: RunContext;
  readonly maxDriftMs?: number;
  readonly write: boolean;
};

What a collection is given.

runClockfunctionno test imports it
function runClock(maxDriftMs: number | undefined, seed: Uint8Array<ArrayBufferLike>): Clock

A replica for the clock of a run: the same for the same folder is not needed, a run makes ids after every id it sees.

collectfunctionno test imports it
function collect(input: CollectInput, clock0: Clock): Promise<Result<Collected, string>>

Reads each source, reconciles it with the store, and writes the result where the run is to write.

Titles, headings, exports, tables, columns and requirements. Esc closes.