rc.17 fix: peerId-author create regression + by-name WM read-flip#1048
Closed
branarakic wants to merge 1 commit into
Closed
rc.17 fix: peerId-author create regression + by-name WM read-flip#1048branarakic wants to merge 1 commit into
branarakic wants to merge 1 commit into
Conversation
Two bugs in the rc.17 WM per-KA flip (#1047), each with a TDD regression test (written failing first, then fixed): 1. Default-agent (peerId) create regression (packages/agent/src/dkg-agent.ts). The D1 create wrapper built the `allocateKaNumber` callback whenever a `kaNumberAllocator` was wired, but `agentAddress` falls back to the libp2p peerId when no default agent is registered. The allocator validates the author via `ethers.getAddress`, so `allocate(peerId)` threw — regressing `agent.assertion.create()` from working to hard-failing on any node without a `defaultAgentAddress`. Fix: gate the callback on a valid 0x EVM author (mirrors the publisher's own self-allocation guard); peerId-author drafts fall back to the legacy name-keyed WM graph. Test: packages/agent/test/d1-peerid-author-create.test.ts. 2. By-name working-memory read goes empty for new assertions (packages/query/src/dkg-query-engine.ts). Writes land in the per-KA `…/_working_memory/{addr}/{number}` graph, but a `view: 'working-memory'` by-name read resolved to the legacy name-keyed graph unless `kaNumber` was supplied — and nothing populated it. Fix: resolve name→number from the `dkg:kaId` on the lifecycle URN in `_meta` (mirrors the publisher's `resolveKaNumber`) and pass it to `resolveViewGraphs`. Unallocated drafts keep the legacy fallback. Test: packages/query/test/query-extra.test.ts (Q-3). Verified: full query suite 261 passed; agent e2e-assertion-lifecycle 7/7, e2e-sub-graphs + wm-multi-agent-isolation-extra green; query + agent tsc clean. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
Subsumed into rc17-vm-wip (the rc.17 integration branch → main via #1053) — this work shipped as part of integrated rc.17. Closing as superseded. |
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.
Stacked on #1047 (
rc17-flip). Fixes the two🔴bot-flagged bugs in the rc.17 WM per-KA flip, each via TDD (failing test written first, then the fix).Bug 1 — default-agent (peerId) create regression
packages/agent/src/dkg-agent.ts. The D1 create wrapper built theallocateKaNumbercallback whenever akaNumberAllocatorwas wired, butagentAddressfalls back to the libp2p peerId when no default agent is registered. The allocator validates the author viaethers.getAddress, soallocate(peerId)threw — regressingagent.assertion.create()from working to hard-failing on any node without adefaultAgentAddress.Fix: gate the callback on a valid
0x…EVM author (mirrors the publisher's own self-allocation guard). peerId-author drafts fall back to the legacy name-keyed WM graph. No-op for EVM authors, so the existing hardhat e2e suites are unaffected by construction.Test:
packages/agent/test/d1-peerid-author-create.test.ts— aNoChainAdapternode (peerId author) with a wired allocator;create → write → queryround-trip. Confirmed red (KaNumberAllocator: invalid author address: 12D3Koo…) before the fix, green after.Bug 2 — by-name working-memory read goes empty for new assertions
packages/query/src/dkg-query-engine.ts. Writes land in the per-KA…/_working_memory/{addr}/{number}graph, but aview: 'working-memory'by-name read resolved to the legacy name-keyed graph unlesskaNumberwas supplied — and nothing on the query caller path populated it (the PR's own TODO).Fix: in
queryWithView, resolve name→number from thedkg:kaIdstamped on the lifecycle URN in_meta(mirrors the publisher'sresolveKaNumber) and pass it toresolveViewGraphs. Unallocated drafts keep the legacy fallback (the single-graph, no-sibling-leak guarantee is preserved).Test:
packages/query/test/query-extra.test.ts(Q-3) — seeds a numbered per-KA graph + the_metadkg:kaIdrow, asserts the by-name WM read returns the data. Confirmed red ([]) before the fix, green after.Verification
e2e-assertion-lifecycle7/7,e2e-sub-graphs+wm-multi-agent-isolation-extragreen.tscclean forquery+agent.Test plan
rc17-flip) and pass with the fixes.Made with Cursor