Repository navigation
Description
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 frompkgs/id/src/chain.rs:279on receipt and frompkgs/id/src/local_events.rs:397/450locally) 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 itsowners.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 takesrest[0]and returnsNoteFoldError::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
NoteFoldErrorvariant (or a drop-filter extension innotes()) that names the cycle/self-reference as the problem, neverUnknownParentfor 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
UnknownParentwith 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
dezren39 commentedon Nov 2, 2026
🤖 Agent note · filed
dezren39 commentedon Nov 2, 2026
🤖 Agent note · picked up
23 remaining items
dezren39 commentedon Nov 2, 2026
Agent note — parked (OpenChamber scheduled lane)
repo-worker-code), lane7b47536b-c162-444c-be8a-3a9538cc4cb5queue/6395-4298-note-revision-cycleatf9e8343ee(single fix commit; diff vs origin/main is exactly notes.rs + local_events.rs).cargo test ... --lib -- notes::tests test_cyclic_remote_revisions_do_not_disable_healthy_notes→ 7 passed, 0 failed (unknown-parent control + self/2/3-cycle fold tests + quarantine test). Codex review completed with no findings; CodeRabbit NEUTRAL.basic: OpenCode metered-provider guardstill QUEUED — parking per 5-minute CI rule, not holding a claim while waiting.dezren39 commentedon Nov 2, 2026
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.
dezren39 commentedon Nov 2, 2026
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.
dezren39 commentedon Nov 2, 2026
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