Help us shape the future of Go! Take the 2026 Go Developer Survey

orbitrecord

package
v3.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package orbitrecord is the committed record of what GitLab.com's Orbit routes answer, and the one reader of it.

It exists because the six Orbit actions were outside every oracle the 1:1 audit reads. The live API record (cmd/internal/apilive) is taken from a booted self-managed GitLab, and no self-managed instance serves Orbit; the routes it does list carry no response entity, because ee/lib/api/orbit/data.rb presents hashes that ee/lib/analytics/knowledge_graph/grpc_client.rb builds by hand from gRPC messages. GitLab's generated OpenAPI document gives no 200 schema for them either. A recorded answer is therefore the only oracle that covers every Orbit output type, and this is that recording, reduced to what a comparison needs and nothing a reader could mistake for data.

What it keeps is a key tree per recorded call: every path a response carried, each with the JSON kinds seen there, and never a value. A subtree whose keys are chosen by data rather than by GitLab's code (a JSON Schema document, the rows a query asked for by column) is kept only as its root, marked verbatim, because the server passes it through as it came and its keys are not a response shape. Each call also names the canonical action that made it, the Go type that action returned, and the query and body parameter names the handler sent, which is what lets the audit join a recorded answer to an output type without inferring anything: the join is the handler the generator called.

Its source names, beside the instance, the Orbit version, the fixture namespace and the day, the query grammar GitLab.com published when the record was taken: a digest of the GQL grammar and input schema orbit.dsl returns (GrammarStamp). That is the one part of the provenance Diff compares, because it is the language orbit.query teaches a model, and a grammar published differently is a change somebody has to read that guidance against (issue 1031). Until issue 1414 the record pinned the JSON query DSL by its $id and version instead; GitLab.com stopped reading that language on 2026-10-15, and Problems refuses a record that still pins it.

cmd/gen_orbit_record writes it from a run against GitLab.com, which needs a token and the network and so can never gate; its -check reads the committed file with neither, holds it to Problems and to its own canonical form, and cmd/audit_1to1's R-PATH scope compares the Orbit output types against it. The retrieval date is held to the window github.com/jmrplens/gitlab-mcp-server/v3/cmd/internal/provenance records for every pinned truth.

Index

Constants

View Source
const (
	KindObject  = "object"
	KindArray   = "array"
	KindString  = "string"
	KindNumber  = "number"
	KindBoolean = "boolean"
	KindNull    = "null"
	KindText    = "text"
)

The kinds a key can be recorded with: the six JSON kinds, and Text for a body that is not JSON at all, which is what the llm answer to a query is.

View Source
const (
	StatusAction      = "orbit.status"
	SchemaAction      = "orbit.schema"
	ToolsAction       = "orbit.tools"
	DSLAction         = "orbit.dsl"
	QueryAction       = "orbit.query"
	GraphStatusAction = "orbit.graph_status"
)

The six Orbit actions a record holds calls of, spelled once here and read by the generator that makes the calls, since most of them are called once per response format.

View Source
const DefaultDir = "docs/development"

DefaultDir is where the record lives, beside the other pinned records.

View Source
const Element = "[]"

Element is the segment suffix for the elements of an array: the elements of the array at "domains" are at "domains[]", and a bare array body's at "[]".

View Source
const FileName = "orbit-responses.json"

FileName is the record's name on disk.

View Source
const GraphQLPath = "/api/graphql"

GraphQLPath is the path a call to GitLab's GraphQL endpoint is recorded under. Every other call is recorded below /api/v4, which is where the Orbit REST and MCP routes are.

View Source
const Instance = "https://gitlab.com"

Instance is the one GitLab that serves Orbit, and so the one a record may be taken from.

View Source
const Root = "$"

Root is the path of the response body itself.

View Source
const SchemaVersion = 4

SchemaVersion is the shape of this record. A reader refuses a version it was not written for rather than guessing at a field that moved. Version 2 added the query DSL the record was taken against to its source, by the JSON DSL's $id and version. Version 3 replaced them with the GQL grammar (Source.QueryGrammar), since GitLab.com reads every query as GQL from 2026-10-15 and answers 404 where it served the JSON DSL, and its query calls are written in GQL, the gql table of a query among them (issue 1414). A record that still pins the JSON DSL is therefore refused by its version, and one of version 3 that carries the old keys anyway is not in the form Encode writes, which the generator's -check refuses. Version 4 records the calls GitLab.com answers since it removed five of the six Orbit REST routes on 2026-10-27 and -28: a call may be sent to GitLab's GraphQL endpoint (GraphQLPath) or to the Orbit MCP endpoint, so a request names the operation it asked (Request.Operation) and its arguments, and a response says where in the body its key tree is taken from (Response.Root). The status and indexing calls lost their llm variants with the routes, since GraphQL has one shape.

Variables

This section is empty.

Functions

func Child

func Child(parent, key string) string

Child is the path of a key under parent.

func Diff

func Diff(before, after Document) []string

Diff lists what changed between two records, one line per change, sorted: a call added or dropped, a key added or dropped, a key's kinds changed, a key that became or stopped being verbatim, and the query grammar the record was taken against. The rest of the provenance and the request names are not compared, since a new day or Orbit version is what every recording brings and is not a change to the shape. The grammar is the exception because it is what orbit.query teaches a model: a grammar GitLab publishes differently is a language that guidance has not been read against yet (issues 1031 and 1414).

func ElementOf

func ElementOf(parent string) string

ElementOf is the path of the elements of the array at parent.

func Elided

func Elided(path string) string

Elided is a path with its element markers removed, which is how a Go field path reads: "system.components[].name" is "system.components.name", and the elements of a bare array body are the body.

func Encode

func Encode(doc Document) []byte

Encode renders a record in its canonical form: calls sorted by action and variant, keys by path, kinds and parameter names alphabetically, indented so a re-recording is a readable diff. A committed record that is not in this form was edited by hand or written by another build, which is what the generator's -check holds it to.

func GrammarStamp added in v3.3.0

func GrammarStamp(description string, parameters any) string

GrammarStamp is how a record names the query language GitLab.com published: "sha256:" and the hex SHA-256 of the query command's description, a zero byte, and the JSON encoding of the JSON Schema of its input, whose object keys encoding/json writes sorted, so the same grammar stamps the same however it was decoded. A command with no description describes no language and stamps nothing, which Problems refuses.

func Parent

func Parent(path string) string

Parent is the path one level up, the root for a top-level key.

func Path

func Path(dir string) string

Path is where the record lives under a directory.

func Problems

func Problems(doc Document, now time.Time) []string

Problems reports every way a record fails to be a whole, current and value-free recording of the expected calls. It judges the document as decoded; whether the file is in canonical form is the caller's question, since only the caller holds the bytes.

func SortKeys

func SortKeys(keys []Key)

SortKeys orders keys by path, the root before every other path, which is where a reader looks for what the body was.

func ValidKey

func ValidKey(key string) bool

ValidKey reports whether an object key of an answer is a key name.

func ValidSegment

func ValidSegment(segment string) bool

ValidSegment reports whether one segment of a path is one of the shapes segmentPattern allows.

Types

type Call

type Call struct {
	// Action is the canonical action ID whose handler made the call.
	Action string `json:"action"`
	// Variant tells two calls of one action apart: the response format it
	// asked for, what else it asked (an expanded node), or "default" for a
	// route that takes no parameter and so has one answer.
	Variant string `json:"variant"`
	// Output is the Go type the handler returned, repository relative
	// (internal/tools/orbit.StatusOutput). It is what the audit judges
	// against the keys below.
	Output string `json:"output"`
	// RetrievedAt is the day the call was answered when it is not the
	// record's own: a call carried from an earlier recording because GitLab
	// refused the account on the day of this one, while the request the
	// handler builds was still the one that recording made. Empty for a call
	// made on [Source.RetrievedAt].
	RetrievedAt string   `json:"retrieved_at,omitempty"`
	Request     Request  `json:"request"`
	Response    Response `json:"response"`
}

Call is one handler invocation and what GitLab answered it with.

func (Call) ID

func (c Call) ID() CallID

ID is the call's identity in the record.

func (Call) SameRequest added in v3.4.0

func (c Call) SameRequest(other Call) bool

SameRequest reports whether two calls sent the same request, by every name the record keeps of one, which is what carrying an answer from an earlier recording rests on.

type CallID

type CallID struct {
	Action  string
	Variant string
}

CallID names one recorded call.

func ExpectedCalls

func ExpectedCalls() []CallID

ExpectedCalls is every call a whole record holds, in the order the generator makes them. The status call comes first because it carries the version the record is stamped with. The status and the indexing status have one call each since GitLab answers both through GraphQL, which has no llm rendering: "default" for the status, which takes no argument, and "full_path" for the indexing status, asked by the fixture namespace's path.

func (CallID) String

func (id CallID) String() string

String renders the ID the way the report and the diff spell a call.

type Document

type Document struct {
	SchemaVersion int    `json:"schema_version"`
	Note          string `json:"note"`
	Source        Source `json:"source"`
	// Calls are the recorded calls, sorted by action and variant.
	Calls []Call `json:"calls"`
	// Unrecorded are the expected calls the recording could not make and had
	// no earlier answer to carry for, each with the reason, sorted by action
	// and variant. A recording leaves a call here only when it was told GitLab
	// might refuse the account (gen_orbit_record -allow-unanswered) and GitLab
	// refused it or answered it with null.
	Unrecorded []Unrecorded `json:"unrecorded,omitempty"`
}

Document is the committed record.

func Canonical

func Canonical(doc Document) Document

Canonical returns a copy of doc with every list in its sorted order. The input is left as it was.

func Decode

func Decode(raw []byte) (Document, error)

Decode reads a record from its bytes, wherever they came from: the file on disk, or the version a commit holds.

A schema version this build was not written for is refused rather than decoded, for the reason SchemaVersion gives.

func DecodeCarried added in v3.4.0

func DecodeCarried(raw []byte) (Document, error)

DecodeCarried reads a record whose calls a new recording may carry: one of this version, or of a version whose calls this one reads unchanged. It is how a recording made while GitLab refuses the account keeps the answers an earlier one got to the same requests (see Call.RetrievedAt); everything else reads a record through Decode.

func Read

func Read(dir string) (Document, error)

Read loads the record on disk under dir, through Decode.

type Key

type Key struct {
	Path  string   `json:"path"`
	Kinds []string `json:"kinds"`
	// Verbatim marks a subtree recorded as its root only, because its keys
	// are data rather than a response shape. Nothing below it is recorded.
	Verbatim bool `json:"verbatim,omitempty"`
}

Key is one path of a response body and the kinds seen there.

type Request

type Request struct {
	Method string `json:"method"`
	// Path is the route below /api/v4, or [GraphQLPath].
	Path string `json:"path"`
	// Query are the query parameter names the handler sent, sorted.
	Query []string `json:"query,omitempty"`
	// Body are the top-level names of the JSON body the handler sent, sorted.
	Body []string `json:"body,omitempty"`
	// Operation is what the request asked of an endpoint that serves more than
	// one thing at one route: a GraphQL document's type and name ("query
	// OrbitServiceStatus"), or an MCP request's method and the tool it calls
	// ("tools/call list_commands"). Empty for a REST route.
	Operation string `json:"operation,omitempty"`
	// Arguments are the names of what the operation was asked with, sorted:
	// a GraphQL document's variables, or the MCP tool's arguments.
	Arguments []string `json:"arguments,omitempty"`
}

Request is what the handler sent, by name only.

type Response

type Response struct {
	Status int `json:"status"`
	// ContentType is the media type without its parameters.
	ContentType string `json:"content_type"`
	// Root is where in the body the key tree is taken from: a path below a
	// GraphQL answer's data ("data.orbit.serviceStatus"), whose connections are
	// recorded as the lists they page, the JSON-RPC result of an MCP answer
	// ("result"), or the text of an MCP tool result ("result.content[].text"),
	// decoded when it is JSON. Empty for the whole body, which is a REST
	// route's.
	Root string `json:"root,omitempty"`
	// RootContentType is the media type of what the root holds when it is not
	// the whole body: application/json, or text/plain for an MCP tool's text
	// that is not JSON.
	RootContentType string `json:"root_content_type,omitempty"`
	// Keys is every path the body carried, sorted, the body itself first.
	Keys []Key `json:"keys"`
}

Response is what GitLab answered, reduced to its key tree.

type Source

type Source struct {
	// Instance is the GitLab the calls were made against.
	Instance string `json:"instance"`
	// OrbitVersion is the Knowledge Graph service version GitLab.com
	// reported in the status call, which is what moves between two
	// recordings far more often than GitLab's own release does.
	OrbitVersion string `json:"orbit_version"`
	// QueryGrammar names the query language GitLab.com published beside the
	// answers (orbit.dsl, raw): the description of the query_graph command,
	// which is the GQL grammar, and the JSON Schema of its input, as
	// [GrammarStamp] writes them. GQL carries no version of its own the way
	// the JSON DSL's $id and version field did, so the stamp is a digest of
	// what GitLab says the language is, which moves whenever GitLab says it
	// differently. It is the drift alarm issue 1031 asked for: [Diff] reports
	// it changing, so a recording fails until somebody has read orbit.query's
	// guidance against the new language and committed the record.
	QueryGrammar string `json:"query_grammar"`
	// Namespace is the fixture namespace the indexing status and the query
	// were asked about (test/fixtures/orbit, docs/development/orbit-fixtures.md).
	Namespace string `json:"namespace"`
	// RetrievedAt is the day of the recording, YYYY-MM-DD.
	RetrievedAt string `json:"retrieved_at"`
}

Source is what the record was taken from and when.

type Unrecorded added in v3.4.0

type Unrecorded struct {
	Action  string `json:"action"`
	Variant string `json:"variant"`
	// Reason is what GitLab answered and when, in the words a reader needs to
	// tell whether a new recording can make the call.
	Reason string `json:"reason"`
}

Unrecorded is one expected call a recording could not make.

func (Unrecorded) ID added in v3.4.0

func (u Unrecorded) ID() CallID

ID is the unrecorded call's identity.

Jump to

Keyboard shortcuts

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