Problem
internal/hook/emit.go has zero test coverage. emitEvent() writes governance events to a JSONL file and RotateEvents() rotates the file for ingestion by Sentinel. If these break, telemetry goes dark.
Acceptance Criteria
Hints
- File:
internal/hook/emit.go
- Functions:
emitEvent(), detectAgent(), truncate(), RotateEvents()
emitEvent() is unexported — test via package-level test file in hook package
- Events file:
<CHITIN_WORKSPACE>/.chitin/events.jsonl
- Create test file:
internal/hook/emit_test.go
Generated by /forge fill
Problem
internal/hook/emit.gohas zero test coverage.emitEvent()writes governance events to a JSONL file andRotateEvents()rotates the file for ingestion by Sentinel. If these break, telemetry goes dark.Acceptance Criteria
emitEvent()appends valid JSON line to<workspace>/.chitin/events.jsonlemitEvent()creates the.chitindirectory if missingemitEvent()is a no-op when CHITIN_WORKSPACE is emptydetectAgent()returns correct agent name for CHITIN_AGENT, CLAUDE_HOOK_EVENT_NAME, COPILOT_HOOK_EVENT, and unknowntruncate()truncates strings longer than max and passes through shorter stringsRotateEvents()renames events.jsonl to a timestamped filenameRotateEvents()returns empty string when no events file existsRotateEvents()returns empty string when CHITIN_WORKSPACE is emptyt.TempDir()andt.Setenv()go test ./internal/hook/...Hints
internal/hook/emit.goemitEvent(),detectAgent(),truncate(),RotateEvents()emitEvent()is unexported — test via package-level test file inhookpackage<CHITIN_WORKSPACE>/.chitin/events.jsonlinternal/hook/emit_test.goGenerated by /forge fill