Skip to content

fix(rfc64): resolve cold selected CG name hashes - #2043

Open
branarakic wants to merge 4 commits into
codex/rfc64-m1-first-boot-periodic-scopefrom
codex/rfc64-m1-cold-historical-binding
Open

fix(rfc64): resolve cold selected CG name hashes#2043
branarakic wants to merge 4 commits into
codex/rfc64-m1-first-boot-periodic-scopefrom
codex/rfc64-m1-cold-historical-binding

Conversation

@branarakic

@branarakic branarakic commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

User impact

An Edge user can select an existing public Context Graph after its creation event has aged out of the node's bounded live-event lookback. The node can now recover that selected graph's authoritative numeric on-chain ID directly from the indexed creation commitment, without requiring the ontology graph to have synchronized first.

This removes the cold-start identity deadlock that kept policy, ownership, era, VM and SWM validation pending for an otherwise valid selected graph.

It does not make Edge nodes enumerate or synchronize every public Context Graph. Historical lookup is admitted only for an explicitly selected subscription or a Core-hosted record; arbitrary remote identifiers and passive records cannot start a chain scan.

Stack base: #2041

Before

sequenceDiagram
    actor User
    participant Edge
    participant Poller as "Live event poller"
    participant Ontology as "Local ontology graph"
    participant Chain

    User->>Edge: Select an existing public CG
    Edge->>Poller: Resolve creation event
    Poller-->>Edge: Event is older than bounded lookback
    Edge->>Ontology: Legacy reverse lookup
    Ontology-->>Edge: No binding in cold store
    Edge-->>Edge: Numeric CG ID remains unresolved
    Note over Edge,Chain: Policy, VM and SWM validation cannot establish the authoritative CG binding
Loading

After

sequenceDiagram
    actor User
    participant Edge
    participant Chain as "ContextGraphStorage"
    participant DKG

    User->>Edge: Select an existing public CG
    Edge->>Edge: Confirm local sync admission
    Edge->>Chain: Exact indexed ContextGraphCreated(nameHash) lookup
    Chain-->>Edge: One numeric CG ID candidate
    Edge->>Chain: getNameHash(CG ID)
    Chain-->>Edge: Current matching commitment
    Edge->>Edge: Persist hash-to-ID binding
    Edge->>Chain: Read policy, ownership and era
    Edge->>DKG: Continue selected VM/SWM synchronization
Loading

Implementation

  • adds an optional chain-adapter reverse-resolution capability;
  • keeps normalization, TTL/single-flight behavior and abortable waiting in a focused ContextGraphNameHashResolver;
  • injects one concrete EVM-owned loader rather than a generic scan framework;
  • scans exact indexed ContextGraphCreated.nameHash topics in deploy-block-anchored, RPC-safe pages;
  • rejects an over-budget historical span before making any page query;
  • single-flights concurrent requests and short-caches misses so a later registration is discoverable without restart;
  • deliberately does not retain positive results in the adapter: every independent lookup can detect a duplicate commitment created later, while the Agent persists an admitted successful binding;
  • fails closed for duplicate historical commitments or a current-slot hash mismatch;
  • lets an aborted caller stop waiting without cancelling shared work needed by other callers;
  • gates historical scans on explicit local selection or Core-hosted admission before retaining the ontology projection as a legacy miss fallback;
  • preserves the original spelling of hash-shaped cleartext Context Graph IDs;
  • keeps the production mock adapter behaviorally aligned with the EVM adapter;
  • preserves existing call shapes when no abort signal is supplied.

Validation

  • full 17-package dependency/build chain: 17/17 passed;
  • full Chain suite: 69 files, 1,224 passed, 1 skipped, 0 failed;
  • focused Chain reverse-resolution tests: 8/8 passed;
  • focused resolver plus production Mock/EVM adapter parity: 23/23 passed;
  • Agent historical-binding, source-label, host-mode and hash-shaped-ID coverage plus relevant integration: 4 files, 46/46 passed;
  • staged diff check: passed.

Isolated testnet canary evidence

Production Core services were not changed. A fresh isolated Edge used only three selected cleartext public CG IDs and the exact stack head.

  • cold binding persisted 3/3 authoritative mappings without ontology catch-up: m1-20260803o-1 -> 222, -2 -> 223, -3 -> 224;
  • the Edge assembled 18/18 data graphs and 432/432 data triples: 12 SWM graphs plus 6 finalized VM graphs, 24 triples each;
  • every graph's canonical triple digest matched at least one production Core source exactly; no metadata-only result was counted;
  • four SWM graphs were fragmented across individual Cores, but the Edge assembled the complete union across providers;
  • the exact final head ec7f2bd9 restarted healthy with the same peer identity, 3/3 bindings, 18 graphs and 432 triples intact;
  • restart reached API readiness in seconds from persisted bindings; the genuinely cold three-CG run took about 5m26s and recorded RPC 429 failover without exhaustion;
  • store and sync-global schedulers recovered healthy with zero rejected work.

Review feedback closed

  • 11b87b893: removed permanent positive caching, preserved hash-shaped cleartext IDs, extracted resolver state, reused the canonical cache, and added Core-hosted plus negative-TTL coverage;
  • ec7f2bd9e: collapsed the generic scan framework into one concrete EVM loader and added fail-closed scan-budget coverage.

M1 gate status

This PR removes the observed cold selected-CG identity-resolution blocker and has a real-network cold Edge VM+SWM payload proof. It does not by itself claim the entire M1 release gate: the final release evidence must compose the full stack's on-demand, always-on, unselected, restart and Core-coverage cells without treating legacy synced metadata as payload completion.

Comment thread packages/chain/src/evm-adapter-context-graph.ts Outdated
Comment thread packages/agent/src/dkg-agent-cg-registry.ts Outdated
Comment thread packages/chain/src/evm-adapter-context-graph.ts
Comment thread packages/chain/src/evm-adapter-base.ts Outdated
Comment thread packages/agent/src/dkg-agent-cg-registry.ts
Comment thread packages/chain/test/context-graph-name-hash-reverse-resolution.unit.test.ts Outdated
Comment thread packages/chain/src/context-graph-name-hash-resolver.ts Outdated
Comment thread packages/chain/src/context-graph-name-hash-resolver.ts Outdated
Comment thread packages/chain/src/evm-adapter-base.ts
Comment thread packages/chain/src/mock-adapter.ts

/** Offline-development parity for the EVM exact name-hash reverse lookup. */
async resolveContextGraphIdByNameHash(nameHash: string): Promise<bigint | null> {
if (!ethers.isHexString(nameHash, 32)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Suggestion: Share the name-hash normalizer between EVM and mock adapters

Why it matters
The mock is meant to mirror the EVM adapter contract. Duplicating the boundary parsing in two places makes parity depend on matching strings and normalization behavior by convention rather than by construction.

Suggestion
Export a small normalizeContextGraphNameHash helper from the resolver module or a chain-level utility, and use it in both the resolver and MockChainAdapter. Keep the zero-hash opt-out handling either in the helper or in one clearly documented callsite.

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