summaryrefslogtreecommitdiff
path: root/internal/executor/channel.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/executor/channel.go')
-rw-r--r--internal/executor/channel.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/internal/executor/channel.go b/internal/executor/channel.go
index ef64ede..5afe22e 100644
--- a/internal/executor/channel.go
+++ b/internal/executor/channel.go
@@ -10,6 +10,8 @@ import (
"github.com/thepeterstone/claudomator/internal/agentchannel"
"github.com/thepeterstone/claudomator/internal/event"
+ "github.com/thepeterstone/claudomator/internal/role"
+ "github.com/thepeterstone/claudomator/internal/storage"
"github.com/thepeterstone/claudomator/internal/story"
"github.com/thepeterstone/claudomator/internal/task"
"github.com/google/uuid"
@@ -50,6 +52,12 @@ type channelStore interface {
GetEpicByName(name string) (*story.Epic, error)
GetStory(id string) (*story.Story, error)
UpdateStory(st *story.Story) error
+ // CreateRoleConfig backs storeChannel.ProposeRoleConfig (Phase 8): it
+ // inserts a new "draft"-status role_configs row for a role, auto-
+ // assigning the next version number, exactly the way
+ // api.handleCreateRoleVersion (the human-facing
+ // POST /api/roles/{role}/versions endpoint) already uses it.
+ CreateRoleConfig(roleName, configJSON, proposedBy string) (*storage.RoleConfigRow, error)
}
// pendingAsker is implemented by channels that buffer an ask_user call so the
@@ -223,4 +231,45 @@ func (c *storeChannel) ProposeEpic(_ context.Context, spec agentchannel.EpicProp
return epic.ID, err
}
return epic.ID, nil
+}
+
+// ProposeRoleConfig creates a new draft role_configs row for config.Role,
+// proposed_by "retro" (the only role this phase wires the tool up for,
+// though nothing else about the mechanism is retro-specific). It never reads
+// or touches whatever version is currently active for that role — draft
+// creation and activation are deliberately separate paths (see
+// storage.CreateRoleConfig / storage.ActivateRoleConfigVersion), the latter
+// staying a human action via POST /api/roles/{role}/activate.
+//
+// Records event.KindRoleConfigProposed on the *calling task's own ID*
+// (c.taskID, not a role or story ID — roles have no first-class row/ID of
+// their own the way epics/stories do), payload {role, version}. This mirrors
+// ProposeEpic's "one event per proposal call" convention but attaches to the
+// task rather than the proposed entity: internal/scheduler.StoryOrchestrator
+// reads a retro task's own event stream for these once the task completes,
+// to assemble the aggregate KindRetroCaptured payload it attaches to the
+// story's ID (see that package's finalizeRetro).
+func (c *storeChannel) ProposeRoleConfig(_ context.Context, config role.RoleConfig) (int, error) {
+ configJSON, err := json.Marshal(config)
+ if err != nil {
+ return 0, err
+ }
+ row, err := c.store.CreateRoleConfig(config.Role, string(configJSON), "retro")
+ if err != nil {
+ return 0, err
+ }
+
+ payload, _ := json.Marshal(struct {
+ Role string `json:"role"`
+ Version int `json:"version"`
+ }{Role: row.Role, Version: row.Version})
+ if err := c.store.CreateEvent(&event.Event{
+ TaskID: c.taskID,
+ Kind: event.KindRoleConfigProposed,
+ Actor: event.ActorAgent,
+ Payload: payload,
+ }); err != nil {
+ return row.Version, err
+ }
+ return row.Version, nil
} \ No newline at end of file