mesh-issues: record who acted as the caller the runtime proves (hq issue 365)
The tool runner now takes a call's caller from the subject it arrived on and hands it to the module through the SDK (stdio.CallerOf); the tracker records that bus user on what each verb writes instead of unproven. Never from the arguments, which still refuse any caller, and unproven where the runtime proves none. Needs mesh-sdk's go/caller.go (pinned at its branch head until merged).
This commit is contained in:
@@ -34,7 +34,9 @@ type Tracker struct {
|
||||
Deliveries DeliveryState
|
||||
// Notify tells the operator's channel of a stuck fix (ADR 0281); nil says nothing there.
|
||||
Notify Notifier
|
||||
groom grooming
|
||||
// CallerOf is who called, for the arguments one call was handed (stdio.CallerOf); nil proves nobody.
|
||||
CallerOf func(map[string]any) string
|
||||
groom grooming
|
||||
}
|
||||
|
||||
// The events this module says, one per kind of change.
|
||||
@@ -57,10 +59,22 @@ const (
|
||||
createAttempts = 3
|
||||
)
|
||||
|
||||
// by is who acted on this call. The runtime does not hand a module its caller, so it is Unproven; it is
|
||||
// never read from the call's arguments, so no caller can name another (ADR 0275 §5).
|
||||
// by is who acted where no call says it — a public method called at the terminal or in a test: Unproven.
|
||||
func (t *Tracker) by() string { return Unproven }
|
||||
|
||||
// callerOf is who acted on one call, as the runtime proves it: the bus user that published the call, which the
|
||||
// runtime takes from the subject it arrived on (hq issue 365, mesh-sdk stdio.CallerOf), or Unproven where the
|
||||
// runtime proves none. It is never read from the call's arguments, so no caller can name another (ADR 0275 §5).
|
||||
func (t *Tracker) callerOf(m map[string]any) string {
|
||||
if t.CallerOf == nil {
|
||||
return Unproven
|
||||
}
|
||||
if c := t.CallerOf(m); c != "" {
|
||||
return c
|
||||
}
|
||||
return Unproven
|
||||
}
|
||||
|
||||
func (t *Tracker) now() time.Time { return t.Now().UTC().Truncate(time.Second) }
|
||||
|
||||
func (t *Tracker) owners() (Owners, error) {
|
||||
@@ -108,7 +122,10 @@ type Opened struct {
|
||||
// Open checks an issue, then takes the next number and writes the issue under it (to-be 53 §4). A refused
|
||||
// issue takes no number. A number taken and then not written — the bus failing between the two — stays
|
||||
// unused, and the answer says which: numbers may skip, never repeat.
|
||||
func (t *Tracker) Open(a OpenAsk) (*Opened, error) {
|
||||
func (t *Tracker) Open(a OpenAsk) (*Opened, error) { return t.open(t.by(), a) }
|
||||
|
||||
// open is Open as the one who acts.
|
||||
func (t *Tracker) open(by string, a OpenAsk) (*Opened, error) {
|
||||
title, err := singleLine("title", a.Title, MostTitle)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -143,7 +160,7 @@ func (t *Tracker) Open(a OpenAsk) (*Opened, error) {
|
||||
}
|
||||
}
|
||||
at := t.now()
|
||||
is := Issue{Title: title, Status: StatusOpen, Report: report, Opened: at, OpenedBy: t.by(), LocatedIn: located, Opening: newID(),
|
||||
is := Issue{Title: title, Status: StatusOpen, Report: report, Opened: at, OpenedBy: by, LocatedIn: located, Opening: newID(),
|
||||
Severity: severity, Needs: needs}
|
||||
|
||||
n, err := t.next()
|
||||
|
||||
Reference in New Issue
Block a user