darkfactory

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package darkfactory holds the network-backed candidate evaluator that decides whether an open draft PR carries an approved-not-completed dark-factory spec in its diff and therefore warrants a dark-factory-implement task.

Index

Constants

View Source
const (
	ReasonNotDraft         = "not_draft"
	ReasonNotOpen          = "not_open"
	ReasonNoDarkFactoryYML = "no_dark_factory_yaml"
	ReasonNoSpecInDiff     = "no_spec_in_diff"
	ReasonPromptsInFlight  = "prompts_in_flight"
)

Skip reason labels (also the IncFilterSkipped metric labels).

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentReader

type ContentReader interface {
	ListPRFiles(ctx context.Context, owner, repo string, number int) ([]string, error)
	GetContent(ctx context.Context, owner, repo, filePath, ref string) ([]byte, error)
	ListDir(ctx context.Context, owner, repo, dirPath, ref string) ([]string, error)
	IsNotFound(err error) bool
}

ContentReader is the narrow GitHub read surface the evaluator needs. It is declared here (with primitive returns only) so this package does not import pkg and the concrete *githubClient satisfies it structurally without an adapter or an import cycle.

type Input

type Input struct {
	Owner   string
	Repo    string
	Number  int
	HeadSHA string
	IsDraft bool
	State   string
}

Input is the per-PR data the evaluator decides on. IsDraft and State are the pulls/N-confirmed values (dodging search-index lag), not the search snapshot.

type Result

type Result struct {
	Keep         bool
	Reason       string
	MatchedSpecs []string
}

Result is the keep/skip verdict. Reason is the metric label for a skip and is empty when Keep is true. MatchedSpecs lists the approved-not-completed spec paths that satisfied the diff check (populated only when Keep is true).

func Evaluate

func Evaluate(ctx context.Context, reader ContentReader, in Input) (Result, error)

Evaluate returns Keep=true only when ALL hold at in.HeadSHA:

a. the PR is open and a draft;
b. .dark-factory.yaml is present;
c. at least one approved-not-completed spec under specs/in-progress/ is
   touched by the PR diff (existence alone is NOT enough — specs persist
   across their lifecycle);
d. no *.md remains under prompts/in-progress/ (self-trigger suppression).

A non-404 GitHub error is returned to the caller (cursor not advanced); a 404 on an expected-optional path is treated as "absent" and drives a skip verdict.

Jump to

Keyboard shortcuts

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