Skip to content

booking: owner's line for a held deposit, with Return deposit - #10028

Open
olety wants to merge 2 commits into
mainfrom
opus-deposits/deposit-owner-lines
Open

olety wants to merge 2 commits into
mainfrom
opus-deposits/deposit-owner-lines

Conversation

@olety

@olety olety commented Nov 20, 2026

Copy link
Copy Markdown
Member

FIX rows: [BK-DEPOSIT-HOST-CANCEL-AFTER-START-OWNER-LINE] PR 2 (the owner lines) and [BK-ECHO-UNMARKED-COPY-OWNER-LINE].
Rulings: BK-DEPOSIT-OWNER-RETURN-ACT = A and BK-DEPOSIT-OWNER-RETURN-SCOPE = A (Engine 21 Nov 02:56: "The actionable inbox line shows only for the calendar-cancel cases (a) and (b) and the held unproven-replay case. Everywhere else the act is on the owner's booking card only. Nothing refunds by itself."); BK-ECHO-UNMARKED-SAME-SHAPE-COPY = C (lead 21 Nov 04:3x: A plus an owner-visible line "a cancel we can't attribute: refund by hand?" with the Return deposit button). PR 1, the act vault.booking.deposit.refund, is #9977 (merged).

What changes

  • Booking card (BookingOwnerCard.deposit, serde default, omitted when None): once the booking is effectively cancelled or has started (the return's own condition), what its deposit still holds: held (capture_due, captured, or the balance after a partial refund), amount_minor, currency, reason (calendar_cancel, unattributed_cancel, cancelled, started), the owner's line, and return_offered (the reader is a host selected at confirmation, who alone may call vault.booking.deposit.refund). Before then, or with nothing held, no field.
  • INBOX row booking-held-deposit:<event hex> (kind CoordinationUpdate, no new wire kind, nothing stored): for the live owners among the selected hosts, on any day, only where a calendar's cancel moved no money (the booking's own status still live, a calendar.status cancellation counted: cases (a), (b) and the held unproven-replay case all read this way) or a cancel could not be attributed. Opening it opens the booking card; once the deposit no longer stands held (a return owed or made) the row goes, and its handle opens nothing. Its own id, so marking the same-day booking: row done never hides it.
  • One rule for "held": booking/lifecycle/deposit/held.rs held_of(); the owner's return (owner_return, refund.rs) now reads it, so the line shows exactly when Return deposit moves money.
  • C flag: DepositRow.unattributed_cancel_sequence (serde default, skipped when None), set in the replay proof's own writer (outbound.rs write_replay_proof) when a cancelled write's replay read a stored copy with no write marker as the owner's own (StoredCopy::Own { marker_proved: false }), on a deposit a host cancel would have moved (capture due or captured). First one wins; no money moves.
  • Amounts read in the major unit by the ISO 4217 exponent (connector_key::iso_4217_exponent, now crate-visible): "40.00 USD".

Line (captured, selected host): Booking at 2026-03-02 09:00 (UTC) was cancelled in a calendar. 40.00 USD is still held as its deposit. Choose Return deposit to refund it in full. Unattributed: Booking at ...: a cancel we can't attribute: refund by hand? 40.00 USD is still held as its deposit. Choose Return deposit to refund it in full.

Not in this PR: the emergency-repick note ("no deposit held (refunded at your emergency cancel)", 11-15 19:17 line of the row) follows as PR 3; the row stays open for it.

Stored change: keep (one additive optional field on the deposit row; old rows decode as before). No new verb; self.inbox.get's output card gains the optional deposit object. Grants: the row and the card are read under the owner's own INBOX checks (own_inbox_item); the act stays vault.booking.deposit.refund (owner proof revalidated in the money write, selected host).

Tests (tests/booking_deposit_refund_rules.rs, 5 new at the end)

  • a_calendar_cancel_that_moved_no_money_lists_the_held_deposit_until_the_host_returns_it
  • a_calendar_cancel_after_the_start_lists_the_held_deposit
  • a_cancel_read_as_the_owners_write_without_its_marker_lists_the_held_deposit_as_unattributed
  • a_started_booking_shows_its_held_deposit_on_its_card_only
  • an_owner_who_was_not_a_selected_host_is_not_offered_the_return

Red pin opus-deposits/deposit-owner-lines-red-ad866d58 (tests only, on main a4da017; the rows are read through self.inbox.get by name, so it builds and fails by assert); head pin opus-deposits/deposit-owner-lines-head-a0aa05cd. Proof runs are booked after the merge.
Run: RUSTFLAGS="--cfg oneiron_test_support" cargo test --locked -p oneiron --all-features --test booking_deposit_refund_rules.

BK-DEPOSIT-HOST-CANCEL-AFTER-START-OWNER-LINE PR 2 and
BK-ECHO-UNMARKED-COPY-OWNER-LINE (BK-DEPOSIT-OWNER-RETURN-SCOPE = A,
Engine 21 Nov 02:56; BK-ECHO-UNMARKED-SAME-SHAPE-COPY = C, lead 21 Nov
04:3x). Five tests at the end of tests/booking_deposit_refund_rules.rs:
a calendar cancel that moved no money (a calendar never written to, and
one seen after the start) lists a booking-held-deposit row for the
selected host until the host's return; an unmarked same-shape copy read
as the owner's own write lists it as a cancel we can't attribute; a
started booking shows the line on its card only; an owner who was not a
selected host gets no row and no Return deposit. Rows are read through
self.inbox.get by name, so this commit builds on main and fails by
assert.
BK-DEPOSIT-HOST-CANCEL-AFTER-START-OWNER-LINE PR 2 (BK-DEPOSIT-OWNER-
RETURN-ACT = A and -SCOPE = A, Engine 21 Nov 02:56) and
BK-ECHO-UNMARKED-COPY-OWNER-LINE (BK-ECHO-UNMARKED-SAME-SHAPE-COPY = C,
lead 21 Nov 04:3x).

- BookingOwnerCard.deposit (serde default, omitted when None): once the
  booking is effectively cancelled or has started, what its deposit still
  holds (capture due, captured, or the balance after a partial refund),
  the reason (calendar_cancel, unattributed_cancel, cancelled, started),
  the owner's line and return_offered (the reader is a host selected at
  confirmation, who alone may call vault.booking.deposit.refund).
- An INBOX row booking-held-deposit:<event hex> for the live owners among
  the selected hosts, any day, only where a calendar's cancel moved no
  money (raw booking status live, a calendar.status cancellation) or a
  cancel could not be attributed; opening it opens the booking card, and
  a handle whose deposit no longer stands held opens nothing.
- deposit/held.rs: held_of() is the one rule for what is held; the
  owner's return (owner_return) now reads it, so the line shows exactly
  when the return moves money.
- DepositRow.unattributed_cancel_sequence (serde default, skipped when
  None; stored change: keep, additive): set in the replay proof's own
  writer when a cancelled write's replay read a stored copy with no write
  marker as the owner's own (StoredCopy::Own { marker_proved: false }),
  on a deposit a host cancel would have moved.
- Amounts read in the currency's major unit by its ISO 4217 exponent
  (connector_key::iso_4217_exponent, now crate-visible).
@greptile-apps

greptile-apps Bot commented Nov 20, 2026

Copy link
Copy Markdown

Automatic reviews are disabled for this repository. Configure in Code Review Settings.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 12 billable files and costs up to $3.00.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 58 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 151 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 436c6e5 and a0aa05c.

Files selected for processing: 12

  • crates/oneiron/src/agent_inbox_lens/read_state.rs
  • crates/oneiron/src/booking/lifecycle/deposit.rs
  • crates/oneiron/src/booking/lifecycle/deposit/held.rs
  • crates/oneiron/src/booking/lifecycle/deposit/refund.rs
  • crates/oneiron/src/booking/lifecycle/mod.rs
  • crates/oneiron/src/booking/lifecycle/owner_card.rs
  • crates/oneiron/src/booking/lifecycle/owner_card/held_deposit.rs
  • crates/oneiron/src/booking/mod.rs
  • crates/oneiron/src/calendar/connectors/outbound.rs
  • crates/oneiron/src/connector_key/charter.rs
  • crates/oneiron/src/connector_key/mod.rs
  • crates/oneiron/tests/booking_deposit_refund_rules.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

This branch has not been deployed

No deployments
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.

1 participant