Skip to content

fix(sync): prioritize bounded public coverage - #2047

Open
branarakic wants to merge 2 commits into
codex/rfc64-m1-core-discovery-wakeupfrom
codex/rfc64-m1-public-priority
Open

fix(sync): prioritize bounded public coverage#2047
branarakic wants to merge 2 commits into
codex/rfc64-m1-core-discovery-wakeupfrom
codex/rfc64-m1-public-priority

Conversation

@branarakic

@branarakic branarakic commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

User impact

When a Core node has admitted a bounded batch of public Context Graphs, it now synchronizes both their finalized VM data and live SWM before spending the rest of the peer round on the potentially large agents/ontology bootstrap backlog.

Only scheduler-vetted automatic public CGs receive this priority. Configured or private CGs remain after the Agents/Ontology bootstrap, so private SWM authorization and key recovery always use a refreshed Agents registry. Edge opt-in behavior is unchanged.

Problem

The previous peer round combined system graphs and the bounded public batch into one durable request, then deferred all SWM until that combined request completed. A large or pressured agents graph could therefore time out first and terminate the round even though the user-facing public CGs were ready to converge.

The formal M1 gate reproduced this: the Core spent its round transferring tens of thousands of system triples and hit store/RPC pressure before emitting an automatic coverage entry for the three fresh public graphs.

Before

sequenceDiagram
    participant C as "Core"
    participant P as "Peer"

    C->>P: Durable sync agents + ontology + public/configured CGs
    P-->>C: Large agents backlog
    P--xC: Timeout or backpressure
    Note over C: Round stops
    Note over C: Public VM incomplete and public SWM never attempted
Loading

After

sequenceDiagram
    participant C as "Core"
    participant P as "Peer"

    C->>P: Durable sync scheduler-vetted public batch
    P-->>C: Public VM data
    C->>P: Sync public SWM for the same batch
    P-->>C: Public SWM data
    C->>P: Bootstrap agents + ontology + configured scope
    P-->>C: Refreshed registry and configured VM data
    C->>P: Sync configured/private SWM
    Note over C: Public VM and SWM are already evidenced
    Note over C: Private SWM runs only after registry refresh
Loading

Implementation

  • Define one canonical SyncOnConnectScopePlan; the base and lifecycle plans extend it instead of duplicating the contract.
  • Pass only scheduler-vetted automatic public CGs through preBootstrapPublicContextGraphIds.
  • Execute durable and shared phases through one ordered helper with common accounting, metadata refresh, and stop-on-pressure behavior.
  • Preserve the legacy empty initial probe for Edge accounting compatibility.
  • Avoid repeating SWM work for graphs completed by the early public phase.
  • Keep configured/private graphs in the post-bootstrap path.

Validation

  • 139 focused tests passed across:
    • sync-on-connect-retry.test.ts
    • sync-on-connect-churn.test.ts
    • core-public-coverage-scheduler.test.ts
    • discovery-subscription-boundary.test.ts
    • sync-coverage-evidence-runtime.test.ts
    • sync-coverage-evidence-edge-periodic.test.ts
  • Includes an exact phase-order regression proving private SWM is attempted only after Agents/Ontology and metadata refresh.
  • pnpm --filter @origintrail-official/dkg-agent run build
    • TypeScript, type tests, and package-root test passed.
  • git diff --check
    • passed.

Stack

  • Base: fix(sync): wake Core coverage after scope expansion #2046 (codex/rfc64-m1-core-discovery-wakeup)
  • This PR is the next independently reviewable M1 layer.
  • It addresses the scheduling blocker exposed by the formal three-node gate; the gate must still be rerun on the exact reviewed stack before M1 can pass.

Comment thread packages/agent/src/sync/on-connect/sync-on-connect.ts Outdated
Comment thread packages/agent/src/sync/on-connect/sync-on-connect.ts Outdated
Comment thread packages/agent/src/dkg-agent-base.ts Outdated
@branarakic
branarakic force-pushed the codex/rfc64-m1-public-priority branch from d8b62db to e748989 Compare August 3, 2026 08:26
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