Files
archie/internal/domain/workflow/test_run.go
T
sam f92c5b4536
ci/woodpecker/pr/quality Pipeline was successful
Quality / check (pull_request) Canceled after 7m39s
chore(runtime): delete Kit and external agent harness support (#1877)
Archie runs its own agent loop only. Removes Kit resolution and launch,
the harness runner and adapters, the setup terminal and sandbox view,
harness secrets and OAuth capture (table dropped in migration 0075), the
task-tools contract that only Kit containers reached, and the
sandbox-kit-spec dependency. Agent profiles carry image and tools only.
The egress proxy keeps the model-session path; the sandbox relay code
stays for #1867.
2026-11-12 21:29:05 +11:00

94 lines
3.5 KiB
Go

package workflow
import (
"context"
"fmt"
"github.com/samcharles93/archie-core/internal/events"
)
// Deliveries is the one door a run's outward effects pass through: a forge
// write, a push, an HTTP post. There is one implementation, recordDeliveries,
// because a live run needs none -- a nil TaskContext.Deliveries performs.
type Deliveries interface {
// Record records one effect the run must not perform: what it would have
// done, phrased without the leading "would". The caller returns success as
// though it had been delivered, so the rest of the step runs as it would
// have.
Record(ctx context.Context, detail string)
}
// RecordDeliveries makes tc record every outward delivery its steps ask for
// and perform none of them, so an operator can run a draft workflow and see
// what it would do without it reaching anyone. The forge and push writes are
// wrapped here. A container's own network has no proxy in front of it, so
// nothing it sends is recorded.
func RecordDeliveries(tc *TaskContext) {
tc.Deliveries = recordDeliveries{tc: tc}
tc.Forge = recordedForge{Forger: tc.Forge, deliveries: tc.Deliveries}
tc.Trees = recordedTrees{Trees: tc.Trees, deliveries: tc.Deliveries}
}
type recordDeliveries struct {
tc *TaskContext
}
func (r recordDeliveries) Record(ctx context.Context, detail string) {
r.tc.Emit(ctx, events.KindDeliveryRecorded, r.tc.Stage, "would "+detail, nil)
}
type recordedForge struct {
Forger
deliveries Deliveries
}
func (f recordedForge) CreateIssue(ctx context.Context, owner, repo, title, _ string, _ []string) (int, error) {
f.deliveries.Record(ctx, fmt.Sprintf("open issue %q in %s/%s", title, owner, repo))
return 0, nil
}
func (f recordedForge) CloseIssue(ctx context.Context, owner, repo string, number int, _ string) error {
f.deliveries.Record(ctx, fmt.Sprintf("close issue %s/%s#%d", owner, repo, number))
return nil
}
func (f recordedForge) SetStateLabel(ctx context.Context, owner, repo string, number int, label string, _ []string) error {
f.deliveries.Record(ctx, fmt.Sprintf("label %s/%s#%d %q", owner, repo, number, label))
return nil
}
func (f recordedForge) CreatePR(ctx context.Context, owner, repo, title, head, base, _ string) (int, error) {
f.deliveries.Record(ctx, fmt.Sprintf("open PR %q in %s/%s from %s into %s", title, owner, repo, head, base))
return 0, nil
}
func (f recordedForge) LinkBranch(ctx context.Context, owner, repo string, number int, branch string) error {
f.deliveries.Record(ctx, fmt.Sprintf("link %s to %s/%s#%d", branch, owner, repo, number))
return nil
}
func (f recordedForge) CreateReviewComments(ctx context.Context, owner, repo string, number int, _ string, review Review) error {
f.deliveries.Record(ctx, fmt.Sprintf("post a %s review with %d comments on %s/%s#%d", review.Event, len(review.Comments), owner, repo, number))
return nil
}
func (f recordedForge) Comment(ctx context.Context, owner, repo string, number int, body string) (int64, error) {
f.deliveries.Record(ctx, fmt.Sprintf("comment on %s/%s#%d: %s", owner, repo, number, body))
return 0, nil
}
func (f recordedForge) ReplyToReview(ctx context.Context, owner, repo string, number int, _ int64, body string) error {
f.deliveries.Record(ctx, fmt.Sprintf("reply to a review on %s/%s#%d: %s", owner, repo, number, body))
return nil
}
type recordedTrees struct {
Trees
deliveries Deliveries
}
func (t recordedTrees) Push(ctx context.Context, _, branch string) error {
t.deliveries.Record(ctx, fmt.Sprintf("push branch %s", branch))
return nil
}