pubgate

package
v1.0.598 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2026 License: MIT Imports: 5 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 pubgate is the publication gate's state (ADR-0064 part D, "When the gate is armed"): whether it is armed, by which activation and why, the segment the promotion came from, and the disarm rule.

Contract

  • Arming records the activation's lineage, the time, the reason, and the promoted-from segment (the lineage this node followed, capped at the version it had applied) when there is one. It also records the diagnostic window (cap, cap + Jump] (R1-L1).
  • Disarm is automatic once every enrolled, non-revoked node has, since the arming, been classified trusted (R1-M8). Accounting is by node ID: a node counts only with a trusted classification seen at or after the arming. With no enrolled node, nothing is pending.
  • The stored form is versioned. A value that does not decode, or an unknown version, is an error: the application decides what an unreadable gate means.

Boundary

A leaf: standard library only, no package state, no init, no goroutine, no clock of its own (times are passed in). The application owns where the gate is stored, when it arms and disarms, which nodes are enrolled, how reports are classified, auditing, and every serving decision built on the gate.

Index

Constants

View Source
const Jump int64 = 1 << 20

Jump is the counter jump an arming makes above every trusted last it knows (ADR-0064 part D, "The version counter"); the diagnostic window's width.

Variables

This section is empty.

Functions

func Encode

func Encode(s State) ([]byte, error)

Encode returns the stored form of s.

Types

type Source

type Source struct {
	Lineage [16]byte
	Cap     int64
}

Source is the segment a promotion came from: the lineage this node followed and the version it had applied (a lower bound of what that leader issued).

type State

type State struct {
	Armed bool
	// Lineage is the activation that armed the gate.
	Lineage [16]byte
	// At is when the gate last armed or disarmed.
	At time.Time
	// Reason is why it last armed or disarmed.
	Reason string
	// Source is the promoted-from segment; nil when the promotion followed no
	// lineage (an empty or resyncing record).
	Source *Source
}

State is the gate's state. The zero value is unarmed.

func Arm

func Arm(l [16]byte, src *Source, reason string, now time.Time) State

Arm returns the state armed by activation l at now for reason, with the promoted-from segment src (nil for none).

func Decode

func Decode(data []byte) (State, error)

Decode parses a stored form.

func Disarm

func Disarm(reason string, now time.Time) State

Disarm returns the unarmed state at now for reason.

func (State) Pending

func (s State) Pending(enrolled []string, trustedAt func(nodeID string) (time.Time, bool)) int

Pending counts the enrolled nodes that block an automatic disarm: those with no trusted classification seen at or after the arming. trustedAt reports when a node was last classified trusted.

func (State) Window

func (s State) Window() (low, high int64, ok bool)

Window is the diagnostic window (cap, cap + Jump] of the promoted-from segment; ok is false when there is none.

Jump to

Keyboard shortcuts

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