@@ -11,27 +11,27 @@ import (
1111 "log/slog"
1212 "time"
1313
14- "github.com/xraph/shield/ext "
14+ "github.com/xraph/shield/plugin "
1515 "github.com/xraph/shield/id"
1616)
1717
1818// Compile-time interface checks.
1919var (
20- _ ext. Extension = (* Extension )(nil )
21- _ ext .ScanStarted = (* Extension )(nil )
22- _ ext .ScanCompleted = (* Extension )(nil )
23- _ ext .ScanBlocked = (* Extension )(nil )
24- _ ext .ScanFailed = (* Extension )(nil )
25- _ ext .InstinctTriggered = (* Extension )(nil )
26- _ ext .AwarenessDetected = (* Extension )(nil )
27- _ ext .JudgmentAssessed = (* Extension )(nil )
28- _ ext .ValueViolated = (* Extension )(nil )
29- _ ext .ReflexFired = (* Extension )(nil )
30- _ ext .BoundaryEnforced = (* Extension )(nil )
31- _ ext .PIIDetected = (* Extension )(nil )
32- _ ext .PIIRedacted = (* Extension )(nil )
33- _ ext .PolicyEvaluated = (* Extension )(nil )
34- _ ext .SafetyProfileResolved = (* Extension )(nil )
20+ _ plugin. Plugin = (* Extension )(nil )
21+ _ plugin .ScanStarted = (* Extension )(nil )
22+ _ plugin .ScanCompleted = (* Extension )(nil )
23+ _ plugin .ScanBlocked = (* Extension )(nil )
24+ _ plugin .ScanFailed = (* Extension )(nil )
25+ _ plugin .InstinctTriggered = (* Extension )(nil )
26+ _ plugin .AwarenessDetected = (* Extension )(nil )
27+ _ plugin .JudgmentAssessed = (* Extension )(nil )
28+ _ plugin .ValueViolated = (* Extension )(nil )
29+ _ plugin .ReflexFired = (* Extension )(nil )
30+ _ plugin .BoundaryEnforced = (* Extension )(nil )
31+ _ plugin .PIIDetected = (* Extension )(nil )
32+ _ plugin .PIIRedacted = (* Extension )(nil )
33+ _ plugin .PolicyEvaluated = (* Extension )(nil )
34+ _ plugin .SafetyProfileResolved = (* Extension )(nil )
3535)
3636
3737// Recorder is the interface that audit backends must implement.
@@ -82,20 +82,20 @@ func New(r Recorder, opts ...Option) *Extension {
8282 return e
8383}
8484
85- // Name implements ext.Extension .
85+ // Name implements plugin.Plugin .
8686func (e * Extension ) Name () string { return "audit-hook" }
8787
8888// ── Scan lifecycle hooks ──────────────────────────────
8989
90- // OnScanStarted implements ext .ScanStarted.
90+ // OnScanStarted implements plugin .ScanStarted.
9191func (e * Extension ) OnScanStarted (ctx context.Context , scanID id.ScanID , direction string , _ string ) error {
9292 return e .record (ctx , ActionScanStarted , SeverityInfo , OutcomeSuccess ,
9393 ResourceScan , scanID .String (), CategorySafety , nil ,
9494 "direction" , direction ,
9595 )
9696}
9797
98- // OnScanCompleted implements ext .ScanCompleted.
98+ // OnScanCompleted implements plugin .ScanCompleted.
9999func (e * Extension ) OnScanCompleted (ctx context.Context , scanID id.ScanID , decision string , findingCount int , elapsed time.Duration ) error {
100100 return e .record (ctx , ActionScanCompleted , SeverityInfo , OutcomeSuccess ,
101101 ResourceScan , scanID .String (), CategorySafety , nil ,
@@ -105,15 +105,15 @@ func (e *Extension) OnScanCompleted(ctx context.Context, scanID id.ScanID, decis
105105 )
106106}
107107
108- // OnScanBlocked implements ext .ScanBlocked.
108+ // OnScanBlocked implements plugin .ScanBlocked.
109109func (e * Extension ) OnScanBlocked (ctx context.Context , scanID id.ScanID , reason string ) error {
110110 return e .record (ctx , ActionScanBlocked , SeverityWarning , OutcomeSuccess ,
111111 ResourceScan , scanID .String (), CategorySafety , nil ,
112112 "reason" , reason ,
113113 )
114114}
115115
116- // OnScanFailed implements ext .ScanFailed.
116+ // OnScanFailed implements plugin .ScanFailed.
117117func (e * Extension ) OnScanFailed (ctx context.Context , scanID id.ScanID , scanErr error ) error {
118118 return e .record (ctx , ActionScanFailed , SeverityCritical , OutcomeFailure ,
119119 ResourceScan , scanID .String (), CategorySafety , scanErr ,
@@ -122,7 +122,7 @@ func (e *Extension) OnScanFailed(ctx context.Context, scanID id.ScanID, scanErr
122122
123123// ── Safety primitive lifecycle hooks ──────────────────
124124
125- // OnInstinctTriggered implements ext .InstinctTriggered.
125+ // OnInstinctTriggered implements plugin .InstinctTriggered.
126126func (e * Extension ) OnInstinctTriggered (ctx context.Context , scanID id.ScanID , instinctName string , score float64 ) error {
127127 return e .record (ctx , ActionInstinctTriggered , SeverityWarning , OutcomeSuccess ,
128128 ResourceInstinct , scanID .String (), CategorySafety , nil ,
@@ -131,7 +131,7 @@ func (e *Extension) OnInstinctTriggered(ctx context.Context, scanID id.ScanID, i
131131 )
132132}
133133
134- // OnAwarenessDetected implements ext .AwarenessDetected.
134+ // OnAwarenessDetected implements plugin .AwarenessDetected.
135135func (e * Extension ) OnAwarenessDetected (ctx context.Context , scanID id.ScanID , detectorName string , findingCount int ) error {
136136 return e .record (ctx , ActionAwarenessDetected , SeverityInfo , OutcomeSuccess ,
137137 ResourceAwareness , scanID .String (), CategorySafety , nil ,
@@ -140,7 +140,7 @@ func (e *Extension) OnAwarenessDetected(ctx context.Context, scanID id.ScanID, d
140140 )
141141}
142142
143- // OnJudgmentAssessed implements ext .JudgmentAssessed.
143+ // OnJudgmentAssessed implements plugin .JudgmentAssessed.
144144func (e * Extension ) OnJudgmentAssessed (ctx context.Context , scanID id.ScanID , assessorName string , riskLevel string , confidence float64 ) error {
145145 return e .record (ctx , ActionJudgmentAssessed , SeverityInfo , OutcomeSuccess ,
146146 ResourceJudgment , scanID .String (), CategorySafety , nil ,
@@ -150,7 +150,7 @@ func (e *Extension) OnJudgmentAssessed(ctx context.Context, scanID id.ScanID, as
150150 )
151151}
152152
153- // OnValueViolated implements ext .ValueViolated.
153+ // OnValueViolated implements plugin .ValueViolated.
154154func (e * Extension ) OnValueViolated (ctx context.Context , scanID id.ScanID , valueName string , severity string ) error {
155155 return e .record (ctx , ActionValueViolated , SeverityWarning , OutcomeSuccess ,
156156 ResourceValue , scanID .String (), CategorySafety , nil ,
@@ -159,7 +159,7 @@ func (e *Extension) OnValueViolated(ctx context.Context, scanID id.ScanID, value
159159 )
160160}
161161
162- // OnReflexFired implements ext .ReflexFired.
162+ // OnReflexFired implements plugin .ReflexFired.
163163func (e * Extension ) OnReflexFired (ctx context.Context , scanID id.ScanID , reflexName string , action string ) error {
164164 return e .record (ctx , ActionReflexFired , SeverityInfo , OutcomeSuccess ,
165165 ResourceReflex , scanID .String (), CategoryGovernance , nil ,
@@ -168,7 +168,7 @@ func (e *Extension) OnReflexFired(ctx context.Context, scanID id.ScanID, reflexN
168168 )
169169}
170170
171- // OnBoundaryEnforced implements ext .BoundaryEnforced.
171+ // OnBoundaryEnforced implements plugin .BoundaryEnforced.
172172func (e * Extension ) OnBoundaryEnforced (ctx context.Context , scanID id.ScanID , boundaryName string ) error {
173173 return e .record (ctx , ActionBoundaryEnforced , SeverityWarning , OutcomeSuccess ,
174174 ResourceBoundary , scanID .String (), CategorySafety , nil ,
@@ -178,7 +178,7 @@ func (e *Extension) OnBoundaryEnforced(ctx context.Context, scanID id.ScanID, bo
178178
179179// ── PII lifecycle hooks ───────────────────────────────
180180
181- // OnPIIDetected implements ext .PIIDetected.
181+ // OnPIIDetected implements plugin .PIIDetected.
182182func (e * Extension ) OnPIIDetected (ctx context.Context , scanID id.ScanID , piiType string , count int ) error {
183183 return e .record (ctx , ActionPIIDetected , SeverityWarning , OutcomeSuccess ,
184184 ResourcePII , scanID .String (), CategoryPrivacy , nil ,
@@ -187,7 +187,7 @@ func (e *Extension) OnPIIDetected(ctx context.Context, scanID id.ScanID, piiType
187187 )
188188}
189189
190- // OnPIIRedacted implements ext .PIIRedacted.
190+ // OnPIIRedacted implements plugin .PIIRedacted.
191191func (e * Extension ) OnPIIRedacted (ctx context.Context , scanID id.ScanID , piiType string , count int ) error {
192192 return e .record (ctx , ActionPIIRedacted , SeverityInfo , OutcomeSuccess ,
193193 ResourcePII , scanID .String (), CategoryPrivacy , nil ,
@@ -198,7 +198,7 @@ func (e *Extension) OnPIIRedacted(ctx context.Context, scanID id.ScanID, piiType
198198
199199// ── Policy lifecycle hooks ────────────────────────────
200200
201- // OnPolicyEvaluated implements ext .PolicyEvaluated.
201+ // OnPolicyEvaluated implements plugin .PolicyEvaluated.
202202func (e * Extension ) OnPolicyEvaluated (ctx context.Context , scanID id.ScanID , policyName string , decision string ) error {
203203 return e .record (ctx , ActionPolicyCreated , SeverityInfo , OutcomeSuccess ,
204204 ResourcePolicy , scanID .String (), CategoryGovernance , nil ,
@@ -207,7 +207,7 @@ func (e *Extension) OnPolicyEvaluated(ctx context.Context, scanID id.ScanID, pol
207207 )
208208}
209209
210- // OnSafetyProfileResolved implements ext .SafetyProfileResolved.
210+ // OnSafetyProfileResolved implements plugin .SafetyProfileResolved.
211211func (e * Extension ) OnSafetyProfileResolved (ctx context.Context , scanID id.ScanID , profileName string ) error {
212212 return e .record (ctx , ActionProfileResolved , SeverityInfo , OutcomeSuccess ,
213213 ResourceProfile , scanID .String (), CategorySafety , nil ,
0 commit comments