Compare commits

..
2 Commits
Author SHA1 Message Date
sam f8b061c314 chore(release): v1.54.3
deploy / gate (push) Canceled after 0s
deploy / archied-image (push) Canceled after 0s
deploy / agent-image (push) Canceled after 0s
deploy / dist-zip (push) Canceled after 0s
2026-10-16 03:46:35 +11:00
sam c5158edb6c feat(gateway): chat reads workflows and validates drafts
workflow_list, workflow_get and workflow_step_types read the org's
definitions and step catalog; workflow_validate runs the editor's save
check on a proposed definition without saving it.
2026-10-16 03:46:27 +11:00
9 changed files with 292 additions and 5 deletions

No files matched your search

+6
View File
@@ -5,6 +5,12 @@ release's per-component sections are labelled beneath its heading.
## [Unreleased]
## [1.54.3] - 2026-10-16
### archied
- Chat can help write a workflow: it reads your workflows and the step catalog, writes a definition, and checks it the same way saving does, fixing what the check reports. It does not save; paste the YAML it gives you into the editor's YAML view and save there.
## [1.54.2] - 2026-10-16
### archied
+2
View File
@@ -82,6 +82,7 @@
"/news/archie/1.54.0/": "/news/1.54.0/",
"/news/archie/1.54.1/": "/news/1.54.1/",
"/news/archie/1.54.2/": "/news/1.54.2/",
"/news/archie/1.54.3/": "/news/1.54.3/",
"/news/archie/1.6.0/": "/news/1.6.0/",
"/news/archie/1.7.0/": "/news/1.7.0/",
"/news/archie/1.8.0/": "/news/1.8.0/",
@@ -180,6 +181,7 @@
"/news/archied/1.54.0/": "/news/1.54.0/",
"/news/archied/1.54.1/": "/news/1.54.1/",
"/news/archied/1.54.2/": "/news/1.54.2/",
"/news/archied/1.54.3/": "/news/1.54.3/",
"/news/archied/1.6.0/": "/news/1.6.0/",
"/news/archied/1.7.0/": "/news/1.7.0/",
"/news/archied/1.8.0/": "/news/1.8.0/",
+5
View File
@@ -1,4 +1,9 @@
[
{
"version": "1.54.3",
"date": "2026-10-16",
"body": "### archied\n\n- Chat can help write a workflow: it reads your workflows and the step catalog, writes a definition, and checks it the same way saving does, fixing what the check reports. It does not save; paste the YAML it gives you into the editor's YAML view and save there."
},
{
"version": "1.54.2",
"date": "2026-10-16",
+2
View File
@@ -51,6 +51,7 @@ type chatSetup struct {
ChatTaskLogs gateway.ChatTaskLogReader
ChatTaskActor gateway.ChatTaskActor
DefaultChatIdentity string
Workflows gateway.WorkflowSource
// Bus carries primary-input events: a completed
// chat turn is published here so input-driven curators can wake. Nil
// disables turn events (tests, minimal setups).
@@ -138,6 +139,7 @@ func newChatTurnRunner(
TaskLogs: s.ChatTaskLogs,
TaskActor: s.ChatTaskActor,
TaskIdentity: s.DefaultChatIdentity,
Workflows: s.Workflows,
Bus: s.Bus,
BotUser: cfg.BotUser,
Channel: channel,
@@ -252,6 +252,7 @@ func (b *server) setupGatewayChat(ctx context.Context, actor gateway.ChatTaskAct
ChatTaskLogs: chatTaskLogReaderAdapter{tasks: b.stateStore.TaskByID, taskLogs: b.stateStore},
ChatTaskActor: actor,
DefaultChatIdentity: b.defaultChatIdentity,
Workflows: controlplanerpc.NewWorkflows(b.stateStore.ControlPlane()),
Bus: b.bus, Log: b.log,
MemoryEngine: b.memoryStore(),
MemoryWriter: b.memoryWriter(),
+1 -1
View File
@@ -7,7 +7,7 @@ Accounts and organization:
Creating a workflow:
1. Open /workflows and choose New workflow. The new definition is an unsaved draft with an id and empty steps.
2. Use YAML to edit its id, or the canvas to add and select steps. Select Starts when on the canvas to open Workflow settings. Set Runs as to an existing active agent identity. Works on selects Repository, If given, or None.
3. Read an existing workflow and the served step/settings catalog before constructing YAML. A repository planning workflow normally prepares the repository, then uses agent.run with read_only: true and a mission asking it to inspect the code and return a plan. Keep forge writes, commits, implementation steps and automatic implementation handoffs out of a planning-only workflow. The shipped feasibility workflow also closes issues or hands off after approval: it is not a planning-only template unchanged.
3. Before writing YAML, read a similar workflow (workflow_list, workflow_get) and the step catalog (workflow_step_types). Run workflow_validate on the YAML and fix every problem it reports until it is valid, then give the operator the YAML to paste into the editor's YAML view and save. A repository planning workflow normally prepares the repository, then uses agent.run with read_only: true and a mission asking it to inspect the code and return a plan. Keep forge writes, commits, implementation steps and automatic implementation handoffs out of a planning-only workflow. The shipped feasibility workflow also closes issues or hands off after approval: it is not a planning-only template unchanged.
4. Save the definition. Test runs the draft once with forge writes/pushes skipped; commands and tools still run, so a test is not a side-effect-free simulation. Run starts the saved version. History, Performance and Runs show revisions and execution evidence.
5. Manual workflows need no automatic trigger. Bind an event creates an event binding from a captured example and maps payload fields to declared inputs. Existing bindings can be paused or removed. Playbooks are edited at /settings/playbooks; workflow calls/handoffs are edited in the workflow that invokes them. Built-in issue-label routes are marked Built-in; they cannot be removed in the event-binding editor. Disable the workflow to prevent automatic execution.
+7 -4
View File
@@ -102,10 +102,12 @@ type TurnRunnerConfig struct {
TaskLogs ChatTaskLogReader
TaskActor ChatTaskActor
TaskIdentity string
Bus TurnEventPublisher
BotUser string
Channel string
Operator string
// Workflows backs the workflow read and validate tools. Nil omits them.
Workflows WorkflowSource
Bus TurnEventPublisher
BotUser string
Channel string
Operator string
// Workspace is the directory the chat agent's file and shell tools are
// rooted at (chat.workspace). Passed into the prompt's <env> block.
Workspace string
@@ -306,6 +308,7 @@ func (r *TurnRunner) prepareTurn(ctx context.Context, sessionID string, in Inbou
// UI only: a non-web channel has no dashboard to point at.
extraTools = append(extraTools, PageIndexTools(r.Channel)...)
extraTools = append(extraTools, MemoryTools(r.MemoryWriter, subject)...)
extraTools = append(extraTools, WorkflowTools(r.Workflows)...)
// The question tool is per-turn: it exists only when this turn's channel
// adapter can carry a clarify/picker interaction (see WithInteractive).
extraTools = append(extraTools, InteractiveTools(ctx)...)
+196
View File
@@ -0,0 +1,196 @@
package gateway
import (
"context"
"encoding/json"
"fmt"
"strings"
"gopkg.in/yaml.v3"
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
"github.com/samcharles93/archie-core/internal/tools"
)
// WorkflowSource is the control-plane surface the workflow tools use, acting
// in the caller's org. Validate returns the reason a collection is refused,
// or "" when it would be accepted; err is reserved for an unavailable store.
type WorkflowSource interface {
Workflows(ctx context.Context) (task.WorkflowDefinitionCollection, error)
StepTypes(ctx context.Context) (json.RawMessage, error)
Validate(ctx context.Context, collection task.WorkflowDefinitionCollection) (problem string, err error)
}
// WorkflowSummary is one workflow as workflow_list shows it.
type WorkflowSummary struct {
ID string `json:"id"`
Steps []string `json:"steps"`
}
// WorkflowValidation is what workflow_validate returns.
type WorkflowValidation struct {
ID string `json:"id,omitempty"`
Valid bool `json:"valid"`
Replace bool `json:"replaces_existing,omitempty"`
Problem string `json:"problem,omitempty"`
}
// WorkflowTools returns the read and validate tools over source. Saving is
// left to the operator in the workflow editor. Nil source registers none.
func WorkflowTools(source WorkflowSource) []tools.ToolEntry {
if source == nil {
return nil
}
return []tools.ToolEntry{
workflowListTool(source),
workflowGetTool(source),
workflowStepTypesTool(source),
workflowValidateTool(source),
}
}
func workflowListTool(source WorkflowSource) tools.ToolEntry {
return tools.ToolEntry{
Name: "workflow_list",
Toolset: "workflows",
Description: "List the workflows defined in this org with the step types each runs, in order.",
Classification: tools.ClassIdempotent,
Schema: tools.JSONSchema{"type": "object", "properties": map[string]any{}},
Handler: func(ctx context.Context, _ map[string]any) (any, error) {
collection, err := source.Workflows(ctx)
if err != nil {
return nil, fmt.Errorf("workflow_list: %w", err)
}
out := make([]WorkflowSummary, 0, len(collection.Definitions))
for _, entry := range collection.Definitions {
out = append(out, WorkflowSummary{ID: entry.ID, Steps: stepTypesOf(entry.YAML)})
}
return out, nil
},
}
}
func workflowGetTool(source WorkflowSource) tools.ToolEntry {
return tools.ToolEntry{
Name: "workflow_get",
Toolset: "workflows",
Description: "Return one workflow's YAML definition. Read a similar workflow before writing a new one.",
Classification: tools.ClassIdempotent,
Schema: tools.JSONSchema{
"type": "object",
"properties": map[string]any{"id": map[string]any{"type": "string", "description": "The workflow id from workflow_list."}},
"required": []any{"id"},
},
Handler: func(ctx context.Context, input map[string]any) (any, error) {
id := strings.TrimSpace(asString(input["id"]))
collection, err := source.Workflows(ctx)
if err != nil {
return nil, fmt.Errorf("workflow_get: %w", err)
}
entry, ok := collection.DefinitionByID(id)
if !ok {
return nil, fmt.Errorf("workflow_get: no workflow %q", id)
}
return map[string]string{"id": entry.ID, "yaml": entry.YAML}, nil
},
}
}
func workflowStepTypesTool(source WorkflowSource) tools.ToolEntry {
return tools.ToolEntry{
Name: "workflow_step_types",
Toolset: "workflows",
Description: "Return the step types a workflow may use, with each type's settings schema.",
Classification: tools.ClassIdempotent,
Schema: tools.JSONSchema{"type": "object", "properties": map[string]any{}},
Handler: func(ctx context.Context, _ map[string]any) (any, error) {
types, err := source.StepTypes(ctx)
if err != nil {
return nil, fmt.Errorf("workflow_step_types: %w", err)
}
return types, nil
},
}
}
func workflowValidateTool(source WorkflowSource) tools.ToolEntry {
return tools.ToolEntry{
Name: "workflow_validate",
Toolset: "workflows",
Description: "Check a workflow YAML definition exactly as saving it would, without saving. " +
"Fix every problem it reports and validate again before giving the operator the YAML, " +
"who saves it from the workflow editor.",
Classification: tools.ClassIdempotent,
Schema: tools.JSONSchema{
"type": "object",
"properties": map[string]any{"yaml": map[string]any{"type": "string", "description": "The complete workflow definition."}},
"required": []any{"yaml"},
},
Handler: func(ctx context.Context, input map[string]any) (any, error) {
src := asString(input["yaml"])
id, problem := definitionID(src)
if problem != "" {
return WorkflowValidation{Problem: problem}, nil
}
collection, err := source.Workflows(ctx)
if err != nil {
return nil, fmt.Errorf("workflow_validate: %w", err)
}
proposed, replaced := withDefinition(collection, id, src)
problem, err = source.Validate(ctx, proposed)
if err != nil {
return nil, fmt.Errorf("workflow_validate: %w", err)
}
return WorkflowValidation{ID: id, Valid: problem == "", Replace: replaced, Problem: problem}, nil
},
}
}
// withDefinition returns collection with src as workflow id, replacing an
// existing definition of that id or appending a new one.
func withDefinition(collection task.WorkflowDefinitionCollection, id, src string) (task.WorkflowDefinitionCollection, bool) {
out := task.WorkflowDefinitionCollection{Definitions: make([]task.WorkflowDefinitionEntry, 0, len(collection.Definitions)+1)}
replaced := false
for _, entry := range collection.Definitions {
if entry.ID == id {
entry.YAML, replaced = src, true
}
out.Definitions = append(out.Definitions, entry)
}
if !replaced {
out.Definitions = append(out.Definitions, task.WorkflowDefinitionEntry{ID: id, YAML: src})
}
return out, replaced
}
// definitionID returns the id src declares, or why it declares none.
func definitionID(src string) (id, problem string) {
var declared struct {
ID string `yaml:"id"`
}
if err := yaml.Unmarshal([]byte(src), &declared); err != nil {
return "", "the YAML does not parse: " + err.Error()
}
if strings.TrimSpace(declared.ID) == "" {
return "", "the definition needs an id"
}
return declared.ID, ""
}
// stepTypesOf lists a definition's top-level step types; a definition that
// does not parse lists none.
func stepTypesOf(src string) []string {
var def struct {
Steps []struct {
Type string `yaml:"type"`
} `yaml:"steps"`
}
_ = yaml.Unmarshal([]byte(src), &def)
out := make([]string, 0, len(def.Steps))
for _, step := range def.Steps {
if step.Type != "" {
out = append(out, step.Type)
}
}
return out
}
@@ -0,0 +1,72 @@
package controlplanerpc
import (
"context"
"encoding/json"
"errors"
"fmt"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
pb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
)
const workflowDefinitionsKind = "workflow-definitions"
// Workflows reads and validates workflow definitions in the caller's org,
// through the same control-plane calls the workflow editor makes.
type Workflows struct{ rpc pb.ControlPlaneServiceClient }
func NewWorkflows(rpc pb.ControlPlaneServiceClient) Workflows { return Workflows{rpc: rpc} }
func (w Workflows) Workflows(ctx context.Context) (task.WorkflowDefinitionCollection, error) {
var collection task.WorkflowDefinitionCollection
response, err := w.rpc.Query(ctx, &pb.QueryRequest{Kind: workflowDefinitionsKind})
if err != nil {
return collection, fmt.Errorf("%w: %w", ErrUnavailable, err)
}
if response.GetResource() == nil || len(response.GetResource().GetValueJson()) == 0 {
return collection, nil
}
if err := json.Unmarshal(response.GetResource().GetValueJson(), &collection); err != nil {
return collection, fmt.Errorf("decode workflow definitions: %w", err)
}
return collection, nil
}
func (w Workflows) StepTypes(ctx context.Context) (json.RawMessage, error) {
catalog, err := w.rpc.Catalog(ctx, &pb.CatalogRequest{})
if err != nil {
return nil, fmt.Errorf("%w: %w", ErrUnavailable, err)
}
for _, resource := range catalog.GetResources() {
if resource.GetKind() != workflowDefinitionsKind {
continue
}
var schema struct {
StepTypes json.RawMessage `json:"x-step-types"`
}
if err := json.Unmarshal([]byte(resource.GetSchemaJson()), &schema); err != nil {
return nil, fmt.Errorf("decode workflow schema: %w", err)
}
return schema.StepTypes, nil
}
return nil, errors.New("the control plane serves no workflow definitions")
}
func (w Workflows) Validate(ctx context.Context, collection task.WorkflowDefinitionCollection) (string, error) {
value, err := json.Marshal(collection)
if err != nil {
return "", err
}
_, err = w.rpc.Command(ctx, &pb.CommandRequest{Kind: workflowDefinitionsKind, Command: "validate", ValueJson: value})
if status.Code(err) == codes.InvalidArgument {
return status.Convert(err).Message(), nil
}
if err != nil {
return "", fmt.Errorf("%w: %w", ErrUnavailable, err)
}
return "", nil
}