Documentation
¶
Overview ¶
Package extractor turns raw GitHub Actions log archives into the small, relevant excerpts an LLM can actually reason about.
Index ¶
Constants ¶
const MaxArchiveBytes = 64 << 20 // 64 MiB
MaxArchiveBytes caps how much a single archive may expand to. Archives are fetched from a remote API, so an unbounded read is a decompression-bomb vector as well as an out-of-memory risk on a small runner.
Variables ¶
This section is empty.
Functions ¶
func ErrorBlock ¶
ErrorBlock returns the contiguous region around the strongest failure signal, with `before` lines of lead-in and `after` lines of trailing context.
Anchoring on the failure rather than on the end of the file matters because Go's test runner, and most others, print a summary block after the failure — tailing the file blindly captures the summary and drops the stack trace that explains it.
Types ¶
type ChunkOptions ¶
type ChunkOptions struct {
// MaxChars is the hard ceiling on the excerpt. Characters rather than tokens
// because the budget must hold for any provider; ~4 chars/token is the usual
// rule of thumb, so 12000 chars is roughly 3k tokens.
MaxChars int
// LinesBefore and LinesAfter frame the failure anchor.
LinesBefore int
LinesAfter int
// HeadLines keeps the start of the step, where the command and environment
// are echoed — often the difference between a confident and an unknown verdict.
HeadLines int
}
ChunkOptions tunes how a step log is reduced to an LLM-sized excerpt.
func DefaultChunkOptions ¶
func DefaultChunkOptions() ChunkOptions
DefaultChunkOptions is a budget that fits comfortably in a small local model's context while still carrying a full stack trace.
type Excerpt ¶
type Excerpt struct {
Text string `json:"text"`
StepName string `json:"step_name"`
OriginalBytes int `json:"original_bytes"`
ExcerptBytes int `json:"excerpt_bytes"`
Truncated bool `json:"truncated"`
}
Excerpt is the reduced log handed to a provider, plus what it cost.
func Chunk ¶
func Chunk(step StepLog, opts ChunkOptions) Excerpt
Chunk reduces a step log to an excerpt that fits the budget.
The strategy is deliberately not "take the last N bytes". A blind tail captures the runner's teardown and drops the stack trace, and a blind head captures setup and never reaches the failure. Instead the excerpt is built from the two regions that carry signal — the command echo at the top, and the window around the failure — joined by an explicit elision marker so the model knows material was removed rather than inferring a gap in the story.
func ChunkArchive ¶
func ChunkArchive(data []byte, opts ChunkOptions) (Excerpt, error)
ChunkArchive is the whole path from raw archive bytes to an excerpt.
type StepLog ¶
type StepLog struct {
// JobDir is the folder inside the archive, which GitHub names after the job.
JobDir string
// Order is the numeric prefix GitHub puts on each step file ("3_Run tests.txt").
Order int
Name string
Body string
}
StepLog is one step's output from within a job's log archive.
func FailingStep ¶
FailingStep picks the step most likely to contain the real failure.
The last step with an explicit error marker wins. Preferring the last one matters: post-job cleanup steps frequently mention "error" while unwinding, and a naive first-match lands on a red herring instead of the test output.
func ReadArchive ¶
ReadArchive parses a GitHub Actions log archive.
The layout is not documented as a contract, but in practice is either a flat set of "<n>_<step name>.txt" files, or one directory per job containing them. Both shapes are handled, and anything that is not a .txt file is skipped.