@@ -5,22 +5,6 @@ import (
55 "sort"
66)
77
8- // FILE:internal/checker/checker.go
9- // VERSION:1.0.1
10- // START_MODULE_CONTRACT:
11- // PURPOSE:Provide check interface and deterministic runner execution order.
12- // SCOPE:Check metadata contract, runner assembly, status-to-severity mapping.
13- // INPUT:RuntimeState snapshot and check implementations.
14- // OUTPUT:Ordered list of CheckResult entries.
15- // KEYWORDS:[PATTERN(Strategy): pluggable checks; PATTERN(Pipeline): evaluation runner]
16- // LINKS:[READS_DATA_FROM(internal/checker/context.go): RuntimeState]
17- // END_MODULE_CONTRACT
18-
19- // START_CHANGE_SUMMARY:
20- // LAST_CHANGE:1.0.1 - Added panic recovery, runtime failure propagation, and result normalization to preserve contract stability.
21- // PREV_CHANGE_SUMMARY:1.0.0 - Implemented check strategy interface and deterministic execution.
22- // END_CHANGE_SUMMARY
23-
248type Meta struct {
259 ID string
2610 Name string
@@ -37,18 +21,6 @@ type Runner struct {
3721 runtimeError bool
3822}
3923
40- // START_FUNCTION_NewRunner
41- // START_CONTRACT:
42- // PURPOSE:Create a runner that executes checks in deterministic ID order.
43- // INPUTS:
44- // - provided checks => checks: []Check
45- // OUTPUTS:
46- // - *Runner - ready-to-run checker engine
47- // SIDE_EFFECTS: none
48- // KEYWORDS:[PATTERN(Sorting): stable execution; CONCEPT(Reproducibility): deterministic output]
49- // LINKS:[USES_API(sort.Slice): ordering by check id]
50- // COMPLEXITY_SCORE:[3][single sort operation]
51- // END_CONTRACT
5224func NewRunner (checks []Check ) * Runner {
5325 ordered := make ([]Check , len (checks ))
5426 copy (ordered , checks )
@@ -58,18 +30,6 @@ func NewRunner(checks []Check) *Runner {
5830 return & Runner {checks : ordered }
5931}
6032
61- // START_FUNCTION_Run
62- // START_CONTRACT:
63- // PURPOSE:Execute all registered checks against runtime state.
64- // INPUTS:
65- // - runtime snapshot => state: RuntimeState
66- // OUTPUTS:
67- // - []CheckResult - sorted check result rows
68- // SIDE_EFFECTS: none
69- // KEYWORDS:[PATTERN(Pipeline): sequential execution; CONCEPT(Stateless): pure evaluation]
70- // LINKS:[USES_API(None): none]
71- // COMPLEXITY_SCORE:[3][single loop over checks]
72- // END_CONTRACT
7333func (r * Runner ) Run (state RuntimeState ) []CheckResult {
7434 r .runtimeError = false
7535 results := make ([]CheckResult , 0 , len (r .checks ))
@@ -86,18 +46,6 @@ func (r *Runner) Run(state RuntimeState) []CheckResult {
8646 return results
8747}
8848
89- // START_FUNCTION_HasRuntimeError
90- // START_CONTRACT:
91- // PURPOSE:Expose whether any checker execution produced runtime failure.
92- // INPUTS:
93- // - none
94- // OUTPUTS:
95- // - bool - true when at least one checker panic was recovered
96- // SIDE_EFFECTS: none
97- // KEYWORDS:[CONCEPT(Reliability): runtime signal propagation]
98- // LINKS:[USES_API(None): none]
99- // COMPLEXITY_SCORE:[1][field accessor]
100- // END_CONTRACT
10149func (r * Runner ) HasRuntimeError () bool {
10250 return r .runtimeError
10351}
@@ -143,7 +91,6 @@ func runtimeFailureResult(meta Meta, details string) CheckResult {
14391}
14492
14593func normalizeCheckResult (meta Meta , result CheckResult ) CheckResult {
146- // BUG_FIX_CONTEXT: Earlier checker outputs could miss required contract fields, which broke JSON stability and safety classification. The normalizer guarantees complete machine-readable rows for every check.
14794 if result .ID == "" {
14895 result .ID = meta .ID
14996 }
@@ -183,18 +130,6 @@ func normalizeCheckResult(meta Meta, result CheckResult) CheckResult {
183130 return result
184131}
185132
186- // START_FUNCTION_SeverityFromStatus
187- // START_CONTRACT:
188- // PURPOSE:Normalize output severity from resulting status.
189- // INPUTS:
190- // - status emitted by check => status: Status
191- // OUTPUTS:
192- // - Severity - mapped urgency level
193- // SIDE_EFFECTS: none
194- // KEYWORDS:[PATTERN(Mapping): status normalization]
195- // LINKS:[USES_API(None): none]
196- // COMPLEXITY_SCORE:[2][constant switch]
197- // END_CONTRACT
198133func SeverityFromStatus (status Status ) Severity {
199134 switch status {
200135 case StatusCrit :
0 commit comments