@intentius/behold 0.31.0 → 0.32.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.
@@ -4,7 +4,7 @@
4
4
  "pins": [
5
5
  {
6
6
  "package": "@intentius/chant-lexicon-terraform",
7
- "version": "0.124.58"
7
+ "version": "0.124.98"
8
8
  }
9
9
  ],
10
10
  "members": [
@@ -93,7 +93,7 @@ naming both packages, the ranges behold declares, where it looked, and the line
93
93
  that puts them back:
94
94
 
95
95
  ```sh
96
- npm install @intentius/chant-lexicon-terraform@^0.124.58 @cdktn/hcl2json@^0.24.0
96
+ npm install @intentius/chant-lexicon-terraform@^0.124.98 @cdktn/hcl2json@^0.24.0
97
97
  ```
98
98
 
99
99
  The estate is a declared chant workspace, and chant reads a member's kind from
@@ -105,7 +105,7 @@ copy and sets the copy's pin to that version (#484). It says so as it loads:
105
105
  your own declared workspace is different: install the pinned lexicon in its
106
106
  root, the way `chant workspace check` asks.
107
107
 
108
- The pin in `chant.workspace.json` names chant 0.124.58, the release behold
108
+ The pin in `chant.workspace.json` names chant 0.124.98, the release behold
109
109
  depends on (`CHANT_RELEASE` in src/chant-release.ts, behold#1005), so a plain
110
110
  `npm ci` beside behold installs what it pins. That release also carries what
111
111
  promote's dry run on a real root with a `terraform.tfstate` and the drift
@@ -4,7 +4,7 @@
4
4
  "pins": [
5
5
  {
6
6
  "package": "@intentius/chant-lexicon-terraform",
7
- "version": "0.124.58"
7
+ "version": "0.124.98"
8
8
  }
9
9
  ],
10
10
  "members": [
@@ -4,11 +4,11 @@
4
4
  "pins": [
5
5
  {
6
6
  "package": "@intentius/chant-lexicon-terraform",
7
- "version": "0.124.58"
7
+ "version": "0.124.98"
8
8
  },
9
9
  {
10
10
  "package": "@intentius/chant-lexicon-pulumi",
11
- "version": "0.124.58"
11
+ "version": "0.124.98"
12
12
  }
13
13
  ],
14
14
  "members": [
@@ -6,11 +6,11 @@
6
6
  "": {
7
7
  "name": "behold-example-three-cloud",
8
8
  "dependencies": {
9
- "@intentius/chant": "^0.124.58",
10
- "@intentius/chant-lexicon-aws": "^0.124.58",
11
- "@intentius/chant-lexicon-gcp": "^0.124.58",
12
- "@intentius/chant-lexicon-pulumi": "^0.124.58",
13
- "@intentius/chant-lexicon-terraform": "^0.124.58"
9
+ "@intentius/chant": "^0.124.98",
10
+ "@intentius/chant-lexicon-aws": "^0.124.98",
11
+ "@intentius/chant-lexicon-gcp": "^0.124.98",
12
+ "@intentius/chant-lexicon-pulumi": "^0.124.98",
13
+ "@intentius/chant-lexicon-terraform": "^0.124.98"
14
14
  }
15
15
  },
16
16
  "node_modules/@dagrejs/dagre": {
@@ -445,9 +445,9 @@
445
445
  }
446
446
  },
447
447
  "node_modules/@intentius/chant": {
448
- "version": "0.124.58",
449
- "resolved": "https://registry.npmjs.org/@intentius/chant/-/chant-0.124.58.tgz",
450
- "integrity": "sha512-v8I7QJLwQem3F2fWU2hTmZYUVqjBB4BaI+bNAjDOHy1i0Tm1wFmS6Mubp489WQXTKlL25xdOEHB/KTnPq6V2/g==",
448
+ "version": "0.124.98",
449
+ "resolved": "https://registry.npmjs.org/@intentius/chant/-/chant-0.124.98.tgz",
450
+ "integrity": "sha512-Tf1RKkcmrtRd8JOVs73ZxHsXBlnGzpvqat4LvwOBU0zKwKXtd8GaBvJPPoL4qsPbRIu18wpP+q8wr3QcW6N+og==",
451
451
  "license": "Apache-2.0",
452
452
  "dependencies": {
453
453
  "@dagrejs/dagre": "^3.0.0",
@@ -486,22 +486,22 @@
486
486
  }
487
487
  },
488
488
  "node_modules/@intentius/chant-lexicon-aws": {
489
- "version": "0.124.58",
490
- "resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-aws/-/chant-lexicon-aws-0.124.58.tgz",
491
- "integrity": "sha512-b0xQlfDvj4t5CDuvxqXPWmCuzypleDyQ+cKj4NZGsvvd2nUtqR1ZvhIeg8LiXiFUeKFxTjnbYu10W4h6LYCNOQ==",
489
+ "version": "0.124.98",
490
+ "resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-aws/-/chant-lexicon-aws-0.124.98.tgz",
491
+ "integrity": "sha512-8Mi66mguNuN1+oGl7Y4eQUXZvuO2kZHOzvy8HoV+QezLkHqcrLI6RfHGIYJmhGz3oDeLGR7LZUE3OU418khg9w==",
492
492
  "license": "Apache-2.0",
493
493
  "dependencies": {
494
494
  "fflate": "^0.8.2",
495
495
  "js-yaml": "^4.3.1"
496
496
  },
497
497
  "peerDependencies": {
498
- "@intentius/chant": "^0.124.58"
498
+ "@intentius/chant": "^0.124.98"
499
499
  }
500
500
  },
501
501
  "node_modules/@intentius/chant-lexicon-gcp": {
502
- "version": "0.124.58",
503
- "resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-gcp/-/chant-lexicon-gcp-0.124.58.tgz",
504
- "integrity": "sha512-cf3sLKBFtk48469uUin2KiJgRZ0H4obaxJKYD7Fl5+eudRz4u1pVcldyQLjwjmi5I7UPr62Ew8dD020lPw6SSw==",
502
+ "version": "0.124.98",
503
+ "resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-gcp/-/chant-lexicon-gcp-0.124.98.tgz",
504
+ "integrity": "sha512-mqKQJbO8Zucych1v2u35iWkflBkBZt3uutk4MfhFukH3PzGBRDl/7CtCBRT+dKbqbYxxhp6XvXeSCLj/Znb/WQ==",
505
505
  "license": "Apache-2.0",
506
506
  "dependencies": {
507
507
  "@types/js-yaml": "^4.0.9",
@@ -509,26 +509,26 @@
509
509
  "js-yaml": "^4.3.1"
510
510
  },
511
511
  "peerDependencies": {
512
- "@intentius/chant": "^0.124.58"
512
+ "@intentius/chant": "^0.124.98"
513
513
  }
514
514
  },
515
515
  "node_modules/@intentius/chant-lexicon-pulumi": {
516
- "version": "0.124.58",
517
- "resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-pulumi/-/chant-lexicon-pulumi-0.124.58.tgz",
518
- "integrity": "sha512-fWQ1i0V48t6j+rSmHRG3YrM46km4BUPsK6yiJXYqdDkgp7tDnfGQuPNuxW06Gpo7XBK/bmjUE4LNtVBHq6lZbQ==",
516
+ "version": "0.124.98",
517
+ "resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-pulumi/-/chant-lexicon-pulumi-0.124.98.tgz",
518
+ "integrity": "sha512-I/oTgB0qF0P+9pXHTyFUsHMbt7Lza9cptFr9h5bTmj87w+wo/TGFz1MPSbacmdIvhJGc1cLEpEgedfMjZjNxLQ==",
519
519
  "license": "Apache-2.0",
520
520
  "peerDependencies": {
521
- "@intentius/chant": "^0.124.58",
521
+ "@intentius/chant": "^0.124.98",
522
522
  "zod": "^4.3.6"
523
523
  }
524
524
  },
525
525
  "node_modules/@intentius/chant-lexicon-terraform": {
526
- "version": "0.124.58",
527
- "resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-terraform/-/chant-lexicon-terraform-0.124.58.tgz",
528
- "integrity": "sha512-pJVymn/IOwRA6Oial//h7tKTXt5aiAs+4TM+riaczyr3oVoO1CMtKdaz7goSpMc9PeHXnBpDn6E6+d9AYcsi9Q==",
526
+ "version": "0.124.98",
527
+ "resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-terraform/-/chant-lexicon-terraform-0.124.98.tgz",
528
+ "integrity": "sha512-X5/JRKWT/EQctpeonIzNqPEhpn9QmxsKTg7BtOy89pxaurP/ktAE1VIwjAv/uDSGOG8zwNcbSfmZpQ/S4h+DYA==",
529
529
  "license": "Apache-2.0",
530
530
  "peerDependencies": {
531
- "@intentius/chant": "^0.124.58",
531
+ "@intentius/chant": "^0.124.98",
532
532
  "zod": "^4.3.6"
533
533
  }
534
534
  },
@@ -9,10 +9,10 @@
9
9
  "change-set": "tsx scripts/front-door.ts plan --out .front-door/change-set.json"
10
10
  },
11
11
  "dependencies": {
12
- "@intentius/chant": "^0.124.58",
13
- "@intentius/chant-lexicon-aws": "^0.124.58",
14
- "@intentius/chant-lexicon-gcp": "^0.124.58",
15
- "@intentius/chant-lexicon-pulumi": "^0.124.58",
16
- "@intentius/chant-lexicon-terraform": "^0.124.58"
12
+ "@intentius/chant": "^0.124.98",
13
+ "@intentius/chant-lexicon-aws": "^0.124.98",
14
+ "@intentius/chant-lexicon-gcp": "^0.124.98",
15
+ "@intentius/chant-lexicon-pulumi": "^0.124.98",
16
+ "@intentius/chant-lexicon-terraform": "^0.124.98"
17
17
  }
18
18
  }
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "name": "@intentius/behold",
3
- "version": "0.31.0",
3
+ "version": "0.32.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
- "description": "behold — a live control plane on chant. See your whole estate (every substrate in one graph), coloured by drift; act through delegated, gated Ops.",
6
+ "description": "Your infrastructure repo as a graph, from the files. Draws Terraform roots, no state needed.",
7
7
  "bin": {
8
8
  "behold": "./bin/behold.js"
9
9
  },
10
+ "mcpName": "io.github.INTENTIUS/behold",
10
11
  "files": [
11
12
  "bin",
12
13
  "dist",
14
+ "schemas",
13
15
  "web",
14
16
  "example-writes",
15
17
  "example-k8s",
@@ -43,17 +45,23 @@
43
45
  "test": "vitest run",
44
46
  "generate:graph-layout": "tsx src/graph-db/generate-layout.ts",
45
47
  "check:graph-layout": "tsx src/graph-db/generate-layout.ts --check",
46
- "build": "tsx src/graph-db/generate-layout.ts && esbuild src/cli.ts --bundle --platform=node --format=esm --external:hono --external:@hono/node-server --external:@intentius/pinhole --external:@kubernetes/client-node --external:ajv --external:@modelcontextprotocol/sdk --external:@ladybugdb/core --outfile=dist/cli.js && chmod +x dist/cli.js",
48
+ "generate:icons": "tsx src/generate-icons.ts",
49
+ "check:icons": "tsx src/generate-icons.ts --check",
50
+ "check:browser-bundle": "tsx scripts/check-browser-bundle.mts",
51
+ "build": "tsx src/graph-db/generate-layout.ts && tsx src/generate-icons.ts && esbuild src/cli.ts --bundle --platform=node --format=esm --external:hono --external:@hono/node-server --external:@intentius/pinhole --external:@kubernetes/client-node --external:ajv --external:@modelcontextprotocol/sdk --external:@ladybugdb/core --outfile=dist/cli.js && chmod +x dist/cli.js && npm run build:graph",
52
+ "build:graph": "esbuild index=src/graph-package.ts cli=src/graph-bin.ts --bundle --splitting --platform=node --format=esm --external:@intentius/pinhole --external:@intentius/chant-k8s-client --external:@kubernetes/client-node --external:ajv --outdir=packages/graph/dist",
53
+ "check:graph-package": "tsx scripts/graph-package-check.ts",
54
+ "build:viewer": "tsx scripts/build-viewer.mts",
47
55
  "prepare": "npm run build",
48
56
  "prepublishOnly": "npm run build"
49
57
  },
50
58
  "dependencies": {
51
59
  "@cdktn/hcl2json": "^0.24.0",
52
60
  "@hono/node-server": "^2.0.5",
53
- "@intentius/chant": "^0.124.58",
54
- "@intentius/chant-k8s-client": "^0.124.58",
55
- "@intentius/chant-lexicon-terraform": "^0.124.58",
56
- "@intentius/pinhole": "^0.5.0",
61
+ "@intentius/chant": "^0.124.98",
62
+ "@intentius/chant-k8s-client": "^0.124.98",
63
+ "@intentius/chant-lexicon-terraform": "^0.124.98",
64
+ "@intentius/pinhole": "^0.6.0",
57
65
  "@modelcontextprotocol/sdk": "1.30.1",
58
66
  "ajv": "^8.20.0",
59
67
  "hono": "^4.13.13"
@@ -71,8 +79,11 @@
71
79
  }
72
80
  },
73
81
  "devDependencies": {
74
- "@intentius/chant-lexicon-pulumi": "^0.124.58",
75
- "@intentius/chant-lexicon-sql": "^0.124.58",
82
+ "@intentius/chant-lexicon-k8s": "0.124.98",
83
+ "@intentius/chant-lexicon-otel": "0.124.98",
84
+ "@intentius/chant-lexicon-prometheus": "0.124.98",
85
+ "@intentius/chant-lexicon-pulumi": "^0.124.98",
86
+ "@intentius/chant-lexicon-sql": "^0.124.98",
76
87
  "@types/node": "^26.4.1",
77
88
  "esbuild": "^0.28.0",
78
89
  "playwright": "^1.62.1",
@@ -0,0 +1,140 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://intentius.io/behold/schemas/graph/v1/graph.schema.json",
4
+ "title": "behold-graph/1",
5
+ "description": "A behold graph as flat node and edge lists (behold#1066). Field names follow Grafana's node graph panel: a node has id, title, subtitle, mainstat, secondarystat, color and detail__* fields, and an edge has id, source and target, so the panel reads the lists with no transform. Every edge's source and target is the id of a node in the same document. No field holds an absolute path: files are relative to the repository root. Within behold-graph/1 fields are only ever added, and a reader ignores the fields it does not know. A change a reader could not ignore is behold-graph/2, which a behold-graph/1 reader refuses.",
6
+ "type": "object",
7
+ "required": ["schema", "generator", "origin", "cut", "nodes", "edges", "groups", "notes"],
8
+ "properties": {
9
+ "schema": { "const": "behold-graph/1", "description": "The document's version. A reader refuses one it does not know." },
10
+ "generator": {
11
+ "type": "object",
12
+ "description": "The behold that wrote the document and the chant that read the graph.",
13
+ "required": ["behold"],
14
+ "properties": {
15
+ "behold": { "type": "string" },
16
+ "chant": { "type": "string" }
17
+ }
18
+ },
19
+ "origin": {
20
+ "type": "object",
21
+ "description": "What was read.",
22
+ "required": ["dir"],
23
+ "properties": {
24
+ "dir": { "$ref": "#/$defs/relativePath", "description": "The directory read, relative to the repository root. '.' is the root." },
25
+ "rev": { "type": "string", "description": "The revision the graph was read at, when it was not read from the working tree." }
26
+ }
27
+ },
28
+ "cut": {
29
+ "type": "object",
30
+ "description": "Which part of the graph the document holds. 'whole' is every card the view draws; a cut such as 'around' or 'changed' carries its parameters beside kind.",
31
+ "required": ["kind"],
32
+ "properties": { "kind": { "type": "string", "minLength": 1 } }
33
+ },
34
+ "nodes": { "type": "array", "items": { "$ref": "#/$defs/node" } },
35
+ "edges": { "type": "array", "items": { "$ref": "#/$defs/edge" } },
36
+ "groups": { "type": "array", "items": { "$ref": "#/$defs/group" } },
37
+ "notes": { "type": "array", "items": { "$ref": "#/$defs/note" } },
38
+ "layout": {
39
+ "type": "object",
40
+ "description": "Positions a host can draw without laying the graph out again.",
41
+ "required": ["nodes"],
42
+ "properties": {
43
+ "nodes": { "type": "object", "additionalProperties": { "$ref": "#/$defs/point" } },
44
+ "groups": { "type": "object", "additionalProperties": { "$ref": "#/$defs/rect" } }
45
+ }
46
+ }
47
+ },
48
+ "$defs": {
49
+ "relativePath": {
50
+ "type": "string",
51
+ "minLength": 1,
52
+ "not": { "pattern": "^(/|[A-Za-z]:[\\\\/]|\\.\\.(/|$))" }
53
+ },
54
+ "status": { "enum": ["good", "warn", "accent", "neutral", "runtime"] },
55
+ "node": {
56
+ "type": "object",
57
+ "required": ["id", "title", "subtitle", "kind", "lexicon", "attrs"],
58
+ "properties": {
59
+ "id": { "type": "string", "minLength": 1, "description": "The graph IR's node id, unique in the document." },
60
+ "title": { "type": "string", "description": "What the card is titled." },
61
+ "subtitle": { "type": "string", "description": "The tool that declares it: terraform, kubernetes, helm, choudoufu, or the chant lexicon." },
62
+ "kind": { "type": "string", "description": "The resource type." },
63
+ "lexicon": { "type": "string" },
64
+ "box": { "type": "string", "description": "The id of the innermost group the card is drawn in." },
65
+ "file": { "$ref": "#/$defs/relativePath", "description": "The declaring file, relative to the repository root. Absent when behold cannot place it there." },
66
+ "seed": { "type": "boolean", "description": "In an 'around' cut, true on the cards the cut was asked for." },
67
+ "diff": { "enum": ["added", "removed", "changed", "neighbour"], "description": "In a 'changed' cut, what happened to the card between the two revisions, or neighbour for a card kept for being near one that did." },
68
+ "changedAttrs": { "type": "array", "items": { "type": "string" }, "description": "On a changed card, the attribute keys whose values differ between the revisions." },
69
+ "line": { "type": "integer", "minimum": 1 },
70
+ "change": { "type": "string", "description": "What a plan would do to it (create, update, replace, delete), when a plan was read and it changes." },
71
+ "status": { "$ref": "#/$defs/status" },
72
+ "color": { "type": "string", "pattern": "^#[0-9A-Fa-f]{6}$", "description": "A colour for status." },
73
+ "mainstat": { "type": ["string", "number"], "description": "The status in words." },
74
+ "secondarystat": { "type": ["string", "number"] },
75
+ "icon": { "type": "string" },
76
+ "stackOf": { "type": "array", "items": { "type": "string" }, "description": "On a stacked card, the ids of the cards it stands for." },
77
+ "detail__member": { "type": "string", "description": "The workspace member it belongs to." },
78
+ "detail__root": { "type": "string", "description": "The Terraform root that applies it." },
79
+ "detail__namespace": { "type": "string", "description": "The Kubernetes namespace it lives in." },
80
+ "detail__release": { "type": "string", "description": "The Helm release that installs it." },
81
+ "attrs": { "type": "object", "description": "The graph IR's attributes. 'source' is present only when it was asked for." }
82
+ }
83
+ },
84
+ "edge": {
85
+ "type": "object",
86
+ "required": ["id", "source", "target", "kind", "inferred"],
87
+ "properties": {
88
+ "id": { "type": "string", "minLength": 1, "description": "Deterministic, unique in the document." },
89
+ "source": { "type": "string", "description": "The id of the node holding the reference." },
90
+ "target": { "type": "string", "description": "The id of the node it names." },
91
+ "kind": { "type": "string", "description": "The graph IR's edge kind: ref, needs, calls, triggers, includes, extends, or one added later." },
92
+ "inferred": { "type": "boolean", "description": "True when behold or chant joined the two rather than a reader stating it." },
93
+ "rule": { "type": "string", "description": "On an inferred edge, the join that drew it: behold:<pass>, or chant's catalog rule id. On the edge to a placeholder card (a reference that names nothing) and on each edge of a reference that names several candidates, the rule of that reference." },
94
+ "via": { "type": "string", "description": "The consumer-side attribute the reference flows through." },
95
+ "diff": { "enum": ["added", "removed"], "description": "In a 'changed' cut, set when the edge exists in one revision only." }
96
+ }
97
+ },
98
+ "group": {
99
+ "type": "object",
100
+ "required": ["id", "title", "kind"],
101
+ "properties": {
102
+ "id": { "type": "string", "pattern": "^[a-z]+:", "description": "<kind>:<key>, never a node id." },
103
+ "title": { "type": "string" },
104
+ "kind": { "type": "string", "description": "stack (a workspace member or a Terraform root), wave, pipeline, container, or one added later." },
105
+ "parent": { "type": "string", "description": "The group this one is drawn inside." }
106
+ }
107
+ },
108
+ "note": {
109
+ "type": "object",
110
+ "required": ["kind", "text"],
111
+ "properties": {
112
+ "kind": { "type": "string" },
113
+ "text": { "type": "string" },
114
+ "short": { "type": "string" },
115
+ "box": { "type": "string" },
116
+ "count": { "type": "integer", "minimum": 0 }
117
+ }
118
+ },
119
+ "point": {
120
+ "type": "object",
121
+ "required": ["x", "y"],
122
+ "properties": {
123
+ "x": { "type": "number" },
124
+ "y": { "type": "number" },
125
+ "width": { "type": "number" },
126
+ "height": { "type": "number" }
127
+ }
128
+ },
129
+ "rect": {
130
+ "type": "object",
131
+ "required": ["x", "y", "width", "height"],
132
+ "properties": {
133
+ "x": { "type": "number" },
134
+ "y": { "type": "number" },
135
+ "width": { "type": "number" },
136
+ "height": { "type": "number" }
137
+ }
138
+ }
139
+ }
140
+ }
package/web/app.js CHANGED
@@ -9356,7 +9356,7 @@ function wireEdgeHighlight(svgEl, ir) {
9356
9356
  // itself; this fills it in where it did not.
9357
9357
  const viaOf = viaIndex(ir.edges || []);
9358
9358
  // #878: each reference weighed by how it was found (web/edge-weight.js).
9359
- lastEdgeWeights = edgeWeights(ir.edges || [], new Map((ir.nodes || []).map((n) => [n.id, n.kind])));
9359
+ lastEdgeWeights = edgeWeights(ir.edges || [], new Map((ir.nodes || []).map((n) => [n.id, n.kind])), ir.catalog && ir.catalog.rules);
9360
9360
  for (const g of edges) {
9361
9361
  const w = lastEdgeWeights.get(`${g.getAttribute("data-edge-from")}→${g.getAttribute("data-edge-to")}`);
9362
9362
  if (w) g.setAttribute("data-edge-weight", w);
@@ -9369,6 +9369,8 @@ function wireEdgeHighlight(svgEl, ir) {
9369
9369
  if (via) g.setAttribute("data-edge-via", via); // drives the dashed style
9370
9370
  const cross = g.getAttribute("data-edge-cross") === "true";
9371
9371
  if (!g.querySelector("path")) relabelEdgeChip(g, kind, via);
9372
+ // behold#1080: an edge the catalog drew arrives with its tooltip, which names the rule.
9373
+ if (g.querySelector(":scope > title")) continue;
9372
9374
  const title = document.createElementNS(SVGNS, "title");
9373
9375
  title.textContent = edgeTitle(from, to, { kind, via, cross });
9374
9376
  g.insertBefore(title, g.firstChild);
@@ -12187,9 +12189,12 @@ async function initActions() {
12187
12189
  bar.appendChild(pill);
12188
12190
  // #510: other commits' views, when ../history.json sits beside this one.
12189
12191
  // The deploy tab stays hidden unless there is history to pick from.
12190
- mountHistoryPicker(bar).then((picker) => {
12191
- if (picker) document.documentElement.classList.add("static-history");
12192
- });
12192
+ // behold#1068: only when the manifest says a history.json was published; any other export would log a 404.
12193
+ if (manifest && manifest.history) {
12194
+ mountHistoryPicker(bar).then((picker) => {
12195
+ if (picker) document.documentElement.classList.add("static-history");
12196
+ });
12197
+ }
12193
12198
  previewMode = true;
12194
12199
  return; // nothing else in the bar is a read
12195
12200
  }
@@ -0,0 +1,6 @@
1
+ // behold#725: the shared beat paused in a hidden tab, and the shared tooltip for the graph's badges.
2
+ // A file rather than an inline module (behold#1068): a webview's content security policy blocks inline scripts.
3
+ import { installMotion } from "./motion.js";
4
+ import { installTooltips } from "./tooltip.js";
5
+ installMotion();
6
+ installTooltips(document);
@@ -0,0 +1,30 @@
1
+ // Types for web/cut-around.js, for the TypeScript that wraps it (src/graph-cut.ts, #1067).
2
+
3
+ export interface CutGraph {
4
+ nodes: Array<{ id: string }>;
5
+ edges: Array<{ from: string; to: string }>;
6
+ groups?: unknown;
7
+ }
8
+
9
+ export interface CutAroundOptions {
10
+ depth?: number;
11
+ up?: boolean;
12
+ down?: boolean;
13
+ outside?: number;
14
+ inside?: ((node: any) => boolean) | null;
15
+ }
16
+
17
+ export interface CutAroundResult<N, E> {
18
+ nodes: N[];
19
+ edges: E[];
20
+ groups: Record<string, Record<string, string[]>>;
21
+ seeds: string[];
22
+ missing?: string[];
23
+ reason?: string;
24
+ }
25
+
26
+ export function cutAround<N extends { id: string }, E extends { from: string; to: string }>(
27
+ graph: { nodes: N[]; edges: E[]; groups?: unknown },
28
+ startIds: readonly string[],
29
+ opts?: CutAroundOptions,
30
+ ): CutAroundResult<N, E>;
@@ -0,0 +1,138 @@
1
+ // The one walk behind every "cut around" in behold (#1081, and #1067 over a
2
+ // behold-graph/1 document). Plain ESM, no imports at all: a browser host, a
3
+ // Node reader and a test load it the same way.
4
+ //
5
+ // A cut keeps the seeds, what they reach upstream, what reaches them
6
+ // downstream, and the groups (boxes) those nodes sit in. An edge runs from a
7
+ // consumer to what it needs (`from` needs `to`, as chant's IR draws it), so
8
+ // "up" follows `from -> to` and "down" follows `to -> from`. Each direction is
9
+ // its own closure, as chant's `blast:` lens does it: two things that merely
10
+ // share a dependency are not neighbours of each other.
11
+ //
12
+ // Two budgets bound the walk. `depth` counts hops between "inside" nodes. The
13
+ // host says what inside is with `inside(node)`; with none, every node is
14
+ // inside and `outside` never applies, which is the plain depth-bounded cut.
15
+ // `outside` counts hops past the last inside node, so a Kubernetes host can
16
+ // keep two hops beyond the cluster (a service account, the cloud identity it
17
+ // is bound to, the project that owns it) without a long walk through the
18
+ // cloud estate. A hop never goes from outside back to inside.
19
+ //
20
+ // #1067 wraps this: it turns a box id into its member ids, calls cutAround,
21
+ // and adds `cut` and `notes` to the document it returns. Nothing there should
22
+ // walk the graph a second time.
23
+
24
+ /** Adjacency for one direction: node id -> ids it leads to. */
25
+ function adjacency(edges, direction) {
26
+ const next = new Map();
27
+ for (const e of edges || []) {
28
+ const [a, b] = direction === "up" ? [e.from, e.to] : [e.to, e.from];
29
+ if (a === undefined || b === undefined) continue;
30
+ let list = next.get(a);
31
+ if (!list) next.set(a, (list = []));
32
+ list.push(b);
33
+ }
34
+ return next;
35
+ }
36
+
37
+ /** Ids reached walking one direction from `seeds`, seeds included. */
38
+ function reach(next, seeds, byId, depth, outside, inside) {
39
+ const kept = new Set(seeds);
40
+ const insideSeeds = seeds.filter((id) => inside(byId.get(id)));
41
+ const outsideSeeds = seeds.filter((id) => !inside(byId.get(id)));
42
+ // Inside phase: breadth-first to `depth` hops, over inside nodes only.
43
+ const insideKept = new Set(insideSeeds);
44
+ let layer = insideSeeds;
45
+ for (let hop = 0; hop < depth && layer.length; hop++) {
46
+ const following = [];
47
+ for (const id of layer) {
48
+ for (const m of next.get(id) || []) {
49
+ const node = byId.get(m);
50
+ if (!node || !inside(node) || insideKept.has(m)) continue;
51
+ insideKept.add(m);
52
+ following.push(m);
53
+ }
54
+ }
55
+ layer = following;
56
+ }
57
+ for (const id of insideKept) kept.add(id);
58
+ // Outside phase: from every kept inside node and every outside seed, up to
59
+ // `outside` hops through outside nodes. Breadth-first from all of them at
60
+ // once, so a node is reached with the fewest outside hops it can be.
61
+ const seen = new Set(outsideSeeds);
62
+ const expand = (ids) => {
63
+ const following = [];
64
+ for (const id of ids) {
65
+ for (const m of next.get(id) || []) {
66
+ const node = byId.get(m);
67
+ if (!node || inside(node) || seen.has(m)) continue;
68
+ seen.add(m);
69
+ following.push(m);
70
+ }
71
+ }
72
+ return following;
73
+ };
74
+ let wave = expand([...insideKept, ...outsideSeeds]);
75
+ for (let hop = 1; hop <= outside && wave.length; hop++) {
76
+ for (const id of wave) kept.add(id);
77
+ wave = expand(wave);
78
+ }
79
+ return kept;
80
+ }
81
+
82
+ /**
83
+ * Cut `graph` (`{ nodes, edges, groups }`, the `ir` of /api/graph or a
84
+ * behold-graph/1 document) around `startIds`.
85
+ *
86
+ * Options: `depth` (default 1), `up` and `down` (default true), `outside`
87
+ * (default 2, used only when `inside` is given), `inside(node) -> boolean`.
88
+ *
89
+ * Returns `{ nodes, edges, groups, seeds }`. `seeds` are the start ids the
90
+ * graph holds, in the order given. An id the graph does not hold is not
91
+ * silently dropped: with none of them found, `nodes` is empty and `reason`
92
+ * names every missing id; with some found, `missing` lists the rest. Edges are
93
+ * kept only when both ends are kept. `groups` keeps, for each group key, the
94
+ * boxes that still hold a kept node, filtered to the kept ids.
95
+ */
96
+ export function cutAround(graph, startIds, opts = {}) {
97
+ const { depth = 1, up = true, down = true, outside = 2, inside = null } = opts;
98
+ const isInside = typeof inside === "function" ? inside : () => true;
99
+ const nodes = (graph && graph.nodes) || [];
100
+ const edges = (graph && graph.edges) || [];
101
+ const byId = new Map(nodes.map((n) => [n.id, n]));
102
+ const wanted = [...new Set(startIds || [])];
103
+ const seeds = wanted.filter((id) => byId.has(id));
104
+ const missing = wanted.filter((id) => !byId.has(id));
105
+ if (!seeds.length) {
106
+ const reason = wanted.length ? `the graph holds no node ${missing.map((m) => `"${m}"`).join(", ")}` : "no start node was given";
107
+ return { nodes: [], edges: [], groups: {}, seeds: [], missing, reason };
108
+ }
109
+ const kept = new Set(seeds);
110
+ const budget = Math.max(0, Number.isFinite(depth) ? Math.floor(depth) : 0);
111
+ const out = Math.max(0, Number.isFinite(outside) ? Math.floor(outside) : 0);
112
+ if (up) for (const id of reach(adjacency(edges, "up"), seeds, byId, budget, out, isInside)) kept.add(id);
113
+ if (down) for (const id of reach(adjacency(edges, "down"), seeds, byId, budget, out, isInside)) kept.add(id);
114
+ const cut = {
115
+ nodes: nodes.filter((n) => kept.has(n.id)),
116
+ edges: edges.filter((e) => kept.has(e.from) && kept.has(e.to)),
117
+ groups: cutGroups(graph && graph.groups, kept),
118
+ seeds,
119
+ };
120
+ if (missing.length) cut.missing = missing;
121
+ return cut;
122
+ }
123
+
124
+ /** Each `{ key: { box: [ids] } }` group set, reduced to the kept ids; empty boxes drop. */
125
+ function cutGroups(groups, kept) {
126
+ const out = {};
127
+ for (const [key, boxes] of Object.entries(groups || {})) {
128
+ if (!boxes || typeof boxes !== "object" || Array.isArray(boxes)) continue;
129
+ const reduced = {};
130
+ for (const [box, ids] of Object.entries(boxes)) {
131
+ if (!Array.isArray(ids)) continue;
132
+ const keep = ids.filter((id) => kept.has(id));
133
+ if (keep.length) reduced[box] = keep;
134
+ }
135
+ if (Object.keys(reduced).length) out[key] = reduced;
136
+ }
137
+ return out;
138
+ }
@@ -1,5 +1,11 @@
1
- // Types for src/stack-lens.ts, which keeps the traffic path's lines when a card carries a count instead (#877).
1
+ // Types for src/stack-lens.ts, which keeps the traffic path's lines when a card carries a count instead (#877), and src/catalog-draw.ts (#1080).
2
2
  export const WEIGHTS: Record<string, string>;
3
+ export const CATALOG_WEIGHTS: string[];
3
4
  export function isWired(e: { viaAttr?: string }): boolean;
4
- export function edgeWeights(edges?: Array<{ from: string; to: string; kind?: string; viaAttr?: string; inferred?: boolean; origin?: string }>, kindOf?: Map<string, string | undefined>): Map<string, string>;
5
+ export function isCatalogEdge(e: { origin?: string; rule?: string; relation?: string }, rules?: Record<string, unknown>): boolean;
6
+ export function edgeWeights(
7
+ edges?: Array<{ from: string; to: string; kind?: string; viaAttr?: string; inferred?: boolean; origin?: string; rule?: string; relation?: string; dangling?: boolean; ambiguous?: unknown }>,
8
+ kindOf?: Map<string, string | undefined>,
9
+ rules?: Record<string, unknown>,
10
+ ): Map<string, string>;
5
11
  export function weightLegend(weights: Map<string, string>): Array<{ weight: string; label: string; title: string; count: number }>;