sessionkind

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 3 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 sessionkind is the per-run context stamp: the one token a reading bundle and a scribe context each carry, naming the kind of session the context is for, the run it belongs to and a digest of what it holds (adr-2609021016275803, spc-2609020626045177).

It is a LEAF, and that is the reason it exists as a package at all. Two packages read the stamp: core/reading writes it into the bundle, and core/history recognises it in a transcript at capture and checks separation over what it recorded. core/scribe writes it too. None of the three may import another for it — history importing reading would pull the whole assembler into the transcript store — so the grammar lives here, once, and each of them imports this.

The stamp is PER RUN on purpose. A fixed token per kind would sit committed in the documentation and the code, so any session that read either would carry both kinds and be reported in breach, and a session that reached the ledger by another route would carry one and be reported clean; the ADR rejects that mechanism by name. A stamp names one run and a digest, and it is matched exactly, so a session that reads the docs carries none and a transcript carrying the reading stamp of one run and the scribe stamp of another is not a violation.

Index

Constants

View Source
const DigestLen = 12

DigestLen is how many hex digits of the context's sha256 a stamp carries.

View Source
const Prefix = "abcd.context-stamp"

Prefix opens every stamp. It is carried in the documentation, which is why a prefix alone is never a stamp: StampRe requires a kind, a well-formed run and a full digest behind it.

Variables

View Source
var StampRe = regexp.MustCompile(`abcd\.context-stamp/(reading|scribe)/(rdg-[0-9]+)/([0-9a-f]{12})`)

StampRe is the ONE expression that recognises a stamp. Find adds the boundaries RE2 cannot express as lookarounds; every reader goes through Find or Parse rather than this expression bare.

Functions

func Find

func Find(b []byte) []string

Find returns every distinct stamp in b, in first-seen order.

A match counts only between boundaries: the character before it may not continue a name (so `xabcd.context-stamp/...` is not a stamp) and the character after it may not continue the digest or the run (so a thirteenth hex digit, or any letter, disqualifies it). Without the trailing boundary a longer digest would be read as a shorter stamp that is not the one written.

func Stamp

func Stamp(kind Kind, run, sha256Hex string) (string, error)

Stamp renders the stamp for one context: kind, run, and the first DigestLen hex digits of the context's sha256. It refuses a kind outside the closed set, a run that is not a reading run id and a digest that is not hex or is too short to cut, so no caller can mint a stamp Parse would not read back.

Types

type Kind

type Kind string

Kind is the kind of session a context is assembled for. The set is closed.

const (
	Reading Kind = "reading"
	Scribe  Kind = "scribe"
)

The two kinds.

type Parsed

type Parsed struct {
	Kind   Kind
	Run    string
	Digest string
}

Parsed is one stamp taken apart.

func Parse

func Parse(s string) (Parsed, bool)

Parse reads one stamp, exactly: the whole string must be a stamp and nothing else.

Jump to

Keyboard shortcuts

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