Documentation
¶
Overview ¶
Package record reads the JSONL record format used by tasks.
Index ¶
- Constants
- Variables
- func Absent(value json.RawMessage) bool
- func DecodeStrings(raw json.RawMessage) []string
- func DelegationAgent(value any) bool
- func DelegationClaimed(value any) bool
- func DelegationEmail(value any) bool
- func DelegationErrors(value any) []string
- func DelegationHuman(value any) bool
- func DelegationIdentifier(value any) bool
- func DelegationObject(value any) bool
- func DelegationOrderedKeys(value map[string]any, sourceOrder []string) []string
- func DelegationReady(value any) bool
- func DelegationStamp(value time.Time) string
- func DelegationTimestamp(value any) bool
- func DelegationUnknownKeys(value any) []string
- func DelegationValid(value any) bool
- func DelegationWorkRefErrors(value any) []string
- func Dump(records []Record) (string, error)
- func DumpRecord(record Record) (string, error)
- func EncodeJSON(out *bytes.Buffer, raw json.RawMessage) error
- func EncodeString(out *bytes.Buffer, value string)
- func NestedCanonical(key string, raw json.RawMessage) (string, error)
- func RawInt(value int) json.RawMessage
- func RawString(value string) json.RawMessage
- func RawStrings(values []string) json.RawMessage
- func RubyInspect(value any) string
- type Field
- type GeneratorError
- type ParseError
- type Record
- func (r *Record) Delete(key string)
- func (r Record) Get(key string) (json.RawMessage, bool)
- func (r Record) Has(key string) bool
- func (r *Record) Set(key string, value json.RawMessage)
- func (r *Record) SetDefault(key string, value json.RawMessage)
- func (r *Record) SetOptional(key string, value json.RawMessage)
- func (r *Record) SetString(key, value string)
- func (r Record) String(key string) string
- func (r Record) Truthy(key string) bool
- type Result
Constants ¶
const DelegationField = "delegation"
const LineKey = "line"
LineKey is the physical line number the parser stamps onto a record. It is bookkeeping, never part of the schema, so emission always drops it.
Variables ¶
var DelegationKeyOrder = []string{"kind", "mode", "status", "assignee", "at", "work_ref"}
var KeyOrder = []string{
"type", "id", "parent", "state", "priority", "title", "tags", "scheduled", "scheduled_time",
"deadline", "deadline_time", "recur", "lead", "lead_skip", "delegation",
"closed", "rejected", "archived", "links", "body", "updated",
}
KeyOrder is the canonical field order for a serialized record. A key present on a record but absent here is emitted after these, in the record's own source order, so a field a newer writer added survives a write by this one.
Functions ¶
func Absent ¶
func Absent(value json.RawMessage) bool
Absent is Delegation.absent?: nil, the empty string, the empty array and the empty object all mean "this field is not here".
func DecodeStrings ¶
func DecodeStrings(raw json.RawMessage) []string
DecodeStrings reads a stored string array, skipping members that are not strings — which is what Ruby's tag handling does with a foreign writer's list.
func DelegationAgent ¶
func DelegationClaimed ¶
func DelegationEmail ¶
DelegationEmail is Delegation.email? — an identifier that is also address-SHAPED, so a stray `@work` cannot become a person a task waits on.
func DelegationErrors ¶
DelegationErrors returns Ruby-compatible schema diagnostics for delegation.
func DelegationHuman ¶
func DelegationIdentifier ¶
DelegationIdentifier is Delegation.identifier?: real UTF-8, non-empty, bounded, no whitespace in any script, no control or escape characters.
func DelegationObject ¶
func DelegationOrderedKeys ¶
DelegationOrdered supplies the canonical key order plus unknowns in source order. Go maps cannot retain insertion order, so callers that need emission order should use DelegationOrderedKeys with the source-field order they already possess.
func DelegationReady ¶
func DelegationStamp ¶
func DelegationTimestamp ¶
func DelegationUnknownKeys ¶
func DelegationValid ¶
func DelegationWorkRefErrors ¶
DelegationWorkRefErrors is Delegation.work_ref_errors for one reference. The work-ref writer validates BEFORE it builds a marker, so the user reads the reference's own problem rather than a whole-marker shape report.
func Dump ¶
Dump serializes records to full file text: one record per line with a trailing newline at EOF. An empty list yields the empty string.
func DumpRecord ¶
DumpRecord serializes one record to a single JSON line with no trailing newline. Known keys emit in KeyOrder, then unknown keys in source order. Null, the empty string, the empty array, and the empty object are omitted: they mean an absent field, not a present-but-empty one.
func EncodeJSON ¶
func EncodeJSON(out *bytes.Buffer, raw json.RawMessage) error
EncodeJSON writes one already-parsed JSON value the way Ruby's JSON.generate writes it: no whitespace, object members in source order, and Ruby's escape set and number spellings. It is the seam the store's revision digests need — those digest `JSON.generate(...)` output, so a Go emitter that escaped `<` or reordered a nested object would compute a different token from identical bytes.
func EncodeString ¶
EncodeString writes a Go string as a JSON string with Ruby's escape set.
func NestedCanonical ¶
func NestedCanonical(key string, raw json.RawMessage) (string, error)
NestedCanonical renders one nested object — a delegation or a `*_time` value — in its canonical key order, exactly as Format.nested_object followed by JSON.generate does in Ruby. The merge needs those bytes as a total order over two delegation markers, which is what makes "exactly one worker holds a claim" survive a multi-device sync.
func RawString ¶
func RawString(value string) json.RawMessage
RawString encodes a Go string as a canonical JSON string, with Ruby's escape set rather than Go's — encoding/json is never the writer here.
func RawStrings ¶
func RawStrings(values []string) json.RawMessage
RawStrings encodes a list of strings as a canonical JSON array.
func RubyInspect ¶
RubyInspect renders a value the way a Ruby diagnostic quotes it, which is what every delegation refusal's wording depends on.
Types ¶
type Field ¶
type Field struct {
Key string
Value json.RawMessage
}
Field is one parsed object member. The parser retains source member order so a later canonical emitter can append forward-compatible keys in the same order Ruby's Hash preserves them.
type GeneratorError ¶
GeneratorError reports a value JSON cannot represent. Ruby's generator raises JSON::GeneratorError for a non-finite float; nothing else in the record format can reach this layer unrepresentable, because every value arrives from a successful parse.
func (*GeneratorError) Error ¶
func (e *GeneratorError) Error() string
type ParseError ¶
ParseError is a non-fatal defect in an input file. Parsing continues after per-line errors so callers can still inspect the records that were sound.
type Record ¶
Record is one parsed JSONL object. Fields retain JSON representations and source order so later validation and canonical emission can make their own type decisions. Line is physical and is never part of the persisted record schema.
func Clone ¶
Clone is `duplicate_records`' per-record half: a detached copy whose fields can be replaced without disturbing the original. Values are json.RawMessage and are only ever replaced, never mutated in place, so copying the slice is a deep copy in practice.
func (Record) Get ¶
func (r Record) Get(key string) (json.RawMessage, bool)
Get is `rec[key]`: the raw value, or ok=false when the key is absent. The FIRST occurrence wins, matching the parser's own duplicate-key handling.
func (*Record) Set ¶
func (r *Record) Set(key string, value json.RawMessage)
Set is `rec[key] = value`: an existing key keeps its position, a new one is appended.
func (*Record) SetDefault ¶
func (r *Record) SetDefault(key string, value json.RawMessage)
SetDefault is Ruby's `rec[key] ||= value`: it writes only when the key is absent or holds nil/false.
func (*Record) SetOptional ¶
func (r *Record) SetOptional(key string, value json.RawMessage)
SetOptional is Store#replace_optional: an absent, null or empty value deletes the key rather than writing a present-but-empty one, because the format reads those as the same thing and writing one would change the bytes for no semantic difference.
type Result ¶
type Result struct {
Records []Record
Errors []ParseError
}
Result is the complete, non-failing outcome of parsing a JSONL file.