feat(agent): reconcile selected public VM from chain truth - #2184
Conversation
…ix' into codex/vm-metadata-provenance-repair # Conflicts: # packages/agent/src/dkg-agent-swm-host.ts # packages/agent/test/vm-reconcile-self-prime.test.ts
…om/OriginTrail/dkg into codex/vm-metadata-provenance-repair
…om/OriginTrail/dkg into codex/vm-metadata-provenance-repair # Conflicts: # packages/agent/test/context-graph-historical-name-binding.test.ts
…tadata-provenance-repair
| } | ||
| }); | ||
|
|
||
| it('sweeps only operator-selected accepted RFC-64 public CGs without creating a subscription', async () => { |
There was a problem hiding this comment.
🟡 Issue: This PR pushes vm-reconcile-self-prime.test.ts past 1k lines with a separate feature suite
What's wrong
The file now mixes the original self-prime regression coverage with a large selected-only RFC-64 reconciliation suite. That makes the test file harder to scan and violates the project-health threshold for files crossing 1000 lines without a strong structural reason.
Example
The new tests cover a coherent feature area: selected-only RFC-64 sweep eligibility, target resolution, cursor persistence, revalidation, disabled reconciler behavior, and lifecycle cancellation. That suite can stand on its own without living inside the existing self-prime regression file.
Suggested direction
Decompose before merging. Put the selected-only RFC-64 reconciliation scenarios in their own test module and leave this file focused on the original self-prime behavior.
Confidence note
The prompt diff shows this PR adds the selected-only block, and the current file is 1054 lines; the local git base was not aligned with the supplied PR diff, so the exact pre-PR count comes from the provided diff size plus current line count.
For Agents
Split the selected-only RFC-64 VM reconciliation tests from packages/agent/test/vm-reconcile-self-prime.test.ts into a focused file such as vm-reconcile-rfc64-selected.test.ts. Move shared setup helpers if needed and keep the existing self-prime tests scoped to self-prime behavior.
Impact
Public VM inventory remains the chain. This PR does not introduce or require an RFC-64 VM catalog.
It makes two public-VM recovery paths complete and safe:
The selected-only path is intentionally separate from subscription state. It does not persist a synthetic subscription, install gossip handlers, trigger RS healing, or expand automatic SWM scope. It owns a dedicated durable cursor bound to the exact DKG deployment, local CG id, name hash, and numeric on-chain CG id. Restart resumes from that cursor, while a deployment or binding change resets it fail-closed.
Startup subscription rehydration also has an independent operator gate. Disabling it leaves persisted non-system subscription rows and RDF data intact but dormant, so stale historical subscriptions do not silently fan out background work. Explicit subscriptions after startup still work normally.
/api/status.syncLifecycle.syncReconcilerEnabledexposes the effective reconciler gate using the same resolver as runtime, including environment-variable precedence, so canary certification can prove configured versus honored behavior.Receiptless public finalization
Before
sequenceDiagram participant Chain participant Reconciler participant SWM participant VM Chain->>Reconciler: Finalized public KA inventory row Reconciler->>SWM: Verify exact assertion bytes SWM-->>Reconciler: Exact bytes but no transaction provenance Reconciler-->>VM: Defer indefinitelyAfter
sequenceDiagram participant Chain participant Reconciler participant SWM participant VM Chain->>Reconciler: Finalized public KA inventory row Reconciler->>Chain: Verify binding, policy, version, and root Reconciler->>SWM: Recompute exact assertion root and shape SWM-->>Reconciler: Exact chain-bound bytes Reconciler->>VM: Materialize finalized public assertion Reconciler->>VM: Persist receiptless chain-authenticated metadataBoth finalization entry points now use one
applyPublicFinalizedMaterializationhelper, so idempotence, metadata repair, and durable flush semantics cannot drift.Selected public VM reconciliation
Before
sequenceDiagram participant Config participant Agent participant SubscriptionStore participant Chain Config->>Agent: Select a public Context Graph Agent->>SubscriptionStore: Create synthetic selected-only subscription Agent->>Chain: Reconcile through subscription path Note over Agent,SubscriptionStore: Selection and subscription semantics are coupledAfter
sequenceDiagram participant Config participant Agent participant Chain participant CursorStore participant VM Config->>Agent: Select a public Context Graph Agent->>Chain: Resolve name hash to current numeric CG id Agent->>Chain: Enumerate finalized KA inventory Agent->>Chain: Revalidate binding before materialization Agent->>VM: Fetch, verify, and materialize exact public KA Agent->>CursorStore: Persist deployment-bound reconcile watermark Note over Agent,CursorStore: No subscription persistence or RS healStartup subscription rehydration
Before
sequenceDiagram participant Store as Persisted subscriptions participant Agent participant Network Store->>Agent: Load every historical non-system row Agent->>Network: Activate gossip and automatic sync scopeAfter
sequenceDiagram participant Config participant Store as Persisted subscriptions participant Agent participant Network Config->>Agent: Resolve rehydration gate Store->>Agent: Load persisted rows for accounting alt Rehydration enabled Agent->>Network: Activate rows up to configured cap else Rehydration disabled Agent-->>Store: Preserve rows and RDF data unchanged Note over Agent,Network: Rows remain dormant; no startup fan-out endSafety properties
syncReconcilerEnabled=falsegates startup sweep, periodic sweep, live registration, and selected reconciliation consistently.Validation
5fe837036:5fe837036is running.Stack and scope
testnet-canary.contextGraphSubscriptionRehydrationEnabledandDKG_CONTEXT_GRAPH_SUBSCRIPTION_REHYDRATION_ENABLED; the default remains enabled for compatibility.