chore: replace 607 em-dashes with double hyphens project-wide

Includes MCP crash-after-init test fix (crash moved from handle() to serve()
entry point so transport sees immediate subprocess death).
This commit is contained in:
sam committed 2026-07-26 09:53:33 +10:00
1 parent 16d6cd62b7
commit f6d51416f0
112 files changed
+587 -582

No files matched your search

+4 -4
View File
@@ -15,7 +15,7 @@ import (
// AgentStage is the reusable bridge from a workflow stage to an
// agentloop run. Every LLM-driven stage in any workflow (implement's
// planner/builder, tdd's test-writer/fixer, feasibility's analyst)
// is an AgentStage with a different mission, gate, and result handler —
// is an AgentStage with a different mission, gate, and result handler --
// never a new engine.
type AgentStage struct {
Name string
@@ -33,7 +33,7 @@ type AgentStage struct {
// MaxSteps overrides the configured step budget when > 0 (planner
// stages are cheaper than builder stages).
MaxSteps int
// ProtectGlobs blocks write/edit on matching paths for this stage —
// ProtectGlobs blocks write/edit on matching paths for this stage --
// an environmental constraint, not a prompt rule (TDD's fix stage
// protects the committed repro tests; every builder stage protects
// the repo's generated files). The returned globs are combined
@@ -48,7 +48,7 @@ type AgentStage struct {
// ReviewResult gates agent output before OnResult forwards it to
// human channels. The daemon calls this hook to review stage output
// (issue comments, PR bodies) before human delivery. Return an
// error to block the stage. Nil means pass-through — no review.
// error to block the stage. Nil means pass-through -- no review.
// PRD §1: daemon reviews agent responses before forwarding.
ReviewResult func(*TaskContext, agentexec.Result) error
}
@@ -207,7 +207,7 @@ func missionWithSkill(tc *TaskContext, mission string) string {
// loadSkillBody loads the SKILL.md body and plugins for the current
// workflow from the worktree's .agents/skills/ directory. Skills declare
// their workflow in metadata.archie.workflow — no hardcoded mapping.
// their workflow in metadata.archie.workflow -- no hardcoded mapping.
// When metadata.archie.plugins is non-empty, only the listed plugin files
// are loaded in declared order; otherwise all *.go files are globbed.
func loadSkillBody(tc *TaskContext) string {
+3 -3
View File
@@ -175,7 +175,7 @@ func TestFeasibilityRejectsNullFitValue(t *testing.T) {
}
}
// ── regression: Gap 5 — daemon review step ──────────────────────────
// ── regression: Gap 5 -- daemon review step ──────────────────────────
func TestReviewResultBlocksOnResultWhenRejected(t *testing.T) {
// Gap 5: no daemon review step before human delivery.
@@ -183,7 +183,7 @@ func TestReviewResultBlocksOnResultWhenRejected(t *testing.T) {
// to human channels. When ReviewResult returns an error, the stage
// must fail and OnResult must NOT be called. When ReviewResult
// returns nil, OnResult IS called. Currently ReviewResult exists
// but no workflow uses it — the review step is never exercised.
// but no workflow uses it -- the review step is never exercised.
runner := &fakeAgentRunner{result: agentexec.Result{
Version: agentexec.ProtocolVersion, Status: agentexec.StatusPassed,
Summary: "sensitive output", TokensUsed: 1,
@@ -215,7 +215,7 @@ func TestReviewResultBlocksOnResultWhenRejected(t *testing.T) {
}
if onResultCalled {
t.Error("Gap 5: ReviewResult rejected the output but OnResult was still called. " +
"ReviewResult must gate OnResult — rejected output must not reach human channels.")
"ReviewResult must gate OnResult -- rejected output must not reach human channels.")
}
// Test 2: ReviewResult approves → OnResult IS called.
+3 -3
View File
@@ -16,7 +16,7 @@ import (
// against the project's direction, close it with reasons when it
// doesn't fit, otherwise produce a PRD, deliver it to Sam (issue
// comment + notify webhook), and hand the task to waiting_human. The
// daemon watches for Sam's reply and — LLM-judged, not keyword-matched —
// daemon watches for Sam's reply and -- LLM-judged, not keyword-matched --
// requeues approved features under the implement workflow or closes
// rejected ones. Routed via the "feature" label.
func Feasibility() Workflow {
@@ -61,7 +61,7 @@ func Feasibility() Workflow {
}
tc.decision = &decision{Fit: *captured.Fit, Reasons: captured.Reasons}
if !tc.decision.Fit {
comment := fmt.Sprintf("**archie assessed this feature as not a fit — closing as won't-do.**\n\n%s\n\n_Reopen and re-assign if you disagree._", tc.decision.Reasons)
comment := fmt.Sprintf("**archie assessed this feature as not a fit -- closing as won't-do.**\n\n%s\n\n_Reopen and re-assign if you disagree._", tc.decision.Reasons)
if err := tc.Forge.CloseIssue(context.Background(), tc.Task.Owner, tc.Task.Repo, tc.Task.IssueNumber, comment); err != nil {
return err
}
@@ -96,7 +96,7 @@ func Feasibility() Workflow {
// channel the daemon watches) plus the notify webhook (n8n →
// email).
{Name: "deliver", Run: func(ctx context.Context, tc *TaskContext) error {
body := fmt.Sprintf("**archie's PRD — awaiting your go/no-go.** Reply on this issue; I'll read your answer.\n\n%s", tc.Task.Plan)
body := fmt.Sprintf("**archie's PRD -- awaiting your go/no-go.** Reply on this issue; I'll read your answer.\n\n%s", tc.Task.Plan)
commentID, err := tc.Forge.Comment(ctx, tc.Task.Owner, tc.Task.Repo, tc.Task.IssueNumber, body)
if err != nil {
return err
+9 -9
View File
@@ -25,19 +25,19 @@ func StageBaselineGate() Stage {
if err == nil {
continue
}
tc.Log.Warn("baseline red — auto-fixing pre-existing gate failure",
tc.Log.Warn("baseline red -- auto-fixing pre-existing gate failure",
"cmd", strings.Join(argv, " "),
"err", clip(string(out), 200))
// Run builder to fix the failure via TDD.
mission := fmt.Sprintf(
"The baseline gate check `%s` failed on the repository %s at the base commit "+
"(before any feature work). This is a pre-existing issue — not caused by your work. "+
"(before any feature work). This is a pre-existing issue -- not caused by your work. "+
"Fix it using TDD:\n\n"+
"1. Write a test that proves the failure exists\n"+
"2. Run the test — it should FAIL (confirming the bug)\n"+
"2. Run the test -- it should FAIL (confirming the bug)\n"+
"3. Fix the root cause\n"+
"4. Run the test — it should PASS\n"+
"4. Run the test -- it should PASS\n"+
"5. Repeat until the gate `%s` passes for all packages\n\n"+
"Gate output:\n%s\n\n"+
"When the gate passes, call finish with status \"passed\".",
@@ -67,7 +67,7 @@ func StageBaselineGate() Stage {
return fmt.Errorf("baseline-fix agent run: %w", agentErr)
}
if res.Status != agentexec.StatusPassed {
return fmt.Errorf("baseline red — %s fails and builder could not auto-fix (status: %s)",
return fmt.Errorf("baseline red -- %s fails and builder could not auto-fix (status: %s)",
strings.Join(argv, " "), res.Status)
}
@@ -112,14 +112,14 @@ func Implement() Workflow {
"<issue number=%d>\n# %s\n\n%s\n</issue>\n\n"+
"Explore the codebase with your read-only tools, then call finish with status "+
"\"passed\" and the plan as the summary: files to touch, the approach, acceptance "+
"criteria, and what tests should prove it. Keep the plan tightly scoped to the issue — "+
"criteria, and what tests should prove it. Keep the plan tightly scoped to the issue -- "+
"call finish with status \"blocked\" if the issue is too vague or too large for one PR.",
tc.Repo.FullName(), tc.Task.IssueNumber, tc.Task.Title, tc.Task.Body,
)
},
OnResult: func(tc *TaskContext, res agentexec.Result) error {
tc.Task.Plan = res.Summary
body := fmt.Sprintf("**archie's plan** (review now if you want to veto — building starts immediately):\n\n%s", res.Summary)
body := fmt.Sprintf("**archie's plan** (review now if you want to veto -- building starts immediately):\n\n%s", res.Summary)
if _, err := tc.Forge.Comment(context.Background(), tc.Task.Owner, tc.Task.Repo, tc.Task.IssueNumber, body); err != nil {
tc.Log.Warn("failed to post plan comment", "err", err)
}
@@ -134,13 +134,13 @@ func Implement() Workflow {
return GateFromRepo(tc.Repo, tc.Cfg.Budgets)
},
ExtraRules: "Files matching the repository's protected suffixes (e.g. generated code) are " +
"write-blocked — edit their sources instead; the gate regenerates them.",
"write-blocked -- edit their sources instead; the gate regenerates them.",
Mission: func(tc *TaskContext) string {
return fmt.Sprintf(
"Implement this GitHub issue on the repository %s, following the plan below.\n\n"+
"<issue number=%d>\n# %s\n\n%s\n</issue>\n\n<plan>\n%s\n</plan>\n\n"+
"Make the smallest change that satisfies the issue and the plan's acceptance criteria. "+
"Do not run git — the orchestrator commits and pushes for you. When done, call finish "+
"Do not run git -- the orchestrator commits and pushes for you. When done, call finish "+
"with status \"passed\" and a summary written for the human who will review the pull "+
"request: what changed, why, and how it was verified.",
tc.Repo.FullName(), tc.Task.IssueNumber, tc.Task.Title, tc.Task.Body, tc.Task.Plan,
+1 -1
View File
@@ -25,7 +25,7 @@ func (f *fakeForge) Comment(ctx context.Context, owner, repo string, number int,
return 0, nil
}
// Remaining forge.Forge stubs — only CloseIssue and Comment are used by StageCommitPush.
// Remaining forge.Forge stubs -- only CloseIssue and Comment are used by StageCommitPush.
func (f *fakeForge) CreateIssue(ctx context.Context, owner, repo, title, body string, labels []string) (int, error) {
return 0, nil
}
+6 -6
View File
@@ -11,7 +11,7 @@ import (
"github.com/samcharles93/archie-core/internal/store"
)
// ── regression: Gap 7 — plugins discovered but not executed ─────────
// ── regression: Gap 7 -- plugins discovered but not executed ─────────
func TestSkillPluginsAvailableDuringStageExecution(t *testing.T) {
// Gap 7: skill.Discover() populates Skill.Plugins but nothing calls
@@ -24,7 +24,7 @@ func TestSkillPluginsAvailableDuringStageExecution(t *testing.T) {
// accessible via the TaskContext.
//
// Additionally (Gap 8): when metadata.archie.plugins lists specific
// plugin files, only those are loaded — unlisted *.go files are ignored.
// plugin files, only those are loaded -- unlisted *.go files are ignored.
dir := t.TempDir()
skillsDir := filepath.Join(dir, ".agents", "skills", "archie-wf-tdd")
@@ -61,7 +61,7 @@ func Run(input string) string {
t.Fatal(err)
}
// Write an unlisted plugin — it must NOT be loaded.
// Write an unlisted plugin -- it must NOT be loaded.
if err := os.WriteFile(filepath.Join(pluginsDir, "extra.go"), []byte(`package main
func Run(input string) string {
@@ -89,7 +89,7 @@ func Run(input string) string {
// Load the skill body (existing behavior).
body := loadSkillBody(tc)
if body == "" {
t.Fatal("skill body not loaded — worktree setup is wrong")
t.Fatal("skill body not loaded -- worktree setup is wrong")
}
// Gap 7 assertion: loadSkillBody must also populate skill plugins
@@ -105,12 +105,12 @@ func Run(input string) string {
// Gap 8 assertion: only the frontmatter-listed plugin must be loaded.
// The unlisted extra.go must NOT appear in SkillPlugins.
if len(tc.SkillPlugins) != 1 {
t.Errorf("Gap 8: got %d plugins, want 1 — loadSkillBody must honor "+
t.Errorf("Gap 8: got %d plugins, want 1 -- loadSkillBody must honor "+
"metadata.archie.plugins and exclude unlisted *.go files", len(tc.SkillPlugins))
}
for _, p := range tc.SkillPlugins {
if p.Name == "extra" {
t.Error("Gap 8: unlisted plugin 'extra' was loaded — " +
t.Error("Gap 8: unlisted plugin 'extra' was loaded -- " +
"loadSkillBody must only load plugins declared in metadata.archie.plugins")
}
}
+4 -4
View File
@@ -64,7 +64,7 @@ type SkillWorkflow struct {
// specific cloned worktree so that per-repo skills are discovered
// without restarting the daemon.
func AugmentRegistry(worktree string, base workflow.Registry) (workflow.Registry, error) {
// Copy base — never mutate the caller's registry.
// Copy base -- never mutate the caller's registry.
reg := make(workflow.Registry, len(base))
maps.Copy(reg, base)
if err := mergeSkillWorkflows(worktree, reg); err != nil {
@@ -102,9 +102,9 @@ func mergeSkillWorkflows(worktree string, reg workflow.Registry) error {
}
if len(wf.Stages) > 0 {
// Only warn when TWO SKILLS declare the same workflow name.
// Overriding a built-in name is routine — don't log.
// Overriding a built-in name is routine -- don't log.
if prevSkill, dup := seenFromSkill[entry.Workflow]; dup {
slog.Default().Warn("duplicate workflow name across skills — overriding",
slog.Default().Warn("duplicate workflow name across skills -- overriding",
"workflow", entry.Workflow,
"skill", entry.Dir,
"previous_skill", prevSkill,
@@ -141,7 +141,7 @@ func BuildWorkflow(worktree string, entry SkillWorkflow) (workflow.Workflow, err
}
sort.Strings(names)
// Each plugin file is package main defining Stage() — they must be
// Each plugin file is package main defining Stage() -- they must be
// evaluated in separate interpreters to avoid symbol collisions.
stages := make([]workflow.Stage, 0, len(names))
for _, name := range names {
+27 -27
View File
@@ -88,7 +88,7 @@ func Stage() (string, func(context.Context, *workflow.TaskContext) error) {
t.Errorf("stage[1].Name = %q, want world", wf.Stages[1].Name)
}
// Run the workflow — stages must execute in order.
// Run the workflow -- stages must execute in order.
tc := &workflow.TaskContext{BuildSummary: ""}
for _, s := range wf.Stages {
if err := s.Run(context.Background(), tc); err != nil {
@@ -101,7 +101,7 @@ func Stage() (string, func(context.Context, *workflow.TaskContext) error) {
}
func TestBuildWorkflowMissingSkillReturnsEmptyWorkflow(t *testing.T) {
// Missing plugins directory is not an error — same pattern as
// Missing plugins directory is not an error -- same pattern as
// wfeval.Discover. Returns a Workflow with no stages.
entry := SkillWorkflow{Workflow: "nonexistent", Dir: "nonexistent"}
wf, err := BuildWorkflow(t.TempDir(), entry)
@@ -124,7 +124,7 @@ func TestBuildRegistryFromSkillCatalog(t *testing.T) {
dir := t.TempDir()
// Skill 1: archie-wf-greet — plugin-defined workflow.
// Skill 1: archie-wf-greet -- plugin-defined workflow.
greetDir := filepath.Join(dir, ".agents", "skills", "archie-wf-greet", "plugins")
if err := os.MkdirAll(greetDir, 0o755); err != nil {
t.Fatal(err)
@@ -158,7 +158,7 @@ Greet the user.
t.Fatal(err)
}
// Skill 2: archie-wf-implement — overrides the built-in implement workflow.
// Skill 2: archie-wf-implement -- overrides the built-in implement workflow.
implDir := filepath.Join(dir, ".agents", "skills", "archie-wf-custom-impl", "plugins")
if err := os.MkdirAll(implDir, 0o755); err != nil {
t.Fatal(err)
@@ -207,9 +207,9 @@ Custom implementation workflow.
t.Errorf("Workflow.Name = %q, want greet", wf.Name)
}
if len(wf.Stages) == 0 {
t.Error("workflow 'greet' has no stages — plugin stages not loaded")
t.Error("workflow 'greet' has no stages -- plugin stages not loaded")
}
// Run it — stages must execute.
// Run it -- stages must execute.
tc := &workflow.TaskContext{BuildSummary: ""}
for _, s := range wf.Stages {
if err := s.Run(context.Background(), tc); err != nil {
@@ -237,7 +237,7 @@ Custom implementation workflow.
}
}
if tc.BuildSummary != "custom-impl-ran" {
t.Errorf("BuildSummary = %q, want 'custom-impl-ran' — skill override did not take effect", tc.BuildSummary)
t.Errorf("BuildSummary = %q, want 'custom-impl-ran' -- skill override did not take effect", tc.BuildSummary)
}
})
@@ -317,7 +317,7 @@ Utility content.
// There is no workflow called "utils" because the skill didn't declare one.
if _, ok := reg["utils"]; ok {
t.Error("BuildRegistry registered 'utils' as a workflow, but the skill " +
"did not declare metadata.archie.workflow — only skills that declare " +
"did not declare metadata.archie.workflow -- only skills that declare " +
"a workflow should produce registry entries")
}
@@ -400,7 +400,7 @@ func Stage() (string, func(context.Context, *workflow.TaskContext) error) {
// Worktree workflow added.
wf, ok := aug["custom"]
if !ok {
t.Fatal("'custom' workflow not found in augmented registry — worktree skill was not discovered")
t.Fatal("'custom' workflow not found in augmented registry -- worktree skill was not discovered")
}
if wf.Name != "custom" {
t.Errorf("Workflow.Name = %q, want custom", wf.Name)
@@ -485,7 +485,7 @@ func Stage() (string, func(context.Context, *workflow.TaskContext) error) {
t.Errorf("stage[0].Name = %q, want 'repo-plan' from worktree override", wf.Stages[0].Name)
}
// Run it — must use worktree version.
// Run it -- must use worktree version.
tc := &workflow.TaskContext{BuildSummary: ""}
if err := wf.Stages[0].Run(context.Background(), tc); err != nil {
t.Fatal(err)
@@ -496,7 +496,7 @@ func Stage() (string, func(context.Context, *workflow.TaskContext) error) {
}
func TestAugmentRegistryDoesNotModifyBase(t *testing.T) {
// AugmentRegistry returns a NEW registry — the caller's base must
// AugmentRegistry returns a NEW registry -- the caller's base must
// not be mutated.
base := workflow.Registry{"keep": {Name: "keep"}}
worktree := t.TempDir()
@@ -514,7 +514,7 @@ func TestAugmentRegistryDoesNotModifyBase(t *testing.T) {
// Mutating augmented must not affect base.
aug["keep"] = workflow.Workflow{Name: "modified"}
if base["keep"].Name != "keep" {
t.Error("AugmentRegistry mutated the base registry — must return a copy")
t.Error("AugmentRegistry mutated the base registry -- must return a copy")
}
}
@@ -530,7 +530,7 @@ func TestAugmentRegistryNonexistentWorktreeReturnsBase(t *testing.T) {
}
func TestAugmentRegistryWorktreeWithNoSkillsReturnsBase(t *testing.T) {
// A worktree without .agents/skills/ must not error — returns
// A worktree without .agents/skills/ must not error -- returns
// a copy of the base unchanged.
worktree := t.TempDir()
base := workflow.Registry{"default": {Name: "default"}}
@@ -545,7 +545,7 @@ func TestAugmentRegistryWorktreeWithNoSkillsReturnsBase(t *testing.T) {
func TestAugmentRegistryWorktreeSkillWithNoStagesDoesNotOverride(t *testing.T) {
// A skill that declares a workflow but has no plugins must not
// override the base entry — it would produce an empty workflow.
// override the base entry -- it would produce an empty workflow.
worktree := t.TempDir()
skillDir := filepath.Join(worktree, ".agents", "skills", "archie-wf-empty")
if err := os.MkdirAll(skillDir, 0o755); err != nil {
@@ -574,7 +574,7 @@ No plugins here.
wf := aug["implement"]
if len(wf.Stages) == 0 {
t.Error("worktree skill with no stages overrode base — must keep base when skill is empty")
t.Error("worktree skill with no stages overrode base -- must keep base when skill is empty")
}
if wf.Stages[0].Name != "builtin" {
t.Error("base stage was replaced by empty worktree skill")
@@ -622,7 +622,7 @@ func Stage() (string, func(context.Context, *workflow.TaskContext) error) {
base := workflow.Registry{"default": {Name: "default"}}
// Run 10 concurrent augmentations — none should panic or corrupt state.
// Run 10 concurrent augmentations -- none should panic or corrupt state.
errs := make(chan error, 10)
for range 10 {
go func() {
@@ -651,7 +651,7 @@ func Stage() (string, func(context.Context, *workflow.TaskContext) error) {
}
func TestAugmentRegistryBrokenSkillMDIsSkipped(t *testing.T) {
// A SKILL.md with invalid YAML must not crash augmentation — the
// A SKILL.md with invalid YAML must not crash augmentation -- the
// skill is simply skipped (skill.Catalog skips parse errors).
worktree := t.TempDir()
skillDir := filepath.Join(worktree, ".agents", "skills", "archie-wf-broken")
@@ -680,7 +680,7 @@ func TestAugmentRegistryWorktreeWithNoSkillsDir(t *testing.T) {
// A worktree that exists but has no .agents/ directory at all
// must not error.
worktree := t.TempDir()
// Don't create .agents/skills/ — just a bare worktree.
// Don't create .agents/skills/ -- just a bare worktree.
if err := os.WriteFile(filepath.Join(worktree, "README.md"), []byte(`# repo`), 0o644); err != nil {
t.Fatal(err)
}
@@ -696,14 +696,14 @@ func TestAugmentRegistryWorktreeWithNoSkillsDir(t *testing.T) {
}
func TestAugmentRegistryNilBaseReturnsEmpty(t *testing.T) {
// A nil base registry must be treated as empty — not panic.
// A nil base registry must be treated as empty -- not panic.
worktree := t.TempDir()
aug, err := AugmentRegistry(worktree, nil)
if err != nil {
t.Fatal("AugmentRegistry errored with nil base:", err)
}
if aug == nil {
t.Error("AugmentRegistry returned nil for nil base — want empty registry")
t.Error("AugmentRegistry returned nil for nil base -- want empty registry")
}
if len(aug) != 0 {
t.Errorf("got %d entries with nil base and no skills, want 0", len(aug))
@@ -754,7 +754,7 @@ func TestBuildWorkflowSkipsBrokenPlugin(t *testing.T) {
t.Fatal(err)
}
// First plugin — valid.
// First plugin -- valid.
if err := os.WriteFile(filepath.Join(pluginsDir, "01-setup.go"), []byte(`package main
import (
@@ -772,14 +772,14 @@ func Stage() (string, func(context.Context, *workflow.TaskContext) error) {
t.Fatal(err)
}
// Second plugin — BROKEN (syntax error).
// Second plugin -- BROKEN (syntax error).
if err := os.WriteFile(filepath.Join(pluginsDir, "02-broken.go"), []byte(`package main
this is %% NOT VALID GO @@@@
`), 0o644); err != nil {
t.Fatal(err)
}
// Third plugin — valid.
// Third plugin -- valid.
if err := os.WriteFile(filepath.Join(pluginsDir, "03-teardown.go"), []byte(`package main
import (
@@ -1244,7 +1244,7 @@ func Stage() (string, func(context.Context, *workflow.TaskContext) error) {
func TestBuildRegistrySkipsBrokenSkill(t *testing.T) {
// R2: a skill with broken plugins must not prevent other skills
// from registering — and must not block daemon startup.
// from registering -- and must not block daemon startup.
dir := t.TempDir()
@@ -1281,7 +1281,7 @@ Good.
t.Fatal(err)
}
// Skill 2: broken plugins — ALL plugins are broken.
// Skill 2: broken plugins -- ALL plugins are broken.
badDir := filepath.Join(dir, ".agents", "skills", "archie-wf-bad", "plugins")
if err := os.MkdirAll(badDir, 0o755); err != nil {
t.Fatal(err)
@@ -1311,11 +1311,11 @@ Broken.
// Good workflow must still be registered.
if _, ok := reg["good"]; !ok {
t.Error("'good' workflow missing — broken skill blocked registry build")
t.Error("'good' workflow missing -- broken skill blocked registry build")
}
// Bad workflow must not be registered (it had no valid stages).
if _, ok := reg["bad"]; ok {
// It might fall back to built-in "bad" — that's fine.
// It might fall back to built-in "bad" -- that's fine.
// But it should NOT be the empty workflow from the broken skill.
t.Log("'bad' workflow present (may be built-in fallback)")
}
+10 -10
View File
@@ -31,7 +31,7 @@ func StagePrepareWorktree() Stage {
}}
}
// StageCommit commits everything in the worktree without pushing —
// StageCommit commits everything in the worktree without pushing --
// used mid-workflow so a PR tells its story in multiple commits (TDD:
// failing tests first, fix second). An empty tree parks.
func StageCommit(name string, message func(*TaskContext) string) Stage {
@@ -49,19 +49,19 @@ func StageCommit(name string, message func(*TaskContext) string) Stage {
// StageCommitPush commits everything in the worktree and pushes the
// branch. When the builder completed with no changes (BuildNoChanges is
// set), the issue is already resolved — close it with a comment instead
// set), the issue is already resolved -- close it with a comment instead
// of erroring on an empty tree.
func StageCommitPush(message func(*TaskContext) string) Stage {
return Stage{Name: "commit-push", Run: func(ctx context.Context, tc *TaskContext) error {
if tc.BuildNoChanges {
body := fmt.Sprintf("**archie closed this issue — no changes required.**\n\n%s", tc.BuildSummary)
body := fmt.Sprintf("**archie closed this issue -- no changes required.**\n\n%s", tc.BuildSummary)
if _, err := tc.Forge.Comment(ctx, tc.Task.Owner, tc.Task.Repo, tc.Task.IssueNumber, body); err != nil {
tc.Log.Warn("no-op close comment failed", "err", err)
}
if err := tc.Forge.CloseIssue(ctx, tc.Task.Owner, tc.Task.Repo, tc.Task.IssueNumber, ""); err != nil {
return err
}
tc.Outcome = Outcome{Status: store.StatusMerged, Detail: "closed — no changes required"}
tc.Outcome = Outcome{Status: store.StatusMerged, Detail: "closed -- no changes required"}
return nil
}
commit := StageCommit("commit-push", message)
@@ -72,7 +72,7 @@ func StageCommitPush(message func(*TaskContext) string) Stage {
}}
}
// StageDiffCap parks tasks whose diff exceeds the configured line cap —
// StageDiffCap parks tasks whose diff exceeds the configured line cap --
// oversized changes need human pre-approval, not an auto-opened PR.
func StageDiffCap() Stage {
return Stage{Name: "diff-cap", Run: func(ctx context.Context, tc *TaskContext) error {
@@ -86,7 +86,7 @@ func StageDiffCap() Stage {
if lines > tc.Cfg.DiffCapLines {
tc.Outcome = Outcome{
Status: store.StatusParked,
Detail: fmt.Sprintf("diff is %d changed lines (cap %d) — split the issue or approve manually", lines, tc.Cfg.DiffCapLines),
Detail: fmt.Sprintf("diff is %d changed lines (cap %d) -- split the issue or approve manually", lines, tc.Cfg.DiffCapLines),
}
}
return nil
@@ -95,7 +95,7 @@ func StageDiffCap() Stage {
// StageRepoStages runs every custom stage the repo defines under
// .archie/stages/*.go (Yaegi-interpreted via TaskContext.CustomStages),
// in the order the loader returns them — a no-op when no loader is wired
// in the order the loader returns them -- a no-op when no loader is wired
// up or the repo defines none. A custom stage that sets tc.Outcome ends
// the workflow there, same as any built-in stage.
func StageRepoStages() Stage {
@@ -120,7 +120,7 @@ func StageRepoStages() Stage {
}}
}
// StageYaegiGate evaluates the repo's optional .archie/gate.go — a
// StageYaegiGate evaluates the repo's optional .archie/gate.go -- a
// Yaegi-interpreted Go file inspecting the committed diff for
// project-specific rules shell gate commands can't express (AST checks,
// diff scanning). A missing script is a no-op. Error-level findings
@@ -170,7 +170,7 @@ func StageYaegiGate() Stage {
// OpenPR opens the task's pull request, records its number, and sets
// the terminal pr_open outcome. Stages that need to act after the PR
// exists (e.g. posting evidence comments) call this and then do so in
// the same stage — the engine stops at the first stage with an outcome.
// the same stage -- the engine stops at the first stage with an outcome.
func OpenPR(ctx context.Context, tc *TaskContext, body string) error {
t := tc.Task
title := fmt.Sprintf("%s (archie)", t.Title)
@@ -204,7 +204,7 @@ func Bootstrap() Workflow {
if err := os.MkdirAll(dir, 0o755); err != nil {
return err
}
content := fmt.Sprintf("# archie bootstrap\n\nIssue: #%d — %s\nTime: %s\n\nThis file proves the archie pipeline (poll → worktree → push → PR) works for this repository.\n",
content := fmt.Sprintf("# archie bootstrap\n\nIssue: #%d -- %s\nTime: %s\n\nThis file proves the archie pipeline (poll → worktree → push → PR) works for this repository.\n",
tc.Task.IssueNumber, tc.Task.Title, time.Now().UTC().Format(time.RFC3339))
return os.WriteFile(filepath.Join(dir, "bootstrap.md"), []byte(content), 0o644)
}},
+2 -2
View File
@@ -27,8 +27,8 @@ func runGit(t *testing.T, dir string, args ...string) {
// gitRepoWithOriginRef creates a repo with a base commit, then labels
// that commit "origin/<base>" (a plain local branch standing in for a
// remote-tracking ref) so Manager.Diff/ChangedFiles — which always diff
// against "origin/<base>" — resolve without a real clone/push round trip.
// remote-tracking ref) so Manager.Diff/ChangedFiles -- which always diff
// against "origin/<base>" -- resolve without a real clone/push round trip.
func gitRepoWithOriginRef(t *testing.T, base string) string {
t.Helper()
dir := t.TempDir()
+9 -9
View File
@@ -12,8 +12,8 @@ import (
// TDD is the bugfix workflow: prove the bug with failing tests before
// fixing it. The repro stage's gate INVERTS the test command
// (ExpectFailure) — the run cannot proceed until the new tests fail for
// the right reason — and the fix stage restores the repo's full gate.
// (ExpectFailure) -- the run cannot proceed until the new tests fail for
// the right reason -- and the fix stage restores the repo's full gate.
// Routed via the "bug" label.
func TDD() Workflow {
return Workflow{
@@ -49,7 +49,7 @@ func TDD() Workflow {
Role: "builder",
// The inverted gate: code-quality commands must still
// pass, but the test command (last in repo.Gate) MUST
// fail — proof the repro captures the bug.
// fail -- proof the repro captures the bug.
Gate: func(tc *TaskContext) agentexec.Gate {
return tddReproGate(tc.Repo, tc.Cfg.Budgets)
},
@@ -67,18 +67,18 @@ func TDD() Workflow {
},
}.Stage(),
// Capture the failing test run — the proof the repro
// Capture the failing test run -- the proof the repro
// reproduces the bug, posted on the PR later.
{Name: "capture-proof", Run: func(ctx context.Context, tc *TaskContext) error {
argv := testCommandArgv(tc.Repo)
if len(argv) == 0 {
return fmt.Errorf("tdd: repo %s has no gate configured — cannot capture repro proof (add at least one [[repos.gate]] command, with the test runner last)", tc.Repo.FullName())
return fmt.Errorf("tdd: repo %s has no gate configured -- cannot capture repro proof (add at least one [[repos.gate]] command, with the test runner last)", tc.Repo.FullName())
}
cmd := exec.CommandContext(ctx, argv[0], argv[1:]...)
cmd.Dir = tc.Dir
out, err := cmd.CombinedOutput()
if err == nil {
return fmt.Errorf("repro tests unexpectedly pass after commit — the bug is not captured")
return fmt.Errorf("repro tests unexpectedly pass after commit -- the bug is not captured")
}
tc.ReproProof = clip(string(out), 4000)
return nil
@@ -95,7 +95,7 @@ func TDD() Workflow {
return GateFromRepo(tc.Repo, tc.Cfg.Budgets)
},
// Environmental, not advisory: the fix stage cannot touch
// test files at all — the committed repro is the spec.
// test files at all -- the committed repro is the spec.
ProtectGlobs: func(tc *TaskContext) []string {
glob := tc.Repo.ResolvedTestGlob()
if glob == "" {
@@ -104,7 +104,7 @@ func TDD() Workflow {
return []string{glob}
},
ExtraRules: "The repro tests written in the previous stage are the bug's specification. " +
"Test files are write-protected in this stage — make them pass by fixing the code they exercise.",
"Test files are write-protected in this stage -- make them pass by fixing the code they exercise.",
Mission: func(tc *TaskContext) string {
return fmt.Sprintf(
"Fix the bug in the repository %s. Failing repro tests are already committed; make them pass.\n\n"+
@@ -149,7 +149,7 @@ func TDD() Workflow {
// tddReproGate builds the inverted gate for the repro-tests stage:
// every command from repo.Gate runs normally except the last one (the
// test runner, by convention), which gets ExpectFailure — the repro
// test runner, by convention), which gets ExpectFailure -- the repro
// must fail the tests to prove the bug exists.
func tddReproGate(repo config.Repo, budgets config.Budgets) agentexec.Gate {
if len(repo.Gate) == 0 {
+1 -1
View File
@@ -24,7 +24,7 @@ const stagesDir = ".archie/stages"
// Discover loads every .archie/stages/*.go file in dir and returns the
// workflow.Stage each exports, in filename order. A missing directory is
// not an error — it returns (nil, nil), meaning no custom stages are
// not an error -- it returns (nil, nil), meaning no custom stages are
// configured for this repo.
func Discover(dir string) ([]workflow.Stage, error) {
entries, err := os.ReadDir(filepath.Join(dir, stagesDir))
+8 -8
View File
@@ -1,7 +1,7 @@
// Package workflow is archied's extensible pipeline engine. A Workflow
// is an ordered list of stages over a shared TaskContext; stages are
// either deterministic steps (git, gate, PR, comments) or agent stages
// (agentloop runs). New workflows compose from the shared step library —
// (agentloop runs). New workflows compose from the shared step library --
// adding one must never require reimplementing the engine or the steps.
package workflow
@@ -58,7 +58,7 @@ type TaskContext struct {
// CustomStages discovers a repo's per-repo custom stages (Yaegi-
// interpreted from .archie/stages/*.go in the given worktree
// directory), returning them in the order they should run. Wired up
// by the composition root (cmd/archied) — nil disables discovery, so
// by the composition root (cmd/archied) -- nil disables discovery, so
// StageRepoStages is a no-op. Kept as an injected function rather
// than a direct import to avoid workflow depending on its own
// generated Yaegi symbol table (an import cycle).
@@ -75,10 +75,10 @@ type TaskContext struct {
// Dir/Branch are set by the prepare step.
Dir string
Branch string
// BuildSummary is the builder agent's finish summary — the PR body.
// BuildSummary is the builder agent's finish summary -- the PR body.
BuildSummary string
// BuildNoChanges is set when the builder returned StatusPassed but
// made no file changes — the fix already exists or the issue is a
// made no file changes -- the fix already exists or the issue is a
// no-op. StageCommitPush closes the issue instead of erroring.
BuildNoChanges bool
// ReproProof is the captured failing-test output from a TDD repro
@@ -153,7 +153,7 @@ func Route(t *store.Task, reg Registry) Workflow {
}
case "bootstrap":
// Diagnostics: exercise the full pipeline deterministically
// (no LLM spend) — invites, clone, push, PR, labels.
// (no LLM spend) -- invites, clone, push, PR, labels.
if wf, ok := reg["bootstrap"]; ok {
return wf
}
@@ -175,7 +175,7 @@ func Route(t *store.Task, reg Registry) Workflow {
}
// Run executes the workflow: stages in order, task persisted after each,
// errors park the task with a comment on the issue — never silently.
// errors park the task with a comment on the issue -- never silently.
func Run(ctx context.Context, wf Workflow, tc *TaskContext) {
t := tc.Task
t.Workflow = wf.Name
@@ -204,7 +204,7 @@ func Run(ctx context.Context, wf Workflow, tc *TaskContext) {
return
}
t.ParkReason = fmt.Sprintf("stage %s: %v", stage.Name, err)
log.Warn("stage failed — parking", "stage", stage.Name, "err", err)
log.Warn("stage failed -- parking", "stage", stage.Name, "err", err)
park(ctx, tc, t.ParkReason)
return
}
@@ -233,7 +233,7 @@ func finish(ctx context.Context, tc *TaskContext, log *slog.Logger) {
// stateLabelFor maps a terminal workflow status to its forge label by
// looking up the configured [dispatch.labels]; empty clears (done states
// — the issue closes or the PR speaks).
// -- the issue closes or the PR speaks).
func stateLabelFor(d config.Dispatch, status string) string {
switch status {
case store.StatusPROpen: