pinned

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package pinned is an out-of-band registry of the board records a user has chosen to keep. A pin is a zero-byte marker file at ConfigDir/pinned/<kind>/<id>; it carries no content. The registry is deliberately separate from the record stores (subagent-jobs, teams-history) so the record writers — a board refresh's teamhist.Upsert, the engine's manifest SaveRun, a job's writeMeta — never touch a pin and so can never clobber it. GC and the board consult the registry to skip / mark pinned records; an explicit per-record delete (board `d`) Unpins, and uninstall Purges the whole dir.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pin

func Pin(kind Kind, id string) error

Pin marks (kind,id) as user-kept. Idempotent (re-pinning rewrites the empty marker).

func Purge

func Purge() (string, error)

Purge removes the whole registry dir (cc-fleet uninstall). Returns the dir path so the caller can report it; a missing dir is not an error.

func Unpin

func Unpin(kind Kind, id string) error

Unpin clears (kind,id)'s mark. A missing marker is not an error.

Types

type Kind

type Kind string

Kind namespaces a pin by record type so a job, a run, and a team can share an id without colliding (each lives under its own subdir).

const (
	Job  Kind = "job"
	Run  Kind = "run"
	Team Kind = "team"
)

type Set

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

Set is an in-memory snapshot of the registry — a map lookup so a GC sweep or a board refresh can test many records without one stat per record. The zero Set has no pins (Has always false), so a caller that fails to snapshot degrades safely to "nothing pinned" only where that is the intended fallback.

func Snapshot

func Snapshot() (Set, error)

Snapshot reads the whole registry into a Set. A missing registry (or a missing kind subdir) yields an empty set for that kind — everything reads as unpinned.

func (Set) Has

func (s Set) Has(kind Kind, id string) bool

Has reports whether (kind,id) was pinned when the snapshot was taken.

func (Set) With

func (s Set) With(kind Kind, id string, add bool) Set

With returns a copy of the set with (kind,id) pinned (add=true) or unpinned (add=false). The board applies it optimistically when it dispatches a pin toggle, so two quick presses before the registry write + reload land still alternate instead of both pinning off the same stale snapshot.

Jump to

Keyboard shortcuts

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