commitattribution

package
v0.2.0-rc.1 Latest Latest
Warning

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

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

README

Durable session commit observations

The live tracker identifies the agent session whose process ancestry owns a Git post-commit or pre-push hook. This store retains those observations in the private application database, under attribution/commits/<repository>/<sha>. Records keep canonical repository and agent identity, session, exact SHA, commit/push kind, hook event id and UTC observation time. There is no TTL.

A post-commit observation establishes commit creation. A pre-push observation records context, including pushes that later fail remotely, and never proves that its session authored a commit. Checkout history is not written here.

Writes merge idempotently under the application database write transaction. Independent writers cannot overwrite each other's observations. Reads are indexed by repository and SHA and never create a database. The tracker retains failed writes in its recovery file and retries them, independently of live session expiry. Existing saved hook work is backfilled at startup.

The shared local resolver adds creation references alongside transcript references without changing cached session graphs. It preserves links when a transcript is absent, marking conversation and usage as unavailable. The same resolver supplies review session cards, review bundles and feature attribution.

Run the focused checks from the monorepo root, in Docker:

just oss-go test -race ./internal/commitattribution ./internal/livesessions ./internal/locallink

Documentation

Overview

Package commitattribution retains session-owned Git hook observations beyond the lifetime of the live session tracker. Pushes are context; only a post-commit observation establishes commit creation.

Index

Constants

View Source
const Commit = "commit"
View Source
const Push = "push"

Variables

This section is empty.

Functions

func Vendor

func Vendor(agent string) string

Vendor translates the live hook agent spelling to the session store spelling.

Types

type Observation

type Observation struct {
	Repository string    `json:"repository"`
	CommitSHA  string    `json:"commit"`
	Agent      string    `json:"agent"`
	SessionID  string    `json:"session"`
	Kind       string    `json:"kind"`
	EventID    string    `json:"event"`
	At         time.Time `json:"at"`
}

Observation records the session identified by a Git hook's process ancestry. Repository includes the GitHub host for enterprise repositories. No local paths or conversation text are retained.

type Store

type Store struct{ Path string }

Store uses the shared application database. The empty Path selects its default location. Reads never create a database, and records have no TTL.

func (*Store) Lookup

func (s *Store) Lookup(ctx context.Context, repositories, commits []string) ([]Observation, error)

Lookup reads observations of exactly these commits, scoped to repositories named by the clone's remotes. Missing application state is an empty result.

func (*Store) Record

func (s *Store) Record(observations []Observation) error

Record merges observations idempotently under SQLite's write transaction. A failed write leaves the prior records available for retry.

Jump to

Keyboard shortcuts

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