tapapi

package
v0.48.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tapapi defines the wire contract for complete TAP operations a Hub executes near the data, under /api/v1/tap/*.

A per-KEG route performs one KEG operation. A TAP operation is a whole client-facing workflow (a relationship lookup plus the fields its listing renders, a tag listing, a multi-KEG read) that would otherwise take several round trips. The Hub resolves every KEG a request names through its KEG authority boundary; nothing here grants access.

Rendering stays on the client: responses carry structured rows and resolved field values, never formatted lines.

Index

Constants

View Source
const (
	PathLinks     = "/tap/links"
	PathBacklinks = "/tap/backlinks"
	PathTags      = "/tap/tags"
	PathCat       = "/tap/cat"
	PathSearch    = "/tap/search"
)

Paths of the TAP operations, relative to the Hub's /api/v1 root.

View Source
const (
	SearchRouteHeader      = "Tapper-Search"
	SearchRouteHeaderValue = "ranked"
)

SearchRouteHeader is a response header the Hub's search route sets to SearchRouteHeaderValue on every response, success and error alike. It tells the route's own answers apart from a Hub without the route: such a Hub answers 404 or 405, often with the same NOT_FOUND envelope the route uses for an unreadable KEG, but never with this header.

View Source
const (
	SearchFieldTitle = "title"
	SearchFieldMeta  = "meta"
	SearchFieldBody  = "body"
)

Search hit fields name where a hit matched.

View Source
const (
	SearchSourceKeyword  = "keyword"
	SearchSourceSemantic = "semantic"
)

Search hit sources name the ranking signals that found a hit.

View Source
const (
	SearchModeKeyword = "keyword"
	SearchModeHybrid  = "hybrid"
)

Search modes report how a response was ranked. SearchModeKeyword means semantic ranking was not used: the Hub has no embedding model or degraded.

View Source
const SearchMaxKegs = 50

SearchMaxKegs is the most KEGs one SearchRequest may name. The Hub refuses a longer Kegs list with 400.

Variables

This section is empty.

Functions

This section is empty.

Types

type CatNode

type CatNode struct {
	Ref     string `json:"ref"`
	Content string `json:"content,omitempty"`
	Meta    string `json:"meta,omitempty"`
	Hash    string `json:"hash,omitempty"`
	Error   string `json:"error,omitempty"`
	Code    string `json:"code,omitempty"`
}

CatNode is one requested node, in request order. A node that cannot be read carries Error and Code instead of content, so one failure does not hide the rest of the batch.

type CatRequest

type CatRequest struct {
	Nodes []string `json:"nodes"`
	Touch bool     `json:"touch,omitempty"`
}

CatRequest reads nodes across any number of KEGs on this Hub in one call. Each reference is qualified, "keg:@namespace/alias/id". Touch records the read as an open.

type CatResponse

type CatResponse struct {
	Nodes []CatNode `json:"nodes"`
}

CatResponse returns the requested nodes in request order.

type RelatedRequest

type RelatedRequest struct {
	// Keg is the qualified KEG reference, "@namespace/alias".
	Keg     string   `json:"keg"`
	NodeIDs []string `json:"node_ids"`
	Fields  []string `json:"fields,omitempty"`
	Offset  int      `json:"offset,omitempty"`
	Limit   int      `json:"limit,omitempty"`
}

RelatedRequest asks for a node set's links or backlinks in one KEG, paged and with the named field selectors resolved for every returned row.

type RelatedResponse

type RelatedResponse struct {
	Rows  []keg.ListViewRow `json:"rows"`
	Pairs []keg.RelatedPair `json:"pairs"`
	Total int               `json:"total"`
}

RelatedResponse is one page of related nodes. Pairs attributes every returned row to the input node that produced it; Total counts related nodes before paging.

type SearchHit added in v0.46.0

type SearchHit struct {
	// Ref is the qualified node reference, "keg:@namespace/alias/id".
	Ref string `json:"ref" jsonschema:"The node reference, keg:@namespace/keg/id."`
	// Keg is the qualified KEG reference, "@namespace/alias".
	Keg    string  `json:"keg" jsonschema:"The KEG, as @namespace/keg."`
	NodeID string  `json:"node_id" jsonschema:"The node's ID in its KEG."`
	Title  string  `json:"title" jsonschema:"The node's title."`
	Score  float64 `json:"score" jsonschema:"Relevance; hits arrive highest first."`
	// Fields lists where the node matched: SearchFieldTitle, SearchFieldMeta,
	// SearchFieldBody.
	Fields []string `json:"fields" jsonschema:"Where the node matched: title, meta, or body."`
	// Sources lists the signals that found the node: SearchSourceKeyword,
	// SearchSourceSemantic.
	Sources []string `json:"sources,omitempty" jsonschema:"The signals that found the node: keyword, semantic."`
	Snippet string   `json:"snippet,omitempty" jsonschema:"An excerpt around the match."`
	// Highlights are the matched ranges of Snippet.
	Highlights []Span `json:"highlights,omitempty" jsonschema:"The matched ranges of snippet."`
}

SearchHit is one ranked node. Hits arrive in a total order: Score descending, then Keg, then NodeID.

type SearchRequest added in v0.46.0

type SearchRequest struct {
	Query string `json:"query"`
	// Kegs are qualified references, "@namespace/alias".
	Kegs   []string `json:"kegs,omitempty"`
	Cursor string   `json:"cursor,omitempty"`
	Limit  int      `json:"limit,omitempty"`
}

SearchRequest asks for nodes ranked by relevance to Query across every KEG the caller may read on this Hub, narrowed to Kegs when it is non-empty: an empty Kegs means every readable KEG. A request carrying the orientation proof (keg.OrientationHeaderName) is governed: there an empty Kegs means every readable KEG in the proof's flight cover, which the Hub resolves itself, so a client never has to name a cover wider than SearchMaxKegs. The Hub resolves each KEG through its authority boundary; naming a KEG only narrows and never grants access.

Cursor continues a previous response's NextCursor; it is opaque and passed through unchanged. Limit 0 lets the Hub choose the page size. Defaults and clamping live only on the Hub.

type SearchResponse added in v0.46.0

type SearchResponse struct {
	Hits       []SearchHit     `json:"hits" jsonschema:"The page's hits, most relevant first."`
	NextCursor string          `json:"next_cursor,omitempty" jsonschema:"Pass as cursor, with the same query, for the next page; absent on the last page."`
	Terms      []TermExpansion `json:"terms,omitempty" jsonschema:"How the Hub interpreted each query term."`
	Mode       string          `json:"mode,omitempty" jsonschema:"How the page was ranked: keyword or hybrid."`
	Warnings   []string        `json:"warnings,omitempty" jsonschema:"Partial results or degraded ranking to know about."`
}

SearchResponse is one page of ranked hits. NextCursor is empty on the last page. Mode is SearchModeKeyword or SearchModeHybrid. Warnings report partial results the caller should know about.

type Span added in v0.46.0

type Span struct {
	Start int `json:"start" jsonschema:"First highlighted rune of the snippet."`
	End   int `json:"end" jsonschema:"Rune just past the highlight."`
}

Span is a highlighted range of a hit's Snippet in rune offsets: Start is inclusive and End exclusive.

type TagsRequest

type TagsRequest struct {
	Keg    string   `json:"keg"`
	Query  string   `json:"query,omitempty"`
	Fields []string `json:"fields,omitempty"`
	Offset int      `json:"offset,omitempty"`
	Limit  int      `json:"limit,omitempty"`
}

TagsRequest lists tags, or with a Query, the nodes it selects rendered as rows with the named fields resolved.

type TagsResponse

type TagsResponse struct {
	Tags  []string          `json:"tags,omitempty"`
	Rows  []keg.ListViewRow `json:"rows,omitempty"`
	Total int               `json:"total"`
}

TagsResponse carries Tags when the request had no query, otherwise Rows. Total counts before paging.

type TermExpansion added in v0.46.0

type TermExpansion struct {
	Term    string   `json:"term" jsonschema:"A term of the query."`
	Lexemes []string `json:"lexemes" jsonschema:"The lexemes searched for it."`
	Typo    bool     `json:"typo" jsonschema:"True when the lexemes came from typo expansion."`
}

TermExpansion reports how the Hub interpreted one query term: the lexemes it searched for, and whether they came from typo expansion.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL