Skip to content

fix(leasehold): block unrent while a termination is pending - #29

Merged
md5sha256 merged 1 commit into
mainfrom
fix/block-unrent-while-terminating
Aug 23, 2026
Merged

fix(leasehold): block unrent while a termination is pending#29
md5sha256 merged 1 commit into
mainfrom
fix/block-unrent-while-terminating

Conversation

@md5sha256

Copy link
Copy Markdown
Collaborator

An eviction is a landlord-initiated termination, held on the contract as terminationEffectiveDate + terminatedByRole. The unrentRegion UPDATE cleared both alongside the tenant, and rentRegion had no termination guard, so an evicted tenant could /realty unrent (erasing the eviction and taking a pro-rata refund) and immediately re-rent on a fresh full-length lease -- unilaterally cancelling an eviction that /realty terminate cancel restricts to the initiating party.

Guard unrent the way extend and modify are already guarded: a scheduled termination now yields UnrentResult.Terminating, so the lease can only end via the sweep on its effective date. The guard is applied both on the read in RealtyBackendImpl (for the message) and as a WHERE predicate on the UPDATE, since serializeByRegion only locks within a single server and a scheduleTermination from another could otherwise land between the two.

This covers tenant-initiated terminations too, consistent with extend and modify; a tenant who scheduled their own can cancel it first, which an evicted tenant cannot.

An eviction is a landlord-initiated termination, held on the contract as
terminationEffectiveDate + terminatedByRole. The unrentRegion UPDATE cleared
both alongside the tenant, and rentRegion had no termination guard, so an
evicted tenant could /realty unrent (erasing the eviction and taking a
pro-rata refund) and immediately re-rent on a fresh full-length lease --
unilaterally cancelling an eviction that /realty terminate cancel restricts
to the initiating party.

Guard unrent the way extend and modify are already guarded: a scheduled
termination now yields UnrentResult.Terminating, so the lease can only end
via the sweep on its effective date. The guard is applied both on the read
in RealtyBackendImpl (for the message) and as a WHERE predicate on the
UPDATE, since serializeByRegion only locks within a single server and a
scheduleTermination from another could otherwise land between the two.

This covers tenant-initiated terminations too, consistent with extend and
modify; a tenant who scheduled their own can cancel it first, which an
evicted tenant cannot.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@md5sha256
md5sha256 merged commit d0122d1 into main Aug 23, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants