Skip to content

id: note reference edges in the native graph + backlink query (#7587) - #13233

Merged
dezren39 merged 2 commits into
mainfrom
xaltha/7587-ref-edges
Nov 24, 2026
Merged

dezren39 merged 2 commits into
mainfrom
xaltha/7587-ref-edges

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Refs #7587 — scope item 4 of the #5830 sharing model (slices 1–2 merged as #7953 and #12206).

The three reference edges live in BoardGraph and backlinks are a query over the same edge store:

  • note_anchors(): reply —anchors→ note-version/passage edges from Post::note_anchor.
  • note_discussions(): post —discusses→ note edges derived from thread membership (a post in a thread where another post embeds the note).
  • note_edges_from(): forward jump-through per post (embeds, anchors, discusses).
  • note_backlinks(): reverse query over all three edge kinds, deduped, deterministic; a post counts once however many edges name the note.
  • Removing a post (active supersede/tombstone) removes its forward edges; superseding the tombstone restores them.
  • Follow-up fix: a plain post in a sharing thread backlinks the note via its discusses edge, so the pre-existing slice-1 test now asserts the union backlink set.

Verification (remote dispatch only, fleet-command.yml fallback): cargo test --lib boards on this branch — 87 passed, 0 failed — in two runs: https://github.com/developing-today/fleet/actions/runs/45165313624 and https://github.com/developing-today/fleet/actions/runs/45166519603.

Does not close #7587 — slice 4 (cross-server) remains.

{
  "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-23T11:48:48Z",
    "session_id": null,
    "lane": null,
    "host": "htch-runtime",
    "worktree": "/home/hatch/workspace/github-work/code-7587",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/hatch/workspace/github-work/code-7587",
      "repo": "developing-today/code",
      "branch": "xaltha/7587-ref-edges",
      "sha": "b86e5acfb7a3b199aae79725cd046f0a08d7cd98"
    },
    "auth_subject": "xaltha",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

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

Scope item 4 of the #5830 sharing model: the three reference edges
live in BoardGraph and backlinks are a query over the same edge store.

- note_anchors(): reply —anchors→ note-version/passage edges from
  Post::note_anchor.
- note_discussions(): post —discusses→ note edges derived from thread
  membership (a post in a thread where another post embeds the note).
- note_edges_from(): forward jump-through per post (embeds, anchors,
  discusses).
- note_backlinks(): reverse query over all three edge kinds, deduped,
  deterministic; a post counts once however many edges name the note.
- Removing a post (active supersede/tombstone) removes its forward
  edges; superseding the tombstone restores them.

Refs #7587
…ses edge (#7587)

The slice-4 backlinks query is the union over all three edge kinds, so
a plain post in the same thread as a sharing post backlinks the note
through its discusses edge. The pre-existing slice-1 test still asserted
the embeds-only backlink set; update it to the union, in content-hash
order like the slice-4 coverage test.

Refs #7587
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 44 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

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: dd3806b3-342c-497e-9107-4e70b1b2b871
Commits

Reviewing files that changed from the base of the PR and between 36b25a0 and b86e5ac.

Files selected for processing: 1

  • pkgs/id/src/boards.rs
  • 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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T11:52:58.585146Z b86e5ac PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b86e5acfb7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkgs/id/src/boards.rs
Comment on lines +7259 to +7260
#[test]
fn note_anchors_discussions_and_backlinks_cover_all_three_edge_kinds() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add property-based coverage for the note-edge invariants

The new edge projections promise meaningful invariants—backlinks are exactly the inverse of forward edges, removed posts contribute no edges, and superseded tombstones restore their targets—but the added tests exercise only fixed graphs. This does not satisfy the testing doctrine in AGENTS.md, which requires property-based coverage where code has invariants. Add generated graph/withdrawal histories with a named oracle for edge membership and the forward/backlink equivalence; retain these examples as acceptance coverage.

AGENTS.md reference: AGENTS.md:L34-L39

Useful? React with 👍 / 👎.

Comment thread pkgs/id/src/boards.rs
Comment on lines +796 to +797
if !removed.contains(hash) {
removed.insert(value.target.clone());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Separate tombstone eligibility from accumulated removed targets

When a post P is targeted by tombstone T1 and another valid tombstone T2 targets T1, visiting T2 first adds T1 to removed, so this condition skips T1 and incorrectly restores P's reference edges and backlinks. Tombstones targeting tombstones are permitted by validate_links, but compose_view checks tombstone eligibility only against the superseded set, so it still hides P. The new query therefore disagrees with the board projection depending on the tombstones' content-hash ordering. Determine tombstone eligibility from the immutable superseded set, separately from accumulating removed targets.

Useful? React with 👍 / 👎.

Comment thread pkgs/id/src/boards.rs
Comment on lines +767 to +769
self.note_discussions()
.into_iter()
.filter(|(_, target)| target == note)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Filter discussion edges before materializing the entire relation

For a thread containing N posts that each embed a distinct note, note_discussions() allocates N×(N−1) pairs of cloned, string-backed hashes before this filter runs. Consequently, even querying backlinks for an absent note produces quadratic work and memory usage: 5,000 valid sharing posts generate roughly 25 million temporary pairs and several gigabytes of allocations just to return an empty result. There is no post-count limit preventing this input. note_edges_from() has the same issue when filtering the complete relation for one post. Traverse discussions with the requested note/post constraint before allocating edges, rather than materializing every unrelated edge.

Useful? React with 👍 / 👎.

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

Labels

audit:partial PR partially implemented; gap filed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

id: implement the note→board sharing model (decision on #5830)

1 participant