Skip to content

fix(sync): default-deprioritize system Context Graphs in sync scheduling - #2115

Merged
branarakic merged 2 commits into
mainfrom
fix/sync-default-depriority-system-cgs
Aug 6, 2026
Merged

fix(sync): default-deprioritize system Context Graphs in sync scheduling#2115
branarakic merged 2 commits into
mainfrom
fix/sync-default-depriority-system-cgs

Conversation

@branarakic

Copy link
Copy Markdown
Contributor

Problem

System CGs (agents, ontology) are broadcast directories, yet they bulk-replicate through the same per-peer sync fanout as user data — ahead of it, at default priority. On a live 10.0.12 Base-mainnet edge node (2026-08-06) they were the observed poison transfers: ~16k-triple rounds dying mid-stream against a relay-only curator every 5-minute cycle, and because the fanout stops on the first backoff-worthy failure, a trivial 604-triple user CG behind them could not receive its curator's SWM updates for hours.

Fix

System CGs now default to priority -100 (DEFAULT_SYSTEM_CONTEXT_GRAPH_PRIORITY), so they sort last in every fanout and admission-queue ordering. Two layers that can never disagree:

  • resolveSyncContextGraphPriorities(...) fills defaults at agent construction, so every consumer — fanout ordering, admission scheduling, and the "Resolved sync policy" boot log's class counts — sees the same effective map.
  • contextGraphPriority(...) carries a read-side backstop for maps that never passed through the resolve step.

An explicit operator entry in syncContextGraphPriorities (including 0) always wins.

Running system CGs last also bounds the fanout-abort blast radius: their failures can no longer starve user CGs — only each other. (Fanout abort semantics themselves are fixed separately in the sibling PR fix/sync-fanout-isolation.)

Notes

  • Field-verified equivalent: setting "agents": -100, "ontology": -100 in config on the affected node moved user-CG rounds ahead of the poison transfers in the very next cycle.
  • Supersedes part of draft fix(sync): prioritize user graphs over system discovery #1946.
  • OT-RFC-64 Rev 4.7 is silent on system-CG scheduling; this is a legacy-path repair that also improves the fixed Track-1 baseline its §10.4 A/B gate measures against.

Tests

sync-policy.test.ts + sync-requester-priority.test.ts: defaults applied; explicit override wins (positive/zero/negative); system CGs order last incl. the read-side backstop path; resolved class counts reflect defaults. Full @origintrail-official/dkg-agent build (tsc + type tests) green.

🤖 Generated with Claude Code

On a live 10.0.12 Base-mainnet edge node (2026-08-06) a trivial 604-triple
Context Graph could not receive its curator's SWM updates for hours: the
per-peer sync fanout aborted on a poison system-CG transfer every 5-minute
cycle, and because the fanout stops on the first failure, the user graph
queued behind it never ran. The poison transfers were the system graphs
agents/ontology (~16k+ triples), which bulk-replicate through the same
fanout as user data despite being broadcast directories any connected peer
can serve. Interrupted transfers restarting from offset 0 made each retry
as expensive as the first.

System Context Graphs now default to priority -100
(DEFAULT_SYSTEM_CONTEXT_GRAPH_PRIORITY) so they sort LAST in every
per-peer fanout and admission-queue ordering. Running them last means
their failures land after all user work and therefore cannot starve it,
while their content still syncs whenever the fanout survives that far.

Design: the defaults are merged exactly once, where the operator config is
normalized (resolveSyncContextGraphPriorities, applied in DKGAgent.create),
so every consumer -- ordered fanout, priority admission, responder
scheduling, and the "Resolved sync policy" boot log's class counts -- acts
on and reports the same effective map. contextGraphPriority additionally
falls back to the system default for maps that never passed through the
resolve step, so no call site can bypass the invariant. An explicit
operator entry in syncContextGraphPriorities (including 0) always wins
over the default.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@otReviewAgent otReviewAgent 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.

Operational Notice: Review Agent could not complete this review.

Business logic reviewer failed: WARNING: failed to clean up stale arg0 temp dirs: Permission denied (os error 13)

@branarakic
branarakic merged commit b1679a0 into main Aug 6, 2026
7 of 14 checks passed
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.

2 participants