Repository navigation
feat(ct-05): Define workspace deactivation with active bookings policy - #831
Merged
Qoder-Voidd merged 1 commit intoOct 23, 2026
Conversation
Define and enforce an explicit deactivation policy in the workspace_booking Soroban contract: - Admin cannot deactivate a workspace (set_workspace_availability with is_available=false) while it has one or more active bookings. The function returns the stable error WorkspaceHasActiveBookings (203) so callers can retry after bookings end, are cancelled, or expire. - Reactivation (is_available=true) is always allowed, regardless of whether active bookings exist. - Existing bookings are never modified or removed by this function — deactivation only prevents new bookings from being created. - Added a private workspace_has_active_bookings helper that iterates the active-bookings index (same pattern as is_slot_available). - Added a public workspace_has_active_bookings_query for off-chain callers to check whether a workspace has active bookings before attempting deactivation. Tests added (test.rs): - Deactivate with no bookings succeeds. - Deactivate with an active booking is blocked (Error 203). - Deactivate after cancelling all bookings succeeds. - Reactivate with active bookings is always allowed. - Deactivate with multiple active bookings is blocked. - Non-admin deactivation is Unauthorized. - Deactivate non-existent workspace is WorkspaceNotFound. - Public query returns correct active-bookings state. Closes Akazajan#709
harmondconsultant-png
pushed a commit
to harmondconsultant-png/Oraculum
that referenced
this pull request
Nov 10, 2026
…-deactivation-policy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements issue #709 (CT-05) — defines and enforces an explicit workspace deactivation policy in the
workspace_bookingSoroban contract.Policy
An admin cannot deactivate a workspace while it has one or more active bookings. The
set_workspace_availabilityfunction returns the stable errorWorkspaceHasActiveBookings(code 203) so the caller can retry after the bookings end, are cancelled, or expire.Reactivation (setting
is_available = true) is always allowed, regardless of active bookings.Existing bookings are never modified or removed — deactivation only prevents new bookings from being created.
Changes
contracts/workspace_booking/src/lib.rsworkspace_has_active_bookingshelper — iterates the active-bookings index (same pattern asis_slot_available/booked_seats_in_window).set_workspace_availabilityto check for active bookings before deactivating. ReturnsError::WorkspaceHasActiveBookings(203) when blocked.workspace_has_active_bookings_queryfor off-chain callers to check whether a workspace has active bookings before attempting deactivation.contracts/workspace_booking/src/errors.rsWorkspaceHasActiveBookings = 203was already defined but unused. Now it is returned by the deactivation guard.contracts/workspace_booking/src/test.rstest_ct05_deactivate_no_active_bookings_succeeds— deactivation with no bookings succeeds.test_ct05_deactivate_with_active_booking_blocked— deactivation with an active booking returns Error 203, workspace stays Available, booking preserved.test_ct05_deactivate_after_cancel_succeeds— blocked while active, succeeds after cancellation.test_ct05_reactivate_with_active_bookings_allowed— reactivation always permitted.test_ct05_deactivate_multiple_active_bookings_blocked— multiple active bookings block deactivation.test_ct05_deactivate_non_admin_fails— non-admin gets Unauthorized.test_ct05_deactivate_nonexistent_workspace_fails— returns WorkspaceNotFound.test_ct05_active_bookings_query— public query returns correct state before booking, during active booking, and after cancellation.Acceptance Criteria
WorkspaceHasActiveBookings= 203)Closes #709