Skip to content

id-events: fold position queries use the memoised frontier, not a per-call index clone (#15142 slice) - #17551

Merged
developing-today-fleet[bot] merged 3 commits into
mainfrom
xaltha/15142-group-warnings
Nov 30, 2026
Merged

developing-today-fleet[bot] merged 3 commits into
mainfrom
xaltha/15142-group-warnings

Conversation

@developing-today-fleet

@developing-today-fleet developing-today-fleet Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Refs #15142 — remainder slice (a) from lane 0900-AH's handoff: the serve_group_warnings tests, whose member counts (96/128) ARE the size thresholds under test, so no fixture cut is legitimate. This is the production-side fix AH called for.

Root cause (evidenced by component bench)

GroupLog::record folds the whole log per append, and the fold judged every event's authority through Membership::access_at_position_shared. That shared variant clones the entire CausalIndex — every decided event plus the frontier memo — on every call, because it borrows immutably (its own doc: "it copies the frontier index rather than memoising into it, so prefer the mutable method on a hot path"; fold.rs even admitted "This is the slow path: it does not use the membership layer's frontier memo"). Per member event the fold made ≥2 such calls (is_active_for + access_for in effective_author).

Component bench (temporary test, since removed; fleet runner, 128-member log):

measure main this branch
build 128-member log 20,755ms 16,751ms
one fold of the 128-event log 231ms 187ms
one more record on the full log 470ms 377ms

Runs 46490243711 (main) and 46490355803 (this branch's fix commits). A consistent −19/−20% across all three measures. The remaining fold cost is the membership layer's per-event position work (state_at replays, several queries per event at the same position) — recorded on #15142 as the next slice's starting point; this PR does not speculate at it.

Fix

Propagate &mut through the fold's judge graph (apply/judge and the delegation judges were already &mut) so position queries use the memoised Membership::access_at_position. Borrow-only change — no verdict logic moves:

  • is_active_at/is_active_for take the record's friendship/present facts as values, read by callers before the mutable borrow.
  • authorized_device_account collects candidate grants before the mutable queries (iteration order preserved).
  • is_grantor_of_record copies the grant's group/grantor out first and collects matching removals before calling successors_of.

Verification

  • The 6 serve_group_warnings tests pass with thresholds and assertions untouched; the full id-events, id-groups, and id-core suites (the fold's verdict surface) pass in the same dispatch: 1631 passed / 0 failed (run 46485581212, pre-merge head; re-verified on the merged head in run 46494051603).
  • Isolation timings for the warnings family on the fix commits were runner-variance-bound (14.287s vs 12.393s baseline on a different runner instance), which is why the component bench above — same-shape measures, three consistent deltas — is the evidence of record for the improvement.
{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-30T19:45:33Z",
    "session_id": null,
    "lane": null,
    "host": "htch-runtime",
    "worktree": "/home/hatch/workspace/github-work/code-15142-cl",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/hatch/workspace/github-work/code-15142-cl",
      "repo": "developing-today/code",
      "branch": "xaltha/15142-group-warnings",
      "sha": "79e22bd2f21ddd9bd15d686085dde04a61261747"
    },
    "auth_subject": "xaltha",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…frontier, not a per-call index clone

The group fold judged every event's authority through
Membership::access_at_position_shared, which clones the whole
CausalIndex (every decided event plus the frontier memo) on every
call because it borrows immutably. A fold of an n-event log made
several such calls per event, and GroupLog::record folds the whole
log per append, so building a group log cost O(n) folds x O(n)
events x O(n) index clones.

Propagate &mut through the fold's judge graph (apply/judge and the
delegation judges were already &mut) so the position queries use
Membership::access_at_position, which memoises frontiers in the
index instead of copying it. Borrow-only change: no verdict logic
moves. authorized_device_account collects its candidate grants
before the mutable queries, and is_grantor_of_record copies the
grant's group/grantor out first, both preserving iteration order
and outcomes.

Measured on the serve_group_warnings tests whose member counts are
the thresholds under test (96/128), so no fixture cut is legitimate
(#15142): baseline on main 56da0db, isolation, fleet runner —
fire_once_at_each_size_threshold 12.393s, evaluate_custom_groups_log
5.191s (run 46478887061). After/before comparison follows in the PR.

Refs #15142
…essor query (borrow fix for the fold &mut propagation)
@coderabbitai

coderabbitai Bot commented Nov 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0758f848-cc19-4799-830c-d40b3243efcc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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