@neuralaxis/vibedoctor 0.1.3 → 0.2.1

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 (112) hide show
  1. package/README.md +298 -115
  2. package/dist/adapters/biome.js +135 -21
  3. package/dist/adapters/dpdp.d.ts +6 -0
  4. package/dist/adapters/dpdp.js +34 -0
  5. package/dist/adapters/index.d.ts +1 -0
  6. package/dist/adapters/index.js +3 -1
  7. package/dist/adapters/osvScanner.js +136 -17
  8. package/dist/adapters/presidio.js +6 -2
  9. package/dist/adapters/privacyDetector.d.ts +24 -1
  10. package/dist/adapters/privacyDetector.js +86 -2
  11. package/dist/adapters/shared.d.ts +6 -0
  12. package/dist/agentPack/templates/skills.js +159 -53
  13. package/dist/cli/commands/dpdp.d.ts +35 -0
  14. package/dist/cli/commands/dpdp.js +103 -0
  15. package/dist/cli/commands/init.js +105 -50
  16. package/dist/cli/commands/privacyReview.js +3 -4
  17. package/dist/cli/commands/scan.js +4 -1
  18. package/dist/cli/commands/setup.d.ts +13 -17
  19. package/dist/cli/commands/setup.js +138 -200
  20. package/dist/cli/index.js +84 -0
  21. package/dist/core/capability.d.ts +92 -0
  22. package/dist/core/capability.js +122 -0
  23. package/dist/core/config.d.ts +57 -0
  24. package/dist/core/config.js +194 -7
  25. package/dist/core/credentialHeuristics.d.ts +28 -0
  26. package/dist/core/credentialHeuristics.js +179 -0
  27. package/dist/core/engine.d.ts +21 -0
  28. package/dist/core/engine.js +484 -84
  29. package/dist/core/executable.d.ts +18 -0
  30. package/dist/core/executable.js +137 -0
  31. package/dist/core/fileRole.d.ts +24 -0
  32. package/dist/core/fileRole.js +125 -0
  33. package/dist/core/finding.d.ts +125 -1
  34. package/dist/core/finding.js +63 -5
  35. package/dist/core/findingNormalizer.d.ts +33 -0
  36. package/dist/core/findingNormalizer.js +171 -0
  37. package/dist/core/projectDetector.d.ts +13 -0
  38. package/dist/core/projectDetector.js +100 -15
  39. package/dist/core/relevance.d.ts +87 -0
  40. package/dist/core/relevance.js +367 -0
  41. package/dist/core/scanPlanner.d.ts +12 -0
  42. package/dist/core/scanPlanner.js +61 -29
  43. package/dist/core/semverLite.d.ts +27 -0
  44. package/dist/core/semverLite.js +163 -0
  45. package/dist/core/suppressions.d.ts +96 -0
  46. package/dist/core/suppressions.js +302 -0
  47. package/dist/core/toolRegistry.d.ts +58 -0
  48. package/dist/core/toolRegistry.js +247 -0
  49. package/dist/core/toolRunner.d.ts +23 -2
  50. package/dist/core/toolRunner.js +61 -93
  51. package/dist/core/toolVerification.d.ts +87 -0
  52. package/dist/core/toolVerification.js +370 -0
  53. package/dist/dpdp/artifacts.d.ts +11 -0
  54. package/dist/dpdp/artifacts.js +120 -0
  55. package/dist/dpdp/catalogue.d.ts +14 -0
  56. package/dist/dpdp/catalogue.js +661 -0
  57. package/dist/dpdp/collectors/confidence.d.ts +9 -0
  58. package/dist/dpdp/collectors/confidence.js +25 -0
  59. package/dist/dpdp/collectors/dependencies.d.ts +7 -0
  60. package/dist/dpdp/collectors/dependencies.js +63 -0
  61. package/dist/dpdp/collectors/index.d.ts +24 -0
  62. package/dist/dpdp/collectors/index.js +71 -0
  63. package/dist/dpdp/collectors/lifecycle.d.ts +2 -0
  64. package/dist/dpdp/collectors/lifecycle.js +202 -0
  65. package/dist/dpdp/collectors/optionalScanners.d.ts +14 -0
  66. package/dist/dpdp/collectors/optionalScanners.js +437 -0
  67. package/dist/dpdp/collectors/privacyBridge.d.ts +13 -0
  68. package/dist/dpdp/collectors/privacyBridge.js +152 -0
  69. package/dist/dpdp/collectors/safeguards.d.ts +5 -0
  70. package/dist/dpdp/collectors/safeguards.js +186 -0
  71. package/dist/dpdp/collectors/schema.d.ts +6 -0
  72. package/dist/dpdp/collectors/schema.js +122 -0
  73. package/dist/dpdp/collectors/shared.d.ts +10 -0
  74. package/dist/dpdp/collectors/shared.js +43 -0
  75. package/dist/dpdp/context.d.ts +28 -0
  76. package/dist/dpdp/context.js +195 -0
  77. package/dist/dpdp/dataMap.d.ts +7 -0
  78. package/dist/dpdp/dataMap.js +339 -0
  79. package/dist/dpdp/evaluators.d.ts +20 -0
  80. package/dist/dpdp/evaluators.js +522 -0
  81. package/dist/dpdp/evidence.d.ts +11 -0
  82. package/dist/dpdp/evidence.js +123 -0
  83. package/dist/dpdp/findings.d.ts +44 -0
  84. package/dist/dpdp/findings.js +286 -0
  85. package/dist/dpdp/gates.d.ts +14 -0
  86. package/dist/dpdp/gates.js +47 -0
  87. package/dist/dpdp/index.d.ts +16 -0
  88. package/dist/dpdp/index.js +32 -0
  89. package/dist/dpdp/legalSources.d.ts +10 -0
  90. package/dist/dpdp/legalSources.js +104 -0
  91. package/dist/dpdp/paths.d.ts +25 -0
  92. package/dist/dpdp/paths.js +85 -0
  93. package/dist/dpdp/report.d.ts +6 -0
  94. package/dist/dpdp/report.js +222 -0
  95. package/dist/dpdp/reviewQueue.d.ts +3 -0
  96. package/dist/dpdp/reviewQueue.js +88 -0
  97. package/dist/dpdp/scan.d.ts +26 -0
  98. package/dist/dpdp/scan.js +310 -0
  99. package/dist/dpdp/scoring.d.ts +41 -0
  100. package/dist/dpdp/scoring.js +237 -0
  101. package/dist/dpdp/types.d.ts +312 -0
  102. package/dist/dpdp/types.js +86 -0
  103. package/dist/index.d.ts +1 -0
  104. package/dist/index.js +1 -0
  105. package/dist/mcp/tools/dpdp.d.ts +11 -0
  106. package/dist/mcp/tools/dpdp.js +151 -0
  107. package/dist/mcp/tools/index.js +3 -1
  108. package/dist/reporters/html.js +57 -13
  109. package/dist/reporters/json.js +12 -1
  110. package/dist/reporters/markdown.js +46 -4
  111. package/dist/reporters/sarif.js +54 -5
  112. package/package.json +4 -1
@@ -0,0 +1,41 @@
1
+ import type { Severity } from "../core/finding";
2
+ import type { ControlResult, ControlStatusCounts, DpdpCapabilityStatus, DpdpScores } from "./types";
3
+ /**
4
+ * Controls that expect an implementation signal when personal data is processed.
5
+ * NOT_OBSERVED on these is weak posture (missing expected control), not a clean bill of health.
6
+ */
7
+ export declare const POSITIVE_CONTROL_EVALUATORS: Set<string>;
8
+ /**
9
+ * Gap / anti-pattern detectors. NOT_OBSERVED means no gap was seen (good, with uncertainty).
10
+ */
11
+ export declare const GAP_CONTROL_EVALUATORS: Set<string>;
12
+ export declare function isPositiveControl(control: ControlResult): boolean;
13
+ export declare function isGapControl(control: ControlResult): boolean;
14
+ export declare function countStatuses(controls: ControlResult[]): ControlStatusCounts;
15
+ /**
16
+ * Whether the scanners a control depends on actually ran.
17
+ *
18
+ * "Nothing bad was found" and "nothing looked" produce the same control status,
19
+ * and a gap detector's silence was credited at 0.85 either way. That let a
20
+ * posture score climb because a scanner was missing, which is exactly backwards.
21
+ */
22
+ export declare function hasSupportingCoverage(capabilities: DpdpCapabilityStatus[]): boolean;
23
+ /** Points contributed by one control status toward technical posture (0–1). */
24
+ export declare function posturePointsForControl(control: ControlResult, coverageComplete?: boolean): number;
25
+ /**
26
+ * Technical posture score from applicable technically observable controls only.
27
+ * NOT a legal compliance percentage.
28
+ *
29
+ * Scoring table:
30
+ * - VERIFIED 1.0 · PARTIAL 0.5 · VIOLATED 0.0 · ERROR 0.15 · NEEDS_CONTEXT 0.4
31
+ * - NOT_OBSERVED: 0.25 (positive control), 0.85 (gap detector), 0.7 (other)
32
+ * - When supporting scanners did not run, unobserved controls score 0.4 instead,
33
+ * because their silence carries no information.
34
+ */
35
+ export declare function computeTechnicalPostureScore(controls: ControlResult[], capabilities?: DpdpCapabilityStatus[]): number;
36
+ /**
37
+ * Evidence completeness: share of applicable controls that have evidence or are verified/violated/partial.
38
+ */
39
+ export declare function computeEvidenceCompleteness(controls: ControlResult[]): number;
40
+ export declare function openRiskBySeverity(controls: ControlResult[]): Record<Severity, number>;
41
+ export declare function buildDpdpScores(controls: ControlResult[], capabilities?: DpdpCapabilityStatus[]): DpdpScores;
@@ -0,0 +1,237 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GAP_CONTROL_EVALUATORS = exports.POSITIVE_CONTROL_EVALUATORS = void 0;
4
+ exports.isPositiveControl = isPositiveControl;
5
+ exports.isGapControl = isGapControl;
6
+ exports.countStatuses = countStatuses;
7
+ exports.hasSupportingCoverage = hasSupportingCoverage;
8
+ exports.posturePointsForControl = posturePointsForControl;
9
+ exports.computeTechnicalPostureScore = computeTechnicalPostureScore;
10
+ exports.computeEvidenceCompleteness = computeEvidenceCompleteness;
11
+ exports.openRiskBySeverity = openRiskBySeverity;
12
+ exports.buildDpdpScores = buildDpdpScores;
13
+ const catalogue_1 = require("./catalogue");
14
+ /**
15
+ * Controls that expect an implementation signal when personal data is processed.
16
+ * NOT_OBSERVED on these is weak posture (missing expected control), not a clean bill of health.
17
+ */
18
+ exports.POSITIVE_CONTROL_EVALUATORS = new Set([
19
+ "notice-signals",
20
+ "consent-capture",
21
+ "consent-metadata",
22
+ "consent-withdrawal",
23
+ "purpose-binding",
24
+ "retention-mechanism",
25
+ "erasure-path",
26
+ "access-export",
27
+ "correction-path",
28
+ "grievance-handling",
29
+ "nomination-signal",
30
+ "rights-request-tracking",
31
+ "breach-preparedness",
32
+ "audit-signals",
33
+ "guardian-consent",
34
+ "childrens-data"
35
+ ]);
36
+ /**
37
+ * Gap / anti-pattern detectors. NOT_OBSERVED means no gap was seen (good, with uncertainty).
38
+ */
39
+ exports.GAP_CONTROL_EVALUATORS = new Set([
40
+ "api-overfetch",
41
+ "broad-db-select",
42
+ "pii-in-logs",
43
+ "pii-in-llm",
44
+ "pii-in-urls",
45
+ "browser-storage-pii",
46
+ "insecure-http",
47
+ "route-auth",
48
+ "hardcoded-pii",
49
+ "debug-exposure",
50
+ "weak-masking",
51
+ "unprotected-export",
52
+ "third-party-user-object",
53
+ "storage-without-deletion"
54
+ ]);
55
+ function isPositiveControl(control) {
56
+ const definition = (0, catalogue_1.getControlById)(control.controlId);
57
+ const evaluatorId = definition?.evaluatorId;
58
+ if (!evaluatorId) {
59
+ return false;
60
+ }
61
+ return exports.POSITIVE_CONTROL_EVALUATORS.has(evaluatorId);
62
+ }
63
+ function isGapControl(control) {
64
+ const definition = (0, catalogue_1.getControlById)(control.controlId);
65
+ const evaluatorId = definition?.evaluatorId;
66
+ if (!evaluatorId) {
67
+ return false;
68
+ }
69
+ return exports.GAP_CONTROL_EVALUATORS.has(evaluatorId);
70
+ }
71
+ function countStatuses(controls) {
72
+ const counts = {
73
+ verified: 0,
74
+ violated: 0,
75
+ partial: 0,
76
+ notObserved: 0,
77
+ needsContext: 0,
78
+ notApplicable: 0,
79
+ skipped: 0,
80
+ error: 0,
81
+ humanReview: 0,
82
+ unresolved: 0
83
+ };
84
+ for (const control of controls) {
85
+ switch (control.status) {
86
+ case "VERIFIED":
87
+ counts.verified += 1;
88
+ break;
89
+ case "VIOLATED":
90
+ counts.violated += 1;
91
+ break;
92
+ case "PARTIAL":
93
+ counts.partial += 1;
94
+ break;
95
+ case "NOT_OBSERVED":
96
+ counts.notObserved += 1;
97
+ break;
98
+ case "NEEDS_CONTEXT":
99
+ counts.needsContext += 1;
100
+ break;
101
+ case "NOT_APPLICABLE":
102
+ counts.notApplicable += 1;
103
+ break;
104
+ case "SKIPPED":
105
+ counts.skipped += 1;
106
+ break;
107
+ case "ERROR":
108
+ counts.error += 1;
109
+ break;
110
+ default:
111
+ break;
112
+ }
113
+ if (control.verificationClass === "HUMAN_REVIEW" || control.status === "NEEDS_CONTEXT") {
114
+ counts.humanReview += 1;
115
+ }
116
+ }
117
+ // Unresolved = needs attention: violated + partial + needs_context + error
118
+ counts.unresolved = counts.violated + counts.partial + counts.needsContext + counts.error;
119
+ return counts;
120
+ }
121
+ /**
122
+ * Whether the scanners a control depends on actually ran.
123
+ *
124
+ * "Nothing bad was found" and "nothing looked" produce the same control status,
125
+ * and a gap detector's silence was credited at 0.85 either way. That let a
126
+ * posture score climb because a scanner was missing, which is exactly backwards.
127
+ */
128
+ function hasSupportingCoverage(capabilities) {
129
+ const optional = capabilities.filter((capability) => capability.id === "presidio" || capability.id === "semgrep");
130
+ if (optional.length === 0) {
131
+ return true;
132
+ }
133
+ return optional.some((capability) => capability.status === "available");
134
+ }
135
+ /** Points contributed by one control status toward technical posture (0–1). */
136
+ function posturePointsForControl(control, coverageComplete = true) {
137
+ switch (control.status) {
138
+ case "VERIFIED":
139
+ return 1;
140
+ case "PARTIAL":
141
+ return 0.5;
142
+ case "VIOLATED":
143
+ return 0;
144
+ case "ERROR":
145
+ return 0.15;
146
+ case "NEEDS_CONTEXT":
147
+ return 0.4;
148
+ case "NOT_OBSERVED":
149
+ // Positive controls missing expected signals: low credit.
150
+ // Gap detectors with no bad pattern: mostly good (not VERIFIED).
151
+ if (isPositiveControl(control)) {
152
+ return 0.25;
153
+ }
154
+ if (isGapControl(control)) {
155
+ // Silence only earns credit when something was actually looking. Without
156
+ // the supporting scanners it is an unknown, scored like NEEDS_CONTEXT.
157
+ return coverageComplete ? 0.85 : 0.4;
158
+ }
159
+ // Inventory, processors, cross-border, SDF, etc. — neutral-good silence
160
+ return coverageComplete ? 0.7 : 0.4;
161
+ default:
162
+ return 0.5;
163
+ }
164
+ }
165
+ /**
166
+ * Technical posture score from applicable technically observable controls only.
167
+ * NOT a legal compliance percentage.
168
+ *
169
+ * Scoring table:
170
+ * - VERIFIED 1.0 · PARTIAL 0.5 · VIOLATED 0.0 · ERROR 0.15 · NEEDS_CONTEXT 0.4
171
+ * - NOT_OBSERVED: 0.25 (positive control), 0.85 (gap detector), 0.7 (other)
172
+ * - When supporting scanners did not run, unobserved controls score 0.4 instead,
173
+ * because their silence carries no information.
174
+ */
175
+ function computeTechnicalPostureScore(controls, capabilities = []) {
176
+ const observable = controls.filter((control) => control.applicable &&
177
+ control.status !== "NOT_APPLICABLE" &&
178
+ control.status !== "SKIPPED" &&
179
+ (control.verificationClass === "DETERMINISTIC" || control.verificationClass === "TECHNICAL_SIGNAL"));
180
+ if (observable.length === 0) {
181
+ return 100;
182
+ }
183
+ const coverageComplete = hasSupportingCoverage(capabilities);
184
+ let points = 0;
185
+ for (const control of observable) {
186
+ points += posturePointsForControl(control, coverageComplete);
187
+ }
188
+ return Math.max(0, Math.min(100, Math.round((points / observable.length) * 100)));
189
+ }
190
+ /**
191
+ * Evidence completeness: share of applicable controls that have evidence or are verified/violated/partial.
192
+ */
193
+ function computeEvidenceCompleteness(controls) {
194
+ const applicable = controls.filter((control) => control.applicable && control.status !== "NOT_APPLICABLE" && control.status !== "SKIPPED");
195
+ if (applicable.length === 0) {
196
+ return 100;
197
+ }
198
+ const withEvidence = applicable.filter((control) => control.evidenceIds.length > 0 ||
199
+ control.status === "VERIFIED" ||
200
+ control.status === "VIOLATED" ||
201
+ control.status === "PARTIAL");
202
+ return Math.round((withEvidence.length / applicable.length) * 100);
203
+ }
204
+ function openRiskBySeverity(controls) {
205
+ const counts = {
206
+ critical: 0,
207
+ high: 0,
208
+ medium: 0,
209
+ low: 0,
210
+ info: 0
211
+ };
212
+ for (const control of controls) {
213
+ if (control.status === "VIOLATED" || control.status === "PARTIAL" || control.status === "ERROR") {
214
+ counts[control.severity] += 1;
215
+ }
216
+ }
217
+ return counts;
218
+ }
219
+ function buildDpdpScores(controls, capabilities = []) {
220
+ const coverageComplete = hasSupportingCoverage(capabilities);
221
+ const missing = capabilities
222
+ .filter((capability) => capability.status !== "available")
223
+ .map((capability) => capability.id);
224
+ return {
225
+ technicalPostureScore: computeTechnicalPostureScore(controls, capabilities),
226
+ evidenceCompletenessPercent: computeEvidenceCompleteness(controls),
227
+ openRiskBySeverity: openRiskBySeverity(controls),
228
+ statusCounts: countStatuses(controls),
229
+ labels: {
230
+ technicalPosture: coverageComplete
231
+ ? "DPDP technical posture (not legal compliance)"
232
+ : `DPDP technical posture — reduced coverage, ${missing.join(" and ")} did not run (not legal compliance)`,
233
+ evidenceCompleteness: "Evidence completeness (technical observability)",
234
+ openRisk: "Open technical risk counts by severity"
235
+ }
236
+ };
237
+ }
@@ -0,0 +1,312 @@
1
+ import type { Confidence, Severity } from "../core/finding";
2
+ /** Verification classes for DPDP controls. */
3
+ export declare const VERIFICATION_CLASSES: readonly ["DETERMINISTIC", "TECHNICAL_SIGNAL", "DECLARED_EVIDENCE", "HUMAN_REVIEW"];
4
+ export type VerificationClass = (typeof VERIFICATION_CLASSES)[number];
5
+ /** Control result statuses. Absence of evidence must never become VERIFIED. */
6
+ export declare const CONTROL_STATUSES: readonly ["VERIFIED", "VIOLATED", "PARTIAL", "NOT_OBSERVED", "NEEDS_CONTEXT", "NOT_APPLICABLE", "SKIPPED", "ERROR"];
7
+ export type ControlStatus = (typeof CONTROL_STATUSES)[number];
8
+ export declare const CONTROL_DOMAINS: readonly ["applicability_and_inventory", "notice", "consent", "withdrawal", "purpose_limitation", "data_minimisation", "accuracy", "security_safeguards", "breach_preparedness", "retention", "erasure", "data_principal_access", "correction", "grievance_handling", "nomination", "childrens_data", "guardian_consent", "processors_and_recipients", "cross_border_signals", "significant_data_fiduciary", "exemptions_and_applicability"];
9
+ export type ControlDomain = (typeof CONTROL_DOMAINS)[number];
10
+ export declare const EVIDENCE_KINDS: readonly ["personal_data_category", "field_or_column", "collection_source", "processing_operation", "transformation", "storage_location", "log_or_telemetry", "external_recipient", "protection_control", "retention_mechanism", "deletion_path", "rights_endpoint", "consent_signal", "policy_declaration", "safeguard_gap", "declared_assertion", "skip_or_capability"];
11
+ export type EvidenceKind = (typeof EVIDENCE_KINDS)[number];
12
+ export type ObservationCertainty = "confirmed" | "inferred" | "declared";
13
+ export type DataCategory = "aadhaar" | "pan" | "passport" | "voter_id" | "driving_licence" | "name" | "email" | "phone" | "postal_address" | "date_of_birth" | "age" | "financial_payment" | "health_disability" | "biometric_identity" | "location" | "ip_device_id" | "cookie_ad_id" | "credentials_auth" | "employee_applicant_customer" | "free_text_personal" | "llm_prompt_embedding" | "other_personal" | "unknown";
14
+ export type LegalSourceRef = {
15
+ id: string;
16
+ title: string;
17
+ version: string;
18
+ citation: string;
19
+ notificationId?: string;
20
+ publishedAt?: string;
21
+ effectiveSchedule?: string[];
22
+ sourceStatus?: "enacted" | "notified" | "corrigendum";
23
+ sections?: string[];
24
+ url?: string;
25
+ };
26
+ export type ControlDefinition = {
27
+ id: string;
28
+ title: string;
29
+ domain: ControlDomain;
30
+ technicalIntent: string;
31
+ legalSourceIds: string[];
32
+ legalCitations: string[];
33
+ applicability: {
34
+ when: string;
35
+ requiresPersonalData?: boolean;
36
+ requiresChildren?: boolean;
37
+ requiresSdf?: boolean;
38
+ requiresProcessors?: boolean;
39
+ requiresCrossBorder?: boolean;
40
+ };
41
+ verificationClass: VerificationClass;
42
+ evidenceRequirements: string[];
43
+ /** Stable evaluator key; when absent, only human/declared evaluation applies. */
44
+ evaluatorId?: string;
45
+ possibleStatuses: ControlStatus[];
46
+ severityRules: {
47
+ defaultSeverity: Severity;
48
+ violatedSeverity: Severity;
49
+ partialSeverity?: Severity;
50
+ };
51
+ limitations: string[];
52
+ remediation: string;
53
+ humanReviewQuestions: string[];
54
+ sourceVersion: string;
55
+ };
56
+ export type EvidenceItem = {
57
+ id: string;
58
+ kind: EvidenceKind;
59
+ dataCategory?: DataCategory;
60
+ file?: string;
61
+ line?: number;
62
+ endLine?: number;
63
+ symbol?: string;
64
+ field?: string;
65
+ source?: string;
66
+ destination?: string;
67
+ detectionMethod: string;
68
+ confidence: Confidence;
69
+ confidenceScore?: number;
70
+ provenance: "deterministic" | "technical_signal" | "declared" | "presidio" | "semgrep" | "privacy-detector";
71
+ relatedControls: string[];
72
+ certainty: ObservationCertainty;
73
+ /** Masked/classified summary only — never raw PII. */
74
+ summary: string;
75
+ /** Optional redacted snippet. */
76
+ snippet?: string;
77
+ tags: string[];
78
+ };
79
+ export type DeclaredAssertion = {
80
+ id: string;
81
+ statement: string;
82
+ source: string;
83
+ suppliedRole: string;
84
+ date: string;
85
+ relatedControls: string[];
86
+ verificationStatus: "unverified" | "partially_corroborated" | "contradicted" | "supported_by_signal";
87
+ };
88
+ export type DpdpContext = {
89
+ version: number;
90
+ organization: {
91
+ processesPersonalData: "true" | "false" | "unknown";
92
+ isSignificantDataFiduciary: "true" | "false" | "unknown";
93
+ processesChildrenData: "true" | "false" | "unknown";
94
+ hasCrossBorderTransfer: "true" | "false" | "unknown";
95
+ industry?: string;
96
+ notes?: string;
97
+ };
98
+ purposes?: string[];
99
+ processors?: string[];
100
+ policies?: Array<{
101
+ name: string;
102
+ path?: string;
103
+ version?: string;
104
+ }>;
105
+ };
106
+ export type ControlResult = {
107
+ controlId: string;
108
+ title: string;
109
+ domain: ControlDomain;
110
+ status: ControlStatus;
111
+ verificationClass: VerificationClass;
112
+ confidence: Confidence;
113
+ severity: Severity;
114
+ evidenceIds: string[];
115
+ explanation: string;
116
+ limitations: string[];
117
+ remediation?: string;
118
+ humanReviewQuestion?: string;
119
+ isNew: boolean;
120
+ applicable: boolean;
121
+ };
122
+ /** Node kinds in the personal-data processing graph (classified labels only — never raw PII). */
123
+ export declare const DATA_MAP_NODE_KINDS: readonly ["category", "field", "collection", "store", "external", "lifecycle", "safeguard_gap", "control", "evidence"];
124
+ export type DataMapNodeKind = (typeof DATA_MAP_NODE_KINDS)[number];
125
+ export declare const DATA_MAP_EDGE_RELATIONS: readonly ["instance_of", "collected_at", "stored_in", "sent_to", "protected_by", "lifecycle_of", "related_control", "evidenced_by", "co_located"];
126
+ export type DataMapEdgeRelation = (typeof DATA_MAP_EDGE_RELATIONS)[number];
127
+ export type DataMapNode = {
128
+ id: string;
129
+ kind: DataMapNodeKind;
130
+ /** Classified label only (category name, store kind, control id, etc.). Never raw PII. */
131
+ label: string;
132
+ category?: DataCategory;
133
+ file?: string;
134
+ line?: number;
135
+ evidenceIds?: string[];
136
+ };
137
+ export type DataMapEdge = {
138
+ id: string;
139
+ from: string;
140
+ to: string;
141
+ relation: DataMapEdgeRelation;
142
+ };
143
+ export type PersonalDataMapGraph = {
144
+ nodes: DataMapNode[];
145
+ edges: DataMapEdge[];
146
+ };
147
+ export type PersonalDataMap = {
148
+ version: 1;
149
+ generatedAt: string;
150
+ disclaimer: string;
151
+ categories: Array<{
152
+ category: DataCategory;
153
+ count: number;
154
+ evidenceIds: string[];
155
+ }>;
156
+ collectionPoints: Array<{
157
+ id: string;
158
+ kind: string;
159
+ file?: string;
160
+ line?: number;
161
+ summary: string;
162
+ evidenceIds: string[];
163
+ }>;
164
+ stores: Array<{
165
+ id: string;
166
+ kind: string;
167
+ file?: string;
168
+ summary: string;
169
+ evidenceIds: string[];
170
+ }>;
171
+ externalRecipients: Array<{
172
+ id: string;
173
+ name: string;
174
+ kind: string;
175
+ file?: string;
176
+ summary: string;
177
+ evidenceIds: string[];
178
+ }>;
179
+ lifecycleSignals: Array<{
180
+ id: string;
181
+ kind: string;
182
+ file?: string;
183
+ line?: number;
184
+ summary: string;
185
+ evidenceIds: string[];
186
+ }>;
187
+ safeguardGaps: Array<{
188
+ id: string;
189
+ kind: string;
190
+ file?: string;
191
+ line?: number;
192
+ summary: string;
193
+ evidenceIds: string[];
194
+ }>;
195
+ relatedControls: string[];
196
+ /** Lightweight processing graph; safe for agents. Existing flat lists remain for compat. */
197
+ graph: PersonalDataMapGraph;
198
+ };
199
+ export type ControlMatrix = {
200
+ version: 1;
201
+ generatedAt: string;
202
+ disclaimer: string;
203
+ legalSourceVersion: string;
204
+ controls: ControlResult[];
205
+ summary: ControlStatusCounts;
206
+ };
207
+ export type ControlStatusCounts = {
208
+ verified: number;
209
+ violated: number;
210
+ partial: number;
211
+ notObserved: number;
212
+ needsContext: number;
213
+ notApplicable: number;
214
+ skipped: number;
215
+ error: number;
216
+ humanReview: number;
217
+ unresolved: number;
218
+ };
219
+ export type EvidenceLedger = {
220
+ version: 1;
221
+ generatedAt: string;
222
+ disclaimer: string;
223
+ evidence: EvidenceItem[];
224
+ declared: DeclaredAssertion[];
225
+ };
226
+ export type DpdpScores = {
227
+ /** Technical readiness only — not legal compliance. */
228
+ technicalPostureScore: number;
229
+ evidenceCompletenessPercent: number;
230
+ openRiskBySeverity: Record<Severity, number>;
231
+ statusCounts: ControlStatusCounts;
232
+ labels: {
233
+ /**
234
+ * Names the figure and, when supporting scanners did not run, says so in the
235
+ * label itself — a posture number quoted without its coverage caveat is the
236
+ * thing that overstates the evidence.
237
+ */
238
+ technicalPosture: string;
239
+ evidenceCompleteness: "Evidence completeness (technical observability)";
240
+ openRisk: "Open technical risk counts by severity";
241
+ };
242
+ };
243
+ export type ReviewQueueItem = {
244
+ controlId: string;
245
+ title: string;
246
+ domain: ControlDomain;
247
+ audience: "developer" | "security" | "product" | "legal" | "operations" | "founder";
248
+ question: string;
249
+ status: ControlStatus;
250
+ severity: Severity;
251
+ };
252
+ export type DpdpScanMode = "default" | "changed" | "full";
253
+ export type DpdpCapabilityStatus = {
254
+ id: string;
255
+ status: "available" | "skipped" | "error";
256
+ message?: string;
257
+ /**
258
+ * Which decision produced this status. "Skipped" previously covered opting
259
+ * out, having nothing in scope, and not being installed — three situations with
260
+ * nothing in common, so a user could not tell whether a scanner they had
261
+ * installed was actually contributing evidence.
262
+ */
263
+ cause?: "opted_out" | "disabled" | "quick_mode" | "nothing_in_scope" | "not_installed" | "not_applicable" | "failed" | "timed_out" | "ran";
264
+ /** What to change to make this capability available. */
265
+ remediation?: string;
266
+ /** Absolute path or interpreter that answered, when the capability did run. */
267
+ resolvedVia?: string;
268
+ /** How many signals this capability contributed to the evidence ledger. */
269
+ signalsContributed?: number;
270
+ };
271
+ export type DpdpScanResult = {
272
+ version: 1;
273
+ generatedAt: string;
274
+ root: string;
275
+ mode: DpdpScanMode;
276
+ disclaimer: string;
277
+ scores: DpdpScores;
278
+ dataMap: PersonalDataMap;
279
+ controlMatrix: ControlMatrix;
280
+ evidenceLedger: EvidenceLedger;
281
+ reviewQueue: ReviewQueueItem[];
282
+ fixNext: Array<{
283
+ controlId: string;
284
+ title: string;
285
+ severity: Severity;
286
+ remediation: string;
287
+ evidenceIds: string[];
288
+ }>;
289
+ capabilities: DpdpCapabilityStatus[];
290
+ findings: import("../core/finding").Finding[];
291
+ legalSourceVersion: string;
292
+ context: DpdpContext;
293
+ baselineApplied: boolean;
294
+ };
295
+ export type TechnicalSignalBag = {
296
+ id: string;
297
+ kind: string;
298
+ file?: string;
299
+ line?: number;
300
+ symbol?: string;
301
+ field?: string;
302
+ category?: DataCategory;
303
+ summary: string;
304
+ snippet?: string;
305
+ confidence: Confidence;
306
+ confidenceScore?: number;
307
+ tags: string[];
308
+ relatedControls?: string[];
309
+ certainty?: ObservationCertainty;
310
+ detectionMethod: string;
311
+ provenance?: EvidenceItem["provenance"];
312
+ };
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DATA_MAP_EDGE_RELATIONS = exports.DATA_MAP_NODE_KINDS = exports.EVIDENCE_KINDS = exports.CONTROL_DOMAINS = exports.CONTROL_STATUSES = exports.VERIFICATION_CLASSES = void 0;
4
+ /** Verification classes for DPDP controls. */
5
+ exports.VERIFICATION_CLASSES = [
6
+ "DETERMINISTIC",
7
+ "TECHNICAL_SIGNAL",
8
+ "DECLARED_EVIDENCE",
9
+ "HUMAN_REVIEW"
10
+ ];
11
+ /** Control result statuses. Absence of evidence must never become VERIFIED. */
12
+ exports.CONTROL_STATUSES = [
13
+ "VERIFIED",
14
+ "VIOLATED",
15
+ "PARTIAL",
16
+ "NOT_OBSERVED",
17
+ "NEEDS_CONTEXT",
18
+ "NOT_APPLICABLE",
19
+ "SKIPPED",
20
+ "ERROR"
21
+ ];
22
+ exports.CONTROL_DOMAINS = [
23
+ "applicability_and_inventory",
24
+ "notice",
25
+ "consent",
26
+ "withdrawal",
27
+ "purpose_limitation",
28
+ "data_minimisation",
29
+ "accuracy",
30
+ "security_safeguards",
31
+ "breach_preparedness",
32
+ "retention",
33
+ "erasure",
34
+ "data_principal_access",
35
+ "correction",
36
+ "grievance_handling",
37
+ "nomination",
38
+ "childrens_data",
39
+ "guardian_consent",
40
+ "processors_and_recipients",
41
+ "cross_border_signals",
42
+ "significant_data_fiduciary",
43
+ "exemptions_and_applicability"
44
+ ];
45
+ exports.EVIDENCE_KINDS = [
46
+ "personal_data_category",
47
+ "field_or_column",
48
+ "collection_source",
49
+ "processing_operation",
50
+ "transformation",
51
+ "storage_location",
52
+ "log_or_telemetry",
53
+ "external_recipient",
54
+ "protection_control",
55
+ "retention_mechanism",
56
+ "deletion_path",
57
+ "rights_endpoint",
58
+ "consent_signal",
59
+ "policy_declaration",
60
+ "safeguard_gap",
61
+ "declared_assertion",
62
+ "skip_or_capability"
63
+ ];
64
+ /** Node kinds in the personal-data processing graph (classified labels only — never raw PII). */
65
+ exports.DATA_MAP_NODE_KINDS = [
66
+ "category",
67
+ "field",
68
+ "collection",
69
+ "store",
70
+ "external",
71
+ "lifecycle",
72
+ "safeguard_gap",
73
+ "control",
74
+ "evidence"
75
+ ];
76
+ exports.DATA_MAP_EDGE_RELATIONS = [
77
+ "instance_of",
78
+ "collected_at",
79
+ "stored_in",
80
+ "sent_to",
81
+ "protected_by",
82
+ "lifecycle_of",
83
+ "related_control",
84
+ "evidenced_by",
85
+ "co_located"
86
+ ];
package/dist/index.d.ts CHANGED
@@ -7,3 +7,4 @@ export * from "./core/finding";
7
7
  export * from "./core/privacyReview";
8
8
  export * from "./core/projectDetector";
9
9
  export * from "./mcp/server";
10
+ export * from "./dpdp";
package/dist/index.js CHANGED
@@ -26,3 +26,4 @@ __exportStar(require("./core/finding"), exports);
26
26
  __exportStar(require("./core/privacyReview"), exports);
27
27
  __exportStar(require("./core/projectDetector"), exports);
28
28
  __exportStar(require("./mcp/server"), exports);
29
+ __exportStar(require("./dpdp"), exports);