Repository navigation
Filter hardware offers and add bounded marketplace pages #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
NetworkTheoryAppliedResearchInstitute
merged 8 commits into
NTARI-RAND:main
from
nirmalhk7:nirmal/cloudy-market-offers
Nov 9, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4c94728
Filter hardware offers and add bounded marketplace pages
nirmalhk7 f8628c9
test: pin marketplace summary field names
nirmalhk7 9120726
test: reject repeated well-formed marketplace maker keys
nirmalhk7 7572845
test: require marketplace page continuation tokens
nirmalhk7 b7c41cd
docs: show a valid exhausted marketplace page
nirmalhk7 61e45e9
docs: clarify marketplace maker identity scope
nirmalhk7 9f355af
fix: reject marketplace cursors from previous instances
nirmalhk7 c7b0a7f
refactor: share category browsing traversal
nirmalhk7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| # Browsing hardware offers | ||
|
|
||
| `GET /api/v1/market/listings` is public and returns structural listing summaries | ||
| in catalogue append order. Browsing neither records an exchange nor authorizes | ||
| settlement. Maker keys are the existing platform member keys; the API adds no | ||
| producer/consumer identity split, paid placement, reputation score or ranking. | ||
|
|
||
| ## Filters | ||
|
|
||
| | Parameter | Meaning | | ||
| | --- | --- | | ||
| | `category` | Existing hardware category: `computer`, `mobile_phone`, `tablet`, `smart_tv`, `tv_streaming_stick`, or `nas_storage`. Omitted/empty retains the existing behavior: no matches. | | ||
| | `maker` | Optional exact 32-byte Ed25519 public key, encoded as 64 hex characters. Uppercase and lowercase hex denote the same key. An unknown well-formed key returns an empty list. | | ||
| | `rail` | Optional `fiat` or `member_credit`. Repeat the parameter to match **any** selected rail. Omit it to impose no rail restriction. | | ||
|
|
||
| Category, maker and the rail selection combine with AND. For example: | ||
|
|
||
| ```text | ||
| /api/v1/market/listings?category=computer&rail=fiat&rail=member_credit&limit=10 | ||
| ``` | ||
|
|
||
| This returns computer offers accepting fiat, member credit, or both. Selecting | ||
| only `rail=member_credit` matches credit-only and dual-rail offers. These flags | ||
| describe the maker's signed acceptance, not the platform's current settlement | ||
| capabilities. Credit remains blocked while the economy is in escrow mode. Fiat | ||
| and credit remain separate, nonconvertible rails; no purchase or redemption of | ||
| member credit is added. | ||
|
|
||
| ## Opt-in pagination | ||
|
|
||
| Supplying `limit` or `cursor` enables paged reads. `limit` must be 1–100; it | ||
| defaults to 50 when only `cursor` is supplied. Start at `cursor=0` or omit the | ||
| cursor on the first limited request. | ||
|
|
||
| An exhausted page can contain an empty array and has no continuation token: | ||
|
|
||
| ```json | ||
| {"listings": []} | ||
| ``` | ||
|
|
||
| `listings` contains the same summary fields as before. When more matching | ||
| offers exist, `next_cursor` contains the running instance's log ID and a decimal | ||
| append position, separated by `:` (for example, `<64-hex-log-id>:125`). It points | ||
| after the last returned listing in the catalogue log. Follow it with the same category, maker, rail | ||
| selection and page limit. Treat it as a continuation token, not a result count: | ||
| sales and nonmatching listings also occupy log positions. Exhausted pages omit | ||
| `next_cursor`; `listings` is always an array, including for empty results. | ||
|
|
||
| Append positions stay stable as offers and sales are appended. Pagination is | ||
| live, not a frozen snapshot: later requests may include new offers and updated | ||
| sales counts. A cursor equal to the current log length returns an empty page; | ||
| a cursor beyond the current log length is invalid. Cursors are local to this | ||
| in-memory catalogue instance, not portable durable bookmarks. Tokens from another | ||
| instance or a previous run return HTTP 400, even when their position would fit | ||
| the current log. After a restart, start a fresh traversal with `cursor=0` or omit | ||
| the cursor on a limited request. Bare decimal continuations other than the | ||
| bootstrap value `0` are rejected. Changing filters also starts a fresh traversal. | ||
|
|
||
| Each request snapshots its summaries under the existing server lock and writes | ||
| the response after unlocking. Bounded reads allocate for the page, without | ||
| copying the complete log, full category results or sales histories. Sparse | ||
| filters may still scan all remaining log entries; this is not an indexed search | ||
| or a bound on scan CPU time. Legacy requests with neither pagination parameter | ||
| remain unbounded and preserve the `{"listings": [...]}` response shape. | ||
|
|
||
| ## Invalid input and compatibility | ||
|
|
||
| Malformed URL query encoding, invalid nonempty categories, malformed/empty maker | ||
| keys, unknown/empty rails, and repeated singleton parameters (`category`, | ||
| `maker`, `limit`, `cursor`) return HTTP 400. Rails may repeat; duplicates do not | ||
| duplicate offers. Comma-separated rail values are not supported. Limits and cursor | ||
| positions must contain only ASCII decimal digits and fit a nonnegative Go `int`; signs, | ||
| whitespace, fractions, suffixes and overflow fail. Empty bounds fail rather than | ||
| silently becoming defaults. Unknown unrelated query parameters remain ignored. | ||
|
|
||
| Valid existing category-only requests retain their fields, append ordering and | ||
| empty-category behavior. Invalid categories now receive 400 rather than looking | ||
| like a successful empty result. No signed listing, domain tag, protocol message, | ||
| storage format, public-read authorization or governance policy changes. | ||
|
|
||
| ## Verification | ||
|
|
||
| ```sh | ||
| go test ./internal/consumerapi -run '^TestMarketplaceBrowse' -count=1 | ||
| go test -race ./... | ||
| go vet ./... | ||
| go build ./... | ||
| go test ./internal/consumerapi -run '^$' -bench '^BenchmarkMarketplaceBrowse$' -benchmem | ||
| ``` | ||
|
|
||
| HTTP tests use real signed registration, product-spec claims, listing creation | ||
| and the catalogue. They check filter conjunction and rail OR semantics, dual-rail | ||
| offers, unknown keys, exact summary fields, sale-interleaved append cursors, | ||
| continuation after appends, rejection after a server restart, malformed instance | ||
| tokens, malformed requests, page limits and legacy behavior. | ||
| The benchmark uses a ten-offer page against 100 and 1,000 stored offers. It | ||
| measures local request allocations and time, not a production capacity guarantee. |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional:
TestMarketplaceBrowseSummaryFieldsandTestMarketplaceBrowseRejectsMalformedInstanceCursoralso bind behavior this section describes, so they're worth listing here too.