Skip to content

[bug] Append-order sentinel last_order > 0.0 misreads sibling orders ≤ 0 → sibling-order collisions #1431

Closed

Description

@mstomar125

Severity: medium · Confidence: high

"Append at end" reads max sibling order and treats last_order > 0.0 as "siblings exist", else returns order 1.0 (sqlite_store.rs:486-490, 3074-3078, 3127-3134). But fractional ordering legitimately yields orders ≤ 0 (prepends → 0.0, -1.0…), and unwrap_or(0.0) maps NULL to 0.0. A lone child at order 0.0 is misread as "no children" → next append also gets 1.0 → two siblings share order 1.0.

Fix: distinguish "no row" from "row with order ≤ 0" (Option/row-count); pass Some(last_order) whenever any row exists, regardless of sign.


Found via the 2026-06-18 multi-repo bug-hunt sweep. Confidence/severity from the sweep + spot-verification.

Activity

  1. mstomar125 commented on Jun 24, 2026

    @mstomar125
    ContributorAuthor

    Resolved in #1458. The three append-order sites now track sibling presence as Option<f64> instead of the last_order > 0.0 sentinel, so an append computes from the real max sibling even when its order is ≤ 0 (a legitimate prepend result) — no more first-item-default collisions. Test: append after a sibling at -1.0 → 0.0, not 1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions