| 1 | package instruction |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | ) |
| 6 | |
| 7 | // VerifyCheck preserves the retired structured-check option for old callers. |
| 8 | // Current execution reads project instructions as normal model context. |
| 9 | type VerifyCheck struct { |
| 10 | Command string |
| 11 | SourcePath string |
| 12 | Line int |
| 13 | } |
| 14 | |
| 15 | type contextKey struct{} |
| 16 | |
| 17 | func WithChecks(ctx context.Context, checks []VerifyCheck) context.Context { |
| 18 | if len(checks) == 0 { |
| 19 | return ctx |
| 20 | } |
| 21 | cp := append([]VerifyCheck(nil), checks...) |
| 22 | return context.WithValue(ctx, contextKey{}, cp) |
| 23 | } |
| 24 | |
| 25 | func FromContext(ctx context.Context) []VerifyCheck { |
| 26 | checks, ok := ctx.Value(contextKey{}).([]VerifyCheck) |
| 27 | if !ok || len(checks) == 0 { |
| 28 | return nil |
| 29 | } |
| 30 | return append([]VerifyCheck(nil), checks...) |
| 31 | } |
| 32 |