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

writing

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package writing builds explicit, local-only prose snapshots and keeps a content-free index of reviewed answers. References are caller-approved data, not model training, implicit memory, or permission to reuse changed facts.

Index

Constants

View Source
const ConfigName = "writing-workflow.json"
View Source
const MaxEvidenceBytes = 32 << 10
View Source
const MaxIndexBytes = 128 << 10
View Source
const MaxIndexEntries = 128
View Source
const MaxReferenceBytes = 16 << 10

Variables

View Source
var ErrIndexFull = errors.New("writing_review_index_full")
View Source
var ErrInvalid = errors.New("writing_snapshot_invalid")
View Source
var ErrUnconfirmed = errors.New("writing_answer_unconfirmed")

Functions

func Hash

func Hash(data []byte) string

func Record

func Record(ctx context.Context, broker inference.Broker, plan Plan, result delegation.Result, review string) (protocol.PublishResult, error)

Record indexes a confirmed answer after explicit caller review. An index is a historical reference, never a cache hit or an assertion of human acceptance. Use outcomes feedback for an actual person's acceptance, rewrite and effort.

func ValidatePlan

func ValidatePlan(plan Plan) error

Types

type Config

type Config struct {
	Schema          int    `json:"schema"`
	ReferencePath   string `json:"reference_path"`
	ReferenceSHA256 string `json:"reference_sha256"`
	Recipe          Recipe `json:"recipe"`
}

Config pins an explicitly selected local reference. Changing its bytes requires a deliberately updated config; no chat or home directory is scanned.

type Entry

type Entry struct {
	Schema            int    `json:"schema"`
	RequestSHA256     string `json:"request_sha256"`
	ReferenceID       string `json:"reference_id"`
	ReferenceRevision string `json:"reference_revision"`
	ReferenceSHA256   string `json:"reference_sha256"`
	EvidenceID        string `json:"evidence_id"`
	EvidenceRevision  string `json:"evidence_revision"`
	EvidenceSHA256    string `json:"evidence_sha256"`
	AnswerKey         string `json:"answer_key"`
	AnswerVersion     int64  `json:"answer_version"`
	AnswerSHA256      string `json:"answer_sha256"`
	ReviewStatus      string `json:"review_status"`
	HumanAcceptance   string `json:"human_acceptance"`
}

Entry stores no prompt, profile, evidence or answer content. The broker artifact version identifies the historical answer; expiry is left unchanged.

func ReadEntries

func ReadEntries(ctx context.Context, broker inference.Broker, referenceID string) ([]Entry, error)

ReadEntries resolves only the immutable metadata referenced by ReadIndex. It verifies each pointer's version, bytes and reference binding. Answer content and profile/evidence documents are never fetched by this function.

type EntryRef

type EntryRef struct {
	Key     string `json:"key"`
	Version int64  `json:"version"`
	SHA256  string `json:"sha256"`
}

EntryRef pins an immutable metadata entry, not the answer itself. Metadata entries contain source versions and review status, never profile or prose.

type Evidence

type Evidence struct {
	Schema   int      `json:"schema"`
	ID       string   `json:"id"`
	Revision string   `json:"revision"`
	Question string   `json:"question"`
	Facts    []string `json:"facts"`
	Sources  []string `json:"sources"`
}

func DecodeEvidence

func DecodeEvidence(data []byte) (Evidence, error)

type Plan

type Plan struct {
	Schema            int                `json:"schema"`
	Recipe            Recipe             `json:"recipe"`
	ReferenceID       string             `json:"reference_id"`
	ReferenceRevision string             `json:"reference_revision"`
	ReferenceSHA256   string             `json:"reference_sha256"`
	EvidenceID        string             `json:"evidence_id"`
	EvidenceRevision  string             `json:"evidence_revision"`
	EvidenceSHA256    string             `json:"evidence_sha256"`
	RequestSHA256     string             `json:"request_sha256"`
	Request           delegation.Request `json:"request"`
}

func Build

func Build(reference, evidence []byte, recipe Recipe) (Plan, error)

type Recipe

type Recipe struct {
	Model           string   `json:"model"`
	MaxInputTokens  int64    `json:"max_input_tokens"`
	MaxOutputTokens int64    `json:"max_output_tokens"`
	ReuseForSeconds int64    `json:"reuse_for_seconds"`
	MinWords        int      `json:"min_words"`
	MaxWords        int      `json:"max_words"`
	Paragraphs      int      `json:"paragraphs"`
	Forbidden       []string `json:"forbidden"`
}

func DefaultRecipe

func DefaultRecipe(model string) Recipe

type Reference

type Reference struct {
	Schema   int      `json:"schema"`
	ID       string   `json:"id"`
	Revision string   `json:"revision"`
	Facts    []string `json:"facts"`
	Style    []string `json:"style"`
}

func DecodeReference

func DecodeReference(data []byte) (Reference, error)

type ReviewIndex

type ReviewIndex struct {
	Schema      int        `json:"schema"`
	ReferenceID string     `json:"reference_id"`
	Entries     []EntryRef `json:"entries"`
}

ReviewIndex persists bounded historical metadata references. It grants no cache eligibility, extends no inference TTL, and asserts no human acceptance.

func ReadIndex

func ReadIndex(ctx context.Context, broker inference.Broker, referenceID string) (ReviewIndex, error)

ReadIndex returns an empty schema-1 index only when the broker explicitly reports not_found. Every other read or validation failure is preserved.

Jump to

Keyboard shortcuts

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