Class DataQueryClient
java.lang.Object
ai.badmonkey.agentspaces.connect.DataQueryClient
The agent side of
aspace:cap/data-query (ENTERPRISE §3): fetch data
by asset name and parameters, local-first. A live result under the same
canonical hash answers immediately and costs the source system nothing;
otherwise the client writes a query entry and awaits the connector's result.
The counters make the economics observable: cacheHits is money the
abstraction returned.-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionDataQueryClient(Space dataSpace, String requester) Creates a client that accepts a result from any admitted peer.DataQueryClient(Space dataSpace, String requester, Authorizer authorizer) Creates a client whose trust in a result is the fleet'sAuthorizer(TODO-EFG §4, TODO item 6): aDataResultcounts — for the cache check and for the awaited answer — only when its space-authenticated issuer's peer is permittedCONNECTOR_SERVEforresult.asset().DataQueryClient(Space dataSpace, String requester, Set<PeerId> trustedConnectors) Creates a client that consumes only results written by the named connector peers (ASF-009): a result forged by any other admitted peer is ignored, for both the cache check and the awaited answer. -
Method Summary
Modifier and TypeMethodDescriptionintFetches answered by a live space result, with no source execution.Fetches one asset query, pull-once.intFetches that wrote a query entry for a connector to execute.
-
Constructor Details
-
DataQueryClient
Creates a client that accepts a result from any admitted peer. Suitable for a fleet where every member is trusted to answer honestly; a fleet that is not should name its connectors viaDataQueryClient(Space, String, Set).- Parameters:
dataSpace- the space queries and results flow throughrequester- the asking agent's name, stamped into queries
-
DataQueryClient
Creates a client that consumes only results written by the named connector peers (ASF-009): a result forged by any other admitted peer is ignored, for both the cache check and the awaited answer. The trusted peers come from the connectors' signedAssetCards (card.issuer()), discovered through the group's discovery service.- Parameters:
dataSpace- the space queries and results flow throughrequester- the asking agent's name, stamped into queriestrustedConnectors- connector peers whose results to accept; empty accepts any peer's result
-
DataQueryClient
Creates a client whose trust in a result is the fleet'sAuthorizer(TODO-EFG §4, TODO item 6): aDataResultcounts — for the cache check and for the awaited answer — only when its space-authenticated issuer's peer is permittedCONNECTOR_SERVEforresult.asset(). Under the OIDC profiles that is the identity provider'saspace:connector-serve:<asset>scope; under the membership profiles it is admission plus anyconnector-servegrant. The trusted-set constructor remains for fleets that name their connectors directly.- Parameters:
dataSpace- the space queries and results flow throughrequester- the asking agent's name, stamped into queriesauthorizer- decidesCONNECTOR_SERVEper result issuer and asset
-
-
Method Details
-
fetch
public Optional<DataQueryClient.Fetched> fetch(String asset, Map<String, String> parameters, Duration timeout) Fetches one asset query, pull-once.- Parameters:
asset- the asset name from its cardparameters- the query parameterstimeout- how long to wait for a connector when the cache misses- Returns:
- the answer, or empty when no connector answered in time
-
cacheHits
public int cacheHits()Fetches answered by a live space result, with no source execution. -
queriesSent
public int queriesSent()Fetches that wrote a query entry for a connector to execute.
-