The role replacement algorithm is a percentage-based system. Staffing requirement date range is driven by the source requirement, not by the incoming resource filling the requirement.
When a resource is selected to fill a role requirement, the Resource availability is figured into the algorithm that determines the allocation segments. When a resource is added using 'Remaining Availability', the algorithm divides the role allocation with the resource's remaining allocation to get a percentage that is applied to the requirement allocation. Therefore, the Role will stay on the project with some remaining allocation requirement as the resource will only partially fill the requirement. With the 'Over Allocate' option or a role replacement matching 100%, if both the role and the resource have the same calendar and default availability, the resource will fill the entire requirement and the role will be removed.
In the example above, the application is working as expected. The role requirement had a defined date range of 7/1/10 thru 7/31/10. The selected resource filled the role requirement 100% and since the resource is only available for 40 hours, the allocation reflects the resource's availability. The requested role requirement is defined for 100% and it is filled with a resource at 100% (although the resource availability is not for the entire date range) and thus the requirement is considered 'fully filled'.
If you use Resource Finder or Resource Requisitions, the fulfillment of the role requirement can be different. If you want to manage the incoming team member dates on a per-resource basis, you can use Requisitions for the roles and then set the incoming resource's team member dates within the requisition to match their availability.