conformance

package
v0.0.0-...-09262ef Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 23 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 conformance checks that a server offers the Open Workout API core and MCP profile.

Run checks the REST API by running a fixed script against it as one person: log a workout, read it back equal, replay the Idempotency-Key and the external ID, change it, find it in the change feed, export the log and validate every workout in it, delete it, find its tombstone, check a deleted external ID stays deleted, and subscribe a webhook and remove it. RunMCP checks an MCP server against the tool profile (mcp.go), and CheckVectors checks an implementation of the progression rules against the published cases (vectors.go). VerifySignature checks a webhook delivery's OWS-Signature.

The script writes one workout to the account and deletes it at the end, also when a check fails part way. Use a test account: the token needs workouts:read and workouts:write, for a person who has given whatever consent the server asks before it stores health data.

"Conformant" is self-reported: a server that passes may say so. The reference implementation is Lifterclub (https://lifterclub.com/developers), whose CI runs this suite.

Index

Constants

View Source
const SignatureHeader = "OWS-Signature"

SignatureHeader is the header a webhook delivery is signed in.

Variables

View Source
var Checks = []string{
	"discovery", "create", "read", "replay", "external-id", "update", "change-feed", "export", "delete", "tombstone",
	"stays-deleted", "webhooks", "document",
}

Checks are the script's steps, in the order they run.

View Source
var MCPChecks = []string{
	"discovery", "tools", "log", "replay", "needs-confirmation", "read", "errors", "read-only", "delete",
}

MCPChecks are the MCP script's steps, in the order they run.

Functions

func Sign

func Sign(secret string, t time.Time, body []byte) string

Sign computes a delivery's OWS-Signature: "t=<unix seconds>,v1=<hex HMAC-SHA256>", the HMAC keyed with the subscription's secret over "<t>.<body>".

func VerifySignature

func VerifySignature(secret, header string, body []byte, now time.Time, tolerance time.Duration) error

VerifySignature checks a webhook delivery as a receiver should: the OWS-Signature header's v1 is the HMAC of the body sent at its t, compared in constant time, and t is within tolerance of now, so a captured delivery can't be replayed later.

Types

type Config

type Config struct {
	// BaseURL is the API's origin, such as https://api.lifterclub.com. Routes are under /v1.
	BaseURL string
	// Token is an OAuth access token with workouts:read and workouts:write.
	Token string
	// HTTPClient sends the requests; http.DefaultClient when nil.
	HTTPClient *http.Client
	// Now is the clock the workout's start time comes from; time.Now when nil.
	Now func() time.Time
}

Config says where to run the script and as whom.

type MCPConfig

type MCPConfig struct {
	// URL is the Streamable HTTP endpoint, such as https://mcp.lifterclub.com.
	URL string
	// Token is a person's credential an assistant would use, able to log workouts.
	Token string
	// ReadOnlyToken is a read-only credential for the same person. Without one, read-only is
	// skipped and the server can't pass.
	ReadOnlyToken string
	// HTTPClient sends the requests; http.DefaultClient when nil.
	HTTPClient *http.Client
}

MCPConfig says which MCP server to check and as whom.

type MCPReport

type MCPReport struct {
	URL     string   `json:"url"`
	Results []Result `json:"results"`
}

MCPReport is every MCP check's outcome, in order.

func RunMCP

func RunMCP(ctx context.Context, cfg MCPConfig) (MCPReport, error)

RunMCP checks an MCP server against the profile's core (mcp/tools.json) as one person: it answers 401 with discovery, lists every core tool with the profile's input schema and annotations, logs a workout with an exercise no catalogue knows (which must come back in needs_confirmation), replays the idempotency_key, reads the workout back, returns tool errors that start with a profile code, keeps a read-only credential to read-only tools, and deletes the workout. The workout is deleted at the end, also when a check fails part way.

func (MCPReport) Passed

func (r MCPReport) Passed() bool

Passed reports whether every check passed.

type Report

type Report struct {
	BaseURL string   `json:"base_url"`
	Results []Result `json:"results"`
}

Report is every check's outcome, in order.

func Run

func Run(ctx context.Context, cfg Config) (Report, error)

Run runs every check in order and reports each one. The error is for a run that couldn't start (a bad base URL, no token); a failing server is a report with failures, not an error.

func (Report) Passed

func (r Report) Passed() bool

Passed reports whether every check passed.

type Result

type Result struct {
	Name   string `json:"name"`
	Status Status `json:"status"`
	// Detail says what was wrong, or why the check was skipped.
	Detail string `json:"detail,omitempty"`
}

Result is one check's outcome.

type SignatureVector

type SignatureVector struct {
	Name      string `json:"name"`
	Secret    string `json:"secret"`
	Timestamp int64  `json:"timestamp"`
	Body      string `json:"body"`
	Signature string `json:"signature"`
}

SignatureVector is one published webhook signature case (schema/v0/webhook-signature-vectors.json).

func SignatureVectors

func SignatureVectors() ([]SignatureVector, error)

SignatureVectors reads the published webhook signature cases, for a sender's own tests: sign each body at its timestamp and compare with Signature.

type Status

type Status string

Status is a check's outcome.

const (
	Pass Status = "pass"
	Fail Status = "fail"
	// Skip is a check that couldn't run because one it depends on failed.
	Skip Status = "skip"
)

type VectorCase

type VectorCase struct {
	Name  string
	Input json.RawMessage
	Want  VectorTarget
}

VectorCase is one published case (schema/v0/progression-vectors.json). Input is the case as an implementation receives it: everything but want.

func ProgressionVectors

func ProgressionVectors() ([]VectorCase, error)

ProgressionVectors reads the published cases.

type VectorReport

type VectorReport struct {
	Results []Result `json:"results"`
}

VectorReport is every case's outcome, in order.

func CheckVectors

func CheckVectors(ctx context.Context, compute func(ctx context.Context, input json.RawMessage) (VectorTarget, error)) (VectorReport, error)

CheckVectors runs every published case through compute, an implementation of the progression rules, and compares what it works out with the case's want. A server's own tests can call it with their evaluator; ows vectors calls it with a command (the runner contract).

func (VectorReport) Passed

func (r VectorReport) Passed() bool

Passed reports whether every case passed.

type VectorTarget

type VectorTarget struct {
	Load       *float64        `json:"load"`
	Loads      []float64       `json:"loads,omitempty"`
	Sets       json.RawMessage `json:"sets,omitempty"`
	Exercise   string          `json:"exercise,omitempty"`
	NeedsStart bool            `json:"needs_start"`
}

VectorTarget is what an implementation of the progression rules works out for a case: the runner contract's output. Load is the next weight in the case's unit, or null for none; Loads is each set group's weight when the slot's groups carry their own percentage; Sets is the set scheme to do next, for a stages rule; Exercise is the exercise to do next, for a variations rule; NeedsStart says a starting number is missing. Explanations aren't part of it.

Jump to

Keyboard shortcuts

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