@@ -14,7 +14,6 @@ import (
1414 "time"
1515
1616 hawkconfig "github.com/GrayCodeAI/hawk/config"
17- "github.com/GrayCodeAI/hawk/session"
1817)
1918
2019// ─── friendlyError ────────────────────────────────────────────────────────────
@@ -174,6 +173,7 @@ func friendlyError(err error) string {
174173// Catches panics, saves the current session state, logs the stack trace to
175174// ~/.hawk/crash.log, and exits with a user-friendly message.
176175
176+ //lint:ignore U1000 Infrastructure wired in main.go for production builds
177177func panicRecovery (saveFn func ()) {
178178 if r := recover (); r != nil {
179179 stack := string (debug .Stack ())
@@ -221,6 +221,7 @@ func panicRecovery(saveFn func()) {
221221// Handles SIGTERM, SIGINT, and SIGHUP gracefully. Calls the provided save
222222// function before exiting to ensure the current session is persisted.
223223
224+ //lint:ignore U1000 Infrastructure wired in main.go for production builds
224225func signalHandler (saveFn func ()) {
225226 sigCh := make (chan os.Signal , 1 )
226227 signal .Notify (sigCh , syscall .SIGINT , syscall .SIGTERM , syscall .SIGHUP )
@@ -261,9 +262,11 @@ type errorLoggerT struct {
261262 path string
262263}
263264
265+ //lint:ignore U1000 Singleton used by logError below
264266var errLogger * errorLoggerT
265267var errLoggerOnce sync.Once
266268
269+ //lint:ignore U1000 Infrastructure used by logError
267270func getErrorLogger () * errorLoggerT {
268271 errLoggerOnce .Do (func () {
269272 home , _ := os .UserHomeDir ()
@@ -324,11 +327,6 @@ func (l *errorLoggerT) LogErrorf(format string, args ...interface{}) {
324327 f .WriteString (entry )
325328}
326329
327- // logError is a package-level convenience that uses the singleton error logger.
328- func logError (context string , err error ) {
329- getErrorLogger ().LogError (context , err )
330- }
331-
332330// ─── validateStartup ─────────────────────────────────────────────────────────
333331// Checks essential prerequisites before starting a session:
334332// - API key is set for the configured provider
@@ -424,25 +422,4 @@ func providerDNSHost(provider string) string {
424422 }
425423}
426424
427- // ─── Helpers used by session save in panic/signal paths ───────────────────────
428-
429- // saveSessionSafe is a helper for use in panic recovery and signal handlers.
430- // It wraps session.Save with error recovery so it never panics.
431- func saveSessionSafe (sessionID string , model , provider string , messages []session.Message ) {
432- defer func () { recover () }()
433425
434- if len (messages ) == 0 || sessionID == "" {
435- return
436- }
437-
438- s := & session.Session {
439- ID : sessionID ,
440- Model : model ,
441- Provider : provider ,
442- Messages : messages ,
443- CreatedAt : time .Now (),
444- }
445- if err := session .Save (s ); err != nil {
446- logError ("save_session_panic" , err )
447- }
448- }
0 commit comments