validate( $ref ) ) { return new WP_Error( 'invalid_ref', "Ref '{$ref}' does not resolve under the '{$surface}' adapter." ); } return SA_Orch_Arbitration::write( [ 'demand_surface' => $surface, 'demand_ref' => $ref, 'rationale' => $rationale, 'projection_type' => $projection_type, 'truth_class' => $truth_class, ] ); } /** * Convenience: is this surface object already registered as a Demand? * Returns true if at least one arbitration exists for the (surface, ref) pair. */ public static function is_registered( string $surface, string $ref ): bool { global $wpdb; $arb_table = $wpdb->prefix . SA_ORCH_DB_PREFIX . 'arbitration'; $count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$arb_table} WHERE demand_surface = %s AND demand_ref = %s", $surface, $ref ) ); return $count > 0; } }