ports->verifyProviderAndApprove($q); return $this->ports->signProof($q); } public function accept(Envelope $result): void { $this->ports->verifyResultAndApply($result); } } final class ProviderSide { public function __construct(private Ports $ports) {} public function start(Op $op,string $rid,string $target,string $context): Envelope { return $this->ports->challenge($op,$rid,$target,$context); } public function finish(Envelope $proof,string $trustedContext): Outcome { $tx=$this->ports->beginVerified($proof,$trustedContext); try { $old=$tx->cached(); if ($old !== null) return new Outcome($old,false); switch($tx->operation()) { case Op::REGISTER: $tx->registerNewKey(); break; case Op::USE: $tx->requireCurrentEntitlement(); break; case Op::REVOKE: $tx->revokeTarget(); break; case Op::RETRACT: $tx->retractRelationship(); break; } $result=$tx->signResult(); $tx->commitOnce($result); return new Outcome($result,true); } finally { $tx->close(); } } public function lost(string $rid,string $target,string $context): Envelope { return $this->ports->recoverRevoke($rid,$target,$context); } } function legacyValue(string $value,bool $approved,bool $selected): string { if (!$approved || !$selected || $value==='') throw new RuntimeException('Local approval/selection required'); return $value; // No BringPass command sent to the reader. }