Help us shape the future of Go! Take the 2026 Go Developer Survey

processor

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ModelPrefixes = map[string]string{
	"fireworks": "accounts/fireworks/models/",
}
View Source
var ProviderAliases = map[Harness]map[string]string{
	HarnessOpenCode:   {"fireworks-ai": "fireworks"},
	HarnessPi:         {"openai-codex": "openai", "fireworks-ai": "fireworks"},
	HarnessCodex:      {"fireworks-ai": "fireworks"},
	HarnessClaudeCode: {"fireworks-ai": "fireworks"},
}

Source identifiers stay in raw_token_usage; these rules affect canonical facts only.

Functions

func CanonicalModel

func CanonicalModel(model *string, provider string) string

func CanonicalProvider

func CanonicalProvider(harness string, provider *string) (string, string)

func ClaudeCodeMessage

func ClaudeCodeMessage(ctx context.Context, source NativeSource, options ParseOptions, fallbackSessionID string, record map[string]interface{}) (RawTokenFact, []Diagnostic, bool)

func CodexIntField

func CodexIntField(usage map[string]interface{}, name string) *int64

func CodexMessageIdentity

func CodexMessageIdentity(turnID *string, occurredAtMs int64, line int, snapshot CodexSnapshot) string

CodexMessageIdentity retains native turn/time/snapshot identity, including the line witness required when cumulative source usage is absent.

func CodexReplayFingerprint

func CodexReplayFingerprint(turnID, provider, model *string, snapshot CodexSnapshot, valid bool) string

CodexReplayFingerprint is proof only for complete, native integer snapshots.

func CodexTokens

func CodexTokens(usage map[string]interface{}) (TokenComponents, []Diagnostic, bool)

func HasInvalidIntegerField

func HasInvalidIntegerField(record map[string]interface{}, names ...string) bool

func IntField

func IntField(record map[string]interface{}, names ...string) *int64

func NativeTupleHash

func NativeTupleHash(parts ...string) string

Native tuples use unambiguous encoding; source IDs may contain separators.

func Nested

func Nested(record map[string]interface{}, key string) map[string]interface{}

func NormalizationRuleSignature

func NormalizationRuleSignature(harness string) string

func OpenCodeMessage

func OpenCodeMessage(source NativeSource, options ParseOptions, messageID string, sessionID *string, created *int64, data string, v2 bool) (RawTokenFact, []Diagnostic, bool)

OpenCodeMessage interprets native message metadata. Optional row fields are pointers so SQL nullability stays in the reader adapter.

func PiMessage

func PiMessage(ctx context.Context, source NativeSource, options ParseOptions, sessionID string, nativeSession bool, record map[string]interface{}) (RawTokenFact, []Diagnostic, bool)

func Process

func Process(ctx context.Context, records []evidence.Stored) (evidence.Projection, error)

Process is deterministic and has no database, filesystem or Git reads. All interpretation happens here, after the server durably accepts evidence.

func SourceIdentityJSON

func SourceIdentityJSON(sessionSource string, requestID *string) *string

func SourceSessionIdentity

func SourceSessionIdentity(metadata *string) string

func StableHash

func StableHash(value string) string

func StringField

func StringField(record map[string]interface{}, names ...string) *string

func StringValue

func StringValue(record map[string]interface{}, fallback string, names ...string) string

func TokenComponentSum

func TokenComponentSum(values ...*int64) (int64, bool)

Types

type CodexSnapshot

type CodexSnapshot struct {
	Last  *CodexUsageSnapshot `json:"last"`
	Total *CodexUsageSnapshot `json:"total"`
}

type CodexUsageSnapshot

type CodexUsageSnapshot struct {
	Input       *int64 `json:"input"`
	CachedInput *int64 `json:"cachedInput"`
	CacheRead   *int64 `json:"cacheRead"`
	Output      *int64 `json:"output"`
	Reasoning   *int64 `json:"reasoning"`
	Total       *int64 `json:"total"`
}

Snapshot fields preserve source presence and both cache aliases. Replay proof must compare the source counters, not normalized/clamped token components.

func CodexSnapshotFromUsage

func CodexSnapshotFromUsage(usage map[string]interface{}) (*CodexUsageSnapshot, bool)

type Diagnostic

type Diagnostic struct {
	Harness                             Harness
	RawFactKey, Severity, Code, Message string
	MetadataJSON                        *string
}

func FinalizeClaudeCodeFact

func FinalizeClaudeCodeFact(fact *RawTokenFact) ([]Diagnostic, bool)

type Harness

type Harness string
const (
	HarnessOpenCode   Harness = "opencode"
	HarnessPi         Harness = "pi"
	HarnessCodex      Harness = "codex"
	HarnessClaudeCode Harness = "claude-code"
)

type NativeSource

type NativeSource struct {
	Harness     Harness
	ID          string
	Kind        string
	RawSourceID string
}

type ParseOptions

type ParseOptions struct {
	ObservedAtMs      int64
	Collector, Parser string
}

type RawTokenFact

type RawTokenFact struct {
	Harness          Harness
	SourceID         string
	SourceKind       string
	Collector        string
	Parser           string
	ObservedAtMs     int64
	OccurredAtMs     *int64
	SessionID        *string
	MessageID        *string
	Provider         *string
	Model            *string
	UsageScope       string
	Quality          string
	InputTokens      *int64
	OutputTokens     *int64
	ReasoningTokens  *int64
	CacheReadTokens  *int64
	CacheWriteTokens *int64
	TotalTokens      *int64
	MetadataJSON     *string
	DedupeKey        string
}

type TokenComponents

type TokenComponents struct{ Input, Output, Reasoning, CacheRead, CacheWrite, Total *int64 }

TokenComponents are exclusive components after source-native normalization.

Jump to

Keyboard shortcuts

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