@software-dlc/cli 0.192.8 → 0.192.14

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 (61) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/local/app-contract-readers.d.ts.map +1 -1
  3. package/dist/local/app-contract-readers.js +12 -0
  4. package/dist/local/app-contract-readers.js.map +1 -1
  5. package/dist/local/app-tasks-read.d.ts +18 -0
  6. package/dist/local/app-tasks-read.d.ts.map +1 -1
  7. package/dist/local/app-tasks-read.js +24 -10
  8. package/dist/local/app-tasks-read.js.map +1 -1
  9. package/dist/local/health-schema.d.ts +3 -3
  10. package/dist/local/projection-stat-pool.d.ts +2 -0
  11. package/dist/local/projection-stat-pool.d.ts.map +1 -0
  12. package/dist/local/projection-stat-pool.js +96 -0
  13. package/dist/local/projection-stat-pool.js.map +1 -0
  14. package/dist/local/projection.d.ts +25 -1
  15. package/dist/local/projection.d.ts.map +1 -1
  16. package/dist/local/projection.js +124 -42
  17. package/dist/local/projection.js.map +1 -1
  18. package/dist/local/source-evidence/schema.d.ts +2 -2
  19. package/dist/local/task-context-observations.d.ts +8 -8
  20. package/dist/local/task-context-schema.d.ts +1 -1
  21. package/dist/local/workspace-change-commit.d.ts +110 -0
  22. package/dist/local/workspace-change-commit.d.ts.map +1 -0
  23. package/dist/local/workspace-change-commit.js +354 -0
  24. package/dist/local/workspace-change-commit.js.map +1 -0
  25. package/dist/local/workspace-commit-generations.d.ts +12 -4
  26. package/dist/local/workspace-commit-generations.d.ts.map +1 -1
  27. package/dist/local/workspace-commit-generations.js +48 -27
  28. package/dist/local/workspace-commit-generations.js.map +1 -1
  29. package/dist/local/workspace-graph-store.d.ts +30 -1
  30. package/dist/local/workspace-graph-store.d.ts.map +1 -1
  31. package/dist/local/workspace-graph-store.js +86 -1
  32. package/dist/local/workspace-graph-store.js.map +1 -1
  33. package/dist/local/workspace-graph-tree.d.ts +42 -0
  34. package/dist/local/workspace-graph-tree.d.ts.map +1 -1
  35. package/dist/local/workspace-graph-tree.js +189 -0
  36. package/dist/local/workspace-graph-tree.js.map +1 -1
  37. package/dist/local/workspace-overlap-allocation.d.ts +5 -3
  38. package/dist/local/workspace-overlap-allocation.d.ts.map +1 -1
  39. package/dist/local/workspace-overlap-allocation.js +3 -7
  40. package/dist/local/workspace-overlap-allocation.js.map +1 -1
  41. package/dist/local/workspace-overlap-impact.d.ts.map +1 -1
  42. package/dist/local/workspace-overlap-impact.js +12 -1
  43. package/dist/local/workspace-overlap-impact.js.map +1 -1
  44. package/dist/local/workspace-overlap-index.d.ts +179 -0
  45. package/dist/local/workspace-overlap-index.d.ts.map +1 -0
  46. package/dist/local/workspace-overlap-index.js +559 -0
  47. package/dist/local/workspace-overlap-index.js.map +1 -0
  48. package/dist/local/workspace-overlap.d.ts +41 -9
  49. package/dist/local/workspace-overlap.d.ts.map +1 -1
  50. package/dist/local/workspace-overlap.js +336 -140
  51. package/dist/local/workspace-overlap.js.map +1 -1
  52. package/dist/local/workspace-runtime.d.ts +71 -1
  53. package/dist/local/workspace-runtime.d.ts.map +1 -1
  54. package/dist/local/workspace-runtime.js +626 -66
  55. package/dist/local/workspace-runtime.js.map +1 -1
  56. package/package.json +2 -2
  57. package/viewer/assets/index-CTZHobW_.js +389 -0
  58. package/viewer/assets/index-Cck9Xf1-.css +1 -0
  59. package/viewer/index.html +2 -2
  60. package/viewer/assets/index-B5o6MLCA.js +0 -389
  61. package/viewer/assets/index-DJmPW-on.css +0 -1
@@ -0,0 +1,110 @@
1
+ import { type PortableGraph } from '@software-dlc/graph/types';
2
+ import { type ProjectionEntityKind } from './projection.js';
3
+ import { type LocalGraphTreeEdit, type LocalGraphTreeEntity } from './workspace-graph-tree.js';
4
+ import { type LocalEntityChange, type LocalGraphRefIndex } from './workspace-overlap-index.js';
5
+ /**
6
+ * Commit and status on the change (lst-change-commit): which projection files
7
+ * changed since the head's stats were kept, the tree edits they make, whether
8
+ * the change can be checked on its neighborhood, and that neighborhood.
9
+ * Whatever this cannot decide sends the caller to the whole-graph path.
10
+ */
11
+ /** A projection file's stat row as projectionStatRows writes it, less its path. */
12
+ export type ProjectionFileStats = Record<string, string>;
13
+ /** Each file's stat by its path, from projectionStatRows' rows. */
14
+ export declare function projectionFileStats(rows: readonly string[]): ProjectionFileStats;
15
+ type EntityKeyRef = {
16
+ entity_kind: ProjectionEntityKind;
17
+ entity_id: string;
18
+ };
19
+ /**
20
+ * The entity files whose stat differs from the kept one, and the kept ones
21
+ * now gone; null when any other file (tags, package uses, a scope manifest,
22
+ * a stray file) differs, which the whole-graph path reads.
23
+ */
24
+ export declare function changedProjectionFiles(kept: ProjectionFileStats, rows: readonly string[]): {
25
+ present: EntityKeyRef[];
26
+ removed: EntityKeyRef[];
27
+ } | null;
28
+ /**
29
+ * The tree edits a projection's changed files make: each present file's
30
+ * entity in canonical form, and each removed file's entity removed. Null when
31
+ * a file does not parse (the whole-graph compose reports why) or, in a scoped
32
+ * projection, when a file was removed (the compose reads that from its scope).
33
+ */
34
+ export declare function projectionTreeEdits(input: {
35
+ projection_dir: string;
36
+ changes: {
37
+ present: EntityKeyRef[];
38
+ removed: EntityKeyRef[];
39
+ };
40
+ scoped: boolean;
41
+ }): Promise<LocalGraphTreeEdit[] | null>;
42
+ /**
43
+ * Node types some rule checks across the whole graph rather than through
44
+ * references: instanced components, variant sets, journeys and guides, test
45
+ * journeys, workflow placement under a product, native system and context
46
+ * counts, and governance keys and posts. A change touching one takes the
47
+ * whole-graph commit.
48
+ */
49
+ export declare const WHOLE_GRAPH_NODE_TYPES: ReadonlySet<string>;
50
+ /** Whether a node value is one a whole-graph rule reads (see WHOLE_GRAPH_NODE_TYPES). */
51
+ export declare function nodeReachesWholeGraph(value: Record<string, unknown>): boolean;
52
+ /** Why a change cannot be checked on its neighborhood, or null when it can. */
53
+ export declare function wholeGraphReason(input: {
54
+ changes: readonly LocalEntityChange[];
55
+ index: LocalGraphRefIndex;
56
+ }): string | null;
57
+ /**
58
+ * The entities a change's checks read, as entity keys: the changed entities;
59
+ * what their values name; the entities whose values name them; the children
60
+ * of their parents (sibling rules); the entities a graph-wide group puts them
61
+ * with; what each of those names; and every node's and path's parent chain.
62
+ * The head's and the projection's neighborhood graphs both hold exactly these
63
+ * entities, so an issue an entity outside them causes appears in both.
64
+ */
65
+ export declare function neighborhoodKeys(input: {
66
+ changes: readonly LocalEntityChange[];
67
+ index: LocalGraphRefIndex;
68
+ }): Set<string>;
69
+ /** A graph of the given entity values, in canonical (id) order, with the head's graph-level fields. */
70
+ export declare function neighborhoodGraph(values: Iterable<[key: string, value: LocalGraphTreeEntity]>, metadata: Pick<PortableGraph, 'tags' | 'package_uses'>): PortableGraph;
71
+ /**
72
+ * Starting node types a commit warns of when the graph lacks one, and what
73
+ * each stands for.
74
+ */
75
+ export declare const STARTING_NODE_TYPES: Array<[type: string, what: string]>;
76
+ /** An outside system, or one nested in another node, is not the product. */
77
+ export declare function startsTheGraph(node: {
78
+ type?: unknown;
79
+ parentId?: unknown;
80
+ data?: unknown;
81
+ }): boolean;
82
+ /** How many nodes of each starting type start a graph. */
83
+ export declare function startingNodeCounts(nodes: ReadonlyArray<{
84
+ type?: unknown;
85
+ parentId?: unknown;
86
+ data?: unknown;
87
+ }>): Record<string, number>;
88
+ /** The graph shape warnings of a graph whose starting node counts these are. */
89
+ export declare function graphShapeWarningsOfCounts(counts: Record<string, number>): string[];
90
+ /**
91
+ * What a commit keeps of a root it checked, beside the root's derived data:
92
+ * the root's graph holds no broken issue but a node parent's (every root a
93
+ * commit writes, since any other refuses it), and its starting node counts.
94
+ */
95
+ export type LocalCommitCheckRecord = {
96
+ format: 1;
97
+ type: 'commit-check';
98
+ root: string;
99
+ starting: Record<string, number>;
100
+ };
101
+ /**
102
+ * The key a root's check record is kept under. A build's validator decides
103
+ * what the record says, so another build does not read it.
104
+ */
105
+ export declare function commitCheckKey(root: string, build_stamp: string): string;
106
+ export declare function parseCommitCheck(text: string | null, root: string): LocalCommitCheckRecord | null;
107
+ /** Starting node counts after a change, from the counts before it. */
108
+ export declare function startingCountsAfter(before: Record<string, number>, changes: readonly LocalEntityChange[]): Record<string, number>;
109
+ export {};
110
+ //# sourceMappingURL=workspace-change-commit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-change-commit.d.ts","sourceRoot":"","sources":["../../src/local/workspace-change-commit.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAC1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAIL,KAAK,iBAAiB,EAEtB,KAAK,kBAAkB,EACxB,MAAM,8BAA8B,CAAC;AAEtC;;;;;GAKG;AAEH,mFAAmF;AACnF,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEzD,mEAAmE;AACnE,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,mBAAmB,CAOrB;AAED,KAAK,YAAY,GAAG;IAAE,WAAW,EAAE,oBAAoB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7E;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,mBAAmB,EACzB,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB;IAAE,OAAO,EAAE,YAAY,EAAE,CAAC;IAAC,OAAO,EAAE,YAAY,EAAE,CAAA;CAAE,GAAG,IAAI,CAiB7D;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE;IAC/C,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE;QAAE,OAAO,EAAE,YAAY,EAAE,CAAC;QAAC,OAAO,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAC9D,MAAM,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I,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,GAC3E,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASxB;AAED,gFAAgF;AAChF,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,MAAM,EAAE,CAIV;AAED;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,CAAC,CAAC;IACV,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAExE;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,IAAI,EAAE,MAAM,GACX,sBAAsB,GAAG,IAAI,CAc/B;AAED,sEAAsE;AACtE,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,OAAO,EAAE,SAAS,iBAAiB,EAAE,GACpC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAoBxB"}
@@ -0,0 +1,354 @@
1
+ import { GOVERNANCE_NODE_TYPES } from '@software-dlc/graph/types';
2
+ import { readProjectionEntityFiles, projectionEntityOfPath } from './projection.js';
3
+ import { canonicalTreeEntity } from './workspace-graph-tree.js';
4
+ import { entityKey, entityRefs, movesStructure } from './workspace-overlap-index.js';
5
+ /** Each file's stat by its path, from projectionStatRows' rows. */
6
+ export function projectionFileStats(rows) {
7
+ const files = {};
8
+ for (const row of rows) {
9
+ const split = row.indexOf('\0');
10
+ files[row.slice(0, split)] = row.slice(split + 1);
11
+ }
12
+ return files;
13
+ }
14
+ /**
15
+ * The entity files whose stat differs from the kept one, and the kept ones
16
+ * now gone; null when any other file (tags, package uses, a scope manifest,
17
+ * a stray file) differs, which the whole-graph path reads.
18
+ */
19
+ export function changedProjectionFiles(kept, rows) {
20
+ const now = projectionFileStats(rows);
21
+ const present = [];
22
+ const removed = [];
23
+ for (const [path, stat] of Object.entries(now)) {
24
+ if (kept[path] === stat)
25
+ continue;
26
+ const entity = projectionEntityOfPath(path);
27
+ if (!entity)
28
+ return null;
29
+ present.push(entity);
30
+ }
31
+ for (const path of Object.keys(kept)) {
32
+ if (path in now)
33
+ continue;
34
+ const entity = projectionEntityOfPath(path);
35
+ if (!entity)
36
+ return null;
37
+ removed.push(entity);
38
+ }
39
+ return { present, removed };
40
+ }
41
+ /**
42
+ * The tree edits a projection's changed files make: each present file's
43
+ * entity in canonical form, and each removed file's entity removed. Null when
44
+ * a file does not parse (the whole-graph compose reports why) or, in a scoped
45
+ * projection, when a file was removed (the compose reads that from its scope).
46
+ */
47
+ export async function projectionTreeEdits(input) {
48
+ if (input.scoped && input.changes.removed.length > 0)
49
+ return null;
50
+ const edits = input.changes.removed.map((key) => ({
51
+ ...key,
52
+ value: null
53
+ }));
54
+ const files = await readProjectionEntityFiles(input.projection_dir, input.changes.present);
55
+ for (const file of files) {
56
+ if (file.state !== 'entity') {
57
+ // A file removed after the stat reads as removed; one that does not parse is the compose's to report.
58
+ if (file.state === 'invalid' || input.scoped)
59
+ return null;
60
+ edits.push({
61
+ entity_kind: file.entity_kind,
62
+ entity_id: file.entity_id,
63
+ value: null
64
+ });
65
+ continue;
66
+ }
67
+ let value;
68
+ try {
69
+ value = canonicalTreeEntity(file.entity_kind, file.value);
70
+ }
71
+ catch {
72
+ return null;
73
+ }
74
+ edits.push({
75
+ entity_kind: file.entity_kind,
76
+ entity_id: file.entity_id,
77
+ value
78
+ });
79
+ }
80
+ return edits;
81
+ }
82
+ /**
83
+ * Node types some rule checks across the whole graph rather than through
84
+ * references: instanced components, variant sets, journeys and guides, test
85
+ * journeys, workflow placement under a product, native system and context
86
+ * counts, and governance keys and posts. A change touching one takes the
87
+ * whole-graph commit.
88
+ */
89
+ export const WHOLE_GRAPH_NODE_TYPES = new Set([
90
+ 'ui_component_definition',
91
+ 'graph_variant_set',
92
+ 'story',
93
+ 'start',
94
+ 'end',
95
+ 'process',
96
+ 'decision',
97
+ 'test',
98
+ 'product',
99
+ 'system',
100
+ 'context',
101
+ // A theme turns on colour checks for every UI node under it, at any depth.
102
+ 'app',
103
+ 'website',
104
+ ...GOVERNANCE_NODE_TYPES
105
+ ]);
106
+ function record(value) {
107
+ return value && typeof value === 'object' && !Array.isArray(value)
108
+ ? value
109
+ : null;
110
+ }
111
+ /** Whether a node value is one a whole-graph rule reads (see WHOLE_GRAPH_NODE_TYPES). */
112
+ export function nodeReachesWholeGraph(value) {
113
+ if (typeof value.type === 'string' && WHOLE_GRAPH_NODE_TYPES.has(value.type))
114
+ return true;
115
+ const data = record(value.data);
116
+ const domain = record(data?.data);
117
+ // A guide reads the journeys; variant set data misplaced on any node is checked against every set.
118
+ return (domain?.guide !== undefined ||
119
+ data?.guide !== undefined ||
120
+ domain?.graph_variant_set !== undefined);
121
+ }
122
+ /** Why a change cannot be checked on its neighborhood, or null when it can. */
123
+ export function wholeGraphReason(input) {
124
+ if (movesStructure({ changes: [...input.changes], metadata_changed: false }))
125
+ return 'moves a node parent, path parent or path anchor';
126
+ const changed_nodes = new Map();
127
+ for (const change of input.changes) {
128
+ if (change.entity_kind === 'path' || change.entity_kind === 'path_relation')
129
+ return 'changes a path';
130
+ if (change.entity_kind === 'edge' && input.index.hasPaths)
131
+ return 'changes an edge of a graph with paths';
132
+ if (change.entity_kind === 'node') {
133
+ changed_nodes.set(change.entity_id.toLowerCase(), change.after);
134
+ for (const value of [change.before, change.after]) {
135
+ if (value && nodeReachesWholeGraph(value))
136
+ return 'touches a node a graph-wide rule reads';
137
+ }
138
+ }
139
+ }
140
+ const typeOf = (id) => {
141
+ const lower = id.toLowerCase();
142
+ if (changed_nodes.has(lower)) {
143
+ const value = changed_nodes.get(lower);
144
+ return typeof value?.type === 'string' ? value.type : undefined;
145
+ }
146
+ return (input.index.refs.get(entityKey('node', lower))?.type ??
147
+ input.index.refs.get(entityKey('node', id))?.type);
148
+ };
149
+ for (const change of input.changes) {
150
+ if (change.entity_kind !== 'edge')
151
+ continue;
152
+ for (const value of [change.before, change.after]) {
153
+ if (!value)
154
+ continue;
155
+ for (const end of [value.source, value.target]) {
156
+ const type = typeof end === 'string' ? typeOf(end) : undefined;
157
+ if (type && WHOLE_GRAPH_NODE_TYPES.has(type))
158
+ return 'changes an edge of a node a graph-wide rule reads';
159
+ }
160
+ }
161
+ }
162
+ return null;
163
+ }
164
+ const KINDS = [
165
+ 'node',
166
+ 'edge',
167
+ 'path',
168
+ 'path_relation'
169
+ ];
170
+ /** Longest parent chain walked; deeper chains are cut, as the validator's walks are. */
171
+ const ANCESTOR_LIMIT = 64;
172
+ /**
173
+ * The entities a change's checks read, as entity keys: the changed entities;
174
+ * what their values name; the entities whose values name them; the children
175
+ * of their parents (sibling rules); the entities a graph-wide group puts them
176
+ * with; what each of those names; and every node's and path's parent chain.
177
+ * The head's and the projection's neighborhood graphs both hold exactly these
178
+ * entities, so an issue an entity outside them causes appears in both.
179
+ */
180
+ export function neighborhoodKeys(input) {
181
+ const { index } = input;
182
+ const changed_refs = new Map();
183
+ for (const change of input.changes) {
184
+ const key = entityKey(change.entity_kind, change.entity_id);
185
+ changed_refs.set(key, [change.before, change.after].flatMap((value) => value ? [entityRefs(change.entity_kind, value)] : []));
186
+ }
187
+ const refsOf = (key) => changed_refs.get(key) ??
188
+ (index.refs.has(key) ? [index.refs.get(key)] : []);
189
+ const keysOfId = (id) => KINDS.map((kind) => entityKey(kind, id)).filter((key) => index.refs.has(key) || changed_refs.has(key));
190
+ const keys = new Set(changed_refs.keys());
191
+ const named = (refs) => [
192
+ ...refs.ids,
193
+ ...[refs.parent, refs.source, refs.target, refs.left, refs.right].filter((id) => typeof id === 'string'),
194
+ ...(refs.anchors ?? [])
195
+ ].flatMap((id) => keysOfId(id.toLowerCase()).concat(keysOfId(id)));
196
+ for (const [key, all] of changed_refs) {
197
+ const id = key.slice(key.indexOf(':') + 1);
198
+ for (const referrer of index.referrers(id))
199
+ keys.add(referrer);
200
+ for (const refs of all) {
201
+ for (const other of named(refs))
202
+ keys.add(other);
203
+ for (const peer of index.peers(refs))
204
+ keys.add(peer);
205
+ if (key.startsWith('node:') && refs.parent) {
206
+ for (const sibling of index.referrers(refs.parent)) {
207
+ if (sibling.startsWith('node:'))
208
+ keys.add(sibling);
209
+ }
210
+ }
211
+ }
212
+ }
213
+ // One step out from every entity held, so a held entity's references resolve.
214
+ for (const key of [...keys]) {
215
+ for (const refs of refsOf(key))
216
+ for (const other of named(refs))
217
+ keys.add(other);
218
+ }
219
+ // Every node's and path's parent chain, before and after, with what each
220
+ // ancestor names.
221
+ const walked = new Set();
222
+ const stack = [...keys]
223
+ .filter((key) => key.startsWith('node:') || key.startsWith('path:'))
224
+ .map((key) => [key, 0]);
225
+ while (stack.length > 0) {
226
+ const [key, depth] = stack.pop();
227
+ if (walked.has(key) || depth > ANCESTOR_LIMIT)
228
+ continue;
229
+ walked.add(key);
230
+ const kind = key.slice(0, key.indexOf(':'));
231
+ for (const refs of refsOf(key)) {
232
+ if (!refs.parent)
233
+ continue;
234
+ const parent_key = entityKey(kind, refs.parent);
235
+ if (!index.refs.has(parent_key) && !changed_refs.has(parent_key))
236
+ continue;
237
+ if (!keys.has(parent_key)) {
238
+ keys.add(parent_key);
239
+ for (const ancestor_refs of refsOf(parent_key)) {
240
+ for (const other of named(ancestor_refs))
241
+ keys.add(other);
242
+ }
243
+ }
244
+ stack.push([parent_key, depth + 1]);
245
+ }
246
+ }
247
+ return keys;
248
+ }
249
+ const LIST_KEY = {
250
+ node: 'nodes',
251
+ edge: 'edges',
252
+ path: 'paths',
253
+ path_relation: 'path_relations'
254
+ };
255
+ /** A graph of the given entity values, in canonical (id) order, with the head's graph-level fields. */
256
+ export function neighborhoodGraph(values, metadata) {
257
+ const lists = {
258
+ node: [],
259
+ edge: [],
260
+ path: [],
261
+ path_relation: []
262
+ };
263
+ for (const [key, value] of values) {
264
+ lists[key.slice(0, key.indexOf(':'))].push(value);
265
+ }
266
+ const graph = {
267
+ tags: metadata.tags ?? [],
268
+ ...(metadata.package_uses?.length
269
+ ? { package_uses: metadata.package_uses }
270
+ : {})
271
+ };
272
+ for (const kind of KINDS) {
273
+ graph[LIST_KEY[kind]] = lists[kind].sort((left, right) => left.id.localeCompare(right.id));
274
+ }
275
+ return graph;
276
+ }
277
+ /**
278
+ * Starting node types a commit warns of when the graph lacks one, and what
279
+ * each stands for.
280
+ */
281
+ export const STARTING_NODE_TYPES = [
282
+ ['system', 'the product'],
283
+ ['actor', 'the people and outside systems that use it']
284
+ ];
285
+ /** An outside system, or one nested in another node, is not the product. */
286
+ export function startsTheGraph(node) {
287
+ if (node.type !== 'system')
288
+ return true;
289
+ const system = record(record(record(node.data)?.data)?.system);
290
+ return !node.parentId && system?.external !== true;
291
+ }
292
+ /** How many nodes of each starting type start a graph. */
293
+ export function startingNodeCounts(nodes) {
294
+ const counts = {};
295
+ for (const node of nodes) {
296
+ if (typeof node.type !== 'string')
297
+ continue;
298
+ if (!STARTING_NODE_TYPES.some(([type]) => type === node.type))
299
+ continue;
300
+ if (!startsTheGraph(node))
301
+ continue;
302
+ counts[node.type] = (counts[node.type] ?? 0) + 1;
303
+ }
304
+ return counts;
305
+ }
306
+ /** The graph shape warnings of a graph whose starting node counts these are. */
307
+ export function graphShapeWarningsOfCounts(counts) {
308
+ return STARTING_NODE_TYPES.filter(([type]) => !(counts[type] ?? 0)).map(([type, what]) => `The graph has no ${type} node for ${what}.`);
309
+ }
310
+ /**
311
+ * The key a root's check record is kept under. A build's validator decides
312
+ * what the record says, so another build does not read it.
313
+ */
314
+ export function commitCheckKey(root, build_stamp) {
315
+ return `${build_stamp}\u0000commit-check-v1\u0000${root}`;
316
+ }
317
+ export function parseCommitCheck(text, root) {
318
+ if (text === null)
319
+ return null;
320
+ try {
321
+ const parsed = JSON.parse(text);
322
+ return parsed.format === 1 &&
323
+ parsed.type === 'commit-check' &&
324
+ parsed.root === root &&
325
+ parsed.starting &&
326
+ typeof parsed.starting === 'object'
327
+ ? parsed
328
+ : null;
329
+ }
330
+ catch {
331
+ return null;
332
+ }
333
+ }
334
+ /** Starting node counts after a change, from the counts before it. */
335
+ export function startingCountsAfter(before, changes) {
336
+ const counts = { ...before };
337
+ for (const change of changes) {
338
+ if (change.entity_kind !== 'node')
339
+ continue;
340
+ for (const [value, step] of [
341
+ [change.before, -1],
342
+ [change.after, 1]
343
+ ]) {
344
+ if (!value)
345
+ continue;
346
+ const node = value;
347
+ for (const [type, count] of Object.entries(startingNodeCounts([node]))) {
348
+ counts[type] = (counts[type] ?? 0) + step * count;
349
+ }
350
+ }
351
+ }
352
+ return counts;
353
+ }
354
+ //# sourceMappingURL=workspace-change-commit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-change-commit.js","sourceRoot":"","sources":["../../src/local/workspace-change-commit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EAEtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,mBAAmB,EAGpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,SAAS,EACT,UAAU,EACV,cAAc,EAIf,MAAM,8BAA8B,CAAC;AAYtC,mEAAmE;AACnE,MAAM,UAAU,mBAAmB,CACjC,IAAuB;IAEvB,MAAM,KAAK,GAAwB,EAAE,CAAC;IACtC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,E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AAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC;YACpD,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -8,9 +8,13 @@ import type { LocalWorkspaceStoreDatabase } from './workspace-store-database.js'
8
8
  * higher generation to a lower one, which is what lets a merge base search
9
9
  * stop early.
10
10
  *
11
- * A commit whose ancestry reaches a parent in neither table has no generation:
12
- * the parent could arrive later with a larger one. Callers take the full walk
13
- * for such a commit. Rows are filled lazily, reading each missing commit once,
11
+ * An id in neither table is a root, as both walks read it (they find no
12
+ * parents): a store's first head is a bare graph root, not a commit, so every
13
+ * history begun by sdlc workspace init starts at one. Its generation counts
14
+ * its portable mapping, if it has one, like a local commit's. Only an id
15
+ * reached as the parent of a portable commit, whose fetched history may
16
+ * deepen later, has no generation; neither does anything above it, and
17
+ * callers take the full walk for such a commit. Rows are filled lazily, reading each missing commit once,
14
18
  * and are never rewritten except when a portable mapping added after a fill
15
19
  * breaks the order (an external parent mapped to a deeper remote history):
16
20
  * then the table is cleared and refilled on demand. Fills and mapping checks
@@ -29,6 +33,7 @@ export declare class LocalCommitGenerations {
29
33
  constructor(database: LocalWorkspaceStoreDatabase);
30
34
  /** The stored generation of a commit, filling its ancestry if needed. */
31
35
  generation(commit_id: string): number | null;
36
+ private inTables;
32
37
  /**
33
38
  * Checks the portable mappings added since the last check. A mapping whose
34
39
  * stored local generation does not sit above its portable commit's (or whose
@@ -54,7 +59,10 @@ export declare class LocalCommitGenerations {
54
59
  private locked;
55
60
  private stored;
56
61
  private state;
57
- /** The parents a generation counts, or null for a commit in neither table. */
62
+ /**
63
+ * The parents a generation counts. An id in neither table is a root, or
64
+ * null when it was reached as a portable commit's parent.
65
+ */
58
66
  private node;
59
67
  /**
60
68
  * Fills the generations of a commit's unfilled ancestry in one pass, each
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-commit-generations.d.ts","sourceRoot":"","sources":["../../src/local/workspace-commit-generations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAKjF;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,sBAAsB;IASrB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IARrC,sEAAsE;IACtE,cAAc,SAAK;IACnB,6EAA6E;IAC7E,OAAO,CAAC,SAAS,CAAS;IAC1B,2EAA2E;IAC3E,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAC/C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAgC;gBAE9B,QAAQ,EAAE,2BAA2B;IAElE,yEAAyE;IACzE,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAO5C;;;;;OAKG;IACH,aAAa,IAAI,IAAI;IAwCrB,OAAO,CAAC,aAAa;IAOrB;;;OAGG;IACH,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI;IAY5E,OAAO,CAAC,SAAS;IASjB;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM;IAqCd,OAAO,CAAC,MAAM;IAOd,OAAO,CAAC,KAAK;IAOb,8EAA8E;IAC9E,OAAO,CAAC,IAAI;IA6BZ;;;;OAIG;IACH,OAAO,CAAC,IAAI;CA2Eb"}
1
+ {"version":3,"file":"workspace-commit-generations.d.ts","sourceRoot":"","sources":["../../src/local/workspace-commit-generations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAUjF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,sBAAsB;IASrB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IARrC,sEAAsE;IACtE,cAAc,SAAK;IACnB,6EAA6E;IAC7E,OAAO,CAAC,SAAS,CAAS;IAC1B,2EAA2E;IAC3E,OAAO,CAAC,QAAQ,CA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