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

drafts

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package drafts turns malformed order-draft JSON (for example model output wrapped in code fences or using single quotes) into a strictly validated, reviewable candidate. It performs no networking, signing or persistence. A candidate is not an intent: it must still go through `orders prepare`, which produces the digest a submission is bound to.

Repair is syntax only. It is never applied to backend responses, signed actions, MCP frames, credentials, journal records or migration input.

Index

Constants

View Source
const (
	MaxBytes = 16 << 10
	MaxDepth = 4
)

Limits on draft input.

Variables

This section is empty.

Functions

This section is empty.

Types

type Candidate

type Candidate struct {
	Repaired bool   `json:"repaired"`
	JSON     string `json:"json"`
	Order    Order  `json:"order"`
	// PrepareArgs is the equivalent `oku orders prepare` argument list. It is
	// informational; nothing is prepared.
	PrepareArgs []string       `json:"prepare_args"`
	Input       map[string]any `json:"input"`
}

Candidate is the review result.

func Repair

func Repair(r io.Reader) (*Candidate, error)

Repair reads at most MaxBytes of UTF-8 from r and returns a validated candidate or an error explaining why the draft is refused.

type Dec

type Dec string

Dec is a decimal taken verbatim from a JSON string or number literal, never through float64.

func (*Dec) UnmarshalJSON

func (d *Dec) UnmarshalJSON(b []byte) error

UnmarshalJSON accepts "1.5" or 1.5 and keeps the exact text.

type Order

type Order struct {
	Market      string `json:"market"`
	Side        string `json:"side"`
	Type        string `json:"type"`
	Size        Dec    `json:"size"`
	Price       Dec    `json:"price,omitempty"`
	TIF         string `json:"tif,omitempty"`
	SlippageBps int    `json:"slippage_bps,omitempty"`
	ReduceOnly  bool   `json:"reduce_only,omitempty"`
}

Order is the strict order-draft schema. Financial values are strings so no float conversion ever happens.

Jump to

Keyboard shortcuts

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