codify

package
v0.59.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package codify opens pull requests that graduate repository lessons into steering notes. It never merges one.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoClass reports an attempt to codify a lesson that has no task class.
	ErrNoClass = errors.New("codify: a lesson needs a task class before it can be codified")
	// ErrInvalidNote reports a steering note or class name that fails steering.Validate.
	ErrInvalidNote = errors.New("codify: steering note failed validation")
	// ErrNoConnection reports a repository without a factory GitHub App connection.
	ErrNoConnection = errors.New("codify: the repository has no factory connection")
)

Functions

This section is empty.

Types

type Broker

type Broker interface {
	CodifyingLessons(ctx context.Context) ([]rooms.Lesson, error)
	FinishCodify(ctx context.Context, repository string, number int, merged bool) (rooms.Lesson, error)
}

Broker reads lessons awaiting codify PR completion and reports PR outcomes back to the broker; *rooms.Client implements it.

type ErrTooLarge

type ErrTooLarge struct {
	Current   int
	Resulting int
}

ErrTooLarge reports that appending the codified lesson would push the steering note past steering.MaxBytes.

func (ErrTooLarge) Error

func (e ErrTooLarge) Error() string

Error implements error.

type Meta

type Meta struct {
	Source      string `json:"source,omitempty"`
	RecallCount int    `json:"recallCount,omitempty"`
}

Meta carries optional provenance metadata included in the pull request body.

type Result

type Result struct {
	Number  int    `json:"number"`
	URL     string `json:"url"`
	Created bool   `json:"created"`
}

Result describes the pull request opened or reused for a codified lesson.

type Service

type Service struct {
	Git func(repository string) (promote.Git, bool)
}

Service opens steering-note pull requests for repository lessons using the factory App.

func (*Service) Open

func (s *Service) Open(ctx context.Context, repository, class, lessonID, text string, meta ...Meta) (Result, error)

Open opens a pull request on repository that appends lessonID/text to the steering note for class, idempotently reusing an already-open pull request on the codify branch.

type Watcher

type Watcher struct {
	Broker     Broker
	Git        func(repository string) (promote.Git, bool)
	Every      time.Duration
	RetryEvery time.Duration
	Ticker     func(d time.Duration) (<-chan time.Time, func())
	After      func(d time.Duration) <-chan time.Time
	Log        *slog.Logger
}

Watcher polls active lessons with open codify pull requests and updates the broker when those pull requests merge or close unmerged.

func (*Watcher) Run

func (w *Watcher) Run(ctx context.Context) error

Run checks codifying lessons once at startup and then on every interval (10 minutes by default) until ctx is cancelled. When a poll encounters transient errors or unwired repositories, it schedules a short retry (10 seconds by default, capped at the poll interval).

Jump to

Keyboard shortcuts

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