feat(monetize): ServiceOffer type=dataset — CRD, catalog & x402 extras wiring (P1)#640
Open
bussyjd wants to merge 1 commit into
Open
feat(monetize): ServiceOffer type=dataset — CRD, catalog & x402 extras wiring (P1)#640bussyjd wants to merge 1 commit into
bussyjd wants to merge 1 commit into
Conversation
…s wiring
P1 of the decentralized fine-tuning plan: make a versioned dataset a
first-class type=dataset ServiceOffer so the existing
controller -> Middleware -> HTTPRoute -> ForwardAuth -> catalog pipeline
publishes and gates it with no new serving code. Declarations + pipeline
wiring + parity tests only; the dataset server/versionlog/download client
are later phases.
- CRD: dataset enum value; ServiceOfferDataset{manifestHash,version,
fileHash,sizeBytes} spec block (mirrors ServiceOfferAgent);
PriceTable.PerMB; IsDataset(); regenerated serviceoffer-crd.yaml + deepcopy.
- x402: RouteRule.Dataset* fields; routeRuleFromOffer dataset branch
(hex digests lowercased); effectivePrice perMB; mergeDatasetExtras()
adds accepts[].extra.dataset{...} to the 402, wired after mergeAgentExtras.
- catalog: schema type enum + perMB priceUnit + additive dataset* properties;
ServiceCatalogEntry.Dataset*; buildServiceCatalogJSON population; perMB in
offerPriceRawAndUnit + describeOfferPrice.
- dataset folds to the http render branch in normalizeOfferType (a download
is not chat-completions): generic 402 copy + bazaarGenericJSON, no bespoke
copy. Version metadata reaches buyers only via extra.dataset.
- parity tests across CRD fields/block, mergeDatasetExtras, route-rule,
catalog surface + omitempty, bazaar, fallbackOfferType, describeOfferPrice
(incl. perMB precedence), and the HTML 402 copy fold.
go build/vet, full go test ./..., and just generate (idempotent) all green.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
P1 —
ServiceOffertype=dataset(declarations + pipeline wiring)First slice of the decentralized fine-tuning plan: make a versioned dataset a first-class
type=datasetServiceOffer so the existing controller→Middleware→HTTPRoute→ForwardAuth→catalog pipeline publishes and gates it with no new serving code. This PR is declarations + pipeline glue + parity tests only — it deliberately does not build the dataset server, version log, or download client (later phases).What it adds
internal/monetizeapi/types.go)datasetadded tospec.typeenum; newServiceOfferDataset{manifestHash, version, fileHash, sizeBytes}spec block (mirrorsServiceOfferAgent);PriceTable.PerMB;IsDataset()helperinternal/x402)RouteRule.Dataset*fields;routeRuleFromOfferdataset branch (hashes lowercased);effectivePriceperMBcase;mergeDatasetExtras()addsaccepts[].extra.dataset{manifestHash,version,fileHash,sizeBytes}to the 402, wired aftermergeAgentExtrasinternal/schemas,render.go)datasetin the catalogtypeenum +perMBinpriceUnitenum + 3 additivedataset*properties;ServiceCatalogEntry.Dataset*fields; populated inbuildServiceCatalogJSON;perMBhandled inofferPriceRawAndUnit+describeOfferPriceserviceoffer-crd.yaml+zz_generated.deepcopy.goregenerated viajust generate(committed)Deliberately unchanged (parity with
http)normalizeOfferTypefoldsdataset→httprender branch (a download isn't chat-completions) → generic 402 copy +bazaarGenericJSON. No bespokedatasetCopy()/ chat schema. Dataset metadata reaches buyers only viaextra.dataset.obol sell datasetCLI, no server, no download/versionlog — those are P2/P3.Tests (matching the other types)
TestServiceOfferCRD_Fieldsextended (enum + spec fields) + newTestServiceOfferCRD_DatasetFields(dataset block schema +perMB)dataset_extras_test.go: noop / all-fields / nil-extra / omit-zero / additive-preservation (mirrorsagent_extras_test.go)TestRouteRuleFromOffer_DatasetAdvertisesDatasetMetadata(lowercasing +perMBprice + all 4 fields)TestBuildServiceCatalogJSON_DatasetOfferSurfacesVersion+…_NonDatasetOmitsDatasetFields(omitempty)TestBuildBazaarExtensiondataset case;TestFallbackOfferTypedataset case;TestDescribeOfferPriceperMB(USDC + OBOL)TestHTMLAware_DatasetUsesGenericHTTPCopy(pins the http-fold)Status
just generateclean (no drift),go build ./...clean,go vetclean, fullgo test ./...green. Net diff: 15 files, +415/−11 (~190 LOC production, rest tests + generated).