Documentation
¶
Overview ¶
Package hook is part of the GoFastr harness.
See docs/harness-architecture.md for the architecture this package implements.
Package hook implements lifecycle hooks: shell commands the harness runs at well-known event points. Per § Hook timeouts:
- Per-event default timeouts (5/30/30/60/5/5).
- SIGTERM at deadline, SIGKILL at deadline+5s.
- stdout/stderr capped at 64KB.
- Non-zero exit emits HookError; deadline emits HookTimeout.
Hooks are SHA-256 hashed (rule 13). Project-local hooks (`<repo>/.gofastr/harness/hooks/`) are off unless --allow-project-hooks is set.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultTimeout ¶
DefaultTimeout returns the per-event default timeout. Profiles may override per-hook via timeout_ms in TOML.
Types ¶
type Hook ¶
type Hook struct {
Event Event
Command string // shell command, run via /bin/sh -c
Timeout time.Duration // 0 = use DefaultTimeout(Event)
SHA256 string // populated by the TOFU loader
// Source tells the runner where the hook came from for the
// --allow-project-hooks gate. "user" = ~/.config/...; "project"
// = <repo>/.gofastr/...; "builtin" = ships with the binary.
Source string
}
Hook is one configured hook entry.
type Result ¶
type Result struct {
Event Event
Command string
ExitCode int
TimedOut bool
Output string // combined stdout+stderr, capped at 64KB
Duration time.Duration
}
Result is the outcome of running one hook.
func (Result) Summary ¶
Summary returns a short human-readable description for the cost meter / TUI.
func (Result) TrimOutput ¶
TrimOutput returns the first n bytes of Output, ellipsizing if cut.
type Runner ¶
type Runner struct {
AllowProjectHooks bool
// contains filtered or unexported fields
}
Runner runs hooks per event. Concurrency-safe.