wire

package
v1.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 8 Imported by: 0

Documentation

Overview

Package wire implements SPEC §2 (identity and canonical encoding), the §1 numeric limits, the §11 closed detail codes and the taskman-command-result/0 envelope of §3.3. It is standard-library only and has no knowledge of the journal or of any process; every other package builds on it.

The value model is deliberately tiny: taskman profiles use only strings, booleans, null, arrays and objects. JSON numbers are never legal (Count and Size are decimal strings, §2), so the parser refuses them outright.

Index

Constants

View Source
const (
	KiB = 1024
	MiB = 1024 * KiB
	GiB = 1024 * MiB

	MaxIdentifierBytes = 128
	MaxLabelBytes      = 64
	MaxLocalTokenBytes = 64
	MaxRequestIDBytes  = 64
	// MaxPathTextBytes bounds a PathText: the absolute filesystem path
	// recorded as head.primaryWorktree and manifest.primaryWorktree (§2,
	// B2 resolution). It is separate from the Identifier bound.
	MaxPathTextBytes = 4096

	MaxTitleBytes     = 512
	MaxBodyBytes      = 64 * KiB
	MaxCriterionBytes = 4 * KiB
	MaxProseBytes     = 64 * KiB

	MaxTicketFileBytes       = 128 * KiB
	MaxReleaseFileBytes      = 256 * KiB
	MaxMutationEnvelopeBytes = 256 * KiB
	MaxOutcomeBytes          = 64 * KiB

	MaxAcceptanceCriteria = 64
	MaxDependencies       = 64
	MaxRequirementRefs    = 64
	MaxResources          = 64
	MaxApprovals          = 64
	MaxTouchPaths         = 256
	MaxLabels             = 32
	MaxHolds              = 16
	MaxRequiredGates      = 32
	MaxCapabilities       = 32

	MaxTicketsPerQueue  = 10000
	MaxReleasesPerQueue = 1000
	MaxIntentTreeBytes  = 256 * MiB
	MaxQueueFileBytes   = 1 * MiB
	MaxPolicyFileBytes  = 256 * KiB
	MaxImportMapBytes   = 8 * MiB
	MaxImportMapEntries = 10000

	MaxReceiptFileBytes     = 1 * MiB
	MaxInlinePostEntryBytes = 64 * KiB
	MaxInlinePostEntries    = 8
	MaxAttemptRecordBytes   = 64 * KiB
	MaxJournalHeadBytes     = 4 * KiB
	MaxBarrierBytes         = 4 * KiB
	MaxCommandResultBytes   = 64 * KiB // excluding paginated items
	MaxListResultBytes      = 16 * MiB
	MaxReservationSetBytes  = 64 * MiB
	MaxEvidenceBlobBytes    = 64 * MiB
	MaxEvidenceStoreBytes   = 16 * GiB
	MaxImportPlanBytes      = 16 * MiB
	MaxArchiveBytes         = 64 * GiB
	MaxPinnedBytes          = 16 * MiB // largest pinned document (an import plan or plan)

	// Archive capacity (§1, §3.5; B4 resolution, unverified implementation
	// freeze). The journal saturates at 1,000,000 receipts, so a manifest
	// must carry more `files` entries than the ordinary 10,000 decoded-array
	// bound. These three numbers are independent hard aggregate budgets;
	// they are checked on input bytes, entry counts and decoded nodes before
	// any manifest is materialized, and no other document is parsed under
	// them (ParseWith is opt-in; Parse keeps MaxJSONArrayElements).
	//
	// MaxArchiveFiles bounds the `files` array of one taskman-archive/0
	// manifest and the number of files `archive export` will emit.
	MaxArchiveFiles = 2100000
	// MaxArchiveManifestBytes bounds manifest.json on the wire. Arithmetic
	// (largest valid entry, every byte counted): `{"bytes":"` 9 + Size 20 +
	// `","path":"` 10 + encoded path ≤256 (128 Identifier bytes, each `"`
	// escaped to two bytes; backslash and controls are refused by Path) +
	// `","sha256":"` 12 + Digest 64 + `"}` 2 + `,` 1 = 374 bytes per entry;
	// 374 × 2,100,000 = 785,400,000. Envelope outside `files`: thirteen
	// fixed keys and punctuation < 300 bytes, five Digests 320, three Sizes
	// 60, profile 17, queueId ≤128, primaryWorktree ≤8,192 (4,096 PathText
	// bytes, each `"` escaped), `[`/`]`/LF 3: < 9,100 bytes. Worst case
	// 785,409,100 < 768 MiB = 805,306,368; the proposed 512 MiB
	// (536,870,912) would not hold it, so the cap is 768 MiB.
	MaxArchiveManifestBytes = 768 * MiB
	// MaxArchiveScanEntries bounds the directory entries `archive export`
	// enumerates under the state dir (directories, skipped temp names and
	// unexpected names included) before any entry is stat'ed or opened. It
	// is counted separately from the exported-file count, which is bounded
	// by MaxArchiveFiles; the 4,096 headroom covers the fixed layout
	// directories and a bounded number of crashed temp files.
	MaxArchiveScanEntries = MaxArchiveFiles + 4096

	MaxGateArgv         = 16
	MaxRuntimeArgv      = 16
	MaxActiveAttempts   = 64
	MaxWorkersTotal     = 256
	MaxAdmissionsPerRev = 3
	MaxRepairRounds     = 2
	MaxMalformedRetry   = 1
	MaxGateRerunStale   = 1
	MaxReconcileAttempt = 3
	MinEvidenceDays     = 30
	MaxLaneWallMinutes  = 240
	MaxGateTimeoutSecs  = 120 * 60

	PageDefault = 100
	PageMax     = 1000

	MaxJSONDepth         = 24
	MaxJSONArrayElements = 10000
	MaxJSONNodes         = 250000

	MaxCountValue = 2147483647
	VersionSuffix = "/0"
)

Frozen numeric limits (SPEC §1). Every value is validated before any effect; exceeding one fails closed with LIMIT_EXCEEDED.

View Source
const (
	OutcomeOK      = "OK"
	OutcomeRefused = "REFUSED"
	OutcomeError   = "ERROR"
	OutcomeNotRun  = "NOT_RUN"
)

Outcomes of taskman-command-result/0.

View Source
const CodeAdjudication = "ADJUDICATION"

Closed detail codes (SPEC §11). Only these strings may appear in a taskman-command-result/0 or taskman-outcome/0 codes array.

View Source
const CodeAdoptUnsupportedField = "ADOPT_UNSUPPORTED_FIELD"
View Source
const CodeApprovalMissing = "APPROVAL_MISSING"
View Source
const CodeApprovalRevoked = "APPROVAL_REVOKED"
View Source
const CodeAttemptLive = "ATTEMPT_LIVE"
View Source
const CodeBootFenced = "BOOT_FENCED"
View Source
const CodeBootTimeout = "BOOT_TIMEOUT"
View Source
const CodeBudgetExceeded = "BUDGET_EXCEEDED"
View Source
const CodeBudgetUnknown = "BUDGET_UNKNOWN"
View Source
const CodeCapabilityUnavailable = "CAPABILITY_UNAVAILABLE"
View Source
const CodeCemMissing = "CEM_MISSING"
View Source
const CodeContaminated = "CONTAMINATED"
View Source
const CodeCoverageUnknown = "COVERAGE_UNKNOWN"
View Source
const CodeCutoverInProgress = "CUTOVER_IN_PROGRESS"
View Source
const CodeCutoverMissing = "CUTOVER_MISSING"
View Source
const CodeCycle = "CYCLE"
View Source
const CodeDependencyMissing = "DEPENDENCY_MISSING"
View Source
const CodeDependencyUnsatisfied = "DEPENDENCY_UNSATISFIED"
View Source
const CodeDevelopmentMode = "DEVELOPMENT_MODE"
View Source
const CodeDirtyWorktree = "DIRTY_WORKTREE"
View Source
const CodeDocsMissing = "DOCS_MISSING"
View Source
const CodeDuplicateID = "DUPLICATE_ID"
View Source
const CodeEffectOwned = "EFFECT_OWNED"
View Source
const CodeExternalUnbounded = "EXTERNAL_UNBOUNDED"
View Source
const CodeFenced = "FENCED"
View Source
const CodeGateFailed = "GATE_FAILED"
View Source
const CodeGateStale = "GATE_STALE"
View Source
const CodeGateUnknown = "GATE_UNKNOWN"
View Source
const CodeIndependenceUnverified = "INDEPENDENCE_UNVERIFIED"
View Source
const CodeIntentBranchMismatch = "INTENT_BRANCH_MISMATCH"
View Source
const CodeIntentDiverged = "INTENT_DIVERGED"
View Source
const CodeInvalidPriority = "INVALID_PRIORITY"
View Source
const CodeJournalForked = "JOURNAL_FORKED"
View Source
const CodeJournalSaturated = "JOURNAL_SATURATED"
View Source
const CodeLimitExceeded = "LIMIT_EXCEEDED"
View Source
const CodeLockTimeout = "LOCK_TIMEOUT"
View Source
const CodeMalformed = "MALFORMED"
View Source
const CodeMissingEvidence = "MISSING_EVIDENCE"
View Source
const CodeMissingGate = "MISSING_GATE"
View Source
const CodeNoexec = "NOEXEC"
View Source
const CodeOcmMissing = "OCM_MISSING"
View Source
const CodeOutOfScope = "OUT_OF_SCOPE"
View Source
const CodePaused = "PAUSED"
View Source
const CodePlanStale = "PLAN_STALE"
View Source
const CodeQuiescenceUnproved = "QUIESCENCE_UNPROVED"
View Source
const CodeRedoPending = "REDO_PENDING"
View Source
const CodeRequestIDConflict = "REQUEST_ID_CONFLICT"
View Source
const CodeResourceCollision = "RESOURCE_COLLISION"
View Source
const CodeRestoreIncomplete = "RESTORE_INCOMPLETE"
View Source
const CodeRestored = "RESTORED"
View Source
const CodeRetryExhausted = "RETRY_EXHAUSTED"
View Source
const CodeReviewIncomplete = "REVIEW_INCOMPLETE"
View Source
const CodeReviewRejected = "REVIEW_REJECTED"
View Source
const CodeSignalRefusedIdentity = "SIGNAL_REFUSED_IDENTITY"
View Source
const CodeSnapshotMoved = "SNAPSHOT_MOVED"
View Source
const CodeStalePolicy = "STALE_POLICY"
View Source
const CodeStaleTicket = "STALE_TICKET"
View Source
const CodeStaleTree = "STALE_TREE"
View Source
const CodeSupervisorLost = "SUPERVISOR_LOST"
View Source
const CodeSurvivors = "SURVIVORS"
View Source
const CodeTicketHeld = "TICKET_HELD"
View Source
const CodeTicketState = "TICKET_STATE"
View Source
const CodeUncertainEffect = "UNCERTAIN_EFFECT"
View Source
const CodeUninitialized = "UNINITIALIZED"
View Source
const CodeUnpublished = "UNPUBLISHED"
View Source
const CodeUnresolvedFinding = "UNRESOLVED_FINDING"
View Source
const CodeUnsupported = "UNSUPPORTED"
View Source
const CodeUnsupportedFilesystem = "UNSUPPORTED_FILESYSTEM"
View Source
const CodeUnsupportedVersion = "UNSUPPORTED_VERSION"
View Source
const ProfileCommandResult = "taskman-command-result/0"

ProfileCommandResult is the stdout envelope of every corvint-tasks command (§3.3).

View Source
const UntrustedQueueData = "UNTRUSTED_QUEUE_DATA"

UntrustedQueueData is the only legal member of the `untrusted` array.

Variables

Codes is the closed §11 set.

View Source
var TicketRecordKeys = []string{
	"profile", "ticketId", "revision", "acceptanceRevision", "previousRecordSha256", "status",
	"archivedFrom", "title", "body", "kind", "owner", "milestone", "priority", "order", "labels",
	"dependencies", "acceptanceCriteria", "requirementRefs", "source", "effects", "capabilities",
	"requiredGates", "holds", "executionClass", "approvals", "completion", "dueDate",
	"estimateMinutes", "supersedes", "supersededBy", "shadowOverlay", "createdAt", "updatedAt",
	"updatedBy",
}

TicketRecordKeys is the closed taskman-ticket/0 record key set (SPEC §3.1), in record order. Corvint Core's read-only planner imports it instead of keeping a copy.

Functions

func CheckProfile

func CheckProfile(where, got, want string) error

CheckProfile checks a profile string against the expected `<name>/0`. A different version of the same profile is UNSUPPORTED_VERSION; a different profile entirely is MALFORMED.

func CheckSortedUnique

func CheckSortedUnique(where string, vs []Value) error

CheckSortedUnique verifies that an array is canonical-byte sorted without duplicates (§2 rule for non-semantic arrays).

func CodeOf

func CodeOf(err error) string

CodeOf returns the §11 code carried by err, or MALFORMED for any other error, or "" for nil.

func Encode

func Encode(v Value) []byte

Encode returns the canonical body of a value (WQO §4.1): closed objects with keys in UTF-8 byte order, no insignificant whitespace, only `\t`, `\n`, `\r`, `\"` and `\\` as short escapes, `\u00xx` (lowercase) for any other control, never `\/`, never an optional `\u` escape, raw UTF-8 otherwise. The trailing LF is not part of the body; see EncodeFile.

func EncodeFile

func EncodeFile(v Value) []byte

EncodeFile returns the on-disk and transport form: canonical body plus exactly one LF (§2).

func Equal

func Equal(a, b Value) bool

Equal reports whether two values encode to identical canonical bytes.

func FoldToken

func FoldToken(s string) string

FoldToken is the ASCII case folding under which local tokens are unique.

func IsCode

func IsCode(s string) bool

IsCode reports whether s is a member of the closed §11 set.

func ParseDate

func ParseDate(where, s string) (string, error)

ParseDate validates `YYYY-MM-DD`.

func ParseIdentifier

func ParseIdentifier(where, s string) (string, error)

ParseIdentifier validates an Identifier: 1..128 UTF-8 bytes, no hostile code points, no TAB/LF/CR.

func ParseLabel

func ParseLabel(where, s string) (string, error)

ParseLabel validates a label: 1..64 bytes under the identifier rules.

func ParseOID

func ParseOID(where, s string) (string, error)

ParseOID validates a Git object id (40 hex for sha1, 64 for sha256).

func ParsePath

func ParsePath(where, s string) (string, error)

ParsePath validates a WQO Path: 1..512 bytes, `/` separators, no leading `/`, no empty, `.` or `..` segment, no backslash, NUL or control byte. A trailing `/` denotes a directory prefix.

func ParsePathText

func ParsePathText(where, s string) (string, error)

ParsePathText validates a PathText (§2): an absolute filesystem path of 1..4096 UTF-8 bytes with no hostile code point and no TAB, LF or CR. It is the type of `head.primaryWorktree` and `manifest.primaryWorktree`; it is not an Identifier and shares no bound with one. Nothing is normalized: the bytes are compared exactly against the resolved primary worktree.

func ParseProse

func ParseProse(where, s string, min, max int) (string, error)

ParseProse validates a prose field of at most max bytes; TAB, LF and CR are permitted. min is 0 or 1.

func ParseRepoID

func ParseRepoID(where, s string) (string, error)

ParseRepoID validates `repo:<authority-token>` and returns the token.

func ParseToken

func ParseToken(where, s string, max int) (string, error)

ParseToken validates the `[A-Za-z0-9][A-Za-z0-9._-]*` grammar of §2 with a byte bound.

func RecordIdentity

func RecordIdentity(kind string, d Digest) string

RecordIdentity renders `<kind>:sha256:<Digest>`.

Types

type BarrierRef

type BarrierRef struct {
	Scope  string
	Reason string
}

BarrierRef is the `snapshot.barrier` object.

type Count

type Count string

Count is a decimal string `0` or a non-zero integer without leading zero, at most 2147483647 (§2). Used only for cardinalities and small counters.

func CountOf

func CountOf(n int64) Count

CountOf renders a non-negative integer as a Count; values above the Count maximum are a programming error and are clamped so they can never encode as a valid Count silently: the caller must validate.

func ParseCount

func ParseCount(where, s string) (Count, error)

ParseCount validates a Count.

func (Count) Int

func (c Count) Int() int64

Int returns the numeric value of a validated Count.

type Digest

type Digest string

Digest is 64 lowercase hexadecimal SHA-256 characters.

func ContentID

func ContentID(kind, profile string, canonicalBody []byte) Digest

ContentID computes the WQO §4.3 content identity SHA-256(kind || 0x00 || profile || 0x00 || canonicalBody) where the body is the canonical encoding without the trailing LF.

func ParseDigest

func ParseDigest(where, s string) (Digest, error)

ParseDigest validates a Digest.

func Sum

func Sum(raw []byte) Digest

Sum returns the SHA-256 of raw bytes as a Digest. A file's chain digest is the digest of its complete raw bytes, trailing LF included (§2).

type Error

type Error struct {
	Code  string
	Where string
	Msg   string
}

Error is a stable, actionable failure: a closed §11 code, the location in the document (a JSON-pointer-like path or a byte offset) and a message.

func Errorf

func Errorf(detailCode, where, format string, args ...interface{}) *Error

Errorf builds an Error. The code must be a §11 code; anything else is a programming error and is reported as MALFORMED so it can never leak an unknown code onto the wire. The parameter is not named `code`: Corvint's error-code ownership ratchet matches callees by name (ECO-V0-001), so that name would make every fmt.Errorf literal in the module an emitted code.

func (*Error) Error

func (e *Error) Error() string

type Kind

type Kind int

Kind enumerates the JSON value kinds a taskman document may contain.

const (
	KindNull Kind = iota
	KindBool
	KindString
	KindArray
	KindObject
)

func (Kind) String

func (k Kind) String() string

type Object

type Object struct {
	Keys []string
	Vals map[string]Value
}

Object is a JSON object. Keys keeps the order in which members were parsed or set; canonical encoding always sorts by UTF-8 byte order regardless.

func NewObject

func NewObject() *Object

NewObject returns an empty object.

func (*Object) Get

func (o *Object) Get(key string) (Value, bool)

Get returns a member and whether it exists.

func (*Object) Set

func (o *Object) Set(key string, v Value) *Object

Set adds or replaces a member and returns the object for chaining.

func (*Object) SortedKeys

func (o *Object) SortedKeys() []string

SortedKeys returns the member keys in canonical (byte) order.

type Page

type Page struct {
	Offset    Count
	Limit     Count
	Total     *Count
	Truncated bool
}

Page is the pagination object.

type ParseOptions

type ParseOptions struct {
	WideArrayKey string
	WideArrayMax int
	MaxNodes     int
}

ParseOptions is the opt-in widening a single profile may request. Only the array that is the direct value of the top-level key WideArrayKey is bounded by WideArrayMax instead of MaxJSONArrayElements; every other array, at any depth, keeps the ordinary bound. MaxNodes replaces MaxJSONNodes for the whole document. Zero values select the defaults, so ParseOptions{} is Parse. Depth is never widened.

type QueueID

type QueueID struct {
	Raw       string
	Authority string
	Queue     string
}

QueueID is a parsed `queue:<authority>:<queue>`.

func ParseQueueID

func ParseQueueID(where, s string) (QueueID, error)

ParseQueueID validates `queue:<authority>:<queue>`.

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader walks a parsed Value with closed-object checks and typed accessors. The first failure is recorded and every later call returns a zero value, so a decoder reads linearly and checks Err once. Locations are JSON-pointer style paths such as `/dependencies/2/gateId`.

func NewReader

func NewReader(v Value, where string) *Reader

NewReader starts a reader at the document root (or any sub-value).

func (*Reader) Array

func (r *Reader) Array(max int, semantic bool) []*Reader

Array requires an array of at most max elements (max < 0 means unbounded beyond the §1 decode bound). When semantic is false the array must be canonical-byte sorted without duplicates (§2).

func (*Reader) Bool

func (r *Reader) Bool() bool

Bool requires a boolean.

func (*Reader) Closed

func (r *Reader) Closed(keys ...string) *Reader

Closed requires the value to be an object with exactly the listed keys; missing and unknown keys are both MALFORMED, named in the message.

func (*Reader) Count

func (r *Reader) Count() Count

Count requires a Count.

func (*Reader) CountOrNull

func (r *Reader) CountOrNull() *Count

CountOrNull accepts a Count or null.

func (*Reader) Digest

func (r *Reader) Digest() Digest

Digest requires a Digest.

func (*Reader) DigestOrNull

func (r *Reader) DigestOrNull() *Digest

DigestOrNull accepts a Digest or null.

func (*Reader) Enum

func (r *Reader) Enum(allowed ...string) string

Enum requires one of the allowed strings.

func (*Reader) Err

func (r *Reader) Err() error

Err returns the first failure, or nil.

func (*Reader) Exact

func (r *Reader) Exact(want string) string

Exact requires the string to equal one literal.

func (*Reader) Fail

func (r *Reader) Fail(code, format string, args ...interface{})

Fail records a failure at this reader's location unless one exists.

func (*Reader) Field

func (r *Reader) Field(key string) *Reader

Field returns a reader for a member of an object. Closed must have been called first; a missing member here is still reported.

func (*Reader) Identifier

func (r *Reader) Identifier() string

Identifier requires an Identifier.

func (*Reader) IsNull

func (r *Reader) IsNull() bool

IsNull reports whether the value is JSON null.

func (*Reader) Label

func (r *Reader) Label() string

Label requires a label.

func (*Reader) LabelOrNull

func (r *Reader) LabelOrNull() *string

LabelOrNull accepts a label or null.

func (*Reader) OID

func (r *Reader) OID() string

OID requires a Git object id.

func (*Reader) Path

func (r *Reader) Path() string

Path requires a WQO Path.

func (*Reader) PathText

func (r *Reader) PathText() string

PathText requires a PathText (an absolute filesystem path, §2).

func (*Reader) Prose

func (r *Reader) Prose(min, max int) string

Prose requires prose of min..max bytes.

func (*Reader) ProseOrNull

func (r *Reader) ProseOrNull(max int) *string

ProseOrNull accepts prose or null.

func (*Reader) QueueID

func (r *Reader) QueueID() QueueID

QueueID requires a queue ID.

func (*Reader) Size

func (r *Reader) Size() Size

Size requires a Size.

func (*Reader) SizeOrNull

func (r *Reader) SizeOrNull() *Size

SizeOrNull accepts a Size or null.

func (*Reader) String

func (r *Reader) String() string

String requires a string.

func (*Reader) StringOrNull

func (r *Reader) StringOrNull(fn func(*Reader) string) *string

StringOrNull accepts an identifier-class string validated by fn, or null.

func (*Reader) Strings

func (r *Reader) Strings(max int, semantic bool, fn func(*Reader) string) []string

Strings reads an array of strings, each validated by fn (for example (*Reader).Label), with the given bound and sortedness rule.

func (*Reader) TicketID

func (r *Reader) TicketID() TicketID

TicketID requires a ticket ID.

func (*Reader) Timestamp

func (r *Reader) Timestamp() Timestamp

Timestamp requires a timestamp.

func (*Reader) TimestampOrNull

func (r *Reader) TimestampOrNull() *Timestamp

TimestampOrNull accepts a timestamp or null.

func (*Reader) Value

func (r *Reader) Value() Value

Value returns the underlying value.

func (*Reader) Where

func (r *Reader) Where() string

Where returns the reader's location.

type Result

type Result struct {
	Command   []string
	Outcome   string
	Codes     []string
	Snapshot  *Snapshot
	Mutation  *Value // taskman-outcome/0 or nil (null)
	Items     []Value
	Page      *Page
	Untrusted bool
	Warnings  []string
}

Result is a taskman-command-result/0 document.

func DecodeResult

func DecodeResult(data []byte) (*Result, error)

DecodeResult parses and validates an envelope. Items are kept as opaque values (their kind is verb-specific).

func (*Result) Encode

func (r *Result) Encode() ([]byte, error)

Encode validates the envelope against its closed schema and the §1 size bounds and returns the on-disk/transport bytes (canonical body plus LF).

func (*Result) Value

func (r *Result) Value() Value

Value renders the envelope. Codes and warnings are non-semantic arrays and are sorted; items keep their semantic order.

type Size

type Size string

Size is a decimal string without leading zeros in 0..18446744073709551615 (§2). Used for byte sizes, sequence numbers, generations, pids and so on.

func ParseSize

func ParseSize(where, s string) (Size, error)

ParseSize validates a Size.

func SizeOf

func SizeOf(n uint64) Size

SizeOf renders an unsigned integer as a Size.

func (Size) Uint64

func (s Size) Uint64() uint64

Uint64 returns the numeric value of a validated Size.

type Snapshot

type Snapshot struct {
	HeadSeq               *Size
	HeadReceiptSha256     *Digest
	IntentTreeSha256      *Digest
	PrimaryWorktreeSha256 *Digest
	PendingRedo           bool
	Barrier               *BarrierRef
}

Snapshot is the `snapshot` object of the envelope.

type TicketID

type TicketID struct {
	Raw       string
	Authority string
	Queue     string
	Local     string
}

TicketID is a parsed `ticket:<authority>:<queue>:<local>`.

func ParseTicketID

func ParseTicketID(where, s string) (TicketID, error)

ParseTicketID validates `ticket:<authority>:<queue>:<local>` with the local token 1..64 bytes of the token grammar.

func (TicketID) QueueID

func (t TicketID) QueueID() string

QueueID returns the queue the ticket belongs to.

type Timestamp

type Timestamp string

Timestamp is `YYYY-MM-DDTHH:MM:SSZ` (UTC, seconds; advisory only).

func ParseTimestamp

func ParseTimestamp(where, s string) (Timestamp, error)

ParseTimestamp validates `YYYY-MM-DDTHH:MM:SSZ`.

type Value

type Value struct {
	Kind Kind
	Bool bool
	Str  string
	Arr  []Value
	Obj  *Object
}

Value is one decoded JSON value.

func Array

func Array(vs ...Value) Value

Array returns a JSON array keeping the given (semantic) order.

func Bool

func Bool(b bool) Value

Bool returns a JSON boolean.

func Null

func Null() Value

Null returns the JSON null value.

func ObjectValue

func ObjectValue(o *Object) Value

ObjectValue wraps an object as a value.

func Parse

func Parse(data []byte) (Value, error)

Parse decodes one canonical taskman document: a single JSON value with no insignificant whitespace, sorted keys, canonical escapes and exactly one trailing LF (SPEC §2, WQO §4.1). It enforces the §1 decode bounds (depth, array elements, aggregate nodes), refuses duplicate keys, JSON numbers, invalid UTF-8, lone surrogates and hostile code points, and then proves canonical framing by re-encoding the value and comparing bytes.

func ParseWith

func ParseWith(data []byte, opts ParseOptions) (Value, error)

ParseWith is Parse under explicit decode bounds (§3.5: the taskman-archive/0 manifest is the only profile that uses it). The bounds are enforced incrementally while parsing, before the document is materialized; a document over a bound fails LIMIT_EXCEEDED at the first element or node beyond it.

func SortedSet

func SortedSet(where string, vs []Value) (Value, error)

SortedSet sorts values by canonical bytes (§2: non-semantic arrays) and reports a duplicate as MALFORMED.

func String

func String(s string) Value

String returns a JSON string.

func StringOrNull

func StringOrNull(p *string) Value

StringOrNull returns a string value, or null when p is nil.

func Strings

func Strings(ss []string) Value

Strings returns an array of strings in the given order.

Jump to

Keyboard shortcuts

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