[#870] Fix human wallet showing AI Writer badge after OWS linking#875
[#870] Fix human wallet showing AI Writer badge after OWS linking#875realproject7 merged 3 commits intomainfrom
Conversation
…adge Human ↔ OWS agent link is now DB-only via linked_agent_wallet column. ERC-8004 registration belongs on the OWS wallet (plotlink-ows side). LinkAIWriter no longer does on-chain registration — just verifies binding proof and saves the DB link. detectWriterType only checks agent_wallet, so human wallets never return writer_type=1. Profile page shows separate "Linked AI Writer" card for agent owners. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
realproject7
left a comment
There was a problem hiding this comment.
re2 Review — PR #875
Architecture: APPROVE — Moving the human ↔ OWS link to a DB-only column (linked_agent_wallet) and keeping ERC-8004 registration on the OWS side is a clean separation. The simplified LinkAIWriter component and detectWriterType fix are solid.
Security: REQUEST CHANGES — One issue needs addressing before merge:
1. /api/user/link-agent has no caller authentication
The endpoint verifies the OWS wallet's signature (proving the OWS wallet authorized the link), but it does not verify that the caller actually owns humanWallet. Anyone who intercepts or obtains the OWS binding signature can call this endpoint with an arbitrary humanWallet and link the OWS agent to a wallet they don't own.
Fix: Require proof of humanWallet ownership — either:
- Check an existing session/auth token that maps to
humanWallet, or - Require a second signature from
humanWalletitself (e.g.,verifyMessage({ address: humanWallet, ... }))
Since the LinkAIWriter component runs with a connected wallet, adding a useSignMessage step for the human wallet is straightforward.
Minor notes (non-blocking):
- Migration 00034 looks correct — Step 1 copies
agent_wallet→linked_agent_wallet, Step 2 clears agent fields. Both keyed onagent_type = 'ows-writer'which is still set when Step 2 runs. - The
getAgentOwnerProfilereverse lookup vialinked_agent_walletis a nice addition for showing "Operated by" on agent profiles. isAgentOwnerlogic correctly prioritizeshasLinkedAgentover the legacyagentMetapath.- Patch version bump to 0.1.25 ✓
Verdict: REQUEST CHANGES — fix the auth gap on link-agent, rest is good.
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: REQUEST CHANGES
Summary
The DB-only link direction is correct, but this patch introduces one behavioral regression in writer identity resolution and one authorization gap in the new link endpoint.
Findings
- [high]
getAgentOwnerProfile()now returns a non-null owner result for any wallet that appears inlinked_agent_wallet, even when that wallet has not been ERC-8004 registered. The new branch falls through withagentId: 0/agentName: "AI Writer"instead of returningnull, and both writer identity components treat any non-null result as a real agent. That will relabel unregistered linked wallets as AI writers in story/list surfaces, which contradicts the contract of this helper and the issue’s intended flow.- File:
lib/actions.ts:308 - Suggestion: Only take the reverse-lookup branch if
getAgentUserFromDB(writerAddress)returns a real agent row withagent_id; otherwise returnnullso unregistered linked wallets still render as humans/regular wallets.
- File:
- [high] The new
/api/user/link-agentroute trustshumanWalletfrom the request body and writes with the service-role client after checking only the OWS signature. That means anyone who controls an OWS wallet can sign a message for an arbitrary third-party human address and forcelinked_agent_walletonto that victim’s profile without proving control of the human wallet.- File:
src/app/api/user/link-agent/route.ts:15 - Suggestion: Bind the request to an authenticated session / connected wallet, or require a second proof from the human wallet before updating that row.
- File:
Decision
Requesting changes because both issues affect correctness: one mislabels non-agents as agents, and the other allows unauthorized linking of another user’s profile.
Addresses re2 review: require a second signature from the human wallet to prove ownership, preventing anyone with the OWS binding signature from linking to an arbitrary wallet. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Only return agent owner info via linked_agent_wallet when the OWS wallet actually has an agent_id in DB. Prevents showing "AI Writer #0" for wallets linked but not yet registered on-chain. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
realproject7
left a comment
There was a problem hiding this comment.
re2 Re-review — APPROVE
Both issues addressed cleanly:
-
Auth gap fixed:
link-agentnow requireshumanSignature— human wallet signs an ownership proof message, verified server-side viaverifyMessage.LinkAIWritercomponent usesuseSignMessageto produce it. ✓ -
Unregistered OWS guard (re1's finding):
getAgentOwnerProfilenow checksagentUser?.agent_idbefore returning the linked owner path. No more "AI Writer #0" for unregistered wallets. ✓
No new concerns. LGTM.
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Summary
The requested fixes are in place. The new link flow now proves control of both wallets, and the reverse lookup only treats linked OWS wallets as agents once they are actually registered.
Findings
- No remaining blocking findings in the areas previously raised.
Decision
Approving on code review. lint-and-typecheck and e2e were still pending when I re-reviewed, so merge should still wait for checks to finish green.
Summary
Fixes #870
linked_agent_walletcolumn on the human's user row replaces the old approach of settingagent_*fields on the human row. ERC-8004 registration now belongs on the OWS wallet (plotlink-ows side)./api/user/link-agentendpoint: Verifies binding proof (OWS wallet signature) and setslinked_agent_wallet— no on-chain tx required from the human.LinkAIWritercomponent: Simplified to verify + DB link only. Removed on-chain registration and wallet binding steps.detectWriterType: Only checksagent_walletcolumn, notprimary_address. Human wallets will never returnwriter_type=1.agent_type='ows-writer'rows getagent_walletmoved tolinked_agent_wallet, then agent fields cleared.Profile display (new)
Test plan
linked_agent_walletmigration runs clean on stagingdetectWriterTypereturns 0 for human wallets with linked agentsows-writerrows migrated correctly🤖 Generated with Claude Code