@kymoscope/sdk 0.15.0 → 0.16.0

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 (36) hide show
  1. package/dist/kymoscope-embed.js +71 -71
  2. package/dist/kymoscope-sdk.js +65 -65
  3. package/dist/types/analysis/actions.d.ts +9 -0
  4. package/dist/types/analysis/aiCheck.d.ts +40 -0
  5. package/dist/types/analysis/badParts.d.ts +32 -0
  6. package/dist/types/analysis/changes.d.ts +8 -0
  7. package/dist/types/analysis/context.d.ts +7 -1
  8. package/dist/types/analysis/energy.d.ts +21 -0
  9. package/dist/types/analysis/gap.d.ts +6 -0
  10. package/dist/types/analysis/golden.d.ts +6 -0
  11. package/dist/types/analysis/index.d.ts +4 -0
  12. package/dist/types/analysis/known.d.ts +27 -0
  13. package/dist/types/analysis/oee.d.ts +5 -1
  14. package/dist/types/analysis/presets.d.ts +1 -1
  15. package/dist/types/analysis/ranges.d.ts +18 -0
  16. package/dist/types/analysis/reliability.d.ts +62 -1
  17. package/dist/types/analysis/report.d.ts +2 -2
  18. package/dist/types/analysis/review.d.ts +119 -0
  19. package/dist/types/analysis/runWear.d.ts +13 -0
  20. package/dist/types/analysis/shifts.d.ts +1 -0
  21. package/dist/types/analysis/stops.d.ts +10 -0
  22. package/dist/types/analysis/types.d.ts +31 -0
  23. package/dist/types/engine/createEngine.d.ts +22 -1
  24. package/dist/types/index.d.ts +6 -1
  25. package/dist/types/lib/live/clockProbe.d.ts +26 -0
  26. package/dist/types/lib/live/publisher.d.ts +5 -0
  27. package/dist/types/lib/live/types.d.ts +8 -0
  28. package/dist/types/lib/live/videoTrack.d.ts +46 -2
  29. package/dist/types/lib/measurePack.d.ts +13 -0
  30. package/dist/types/lib/recordings/videoSource.d.ts +12 -1
  31. package/dist/types/lib/segments/rules.d.ts +4 -0
  32. package/dist/types/lib/sync/detect.d.ts +28 -0
  33. package/dist/types/lib/sync/estimate.d.ts +143 -0
  34. package/dist/types/lib/sync/flash.d.ts +49 -0
  35. package/dist/types/lib/sync/frameFeatures.d.ts +16 -0
  36. package/package.json +1 -1
@@ -0,0 +1,9 @@
1
+ import type { ReportAction, ReportRole } from './types';
2
+ /** The action tables' words (00.2 and 12.1), shared by the report, its AI review and its known findings. */
3
+ export declare const OWNER: Record<ReportRole, string>;
4
+ /** Actions section 12 shows in full; 00 names the first 3. */
5
+ export declare const SHOWN_ACTIONS = 5;
6
+ export declare const actionRow: (a: ReportAction) => {
7
+ status?: "crit" | undefined;
8
+ cells: string[];
9
+ };
@@ -52,3 +52,43 @@ export declare const AI_CHARS: {
52
52
  * verdict: the fixed verdict's; a sentence: its cited findings'; an action: its fixed text's and cited findings').
53
53
  * Section 14 is never worded. Malformed input never throws. */
54
54
  export declare function checkAi(input: AiCheckInput, ai: unknown): AiChecked;
55
+ /** The AI review's verdict (review.ts) against what it was given: the report's findings (`fixed`: a batches-to-check
56
+ * finding, never set aside), its actions and the checks' results. */
57
+ export interface ReviewCheckInput {
58
+ findings: Array<{
59
+ id: string;
60
+ text: string;
61
+ fixed?: boolean;
62
+ }>;
63
+ actions: Array<{
64
+ id: string;
65
+ text: string;
66
+ refs: string[];
67
+ }>;
68
+ results: Array<{
69
+ id: string;
70
+ text: string;
71
+ }>;
72
+ }
73
+ export interface ReviewChecked {
74
+ triage: Array<{
75
+ finding: string;
76
+ verdict: 'set_aside' | 'merge';
77
+ into: string | null;
78
+ reason: string;
79
+ }>;
80
+ actions: Array<{
81
+ action: string | null;
82
+ finding: string | null;
83
+ text: string;
84
+ cites: string[];
85
+ }>;
86
+ summary: AiSentence[];
87
+ }
88
+ /** Actions the review may rank first, and sentences it may add to the summary. */
89
+ export declare const REVIEW_ACTIONS = 5, REVIEW_SUMMARY = 3;
90
+ /** Keeps of the verdict only what rests on what it was given: a finding set aside or merged (into another finding) with
91
+ * a short reason, never a fixed one; ranked actions that are the report's own or made of one of its findings; summary
92
+ * sentences citing findings or results. Every number written must be in what it rests on (an action: its own text and
93
+ * what it cites; a reason: any finding or result). Malformed input never throws. */
94
+ export declare function checkReview(input: ReviewCheckInput, ai: unknown): ReviewChecked;
@@ -0,0 +1,32 @@
1
+ import { type ActionSeed, type Classified, type Finding, type ReportChart, type ReportInput } from './types';
2
+ /** 04.3 (2026-11-18): what goes with the batches outside their specification limits, stream by stream, so a report says
3
+ * why there are bad batches and not only how many.
4
+ * - A stream with FEW bad batches or fewer: each one, with the channel furthest from its good batches in it.
5
+ * - Episodes: stretches of batches where the bad share rises far above the stream's own (the densest stretch by a
6
+ * maximum-sum scan, kept when a binomial tail under EPISODE_P says chance alone wouldn't make it), with the channels
7
+ * that differed from the good batches meanwhile.
8
+ * - A rising share: the daily bad share outside the episodes trending up (least squares, p < α), with the channels
9
+ * that tell its bad batches from its good ones: a steady rise is what a wearing tool or part does.
10
+ * A channel goes with the bad batches when its median sits EFFECT robust σ of the good batches away (per batch, its
11
+ * mean offset from the golden, and its lowest and highest value). Never the feature itself, a clock or a counter. */
12
+ export declare const FEW = 10;
13
+ export declare const EPISODE_P = 0.000001;
14
+ export declare const EPISODE_MIN = 5;
15
+ export declare const EFFECT = 3;
16
+ export declare const MAX_EPISODES = 3;
17
+ type Span = {
18
+ t0: number;
19
+ t1: number;
20
+ };
21
+ export interface BadPartsOut {
22
+ findings: Finding[];
23
+ actions: ActionSeed[];
24
+ charts: ReportChart[];
25
+ bad: number;
26
+ }
27
+ /** `drifting`: per stream, the channels 05 found drifting (the wear a rising bad share follows). */
28
+ export declare function badParts(input: ReportInput, pop: Classified[], stuck?: Array<Span & {
29
+ sid: string;
30
+ ch: string;
31
+ }>, drifting?: Map<string, string[]>): BadPartsOut | null;
32
+ export {};
@@ -5,6 +5,14 @@ import { type Classified, type Missing, type ReportInput, type SectionOut } from
5
5
  * difference afterwards, not a proven cause. */
6
6
  export declare const CHANGE_N = 20;
7
7
  export declare const CHANGE_NOISE = 3;
8
+ /** The difference of the medians (after − before) and its 95 % interval: a median's standard error is 1.2533 σ/√n for
9
+ * normal data, σ taken robustly (MAD), so an out-lap left in moves it little. Linear in the batches. */
10
+ export declare function medianShift(before: number[], after: number[]): {
11
+ d: number;
12
+ lo: number;
13
+ hi: number;
14
+ };
15
+ export declare const GROUP_MAX = 6;
8
16
  /** The index of the first batch starting at or after `t` (batches sorted by start). */
9
17
  export declare function firstAtOrAfter(xs: Classified[], t: number): number;
10
18
  export declare function changes(input: ReportInput, pop: Classified[]): SectionOut | Missing | null;
@@ -1,3 +1,4 @@
1
+ import { type KnownFinding } from './known';
1
2
  import { type PresetId } from './presets';
2
3
  import { type SectionId } from './types';
3
4
  /** The project's Process context (spec 2026-11-10, delivery B): what a report needs that the data can't say — the
@@ -5,7 +6,7 @@ import { type SectionId } from './types';
5
6
  * machine units, shifts and planned stops, the costs. Report settings (views, reviewer, approver, schedule) live in the plain `report_settings` row. Stored per project, one version per
6
7
  * save, sealed under the project config key in an end-to-end encrypted project. Plain JSON, the same shape in the
7
8
  * app, the engine and (delivery C) the report service. */
8
- export declare const CHANNEL_ROLES: readonly ["setting", "measurement", "quality", "outside", "energy", "ignore"];
9
+ export declare const CHANNEL_ROLES: readonly ["setting", "measurement", "quality", "outside", "energy", "category", "ignore"];
9
10
  export type ChannelRole = (typeof CHANNEL_ROLES)[number];
10
11
  export declare const CHANNEL_ROLE_TEXT: Record<ChannelRole, string>;
11
12
  export interface ChannelContext {
@@ -81,6 +82,8 @@ export interface ProcessContext {
81
82
  ppkMin?: number;
82
83
  /** The industry preset reports are ordered and worded with (presets.ts); absent: the generating person's signup industry. */
83
84
  preset?: PresetId;
85
+ /** Findings a person marked as not a problem, or known (known.ts): later reports set them aside. */
86
+ known?: KnownFinding[];
84
87
  }
85
88
  export declare const PROCESS_MAX = 4000;
86
89
  export declare const emptyChannel: (unit?: string) => ChannelContext;
@@ -92,6 +95,9 @@ export declare const energyChannel: (c: ProcessContext | null | undefined) => st
92
95
  /** A stored body read back: whatever is unknown or malformed is dropped, so the engine never trusts its shape. */
93
96
  export declare function parseContext(raw: unknown): ProcessContext;
94
97
  /** The shift `t` falls in, in `tz`; null outside every shift. */
98
+ /** localDay for many times: looked up once per 15 minutes (every time zone's offset is a whole quarter hour), so a
99
+ * report over 100,000 batches doesn't ask Intl 100,000 times. */
100
+ export declare function dayLookup(tz: string): (t: number) => string;
95
101
  export declare function shiftOf(t: number, shifts: Shift[], tz: string): string | null;
96
102
  /** Monday 0 … Sunday 6 of a "YYYY-MM-DD". */
97
103
  export declare const weekday: (day: string) => number;
@@ -1,4 +1,25 @@
1
1
  import { type Classified, type Missing, type ReportInput, type SectionOut } from './types';
2
+ /** Section 09 (spec 2026-11-10): energy per batch from the Process context's energy channel (measured per batch by the
3
+ * app: a power channel integrated over the batch, or an energy meter's change), against the period before when its
4
+ * batches' energy is stored; its cost at the price per kWh (without one, kWh alone) and its CO₂ at the grid factor
5
+ * (Scope 2, location-based, the factor the customer entered); and whether off-golden batches use more than the rest
6
+ * (Mann–Whitney). Money that could be saved reads "up to". The period's energy is
7
+ * what the meter counted over the recordings when the channel is one (its rise in each, so the handling between
8
+ * batches, the stops and the breaks are in it); a power channel gives the batches' energy only. */
9
+ /** The units 09 measures in (2026-11-18: energy, or a consumable a line is metered by: fuel, steam, gas, water). A
10
+ * meter (`meter`: its change per unit, in `base`) or a rate (`perS`: per second, in `base`). Price and CO₂ only apply
11
+ * to energy (kWh). */
12
+ export declare const CONSUMPTION_UNITS: Record<string, {
13
+ base: 'kWh' | 'L' | 'm³' | 'kg';
14
+ meter?: number;
15
+ perS?: number;
16
+ }>;
17
+ export declare const consumptionUnit: (unit: string | null | undefined) => {
18
+ base: "kWh" | "L" | "m\u00B3" | "kg";
19
+ meter?: number;
20
+ perS?: number;
21
+ };
22
+ export declare const CONSUMPTION_UNIT_LIST = "kW, W, MW, kWh, Wh, MWh (energy), L, L/h, m\u00B3, m\u00B3/h, kg, kg/h or t (fuel, water, gas, steam)";
2
23
  /** What the CO₂ figure is: purchased electricity at the grid's average factor, as the customer entered it. Never a claim of a certified footprint. */
3
24
  export declare const CO2_BASIS = "Scope 2, location-based, factor entered by you";
4
25
  export declare function energy(input: ReportInput, pop: Classified[]): SectionOut | Missing | null;
@@ -5,4 +5,10 @@ export declare const STOP_S = 1800;
5
5
  export declare const WARM_S = 2400;
6
6
  export declare const MAX_FEATURES = 8;
7
7
  export declare const DAYS: string[];
8
+ /** Channel × piece measured on ≥ 80 % of the measured batches; a channel's whole cycle only when it has no pieces
9
+ * (its pieces add up to it). */
10
+ /** A category: a channel with the role Category, or one with no role that looks like one: at most CATEGORY_MAX whole values (2 at least) at a batch's end, the same at its start in CATEGORY_SAME of
11
+ * the batches where the start is measured too (a step code changes inside a batch: no category). The value's own channel and counters are left out. */
12
+ export declare const CATEGORY_MAX = 12, CATEGORY_SAME = 0.95;
13
+ export declare function categories(input: ReportInput, pop: Classified[]): string[];
8
14
  export declare function whyOff(input: ReportInput, pop: Classified[]): SectionOut;
@@ -14,6 +14,12 @@ export declare const MIN_DAYS = 7;
14
14
  /** How much worse than the golden a batch may be and still be at golden level: 2 % of the golden's value, or twice
15
15
  * the spread of the golden's own batches (an envelope's), whichever is larger, so the golden's noise isn't a miss. */
16
16
  export declare const margin: (g: Pick<GoldenIn, "value" | "spread">) => number;
17
+ /** A value with a target (`<kpi>~<target>`) is a distance, folded at the target: its best batches are the ones noise
18
+ * put nearest, so the golden alone is no level a line holds (a part at exactly 186.000 g). There a batch is at golden
19
+ * level within NOISE_SIGMAS of the channel's batch-to-batch noise beyond the golden: 1.4826 × the median absolute
20
+ * difference between successive batches / √2, per stream, so a drift or a step doesn't count as noise. */
21
+ export declare const NOISE_SIGMAS = 2;
22
+ export declare function targetNoise(input: ReportInput): Map<string, number>;
17
23
  /** The batches that can be judged (closed, with a value, not excluded, on a stream with a golden), in time order. */
18
24
  export declare function classify(input: ReportInput): Classified[];
19
25
  /** Only finite numbers (JSON has no NaN or Infinity). */
@@ -3,8 +3,12 @@
3
3
  * namespace, plus the few names the app's viewer and PDF use. */
4
4
  export { buildReport, listedFindings, viewSections } from './report';
5
5
  export { AI_NOTE, AI_SENTENCES, AI_WORDS, aiInput, applyAi, type AiInput, type AiSentence, type AiText } from './ai';
6
+ export { checkReview, type ReviewChecked } from './aiCheck';
7
+ export { KNOWN_GROWTH, KNOWN_MAX, KNOWN_REASONS, KNOWN_REASON_TEXT, applyKnown, findingSignature, grew, type KnownFinding, type KnownReason } from './known';
8
+ export { REVIEW_CHECKS, applyReview, parseChecks, reviewPack, runChecks, type Check, type CheckResult, type ReportReview, type ReviewPack, type ReviewVerdict } from './review';
6
9
  export { CHANNEL_ROLES, CHANNEL_ROLE_TEXT, PROCESS_MAX, completeness, confirmAll, confirmed, contextGaps, moneyGaps, emptyChannel, emptyContext, energyChannel, parseContext, roleOf, shiftOf, stopSpans, suggestedCount, type PlannedStop, type ChannelContext, type ChannelRole, type ContextGap, type ProcessContext, type Shift, } from './context';
7
10
  export { HealthAcc, usualRange, type ChannelHealth, type RecordingHealth } from './health';
11
+ export { CONSUMPTION_UNITS, CONSUMPTION_UNIT_LIST, consumptionUnit } from './energy';
8
12
  export { applyInferred, assumedSections, inferContext, type InferInput, type InferRecording, type InferStream, type Inferred } from './infer';
9
13
  export { classify, goldenRank, ALPHA, GOLDEN_SHARE, MIN_GROUP, OFF_GOLDEN_PCT } from './golden';
10
14
  export { dateText, dateTimeText, evidenceLabel, exact, num, pText, pct1, spanText } from './text';
@@ -0,0 +1,27 @@
1
+ import type { ReportDoc } from './types';
2
+ /** Findings a person said are not a problem (phase 6, 2026-11-19: learning from one click, no daily input). Each is kept
3
+ * in the Process context with its finding's signature — its section and its words, numbers and dates left out, in
4
+ * the engine's own vocabulary — and the numbers it had then. A later report sets a finding with that signature aside
5
+ * (listed under "Known", never deleted), with the actions that rest on it alone; it comes back when a number of it
6
+ * grew past KNOWN_GROWTH times what it was when it was marked (a stuck sensor that is flat by design for 2 h is news
7
+ * when it is flat for 20). Section 00 sums the others up and is never matched. */
8
+ export declare const KNOWN_REASONS: readonly ["design", "season", "planned", "handled"];
9
+ export type KnownReason = (typeof KNOWN_REASONS)[number];
10
+ export declare const KNOWN_REASON_TEXT: Record<KnownReason, string>;
11
+ export interface KnownFinding {
12
+ sig: string;
13
+ section: string;
14
+ text: string;
15
+ reason: KnownReason;
16
+ note: string;
17
+ numbers: Record<string, number>;
18
+ at: number;
19
+ }
20
+ export declare const KNOWN_MAX = 200, KNOWN_GROWTH = 2;
21
+ /** A finding's signature: its section and its words, with dates, times and numbers taken out. */
22
+ export declare const findingSignature: (section: string, text: string) => string;
23
+ /** Whether a finding grew past what it was when marked: any number they share, KNOWN_GROWTH times larger in size. */
24
+ export declare const grew: (now: Record<string, number>, then: Record<string, number>) => boolean;
25
+ /** The document with the known findings set aside (`known` lists them with the reason given), the actions that rest
26
+ * only on them left out and the rest numbered again; a section 14 note says how many and where they are listed. */
27
+ export declare function applyKnown(doc: ReportDoc, known: KnownFinding[]): ReportDoc;
@@ -9,7 +9,7 @@ import { type Classified, type ReportInput, type SectionOut } from './types';
9
9
  * batch's start to the next one's: the golden's cycle time plus the shortest wait between batches the line reaches again
10
10
  * and again (1 wait in 20), so the handling a machine needs between two strokes is no loss, and a wait longer than that
11
11
  * is. An ideal cycle time set in Process context replaces that one, for every stream. Quality = good batches / batches: not flagged bad and inside the specification limits; when the value to compare
12
- * is not the cycle time, also at golden level or better (a slow batch is a performance loss, not a bad batch).
12
+ * is not the cycle time and has no limits of its own, also at golden level or better (offGoldenIsBad).
13
13
  * What is lost, in hours of planned time (and money with the cost of an hour). */
14
14
  export declare const BLOCK_S = 900;
15
15
  /** The channels with specification limits, and whether a batch's KPIs (mean, minimum, maximum, at start, at end of such
@@ -18,6 +18,10 @@ export declare function specCheck(ctx: ProcessContext | null | undefined): {
18
18
  limits: [string, import("./context").ChannelContext][];
19
19
  outside: (kpis: Record<string, number | null>) => boolean;
20
20
  };
21
+ /** Whether an off-golden batch counts as a bad one: only when the value to compare is not the cycle time and its own
22
+ * channel has no specification limits. Limits say what is bad: a slow batch, or one a little off its target but inside
23
+ * the limits, is no bad batch. */
24
+ export declare function offGoldenIsBad(input: ReportInput): boolean;
21
25
  /** What 06 follows, under its title: the ratios are the standard's; a report supports a review, it certifies nothing. */
22
26
  export declare const OEE_STANDARD: string;
23
27
  /** The three losses of planned time (06.1 and 00.1); the third is `bad` when the value to compare is the cycle time. */
@@ -4,7 +4,7 @@ import type { ReportDoc, ReportInput, ReportRole, SectionId } from './types';
4
4
  * `buildReport` and never touches a number: the same findings, ids, evidence and amounts, in another order and
5
5
  * vocabulary. "generic" is the report as it always was (applying it returns the document unchanged). None of the
6
6
  * signup industries (src/lib/industries.ts) is a regulated one, so "regulated" is only ever chosen in Process context. */
7
- export declare const PRESET_IDS: readonly ["generic", "discrete", "process", "regulated"];
7
+ export declare const PRESET_IDS: readonly ["generic", "discrete", "process", "regulated", "motorsport", "lab"];
8
8
  export type PresetId = (typeof PRESET_IDS)[number];
9
9
  export interface Preset {
10
10
  id: PresetId;
@@ -0,0 +1,18 @@
1
+ import type { Part } from './parts';
2
+ import type { Classified, ReportInput } from './types';
3
+ /** 05.7 (2026-11-18): the expected ranges set in Process context, read. A channel past its range in RANGE_MIN batches
4
+ * in a row or more (its highest value over the top, or its lowest under the bottom), lasting RANGE_MIN_S or more, is
5
+ * an episode: when, how far, and what the batches' value did meanwhile against the stream's other batches of those
6
+ * days. Not an episode: a batch past its range alone (a stop inside a batch), a run chance alone would make (N·pⁿ ≥
7
+ * RANGE_CHANCE), or a range the stream crosses routinely (more than RANGE_RARE of its batches: it doesn't describe that
8
+ * stream). A channel's episodes on a stream are one finding, the longest told; urgent when one lasted RANGE_LONG_S or
9
+ * its batches' value was worse than the rest of those days (Mann–Whitney at α). A channel 05.1 finds drifting on that
10
+ * stream (`drifting`: stream id + NUL + channel) crosses its range as it drifts: the drift is the item to act on, and
11
+ * urgent there when it must be, so the episode says so and is not an urgent item of its own. */
12
+ export declare const RANGE_MIN = 5;
13
+ export declare const RANGE_MIN_S = 600;
14
+ export declare const RANGE_CHANCE = 0.01;
15
+ export declare const RANGE_RARE = 0.1;
16
+ export declare const RANGE_LONG_S = 3600;
17
+ export declare const RANGE_MARGIN = 0.05;
18
+ export declare function rangeEpisodes(input: ReportInput, pop: Classified[], drifting?: Set<string>): Part | null;
@@ -1,4 +1,4 @@
1
- import { type Classified, type ReportInput, type SectionOut } from './types';
1
+ import { type Classified, type CycleIn, type ReportInput, type SectionOut } from './types';
2
2
  /** Section 05 (spec 2026-11-10): sensors per stream and channel over the period's recordings (05.1), each one's drift
3
3
  * against the golden forecast to the band's edge (05.2), and machine wear from cycle time and spread (05.3). */
4
4
  export declare const STUCK_S = 600;
@@ -6,15 +6,21 @@ export declare const STUCK_JOIN_S = 3600;
6
6
  export declare const NOISE_UP = 1.3;
7
7
  export declare const NOISE_Z = 3;
8
8
  export declare const SPIKE_RATE = 0.0001;
9
+ export declare const SPIKE_BATCHES = 5;
10
+ export declare const SPIKE_PER_BATCH = 3;
9
11
  export declare const GAP_SHARE = 0.01;
10
12
  export declare const RATE_DROP = 0.9;
11
13
  export declare const HORIZON_D = 365;
14
+ export declare const URGENT_DAYS = 7;
12
15
  export declare const MIN_TREND = 20;
13
16
  export declare const MIN_POINTS = 6;
14
17
  export declare const SPREAD_UP = 1.15;
18
+ export declare const PHASE_SHARE = 0.5;
15
19
  export type Status = 'Replace' | 'Drifting' | 'Watch' | 'Healthy';
16
20
  /** A sensor (a channel of one stream, `ch` its display name) and what 05.1 found; `stuck`: its joined flat runs when Replace. */
17
21
  /** `step`: a Watch whose only reason is its offset stepping once (when, by how much). */
22
+ /** `with`: other channels of the stream stuck over the same time, folded into this one (one fault). */
23
+ /** `outside`: an outside influence's reading, not a sensor; `common`: one row for the same thing on several streams. */
18
24
  export interface Sensor {
19
25
  ch: string;
20
26
  sid: string;
@@ -28,6 +34,9 @@ export interface Sensor {
28
34
  t: number;
29
35
  d: number;
30
36
  };
37
+ with?: string[];
38
+ outside?: true;
39
+ common?: true;
31
40
  }
32
41
  type Span = {
33
42
  t0: number;
@@ -75,6 +84,30 @@ export declare function stepOf(means: Array<{
75
84
  t: number;
76
85
  d: number;
77
86
  } | null;
87
+ /** Stuck on a stream with batches: batches in a row, lasting STUCK_S or more from the first one's start to the last
88
+ * one's end, in which a channel that moves within its usual batch held one value (it moved under FLAT_BATCH of its
89
+ * usual movement). What a channel does between batches or in one phase of a batch (a counter holding, a valve shut, a
90
+ * screw at rest in a stop) never counts: only batches the machine made while the reading stood still. A channel that
91
+ * sits still in more than STILL_SHARE of its batches (a setpoint, a value updated now and then) can't be judged this
92
+ * way and is never stuck. */
93
+ export declare const FLAT_BATCH = 0.02;
94
+ export declare const STILL_SHARE = 0.25;
95
+ export declare const STUCK_CHANCE = 0.01;
96
+ /** A run of fewer than STUCK_BATCHES batches is a fault only for a channel that is otherwise never flat (a probe that
97
+ * always dithers): one still batch says nothing about a value that is read once a batch and held (`heldShare`, the
98
+ * share of its recorded time in flat runs outside the run, over HELD_SHARE). */
99
+ export declare const STUCK_BATCHES = 3;
100
+ export declare const HELD_SHARE = 0.05;
101
+ export declare function stuckRuns(cs: CycleIn[], key: string, flat?: {
102
+ s: number;
103
+ total: number;
104
+ }): Array<Span & {
105
+ value: number;
106
+ n: number;
107
+ }>;
108
+ /** Sensors of one stream stuck over the same time (most of the shorter one's stuck time shared) are one fault: a probe
109
+ * and what is computed from it, or one cable. The first by name keeps the row and names the others; they leave 05.1. */
110
+ export declare const STUCK_TOGETHER = 0.5;
78
111
  /** Wear: cycle time trending up (its daily means, % of its median per week, p < α), and/or the value's spread up (MAD
79
112
  * of the last third over the first third ≥ SPREAD_UP, both thirds resampled, one-sided bootstrap p < α). Per stream (a
80
113
  * machine wears on its own; pooled, one machine running at another level reads as spread): the clearest one, named
@@ -84,7 +117,19 @@ export interface Wear {
84
117
  p: number | null;
85
118
  grow: number | null;
86
119
  spread: number | null;
120
+ sid?: string;
87
121
  }
122
+ /** A drift that follows an outside influence of its stream (its daily offsets against the outside channel's daily
123
+ * means, or recording by recording over fewer days) is the weather or the surroundings at work, not a sensor to
124
+ * calibrate: Pearson |r| of FOLLOW_R or more, or a significant fit on the outside channel that leaves no trend in time.
125
+ * A row to watch says so. */
126
+ export declare const FOLLOW_R = 0.8;
127
+ /** The same channel doing the same thing on most of the comparable streams (COMMON_SHARE of those that have it, two at
128
+ * least) has one cause common to them (the season, the material, every cell aging alike), not one fault each: one row.
129
+ * A drift common to the streams is not urgent; a stream drifting OUTLIER times as fast as the others keeps its own
130
+ * urgent row, said against them. Out-of-range readings are common when they start on the same day. */
131
+ export declare const COMMON_SHARE = 0.6;
132
+ export declare const OUTLIER = 2;
88
133
  /** Channels that are clocks in any recording (a time column read as a channel): never sensors. */
89
134
  export declare const clockKeys: (input: ReportInput) => Set<string>;
90
135
  /** Channels that are counters (an energy meter, a part count): they never fall in any recording they move in. Never
@@ -92,6 +137,22 @@ export declare const clockKeys: (input: ReportInput) => Set<string>;
92
137
  export declare function counterKeys(input: ReportInput): Set<string>;
93
138
  /** 05.1's sensors, sorted as its table: Replace, Drifting (soonest crossing first), Watch, Healthy. */
94
139
  export declare function sensorsOf(input: ReportInput, pop: Classified[]): Sensor[];
140
+ /** Redundant sensors: two channels of one stream that read alike (the same unit, their highest values in a batch within
141
+ * PAIR_LEVEL of each other and swinging alike) measure one thing; when the difference between them drifts (its daily
142
+ * means' trend, p under α over the pairs, moving PAIR_MOVE residual σ over the period), one of them is off. Neither
143
+ * sensor alone shows it: a controller holding its own probe at the setpoint keeps that probe steady. */
144
+ export declare const PAIR_LEVEL = 0.02;
145
+ export declare const PAIR_MOVE = 4;
146
+ export interface Pair {
147
+ sid: string;
148
+ a: string;
149
+ b: string;
150
+ t0: number;
151
+ diff: number;
152
+ perWeek: number;
153
+ p: number;
154
+ }
155
+ export declare function pairsOf(input: ReportInput, pop: Classified[], skip: Set<string>): Pair[];
95
156
  export declare const reliability: (input: ReportInput, pop: Classified[]) => SectionOut;
96
157
  /** Section 05 with what 05.5 plans from: the sensors, the drifting ones' drifts and the wear. */
97
158
  export declare function reliabilityOf(input: ReportInput, pop: Classified[]): {
@@ -1,6 +1,5 @@
1
+ import { OWNER, SHOWN_ACTIONS, actionRow } from './actions';
1
2
  import { type Finding, type ReportDoc, type ReportInput, type ReportRole, type ReportSection } from './types';
2
- /** Actions section 12 shows in full; 00 names the first 3. */
3
- export declare const SHOWN_ACTIONS = 5;
4
3
  /** The production report (spec 2026-11-10, delivery D revised 2026-11-11): sections 00–14, each from the data and the
5
4
  * one-time Process context (those with their inputs), worded from fixed templates. Pure: the same input gives the same
6
5
  * document. */
@@ -13,3 +12,4 @@ export declare function listedFindings(s: ReportSection): {
13
12
  rest: Finding[];
14
13
  };
15
14
  export declare function viewSections(doc: ReportDoc, view: ReportRole | 'full'): ReportSection[];
15
+ export { OWNER, SHOWN_ACTIONS, actionRow };
@@ -0,0 +1,119 @@
1
+ import type { ReportDoc, ReportInput } from './types';
2
+ /** Kymoscope's AI review of a report (phase 4 of 2026-11-18; research §3 A3–A6): the engine computes, the model decides
3
+ * what to check and what it means. It never sees a recording: a briefing pack (this report's findings and actions, the
4
+ * period day by day per stream, the channels' names, roles and units, the process text) and the results of at most
5
+ * REVIEW_CHECKS checks of a fixed set, each run here on the report's batches with a capped output. Two calls: the plan
6
+ * (which checks), then the verdict (keep, merge or set aside each finding; the actions to do first, ranked). Every
7
+ * number the model writes must be in what it cites (aiCheck's checkReview). A batches-to-check finding (04.2) is never
8
+ * set aside: that stays a person's decision. */
9
+ export declare const REVIEW_CHECKS = 12;
10
+ /** At most this many rows of the period table (stream × day), and of a daily series. */
11
+ export declare const PACK_ROWS = 400, DAILY_BINS = 60;
12
+ /** The actions the review ranks first, at most. */
13
+ export declare const REVIEW_TOP = 5;
14
+ export interface ReviewPack {
15
+ process: string;
16
+ value: {
17
+ label: string;
18
+ better: string;
19
+ };
20
+ channels: Array<{
21
+ name: string;
22
+ role: string;
23
+ unit: string;
24
+ }>;
25
+ streams: string[];
26
+ /** What a check can compare: the value, the duration, `bad` (1 a bad batch), and each KPI of the batches. */
27
+ kpis: string[];
28
+ /** stream, day, batches, bad batches, share off the golden, the value's median. */
29
+ days: Array<[string, string, number, number, number, number | null]>;
30
+ /** `fixed`: never set aside or merged (00 sums the others up; 04.2's batches to check are a person's decision). */
31
+ findings: Array<{
32
+ id: string;
33
+ section: string;
34
+ text: string;
35
+ evidence: string;
36
+ fixed: boolean;
37
+ }>;
38
+ /** 00.1's losses: what each kind of problem cost in the period (money, or line time). */
39
+ losses: Array<{
40
+ label: string;
41
+ amount: string;
42
+ detail: string;
43
+ }>;
44
+ /** What people said is not a problem, or known (the Process context's known findings): the AI weighs the rest with it. */
45
+ known: Array<{
46
+ text: string;
47
+ reason: string;
48
+ note: string;
49
+ }>;
50
+ actions: Array<{
51
+ id: string;
52
+ text: string;
53
+ owner: string;
54
+ urgent: boolean;
55
+ refs: string[];
56
+ }>;
57
+ }
58
+ export type Check = {
59
+ tool: 'compare';
60
+ kpi: string;
61
+ by: 'stream' | 'shift' | 'weekday' | 'hour';
62
+ stream: string | null;
63
+ } | {
64
+ tool: 'before_after';
65
+ kpi: string;
66
+ stream: string;
67
+ at: string;
68
+ } | {
69
+ tool: 'pair';
70
+ a: string;
71
+ b: string;
72
+ stream: string;
73
+ } | {
74
+ tool: 'daily';
75
+ kpi: string;
76
+ stream: string;
77
+ } | {
78
+ tool: 'episode';
79
+ stream: string;
80
+ from: string;
81
+ to: string;
82
+ kpis: string[];
83
+ };
84
+ export interface CheckResult {
85
+ id: string;
86
+ check: Check;
87
+ text: string;
88
+ }
89
+ export declare function reviewPack(doc: ReportDoc, input: ReportInput): ReviewPack;
90
+ /** The checks of the model's plan that can run: known tools, streams and KPIs, at most REVIEW_CHECKS; the rest dropped. */
91
+ export declare function parseChecks(plan: unknown, pack: ReviewPack): Check[];
92
+ /** Runs the checks on the report's batches; each result is a short text whose every number the verdict may quote. */
93
+ export declare function runChecks(input: ReportInput, checks: Check[]): CheckResult[];
94
+ /** The verdict as checked by aiCheck's checkReview. */
95
+ export interface ReviewVerdict {
96
+ triage: Array<{
97
+ finding: string;
98
+ verdict: 'set_aside' | 'merge';
99
+ into: string | null;
100
+ reason: string;
101
+ }>;
102
+ actions: Array<{
103
+ action: string | null;
104
+ finding: string | null;
105
+ text: string;
106
+ cites: string[];
107
+ }>;
108
+ summary: Array<{
109
+ text: string;
110
+ cites: string[];
111
+ }>;
112
+ }
113
+ /** What a report keeps of its review: what was sent and found (shown on request), what was set aside or merged. */
114
+ export type ReportReview = NonNullable<ReportDoc['review']>;
115
+ /** The report with its review applied: the reviewed actions first in their order (an existing one keeps its id's
116
+ * urgency, its text may be reworded; a finding the review made an action of is a new one), then the rest as they were,
117
+ * all numbered again; findings set aside or merged leave their sections and are kept in `review`; the summary is 00's
118
+ * AI sentences. Nothing else changes: every table, number and section stays the engine's. */
119
+ export declare function applyReview(doc: ReportDoc, v: ReviewVerdict, checks: CheckResult[], model: string): ReportDoc;
@@ -0,0 +1,13 @@
1
+ import type { Part } from './parts';
2
+ import type { Classified, ReportInput } from './types';
3
+ /** 05.8 (2026-11-18): wear within a run. Along each recording with RUN_MIN batches or more (its first and last left
4
+ * out: a start and a finish are their own), the value's slope per batch (Theil–Sen); a stream whose runs get worse
5
+ * batch after batch (most of them: a one-sided sign test at α over RUN_COUNT runs or more) by a change over a usual run
6
+ * of RUN_SIGNAL robust σ of its runs' scatter or more is wearing within a run — tyres, a tool between dressings, a
7
+ * filter between changes — and starting again with each run (the runs' starts drifting at under RUN_RESETS of that
8
+ * pace, per batch: aging moves them as fast). Said against the other streams' slope. */
9
+ export declare const RUN_MIN = 6;
10
+ export declare const RUN_COUNT = 5;
11
+ export declare const RUN_SIGNAL = 0.5;
12
+ export declare const RUN_RESETS = 0.5;
13
+ export declare function runWear(input: ReportInput, pop: Classified[]): Part | null;
@@ -4,4 +4,5 @@ import { type Classified, type Finding, type Missing, type ReportInput, type Sec
4
4
  * better, stopped time, alerts), and the weakest shift by that share, named when it differs from the rest by a
5
5
  * two-proportion test at ALPHA or 02.4 named it (its finding then referenced). */
6
6
  export declare const SHIFT_GAP = 0.05;
7
+ export declare const STOP_UP = 1.25;
7
8
  export declare function shiftsSection(input: ReportInput, pop: Classified[], stops: Stop[], s02?: Finding[]): SectionOut | Missing;
@@ -7,7 +7,17 @@ export declare const IDLE_FACTOR = 5;
7
7
  export declare const ATTRIB_S = 60;
8
8
  export declare const STOP_CRIT = 0.2;
9
9
  export declare const OFF_GAP_S = 7200;
10
+ export declare const OFF_DAY_S: number;
11
+ export declare const RUN_GAPS = 5;
10
12
  /** `part`: a later piece of a stop a break or the time between shifts cut (1, 2…): its time counts, it is not one more stop. */
13
+ /** 05.6 lists the stops of LONG_STOP_S or more, the longest first (at most LONG_STOPS, SHOWN_STOPS of them unfolded). */
14
+ export declare const LONG_STOPS = 10;
15
+ export declare const SHOWN_STOPS = 5;
16
+ export declare const LONG_STOP_S = 7200;
17
+ /** A gap with no data while every other stream made batches in DARK_COVER of its STOP_MIN_S slots: the line ran, so
18
+ * it is a stop or a recorder that was off, which the data can't tell; 05.4 says both, for the DARK_SHOWN longest. */
19
+ export declare const DARK_COVER = 0.8;
20
+ export declare const DARK_SHOWN = 3;
11
21
  export interface Stop {
12
22
  streamId: string;
13
23
  t0: number;
@@ -35,6 +35,8 @@ export interface CycleIn {
35
35
  range?: Record<string, [number, number]> | null;
36
36
  /** The batch's energy in kWh (09), measured with the Process context's energy channel. */
37
37
  kwh?: number | null;
38
+ /** Seconds the batch spent in each phase of its rule (none: the rule has no phases). */
39
+ phases?: Record<string, number>;
38
40
  }
39
41
  /** A stream's golden: its value to compare, the spread of its own batches, and its band's half-width per channel. */
40
42
  /** `proposed`: no golden set, one batch stands in (not saved); `auto`: none was set, so this report set one. */
@@ -280,6 +282,9 @@ export interface Finding {
280
282
  /** Sections the evidence is in. */
281
283
  refs: SectionId[];
282
284
  numbers: Record<string, number>;
285
+ /** Its signature (known.ts): its section and words without numbers or dates, in the engine's vocabulary; what a
286
+ * person's "Not a problem" is kept against. */
287
+ sig?: string;
283
288
  /** Section 03's proposed golden: the batch the viewer can make its stream's golden. */
284
289
  golden?: {
285
290
  streamId: string;
@@ -390,6 +395,32 @@ export interface ReportDoc {
390
395
  title: string;
391
396
  needs: string;
392
397
  }>;
398
+ /** Kymoscope's AI review (review.ts): the model, the checks it asked for and their results (what was sent back),
399
+ * and the findings it set aside or merged, each with its reason. Absent: no review. */
400
+ /** Findings set aside because the Process context lists them as known (known.ts), each with the reason a person gave. */
401
+ known?: Array<{
402
+ id: string;
403
+ section: string;
404
+ text: string;
405
+ reason: string;
406
+ note: string;
407
+ at: number;
408
+ }>;
409
+ review?: {
410
+ model: string;
411
+ checks: Array<{
412
+ id: string;
413
+ check: unknown;
414
+ text: string;
415
+ }>;
416
+ setAside: Array<{
417
+ id: string;
418
+ section: string;
419
+ text: string;
420
+ reason: string;
421
+ into: string | null;
422
+ }>;
423
+ };
393
424
  }
394
425
  export type Level = 'off' | 'golden' | 'better';
395
426
  /** A batch judged against its stream's golden; `gap` > 0 is worse. */