docs(prds): scope Forge action position; correct Channel assumption

Investigation for t2db.19. Forge is ready to design: internal/forge.Forge
is already a typed, general-purpose interface with real implementations
(GitHub/Gitea) -- native-Go-by-name, no Yaegi/Module detour needed.
close-issue/link-branch are the safe first-slice operations; create-pr
is deferred (harder idempotency shape than a single-call operation).

Corrects the crew investigation's assumption about Channel: verified
directly that channels.Channel has no Send capability at all (only
Name/Start/Stop + config validation). The only generic outbound
mechanism in the codebase is the single-destination Notify webhook.
Real per-channel sending (telegramApprover) is deliberately
conversation-scoped, not a reusable registry lookup -- a documented
precedent to prevent reading a shared bot handle across chats, which
doesn't transfer to a playbook trigger with no chat turn to anchor to.
Flags two materially different things "Channel action" could mean and
recommends Sam decide before any Channel design work starts, rather
than guessing.
This commit is contained in:
sam committed 2026-09-03 04:15:28 +10:00
1 parent d368b729fb
commit c08988e1f3
1 file changed
+117
+117
View File
@@ -0,0 +1,117 @@
# Channel and Forge action positions -- investigation (resolves `t2db.19`)
**Status:** Investigation complete for Forge; Channel corrected and flagged
for a decision only Sam can make -- not a design recommendation.
**Date:** 2026-09-03
**Parent:** `docs/prds/eda-playbook-engine.md`, epic `archie-core-t2db`
**Blocked on:** `archie-core-t2db.17` (idempotency keying) for implementation
of either position -- both are side-effecting.
## Forge: ready to design once t2db.17 lands
`internal/forge.Forge` is already exactly the shape a native-Go action
position needs -- a real, typed, general-purpose interface, not something
that needs a Yaegi/Module-style schema-generation detour:
```go
type Forge interface {
IssueForge // AssignedIssues, IssuesWithLabel, CloseIssue, ...
PullRequestForge // CreatePR, PRState
RepoForge // AcceptInvitations, VerifyPush, LinkBranch, ...
}
```
**Typed contract shape: native-Go-by-name, not a Module-kind.** Module's
whole reason to exist is giving *Yaegi-authored, operator-supplied* code a
typed contract to implement. `Forge` is already a typed Go interface with
real, tested implementations (GitHub, Gitea) selected at daemon startup by
`forge.New(...)`. Wrapping it in a Module-kind schema/`go:generate` detour
would duplicate a contract that already exists. A Forge action position
should be: a small set of named operations (e.g. `close-issue`, `create-pr`,
`link-branch`), each with a typed `Args`/`Result` struct mirroring the
matching `Forge` method's parameters/return, dispatched by the coordinator
directly against the daemon's already-constructed `Forge` client -- the same
"narrow host access" shape `ModuleDir` has, just pointed at an
already-wired instance instead of a loaded directory.
**Operation scope for a first slice:** `close-issue` and `link-branch`
(single-call, cleanly idempotent by event+issue identity) are the safe
starting set. `create-pr` is explicitly a heavier case -- opening a PR is a
harder-to-reverse action with its own dedup shape beyond "did this event
fire before" (a redelivered event must not open a second PR for the same
logical change) -- defer it to a follow-up slice once `t2db.17`'s keying
scheme is proven on the simpler operations, don't design it blind now.
**Host access:** the coordinator needs the same `Forge` instance
`internal/daemon`'s poller already holds (constructed once at startup via
`forge.New`). This is a daemon-composition wiring question (pass the
existing instance into the coordinator's constructor), not a new
extensibility mechanism.
## Channel: the crew's assumption doesn't hold -- flagged, not designed
The investigation backlog that recommended scoping this alongside Forge
assumed `channels.Channel` already has an addressable send capability that
just needs a name-based lookup. **That's not true.** Verified directly:
```go
// internal/gateway/gateway.go
type Gateway interface {
Name() string
Start(ctx context.Context, router *Router, lifecycle Lifecycle) error
Stop(ctx context.Context) error
}
```
`channels.Channel` embeds exactly this plus `ConfigSchema`/`ValidateConfig`
-- lifecycle and config introspection, nothing about sending a message.
Grepping `internal/channels` and `internal/gateway` for any `Send` method
returns nothing. The only generic outbound-message mechanism in the entire
codebase is `Notify` (`internal/config`'s `[notify]` block) -- a single
fixed webhook URL for gate failures/approvals/parked tasks, not a
per-channel-addressable send.
Real per-channel sending exists, but deliberately not as a reusable
capability: `telegramApprover` (`internal/channels/telegram/approval.go`)
captures a `*bot.Bot` plus a specific `chatID`/`threadID`/`recipient` at
construction, scoped to one conversation for one launch. This is the
established precedent in this codebase (already in project memory from
before this session) precisely to prevent reading a shared bot handle
across chats -- a playbook-triggered send has no chat turn to be scoped to,
so this precedent doesn't transfer as-is.
**This means "Channel action position" is not a small wrapper over an
existing capability -- it requires deciding whether to build a genuinely
new send capability that doesn't exist today, and if so, what it targets.**
Two different things could reasonably be meant by "Channel" here, and they
have different shapes:
1. **A new, playbook-scoped notification capability** -- closer in spirit
to `Notify` (fire a message somewhere, no chat-turn context needed) but
addressable by name/target instead of one fixed webhook. This would be
new engine-family work (its own typed contract, registry, narrow host
access), not an extension of `channels.Channel`.
2. **Reusing the interactive chat channels** (Telegram, email) for
playbook-originated sends -- requires deciding what conversation context
a playbook-triggered message has (which chat? whose approval flow?) when
there was no incoming chat turn to anchor it, and building whatever
capture/scoping mechanism the interactive channels use today, generalized
to a non-chat trigger. This is materially harder and touches the
gateway's session model.
**This is not a call to make unilaterally.** It changes what "Channel
action" even means, and the answer affects the trust/scoping model, not
just an implementation detail. Recommend: Sam decides which of the two (or
a third option not listed here) before any Channel position design work
starts. Until then, `t2db.19` should be treated as **Forge scoping only**
-- the Channel half stays genuinely open, not just unimplemented.
## Packages this touches (Forge only, once `t2db.17` lands)
- `internal/domain/eda` (or a new sibling package, e.g.
`internal/domain/eda/forgeaction`): typed `Args`/`Result` per operation,
a small registry keyed by operation name, dispatched against the
daemon's existing `forge.Forge` instance.
- `internal/app/archied`: wiring the coordinator's constructor to receive
the already-built `Forge` instance, no new lifecycle to manage.
- No changes to `internal/forge` itself -- it is already the right shape.