Extend EnqueueChatTask with generic inputs for the pr-review operator trigger #125

Closed
opened 2026-10-27 13:35:03 +00:00 by sam · 1 comment
Owner

afbk.7's watched-repos and archie's-own-PRs triggers are done (commits 7fb1ccd2, 5264d5d8). The operator/chat trigger (review_pr chat tool, currently self-omitting with a nil reviewer since d73e0748 deleted the old synchronous ChatPRReviewer path) still needs to enqueue an async pr-review task with a pr_number input, the same generic mechanism watched-repos now uses via Task.EffectivePRNumber().

Real blocker: EnqueueChatTask is part of the State Store's protobuf-generated gRPC contract (proto/state/v1/state.proto's EnqueueChatTaskRequest, rpc EnqueueChatTask), not just a Go interface method -- CLAUDE.md's state-store-contract rule applies (never add a Go interface method without a matching RPC). Concrete plan for whoever picks this up:

  1. Add 'string inputs_json = 7;' to EnqueueChatTaskRequest in proto/state/v1/state.proto, matching the existing inputs_json convention already used by EnqueueBindingTaskRequest and elsewhere in the same proto (grep inputs_json for the pattern). Regenerate via the proto:generate task.
  2. Add a narrow new SQL query, e.g. 'SetTaskInputs :exec -- UPDATE tasks SET inputs = WHERE id = ;' in internal/infrastructure/postgres/queries/tasks.sql. Do NOT reuse StampTaskBinding (tasks.sql) for this -- it unconditionally sets binding_id/binding_version alongside inputs, which would stamp fake binding provenance onto a plain chat task. Regenerate via db:generate.
  3. Extend postgres.Store.EnqueueChatTask's signature with an inputs map[string]any parameter (internal/infrastructure/postgres/store.go), calling InsertChatTask then the new SetTaskInputs query when inputs is non-empty, mirroring EnqueueBindingTask's two-statement shape but without touching binding_id/version.
  4. Extend staterpc.Client.EnqueueChatTask and the server handler (internal/infrastructure/staterpc/client.go, server.go) to encode/decode inputs_json via task.EncodeInputs/DecodeInputs, matching EnqueueBindingTask's existing pattern exactly.
  5. Extend the chatTaskWriter interface (internal/gateway/tasks.go), SpawnRequest (internal/domain/messaging/inbound.go) with an Inputs map[string]any field, StoreTaskCreator.CreateTask, and chatTaskWriterAdapter.EnqueueChatTask (internal/app/archied/main.go). Update every call site (~20, mostly _test.go files across cmd/archie-state-store, internal/app/archied, internal/app/agentworker, internal/app/archieui) to pass the new parameter (nil is fine for every existing non-pr-review caller).
  6. Rebuild internal/gateway/review_tools.go's review_pr chat tool to call CreateTask with Workflow: "pr-review", Inputs: map[string]any{"pr_number": n}. Keep its identity-scoped repository authorization shape (see d73e0748's diff for the deleted prReviewer.authorize for reference).

Not a quick tool rewrite -- proto/sqlc/wire-contract change plus ~20 call sites. Parent epic: archie-core-afbk.

Close reason

Closed


Imported from beads archie-core-afbk.14 · GitHub #1427 · type task · priority P1 · created 2026-09-28 · closed 2026-09-28

afbk.7's watched-repos and archie's-own-PRs triggers are done (commits 7fb1ccd2, 5264d5d8). The operator/chat trigger (review_pr chat tool, currently self-omitting with a nil reviewer since d73e0748 deleted the old synchronous ChatPRReviewer path) still needs to enqueue an async pr-review task with a pr_number input, the same generic mechanism watched-repos now uses via Task.EffectivePRNumber(). Real blocker: EnqueueChatTask is part of the State Store's protobuf-generated gRPC contract (proto/state/v1/state.proto's EnqueueChatTaskRequest, rpc EnqueueChatTask), not just a Go interface method -- CLAUDE.md's state-store-contract rule applies (never add a Go interface method without a matching RPC). Concrete plan for whoever picks this up: 1. Add 'string inputs_json = 7;' to EnqueueChatTaskRequest in proto/state/v1/state.proto, matching the existing inputs_json convention already used by EnqueueBindingTaskRequest and elsewhere in the same proto (grep inputs_json for the pattern). Regenerate via the proto:generate task. 2. Add a narrow new SQL query, e.g. 'SetTaskInputs :exec -- UPDATE tasks SET inputs = WHERE id = ;' in internal/infrastructure/postgres/queries/tasks.sql. Do NOT reuse StampTaskBinding (tasks.sql) for this -- it unconditionally sets binding_id/binding_version alongside inputs, which would stamp fake binding provenance onto a plain chat task. Regenerate via db:generate. 3. Extend postgres.Store.EnqueueChatTask's signature with an inputs map[string]any parameter (internal/infrastructure/postgres/store.go), calling InsertChatTask then the new SetTaskInputs query when inputs is non-empty, mirroring EnqueueBindingTask's two-statement shape but without touching binding_id/version. 4. Extend staterpc.Client.EnqueueChatTask and the server handler (internal/infrastructure/staterpc/client.go, server.go) to encode/decode inputs_json via task.EncodeInputs/DecodeInputs, matching EnqueueBindingTask's existing pattern exactly. 5. Extend the chatTaskWriter interface (internal/gateway/tasks.go), SpawnRequest (internal/domain/messaging/inbound.go) with an Inputs map[string]any field, StoreTaskCreator.CreateTask, and chatTaskWriterAdapter.EnqueueChatTask (internal/app/archied/main.go). Update every call site (~20, mostly _test.go files across cmd/archie-state-store, internal/app/archied, internal/app/agentworker, internal/app/archieui) to pass the new parameter (nil is fine for every existing non-pr-review caller). 6. Rebuild internal/gateway/review_tools.go's review_pr chat tool to call CreateTask with Workflow: "pr-review", Inputs: map[string]any{"pr_number": n}. Keep its identity-scoped repository authorization shape (see d73e0748's diff for the deleted prReviewer.authorize for reference). Not a quick tool rewrite -- proto/sqlc/wire-contract change plus ~20 call sites. Parent epic: archie-core-afbk. ### Close reason Closed --- _Imported from beads `archie-core-afbk.14` · GitHub #1427 · type task · priority P1 · created 2026-09-28 · closed 2026-09-28_
sam added the hightask labels 2026-10-27 13:35:03 +00:00
sam self-assigned this 2026-10-27 13:35:03 +00:00
sam closed this issue 2026-10-27 13:35:03 +00:00
Author
Owner

sam wrote (originally 2026-09-28):

Done in 772d782f. Steps 1-6 as planned, with one change: instead of adding a SetTaskInputs query, InsertChatTask gained the inputs column directly, so the insert is the inputs column's only writer and StampTaskBinding now stamps provenance alone. One statement, no window where a queued task lacks its inputs.

Also deleted ChatPRReviewer, PRReviewResult/PRReviewFinding and the PRReviewer turn-runner field rather than leaving them unreferenced: review_pr now takes the TaskCreator that task_spawn already uses, so no bespoke interface survives.

Coverage: EffectivePRNumber round trip across both the store and a real gRPC connection (TestStateStoreConformance, local+grpc modes); review_pr tool semantics and CreateTask input forwarding in internal/gateway.

Not covered, filed separately: the dashboard half of the PRD's operator trigger (archie-core-06nq).

_sam wrote (originally 2026-09-28):_ Done in 772d782f. Steps 1-6 as planned, with one change: instead of adding a SetTaskInputs query, InsertChatTask gained the inputs column directly, so the insert is the inputs column's only writer and StampTaskBinding now stamps provenance alone. One statement, no window where a queued task lacks its inputs. Also deleted ChatPRReviewer, PRReviewResult/PRReviewFinding and the PRReviewer turn-runner field rather than leaving them unreferenced: review_pr now takes the TaskCreator that task_spawn already uses, so no bespoke interface survives. Coverage: EffectivePRNumber round trip across both the store and a real gRPC connection (TestStateStoreConformance, local+grpc modes); review_pr tool semantics and CreateTask input forwarding in internal/gateway. Not covered, filed separately: the dashboard half of the PRD's operator trigger (archie-core-06nq).
sam added a new dependency 2026-11-14 14:45:16 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Blocks
Reference: sam/archie#125