@clear-capabilities/agentic-security-scanner 0.145.0 → 0.147.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 (162) hide show
  1. package/CHANGELOG.md +139 -0
  2. package/bin/agentic-security.js +3508 -69
  3. package/dist/1122.index.js +702 -0
  4. package/dist/{301.index.js → 1301.index.js} +2 -2
  5. package/dist/1379.index.js +591 -0
  6. package/dist/{444.index.js → 1444.index.js} +2 -2
  7. package/dist/{660.index.js → 1660.index.js} +2 -2
  8. package/dist/{700.index.js → 1700.index.js} +2 -2
  9. package/dist/{905.index.js → 1905.index.js} +3 -3
  10. package/dist/{920.index.js → 1920.index.js} +3 -3
  11. package/dist/{238.index.js → 2238.index.js} +3 -3
  12. package/dist/{271.index.js → 2271.index.js} +2 -2
  13. package/dist/{985.index.js → 2376.index.js} +1260 -340
  14. package/dist/2432.index.js +793 -0
  15. package/dist/2659.index.js +93 -0
  16. package/dist/{826.index.js → 2826.index.js} +2 -2
  17. package/dist/{830.index.js → 2830.index.js} +2 -2
  18. package/dist/2923.index.js +298 -0
  19. package/dist/{1.index.js → 3001.index.js} +5 -5
  20. package/dist/{117.index.js → 3117.index.js} +3 -3
  21. package/dist/3180.index.js +307 -0
  22. package/dist/3276.index.js +117 -0
  23. package/dist/{415.index.js → 3415.index.js} +2 -2
  24. package/dist/{499.index.js → 3499.index.js} +2 -2
  25. package/dist/3518.index.js +450 -0
  26. package/dist/{526.index.js → 3526.index.js} +5 -5
  27. package/dist/{736.index.js → 3736.index.js} +4 -4
  28. package/dist/{839.index.js → 3839.index.js} +4 -4
  29. package/dist/{113.index.js → 4113.index.js} +5 -5
  30. package/dist/{265.index.js → 4265.index.js} +2 -2
  31. package/dist/{384.index.js → 4384.index.js} +3 -3
  32. package/dist/4547.index.js +268 -0
  33. package/dist/4863.index.js +422 -0
  34. package/dist/{970.index.js → 4970.index.js} +2 -2
  35. package/dist/5051.index.js +770 -0
  36. package/dist/{144.index.js → 5144.index.js} +5 -5
  37. package/dist/{333.index.js → 5333.index.js} +3 -3
  38. package/dist/5343.index.js +185 -0
  39. package/dist/5350.index.js +866 -0
  40. package/dist/5561.index.js +436 -0
  41. package/dist/{637.index.js → 5637.index.js} +3 -3
  42. package/dist/{449.index.js → 5830.index.js} +2 -2
  43. package/dist/6626.index.js +532 -0
  44. package/dist/6662.index.js +297 -0
  45. package/dist/{675.index.js → 6675.index.js} +5 -5
  46. package/dist/{730.index.js → 6730.index.js} +6 -6
  47. package/dist/6829.index.js +225 -0
  48. package/dist/6944.index.js +130 -0
  49. package/dist/{178.index.js → 7178.index.js} +3 -3
  50. package/dist/{227.index.js → 7227.index.js} +2 -2
  51. package/dist/7310.index.js +520 -0
  52. package/dist/{552.index.js → 7552.index.js} +4 -4
  53. package/dist/7709.index.js +78 -0
  54. package/dist/8218.index.js +160 -0
  55. package/dist/{476.index.js → 8476.index.js} +4 -4
  56. package/dist/{513.index.js → 8513.index.js} +5 -5
  57. package/dist/{520.index.js → 8520.index.js} +2 -2
  58. package/dist/{718.index.js → 8718.index.js} +2 -2
  59. package/dist/{752.index.js → 8752.index.js} +2 -2
  60. package/dist/8846.index.js +100 -0
  61. package/dist/{435.index.js → 9091.index.js} +560 -189
  62. package/dist/{207.index.js → 9207.index.js} +2 -2
  63. package/dist/{220.index.js → 9220.index.js} +2 -2
  64. package/dist/9390.index.js +163 -0
  65. package/dist/{503.index.js → 9503.index.js} +2 -2
  66. package/dist/{801.index.js → 9801.index.js} +2 -2
  67. package/dist/{824.index.js → 9824.index.js} +2 -2
  68. package/dist/agentic-security.mjs +16 -16
  69. package/dist/agentic-security.mjs.sha256 +1 -1
  70. package/dist/compliance-frameworks/hipaa-security-rule.json +3 -2
  71. package/package.json +12 -5
  72. package/src/dataflow/CLAUDE.md +1 -1
  73. package/src/dataflow/catalog.js +42 -0
  74. package/src/dataflow/orm-write-catalog.js +175 -0
  75. package/src/engine.js +92 -1
  76. package/src/ir/CLAUDE.md +1 -0
  77. package/src/ir/chrome-probe.mjs +150 -0
  78. package/src/ir/parser-js.js +94 -7
  79. package/src/lineage/CLAUDE.md +1203 -0
  80. package/src/lineage/DESIGN_DESTINATION_RESOLVER.md +156 -0
  81. package/src/lineage/DESIGN_GRAPH_BUILDER.md +938 -0
  82. package/src/lineage/DESIGN_HANDLING_ANALYZER.md +355 -0
  83. package/src/lineage/DESIGN_INTRAPROCEDURAL.md +628 -0
  84. package/src/lineage/DESIGN_PATH_PROVENANCE.md +3451 -0
  85. package/src/lineage/DESIGN_QUEUE_DETAIL.md +120 -0
  86. package/src/lineage/DESIGN_REGISTRIES.md +880 -0
  87. package/src/lineage/DESIGN_STORE_DETAIL.md +143 -0
  88. package/src/lineage/DESIGN_TRANSIT_PROTECTION.md +245 -0
  89. package/src/lineage/classification.js +56 -0
  90. package/src/lineage/coverage.js +658 -0
  91. package/src/lineage/cross-repo-link.js +107 -0
  92. package/src/lineage/dataflow-graph.schema.json +184 -0
  93. package/src/lineage/decision-story.js +206 -0
  94. package/src/lineage/drift-policy.js +279 -0
  95. package/src/lineage/driver.js +135 -0
  96. package/src/lineage/engine.js +992 -0
  97. package/src/lineage/export-briefing.js +628 -0
  98. package/src/lineage/export-csv.js +62 -0
  99. package/src/lineage/export-json.js +238 -0
  100. package/src/lineage/export-privacy.js +258 -0
  101. package/src/lineage/federation-loader.js +111 -0
  102. package/src/lineage/field-identity.js +78 -0
  103. package/src/lineage/fixtures/build-flagship-fixture.mjs +272 -0
  104. package/src/lineage/fixtures/flagship-graph.json +1453 -0
  105. package/src/lineage/flow-grade.js +221 -0
  106. package/src/lineage/governance-edit.js +169 -0
  107. package/src/lineage/graph-builder.js +1114 -0
  108. package/src/lineage/graph-diff.js +431 -0
  109. package/src/lineage/graph-snapshot.js +180 -0
  110. package/src/lineage/handling-analyzer.js +168 -0
  111. package/src/lineage/ids.js +349 -0
  112. package/src/lineage/impact-assessment.js +76 -0
  113. package/src/lineage/impact-engine.js +268 -0
  114. package/src/lineage/index.js +281 -0
  115. package/src/lineage/language-coverage-tiers.js +58 -0
  116. package/src/lineage/obligation-mapping.js +126 -0
  117. package/src/lineage/obligation-predicates.js +235 -0
  118. package/src/lineage/observation-adapters.js +282 -0
  119. package/src/lineage/observation-correlation.js +622 -0
  120. package/src/lineage/observation-store.js +497 -0
  121. package/src/lineage/path-query.js +410 -0
  122. package/src/lineage/path-store.js +400 -0
  123. package/src/lineage/protection.js +53 -0
  124. package/src/lineage/recipient-profile.js +192 -0
  125. package/src/lineage/recipient-registry.js +394 -0
  126. package/src/lineage/redact-graph.js +224 -0
  127. package/src/lineage/remediation.js +417 -0
  128. package/src/lineage/resolve-destination.js +91 -0
  129. package/src/lineage/runtime-observation.js +464 -0
  130. package/src/lineage/scenario-diff.js +84 -0
  131. package/src/lineage/scenario-engine.js +251 -0
  132. package/src/lineage/scenario.js +101 -0
  133. package/src/lineage/schema.js +167 -0
  134. package/src/lineage/sink-registry.js +427 -0
  135. package/src/lineage/source-registry.js +357 -0
  136. package/src/lineage/source-seeding.js +212 -0
  137. package/src/lineage/summaries.js +590 -0
  138. package/src/lineage/transform-catalog.js +397 -0
  139. package/src/lineage/transit-protection.js +150 -0
  140. package/src/lineage/validate.js +285 -0
  141. package/src/mcp/CLAUDE.md +7 -1
  142. package/src/mcp/dataflow-tools.js +160 -0
  143. package/src/mcp/server.js +1 -1
  144. package/src/mcp/tools.js +2 -1
  145. package/src/pipeline/scan-health.js +19 -1
  146. package/src/posture/CLAUDE.md +19 -0
  147. package/src/posture/artifact-registry.js +52 -0
  148. package/src/posture/auditor-walkthrough.js +76 -0
  149. package/src/posture/compliance-frameworks/hipaa-security-rule.json +3 -2
  150. package/src/posture/obligation-evidence-pack.js +202 -0
  151. package/src/posture/remediation-ledger.js +337 -0
  152. package/src/server/CLAUDE.md +47 -0
  153. package/src/server/graph-loader.js +141 -0
  154. package/src/server/http-server.js +325 -0
  155. package/src/server/routes.js +129 -0
  156. package/src/server/security.js +111 -0
  157. package/src/server/static-assets.js +139 -0
  158. package/dist/11.index.js +0 -353
  159. package/dist/259.index.js +0 -975
  160. package/dist/317.index.js +0 -300
  161. package/dist/609.index.js +0 -741
  162. package/dist/838.index.js +0 -152
@@ -0,0 +1,422 @@
1
+ export const id = 4863;
2
+ export const ids = [4863];
3
+ export const modules = {
4
+
5
+ /***/ 4863:
6
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
+
8
+
9
+ // EXPORTS
10
+ __webpack_require__.d(__webpack_exports__, {
11
+ loadRemoteGraphExport: () => (/* binding */ loadRemoteGraphExport)
12
+ });
13
+
14
+ // EXTERNAL MODULE: external "node:fs"
15
+ var external_node_fs_ = __webpack_require__(3024);
16
+ // EXTERNAL MODULE: ./src/lineage/schema.js
17
+ var schema = __webpack_require__(4073);
18
+ // EXTERNAL MODULE: ./src/lineage/protection.js
19
+ var protection = __webpack_require__(965);
20
+ // EXTERNAL MODULE: ./src/lineage/classification.js
21
+ var classification = __webpack_require__(2602);
22
+ ;// CONCATENATED MODULE: ./src/lineage/validate.js
23
+ //
24
+ // Structural validator for DataFlowGraph v1 (PRD section 10). Hand-rolled
25
+ // rather than a generic JSON-Schema interpreter + a new `ajv`-style
26
+ // dependency, matching this codebase's existing preference for
27
+ // hand-rolled implementations over new runtime deps (see every parser in
28
+ // scanner/src/ir/). scanner/src/lineage/dataflow-graph.schema.json (Task
29
+ // 6) is the authoritative JSON Schema document for external interop /
30
+ // documentation; this file is what the engine actually calls at graph-
31
+ // build phase 12 (PRD 18.3: "Validate the graph contract and freeze it
32
+ // before rendering").
33
+ //
34
+ // Never throws. A malformed top-level input produces one error and
35
+ // returns early; a malformed nested entity is skipped for further
36
+ // structural checks on ITSELF but does not stop validation of siblings.
37
+
38
+
39
+
40
+
41
+
42
+ function _err(errors, path, message) {
43
+ errors.push({ path, message });
44
+ }
45
+
46
+ function _requireArray(graph, key, errors) {
47
+ if (!Array.isArray(graph[key])) _err(errors, `$.${key}`, `${key} must be an array`);
48
+ }
49
+
50
+ function _requireObject(graph, key, errors) {
51
+ if (typeof graph[key] !== 'object' || graph[key] === null || Array.isArray(graph[key])) {
52
+ _err(errors, `$.${key}`, `${key} must be an object`);
53
+ }
54
+ }
55
+
56
+ const ID_PREFIXES = {
57
+ node: /^node:/,
58
+ edge: /^edge:/,
59
+ data: /^data:/,
60
+ flow: /^flow:/,
61
+ transform: /^transform:/,
62
+ evidence: /^evidence:/,
63
+ };
64
+
65
+ function _validateNode(node, idx, errors, seenIds) {
66
+ const path = (suffix) => `$.nodes[${idx}]${suffix}`;
67
+ if (!node || typeof node !== 'object') { _err(errors, path(''), 'node must be an object'); return; }
68
+ if (typeof node.id !== 'string' || !node.id) _err(errors, path('.id'), 'node.id is required');
69
+ else {
70
+ if (!ID_PREFIXES.node.test(node.id)) _err(errors, path('.id'), `node.id must start with "node:"`);
71
+ seenIds.add(node.id);
72
+ }
73
+ if (!schema/* NODE_KINDS */.xA.includes(node.kind)) _err(errors, path('.kind'), `unrecognized node kind "${node.kind}"`);
74
+ // node.subtype is optional and may be `null` — an `unsupported`-coverage
75
+ // node (e.g. a sink registry decision with `category: null`, PRD 6.4/
76
+ // DESIGN_REGISTRIES.md §9.0) legitimately carries no subtype at all,
77
+ // either as an absent field or an explicit `null`; only a present,
78
+ // non-null, non-string value (a number, object, array, etc.) is invalid.
79
+ if (Object.prototype.hasOwnProperty.call(node, 'subtype') && node.subtype !== null && typeof node.subtype !== 'string') {
80
+ _err(errors, path('.subtype'), 'node.subtype must be a string or null');
81
+ }
82
+ if (typeof node.label !== 'string' || !node.label) _err(errors, path('.label'), 'node.label is required');
83
+ if (!Array.isArray(node.aliases)) _err(errors, path('.aliases'), 'node.aliases must be an array');
84
+ if (!Array.isArray(node.dataElementIds)) _err(errors, path('.dataElementIds'), 'node.dataElementIds must be an array');
85
+ if (!Array.isArray(node.evidenceRefs)) _err(errors, path('.evidenceRefs'), 'node.evidenceRefs must be an array');
86
+ if (!schema/* COVERAGE_STATUS_VALUES */.R0.includes(node.coverageStatus)) _err(errors, path('.coverageStatus'), `unrecognized coverageStatus "${node.coverageStatus}"`);
87
+ if (node.externality && !schema/* EXTERNALITY_VALUES */.TB.includes(node.externality.value)) {
88
+ _err(errors, path('.externality.value'), `unrecognized externality "${node.externality.value}"`);
89
+ }
90
+ // Milestone 2, Sub-project A, increment 1: `node.destination` is `null`
91
+ // on every node this increment doesn't resolve — only checked when
92
+ // non-null, mirroring `_validateEdge`'s own `edge.protocol` pattern below.
93
+ if (node.destination && typeof node.destination === 'object') {
94
+ if (!schema/* DESTINATION_RESOLUTION_VALUES */.JU.includes(node.destination.resolutionStatus)) {
95
+ _err(errors, path('.destination.resolutionStatus'), `unrecognized destination.resolutionStatus "${node.destination.resolutionStatus}"`);
96
+ }
97
+ if (node.destination.resolutionStatus !== 'literal' && node.destination.literalValue !== null) {
98
+ _err(errors, path('.destination.literalValue'), 'destination.literalValue must be null unless resolutionStatus is "literal"');
99
+ }
100
+ }
101
+ // Milestone 2, Sub-project E, increment 2: `node.storeDetail` is `null`
102
+ // on every node this increment doesn't populate — only checked when
103
+ // non-null, mirroring `node.destination`'s own "only checked when the
104
+ // parent object is present" shape immediately above.
105
+ if (node.storeDetail && typeof node.storeDetail === 'object') {
106
+ if (node.storeDetail.operation !== null && !schema/* STORE_OPERATION_VALUES */.P4.includes(node.storeDetail.operation)) {
107
+ _err(errors, path('.storeDetail.operation'), `unrecognized storeDetail.operation "${node.storeDetail.operation}"`);
108
+ }
109
+ if (Object.prototype.hasOwnProperty.call(node.storeDetail, 'columns') && !Array.isArray(node.storeDetail.columns)) {
110
+ _err(errors, path('.storeDetail.columns'), 'storeDetail.columns must be an array');
111
+ } else if (Array.isArray(node.storeDetail.columns)) {
112
+ node.storeDetail.columns.forEach((c, i) => {
113
+ if (typeof c !== 'string') _err(errors, path(`.storeDetail.columns[${i}]`), 'storeDetail.columns entries must be strings');
114
+ });
115
+ }
116
+ }
117
+ // Milestone 2, Sub-project E, increment 3: `node.queueDetail` is `null`
118
+ // on every node this increment doesn't populate — only checked when
119
+ // non-null, mirroring `node.storeDetail`'s own "only checked when the
120
+ // parent object is present" shape immediately above.
121
+ if (node.queueDetail && typeof node.queueDetail === 'object') {
122
+ if (node.queueDetail.operation !== null && !schema/* QUEUE_OPERATION_VALUES */.hY.includes(node.queueDetail.operation)) {
123
+ _err(errors, path('.queueDetail.operation'), `unrecognized queueDetail.operation "${node.queueDetail.operation}"`);
124
+ }
125
+ if (node.queueDetail.topic !== null && typeof node.queueDetail.topic !== 'string') {
126
+ _err(errors, path('.queueDetail.topic'), 'queueDetail.topic must be a string or null');
127
+ }
128
+ }
129
+ }
130
+
131
+ function _validateDataElement(de, idx, errors, seenIds) {
132
+ const path = (suffix) => `$.dataElements[${idx}]${suffix}`;
133
+ if (!de || typeof de !== 'object') { _err(errors, path(''), 'dataElement must be an object'); return; }
134
+ if (typeof de.id !== 'string' || !de.id) _err(errors, path('.id'), 'dataElement.id is required');
135
+ else {
136
+ if (!ID_PREFIXES.data.test(de.id)) _err(errors, path('.id'), `dataElement.id must start with "data:"`);
137
+ seenIds.add(de.id);
138
+ }
139
+ if (typeof de.name !== 'string' || !de.name) _err(errors, path('.name'), 'dataElement.name is required');
140
+ if (!Array.isArray(de.dataClasses)) _err(errors, path('.dataClasses'), 'dataElement.dataClasses must be an array');
141
+ else {
142
+ for (let i = 0; i < de.dataClasses.length; i++) {
143
+ const cls = de.dataClasses[i];
144
+ if (!classification/* LINEAGE_DATA_CLASSES */.e6.includes(cls)) {
145
+ _err(errors, path(`.dataClasses[${i}]`), `unrecognized data class "${cls}"`);
146
+ }
147
+ }
148
+ }
149
+ if (!Array.isArray(de.aiContexts)) _err(errors, path('.aiContexts'), 'dataElement.aiContexts must be an array');
150
+ else {
151
+ for (let i = 0; i < de.aiContexts.length; i++) {
152
+ const ctx = de.aiContexts[i];
153
+ if (!(0,classification/* isAiContext */.MY)(ctx)) {
154
+ _err(errors, path(`.aiContexts[${i}]`), `unrecognized AI processing context "${ctx}"`);
155
+ }
156
+ }
157
+ }
158
+ }
159
+
160
+ function _validateEdge(edge, idx, errors, nodeIds, dataElementIds) {
161
+ const path = (suffix) => `$.edges[${idx}]${suffix}`;
162
+ if (!edge || typeof edge !== 'object') { _err(errors, path(''), 'edge must be an object'); return; }
163
+ if (typeof edge.id !== 'string' || !edge.id) _err(errors, path('.id'), 'edge.id is required');
164
+ else if (!ID_PREFIXES.edge.test(edge.id)) _err(errors, path('.id'), `edge.id must start with "edge:"`);
165
+ if (!nodeIds.has(edge.from)) _err(errors, path('.from'), `unknown node id "${edge.from}"`);
166
+ if (!nodeIds.has(edge.to)) _err(errors, path('.to'), `unknown node id "${edge.to}"`);
167
+ if (edge.relationship !== 'data_flow') _err(errors, path('.relationship'), `unrecognized relationship "${edge.relationship}"`);
168
+ if (!Array.isArray(edge.fieldMappings)) _err(errors, path('.fieldMappings'), 'edge.fieldMappings must be an array');
169
+ else {
170
+ edge.fieldMappings.forEach((fm, i) => {
171
+ if (!schema/* MAPPING_TYPES */.$W.includes(fm?.mappingType)) _err(errors, path(`.fieldMappings[${i}].mappingType`), `unrecognized mappingType "${fm?.mappingType}"`);
172
+ for (const deId of fm?.dataElementIds || []) {
173
+ if (!dataElementIds.has(deId)) _err(errors, path(`.fieldMappings[${i}].dataElementIds`), `unknown dataElement id "${deId}"`);
174
+ }
175
+ });
176
+ }
177
+ if (!edge.protection || typeof edge.protection !== 'object') {
178
+ _err(errors, path('.protection'), 'edge.protection is required');
179
+ } else {
180
+ for (const dim of protection/* PROTECTION_DIMENSIONS */.Ai) {
181
+ if (!(0,protection/* isValidProtectionDimension */.u9)(edge.protection[dim])) _err(errors, path(`.protection.${dim}`), `invalid protection dimension`);
182
+ }
183
+ }
184
+ if (edge.protocol && typeof edge.protocol === 'object') {
185
+ if (!schema/* DESTINATION_RESOLUTION_VALUES */.JU.includes(edge.protocol.destinationResolution)) {
186
+ _err(errors, path('.protocol.destinationResolution'), `unrecognized destinationResolution "${edge.protocol.destinationResolution}"`);
187
+ }
188
+ }
189
+ if (!schema/* EDGE_PROVENANCE_VALUES */.L9.includes(edge.provenance)) {
190
+ _err(errors, path('.provenance'), `unrecognized provenance "${edge.provenance}"`);
191
+ }
192
+ }
193
+
194
+ function _validateFlow(flow, idx, errors, nodeIds, dataElementIds, edgeIds) {
195
+ const path = (suffix) => `$.flows[${idx}]${suffix}`;
196
+ if (!flow || typeof flow !== 'object') { _err(errors, path(''), 'flow must be an object'); return; }
197
+ if (typeof flow.id !== 'string' || !flow.id) _err(errors, path('.id'), 'flow.id is required');
198
+ else if (!ID_PREFIXES.flow.test(flow.id)) _err(errors, path('.id'), `flow.id must start with "flow:"`);
199
+ if (!nodeIds.has(flow.source)) _err(errors, path('.source'), `unknown node id "${flow.source}"`);
200
+ if (!nodeIds.has(flow.sink)) _err(errors, path('.sink'), `unknown node id "${flow.sink}"`);
201
+ for (const deId of flow.dataElementIds || []) {
202
+ if (!dataElementIds.has(deId)) _err(errors, path('.dataElementIds'), `unknown dataElement id "${deId}"`);
203
+ }
204
+ for (const eId of flow.edgeIds || []) {
205
+ if (!edgeIds.has(eId)) _err(errors, path('.edgeIds'), `unknown edge id "${eId}"`);
206
+ }
207
+ if (!schema/* POLICY_STATES */.QA.includes(flow.policyVerdict)) _err(errors, path('.policyVerdict'), `unrecognized policyVerdict "${flow.policyVerdict}"`);
208
+ if (!schema/* FLOW_SUMMARY_VALUES */.lw.includes(flow.protectionSummary)) _err(errors, path('.protectionSummary'), `unrecognized protectionSummary "${flow.protectionSummary}"`);
209
+ // Milestone 2, Sub-project D, increment 1: `flow.handling` is `null` on
210
+ // every flow this increment's own caller chose not to populate — only
211
+ // checked when non-null, mirroring `_validateNode`'s own `node.destination`
212
+ // pattern above.
213
+ if (flow.handling != null && !schema/* HANDLING_VALUES */.DC.includes(flow.handling)) {
214
+ _err(errors, path('.handling'), `unrecognized handling "${flow.handling}"`);
215
+ }
216
+ }
217
+
218
+ function _validateTransformation(t, idx, errors) {
219
+ const path = (suffix) => `$.transformations[${idx}]${suffix}`;
220
+ if (!t || typeof t !== 'object') { _err(errors, path(''), 'transformation must be an object'); return; }
221
+ if (typeof t.id !== 'string' || !t.id) _err(errors, path('.id'), 'transformation.id is required');
222
+ else if (!ID_PREFIXES.transform.test(t.id)) _err(errors, path('.id'), `transformation.id must start with "transform:"`);
223
+ if (!schema/* TRANSFORM_KINDS */.DK.includes(t.kind)) _err(errors, path('.kind'), `unrecognized transformation kind "${t.kind}"`);
224
+ if (!schema/* REVERSIBILITY_VALUES */.vw.includes(t.reversibility)) _err(errors, path('.reversibility'), `unrecognized reversibility "${t.reversibility}"`);
225
+ }
226
+
227
+ function _validateEvidence(e, idx, errors) {
228
+ const path = (suffix) => `$.evidence[${idx}]${suffix}`;
229
+ if (!e || typeof e !== 'object') { _err(errors, path(''), 'evidence must be an object'); return; }
230
+ if (typeof e.id !== 'string' || !e.id) _err(errors, path('.id'), 'evidence.id is required');
231
+ else if (!ID_PREFIXES.evidence.test(e.id)) _err(errors, path('.id'), `evidence.id must start with "evidence:"`);
232
+ if (!schema/* EVIDENCE_TYPES */.il.includes(e.evidenceType)) _err(errors, path('.evidenceType'), `unrecognized evidenceType "${e.evidenceType}"`);
233
+ }
234
+
235
+ /**
236
+ * Report a validation error for every duplicate id beyond the first
237
+ * occurrence in a top-level entity array. Entities with a missing/invalid
238
+ * id are skipped here — that is already reported by the per-entity
239
+ * structural check, and treating `undefined` as a colliding "id" would be
240
+ * noise, not signal.
241
+ */
242
+ function _checkDuplicateIds(items, key, errors) {
243
+ const seenAt = new Map();
244
+ items.forEach((item, idx) => {
245
+ if (!item || typeof item.id !== 'string' || !item.id) return;
246
+ if (seenAt.has(item.id)) {
247
+ _err(errors, `$.${key}[${idx}].id`, `duplicate id "${item.id}" (also used at $.${key}[${seenAt.get(item.id)}])`);
248
+ } else {
249
+ seenAt.set(item.id, idx);
250
+ }
251
+ });
252
+ }
253
+
254
+ /**
255
+ * Structurally validate a DataFlowGraph v1 envelope. Returns
256
+ * `{valid, errors}` and never throws.
257
+ */
258
+ function validateGraph(graph) {
259
+ const errors = [];
260
+ if (!graph || typeof graph !== 'object' || Array.isArray(graph)) {
261
+ return { valid: false, errors: [{ path: '$', message: 'graph must be an object' }] };
262
+ }
263
+
264
+ if (graph.schemaVersion !== schema/* SCHEMA_VERSION */.f$) {
265
+ _err(errors, '$.schemaVersion', `expected "${schema/* SCHEMA_VERSION */.f$}", got "${graph.schemaVersion}"`);
266
+ }
267
+ if (typeof graph.graphId !== 'string' || !graph.graphId.startsWith('dfg:')) {
268
+ _err(errors, '$.graphId', 'graphId must be a string starting with "dfg:"');
269
+ }
270
+ for (const key of ['nodes', 'edges', 'dataElements', 'transformations', 'flows', 'controls', 'policies', 'evidence', 'limitations']) {
271
+ _requireArray(graph, key, errors);
272
+ }
273
+ for (const key of ['scope', 'scanHealth', 'taxonomy', 'coverage', 'extensions']) {
274
+ _requireObject(graph, key, errors);
275
+ }
276
+ if (graph.scope && typeof graph.scope === 'object' && !Array.isArray(graph.scope)) {
277
+ if (!schema/* GRAPH_SCOPE_SOURCES */.nZ.includes(graph.scope.source)) {
278
+ _err(errors, '$.scope.source', `unrecognized scope.source "${graph.scope.source}"`);
279
+ }
280
+ }
281
+
282
+ const nodeIds = new Set();
283
+ const dataElementIds = new Set();
284
+ const edgeIds = new Set();
285
+
286
+ (Array.isArray(graph.nodes) ? graph.nodes : []).forEach((n, i) => _validateNode(n, i, errors, nodeIds));
287
+ (Array.isArray(graph.dataElements) ? graph.dataElements : []).forEach((d, i) => _validateDataElement(d, i, errors, dataElementIds));
288
+ (Array.isArray(graph.edges) ? graph.edges : []).forEach((e, i) => {
289
+ _validateEdge(e, i, errors, nodeIds, dataElementIds);
290
+ if (e && typeof e.id === 'string') edgeIds.add(e.id);
291
+ });
292
+ (Array.isArray(graph.flows) ? graph.flows : []).forEach((f, i) => _validateFlow(f, i, errors, nodeIds, dataElementIds, edgeIds));
293
+ (Array.isArray(graph.transformations) ? graph.transformations : []).forEach((t, i) => _validateTransformation(t, i, errors));
294
+ (Array.isArray(graph.evidence) ? graph.evidence : []).forEach((e, i) => _validateEvidence(e, i, errors));
295
+
296
+ _checkDuplicateIds(Array.isArray(graph.nodes) ? graph.nodes : [], 'nodes', errors);
297
+ _checkDuplicateIds(Array.isArray(graph.edges) ? graph.edges : [], 'edges', errors);
298
+ _checkDuplicateIds(Array.isArray(graph.dataElements) ? graph.dataElements : [], 'dataElements', errors);
299
+ _checkDuplicateIds(Array.isArray(graph.flows) ? graph.flows : [], 'flows', errors);
300
+
301
+ return { valid: errors.length === 0, errors };
302
+ }
303
+
304
+ // EXTERNAL MODULE: ./src/lineage/export-json.js
305
+ var export_json = __webpack_require__(859);
306
+ ;// CONCATENATED MODULE: ./src/lineage/federation-loader.js
307
+ // federation-loader.js — M5 deliverable #8 (FR-304's "declared" half):
308
+ // loadRemoteGraphExport(filePath) reads an exportGraphJSON-shaped file
309
+ // (dataflow export --format json's own artifact) — chosen over the
310
+ // local server's signed-graph reader (`scanner/src/server/`, whose
311
+ // loadSignedGraph is what `agentic-security explore` uses) for the
312
+ // cross-machine reason this deliverable's own scoping investigation
313
+ // found: loadSignedGraph authenticates against a PER-INSTALL HMAC key,
314
+ // which is the wrong trust model for a file that crossed a repo/machine
315
+ // boundary in the common case (two repos scanned on two different
316
+ // machines sign under two different keys by default, so pointing
317
+ // loadSignedGraph at a second repo's checkout would, in the common case,
318
+ // correctly report 'tampered' even though nothing was actually
319
+ // tampered with). exportGraphJSON's portable, embedded-digest artifact
320
+ // is a SELF-CONSISTENCY check instead — never authentication, disclosed
321
+ // as such everywhere this module or its callers describe it.
322
+ //
323
+ // Mirrors that reader's own four-distinct-outcome discipline, with one
324
+ // structural difference: a digest mismatch here is NOT a blocking
325
+ // failure (`ok:false`) the way all four of its reasons are — it is a
326
+ // WARNING the caller must show, never silently swallowed, and does not
327
+ // by itself block a --yes write (the operator is explicitly asserting
328
+ // this file). `ok:true, digestMatches:false` is therefore a real,
329
+ // valid, non-failing outcome; only `missing`/`malformed`/
330
+ // `invalid-graph` set `ok:false`.
331
+ //
332
+ // The self-consistency check recomputes `computeGraphDigest(parsed.graph)`
333
+ // and compares it to the file's own embedded `bodyDigest` (final
334
+ // whole-branch review, M5 deliverable #8, B1 — NOT `digest`, a real bug
335
+ // that survived five clean task-level reviews). `export-json.js`'s
336
+ // `digest` field always identifies the SOURCE graph an export was taken
337
+ // from, regardless of redaction/filtering — comparing it against a
338
+ // recomputation over `parsed.graph` (which IS the redacted/filtered
339
+ // `graph:` body under the CLI's own default settings) fails under the
340
+ // exact common case a self-consistency check exists to pass: an
341
+ // un-tampered, default-redacted export would permanently read
342
+ // `digestMatches: false`, and a genuine tamper would be indistinguishable
343
+ // from routine redaction. `bodyDigest` identifies the exact bytes this
344
+ // file actually contains, which is what a self-consistency check over a
345
+ // received file needs.
346
+
347
+
348
+
349
+
350
+
351
+ /**
352
+ * @param {string} filePath
353
+ * @returns {{
354
+ * ok: boolean,
355
+ * graph: object|null,
356
+ * digest: string|null,
357
+ * digestMatches: boolean|null,
358
+ * reason: 'missing'|'malformed'|'invalid-graph'|'digest-mismatch'|null,
359
+ * message: string|null,
360
+ * }}
361
+ */
362
+ function loadRemoteGraphExport(filePath) {
363
+ if (!filePath || typeof filePath !== 'string' || !external_node_fs_.existsSync(filePath)) {
364
+ return {
365
+ ok: false, graph: null, digest: null, digestMatches: null, reason: 'missing',
366
+ message: `No remote graph export found at ${filePath}. Run \`dataflow export --format json\` in the remote repository and point --remote-graph at the resulting file.`,
367
+ };
368
+ }
369
+
370
+ let body;
371
+ try {
372
+ body = external_node_fs_.readFileSync(filePath, 'utf8');
373
+ } catch (e) {
374
+ return {
375
+ ok: false, graph: null, digest: null, digestMatches: null, reason: 'missing',
376
+ message: `Remote graph export found at ${filePath} but could not be read: ${e && e.message ? e.message : e}.`,
377
+ };
378
+ }
379
+
380
+ let parsed;
381
+ try {
382
+ parsed = JSON.parse(body);
383
+ } catch (e) {
384
+ return {
385
+ ok: false, graph: null, digest: null, digestMatches: null, reason: 'malformed',
386
+ message: `Remote graph export at ${filePath} is not valid JSON (${e && e.message ? e.message : e}).`,
387
+ };
388
+ }
389
+
390
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)
391
+ || typeof parsed.bodyDigest !== 'string' || !parsed.bodyDigest
392
+ || !parsed.graph || typeof parsed.graph !== 'object' || Array.isArray(parsed.graph)) {
393
+ return {
394
+ ok: false, graph: null, digest: null, digestMatches: null, reason: 'malformed',
395
+ message: `Remote graph export at ${filePath} does not look like an \`exportGraphJSON\` artifact — expected top-level "bodyDigest" (string) and "graph" (object) fields. Run \`dataflow export --format json\` to produce a valid one.`,
396
+ };
397
+ }
398
+
399
+ const { valid, errors } = validateGraph(parsed.graph);
400
+ if (!valid) {
401
+ return {
402
+ ok: false, graph: null, digest: parsed.bodyDigest, digestMatches: null, reason: 'invalid-graph',
403
+ message: `Remote graph export at ${filePath} does not contain a well-formed DataFlowGraph v1 document: ${errors.map((e) => `${e.path}: ${e.message}`).join('; ')}`,
404
+ };
405
+ }
406
+
407
+ const recomputed = (0,export_json.computeGraphDigest)(parsed.graph);
408
+ const digestMatches = recomputed === parsed.bodyDigest;
409
+ if (!digestMatches) {
410
+ return {
411
+ ok: true, graph: parsed.graph, digest: parsed.bodyDigest, digestMatches: false, reason: 'digest-mismatch',
412
+ message: 'WARNING: the remote export\'s embedded digest does not match its own content (self-consistency check failed) — this is NOT authentication, only a check that the file has not been altered since it was exported. Proceeding is a real trust decision the operator is making explicitly.',
413
+ };
414
+ }
415
+
416
+ return { ok: true, graph: parsed.graph, digest: parsed.bodyDigest, digestMatches: true, reason: null, message: null };
417
+ }
418
+
419
+
420
+ /***/ })
421
+
422
+ };
@@ -1,5 +1,5 @@
1
- export const id = 970;
2
- export const ids = [970];
1
+ export const id = 4970;
2
+ export const ids = [4970];
3
3
  export const modules = {
4
4
 
5
5
  /***/ 4970: