Skip to content

id(notes): cyclic note.revise parents (incl. self-parent) pass the gate and the notes() drop-filter, then fail every note query with a false UnknownParent #4298

Closed

Description

@dezren39

Summary

A note.revise whose parents form a cycle — including the degenerate case of a revision naming itself as its only parent — passes every gate pkgs/id has, survives the defensive drop-filter in LocalEvents::notes(), and then makes fold_notes fail the whole store's note view with UnknownParent — an error that falsely claims the named parent "is not a note event", when the parent is present in the set (in the self-parent case it is the revision itself). One signed cyclic revision from any peer therefore takes down notes(), note_history() and revise_note() for every note in the store, and the diagnosis points investigators at a missing event that is not missing.

Evidence (verified this run, main @ beed98f)

  • Gate: check_note_op (pkgs/id/src/notes.rs:97-141, called from pkgs/id/src/chain.rs:279 on receipt and from pkgs/id/src/local_events.rs:397/450 locally) checks parent count (1..=32) and duplicates only. A parent list containing the revision's own future event ID, or two revisions naming each other, is structurally acceptable to it.
  • Drop-filter: LocalEvents::notes() (pkgs/id/src/local_events.rs:498-525) already defends against unknown/foreign parents by dropping revises whose parents are not revisions of the same note — but its owners.get(parent) == Some(note) test passes for self-parents and cycles, because every cyclic parent is a revision of the same note.
  • Fold: fold_notes (pkgs/id/src/notes.rs:274-335) folds a revision only once all its parents have folded. When nothing can progress it takes rest[0] and returns NoteFoldError::UnknownParent (notes.rs:316-332) for the first unfolded parent — for a cycle that parent is in the set, so the error text ("names parent {parent}, which is not a note event", notes.rs:203-209) is false. notes() propagates the error (Ok(fold_notes(&applied)?)), so one cyclic event fails every note query, not just its own note.

Reproduction (laptop probe, verbatim module)

Probe ~/git/fleet/probe-2026-11-02-laneA-notecycle/ on the laptop compiles pkgs/id/src/notes.rs verbatim (md5 3055ade17c6a57dd46ec351a6792721f, identical in both clones @ beed98f; only p2panda_core::Hash, documents::DocumentRef and waiting::AuthorKey are minimal stubs) plus a verbatim copy of the local_events.rs drop-filter loop:

gate check_note_op(self-parent-shaped op): Ok(())
self-parent: drop_filter kept 2 of 2 events
self-parent: fold_notes -> Err("revision 0b0b… names parent 0b0b…, which is not a note event")
2-cycle: drop_filter kept 3 of 3 events
2-cycle: fold_notes -> Err("revision 0b0b… names parent 0c0c…, which is not a note event")
control unknown-parent: fold_notes -> Err("revision 0b0b… names parent 4d4d…, which is not a note event")  (correct: 0x4d is genuinely absent)
control healthy: fold_notes ok = true

Cases: create(0x0a) + revise(0x0b, parents=[0x0b]) — self-parent; create(0x0a) + revise(0x0b, parents=[0x0c]) + revise(0x0c, parents=[0x0b]) — 2-cycle. Both pass the gate and the drop-filter, both fail the fold with the false UnknownParent.

Why it matters

  • Availability: note events are replicated signed events; a buggy or malicious peer can inject one cyclic revision and every note query on the receiving store fails until the event is dealt with out-of-band. The existing drop-filter (added precisely so one bad peer revision cannot fail every note query — see the comment at local_events.rs:498-503) does not cover this shape.
  • Diagnosis: the error names a present event as missing, sending an operator to hunt sync/replication for an event that already arrived.

Acceptance criteria

  • A self-parent revision and a cyclic parent set (2-cycle minimum) are refused or excluded with an accurate diagnosis — e.g. a distinct NoteFoldError variant (or a drop-filter extension in notes()) that names the cycle/self-reference as the problem, never UnknownParent for a parent that is in the set.
  • One cyclic revision in a store no longer fails notes() / note_history() for the store's healthy notes (whichever layer the fix lands in, the consumer-visible behaviour matches the existing unknown/foreign-parent defence).
  • Genuinely unknown parents still report UnknownParent with the absent parent named (existing tests at notes.rs:~526-545 keep passing).
  • Regression tests cover: self-parent, 2-cycle, and a longer cycle (3+), at the layer(s) changed; healthy chains, concurrent heads and explicit merges fold exactly as before.
  • check_note_op's documented contract is updated if the gate gains a rule it can actually evaluate (it has no event ID, so self-parent may be fold/filter-layer only — say so in the docs rather than leaving the gap implicit).

Dedup: searched open + closed for fold_notes / note parent cycle variants on 2026-11-02 — only #3814 (the closed build issue for the notes module itself). No covering issue.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    priority/normalOrdinary priority (the default)
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    effort/sSmall: expected under 2 hours of work
    on Nov 2, 2026
  2. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator-code-a
    • Session / ID: new-issue-creator-code-a cron run 2026-11-02 03:05 CST
    • Found via: filed this run — read of pkgs/id/src/notes.rs fold + pkgs/id/src/local_events.rs notes() drop-filter on main beed98f, verified with a laptop probe compiling notes.rs verbatim
    • Task: Filed this issue: cyclic note.revise parents (incl. a revision naming itself as parent) pass check_note_op and the notes() drop-filter, then fold_notes fails the whole store's note view with a false UnknownParent (the named parent is in the set).
    • Expectation: effort s; done when cyclic/self-parent revisions are refused or excluded with an accurate cycle diagnosis, one cyclic event no longer fails every note query, and regression tests cover self-parent, 2-cycle and 3+-cycle.
    • Links: probe ~/git/fleet/probe-2026-11-02-laneA-notecycle/ (laptop) · issue body carries the full repro output
  3. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  4. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 2, 2026
  5. 23 remaining items

  6. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedQueue worker lifecycle state
    on Nov 2, 2026
  7. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    Agent note — parked (OpenChamber scheduled lane)

  8. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: handed_off
    state: handed off
    task: 6395 (repo-health-code-pilot; worker repo-worker-code)
    session: ses_e5e61a0b61fffe9AIXnmbVGJNu
    route: opencode-route/workhorse
    action: Bound OpenCode worker launched for this already-claimed task. Resume from the existing PR/checkpoint after fresh revalidation; do not claim another task.

  9. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: picked_up
    state: picked up
    task: 6395 (repo-health-code-pilot; worker repo-worker-code)
    session: ses_e5e61a0b61fffe9AIXnmbVGJNu
    lane: opencode
    found_via: resumed the already-claimed task from its existing PR/checkpoint
    verified: issue #4298 OPEN; PR #4587 OPEN and MERGEABLE at f9e8343; no hard-stop labels; basic OpenCode guard passed. Prior checkpoint records 7 targeted tests passed.
    coverage: id-check.yml has no pull_request trigger, so the policy-listed affected-crate matrix did not run on this PR; recording this gap rather than treating it as a passing check.
    next: proceed under the basic PR merge policy, then verify merge state.

  10. added
    queue/claimedQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 2, 2026
  11. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: done
    state: done
    task: 6395 (repo-health-code-pilot; worker repo-worker-code)
    session: ses_e5e61a0b61fffe9AIXnmbVGJNu
    lane: opencode
    result: PR #4587 merged at 8ef2721; issue #4298 closed.
    validation: basic OpenCode guard passed; targeted suite recorded 7 passed, 0 failed (unknown-parent control, self/2/3-cycle fold regressions, and quarantine test).
    coverage_gap: id-check.yml lacks a pull_request trigger, so the policy-listed package matrix did not run on this PR; reported on PR #4587 rather than counting it as CI coverage.
    links: #4587 · #4298

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

Metadata

Metadata

Assignees

Labels

app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions