Why: Owner-only command audit cannot prove shared business commits, and button dispatch omitted its authenticated actor. Evidence: Local go test ./... passed; isolated PostgreSQL cutoff, link, and SQLite-to-PostgreSQL migration receipts are recorded as SELF in the task card. Impact: Add an optional domain-verified metadata link, exact authorized cross-member read, idempotent storage, actor propagation, and honest PostgreSQL cutoff coverage. Broad audit pagination and other sources remain pending. Refs: Stage 5 W9; approved Stage 6 audit-link design adjustment r1
26 lines
916 B
Go
26 lines
916 B
Go
package app
|
|
|
|
import (
|
|
"context"
|
|
|
|
"agent-system-backend/internal/cmdbus"
|
|
"agent-system-backend/internal/surfacesvc"
|
|
)
|
|
|
|
// dispatchSurfaceAction receives Owner from SurfaceService's authenticated
|
|
// caller. The button is acting for that user, so both Actor and Owner must be
|
|
// populated before the command bus writes its audit envelope.
|
|
func dispatchSurfaceAction(ctx context.Context, bus *cmdbus.Bus, d surfacesvc.ActionDispatch) (surfacesvc.ActionOutcome, error) {
|
|
resp := bus.Dispatch(ctx, cmdbus.Request{ID: d.CommandID, Params: d.Params,
|
|
Entrance: "button", Actor: d.Owner, Owner: d.Owner, ConversationID: d.ConversationID})
|
|
state := "committed"
|
|
if resp.Receipt.State != "" {
|
|
state = string(resp.Receipt.State)
|
|
}
|
|
cardID := ""
|
|
if resp.Card != nil {
|
|
cardID = string(resp.Card.ID)
|
|
}
|
|
return surfacesvc.ActionOutcome{State: state, CardID: cardID, Receipt: resp.Receipt, Payload: resp.Payload}, nil
|
|
}
|