Skip to content

[BRIDGE-13] A published intent cannot be read back: no way to fetch one by id, or to see the quotes it received #30

Description

@grantfox-oss

Context

The bazaar has six routes. Five of them write or aggregate; none of them lets you read a single negotiation.

  • POST /api/v1/bazaar/intent returns the row it just created — and that is the last time the publisher sees it.
  • POST /api/v1/bazaar/quote returns the quote to the agent that sent it. The intent's author never receives it.
  • GET /api/v1/bazaar/feed lists status = 'active' intents only. The moment an intent is accepted it becomes negotiating and drops out of the only readable surface in the API.

So an agent that paid $0.005 to publish an intent has no way to answer: who quoted me, at what rate, is that quote still valid, was my intent accepted, and against which secret_hash?

accept writes secret_hash and selected_quote_id to the row (routes/bazaar.ts), and nothing can read them back.

Why this matters

This is a marketplace between agents that cannot poll. Everything a counterparty needs in order to decide is written to the database and never exposed. valid_until on a quote is meaningless to the one party who should act on it, because that party cannot see the quote at all.

What to do

Add two read routes in apps/api/src/routes/bazaar.ts:

  1. GET /api/v1/bazaar/intent/:id — the intent, whatever its status. 404 when the id is unknown. Shape it with intentRowToObject() so it matches the feed exactly; do not invent a second shape for the same record.
  2. The quotes for an intent — either GET /api/v1/bazaar/intent/:id/quotes or GET /api/v1/bazaar/quotes?intent_id=…. Pick one, and say in the PR why. Each quote should carry enough for the caller to act: rate, from_agent, valid_until, and whether it is still valid right now.

Decide and state in the PR whether these are paid (requirePayment) or free. The feed costs 0.001; there is a defensible argument either way, but it should be a decision, not an accident.

Acceptance criteria

  • GET /api/v1/bazaar/intent/:id returns an intent whose status is negotiating — the case the feed cannot serve
  • An unknown id returns 404, distinguishable from an intent that exists
  • The quotes route returns the quotes for that intent, and expired ones are visibly distinct from valid ones
  • A quote belonging to a different intent never appears
  • The intent shape matches what GET /feed returns for the same record
  • Tests cover all of the above offline

Notes

getIntent(), getQuotesForIntent() and getQuote() already exist in apps/api/src/db/bazaar.ts — this needs no new SQL. apps/api/src/__tests__/bazaar.test.ts shows the offline setup: no network, no Postgres.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions