Skip to content

plan: update artifacts for 15 states, range orders, and regenerate tasks - #5

Merged
grunch merged 4 commits into
mainfrom
001-mostro-p2p-client
Mar 23, 2026
Merged

plan: update artifacts for 15 states, range orders, and regenerate tasks#5
grunch merged 4 commits into
mainfrom
001-mostro-p2p-client

Conversation

@grunch

@grunch grunch commented Mar 23, 2026

Copy link
Copy Markdown
Member
  • Add PaymentFailed and CompletedByAdmin to OrderStatus enum (13→15 states)
  • Add range order fields (fiat_amount_min/max) to OrderInfo, NewOrderParams, and Order data model with validation rules
  • Add RelaySource enum and is_blacklisted field to Relay entity
  • Add ThemeMode, LogLevel enums and LogEntry struct to shared types
  • Add privacy_mode and logging_enabled to Settings known keys
  • Expand AppState with theme, privacy_mode, logging_enabled fields
  • Update state machine diagrams in research.md and data-model.md
  • Regenerate tasks.md: 93 tasks across 15 phases organized by user story
  • Update agent context via update-agent-context.sh

Summary by CodeRabbit

  • New Features

    • Orders can be fixed or specified as a fiat-range (min/max).
    • Added Theme modes (System/Dark/Light) and runtime logging controls.
    • Relay management now shows source and blacklist status.
    • Order flows include PaymentFailed and CompletedByAdmin outcomes.
    • Privacy mode exposed as a global toggle with authoritative behavior.
  • Documentation

    • Updated state machine, protocol, plan, tasks, and quickstart docs to reflect these changes.

- Add PaymentFailed and CompletedByAdmin to OrderStatus enum (13→15 states)
- Add range order fields (fiat_amount_min/max) to OrderInfo, NewOrderParams,
  and Order data model with validation rules
- Add RelaySource enum and is_blacklisted field to Relay entity
- Add ThemeMode, LogLevel enums and LogEntry struct to shared types
- Add privacy_mode and logging_enabled to Settings known keys
- Expand AppState with theme, privacy_mode, logging_enabled fields
- Update state machine diagrams in research.md and data-model.md
- Regenerate tasks.md: 93 tasks across 15 phases organized by user story
- Update agent context via update-agent-context.sh
@coderabbitai

coderabbitai Bot commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@grunch has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 9 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b608c8e4-c639-4a60-b958-60460e321a64

📥 Commits

Reviewing files that changed from the base of the PR and between 8ee623b and c539f85.

📒 Files selected for processing (1)
  • specs/001-mostro-p2p-client/tasks.md

Walkthrough

Specification updates add optional fixed-or-range fiat fields for orders, introduce new order states (PaymentFailed, CompletedByAdmin), add UI/logging enums and logging state, extend relay metadata, and reorganize the development task plan and priorities.

Changes

Cohort / File(s) Summary
Order contracts & types
specs/001-mostro-p2p-client/contracts/orders.md, specs/001-mostro-p2p-client/contracts/types.md
Replaced required fiat_amount: f64 with optional fiat_amount: f64? plus fiat_amount_min/fiat_amount_max and validation enforcing either fixed or range (min<max, >0). Added PaymentFailed and CompletedByAdmin to order state enums; added ThemeMode, LogLevel, RelaySource enums; added LogEntry; extended OrderInfo, RelayInfo, TradeHistoryEntry, and AppState with new fields.
Data model docs
specs/001-mostro-p2p-client/data-model.md
Updated Order model to nullable fixed/range fiat fields and validation rules; clarified Identity.privacy_mode behavior and Settings write constraints; added Relay.source and Relay.is_blacklisted; added Settings keys privacy_mode and logging_enabled.
Protocol/state machine docs
specs/001-mostro-p2p-client/plan.md, specs/001-mostro-p2p-client/research.md
Documented a 15-state order state machine including PaymentFailed path and CompletedByAdmin; expanded success/failure/admin outcomes and broadened cancellation conditions (includes timeout).
Tasks & roadmap
specs/001-mostro-p2p-client/tasks.md
Major reorganization of tasks and phases: new Phase/US priorities, new Rust module namespace layout (rust/src/storage/*, rust/src/crypto/*, rust/src/protocol/*, rust/src/network/*), revamped Flutter scaffolding (lib/providers/, lib/widgets/*, lib/theme/, lib/router.dart), and large task list/phase rewrites.
Metadata
CLAUDE.md
Updated the auto-generated timestamp from 2026-03-22 to 2026-03-23 (no other content changes).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • Add specs #1 — Edits the same Mostro P2P spec files (contracts/orders.md, contracts/types.md, data-model.md) implementing fiat field changes, enum additions, and related validations.

Poem

🐇 I hopped through specs both wide and small,
From fixed to ranges, I noted all,
New states and logs, a tidy plan—
Tasks rearranged by clever hands,
A carrot-coded roadmap, here we stand!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: updating artifacts for 15-state order machine, adding range order support, and regenerating tasks documentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 001-mostro-p2p-client

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
specs/001-mostro-p2p-client/tasks.md (1)

6-6: Add explicit test tasks for protocol-critical paths.

Given the new fiat mode validation and 15-state lifecycle changes, omitting test tasks entirely increases regression risk. Add targeted tasks for state-machine transitions and fixed-vs-range validation.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@specs/001-mostro-p2p-client/tasks.md` at line 6, Add explicit test tasks
covering protocol-critical paths: create checklist items in the
specs/001-mostro-p2p-client/tasks.md to test the new fiat mode validation
(validate fixed-vs-range pricing behavior and edge cases), exercise the 15-state
lifecycle state-machine transitions (each transition, invalid transitions, and
recovery paths), and include integration scenarios that combine fiat validation
with lifecycle changes; reference the specific features by name (fiat mode
validation, fixed-vs-range validation, 15-state lifecycle, state-machine
transitions) and add them to the `/speckit.checklist` so CI/tests surface
regressions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CLAUDE.md`:
- Around line 28-29: The "Recent Changes" section contains a duplicated entry
for "001-mostro-p2p-client"; remove the second identical line so only one
"001-mostro-p2p-client: Added Rust stable 1.75+ ..." entry remains, ensuring the
file CLAUDE.md no longer has the repeated verbatim line.

In `@specs/001-mostro-p2p-client/contracts/types.md`:
- Around line 118-120: TradeHistoryEntry currently only defines fiat_amount
(fiat_amount: f64) which loses range info from OrderInfo; update the
TradeHistoryEntry type to include nullable fiat_amount and add fiat_amount_min
and fiat_amount_max (fiat_amount: f64?; fiat_amount_min: f64?; fiat_amount_max:
f64?) so entries created from range orders preserve min/max values, and adjust
any serializers/deserializers and mapping logic that populate TradeHistoryEntry
from OrderInfo to set these three fields accordingly.

In `@specs/001-mostro-p2p-client/data-model.md`:
- Around line 57-58: Update the spec text to explicitly forbid providing both a
fixed amount and a range by adding a mutual-exclusivity clause: state that
Either `fiat_amount` OR both `fiat_amount_min` and `fiat_amount_max` MUST be
provided, but NOT both, and ensure the validation rules require that if
`fiat_amount` is present then neither `fiat_amount_min` nor `fiat_amount_max`
may be present, and conversely if `fiat_amount_min`/`fiat_amount_max` are
present then `fiat_amount` must be absent; reference the `fiat_amount`,
`fiat_amount_min`, and `fiat_amount_max` fields when updating the wording and
validation guidance.

In `@specs/001-mostro-p2p-client/tasks.md`:
- Line 49: Update task T017 wording to avoid the incorrect "Pending through
Expired" range: state the requirement as "implement all order states defined in
rust/src/protocol/state_machine.rs" and list or reference the actual state names
(e.g., Pending, Expired, Dispute, CompletedByAdmin, etc.) so implementers know
to include the extra states beyond Expired; keep the file reference to
rust/src/protocol/state_machine.rs and the task ID T017 so reviewers can locate
the implementation target.

---

Nitpick comments:
In `@specs/001-mostro-p2p-client/tasks.md`:
- Line 6: Add explicit test tasks covering protocol-critical paths: create
checklist items in the specs/001-mostro-p2p-client/tasks.md to test the new fiat
mode validation (validate fixed-vs-range pricing behavior and edge cases),
exercise the 15-state lifecycle state-machine transitions (each transition,
invalid transitions, and recovery paths), and include integration scenarios that
combine fiat validation with lifecycle changes; reference the specific features
by name (fiat mode validation, fixed-vs-range validation, 15-state lifecycle,
state-machine transitions) and add them to the `/speckit.checklist` so CI/tests
surface regressions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d5b89cde-bb22-4559-8735-01767ed82d89

📥 Commits

Reviewing files that changed from the base of the PR and between b77ff3b and e772c1f.

📒 Files selected for processing (7)
  • CLAUDE.md
  • specs/001-mostro-p2p-client/contracts/orders.md
  • specs/001-mostro-p2p-client/contracts/types.md
  • specs/001-mostro-p2p-client/data-model.md
  • specs/001-mostro-p2p-client/plan.md
  • specs/001-mostro-p2p-client/research.md
  • specs/001-mostro-p2p-client/tasks.md

Comment thread CLAUDE.md Outdated
Comment thread specs/001-mostro-p2p-client/contracts/types.md
Comment thread specs/001-mostro-p2p-client/data-model.md Outdated
Comment thread specs/001-mostro-p2p-client/tasks.md Outdated
…dation

- Remove duplicate Recent Changes entry in CLAUDE.md
- Add fiat_amount_min/max to TradeHistoryEntry so range orders preserve
  min/max values in trade history
- Add mutual-exclusivity clause to data-model validation: fixed amount
  and range amount cannot both be present
- List all 15 state names explicitly in T017 task description instead
  of misleading "Pending through Expired" range

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@specs/001-mostro-p2p-client/data-model.md`:
- Line 21: Specify a single source of truth for privacy_mode and a clear sync
contract: declare whether Identity.privacy_mode or Settings.privacy_mode is
authoritative (e.g., "Identity.privacy_mode is authoritative"), define the write
path (which API/method updates it — e.g., calls to setPrivacyMode on Identity
should be used; Settings writes must forward to Identity), and document
conflict-resolution and sync timing (e.g., Settings updates are eventual and
must read Identity first, Identity wins on conflict, propagate
Identity->Settings immediately and enqueue retries on failure, include
timestamps or vector clock to resolve concurrent updates). Reference
Identity.privacy_mode and Settings.privacy_mode in the spec and add a short
paragraph describing the required developer-side enforcement (update methods to
always update authoritative source and publish a sync event).
- Line 201: Clarify the lifecycle of the Settings key `logging_enabled`: update
the spec text so it explicitly states whether `logging_enabled` is persisted to
storage or treated as ephemeral and whether startup code overwrites any
persisted value; for example, state either “persisted in Settings storage and
honored on restart” or “not persisted — runtime-only and reset to false on
process start (startup code sets `logging_enabled = false`)”; include the
corresponding implementation note so readers know whether to change persistence
logic or add startup override in code that initializes Settings.
- Line 75: Clarify the timeout semantics by updating the definitions of the
terminal states so they are unambiguous: state that Expired represents automatic
termination due to protocol-level inactivity timeouts (e.g., offer/accept
deadlines or global TTLs enforced by the system), while Canceled represents
explicit termination initiated by the creator or actor (user-triggered cancel)
and only falls back to Canceled-by-timeout when a creator-intended auto-cancel
timer (a creator-configured cancel window) elapses; update the prose for the
symbols Expired and Canceled and any associated state-transition bullets or
examples (including the “Canceled (by creator or timeout)” line) to reflect this
mapping, and add a short example showing an Expired path (system-enforced
deadline) versus a Canceled path (creator action or creator-configured
auto-cancel).

In `@specs/001-mostro-p2p-client/tasks.md`:
- Line 22: Update the T001 task text to use the capitalized platform name
"macOS" for prose consistency: locate the checklist item string containing "T001
Initialize Flutter project ... (ios/, android/, web/, macos/, windows/, linux/)"
and change the prose reference "macos/" to "macOS" while keeping the literal
folder path (macos/) unchanged where necessary so folder names remain accurate.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9cd6d286-32cb-4ed8-b5a0-1814d2dadca9

📥 Commits

Reviewing files that changed from the base of the PR and between e772c1f and 75e3ac5.

📒 Files selected for processing (4)
  • CLAUDE.md
  • specs/001-mostro-p2p-client/contracts/types.md
  • specs/001-mostro-p2p-client/data-model.md
  • specs/001-mostro-p2p-client/tasks.md
✅ Files skipped from review due to trivial changes (1)
  • CLAUDE.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • specs/001-mostro-p2p-client/contracts/types.md

Comment thread specs/001-mostro-p2p-client/data-model.md Outdated
Comment thread specs/001-mostro-p2p-client/data-model.md Outdated
Comment thread specs/001-mostro-p2p-client/data-model.md Outdated
Comment thread specs/001-mostro-p2p-client/tasks.md Outdated
…antics

- Declare Identity.privacy_mode as authoritative source; writes must go
  through Identity API and propagate to Settings, not the reverse
- Clarify logging_enabled is runtime-only and not persisted to storage;
  startup unconditionally resets to false
- Distinguish Expired (protocol-enforced inactivity timeout) from
  Canceled (explicit user action) in state machine documentation
- Use proper platform names in T001 task description (iOS, macOS, etc.)
  while keeping directory paths lowercase

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@specs/001-mostro-p2p-client/tasks.md`:
- Around line 97-105: The tasks T039 and T047 (and related entries lines
111-121) currently tagged [US1] implement core browse/filter behavior tied to
US4 scenarios—rename and retag these tasks to [US4] and update their
descriptions (e.g., T039: lib/screens/home/home_screen.dart - "Implement order
list with filters (buy/sell, currency, payment method) per US4 phase X"; T047:
lib/providers/orders_provider.dart - "Orders provider: fetch/cache/apply filters
per US4") so they represent the full US4 scope; split out any phase-specific or
incremental items (offline/filter persistence, web fallbacks) into separate
tasks with explicit phase tags (e.g., US4-PHASE5) and clear acceptance criteria
so each task is independently testable; ensure references to files like
lib/screens/home/home_screen.dart, lib/providers/orders_provider.dart, and task
IDs (T039, T047) are used in the updated descriptions to preserve traceability.
- Around line 91-92: Update the order creation validation in create_order() (and
the NewOrderParams type) to enforce explicit rules: require either a fixed
fiat_amount OR a range (fiat_amount_min and fiat_amount_max), but not both or
neither; validate that fiat_amount, fiat_amount_min, and fiat_amount_max are
positive numbers; ensure fiat_amount_min < fiat_amount_max when both are
provided; and return clear validation errors for each violation so callers and
tests can rely on these acceptance criteria.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 22fa309f-38dd-4d8e-9090-74806ba8ea83

📥 Commits

Reviewing files that changed from the base of the PR and between 75e3ac5 and 8ee623b.

📒 Files selected for processing (2)
  • specs/001-mostro-p2p-client/data-model.md
  • specs/001-mostro-p2p-client/tasks.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • specs/001-mostro-p2p-client/data-model.md

Comment thread specs/001-mostro-p2p-client/tasks.md Outdated
Comment thread specs/001-mostro-p2p-client/tasks.md Outdated
 Retagged to [US4] with note "(required by US1/US2 for order selection)";
 Phase 5 updated to clarify it adds incremental enhancements

T033 missing validation rules:
 Added explicit validation: fixed-vs-range mutual exclusivity,
 positive amounts, min < max, distinct errors per violation
@grunch
grunch merged commit fa792ed into main Mar 23, 2026
1 check passed
@grunch
grunch deleted the 001-mostro-p2p-client branch March 23, 2026 13:27
grunch added a commit that referenced this pull request Apr 2, 2026
  orders.rs — Fix #7: store_trade_key_index before publish
  Moved store_trade_key_index(&order_id, trade_index) from before the action dispatch to inside the publish-success else branch. A publish failure no longer leaves a stale key mapping.

  orders.rs — Fix #5: ln_address logged in plain text
  Replaced ln_address={:?} (which printed the actual address) with ln_address=present/none using if ln_address_ref.is_some().

  orders.rs — Fix #4: fixed 30-min deadline regardless of activity
  Replaced the fixed deadline with a last_activity instant that resets on each matching event. The idle timeout is now 30 minutes of inactivity, not 30 minutes of total uptime.

  add_lightning_invoice_screen.dart — Fix #2: Lightning Address sent with 1-sat amount
  _isValid now returns false for @ inputs when _resolvedSats is null. _submit also guards against it and surfaces an error instead of falling through to BigInt.one.

  trade_detail_screen.dart — Fix #3: OrderStatus.pending mapped to TradeStatus.active
  Added TradeStatus.loading to the enum and made it the default branch in _mapOrderStatus. Unresolved/initial statuses no longer match the active-trade action button sections.
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