fix(sync): default-deprioritize system Context Graphs in sync scheduling - #2115
Merged
Conversation
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
left a comment
There was a problem hiding this comment.
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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(including0) 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
"agents": -100, "ontology": -100in config on the affected node moved user-CG rounds ahead of the poison transfers in the very next cycle.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-agentbuild (tsc + type tests) green.🤖 Generated with Claude Code