askref

package
v0.326.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 6 Imported by: 0 modules, 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 askref is an ask's REFERENCES: the drafts, officer items, posts and content entries an ask is about, as typed pointers (migration 0206, attention_asks.refs; docs/attention.md "Reference cards").

An ask stores only the pointer — {kind, id} or, for a post, {kind, url} — never a copy of what it points at. Every surface reads the thing it points at AT RENDER TIME, under the viewer's own principal (row-level security), and draws its CURRENT state (internal/api ask_refs.go): a draft the ask was raised about that has since been sent says "sent", so the person sees the ask is moot. A pointer the viewer cannot read, or that names nothing, draws nothing — never an error.

🔴 THE POINTERS ARE AN AGENT'S, SO UNTRUSTED. Parse is the one validation (kind enum, positive ids, https URLs only, at most MaxRefs): an officer's officer_complete and every other writer go through it, and a refusal names what to fix so the agent can retry.

Index

Constants

View Source
const (
	// KindDraft is an outbound or reply draft (plugin_reply_drafts.id).
	KindDraft = "draft"
	// KindItem is an officer item (officer_items.id).
	KindItem = "item"
	// KindPost is a post already out on a venue: its https URL.
	KindPost = "post"
	// KindContentEntry is one scheduled post of an approved content set
	// (plugin_content_entries.id).
	KindContentEntry = "content_entry"
)

The kinds a reference may name.

View Source
const MaxRefs = 5

MaxRefs is how many references one ask may carry (0206's CHECK holds it).

View Source
const MaxURLRunes = 500

MaxURLRunes bounds a post's URL.

Variables

Kinds is every kind, in the order a refusal lists them.

Functions

This section is empty.

Types

type Ref

type Ref struct {
	Kind string `json:"kind"`
	ID   int64  `json:"id,omitempty"`
	URL  string `json:"url,omitempty"`
}

Ref is one reference: Kind and, for a post, URL; for every other kind ID.

func Clean

func Clean(r Ref, rawID json.RawMessage) (out Ref, bad string)

Clean is r with its id taken from rawID (a JSON whole number, or a string of digits), checked: a known kind; a post with an https URL and no id; any other kind with a positive id and no URL. bad says why it is refused.

func CleanAll

func CleanAll(refs []Ref) ([]Ref, error)

CleanAll is refs as a store keeps them: each Valid, none twice, at most MaxRefs; an error names the first that is not.

func Parse

func Parse(raw json.RawMessage) ([]Ref, string)

Parse is raw — a JSON array of {kind, id} / {kind: "post", url} — as an ask stores it, or why it is refused (a sentence naming the bad element, worded for the agent that sent it). Absent, null and [] are no references. Duplicates are dropped.

func (Ref) Valid

func (r Ref) Valid() bool

Valid reports whether r is a reference Clean would keep as it is.

Jump to

Keyboard shortcuts

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