code: func (s *Simulator) triage() {
  	// Collect the unordered list of currently running invocations.
  	invs := make([]int64, 0, len(s.invIDs))
  	for id := range s.invIDs {
  		invs = append(invs, id)
  	}
  
  	// Clone pending triggers list since we don't want the policy to mutate them.
  	triggers := make([]*internal.Trigger, len(s.PendingTriggers))
  	for i, t := range s.PendingTriggers {
  		triggers[i] = proto.Clone(t).(*internal.Trigger)
  	}
  
  	// Execute the policy function, collecting its log.
  	out := s.Policy(&SimulatedEnvironment{s.OnDebugLog}, In{
  		Now:               s.Now,
  		ActiveInvocations: invs,
  		Triggers:          triggers,
  	})
  
  	// Instantiate all new invocations and collect a set of consumed triggers.
  	consumed := stringset.New(0)
  	for _, r := range out.Requests {
  		s.handleRequest(r)
  		for _, t := range r.IncomingTriggers {
  			consumed.Add(t.Id)
  		}
  	}
  
  	// Pop all consumed triggers from PendingTriggers list (keeping it sorted).
  	if consumed.Len() != 0 {
  		filtered := make([]*internal.Trigger, 0, len(s.PendingTriggers))
  		for _, t := range s.PendingTriggers {
  			if !consumed.Has(t.Id) {
  				filtered = append(filtered, t)
  			}
  		}
  		s.PendingTriggers = filtered
  	}
  }
docs: // triage executes the triggering policy function.