protected function appendProcessor(Processor $processor, int $stage, int $precedence = ProcessChain::RUN_DEFAULT)
    {
        $stage = WF::clamp($stage, static::STAGE_FILTER, static::STAGE_POSTPROCESS);
        $precedence = WF::clamp($precedence, static::RUN_FIRST, static::RUN_LAST);
        $this->processors[] = [
            'precedence' => $precedence, 
            'stage' => $stage, 
            'seq' => ++$this->seq, 
            'processor' => $processor
        ];

        // Sort the processors, first on stage, then on precedence, finally on order of appending
        usort($this->processors, function ($l, $r) {
            if ($l['stage'] != $r['stage'])
                return $l['stage'] - $r['stage'];
            if ($l['precedence'] != $r['precedence'])
                return $l['precedence'] - $r['precedence'];
            return $l['seq'] - $r['seq'];
        });
        return $this;
    }