@@ -11,12 +11,71 @@ import {
1111 CostEstimate ,
1212 HardwareType ,
1313 Jurisdiction ,
14+ Regulation ,
1415} from '../types' ;
1516import { ComplianceLinter } from '../diagnostics/linter' ;
16- import { aethelCli } from '../services/cli' ;
1717import { configManager } from '../utils/config' ;
1818import { logger , CategoryLogger } from '../utils/logger' ;
1919
20+ const SUPPORTED_HARDWARE : ReadonlySet < string > = new Set < HardwareType > ( [
21+ 'generic' ,
22+ 'intel-sgx' ,
23+ 'intel-sgx-dcap' ,
24+ 'intel-tdx' ,
25+ 'amd-sev' ,
26+ 'amd-sev-snp' ,
27+ 'arm-trustzone' ,
28+ 'arm-cca' ,
29+ 'aws-nitro' ,
30+ 'azure-confidential' ,
31+ 'gcp-confidential' ,
32+ 'nvidia-h100' ,
33+ 'nvidia-a100' ,
34+ ] ) ;
35+
36+ const SUPPORTED_JURISDICTIONS : ReadonlySet < string > = new Set < Jurisdiction > ( [
37+ 'Global' ,
38+ 'UAE' ,
39+ 'UAE-ADGM' ,
40+ 'UAE-DIFC' ,
41+ 'Saudi-Arabia' ,
42+ 'EU' ,
43+ 'EU-Germany' ,
44+ 'EU-France' ,
45+ 'UK' ,
46+ 'US' ,
47+ 'US-California' ,
48+ 'US-NewYork' ,
49+ 'Singapore' ,
50+ 'China' ,
51+ 'Japan' ,
52+ 'Australia' ,
53+ 'India' ,
54+ 'Brazil' ,
55+ 'Canada' ,
56+ ] ) ;
57+
58+ const SUPPORTED_REGULATIONS : ReadonlySet < string > = new Set < Regulation > ( [
59+ 'GDPR' ,
60+ 'HIPAA' ,
61+ 'CCPA' ,
62+ 'UAE-DPL' ,
63+ 'PIPL' ,
64+ 'PDPA' ,
65+ 'UK-GDPR' ,
66+ 'PDPL-SA' ,
67+ 'PCI-DSS' ,
68+ 'SOX' ,
69+ 'GLBA' ,
70+ 'EU-AI-Act' ,
71+ 'HITECH' ,
72+ 'APPI' ,
73+ 'PIPA' ,
74+ 'LGPD' ,
75+ 'DPDP' ,
76+ 'PIPEDA' ,
77+ ] ) ;
78+
2079/**
2180 * Code lens data for a sovereign function.
2281 */
@@ -27,6 +86,11 @@ interface SovereignCodeLensData {
2786 costEstimate ?: CostEstimate ;
2887}
2988
89+ type FunctionSpanInfo = Omit <
90+ SovereignFunctionInfo ,
91+ 'decoratorLine' | 'hardware' | 'jurisdiction' | 'compliance' | 'parameters' | 'costEstimate'
92+ > ;
93+
3094/**
3195 * Code lens provider for Aethelred sovereign functions.
3296 */
@@ -60,6 +124,7 @@ export class AethelredCodeLensProvider implements vscode.CodeLensProvider {
60124
61125 // Find all sovereign functions
62126 const functions = this . findSovereignFunctions ( document ) ;
127+ this . log . debug ( `Found ${ functions . length } sovereign function(s) in ${ document . fileName } ` ) ;
63128
64129 for ( const func of functions ) {
65130 if ( token . isCancellationRequested ) {
@@ -159,9 +224,9 @@ export class AethelredCodeLensProvider implements vscode.CodeLensProvider {
159224 functions . push ( {
160225 ...funcInfo ,
161226 decoratorLine : decoratorLine + 1 ,
162- hardware : params . hardware as HardwareType | undefined ,
163- jurisdiction : params . jurisdiction as Jurisdiction | undefined ,
164- compliance : params . compliance ?. split ( ',' ) . map ( ( s : string ) => s . trim ( ) ) ,
227+ hardware : this . parseHardware ( params . hardware ) ,
228+ jurisdiction : this . parseJurisdiction ( params . jurisdiction ) ,
229+ compliance : this . parseRegulations ( params . compliance ) ,
165230 } ) ;
166231 }
167232 }
@@ -175,7 +240,7 @@ export class AethelredCodeLensProvider implements vscode.CodeLensProvider {
175240 private findFunctionAfterLine (
176241 document : vscode . TextDocument ,
177242 startLine : number
178- ) : Partial < SovereignFunctionInfo > | null {
243+ ) : FunctionSpanInfo | null {
179244 for ( let i = startLine ; i < Math . min ( document . lineCount , startLine + 5 ) ; i ++ ) {
180245 const line = document . lineAt ( i ) . text ;
181246
@@ -210,7 +275,7 @@ export class AethelredCodeLensProvider implements vscode.CodeLensProvider {
210275 line : number ,
211276 name : string ,
212277 column : number
213- ) : Partial < SovereignFunctionInfo > {
278+ ) : FunctionSpanInfo {
214279 // Find function end (simple heuristic)
215280 let endLine = line ;
216281 let braceCount = 0 ;
@@ -269,6 +334,27 @@ export class AethelredCodeLensProvider implements vscode.CodeLensProvider {
269334 return params ;
270335 }
271336
337+ private parseHardware ( value ?: string ) : HardwareType | undefined {
338+ return value && SUPPORTED_HARDWARE . has ( value ) ? value as HardwareType : undefined ;
339+ }
340+
341+ private parseJurisdiction ( value ?: string ) : Jurisdiction | undefined {
342+ return value && SUPPORTED_JURISDICTIONS . has ( value ) ? value as Jurisdiction : undefined ;
343+ }
344+
345+ private parseRegulations ( value ?: string ) : Regulation [ ] | undefined {
346+ if ( ! value ) {
347+ return undefined ;
348+ }
349+
350+ const regulations = value
351+ . split ( ',' )
352+ . map ( ( raw ) => raw . trim ( ) . replace ( / ^ R e g u l a t i o n \. / , '' ) )
353+ . filter ( ( item ) : item is Regulation => SUPPORTED_REGULATIONS . has ( item ) ) ;
354+
355+ return regulations . length > 0 ? regulations : undefined ;
356+ }
357+
272358 /**
273359 * Get status title for code lens.
274360 */
0 commit comments