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 ¶
const ( ReasonNotDraft = "not_draft" ReasonNotOpen = "not_open" ReasonNoDarkFactoryYML = "no_dark_factory_yaml" ReasonNoSpecInDiff = "no_spec_in_diff" )
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 ¶
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 ¶
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).
PromptsQueued reports whether *.md files remain under prompts/in-progress/ at head — prompts approved and awaiting execution. It never causes a skip; the caller feeds it into DeriveTaskID, which drops the head SHA from the key while prompts are queued so the agent's own commits dedup instead of re-triggering.
func Evaluate ¶
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).
Queued prompts under prompts/in-progress/ are NOT a veto: they mean "approved, awaiting execution", which is exactly the state that must trigger. The self-trigger loop rule (d) used to guard against is prevented by the task identifier instead (DeriveTaskID drops the head SHA while prompts are queued), so the agent's own commits dedup rather than spawning a second run.
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.