shared

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendFileWithParents

func AppendFileWithParents(path, mkdirContext, openContext string) (*os.File, error)

AppendFileWithParents opens a BEAM artifact file for append after ensuring its parent directory exists.

func AppendJSONLFileWithParents

func AppendJSONLFileWithParents[T any](path, mkdirContext, openContext, writeContext string, rows []T) error

AppendJSONLFileWithParents opens a parent-creating BEAM JSONL artifact for append and writes rows to it.

func ChecksumBytesSHA256

func ChecksumBytesSHA256(raw []byte) string

func CreateFileWithParents

func CreateFileWithParents(path, mkdirContext, createContext string) (*os.File, error)

CreateFileWithParents creates/truncates a BEAM artifact file after ensuring its parent directory exists.

func FirstNonEmptyTrimmed

func FirstNonEmptyTrimmed(values ...string) string

FirstNonEmptyTrimmed returns the first argument with non-empty trimmed content.

func ForEachNonEmptyJSONLLine

func ForEachNonEmptyJSONLLine(scanner *bufio.Scanner, scanContext string, handle func(lineNumber int, line string) error) error

ForEachNonEmptyJSONLLine walks non-blank JSONL lines with BEAM's shared trim-and-scan-error convention.

func FormatArtifactTimestamp

func FormatArtifactTimestamp(t time.Time) string

FormatArtifactTimestamp returns the shared BEAM UTC RFC3339 timestamp format.

func HasNonEmptyTrimmed

func HasNonEmptyTrimmed(value string) bool

HasNonEmptyTrimmed reports whether value has non-empty content after trimming.

func JSONRawIsEmptyOrNull

func JSONRawIsEmptyOrNull(raw []byte) bool

JSONRawIsEmptyOrNull reports whether a raw JSON value is absent or the JSON null literal.

func MarshalIndentedJSON

func MarshalIndentedJSON(value any) ([]byte, error)

MarshalIndentedJSON marshals a BEAM artifact JSON document with the repository's trailing newline convention.

func NewJSONLScanner

func NewJSONLScanner(r io.Reader) *bufio.Scanner

NewJSONLScanner returns a scanner sized for BEAM JSONL artifacts that can contain large prompt/context rows.

func NormalizeAbility

func NormalizeAbility(ability string) string

NormalizeAbility returns the canonical BEAM ability code used in artifacts and match keys.

func NormalizeEvidenceKind

func NormalizeEvidenceKind(kind string) string

NormalizeEvidenceKind returns the canonical BEAM evidence-kind token.

func NormalizeQuestionText

func NormalizeQuestionText(question string) string

NormalizeQuestionText returns the canonical question text used for BEAM question-key matching.

func NormalizeRecordType

func NormalizeRecordType(recordType string) string

NormalizeRecordType returns the canonical BEAM JSONL record type.

func PairedOutcomeCorrect

func PairedOutcomeCorrect(score float64) bool

PairedOutcomeCorrect reports the shared BEAM paired-outcome correctness contract.

func ReadFileWithChecksum

func ReadFileWithChecksum(path, readContext string) ([]byte, string, error)

ReadFileWithChecksum reads a BEAM artifact and returns its raw bytes plus SHA-256 checksum.

func ReadJSONLFile

func ReadJSONLFile[T any](path, openContext, scanContext, decodeContext string) ([]T, error)

ReadJSONLFile decodes a BEAM JSONL file using the shared scan and non-empty-line convention.

func RoundMetric

func RoundMetric(v float64) float64

func RoundSignedMetric

func RoundSignedMetric(v float64) float64

func SortedStringMapKeys

func SortedStringMapKeys[V any](values map[string]V) []string

SortedStringMapKeys returns map keys in stable lexical order.

func TopN

func TopN(values []string, n int) []string

func TrimJSONRaw

func TrimJSONRaw(raw []byte) []byte

TrimJSONRaw returns raw JSON bytes after whitespace trimming.

func WriteBytesArtifact

func WriteBytesArtifact(path string, raw []byte, mkdirContext, writeContext string) error

WriteBytesArtifact writes a BEAM byte artifact to stdout when path is "-" or to a parent-creating file otherwise.

func WriteFileWithParents

func WriteFileWithParents(path string, raw []byte, mkdirContext, writeContext string) error

WriteFileWithParents writes a BEAM artifact file after ensuring its parent directory exists.

func WriteJSONLFileWithParents

func WriteJSONLFileWithParents[T any](path, mkdirContext, createContext, writeContext string, rows []T) error

WriteJSONLFileWithParents creates/truncates a parent-creating BEAM JSONL artifact and writes rows to it.

func WriteJSONLRows

func WriteJSONLRows[T any](w io.Writer, rows []T, writeContext string) error

WriteJSONLRows writes BEAM JSONL rows using the shared one-object-per-line artifact convention.

Types

type OutcomeKey

type OutcomeKey = identity.OutcomeKey

OutcomeKey identifies a BEAM row by the exact scale/conversation/qid match contract.

func NewOutcomeKey

func NewOutcomeKey(scale, conversationID, qid string) OutcomeKey

NewOutcomeKey normalizes BEAM row identity fields for maps and deterministic sorting.

type PairedOutcome

type PairedOutcome = outcome.PairedOutcome

PairedOutcome is the JSONL contract used by BEAM oracle runs and paired comparisons.

type QuestionKey

type QuestionKey = identity.QuestionKey

QuestionKey identifies a BEAM row by normalized question fallback identity.

func NewQuestionKey

func NewQuestionKey(scale, conversationID, ability, question string) QuestionKey

NewQuestionKey normalizes BEAM question fallback fields for oracle judgment and paired-outcome matching.

type ScoreTally

type ScoreTally = score.ScoreTally

ScoreTally accumulates BEAM score totals with the shared rounded-average convention.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL