behavguard 0.0.0-stage → 0.8.4

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 (101) hide show
  1. package/.github/workflows/behavguard.yml +91 -0
  2. package/README.md +150 -2
  3. package/config/static-gates.example.json +9 -0
  4. package/dist/analysis-cache.d.ts +3 -0
  5. package/dist/analysis-cache.js +115 -0
  6. package/dist/analysis-cache.js.map +1 -0
  7. package/dist/artifacts.d.ts +32 -0
  8. package/dist/artifacts.js +170 -0
  9. package/dist/artifacts.js.map +1 -0
  10. package/dist/cli.d.ts +2 -0
  11. package/dist/cli.js +211 -0
  12. package/dist/cli.js.map +1 -0
  13. package/dist/comparator.d.ts +21 -0
  14. package/dist/comparator.js +238 -0
  15. package/dist/comparator.js.map +1 -0
  16. package/dist/controller.d.ts +93 -0
  17. package/dist/controller.js +384 -0
  18. package/dist/controller.js.map +1 -0
  19. package/dist/coverage.d.ts +14 -0
  20. package/dist/coverage.js +134 -0
  21. package/dist/coverage.js.map +1 -0
  22. package/dist/database-syntax.d.ts +3 -0
  23. package/dist/database-syntax.js +117 -0
  24. package/dist/database-syntax.js.map +1 -0
  25. package/dist/dependencies.d.ts +10 -0
  26. package/dist/dependencies.js +249 -0
  27. package/dist/dependencies.js.map +1 -0
  28. package/dist/dependency-inputs.d.ts +8 -0
  29. package/dist/dependency-inputs.js +10 -0
  30. package/dist/dependency-inputs.js.map +1 -0
  31. package/dist/effects.d.ts +12 -0
  32. package/dist/effects.js +263 -0
  33. package/dist/effects.js.map +1 -0
  34. package/dist/evidence.d.ts +3 -0
  35. package/dist/evidence.js +68 -0
  36. package/dist/evidence.js.map +1 -0
  37. package/dist/gate.d.ts +46 -0
  38. package/dist/gate.js +89 -0
  39. package/dist/gate.js.map +1 -0
  40. package/dist/index.d.ts +15 -0
  41. package/dist/index.js +11 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/init.d.ts +4 -0
  44. package/dist/init.js +55 -0
  45. package/dist/init.js.map +1 -0
  46. package/dist/model.d.ts +78 -0
  47. package/dist/model.js +2 -0
  48. package/dist/model.js.map +1 -0
  49. package/dist/package-resolution.d.ts +15 -0
  50. package/dist/package-resolution.js +156 -0
  51. package/dist/package-resolution.js.map +1 -0
  52. package/dist/planning.d.ts +35 -0
  53. package/dist/planning.js +56 -0
  54. package/dist/planning.js.map +1 -0
  55. package/dist/runtime-coverage.d.ts +8 -0
  56. package/dist/runtime-coverage.js +70 -0
  57. package/dist/runtime-coverage.js.map +1 -0
  58. package/dist/runtime-protocol.d.ts +33 -0
  59. package/dist/runtime-protocol.js +2 -0
  60. package/dist/runtime-protocol.js.map +1 -0
  61. package/dist/runtime.d.ts +17 -0
  62. package/dist/runtime.js +215 -0
  63. package/dist/runtime.js.map +1 -0
  64. package/dist/scenarios.d.ts +75 -0
  65. package/dist/scenarios.js +435 -0
  66. package/dist/scenarios.js.map +1 -0
  67. package/dist/snapshot.d.ts +6 -0
  68. package/dist/snapshot.js +103 -0
  69. package/dist/snapshot.js.map +1 -0
  70. package/dist/static-analysis.d.ts +61 -0
  71. package/dist/static-analysis.js +408 -0
  72. package/dist/static-analysis.js.map +1 -0
  73. package/dist/static-approvals.d.ts +25 -0
  74. package/dist/static-approvals.js +54 -0
  75. package/dist/static-approvals.js.map +1 -0
  76. package/dist/static-index.d.ts +113 -0
  77. package/dist/static-index.js +654 -0
  78. package/dist/static-index.js.map +1 -0
  79. package/dist/static-project.d.ts +40 -0
  80. package/dist/static-project.js +236 -0
  81. package/dist/static-project.js.map +1 -0
  82. package/dist/values.d.ts +10 -0
  83. package/dist/values.js +274 -0
  84. package/dist/values.js.map +1 -0
  85. package/dist/version.d.ts +1 -0
  86. package/dist/version.js +3 -0
  87. package/dist/version.js.map +1 -0
  88. package/dist/worker.d.ts +1 -0
  89. package/dist/worker.js +338 -0
  90. package/dist/worker.js.map +1 -0
  91. package/docs/adoption-guide.md +365 -0
  92. package/docs/pilot-evaluation.md +113 -0
  93. package/docs/pilot-fixtures/ky840.catalog.json +21 -0
  94. package/docs/pilot-fixtures/ky840.scenarios.json +82 -0
  95. package/docs/pilot-fixtures/ofetch482.catalog.json +45 -0
  96. package/docs/pilot-fixtures/ofetch482.scenarios.json +294 -0
  97. package/package.json +41 -4
  98. package/scripts/check-pull-request.sh +46 -0
  99. package/scripts/github-static-approvals.mjs +196 -0
  100. package/skills/behavguard/SKILL.md +15 -0
  101. package/templates/github-actions.yml +79 -0
@@ -0,0 +1,113 @@
1
+ import ts from 'typescript';
2
+ import type { Snapshot, TargetEntry } from './model.js';
3
+ import { type ProjectGraph, type ProjectSource } from './static-project.js';
4
+ export interface SourceSpan {
5
+ path: string;
6
+ start: number;
7
+ end: number;
8
+ }
9
+ export interface SymbolReference {
10
+ id: string;
11
+ snapshotId: string;
12
+ projectPath: string;
13
+ filePath: string;
14
+ qualifiedName: string;
15
+ kind: string;
16
+ span: {
17
+ start: number;
18
+ end: number;
19
+ };
20
+ }
21
+ export type DependencyKind = 'calls' | 'imports' | 'references' | 'reexports' | 'reads' | 'writes' | 'inherits' | 'implements' | 'type_depends_on' | 'config_depends_on' | 'unknown';
22
+ export interface DependencyEdge {
23
+ from: string;
24
+ to: string;
25
+ kind: DependencyKind;
26
+ location: SourceSpan;
27
+ }
28
+ export interface StaticEffect {
29
+ kind: 'db' | 'http' | 'file' | 'clock' | 'random' | 'process' | 'shared_state' | 'event' | 'unknown';
30
+ adapter?: 'prisma' | 'fetch';
31
+ operation: string;
32
+ resource: string | null;
33
+ access: 'read' | 'write' | 'read_write' | 'unknown';
34
+ source: SymbolReference;
35
+ location: SourceSpan & {
36
+ line: number;
37
+ };
38
+ callSiteId: string;
39
+ arguments?: string[];
40
+ guard?: string;
41
+ transactionScope?: string;
42
+ confidence: 'resolved' | 'approximate' | 'unknown';
43
+ }
44
+ export interface StaticEntry {
45
+ id: string;
46
+ targetRef: string;
47
+ entry: TargetEntry;
48
+ }
49
+ interface Token {
50
+ key: string;
51
+ start: number;
52
+ end: number;
53
+ }
54
+ export interface IndexedSymbol {
55
+ ref: SymbolReference;
56
+ node: ts.Node;
57
+ source: ProjectSource;
58
+ tokens: Token[];
59
+ signature: string;
60
+ implementation: string;
61
+ structure: string;
62
+ positionKey: string;
63
+ }
64
+ export interface StaticIndex {
65
+ symbols: Map<string, IndexedSymbol>;
66
+ publicEntries: Map<string, StaticEntry>;
67
+ edges: DependencyEdge[];
68
+ effects: Map<string, StaticEffect[]>;
69
+ unknown: {
70
+ from: string;
71
+ code: string;
72
+ location: SourceSpan;
73
+ detail?: string;
74
+ }[];
75
+ }
76
+ export declare function normalized(node: ts.Node): string;
77
+ export declare function sourceSpan(node: ts.Node): SourceSpan;
78
+ export declare function moduleFingerprint(file: ts.SourceFile): string;
79
+ export declare function isFormattingOnly(base: ProjectSource | undefined, head: ProjectSource | undefined): boolean;
80
+ export declare class IndexBuilder {
81
+ readonly snapshot: Snapshot;
82
+ readonly project: ProjectGraph;
83
+ readonly symbols: Map<string, IndexedSymbol>;
84
+ readonly publicEntries: Map<string, StaticEntry>;
85
+ readonly edges: DependencyEdge[];
86
+ readonly effects: Map<string, StaticEffect[]>;
87
+ readonly unknown: StaticIndex['unknown'];
88
+ private readonly owners;
89
+ private readonly edgeKeys;
90
+ constructor(snapshot: Snapshot, project: ProjectGraph);
91
+ build(): StaticIndex;
92
+ recordEffect(owner: string, node: ts.Node, effect: Omit<StaticEffect, 'callSiteId' | 'source' | 'location'>): void;
93
+ addUnknown(owner: string, node: ts.Node, code: string, detail?: string): void;
94
+ private register;
95
+ private collectDeclaration;
96
+ private collectExports;
97
+ private ownerForSymbol;
98
+ private addEdge;
99
+ private collectDependencies;
100
+ private addModuleDependency;
101
+ private referenceKind;
102
+ private isReferenceIdentifier;
103
+ private collectCall;
104
+ private collectTaggedCall;
105
+ private unresolvedCall;
106
+ private modelCall;
107
+ }
108
+ export declare function indexedSnapshot(snapshot: Snapshot, project: ProjectGraph): StaticIndex;
109
+ export declare function changedSpans(base: IndexedSymbol | undefined, head: IndexedSymbol | undefined): {
110
+ baseChangedSpans: SourceSpan[];
111
+ headChangedSpans: SourceSpan[];
112
+ };
113
+ export {};