derive

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package derive owns M5's pure derivation seam and C-P5 dirty-set drain loop. Classification policy remains outside the sync engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PullRequestIdentity

func PullRequestIdentity(repositoryGitHubID int64, pullNumber int) string

PullRequestIdentity returns the stable C-D3 identity for a loose pull request.

func StackIdentity

func StackIdentity(repositoryGitHubID int64, stackNumber int) string

StackIdentity returns the stable C-D3 identity for a repository stack.

Types

type Deriver

type Deriver interface {
	Derive(Snapshot) []ScopeResult
}

Deriver is the pure C-D1 seam. Implementations may inspect only Snapshot and must perform no I/O.

type NoopDeriver

type NoopDeriver struct{}

NoopDeriver is the default M5 implementation. It proves the drain loop and leaves classification to the future derivation project.

func (NoopDeriver) Derive

func (NoopDeriver) Derive(snapshot Snapshot) []ScopeResult

Derive returns one empty, scope-owned result per input and performs no I/O.

type Observer

type Observer interface {
	DeriverPass(context.Context, int, time.Duration, error)
}

Observer is M6's C-P5 pass-duration seam.

type Options

type Options struct {
	Pool           *pgxpool.Pool
	Deriver        Deriver
	DirtyCap       int
	PollInterval   time.Duration
	Observer       Observer
	InstallationID int64
	Tracer         trace.Tracer
}

Options configures the dirty-set loop.

type ScopeResult

type ScopeResult struct {
	ScopeKey  string     `json:"scope_key"`
	WorkItems []WorkItem `json:"work_items"`
}

ScopeResult is the complete derived output owned by one claimed C-D2 scope. Returning an empty WorkItems set removes every prior item for that scope.

type ScopeSnapshot

type ScopeSnapshot struct {
	ScopeKey string
	OrgID    int64
	RepoID   int64
	Data     json.RawMessage
}

ScopeSnapshot contains a dirty scope and its cache rows encoded as one stable JSON document for the pure deriver. Data contains only live cache rows; a loose-PR scope never contains a PR currently owned by a stack.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service drains dirty scopes and applies each derivation batch atomically.

func New

func New(options *Options) (*Service, error)

New constructs a C-D2/C-P5 derivation service. NoopDeriver is wired when no implementation is supplied.

func (*Service) Run

func (s *Service) Run(ctx context.Context) error

Run drains full batches immediately, then uses dirty-set NOTIFY as a latency hint with interval polling as the correctness path.

func (*Service) RunOnce

func (s *Service) RunOnce(ctx context.Context) (int, error)

RunOnce claims the entire currently available dirty set up to DirtyCap, loads one cache snapshot, calls the pure deriver once, and writes work items, work_items events, and dirty-row deletes in one transaction (C-P5).

type Snapshot

type Snapshot struct {
	Scopes []ScopeSnapshot
}

Snapshot is one snapshot-consistent cache view for an entire claimed dirty set (C-D2/C-P5).

type SnapshotLoader

type SnapshotLoader struct{}

SnapshotLoader loads all cache state for a claimed C-D2 scope set with one set-oriented query inside the derivation transaction.

func (SnapshotLoader) Load

func (SnapshotLoader) Load(
	ctx context.Context,
	tx pgx.Tx,
	scopeKeys []string,
) (Snapshot, error)

Load returns repository, rule, stack/PR, review-thread, and check-run rows for every requested scope from the transaction's single snapshot.

type WorkItem

type WorkItem struct {
	IdentityKey string          `json:"identity_key"`
	OrgID       int64           `json:"org_id"`
	Payload     json.RawMessage `json:"payload"`
}

WorkItem is the minimal derived value persisted by M5.

Jump to

Keyboard shortcuts

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