Commit Graph
7 Commits
Author SHA1 Message Date
sam 7a2d08426f feat(controlplane): serve each step type's settings schema; the workflow editor checks settings before save 2026-10-05 00:39:47 +11:00
sam 796ca4e2c4 refactor(workflow): cut comments down to what the code does 2026-10-03 21:52:21 +10:00
sam 10bbbf5c4e feat(workflow): wire pr-review into archie's own PRs before opening
StagePRReviewAndOpenPR runs the pr-review pipeline's decision phases
(1-8) against the task's own uncommitted change, using a new
localPRSource that reads Diff/Snapshot straight from Trees instead of
fetching an external PR -- there is no PR number yet to fetch one by,
which is why this trigger needed its own PRSource rather than the
forge-backed one afbk.7 already built for external PRs.

An unchallenged blocking finding parks the task with the findings
instead of opening a PR; a pipeline stage failure parks it the same
way any stage failure does. Once the PR opens, advisory findings post
against it -- best-effort, matching the deleted StagePostReviewComments'
convention: a posting failure is logged, not reverted into the outcome
the PR's existence already earned.

Implement() now uses this in place of the plain StageOpenPR. Bootstrap
and TDD are untouched -- the PRD names "the implement workflow"
specifically; extending to the others is a separate call.

Resolves this bead's first blocker (confirmed via read: CompilePinnedWorkflow
returns the same workflow.Workflow type and runs through the same
workflow.Run either compilation path, so a stage setting Outcome ends
the run identically regardless -- stagePROutput's posting logic had to
move inside StageOpenPR's own Run body, not follow it as a separate
Stage, which OpenPR's own doc comment already anticipated).

Still open on this bead: watched-repositories and operator triggers,
both blocked on the credential path for PRSource's real forge-backed
implementation reaching the sandboxed archie-agent process -- see the
bead comment for the concrete design (egress credential-capability
grant, narrow forge diff/archive HTTP methods) not yet built.
2026-09-28 13:06:42 +10:00
sam f8ec3eb8aa feat(prreview): deterministic core of the PR review pipeline
Every phase of docs/prds/pr-review-agent.md that can be computed is computed
here, in a package that imports the standard library only: diff parsing with
renames, deletions, multi-hunk files and no-newline markers; directory
clustering; per-language blast radius; evidence packages; scoring,
deduplication, line mapping to diff coordinates and the review event.

The review event is REQUEST_CHANGES when a finding is blocking and COMMENT
otherwise; there is no approving value, because archie does not own the merge
decision.

internal/domain/workflow/prreview is now the one diff parser in this
repository: the diff-rules step's addedDiffLines delegates to it and the
private hunk-header and path helpers it used to carry are deleted, so a
repository rule and a review comment cannot disagree about which line a change
introduced. diff_rules_test.go is unchanged.

Blast radius resolves Go imports through the module path in go.mod, Python
module names, and JavaScript/TypeScript relative specifiers, all against files
inside the snapshot; an import that resolves to nothing there contributes no
edge. Evidence extraction reads through an fs.FS rooted at the snapshot, so
both are tested against fstest.MapFS fixtures.

NOTICE records the derivation from PR-AF (Apache-2.0).
2026-09-26 03:24:40 +10:00
sam 66ea2937a9 fix(workflow): make gate.diff-rules fail closed on a change it never read
The step's contract said it diffs "the worktree". It does not: Trees.Diff
reports the merge base against HEAD, so only committed work is visible.
A stored definition that placed gate.diff-rules before the step that
commits therefore ran every rule against an empty diff, found nothing and
returned nil, letting the run proceed -- the "load and check nothing"
failure the same file's settings validation exists to prevent, and
indistinguishable in the run's events from a change that passed.

The rules now read the committed change, and a run that read no committed
change while the worktree still holds uncommitted work fails on the spot,
naming the step it must follow. The count of added lines read is logged on
every run, so "checked nothing" is visible rather than silent.

Telling those two apart needs a fact Trees does not carry, so it arrives as
the same shape of optional capability changeStatsReader is: an unexported
interface in the domain, implemented where git is actually read
(worktree.Manager.HasUncommittedChanges, which excludes ignored files the
way CommitAll's own status check does) and forwarded by hybridTrees, the
Trees every production run uses. A Trees implementation that cannot answer
is refused rather than assumed clean: for a gate, silence about the change
is a failure, not a pass.

The four remaining review findings are recorded, not fixed, in
archie-core-ze7y (the escalated .archie/stages/*.go decision, P1, which now
blocks archie-core-8szi), archie-core-4kbg (discoverability),
archie-core-s1jz (hunk-header and threshold hardening) and archie-core-vof9
(retry keeps the pinned definition, so a rule cannot be unblocked by
editing it).
2026-09-21 20:43:48 +10:00
sam eb4d5c2017 feat(workflow): register gate.diff-rules as the .archie/gate.go replacement
Part of archie-core-8szi. Restores the deleted .archie/gate.go Check() behaviour
as a registered, declarative workflow step type: RE2 rules matched against the
committed diff, per-rule level (error parks with findings in Detail, warn logs),
file:line preserved, registered through the workflowsteps provider set. The
.archie/stages equivalent (an argv-running step) is deliberately not landed and
is held for the maintainer's trust-boundary decision.
2026-09-21 20:35:22 +10:00
sam e3748895a7 feat(workflow): register gate.diff-rules as the .archie/gate.go replacement
steps.go's StageYaegiGate tells the operator to migrate the deleted
.archie/gate.go hook to a registered YAML workflow step, and
BuiltinStepRegistry() exposed only the six shipped workflows' own stages,
so there was nothing to migrate to. What that hook did, from 3944f544
which deleted it: it read the worktree's repository-authored Go,
exporting Check(GateContext{Diff, ChangedFiles, Dir, BaseRef, Repo})
[]Finding, where each Finding carried a level ("error" blocked the run,
"warn" was advisory) and an optional file and line, and it inspected the
committed diff.

gate.diff-rules is that behaviour as a typed step: operator-written rules
in a stored definition -- per-rule level, RE2 pattern, optional path and
exclude_path scope, message -- matched against the ADDED lines of the
diff against the base branch, reported with their new-file line numbers.
An error-level finding parks the run with the findings in the park
reason; a warn-level finding is logged and nothing else. Unlike the hook
it replaces, no code is read out of the repository being worked on, and
the rules are versioned and audited with the definition they live in.

The settings are validated at the factory, which runs where a definition
is validated and again where it is compiled: a missing level, pattern or
message, an unknown level or settings key, and an expression that is not
a RE2 all refuse the definition rather than load and check nothing.

It arrives through the extension point archie-core-fwmp landed: a
repo-hooks provider in internal/infrastructure/workflowsteps, so both
roots that resolve a step type (the State Store's validating side and the
daemon's workflow-definitions client) register it at once.

Deliberately not landed: a step type for .archie/stages/*.go, whose
faithful equivalent is running a configured command. That would make the
stored workflow-definitions resource a command-execution surface on the
agent host, which is a maintainer's trust decision, not this lane's; it
is escalated, so steps.go's repo-stages error stays as it is.
2026-09-21 20:33:47 +10:00