@diagrammo/dgmo 0.25.4 → 0.26.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.
- package/dist/advanced.cjs +62564 -0
- package/dist/advanced.d.cts +5702 -0
- package/dist/advanced.d.ts +5702 -0
- package/dist/advanced.js +62315 -0
- package/dist/auto.cjs +59851 -0
- package/dist/auto.css +214 -0
- package/dist/auto.d.cts +39 -0
- package/dist/auto.d.ts +39 -0
- package/dist/auto.js +437 -0
- package/dist/auto.mjs +59861 -0
- package/dist/cli.cjs +465 -0
- package/dist/editor.cjs +432 -0
- package/dist/editor.d.cts +26 -0
- package/dist/editor.d.ts +26 -0
- package/dist/editor.js +401 -0
- package/dist/highlight.cjs +720 -0
- package/dist/highlight.d.cts +32 -0
- package/dist/highlight.d.ts +32 -0
- package/dist/highlight.js +690 -0
- package/dist/index.cjs +59037 -0
- package/dist/index.d.cts +375 -0
- package/dist/index.d.ts +375 -0
- package/dist/index.js +59041 -0
- package/dist/internal.cjs +62566 -0
- package/dist/internal.d.cts +5702 -0
- package/dist/internal.d.ts +5702 -0
- package/dist/internal.js +62315 -0
- package/dist/map-data/PROVENANCE.json +1 -0
- package/dist/map-data/gazetteer.json +1 -0
- package/dist/map-data/lakes.json +1 -0
- package/dist/map-data/mountain-ranges.json +1 -0
- package/dist/map-data/na-lakes.json +1 -0
- package/dist/map-data/na-land.json +1 -0
- package/dist/map-data/region-names.json +1 -0
- package/dist/map-data/rivers.json +1 -0
- package/dist/map-data/us-states.json +1 -0
- package/dist/map-data/water-bodies.json +1 -0
- package/dist/map-data/world-coarse.json +1 -0
- package/dist/map-data/world-detail.json +1 -0
- package/dist/pert.cjs +325 -0
- package/dist/pert.d.cts +554 -0
- package/dist/pert.d.ts +554 -0
- package/dist/pert.js +294 -0
- package/package.json +1 -1
- package/src/advanced.ts +2 -0
- package/src/class/parser.ts +0 -1
- package/src/completion-types.ts +0 -1
- package/src/completion.ts +80 -39
- package/src/editor/dgmo.grammar.js +18 -0
- package/src/editor/dgmo.grammar.terms.js +35 -0
- package/src/er/parser.ts +0 -1
- package/src/graph/flowchart-parser.ts +1 -1
- package/src/graph/flowchart-renderer.ts +19 -5
- package/src/graph/state-renderer.ts +19 -5
- package/src/infra/parser.ts +1 -1
- package/src/pert/parser.ts +0 -14
- package/src/raci/renderer.ts +8 -2
package/dist/pert.d.ts
ADDED
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
type DgmoSeverity = 'error' | 'warning';
|
|
2
|
+
interface DgmoError {
|
|
3
|
+
line: number;
|
|
4
|
+
column?: number;
|
|
5
|
+
message: string;
|
|
6
|
+
severity: DgmoSeverity;
|
|
7
|
+
/**
|
|
8
|
+
* Optional stable diagnostic code (e.g. 'E_ARROW_SUBSTRING_IN_LABEL').
|
|
9
|
+
* Additive; pre-existing diagnostics omit this field and existing
|
|
10
|
+
* substring-on-`.message` assertions keep working unchanged.
|
|
11
|
+
*/
|
|
12
|
+
code?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** A single entry inside a tag group: `Value color` */
|
|
16
|
+
interface TagEntry {
|
|
17
|
+
readonly value: string;
|
|
18
|
+
readonly color: string;
|
|
19
|
+
readonly lineNumber: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A tag group block: heading + entries.
|
|
23
|
+
*
|
|
24
|
+
* Parser internals build via `Writable<TagGroup>` from `utils/brand.ts`;
|
|
25
|
+
* once returned to a chart-type parser, consumers see the readonly view.
|
|
26
|
+
*/
|
|
27
|
+
interface TagGroup {
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly alias?: string;
|
|
30
|
+
readonly entries: readonly TagEntry[];
|
|
31
|
+
/** Default value for nodes without explicit metadata. First entry unless another is marked `default`. */
|
|
32
|
+
readonly defaultValue?: string;
|
|
33
|
+
readonly lineNumber: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Calendar units: d (days), w (weeks), m (months), q (quarters), y (years), h (hours), min (minutes). bd = business days. s = sprints. */
|
|
37
|
+
type DurationUnit = 'd' | 'bd' | 'w' | 'm' | 'q' | 'y' | 'h' | 'min' | 's';
|
|
38
|
+
interface Duration {
|
|
39
|
+
amount: number;
|
|
40
|
+
unit: DurationUnit;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A three-point duration estimate. Each component is a parsed
|
|
45
|
+
* `Duration { amount, unit }` so mixed units (`1w 2w 3m`) are
|
|
46
|
+
* preserved; the analyzer normalizes to `options.timeUnit` for
|
|
47
|
+
* arithmetic.
|
|
48
|
+
*/
|
|
49
|
+
interface DurationEstimate {
|
|
50
|
+
o: Duration;
|
|
51
|
+
m: Duration;
|
|
52
|
+
p: Duration;
|
|
53
|
+
/**
|
|
54
|
+
* When true, only an M token was given on the source line and the
|
|
55
|
+
* analyzer must expand O/P from confidence factors. When false, the
|
|
56
|
+
* user wrote an explicit O M P triple (even when all three values
|
|
57
|
+
* are equal — zero-variance is a valid, deterministic estimate).
|
|
58
|
+
*/
|
|
59
|
+
mOnly: boolean;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Layout direction. `LR` is the default; `TB` for tall chains. */
|
|
63
|
+
type PertDirection = 'LR' | 'TB';
|
|
64
|
+
/** `node-detail` directive value. */
|
|
65
|
+
type NodeDetail = 'compact' | 'full';
|
|
66
|
+
/**
|
|
67
|
+
* Project schedule anchor. Mutually-exclusive at parse time:
|
|
68
|
+
* - `forward` — `start-date YYYY-MM-DD` anchors source-activity ES.
|
|
69
|
+
* - `backward` — `end-date YYYY-MM-DD` anchors sink-activity LF.
|
|
70
|
+
* - `null` — no anchor; ES/EF/LS/LF render as numeric offsets.
|
|
71
|
+
*/
|
|
72
|
+
type Anchor = {
|
|
73
|
+
kind: 'forward';
|
|
74
|
+
date: string;
|
|
75
|
+
} | {
|
|
76
|
+
kind: 'backward';
|
|
77
|
+
date: string;
|
|
78
|
+
} | null;
|
|
79
|
+
/**
|
|
80
|
+
* One row of the project-stats caption. Replaces the previous
|
|
81
|
+
* `\n`-joined `summaryText` string with a structured shape so the
|
|
82
|
+
* renderer doesn't have to recover bullet structure by splitting on
|
|
83
|
+
* `\n` / `. ` and tests can assert on `isPast` directly instead of
|
|
84
|
+
* matching the trailing `(latest-safe start has passed)` suffix.
|
|
85
|
+
*/
|
|
86
|
+
interface CaptionRow {
|
|
87
|
+
/** Pre-formatted caption text for this row (no leading bullet glyph). */
|
|
88
|
+
text: string;
|
|
89
|
+
/** 0 = top-level row; 1 = sub-row (indented under the previous level-0 row). */
|
|
90
|
+
level: 0 | 1;
|
|
91
|
+
/** When true, renderer paints the text italic. */
|
|
92
|
+
italic?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Backward-mode flag — true when the row reports a latest-safe-start
|
|
95
|
+
* date that precedes `options.today`. The text already carries a
|
|
96
|
+
* `(latest-safe start has passed)` suffix; the flag is for downstream
|
|
97
|
+
* styling/test assertions.
|
|
98
|
+
*/
|
|
99
|
+
isPast?: boolean;
|
|
100
|
+
}
|
|
101
|
+
/** Diagram-level options collected by the parser. */
|
|
102
|
+
interface PertOptions {
|
|
103
|
+
/** Time unit for μ/σ/ES/EF formatting and M-only heuristics. */
|
|
104
|
+
timeUnit: Duration['unit'];
|
|
105
|
+
/** `direction` directive. Defaults to `LR`. */
|
|
106
|
+
direction: PertDirection;
|
|
107
|
+
/** `node-detail` directive. Defaults to `compact`. */
|
|
108
|
+
nodeDetail: NodeDetail;
|
|
109
|
+
/**
|
|
110
|
+
* Global confidence used to fill O/P from M-only durations.
|
|
111
|
+
* Stored verbatim — analyzer applies `resolveConfidence()` to expand
|
|
112
|
+
* named levels (`high`/`medium`/`low`) or `O/P` factor pairs.
|
|
113
|
+
*/
|
|
114
|
+
confidence: string;
|
|
115
|
+
/** Monte-Carlo trials for the canonical run (default 10000). */
|
|
116
|
+
trials: number;
|
|
117
|
+
/** Monte-Carlo seed; deterministic across machines via mulberry32. */
|
|
118
|
+
seed: number;
|
|
119
|
+
/** Fast-MC trials for the live duration scrubber (default 300, floor 100). */
|
|
120
|
+
scrubberTrials: number;
|
|
121
|
+
/**
|
|
122
|
+
* Date anchor — discriminated union enforces mutual exclusion.
|
|
123
|
+
* `null` when no `start-date`/`end-date` directive was authored.
|
|
124
|
+
*/
|
|
125
|
+
anchor: Anchor;
|
|
126
|
+
/** When true, the renderer suppresses the diagram banner title. */
|
|
127
|
+
noTitle?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* `no-analysis` directive — suppresses the analysis layer (tornado +
|
|
130
|
+
* S-curve). The layer renders by default whenever Monte Carlo ran;
|
|
131
|
+
* this bare flag turns it off (mirrors `no-title`). An explicit
|
|
132
|
+
* `viewState.an` (desktop-app toggle / share link) overrides it.
|
|
133
|
+
*/
|
|
134
|
+
noAnalysis?: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* `active-tag <name>` directive — selects which declared tag group
|
|
137
|
+
* drives node fill via `resolveTagColor()`. `'none'` (case-insensitive)
|
|
138
|
+
* suppresses tag coloring; `undefined` lets `resolveActiveTagGroup()`
|
|
139
|
+
* auto-activate the first declared group.
|
|
140
|
+
*/
|
|
141
|
+
activeTag?: string;
|
|
142
|
+
/**
|
|
143
|
+
* Sprint mode (mirrors Gantt's surface). Activated automatically when
|
|
144
|
+
* `time-unit s` is set, or explicitly when any `sprint-*` directive
|
|
145
|
+
* appears. Schedule cells render as `S<n>` instead of numeric offsets
|
|
146
|
+
* or ISO dates.
|
|
147
|
+
*/
|
|
148
|
+
sprintLength: Duration | null;
|
|
149
|
+
sprintNumber: number | null;
|
|
150
|
+
sprintStart: string | null;
|
|
151
|
+
sprintMode: 'auto' | 'explicit' | null;
|
|
152
|
+
/**
|
|
153
|
+
* "Today" baked in at parse time (ISO YYYY-MM-DD). Same source as
|
|
154
|
+
* `start-date now`, captured for every parse regardless of whether
|
|
155
|
+
* `now` was authored. Analyzer reads this to flag past latest-safe
|
|
156
|
+
* starts in backward mode; renderer surfaces it in the
|
|
157
|
+
* `(as of YYYY-MM-DD)` anchor annotation. Empty string when the
|
|
158
|
+
* parser was given no `now` and no `start-date now` directive (legacy
|
|
159
|
+
* fixtures pre-dating this field) — consumers treat empty as
|
|
160
|
+
* "no today known" and skip past-flagging.
|
|
161
|
+
*/
|
|
162
|
+
today: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* A PERT activity (node). Activities have either a three-point estimate,
|
|
166
|
+
* an M-only estimate (parser fills O/P from confidence factors), or no
|
|
167
|
+
* estimate at all (TBD — analyzer null-poisons descendants).
|
|
168
|
+
*/
|
|
169
|
+
interface PertActivity {
|
|
170
|
+
/** Stable id — alias if `as` was given, otherwise normalized name. */
|
|
171
|
+
readonly id: string;
|
|
172
|
+
/** Human-readable label as written in source. */
|
|
173
|
+
readonly name: string;
|
|
174
|
+
/** Optional alias from `<name> <durs> as <id>`. */
|
|
175
|
+
readonly alias?: string;
|
|
176
|
+
/**
|
|
177
|
+
* Activity duration estimate.
|
|
178
|
+
* - `null` → TBD (no estimate); analyzer poisons descendants with `null`.
|
|
179
|
+
*/
|
|
180
|
+
readonly duration: DurationEstimate | null;
|
|
181
|
+
/**
|
|
182
|
+
* Per-activity confidence override from pipe metadata (`| confidence: low`).
|
|
183
|
+
* When unset, analyzer uses `options.confidence`.
|
|
184
|
+
*/
|
|
185
|
+
readonly confidence?: string;
|
|
186
|
+
/** Group id this activity belongs to (post-resolve). */
|
|
187
|
+
readonly groupId?: string;
|
|
188
|
+
/** Source line of the declaration site (1-based). */
|
|
189
|
+
readonly lineNumber: number;
|
|
190
|
+
/** True for `milestone <name>` primitives (zero-duration, diamond shape). */
|
|
191
|
+
readonly isMilestone: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Resolved tag-group metadata from pipe-metadata aliases. Keys are
|
|
194
|
+
* lowercased tag-group names (e.g. `priority`, `team`); values are the
|
|
195
|
+
* authored tag entry names. Drives node fill via `resolveTagColor()`
|
|
196
|
+
* when an `active-tag` group is set. Empty when no tag groups are
|
|
197
|
+
* declared or the activity carried no tag metadata.
|
|
198
|
+
*/
|
|
199
|
+
readonly tags?: Readonly<Record<string, string>>;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Forward-style milestone shorthand. Stored as a `PertActivity` with
|
|
203
|
+
* `isMilestone: true` and a zero-duration estimate, but kept here as a
|
|
204
|
+
* distinct exported alias for callers that want to filter by kind.
|
|
205
|
+
*/
|
|
206
|
+
type PertMilestone = PertActivity & {
|
|
207
|
+
isMilestone: true;
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Dependency type — defaults to FS (Finish-to-Start), the dominant case.
|
|
211
|
+
* - FS: `B.ES ≥ A.EF + lag` (most edges)
|
|
212
|
+
* - SS: `B.ES ≥ A.ES + lag` (parallel start)
|
|
213
|
+
* - FF: `B.EF ≥ A.EF + lag` (synchronized finish)
|
|
214
|
+
* - SF: `B.EF ≥ A.ES + lag` (rare; included for completeness)
|
|
215
|
+
*/
|
|
216
|
+
type EdgeType = 'FS' | 'SS' | 'FF' | 'SF';
|
|
217
|
+
/**
|
|
218
|
+
* Directed dependency edge from `source` activity to `target`.
|
|
219
|
+
* `type` defaults to FS, `lag` to null (zero offset). Lag amount may be
|
|
220
|
+
* negative (a lead — predecessor and successor overlap).
|
|
221
|
+
*/
|
|
222
|
+
interface PertEdge {
|
|
223
|
+
readonly source: string;
|
|
224
|
+
readonly target: string;
|
|
225
|
+
readonly lineNumber: number;
|
|
226
|
+
readonly type: EdgeType;
|
|
227
|
+
readonly lag: Duration | null;
|
|
228
|
+
}
|
|
229
|
+
/** Group declared via `[group-name] | metadata`. */
|
|
230
|
+
interface PertGroup {
|
|
231
|
+
readonly id: string;
|
|
232
|
+
readonly name: string;
|
|
233
|
+
/** Activity ids belonging to this group, populated in Pass 2. */
|
|
234
|
+
readonly activityIds: readonly string[];
|
|
235
|
+
/** Whether the user authored `| collapsed: true`. */
|
|
236
|
+
readonly collapsed: boolean;
|
|
237
|
+
/** Source line of the `[group-name]` header (1-based). */
|
|
238
|
+
readonly lineNumber: number;
|
|
239
|
+
/**
|
|
240
|
+
* Resolved tag-group metadata for the cluster header — same shape as
|
|
241
|
+
* `PertActivity.tags`. Currently informational; default-tag injection
|
|
242
|
+
* skips groups (containers) so they appear "untagged" unless the user
|
|
243
|
+
* authors an explicit value via pipe metadata.
|
|
244
|
+
*/
|
|
245
|
+
readonly tags?: Readonly<Record<string, string>>;
|
|
246
|
+
/**
|
|
247
|
+
* Auto-detected group topology (Pass 2 result).
|
|
248
|
+
* - `hammock`: single entry + single exit — collapses to a super-edge.
|
|
249
|
+
* - `cluster`: multi-entry or multi-exit — collapses to a bounding rect.
|
|
250
|
+
*/
|
|
251
|
+
readonly classification?: 'hammock' | 'cluster';
|
|
252
|
+
}
|
|
253
|
+
/** Output of `parsePert(content)`. */
|
|
254
|
+
interface ParsedPert {
|
|
255
|
+
/** Optional title parsed from `pert <title>`. */
|
|
256
|
+
readonly title: string | null;
|
|
257
|
+
readonly options: PertOptions;
|
|
258
|
+
readonly activities: readonly PertActivity[];
|
|
259
|
+
readonly edges: readonly PertEdge[];
|
|
260
|
+
readonly groups: readonly PertGroup[];
|
|
261
|
+
/**
|
|
262
|
+
* Tag groups declared at the top of the diagram (`tag Priority as p
|
|
263
|
+
* High red, Low green`). Drive node fill via `resolveTagColor()`.
|
|
264
|
+
* Empty when no `tag` blocks are declared.
|
|
265
|
+
*/
|
|
266
|
+
readonly tagGroups: readonly TagGroup[];
|
|
267
|
+
/**
|
|
268
|
+
* Map alias-or-name → canonical activity id. Useful for the analyzer
|
|
269
|
+
* and for editor autocomplete; also populated in Pass 2.
|
|
270
|
+
*/
|
|
271
|
+
readonly idMap: Readonly<Record<string, string>>;
|
|
272
|
+
readonly diagnostics: readonly DgmoError[];
|
|
273
|
+
/** First fatal error message; `null` when parse succeeded. */
|
|
274
|
+
readonly error: string | null;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Fully-resolved per-activity analysis output. ES/EF/LS/LF/slack are
|
|
278
|
+
* `null` for any activity downstream of a TBD (poison-propagation per
|
|
279
|
+
* AC2.3).
|
|
280
|
+
*/
|
|
281
|
+
interface ResolvedActivity {
|
|
282
|
+
activity: PertActivity;
|
|
283
|
+
/** Earliest start (forward pass). `null` if upstream TBD. */
|
|
284
|
+
es: number | null;
|
|
285
|
+
/** Earliest finish. */
|
|
286
|
+
ef: number | null;
|
|
287
|
+
/** Latest start (backward pass). */
|
|
288
|
+
ls: number | null;
|
|
289
|
+
/** Latest finish. */
|
|
290
|
+
lf: number | null;
|
|
291
|
+
/** Slack = LS − ES (or LF − EF). 0 = on critical path. `null` if poisoned. */
|
|
292
|
+
slack: number | null;
|
|
293
|
+
/** True iff the M-world critical path passes through this activity. */
|
|
294
|
+
isCriticalPath: boolean;
|
|
295
|
+
/** Resolved μ in `options.timeUnit` (numeric mean of o/m/p). */
|
|
296
|
+
mu: number | null;
|
|
297
|
+
/** Resolved σ in `options.timeUnit` (Beta-PERT std dev). */
|
|
298
|
+
sigma: number | null;
|
|
299
|
+
/**
|
|
300
|
+
* Criticality index from Monte Carlo (0–1). `null` when MC is off or
|
|
301
|
+
* when this activity is downstream of a TBD.
|
|
302
|
+
*/
|
|
303
|
+
criticality: number | null;
|
|
304
|
+
/**
|
|
305
|
+
* True iff the source declared an explicit O/M/P triple. M-only,
|
|
306
|
+
* TBD, and milestone activities all report `false`.
|
|
307
|
+
*/
|
|
308
|
+
isAuthored: boolean;
|
|
309
|
+
}
|
|
310
|
+
/** Resolved hammock/cluster group. */
|
|
311
|
+
interface ResolvedGroup {
|
|
312
|
+
group: PertGroup;
|
|
313
|
+
/** Aggregate μ/σ along the group's internal critical path. */
|
|
314
|
+
rolledMu: number | null;
|
|
315
|
+
rolledSigma: number | null;
|
|
316
|
+
/** Group entry/exit ids derived in Pass 2. */
|
|
317
|
+
entries: string[];
|
|
318
|
+
exits: string[];
|
|
319
|
+
/**
|
|
320
|
+
* Rolled-up schedule envelope across member activities.
|
|
321
|
+
* ES = min member.es
|
|
322
|
+
* EF = max member.ef
|
|
323
|
+
* LS = min member.ls
|
|
324
|
+
* LF = max member.lf
|
|
325
|
+
* slack = LS − ES
|
|
326
|
+
* criticality = max member.criticality (when MC is on)
|
|
327
|
+
* Each is `null` when no member has a non-null value (e.g. all-TBD group).
|
|
328
|
+
*/
|
|
329
|
+
es: number | null;
|
|
330
|
+
ef: number | null;
|
|
331
|
+
ls: number | null;
|
|
332
|
+
lf: number | null;
|
|
333
|
+
slack: number | null;
|
|
334
|
+
criticality: number | null;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Bare shape for a Monte-Carlo simulation result; Phase 2 fills it.
|
|
338
|
+
* Keeping the shape exported in v1 means analyzer consumers don't break
|
|
339
|
+
* when MC support lands.
|
|
340
|
+
*/
|
|
341
|
+
interface MonteCarloResult {
|
|
342
|
+
/** Trials run (canonical or fast). */
|
|
343
|
+
trials: number;
|
|
344
|
+
/** Seed used for deterministic reproduction. */
|
|
345
|
+
seed: number;
|
|
346
|
+
/** Project-completion percentiles. */
|
|
347
|
+
p50: number;
|
|
348
|
+
p80: number;
|
|
349
|
+
p95: number;
|
|
350
|
+
/**
|
|
351
|
+
* Central ~68% band — empirical equivalent of a ±1σ window. Used by
|
|
352
|
+
* the S-curve to draw a "where the project most likely lands" shaded
|
|
353
|
+
* region without assuming the finish-time distribution is normal.
|
|
354
|
+
*/
|
|
355
|
+
p16: number;
|
|
356
|
+
p84: number;
|
|
357
|
+
/**
|
|
358
|
+
* Empirical lower bound — minimum trial duration in canonical days.
|
|
359
|
+
* Used by the S-curve to anchor its x-axis at the actually-observed
|
|
360
|
+
* span rather than an analytical extrapolation. Backward-mode reads
|
|
361
|
+
* this through `end_date − max` to land the left edge of the
|
|
362
|
+
* candidate-start axis.
|
|
363
|
+
*/
|
|
364
|
+
minDurationDays: number;
|
|
365
|
+
/**
|
|
366
|
+
* Empirical upper bound — maximum trial duration in canonical days.
|
|
367
|
+
* Symmetric counterpart to `minDurationDays`. Backward-mode reads
|
|
368
|
+
* this as the latest candidate start that still has a chance of
|
|
369
|
+
* hitting the deadline.
|
|
370
|
+
*/
|
|
371
|
+
maxDurationDays: number;
|
|
372
|
+
/** Per-activity criticality index, keyed by activity id. */
|
|
373
|
+
criticalityByActivity: Record<string, number>;
|
|
374
|
+
/** Modal-longest-path tuple (activity ids). */
|
|
375
|
+
modalCriticalPath: string[];
|
|
376
|
+
/**
|
|
377
|
+
* Per-activity tornado swings — how much the project end-date
|
|
378
|
+
* moves when this activity comes in at its optimistic (O) or
|
|
379
|
+
* pessimistic (P) extreme while every other activity stays at
|
|
380
|
+
* its mean (μ). Sorted descending by total swing.
|
|
381
|
+
*
|
|
382
|
+
* `lowSwing` and `highSwing` are in canonical days (≥ 0).
|
|
383
|
+
* Renderer converts to display unit.
|
|
384
|
+
*/
|
|
385
|
+
tornadoSwings: TornadoSwing[];
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* One row of a true two-sided tornado: the project end-date moves
|
|
389
|
+
* lowSwing days earlier when the activity is at its optimistic
|
|
390
|
+
* extreme, and highSwing days later when at its pessimistic extreme.
|
|
391
|
+
* All other activities held at their μ.
|
|
392
|
+
*/
|
|
393
|
+
interface TornadoSwing {
|
|
394
|
+
id: string;
|
|
395
|
+
name: string;
|
|
396
|
+
/** Days the project finishes EARLIER when this activity ≈ O. */
|
|
397
|
+
lowSwing: number;
|
|
398
|
+
/** Days the project finishes LATER when this activity ≈ P. */
|
|
399
|
+
highSwing: number;
|
|
400
|
+
/** Per-activity MC criticality index, used by the renderer for bar color. */
|
|
401
|
+
criticality: number | null;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Per-activity (O, M, P) in canonical days — the analyzer's
|
|
405
|
+
* expanded-estimate cache, populated for every activity that has an
|
|
406
|
+
* estimate (TBDs are omitted). Workers re-running Monte Carlo on an
|
|
407
|
+
* already-resolved PERT can read this directly instead of re-parsing
|
|
408
|
+
* + re-expanding from source.
|
|
409
|
+
*/
|
|
410
|
+
interface PertExpandedActivity {
|
|
411
|
+
id: string;
|
|
412
|
+
o: number;
|
|
413
|
+
m: number;
|
|
414
|
+
p: number;
|
|
415
|
+
}
|
|
416
|
+
interface ResolvedPert {
|
|
417
|
+
options: PertOptions;
|
|
418
|
+
activities: ResolvedActivity[];
|
|
419
|
+
edges: PertEdge[];
|
|
420
|
+
groups: ResolvedGroup[];
|
|
421
|
+
/**
|
|
422
|
+
* Tag groups copied from the parsed source. The renderer reads this
|
|
423
|
+
* + `options.activeTag` to drive node fill via `resolveTagColor()`
|
|
424
|
+
* and to render the legend.
|
|
425
|
+
*/
|
|
426
|
+
tagGroups: TagGroup[];
|
|
427
|
+
/**
|
|
428
|
+
* Analysis mode auto-derived from data: `monte-carlo` when at least
|
|
429
|
+
* one non-milestone activity carries an O/M/P triple AND `trials >= 100`,
|
|
430
|
+
* otherwise `analytical`.
|
|
431
|
+
*/
|
|
432
|
+
mode: 'monte-carlo' | 'analytical';
|
|
433
|
+
/**
|
|
434
|
+
* Project-stats caption rows. Each row is one bullet in the rendered
|
|
435
|
+
* caption box; level-1 rows render indented under the preceding
|
|
436
|
+
* level-0 row. Null only when analysis bails out before producing
|
|
437
|
+
* any output (e.g. cycle detection); non-null in every successful
|
|
438
|
+
* analyze() run.
|
|
439
|
+
*/
|
|
440
|
+
summaryRows: CaptionRow[] | null;
|
|
441
|
+
/**
|
|
442
|
+
* One-line project summary rendered as a subtitle under the diagram title.
|
|
443
|
+
* Shape per mode (see §13A.7):
|
|
444
|
+
* - Forward: `Expected finish: <date> · ≈ <μ> <unit> of work (± <σ>)`
|
|
445
|
+
* - Backward: `Expected start: <date> · ≈ <μ> <unit> lead time (± <σ>)`
|
|
446
|
+
* - Unanchored: `≈ <μ> <unit> (± <σ>)`
|
|
447
|
+
* Null when analysis bails out before producing any output.
|
|
448
|
+
*/
|
|
449
|
+
projectSubtitle: string | null;
|
|
450
|
+
/** μ along the M-world critical path (max EF over all activities). */
|
|
451
|
+
projectMu: number | null;
|
|
452
|
+
/** σ along the M-world critical path (sqrt of variance sum). */
|
|
453
|
+
projectSigma: number | null;
|
|
454
|
+
/** Critical-path activity ids in topological order. */
|
|
455
|
+
criticalPath: string[];
|
|
456
|
+
/**
|
|
457
|
+
* Anchored mode: the date all four schedule labels (ES/EF/LS/LF) are
|
|
458
|
+
* computed off. Forward = start-date; backward = end-date − projectMu;
|
|
459
|
+
* null otherwise (no anchor, or backward + TBD upstream).
|
|
460
|
+
*/
|
|
461
|
+
projectStart: string | null;
|
|
462
|
+
/** Populated when `mode === 'monte-carlo'`. */
|
|
463
|
+
monteCarloResult: MonteCarloResult | null;
|
|
464
|
+
/**
|
|
465
|
+
* Per-activity (O, M, P) in canonical days. Always populated; used
|
|
466
|
+
* by Phase 3b Worker / scrubber so the simulator can re-run on a
|
|
467
|
+
* postMessage-cloned ResolvedPert without needing the original
|
|
468
|
+
* ParsedPert or analyzer state.
|
|
469
|
+
*/
|
|
470
|
+
expandedActivities: PertExpandedActivity[];
|
|
471
|
+
diagnostics: DgmoError[];
|
|
472
|
+
error: string | null;
|
|
473
|
+
}
|
|
474
|
+
interface PertLayoutNode {
|
|
475
|
+
readonly id: string;
|
|
476
|
+
readonly x: number;
|
|
477
|
+
readonly y: number;
|
|
478
|
+
readonly width: number;
|
|
479
|
+
readonly height: number;
|
|
480
|
+
}
|
|
481
|
+
interface PertLayoutEdge {
|
|
482
|
+
readonly source: string;
|
|
483
|
+
readonly target: string;
|
|
484
|
+
readonly points: ReadonlyArray<{
|
|
485
|
+
readonly x: number;
|
|
486
|
+
readonly y: number;
|
|
487
|
+
}>;
|
|
488
|
+
}
|
|
489
|
+
interface PertLayoutGroup {
|
|
490
|
+
readonly id: string;
|
|
491
|
+
readonly x: number;
|
|
492
|
+
readonly y: number;
|
|
493
|
+
readonly width: number;
|
|
494
|
+
readonly height: number;
|
|
495
|
+
readonly classification: 'hammock' | 'cluster';
|
|
496
|
+
/**
|
|
497
|
+
* True when the group is currently collapsed. Layout sized this rect
|
|
498
|
+
* as a single rolled-up node and hid the group's member activities
|
|
499
|
+
* from `nodes` / re-routed external edges to land on this rect.
|
|
500
|
+
*/
|
|
501
|
+
readonly collapsed?: boolean;
|
|
502
|
+
}
|
|
503
|
+
interface LayoutResult {
|
|
504
|
+
readonly nodes: readonly PertLayoutNode[];
|
|
505
|
+
readonly edges: readonly PertLayoutEdge[];
|
|
506
|
+
readonly groups: readonly PertLayoutGroup[];
|
|
507
|
+
readonly width: number;
|
|
508
|
+
readonly height: number;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* mulberry32: 32-bit seedable PRNG. Portable, deterministic, ~10 lines.
|
|
513
|
+
* Returns a function that yields [0, 1).
|
|
514
|
+
*/
|
|
515
|
+
declare function mulberry32(seed: number): () => number;
|
|
516
|
+
/**
|
|
517
|
+
* Sample one duration from a Beta-PERT distribution defined by (O, M, P).
|
|
518
|
+
* Zero-variance case (O = M = P) bypasses sampling deterministically.
|
|
519
|
+
*/
|
|
520
|
+
declare function sampleBetaPert(o: number, m: number, p: number, rng: () => number): number;
|
|
521
|
+
interface ExpandedActivity {
|
|
522
|
+
id: string;
|
|
523
|
+
o: number;
|
|
524
|
+
m: number;
|
|
525
|
+
p: number;
|
|
526
|
+
}
|
|
527
|
+
interface SimulateOptions {
|
|
528
|
+
trials: number;
|
|
529
|
+
seed: number;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Build a runnable simulation context from a `ResolvedPert`. The
|
|
533
|
+
* analyzer will call this then invoke `simulateCanonical` /
|
|
534
|
+
* `simulateFast` on the result.
|
|
535
|
+
*/
|
|
536
|
+
declare function buildSimulationContext(resolved: ResolvedPert): {
|
|
537
|
+
predecessors: Map<string, string[]>;
|
|
538
|
+
successors: Map<string, string[]>;
|
|
539
|
+
topo: string[];
|
|
540
|
+
terminals: string[];
|
|
541
|
+
poisoned: Set<string>;
|
|
542
|
+
};
|
|
543
|
+
/**
|
|
544
|
+
* Canonical simulation — N=10000 by default. Used for static export
|
|
545
|
+
* and the "computing…" Worker job in the app.
|
|
546
|
+
*/
|
|
547
|
+
declare function simulateCanonical(resolved: ResolvedPert, expanded: ExpandedActivity[], opts: SimulateOptions): MonteCarloResult;
|
|
548
|
+
/**
|
|
549
|
+
* Fast simulation — N=300 by default. Used by the duration scrubber for
|
|
550
|
+
* sub-100ms re-analysis on each rAF tick.
|
|
551
|
+
*/
|
|
552
|
+
declare function simulateFast(resolved: ResolvedPert, expanded: ExpandedActivity[], opts: SimulateOptions): MonteCarloResult;
|
|
553
|
+
|
|
554
|
+
export { type ExpandedActivity, type LayoutResult, type MonteCarloResult, type NodeDetail, type ParsedPert, type PertActivity, type PertDirection, type PertEdge, type PertExpandedActivity, type PertGroup, type PertLayoutEdge, type PertLayoutGroup, type PertLayoutNode, type PertMilestone, type PertOptions, type ResolvedActivity, type ResolvedGroup, type ResolvedPert, type SimulateOptions, buildSimulationContext, mulberry32, sampleBetaPert, simulateCanonical, simulateFast };
|