Skip to content

Store agentWallet at sweep time and make it searchable #18

Description

@NemboKid

Pasting an agent's payment wallet into search finds nothing, because no table stores agentWallet. Rung 1 evidence carries ownerOf, not getAgentWallet, and the value cannot be reconstructed from events (see analysis/payments-per-chain.md). PR #17's q_match_sql doc comment states the precondition plainly: "Matching it means a sweep-time getAgentWallet read into a real column first, not a scan of evidence JSONB here." This issue is that sweep-time read and column.

Migration 0013_minter_capture.sql is the model to copy: additive and nullable, where NULL means "this run predates capture" and never "the agent has no wallet". Note the spec's semantics (spec/ERC8004SPEC.md, getAgentWallet): the value defaults to the owner and is cleared to the zero address on transfer, so a read zero address is a real observation, distinct from a failed read (NULL).

Where to look

  • migrations/0013_minter_capture.sql — the pattern for an additive nullable snapshot column plus its partial (chain, …) index
  • crates/chain/src/registry.rs — no getAgentWallet binding exists yet; add the contract call, read at the run's pinned block
  • crates/sweeper/src/main.rs and crates/sweeper/src/store.rs — where snapshots are populated and persisted
  • crates/api/src/routes/agents.rsq_match_sql, the one definition of what q matches. PR API: cross-run search — q across explicit runs, grouped by chain #17 (branch journeys/cross-chain-search) moves this into a shared fragment used by both /api/agents and /api/search; the doc comment there explains why agentWallet is deliberately not matched today. Coordinate with API: cross-run search — q across explicit runs, grouped by chain #17 — the shared-fragment code refs land when it merges.
  • crates/checks/src/version.rs — the schema-version doc; a new snapshot column gets an entry, as schema 6 did

Done when

  • A migration adds nullable agent_snapshots.agent_wallet with a partial index on (chain, agent_wallet) WHERE agent_wallet IS NOT NULL (mirror idx_agent_snapshots_minter)
  • The sweeper populates it via getAgentWallet at the run's pinned block; a failed read leaves NULL, never a fabricated value; a read zero address is stored as read
  • q_match_sql gains a wallet-prefix arm (same shape as the owner-prefix match), so both endpoints that share the fragment match it identically
  • Pasting a known agent's wallet address into search returns that agent
  • crates/checks/src/version.rs documents the schema bump

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions