Skip to content

rc.17 fix: peerId-author create regression + by-name WM read-flip#1048

Closed
branarakic wants to merge 1 commit into
rc17-flipfrom
rc17-flip-wm-readfix
Closed

rc.17 fix: peerId-author create regression + by-name WM read-flip#1048
branarakic wants to merge 1 commit into
rc17-flipfrom
rc17-flip-wm-readfix

Conversation

@branarakic

Copy link
Copy Markdown
Contributor

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 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. 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 — a NoChainAdapter node (peerId author) with a wired allocator; create → write → query round-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 a view: 'working-memory' by-name read resolved to the legacy name-keyed graph unless kaNumber was supplied — and nothing on the query caller path populated it (the PR's own TODO).

Fix: in queryWithView, resolve name→number from the dkg:kaId stamped on the lifecycle URN in _meta (mirrors the publisher's resolveKaNumber) and pass it to resolveViewGraphs. 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 _meta dkg:kaId row, asserts the by-name WM read returns the data. Confirmed red ([]) before the fix, green after.

Verification

  • Full query suite: 261 passed.
  • Agent: e2e-assertion-lifecycle 7/7, e2e-sub-graphs + wm-multi-agent-isolation-extra green.
  • tsc clean for query + agent.

Test plan

  • New regression tests fail on the base (rc17-flip) and pass with the fixes.
  • No regression in the PR-touched agent suites.
  • CI green under the real harness.

Made with Cursor

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>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Codex review completed — no issues found.

@branarakic

Copy link
Copy Markdown
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.

@branarakic branarakic closed this Jun 9, 2026
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.

1 participant