protocolsession

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: AGPL-3.0, AGPL-3.0 Imports: 30 Imported by: ? 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 protocolsession implements the authenticated end-to-end session primitives shared by protocol roles. Transport and operation routing remain outside this package so relay identity can never become an authorization input.

Index

Constants

View Source
const (
	EnvelopeNonceBytes        = 12
	EnvelopeHeaderBytes       = 28
	EnvelopeTagBytes          = 16
	EnvelopeOverheadBytes     = EnvelopeHeaderBytes + EnvelopeTagBytes
	MaxEnvelopeBytes          = 65_536
	MaxEnvelopePlaintextBytes = MaxEnvelopeBytes - EnvelopeOverheadBytes
)
View Source
const (
	LaneAttachNonceBytes = 16
	LaneSenderNonceBytes = 16
	LaneHelloBodyBytes   = 4 + 1 + catalog.IdentityBytes + IdentityBytes + 4 + 4 + IdentityBytes + LaneAttachNonceBytes
	LaneHelloBytes       = LaneHelloBodyBytes + sha256.Size
	LaneAcceptBodyBytes  = 4 + 1 + sha256.Size + LaneSenderNonceBytes
	LaneAcceptBytes      = LaneAcceptBodyBytes + ed25519.SignatureSize
	LaneRejectBodyBytes  = 4 + 1 + 1 + 2 + sha256.Size + 4
	LaneRejectBytes      = LaneRejectBodyBytes + ed25519.SignatureSize

	MaxLaneRetryAfter = 30 * time.Second
)
View Source
const (
	LaneGrantTTL            = 30 * time.Second
	LaneGrantTombstoneTTL   = 30 * time.Second
	DefaultMaxLogicalLanes  = 16
	DefaultMaxPendingGrants = 64
)
View Source
const (
	OperationTombstoneLifetime = 30 * time.Second
	// Each logical lane owns bounded control/data queues plus one physical send.
	// A larger count cannot be produced by a conforming runtime.
	MaximumOperationPins = uint32(DefaultMaxLogicalLanes * (ControlQueueFrameLimit + DataQueueFrameLimit + 1))
)
View Source
const (
	OperationScopeDirectory uint8 = 2
	OperationScopeRevision  uint8 = 3
	OperationScopeBlock     uint8 = 4
	OperationScopePeer      uint8 = 5

	PeerOperationCodeNegotiation uint16 = 0x5001
	PeerOperationCodeTimeout     uint16 = 0x5002
	PeerOperationCodeCandidates  uint16 = 0x5003
	PeerOperationCodeAdmission   uint16 = 0x5004

	MaxOperationFailureMessageBytes = 512
	MinOperationFailureRetryAfter   = time.Millisecond
	MaxOperationFailureRetryAfter   = 30 * time.Second
)
View Source
const (
	PeerOperationCodeFirst            uint16 = 0x5000
	PeerOperationCodeLast             uint16 = 0x5fff
	PeerOperationCodeICE              uint16 = 0x5005
	PeerOperationCodeSTUN             uint16 = 0x5006
	PeerOperationCodeTransport        uint16 = 0x5007
	PeerOperationCodeDTLS             uint16 = 0x5008
	PeerOperationCodePolicy           uint16 = 0x5009
	PeerOperationCodeAuthentication   uint16 = 0x500a
	PeerOperationCodeSessionInvariant uint16 = 0x500b
	PeerOperationCodeCapacity         uint16 = 0x500c
)
View Source
const (
	MaxPeerPathControlLifetime  = 120 * time.Second
	MaxPeerPathControlBodyBytes = 256

	MaxPeerProviderProfileBytes = 64
)
View Source
const (
	RouterControlQueueLimit   = 256
	RouterDataQueueLimit      = 1024
	RouterMaximumControlBurst = 8
)
View Source
const (
	SessionTerminalCodeFirst       = uint16(0x1001)
	SessionTerminalCodeLast        = uint16(0x1008)
	MaxSessionTerminalMessageBytes = 512
)
View Source
const (
	WireVersion          = byte(catalog.WireVersionV2)
	HandshakeNonceBytes  = 32
	X25519KeyBytes       = 32
	SessionAuthKeyBytes  = sha256.Size
	TrafficKeyBytes      = sha256.Size
	TranscriptHashBytes  = sha256.Size
	ClientHelloBodySize  = 4 + 1 + catalog.IdentityBytes + IdentityBytes + HandshakeNonceBytes + X25519KeyBytes
	ClientHelloSize      = ClientHelloBodySize + sha256.Size
	ServerHelloBodySize  = 4 + 1 + sha256.Size + HandshakeNonceBytes + X25519KeyBytes + 4 + 4
	ServerHelloSize      = ServerHelloBodySize + ed25519.SignatureSize
	ClientHelloReplayTTL = 5 * time.Minute
)
View Source
const (
	ControlQueueFrameLimit = 256
	ControlQueueByteLimit  = 4 * 1024 * 1024
	DataQueueFrameLimit    = 1024
	DataQueueByteLimit     = 64 * 1024 * 1024
	MaximumDataBurst       = 8
	MaximumControlBurst    = 8
)
View Source
const IdentityBytes = catalog.IdentityBytes
View Source
const MaximumOperationContinuations = 1_024
View Source
const MaximumSendAttemptCauseDetailBytes = 256

Variables

View Source
var (
	ErrControlBinding    = errors.New("sender control signature binding is invalid")
	ErrControlBody       = errors.New("sender control wrapper is invalid")
	ErrControlSemantic   = errors.New("sender control semantic body is invalid")
	ErrControlSignature  = errors.New("sender control signature is invalid")
	ErrControlSigningKey = errors.New("sender control signing key is invalid")
)
View Source
var (
	ErrEnvelopeBinding        = errors.New("operation envelope binding is invalid")
	ErrEnvelopeMalformed      = errors.New("operation envelope is malformed")
	ErrEnvelopeVersion        = errors.New("operation envelope has an unsupported wire version")
	ErrEnvelopeDirection      = errors.New("operation envelope has the wrong direction")
	ErrEnvelopeSequence       = errors.New("operation envelope sequence is not the next expected value")
	ErrEnvelopeAuthentication = errors.New("operation envelope authentication failed")
	ErrEnvelopeTooLarge       = errors.New("operation envelope exceeds the frame limit")
	ErrSequenceExhausted      = errors.New("operation envelope sequence is exhausted")
	ErrNonceSource            = errors.New("operation envelope nonce source failed")
	ErrEnvelopeClosed         = errors.New("operation envelope cryptographic state is closed")
)
View Source
var (
	ErrLaneInput     = errors.New("protocol session lane input is invalid")
	ErrLaneMalformed = errors.New("protocol session lane frame is malformed")
	ErrLaneProof     = errors.New("protocol session lane proof is invalid")
	ErrLaneSignature = errors.New("protocol session lane signature is invalid")
)
View Source
var (
	ErrLaneGrantBudget         = errors.New("protocol session lane grant budget is exhausted")
	ErrLaneEpoch               = errors.New("protocol session lane epoch is exhausted")
	ErrLaneUnknown             = errors.New("protocol session logical lane is unknown")
	ErrLaneStopping            = errors.New("protocol session is stopping")
	ErrLaneSettlementUnclaimed = errors.New("protocol session authenticated lane settlement was not claimed")
)
View Source
var (
	ErrInvalidMessage      = errors.New("protocolsession: invalid message")
	ErrNonCanonicalMessage = errors.New("protocolsession: message is not canonical CBOR")
	ErrUnknownMessageKind  = errors.New("protocolsession: unknown message kind")
	ErrInvalidOperationID  = errors.New("protocolsession: invalid operation identity")
	ErrMessageTooLarge     = errors.New("protocolsession: message exceeds the envelope plaintext limit")
	ErrFragmentHeader      = errors.New("protocolsession: invalid fragment routing header")
)
View Source
var (
	ErrInvalidRole            = errors.New("protocolsession: invalid role")
	ErrInvalidDirection       = errors.New("protocolsession: message kind is invalid for direction")
	ErrUnknownOperation       = errors.New("protocolsession: message refers to an unknown operation")
	ErrOperationIDReused      = errors.New("protocolsession: operation identity was reused")
	ErrUnexpectedOperation    = errors.New("protocolsession: message is invalid for the operation")
	ErrConflictingFinal       = errors.New("protocolsession: operation final conflicts with its tombstone")
	ErrSessionTerminated      = errors.New("protocolsession: session is terminal")
	ErrActiveOperationBudget  = errors.New("protocolsession: active operation budget exhausted")
	ErrTrackedOperationBudget = errors.New("protocolsession: tracked operation budget exhausted")
	ErrOperationPinBudget     = errors.New("protocolsession: operation in-flight pin budget exhausted")
)
View Source
var (
	ErrContinuationContract    = errors.New("protocolsession: operation continuation contract is invalid")
	ErrConflictingContinuation = errors.New("protocolsession: operation continuation conflicts with its contract")
	ErrContinuationPending     = errors.New("protocolsession: operation continuation admission is still pending")
)
View Source
var (
	ErrAuthenticatedOperationViolation        = errors.New("protocolsession: authenticated operation invariant violated")
	ErrInvalidAuthenticatedOperationViolation = errors.New("protocolsession: authenticated operation violation is invalid")
	ErrAuthenticatedOperationObserver         = errors.New("protocolsession: authenticated operation observer is invalid")
)
View Source
var (
	ErrPumpReused            = errors.New("protocolsession: pump Run may only be called once")
	ErrEnvelopeRejected      = errors.New("protocolsession: inbound envelope rejected")
	ErrInboundAuthentication = errors.New("protocolsession: inbound message authentication failed")
	ErrInboundRejected       = errors.New("protocolsession: inbound message rejected")
	ErrPeerSessionTerminal   = errors.New("protocolsession: peer ended the session")
)
View Source
var (
	ErrNilRuntimeDependency = errors.New("protocolsession: runtime dependency must not be nil")
	ErrRouterControlFull    = errors.New("protocolsession: inbound control queue is full")
	ErrRouterDataFull       = errors.New("protocolsession: inbound data queue is full")
	ErrHandlerRegistered    = errors.New("protocolsession: message kind already has a handler")
	ErrHandlerMissing       = errors.New("protocolsession: message kind has no handler")
	ErrInvalidRouteEvent    = errors.New("protocolsession: route event is invalid")
	ErrRouterConsumerBusy   = errors.New("protocolsession: router Next already has a consumer")
)
View Source
var (
	ErrInvalidScanProgress    = errors.New("scan progress body is invalid")
	ErrInvalidSessionTerminal = errors.New("session terminal body is invalid")
)
View Source
var (
	ErrSendAttemptSnapshot = errors.New("protocol session send attempt snapshot is invalid")
	ErrResponseSendResult  = errors.New("protocol session response send result is invalid")
)
View Source
var (
	ErrHandshakeInput          = errors.New("protocol session handshake input is invalid")
	ErrClientHelloMalformed    = errors.New("protocol session client hello is malformed")
	ErrClientHelloProof        = errors.New("protocol session client hello proof is invalid")
	ErrClientHelloReplay       = errors.New("protocol session client hello was already admitted")
	ErrClientHelloReplayBudget = errors.New("protocol session client hello replay budget is exhausted")
	ErrServerHelloMalformed    = errors.New("protocol session server hello is malformed")
	ErrServerHelloSignature    = errors.New("protocol session server hello signature is invalid")
	ErrUnexpectedShare         = errors.New("protocol session hello belongs to another share")
	ErrUnsupportedVersion      = errors.New("protocol session wire version is unsupported")
	ErrKeyLength               = errors.New("protocol session key must be exactly 32 bytes")
	ErrTrafficKeyDirection     = errors.New("protocol session traffic key has the wrong direction")
	ErrKeyAgreement            = errors.New("protocol session X25519 key agreement failed")
)
View Source
var (
	ErrControlQueueFull     = errors.New("protocolsession: control queue capacity exceeded")
	ErrDataQueueFull        = errors.New("protocolsession: data queue capacity exceeded")
	ErrWriterTerminal       = errors.New("protocolsession: writer accepted a terminal message")
	ErrWriterStopped        = errors.New("protocolsession: writer is stopped")
	ErrWriterReused         = errors.New("protocolsession: writer Run may only be called once")
	ErrMessageClass         = errors.New("protocolsession: message submitted to the wrong writer queue")
	ErrSequenceBoundControl = errors.New("protocolsession: sender control must be built with its envelope sequence")
	ErrSequencedBuild       = errors.New("protocolsession: sequenced message builder failed")
	ErrSequencedSize        = errors.New("protocolsession: sequenced message size differs from its reservation")
	ErrSealerSequence       = errors.New("protocolsession: envelope sealer returned a different sequence")
	ErrSealingReservation   = errors.New("protocolsession: reserved delivery lost sealing authority")
	ErrOutboundReplayPermit = errors.New("protocolsession: sender response admission returned no replay permit")
)
View Source
var DefaultRouterLimits = RouterLimits{
	ControlFrames: RouterControlQueueLimit,
	DataFrames:    RouterDataQueueLimit,
}
View Source
var ErrIdentityLength = errors.New("protocol session identity must be exactly 16 bytes")
View Source
var ErrInvalidOperationFailure = errors.New("operation failure body is invalid")
View Source
var ErrPeerPathControl = errors.New("invalid peer path control")

Functions

func ControlSignaturePreimage

func ControlSignaturePreimage(
	domain ControlDomain,
	binding ControlBinding,
	canonicalSemanticBody []byte,
) ([]byte, error)

ControlSignaturePreimage makes every delivery identity explicit. It wraps the typed semantic value before hashing so array and map schemas share one signed delivery contract without admitting signature fields into those schemas.

func EncodeBody

func EncodeBody(value any) ([]byte, error)

EncodeBody produces the deterministic CBOR representation expected by NewMessage. Keeping this helper here lets services share one canonical mode without moving their typed schema into the session runtime.

func EncodeLaneAttachRequest

func EncodeLaneAttachRequest(requestedLaneID uint32) ([]byte, error)

func EncodeLaneGrant

func EncodeLaneGrant(grant LaneGrant) ([]byte, error)

func EncodeMessage

func EncodeMessage(message Message) ([]byte, error)

EncodeMessage returns a copy so callers cannot mutate a queued message after it has passed lifecycle validation.

func EncodeOperationFailure

func EncodeOperationFailure(failure OperationFailure) ([]byte, error)

EncodeOperationFailure owns the cross-service wire schema. Keeping it at the protocol-session boundary prevents a directory operation from depending on a content-only validator that cannot represent its frozen error scope.

func EncodePeerPathControl

func EncodePeerPathControl(control PeerPathControl) ([]byte, error)

func EncodeScanProgress

func EncodeScanProgress(progress ScanProgress) ([]byte, error)

func EncodeSessionTerminal

func EncodeSessionTerminal(terminal SessionTerminal) ([]byte, error)

func EnvelopeFrameSize

func EnvelopeFrameSize(plaintextBytes int) (int, error)

func IsOperationCapacityError

func IsOperationCapacityError(err error) bool

IsOperationCapacityError identifies a retryable refusal before any operation authority or wire delivery exists. Results for admitted operations cannot encounter this condition because admission reserves their retained identity.

func NewLaneAccept

func NewLaneAccept(hello LaneHello, senderNonce []byte, senderPrivateKey ed25519.PrivateKey) ([]byte, error)

func NewLaneReject

func NewLaneReject(hello LaneHello, rejection LaneRejection, senderPrivateKey ed25519.PrivateKey) ([]byte, error)

func ParseLaneAccept

func ParseLaneAccept(encoded []byte, hello LaneHello, sender *senderauth.Verifier) ([]byte, error)

func RetainMessageContext

func RetainMessageContext(lifetime context.Context, messageContext context.Context) context.Context

RetainMessageContext lets asynchronous handlers inherit authenticated values from ingress while their cancellation remains owned by the session/service lifetime. A physical lane ending must not cancel work that can migrate.

func SenderControlSemanticBody

func SenderControlSemanticBody(message Message) ([]byte, error)

SenderControlSemanticBody returns the canonical typed body after the pump has authenticated the delivery wrapper. Business decoders never observe wrapper versioning or the delivery-only signature field.

func SignControlBody

func SignControlBody(
	senderPrivateKey ed25519.PrivateKey,
	domain ControlDomain,
	binding ControlBinding,
	canonicalSemanticBody []byte,
) ([]byte, error)

SignControlBody wraps any canonical semantic CBOR value before signing. The wrapper keeps signature metadata orthogonal to typed map and array schemas.

func ValidateSessionControlBody

func ValidateSessionControlBody(kind MessageKind, body []byte) error

The authenticated outer kind selects the schema. Body versions remain local to each protocol, so a schema revision cannot redirect another control family.

func VerifyControlBody

func VerifyControlBody(
	sender *senderauth.Verifier,
	domain ControlDomain,
	binding ControlBinding,
	canonicalSignedBody []byte,
) ([]byte, error)

VerifyControlBody authenticates the exact unsigned wrapper and returns only its canonical semantic value for typed decoding.

func WithOperationGeneration

func WithOperationGeneration(ctx context.Context, generation OperationGeneration) context.Context

func WithOutboundOperationPermit

func WithOutboundOperationPermit(
	ctx context.Context,
	permit OutboundOperationPermit,
) context.Context

WithOutboundOperationPermit propagates an opaque capability through an async handler boundary. Callers can carry but cannot manufacture its private operation-generation identity.

Types

type AuthenticatedOperationViolation

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

func NewAuthenticatedOperationViolation

func NewAuthenticatedOperationViolation(code AuthenticatedOperationViolationCode) (AuthenticatedOperationViolation, error)

NewAuthenticatedOperationViolation constructs a verified violation value.

func (AuthenticatedOperationViolation) Code

type AuthenticatedOperationViolationCode

type AuthenticatedOperationViolationCode uint8

AuthenticatedOperationViolationCode names facts proved after envelope and sender-control authentication but before ordinary operation dispatch. The value carrying a code is sealed; callers can observe producer facts but cannot manufacture them with a public literal.

const (
	AuthenticatedOperationViolationMalformedFailure AuthenticatedOperationViolationCode = iota + 1
	AuthenticatedOperationViolationMalformedPeerControl
	AuthenticatedOperationViolationConflictingPeerAnswer
	AuthenticatedOperationViolationConflictingFinal
	AuthenticatedOperationViolationContinuationContract
)

type ClientHello

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

func NewClientHello

func NewClientHello(
	share catalog.ShareInstance,
	receiver ReceiverInstanceID,
	receiverNonce []byte,
	receiverPublic *ecdh.PublicKey,
	sessionAuthKey []byte,
) (ClientHello, error)

func (ClientHello) Body

func (h ClientHello) Body() []byte

func (ClientHello) Encoded

func (h ClientHello) Encoded() []byte

func (ClientHello) ReceiverInstanceID

func (h ClientHello) ReceiverInstanceID() ReceiverInstanceID

func (ClientHello) ReceiverNonce

func (h ClientHello) ReceiverNonce() []byte

func (ClientHello) ReceiverPublicKey

func (h ClientHello) ReceiverPublicKey() *ecdh.PublicKey

func (ClientHello) ShareInstance

func (h ClientHello) ShareInstance() catalog.ShareInstance

type ClientHelloReplayGuard

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

ClientHelloReplayGuard owns the atomic admission tombstone. ReceiverInstanceID is intentionally excluded because it is diagnostic and must not let a holder of the share capability replay the same nonce and ephemeral key.

func NewClientHelloReplayGuard

func NewClientHelloReplayGuard(capacity int, now func() time.Time) (*ClientHelloReplayGuard, error)

func (*ClientHelloReplayGuard) AcceptClientHello

func (g *ClientHelloReplayGuard) AcceptClientHello(
	encoded []byte,
	expectedShare catalog.ShareInstance,
	sessionAuthKey []byte,
) (ClientHello, error)

AcceptClientHello makes proof verification and replay admission one atomic sender-side API. Keeping the parser private prevents a future caller from admitting catalog work after authenticating a hello but forgetting its share-scoped replay tombstone.

type ControlBinding

type ControlBinding struct {
	ShareInstance     catalog.ShareInstance
	ProtocolSessionID ProtocolSessionID
	LaneID            uint32
	LaneEpoch         uint32
	Direction         Direction
	Sequence          uint64
	MessageKind       MessageKind
	OperationID       OperationID
	HasOperationID    bool
}

type ControlDomain

type ControlDomain uint8
const (
	ControlDomainOperation ControlDomain = iota + 1
	ControlDomainSessionTerminal
	ControlDomainLaneAttach
	ControlDomainPeerPath
	ControlDomainTURN
)

type Direction

type Direction uint8
const (
	DirectionReceiverToSender Direction = iota
	DirectionSenderToReceiver
)

type EnvelopeBinding

type EnvelopeBinding struct {
	ShareInstance     catalog.ShareInstance
	ProtocolSessionID ProtocolSessionID
	LaneID            uint32
	LaneEpoch         uint32
	Direction         Direction
}

type EnvelopeOpener

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

EnvelopeOpener advances only after AEAD authentication. A forged frame can therefore fail closed without consuming the legitimate sender's sequence.

func NewEnvelopeOpener

func NewEnvelopeOpener(key TrafficKey, binding EnvelopeBinding) (*EnvelopeOpener, error)

func (*EnvelopeOpener) Close

func (o *EnvelopeOpener) Close()

func (*EnvelopeOpener) Destroy

func (o *EnvelopeOpener) Destroy()

Destroy drops the opener's sole AEAD reference and zeroes its visible binding and sequence state. The standard-library AEAD schedule has no zeroization API and is therefore released to GC after this reference is removed.

func (*EnvelopeOpener) NextSequence

func (o *EnvelopeOpener) NextSequence() (uint64, error)

func (*EnvelopeOpener) Open

func (o *EnvelopeOpener) Open(frame []byte) (OpenedEnvelope, error)

func (*EnvelopeOpener) Stop

func (o *EnvelopeOpener) Stop()

Stop is safe at the protocol callback boundary; Destroy remains the lane owner's post-pump join operation.

type EnvelopeSealer

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

EnvelopeSealer is intentionally stateful: one lane writer owns one instance, making sequence assignment and nonce generation impossible to bypass.

func NewEnvelopeSealer

func NewEnvelopeSealer(key TrafficKey, binding EnvelopeBinding, nonceSource io.Reader) (*EnvelopeSealer, error)

func (*EnvelopeSealer) Close

func (s *EnvelopeSealer) Close()

func (*EnvelopeSealer) Destroy

func (s *EnvelopeSealer) Destroy()

Destroy releases every reference and zeroes all directly accessible cryptographic state owned by the sealer. Go's cipher.AEAD does not expose a destructor for its internal AES expanded schedule; clearing aead drops this component's only reference so that opaque schedule becomes garbage-collector managed rather than pretending it was deterministically overwritten.

func (*EnvelopeSealer) NextSequence

func (s *EnvelopeSealer) NextSequence() (uint64, error)

func (*EnvelopeSealer) Seal

func (s *EnvelopeSealer) Seal(plaintext []byte) (SealedEnvelope, error)

func (*EnvelopeSealer) Stop

func (s *EnvelopeSealer) Stop()

Stop freezes future envelope use without touching fields an in-flight writer or pump may still be reading. The lane owner calls Destroy only after those components have joined.

type FrameChannel

type FrameChannel interface {
	Send(ctx context.Context, frame framechannel.Frame) error
	SendTerminal(ctx context.Context, frame framechannel.Frame) error
	Recv() <-chan framechannel.Frame
	State() framechannel.ChannelState
	Close() error
}

FrameChannel is defined where it is consumed. Retaining the parent Frame and ChannelState types keeps transport adapters wire-neutral without importing the old business sessions into this runtime.

type InboundAdmission

type InboundAdmission struct {
	Disposition OperationDisposition
	Generation  OperationGeneration
	Outbound    OutboundOperationPermit
	// contains filtered or unexported fields
}

type InboundAuthenticationResult

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

InboundAuthenticationResult is a sealed result of authenticating one opened message. Its zero value means ordinary authenticated traffic. A non-zero result is consumed by ProtocolPump before generic runtime shutdown.

func (InboundAuthenticationResult) HasOperationViolation

func (result InboundAuthenticationResult) HasOperationViolation() bool

type InboundEnvelopeOpener

type InboundEnvelopeOpener interface {
	Open(frame []byte) (OpenedEnvelope, error)
}

type InboundMessageAuthenticator

type InboundMessageAuthenticator interface {
	AuthenticateInbound(sequence uint64, message Message) (InboundAuthenticationResult, error)
}

InboundMessageAuthenticator verifies authority that AEAD alone cannot grant. In particular, a capability holder knows traffic keys but cannot forge sender control signatures. It runs before operation state or dispatch is touched.

type InboundMessageAuthenticatorFunc

type InboundMessageAuthenticatorFunc func(
	sequence uint64,
	message Message,
) (InboundAuthenticationResult, error)

func (InboundMessageAuthenticatorFunc) AuthenticateInbound

func (authenticate InboundMessageAuthenticatorFunc) AuthenticateInbound(
	sequence uint64,
	message Message,
) (InboundAuthenticationResult, error)

type InboundMessageRouter

type InboundMessageRouter interface {
	RouteInbound(ctx context.Context, message Message) (OperationDisposition, error)
	RouteAuthenticatedOperationViolation(
		context.Context,
		Message,
		AuthenticatedOperationViolation,
	) (bool, error)
	TerminateLocal() error
	InboundDirection() Direction
}

type LaneAdmission

type LaneAdmission struct {
	Disposition     LaneAdmissionDisposition
	SettlementBegan bool
	OperationID     OperationID
	LaneID          uint32
	LaneEpoch       uint32
	Rejection       LaneRejection
	Response        []byte
}

type LaneAdmissionDisposition

type LaneAdmissionDisposition uint8
const (
	LaneAdmissionAccepted LaneAdmissionDisposition = iota + 1
	LaneAdmissionRejected
	LaneAdmissionSilentClose
)

type LaneAdmissionIdentity

type LaneAdmissionIdentity struct {
	LaneID    uint32
	LaneEpoch uint32
}

type LaneAdmissionSettlementGate

type LaneAdmissionSettlementGate interface {
	BeginAuthenticatedSettlement(OperationID, LaneAdmissionIdentity) bool
}

LaneAdmissionSettlementGate transfers terminal authority to the exact connectivity attempt after WS2A authentication and before registry state or signed evidence changes. Implementations must make this a one-shot state transition; false leaves the grant untouched and produces no response.

type LaneAdmissionSettlementGateFunc

type LaneAdmissionSettlementGateFunc func(OperationID, LaneAdmissionIdentity) bool

func (LaneAdmissionSettlementGateFunc) BeginAuthenticatedSettlement

func (function LaneAdmissionSettlementGateFunc) BeginAuthenticatedSettlement(
	operationID OperationID,
	lane LaneAdmissionIdentity,
) bool

type LaneAttachRequest

type LaneAttachRequest struct {
	RequestedLaneID uint32
}

func DecodeLaneAttachRequest

func DecodeLaneAttachRequest(encoded []byte) (LaneAttachRequest, error)

type LaneGrant

type LaneGrant struct {
	LaneID      uint32
	LaneEpoch   uint32
	OperationID OperationID
	AttachNonce [LaneAttachNonceBytes]byte
}

LaneGrant carries the protocol authorization for one channel attachment. OperationID is bound by the enclosing message; expiry remains private to the sender's registry because it is not conveyed to the receiver.

func DecodeLaneGrant

func DecodeLaneGrant(encoded []byte, operationID OperationID) (LaneGrant, error)

type LaneHello

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

func NewLaneHello

func NewLaneHello(share catalog.ShareInstance, session ProtocolSessionID, laneID, laneEpoch uint32, operationID OperationID, attachNonce []byte, receiverToSender TrafficKey) (LaneHello, error)

func ParseLaneHello

func ParseLaneHello(encoded []byte, receiverToSender TrafficKey) (LaneHello, error)

func (LaneHello) AttachNonce

func (h LaneHello) AttachNonce() []byte

func (LaneHello) Encoded

func (h LaneHello) Encoded() []byte

func (LaneHello) LaneEpoch

func (h LaneHello) LaneEpoch() uint32

func (LaneHello) LaneID

func (h LaneHello) LaneID() uint32

func (LaneHello) OperationID

func (h LaneHello) OperationID() OperationID

func (LaneHello) ProtocolSessionID

func (h LaneHello) ProtocolSessionID() ProtocolSessionID

func (LaneHello) ShareInstance

func (h LaneHello) ShareInstance() catalog.ShareInstance

type LaneRegistry

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

func NewLaneRegistry

func NewLaneRegistry(config LaneRegistryConfig) (*LaneRegistry, error)

func (*LaneRegistry) AdmitCandidate

func (r *LaneRegistry) AdmitCandidate(
	encoded,
	senderNonce []byte,
	settlement LaneAdmissionSettlementGate,
) (LaneAdmission, error)

AdmitCandidate returns SilentClose for malformed, unauthenticated, or unclaimed input. A signed response or registry mutation is legal only after the traffic-key proof and the caller's synchronous settlement transition.

func (*LaneRegistry) Close

func (r *LaneRegistry) Close()

func (*LaneRegistry) IssueGrant

func (r *LaneRegistry) IssueGrant(requestedLaneID uint32, operationID OperationID, attachNonce []byte) (LaneGrant, error)

func (*LaneRegistry) Release

func (r *LaneRegistry) Release(laneID, laneEpoch uint32) bool

func (*LaneRegistry) RevokeGrant

func (r *LaneRegistry) RevokeGrant(grant LaneGrant) bool

RevokeGrant removes only the exact grant returned by IssueGrant. LaneEpoch and nonce comparison prevent a delayed sender operation from revoking same-ID work.

func (*LaneRegistry) Stop

func (r *LaneRegistry) Stop()

type LaneRegistryConfig

type LaneRegistryConfig struct {
	ShareInstance     catalog.ShareInstance
	ProtocolSessionID ProtocolSessionID
	ReceiverToSender  TrafficKey
	SenderSigningKey  ed25519.PrivateKey
	InitialLaneID     uint32
	MaxLogicalLanes   int
	MaxPendingGrants  int
	Now               func() time.Time
}

type LaneRejectCode

type LaneRejectCode uint8
const (
	LaneRejectUnknownSession LaneRejectCode = iota + 1
	LaneRejectStaleEpoch
	LaneRejectGrantExpired
	LaneRejectGrantConsumed
	LaneRejectAdmissionLimited
	LaneRejectStopping
	LaneRejectGrantMismatch
)

func (LaneRejectCode) DiagnosticName

func (value LaneRejectCode) DiagnosticName() string

DiagnosticName belongs to the source vocabulary; recorders accept new values.

type LaneRejection

type LaneRejection struct {
	Code       LaneRejectCode
	RetryAfter time.Duration
}

func ParseLaneReject

func ParseLaneReject(encoded []byte, hello LaneHello, sender *senderauth.Verifier) (LaneRejection, error)

type Message

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

Message is an immutable authenticated-plaintext message. Body remains opaque because catalog, revision, and block schemas belong to their business modules. For MessageBlockFragment, Body returns the complete binary fragment plaintext.

func DecodeMessage

func DecodeMessage(plaintext []byte) (Message, error)

DecodeMessage rejects merely decodable CBOR. Re-encoding the typed outer map and the opaque body prevents alternate integers, map order, and indefinite forms from creating multiple authenticated byte representations.

func NewMessage

func NewMessage(kind MessageKind, operationID *OperationID, body []byte) (Message, error)

NewMessage validates an ordinary CBOR message and owns copies of all input. Binary block fragments use DecodeMessage because their operation identity is part of the fixed fragment header rather than the CBOR wrapper.

func (Message) Body

func (m Message) Body() []byte

func (Message) IsData

func (m Message) IsData() bool

func (Message) Kind

func (m Message) Kind() MessageKind

func (Message) OperationID

func (m Message) OperationID() (OperationID, bool)

type MessageHandler

type MessageHandler interface {
	HandleMessage(context.Context, Message) error
}

MessageHandler is deliberately non-transport-facing. A handler should admit work into its own bounded service queue and return promptly; Dispatch is kept outside the sole Recv pump so slow business code cannot capture lane input.

type MessageHandlerFunc

type MessageHandlerFunc func(context.Context, Message) error

func (MessageHandlerFunc) HandleMessage

func (f MessageHandlerFunc) HandleMessage(ctx context.Context, message Message) error

type MessageKind

type MessageKind uint8

MessageKind identifies the operation carried inside an authenticated envelope. Values are wire contract values and therefore intentionally explicit.

const (
	MessageListChildren      MessageKind = 1
	MessageCatalogResult     MessageKind = 2
	MessageOpenRevisions     MessageKind = 3
	MessageOpenResults       MessageKind = 4
	MessageRenewLease        MessageKind = 5
	MessageReleaseLease      MessageKind = 6
	MessageRequestBlocks     MessageKind = 7
	MessageBlockFragment     MessageKind = 8
	MessageCancel            MessageKind = 9
	MessageOperationError    MessageKind = 10
	MessageSessionTerminal   MessageKind = 11
	MessageLaneAttach        MessageKind = 12
	MessageScanProgress      MessageKind = 13
	MessageOperationComplete MessageKind = 14
	MessageLeaseResult       MessageKind = 15
	MessagePeerOffer         MessageKind = 16
	MessagePeerAnswer        MessageKind = 17
	MessagePeerCandidate     MessageKind = 18
	MessagePeerPathControl   MessageKind = 19
	MessageTURNControl       MessageKind = 20
)

func (MessageKind) DiagnosticName

func (value MessageKind) DiagnosticName() string

DiagnosticName belongs to the source vocabulary; recorders accept new values.

type OpenedEnvelope

type OpenedEnvelope struct {
	Sequence  uint64
	Plaintext []byte
}

type OperationCapacityWaitReason

type OperationCapacityWaitReason uint8
const (
	OperationWaitingActiveCapacity OperationCapacityWaitReason = iota + 1
	OperationWaitingRetainedCapacity
)

type OperationContinuationClassifier

type OperationContinuationClassifier interface {
	BeginOperationContinuation(
		requestKind MessageKind,
		canonicalRequestBody []byte,
	) (OperationContinuationContract, bool, error)
	ClassifyUnboundOperationContinuation(
		kind MessageKind,
		canonicalBody []byte,
	) (OperationContinuationScope, bool, error)
}

OperationContinuationClassifier creates the immutable continuation contract for one request generation. The protocol core owns replay state; an injected schema owner only decodes the opaque request and continuation bodies.

type OperationContinuationContract

type OperationContinuationContract interface {
	ClassifyOperationContinuation(
		kind MessageKind,
		canonicalBody []byte,
	) ([sha256.Size]byte, bool, error)
	OperationContinuationScope() OperationContinuationScope
	MaximumContinuations() int
}

OperationContinuationContract validates a continuation against the request that created it and returns its canonical semantic fingerprint. Implementations must be immutable: one contract is shared by the active operation and its tombstone and can be called while either lifecycle state is current.

type OperationContinuationScope

type OperationContinuationScope [sha256.Size]byte

type OperationDisposition

type OperationDisposition uint8

OperationDisposition tells a router whether a valid message is new, an idempotent late arrival, or the authenticated end of the entire session.

const (
	OperationDeliver OperationDisposition = iota
	OperationDrop
	OperationSessionTerminal
)

type OperationFailure

type OperationFailure struct {
	Scope       uint8
	Code        uint16
	Retryable   bool
	RetryAfter  time.Duration
	Message     string
	PeerAttempt *PeerAttemptBinding
}

func DecodeOperationFailure

func DecodeOperationFailure(encoded []byte) (OperationFailure, error)

DecodeOperationFailure is the receive-side authority for signed OPERATION_ERROR semantics. Signature verification proves who sent the bytes; this decoder separately proves that the authenticated value belongs to the frozen schema.

type OperationGeneration

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

OperationGeneration is a comparable opaque identity suitable for async ownership maps. It contains hostile same-ID collisions after bounded retention without making OperationID reuse valid protocol behavior.

func OperationGenerationFromContext

func OperationGenerationFromContext(
	ctx context.Context,
	operationID OperationID,
) (OperationGeneration, bool)

func (OperationGeneration) IsActive

func (generation OperationGeneration) IsActive() bool

IsActive distinguishes executable request authority from a tombstone that is still current only to suppress delayed continuations and cancellation races.

func (OperationGeneration) IsCurrent

func (generation OperationGeneration) IsCurrent() bool

func (OperationGeneration) IsZero

func (generation OperationGeneration) IsZero() bool

func (OperationGeneration) MaximumContinuations

func (generation OperationGeneration) MaximumContinuations() (int, bool)

func (OperationGeneration) PeerAttemptBinding

func (generation OperationGeneration) PeerAttemptBinding() (PeerAttemptBinding, bool)

PeerAttemptBinding returns a copy owned by this opaque generation. A delayed producer cannot borrow the binding of a newer operation with the same ID.

func (OperationGeneration) RegisterAuthenticatedOperationViolationHandler

func (generation OperationGeneration) RegisterAuthenticatedOperationViolationHandler(
	handler func(AuthenticatedOperationViolation),
) error

RegisterAuthenticatedOperationViolationHandler binds one synchronous observer to this exact generation. Pending evidence is retained on operation authority, so a frame that wins the request-delivery/registration race is still observed.

func (OperationGeneration) RequestKind

func (generation OperationGeneration) RequestKind() (MessageKind, bool)

RequestKind reports the initial request semantic only while this exact generation remains active or tombstoned. It lets cancellation dispatch choose one owner without exposing mutable lifecycle state or routing by OperationID.

func (OperationGeneration) Same

func (generation OperationGeneration) Same(other OperationGeneration) bool

type OperationID

type OperationID [IdentityBytes]byte

func OperationIDFromBytes

func OperationIDFromBytes(raw []byte) (OperationID, error)

func (OperationID) Bytes

func (id OperationID) Bytes() []byte

func (OperationID) Equal

func (id OperationID) Equal(other OperationID) bool

func (OperationID) IsZero

func (id OperationID) IsZero() bool

type OperationLimits

type OperationLimits struct {
	MaxActive int
	// MaxTracked bounds retained identities, including the slots reserved by
	// active operations for their eventual completion or cancellation.
	MaxTracked int
}

type OperationTable

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

OperationTable is the cross-lane source of truth for operation identity. Its clock is injectable because tombstone expiry must be deterministic in tests and must not be inferred from relay time.

func NewOperationTable

func NewOperationTable(limits OperationLimits, now func() time.Time) (*OperationTable, error)

func NewOperationTableWithContinuations

func NewOperationTableWithContinuations(
	limits OperationLimits,
	now func() time.Time,
	continuations OperationContinuationClassifier,
) (*OperationTable, error)

func (*OperationTable) AcceptOutboundReplay

func (table *OperationTable) AcceptOutboundReplay(
	direction Direction,
	message Message,
	permit OutboundReplayPermit,
) (OutboundAdmission, error)

AcceptOutboundReplay validates an exact permit without repeating the normal state transition. Final expiry and PeerAnswer multiplicity remain unchanged.

func (*OperationTable) ActiveCount

func (table *OperationTable) ActiveCount() int

func (*OperationTable) AdmitOutbound

func (table *OperationTable) AdmitOutbound(
	direction Direction,
	message Message,
	permit OutboundOperationPermit,
) (OutboundAdmission, error)

AdmitOutbound atomically performs the normal operation transition. Initial receiver requests mint an opaque replay capability so a settled ambiguous send can establish dependency order on a replacement lane; normal duplicate admission still has no path to that capability.

func (*OperationTable) CancelGeneration

func (table *OperationTable) CancelGeneration(generation OperationGeneration) error

CancelGeneration idempotently retires the exact admitted generation. A delayed owner can never retire a newer same-ID call, and session termination already satisfies retirement by revoking all operation authority.

func (*OperationTable) Observe

func (table *OperationTable) Observe(direction Direction, message Message) (OperationDisposition, error)

Observe atomically validates direction, request/response multiplicity, final uniqueness, cancellation races, and the 30-second late-arrival window.

func (*OperationTable) ObserveInbound

func (table *OperationTable) ObserveInbound(direction Direction, message Message) (InboundAdmission, error)

ObserveInbound returns sender response authority in the same critical section that creates or advances the inbound operation. This prevents cancellation or same-ID reuse from changing the generation between observation and minting.

func (*OperationTable) RecordAuthenticatedOperationViolation

func (table *OperationTable) RecordAuthenticatedOperationViolation(
	message Message,
	violation AuthenticatedOperationViolation,
) (bool, error)

RecordAuthenticatedOperationViolation attaches an authenticator-produced fact to the operation authority current at the routing linearization point. A missing/tombstoned observer does not suppress the caller's session shutdown.

func (*OperationTable) TerminateLocal

func (table *OperationTable) TerminateLocal() error

TerminateLocal closes operation admission before a queued terminal reaches a transport. This keeps a slow or blocked Send from leaving a locally terminal session able to accept new cross-lane work.

func (*OperationTable) Terminated

func (table *OperationTable) Terminated() bool

func (*OperationTable) TombstoneCount

func (table *OperationTable) TombstoneCount() int

func (*OperationTable) WaitForCapacity

func (table *OperationTable) WaitForCapacity(ctx context.Context, observe func(OperationCapacityWaitReason)) error

WaitForCapacity waits outside the session's sole reader and writer. Capacity can be contested again before admission; callers must retry only a proven pre-admission capacity refusal, never an ambiguous physical send.

type OutboundAdmission

type OutboundAdmission struct {
	Disposition OperationDisposition
	Generation  OperationGeneration
	Operation   OutboundOperationPermit
	Replay      OutboundReplayPermit
	// contains filtered or unexported fields
}

type OutboundEnvelopeSealer

type OutboundEnvelopeSealer interface {
	NextSequence() (uint64, error)
	Seal(plaintext []byte) (SealedEnvelope, error)
}

OutboundEnvelopeSealer is stateful and belongs exclusively to SessionWriter. NextSequence must preflight nonce acquisition and every other fallible input needed by Seal. This lets the writer validate operation lifecycle after preflight but before consuming a sequence or touching the transport.

type OutboundMessagePolicy

type OutboundMessagePolicy interface {
	AdmitOutbound(message Message, permit OutboundOperationPermit) (OutboundAdmission, error)
	AcceptOutboundReplay(message Message, permit OutboundReplayPermit) (OutboundAdmission, error)
	AcceptOutboundTerminal() error
	OutboundDirection() Direction
}

OutboundMessagePolicy is the narrow lifecycle contract consumed by SessionWriter. It lets a later facade atomically compose routing and writing without exposing FrameChannel to business services.

type OutboundOperationLease

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

func (*OutboundOperationLease) Release

func (lease *OutboundOperationLease) Release()

type OutboundOperationPermit

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

OutboundOperationPermit binds the sender's first response attempt to the exact inbound operation generation that authorized its handler.

func OutboundOperationPermitFromContext

func OutboundOperationPermitFromContext(
	ctx context.Context,
	operationID OperationID,
) (OutboundOperationPermit, bool)

func (OutboundOperationPermit) AcquireLease

func (permit OutboundOperationPermit) AcquireLease() (*OutboundOperationLease, error)

func (OutboundOperationPermit) Generation

func (permit OutboundOperationPermit) Generation() OperationGeneration

func (OutboundOperationPermit) IsZero

func (permit OutboundOperationPermit) IsZero() bool

type OutboundReplayPermit

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

OutboundReplayPermit is an opaque, operation-generation-scoped capability minted only after normal outbound admission.

func (OutboundReplayPermit) IsZero

func (permit OutboundReplayPermit) IsZero() bool

type PeerAttemptBinding

type PeerAttemptBinding struct {
	PeerSlot        uint8
	PeerPathID      [16]byte
	AttemptID       [16]byte
	AttemptSequence uint64
}

PeerAttemptBinding identifies one negotiation. PeerSlot is session-scoped; its sequence survives replacement of the physical PeerPathID.

type PeerAttemptContinuationClassifier

type PeerAttemptContinuationClassifier interface {
	ClassifyPeerAttemptContinuation(MessageKind, []byte) (PeerAttemptBinding, bool, error)
}

PeerAttemptContinuationClassifier supplies schema-validated identities only. Incoming messages may consult an existing retirement boundary, never create it.

type PeerFailureRecoveryScope

type PeerFailureRecoveryScope string
const (
	PeerFailureAttemptTransient PeerFailureRecoveryScope = "attempt-transient"
	PeerFailureResourceDeferred PeerFailureRecoveryScope = "resource-deferred"
	PeerFailurePathTerminal     PeerFailureRecoveryScope = "path-terminal"
	PeerFailureSessionTerminal  PeerFailureRecoveryScope = "session-terminal"
)

func PeerFailureScope

func PeerFailureScope(code uint16) PeerFailureRecoveryScope

PeerFailureScope grants recovery authority only to known typed reasons. Text and Retryable never revive an operation, and an unknown reason cannot confer session termination authority or an automatic retry.

type PeerPathControl

type PeerPathControl struct {
	PeerPathID          [IdentityBytes]byte
	NetworkGenerationID [IdentityBytes]byte
	ControlSequence     uint64
	Kind                PeerPathControlKind
	ValidFor            time.Duration
	HoldFor             time.Duration
	// ProviderProfile is an opaque local implementation evidence identity.
	// Connectivity interprets it; the protocol never grants a transport capability.
	ProviderProfile string
}

PeerPathControl has session authority, never negotiation-operation authority. Durations are relative to authenticated receipt, avoiding remote clock trust.

func DecodePeerPathControl

func DecodePeerPathControl(body []byte) (PeerPathControl, error)

type PeerPathControlKind

type PeerPathControlKind uint8
const (
	PeerPathDemand PeerPathControlKind = iota + 1
	PeerPathRevoke
	PeerPathMappingReady
	PeerPathNetworkChanged
)

type PeerSessionTerminalError

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

PeerSessionTerminalError retains the authenticated message for a caller that needs to decode a diagnostic while still supporting errors.Is classification.

func (*PeerSessionTerminalError) Error

func (terminal *PeerSessionTerminalError) Error() string

func (*PeerSessionTerminalError) Message

func (terminal *PeerSessionTerminalError) Message() Message

func (*PeerSessionTerminalError) Unwrap

func (terminal *PeerSessionTerminalError) Unwrap() error

type PreparedSenderControl

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

PreparedSenderControl contains a fixed-size callback rather than signed bytes. Only SessionWriter can invoke it, after it owns the next envelope sequence. This prevents a caller from signing a guessed sequence and later emitting the control under a different delivery identity.

func PrepareSenderControl

func PrepareSenderControl(
	senderPrivateKey ed25519.PrivateKey,
	base ControlBinding,
	kind MessageKind,
	operationID *OperationID,
	canonicalSemanticBody []byte,
) (PreparedSenderControl, error)

PrepareSenderControl validates and copies every caller-owned input but defers signing until SessionWriter supplies the sequence it will immediately seal.

type ProtocolPump

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

func NewProtocolPump

func NewProtocolPump(
	channel FrameChannel,
	opener InboundEnvelopeOpener,
	authenticator InboundMessageAuthenticator,
	router InboundMessageRouter,
) (*ProtocolPump, error)

func (*ProtocolPump) Run

func (pump *ProtocolPump) Run(ctx context.Context) error

Run acquires Recv exactly once and never exposes it to business code. The injected opener owns replay/sequence validation before any message allocation or operation transition is admitted.

type ProtocolSessionID

type ProtocolSessionID [IdentityBytes]byte

func ProtocolSessionIDFromBytes

func ProtocolSessionIDFromBytes(raw []byte) (ProtocolSessionID, error)

func UntrustedLaneHelloRoute

func UntrustedLaneHelloRoute(encoded []byte) (catalog.ShareInstance, ProtocolSessionID, error)

UntrustedLaneHelloRoute extracts only the identities needed to select the candidate ProtocolSession. Callers must not authorize or answer from this result: LaneRegistry.AdmitCandidate performs the traffic-key proof before any signed response or resource admission is legal.

func (ProtocolSessionID) Bytes

func (id ProtocolSessionID) Bytes() []byte

func (ProtocolSessionID) Equal

func (id ProtocolSessionID) Equal(other ProtocolSessionID) bool

func (ProtocolSessionID) IsZero

func (id ProtocolSessionID) IsZero() bool

type ReceiverInstanceID

type ReceiverInstanceID [IdentityBytes]byte

func ReceiverInstanceIDFromBytes

func ReceiverInstanceIDFromBytes(raw []byte) (ReceiverInstanceID, error)

func (ReceiverInstanceID) Bytes

func (id ReceiverInstanceID) Bytes() []byte

func (ReceiverInstanceID) Equal

func (id ReceiverInstanceID) Equal(other ReceiverInstanceID) bool

func (ReceiverInstanceID) IsZero

func (id ReceiverInstanceID) IsZero() bool

type ResponseSendEnd

type ResponseSendEnd uint8
const (
	ResponseSendEndUninitialized ResponseSendEnd = iota
	ResponseSendEndPreparationFailed
	ResponseSendEndRouteUnavailable
	ResponseSendEndAuthorityUnavailable
	ResponseSendEndTransportConfirmed
	ResponseSendEndPolicySuppressed
	ResponseSendEndCallerCanceled
	ResponseSendEndDeadlineExceeded
	ResponseSendEndRuntimeStopped
	ResponseSendEndRetryDisallowed
	ResponseSendEndNoUsableLane
	ResponseSendEndAttemptsExhausted
	ResponseSendEndAuthorityLost
	ResponseSendEndInvalidReceipt
)

func (ResponseSendEnd) DiagnosticName

func (value ResponseSendEnd) DiagnosticName() string

DiagnosticName belongs to the source vocabulary; recorders accept new values.

type ResponseSendEvidence

type ResponseSendEvidence uint8

ResponseSendEvidence summarizes every physical attempt, independently of why the caller returned or whether cleanup succeeded.

const (
	ResponseSendEvidenceUninitialized ResponseSendEvidence = iota
	ResponseSendEvidenceDefinitelyNotSent
	ResponseSendEvidenceUncertain
	ResponseSendEvidenceTransportConfirmed
)

func FoldResponseSendEvidence

func FoldResponseSendEvidence(attempts []SendAttemptSnapshot) (ResponseSendEvidence, error)

FoldResponseSendEvidence preserves prior uncertainty even when a later attempt is suppressed. Validation continues after confirmation so malformed history cannot acquire a successful business meaning through a short circuit.

func (ResponseSendEvidence) DiagnosticName

func (value ResponseSendEvidence) DiagnosticName() string

DiagnosticName belongs to the source vocabulary; recorders accept new values.

type ResponseSendResult

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

ResponseSendResult owns bounded inline history so neither the caller's input slice nor a later receipt settlement can mutate an already returned result.

func NewResponseSendNotStarted

func NewResponseSendNotStarted(end ResponseSendEnd) (ResponseSendResult, error)

func NewResponseSendReturned

func NewResponseSendReturned(end ResponseSendEnd, attempts []SendAttemptSnapshot) (ResponseSendResult, error)

func NewResponseSendWaitingEnded

func NewResponseSendWaitingEnded(end ResponseSendEnd, attempts []SendAttemptSnapshot) (ResponseSendResult, error)

func (ResponseSendResult) Attempt

func (result ResponseSendResult) Attempt(index int) (SendAttemptSnapshot, bool)

func (ResponseSendResult) AttemptCount

func (result ResponseSendResult) AttemptCount() int

func (ResponseSendResult) Cleanup

func (result ResponseSendResult) Cleanup() SendCleanupKind

func (ResponseSendResult) DiagnosticValue

func (value ResponseSendResult) DiagnosticValue() diag.Value

func (ResponseSendResult) End

func (result ResponseSendResult) End() ResponseSendEnd

func (ResponseSendResult) Evidence

func (result ResponseSendResult) Evidence() ResponseSendEvidence

func (ResponseSendResult) IsZero

func (result ResponseSendResult) IsZero() bool

func (ResponseSendResult) PendingAttempt

func (result ResponseSendResult) PendingAttempt() (SendAttemptIdentity, bool)

func (ResponseSendResult) Started

func (result ResponseSendResult) Started() bool

func (ResponseSendResult) WithCleanup

func (result ResponseSendResult) WithCleanup(cleanup SendCleanupKind) ResponseSendResult

WithCleanup cannot change physical evidence. Invalid cleanup values fail closed to an uninitialized result instead of creating a diagnostic enum that downstream consumers could mistake for a successful cleanup.

type Role

type Role uint8

Role determines, rather than merely documents, the only directions a runtime may receive and send. This prevents accidentally wiring two receiver halves.

const (
	RoleReceiver Role = iota
	RoleSender
)

func (Role) DiagnosticName

func (value Role) DiagnosticName() string

DiagnosticName belongs to the source vocabulary; recorders accept new values.

func (Role) InboundDirection

func (role Role) InboundDirection() (Direction, error)

func (Role) OutboundDirection

func (role Role) OutboundDirection() (Direction, error)

type RoleRouter

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

RoleRouter owns bounded dispatch queues. RouteInbound never invokes business code, so even a stopped data consumer cannot capture the sole Recv pump.

func NewRoleRouter

func NewRoleRouter(role Role, operations *OperationTable) (*RoleRouter, error)

func NewRoleRouterWithLimits

func NewRoleRouterWithLimits(
	role Role,
	operations *OperationTable,
	limits RouterLimits,
) (*RoleRouter, error)

func (*RoleRouter) AcceptOutboundReplay

func (router *RoleRouter) AcceptOutboundReplay(
	message Message,
	permit OutboundReplayPermit,
) (OutboundAdmission, error)

func (*RoleRouter) AcceptOutboundTerminal

func (router *RoleRouter) AcceptOutboundTerminal() error

func (*RoleRouter) AdmitOutbound

func (router *RoleRouter) AdmitOutbound(
	message Message,
	permit OutboundOperationPermit,
) (OutboundAdmission, error)

func (*RoleRouter) Close

func (router *RoleRouter) Close()

Close is the quiescent ownership boundary used after ingress pumps and the sole dispatch consumer have joined. It releases queued message contexts and handler references before a runtime publishes Done.

func (*RoleRouter) Dispatch

func (router *RoleRouter) Dispatch(ctx context.Context, event RouteEvent) error

Dispatch resolves one already-authenticated bounded RouteEvent. Keeping this explicit lets a session facade choose worker ownership without creating a hidden goroutine or allowing handlers to compete with Control/Data consumers.

func (*RoleRouter) InboundDirection

func (router *RoleRouter) InboundDirection() Direction

func (*RoleRouter) Next

func (router *RoleRouter) Next(ctx context.Context) (RouteEvent, error)

Next gives dispatchers the same control-first rule as the writer. Separate bounded queues keep data pressure from blocking pump admission; this method keeps a consumer from accidentally undoing that guarantee with a fair select.

func (*RoleRouter) OutboundDirection

func (router *RoleRouter) OutboundDirection() Direction

func (*RoleRouter) RegisterHandler

func (router *RoleRouter) RegisterHandler(kind MessageKind, handler MessageHandler) error

func (*RoleRouter) RouteAuthenticatedOperationViolation

func (router *RoleRouter) RouteAuthenticatedOperationViolation(
	_ context.Context,
	message Message,
	violation AuthenticatedOperationViolation,
) (bool, error)

func (*RoleRouter) RouteInbound

func (router *RoleRouter) RouteInbound(
	ctx context.Context,
	message Message,
) (OperationDisposition, error)

func (*RoleRouter) TerminateLocal

func (router *RoleRouter) TerminateLocal() error

type RouteEvent

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

RouteEvent is immutable. An overflow event has ErrRouterDataFull and only an operation identity; a normal event has a Message and nil Error.

func (RouteEvent) Error

func (event RouteEvent) Error() error

func (RouteEvent) Message

func (event RouteEvent) Message() (Message, bool)

func (RouteEvent) OperationID

func (event RouteEvent) OperationID() OperationID

type RouterLimits

type RouterLimits struct {
	ControlFrames int
	DataFrames    int
}

RouterLimits permits lower local admission limits without changing wire limits. The default mirrors the writer's frame-count isolation.

type ScanProgress

type ScanProgress struct {
	AttemptID         catalog.ScanAttemptID
	DiscoveredEntries uint64
}

func DecodeScanProgress

func DecodeScanProgress(encoded []byte) (ScanProgress, error)

type SealedEnvelope

type SealedEnvelope struct {
	Sequence uint64
	Frame    []byte
}

type SendAttemptCause

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

func (SendAttemptCause) Detail

func (cause SendAttemptCause) Detail() string

func (SendAttemptCause) Kind

func (SendAttemptCause) Truncated

func (cause SendAttemptCause) Truncated() bool

type SendAttemptCauseKind

type SendAttemptCauseKind uint8

SendAttemptCause preserves the reason for an earlier failure even when a later retry succeeds and the response returns no operational error.

const (
	SendAttemptCauseNone SendAttemptCauseKind = iota
	SendAttemptCauseCanceled
	SendAttemptCauseDeadline
	SendAttemptCauseControlQueueFull
	SendAttemptCauseDataQueueFull
	SendAttemptCauseWriterStopped
	SendAttemptCauseWriterTerminal
	SendAttemptCauseTransportFailure
	SendAttemptCausePreparationFailure
	SendAttemptCauseAdmissionFailure
)

func (SendAttemptCauseKind) DiagnosticName

func (value SendAttemptCauseKind) DiagnosticName() string

DiagnosticName belongs to the source vocabulary; recorders accept new values.

type SendAttemptCorrelation

type SendAttemptCorrelation struct {
	ProtocolSessionID ProtocolSessionID
	OperationID       OperationID
	RequestKind       MessageKind
	ResponseKind      MessageKind
	Identity          SendAttemptIdentity
}

type SendAttemptEnd

type SendAttemptEnd uint8
const (
	SendAttemptEndUninitialized SendAttemptEnd = iota
	SendAttemptEndRejectedBeforeReceipt
	SendAttemptEndSettled
	SendAttemptEndWaitingEnded
)

func (SendAttemptEnd) DiagnosticName

func (value SendAttemptEnd) DiagnosticName() string

DiagnosticName belongs to the source vocabulary; recorders accept new values.

type SendAttemptIdentity

type SendAttemptIdentity struct {
	ResponseSequence uint64
	AttemptSequence  uint32
	LaneID           uint32
	LaneEpoch        uint32
}

SendAttemptIdentity pins the lane before execution. Route migration must not rewrite the identity of an attempt whose transport already owns the frame.

type SendAttemptSettlement

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

SendAttemptSettlement supplements an earlier return snapshot. It does not revise that result or retain any capability to continue its operation.

func (SendAttemptSettlement) Attempt

func (settlement SendAttemptSettlement) Attempt() SendAttemptSnapshot

func (SendAttemptSettlement) Correlation

func (settlement SendAttemptSettlement) Correlation() SendAttemptCorrelation

func (SendAttemptSettlement) ObservedAt

func (settlement SendAttemptSettlement) ObservedAt() time.Time

type SendAttemptSnapshot

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

SendAttemptSnapshot deliberately contains no operation, replay, lease, error or body references. Copies remain factual values after execution releases its authority and after a pending receipt eventually settles.

func NewPendingSendAttempt

func NewPendingSendAttempt(id SendAttemptIdentity, completion SendCompletion) (SendAttemptSnapshot, error)

func NewRejectedSendAttempt

func NewRejectedSendAttempt(id SendAttemptIdentity, cause error) (SendAttemptSnapshot, error)

func NewSettledSendAttempt

func NewSettledSendAttempt(id SendAttemptIdentity, completion SendCompletion) (SendAttemptSnapshot, error)

func (SendAttemptSnapshot) Cause

func (attempt SendAttemptSnapshot) Cause() SendAttemptCause

func (SendAttemptSnapshot) DiagnosticValue

func (value SendAttemptSnapshot) DiagnosticValue() diag.Value

func (SendAttemptSnapshot) End

func (attempt SendAttemptSnapshot) End() SendAttemptEnd

func (SendAttemptSnapshot) Identity

func (attempt SendAttemptSnapshot) Identity() SendAttemptIdentity

func (SendAttemptSnapshot) IsZero

func (attempt SendAttemptSnapshot) IsZero() bool

func (SendAttemptSnapshot) Outcome

func (attempt SendAttemptSnapshot) Outcome() SendOutcome

func (SendAttemptSnapshot) PolicyAdmitted

func (attempt SendAttemptSnapshot) PolicyAdmitted() bool

func (SendAttemptSnapshot) Settled

func (attempt SendAttemptSnapshot) Settled() bool

func (SendAttemptSnapshot) TransportDisposition

func (attempt SendAttemptSnapshot) TransportDisposition() framechannel.SendDisposition

type SendCleanupKind

type SendCleanupKind uint8
const (
	SendCleanupNone SendCleanupKind = iota
	SendCleanupRouteReleased
	SendCleanupOperationRetired
	SendCleanupFailed
)

func (SendCleanupKind) DiagnosticName

func (value SendCleanupKind) DiagnosticName() string

DiagnosticName belongs to the source vocabulary; recorders accept new values.

type SendCompletion

type SendCompletion struct {
	Settled             bool
	Admitted            bool
	Outcome             SendOutcome
	Generation          OperationGeneration
	Operation           OutboundOperationPermit
	Replay              OutboundReplayPermit
	RetryableAcrossLane bool
	// Zero means preparation failed before the channel boundary; nonzero records
	// the adapter's exact ownership decision for this physical send.
	TransportDisposition framechannel.SendDisposition
	Err                  error
	// contains filtered or unexported fields
}

type SendOutcome

type SendOutcome uint8

SendOutcome distinguishes transport acceptance from proven pre-transport suppression. Dropped means the transport did not acquire the frame; Unknown cannot prove peer observation and may be either an unsettled caller timeout or a settled physical error, as distinguished by SendCompletion.Settled.

const (
	SendOutcomeUninitialized SendOutcome = iota
	SendOutcomeUnknown
	SendOutcomeTransportConfirmed
	SendOutcomeDropped
)

func (SendOutcome) DiagnosticName

func (value SendOutcome) DiagnosticName() string

DiagnosticName belongs to the source vocabulary; recorders accept new values.

type SendReceipt

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

SendReceipt reports actual transport acceptance independently of nonblocking queue admission. Await owns cancellation of a not-yet-admitted item, so callers must not use concurrent waiters with different cancellation intent. Repeated observation after settlement remains safe and returns the stored completion.

func (SendReceipt) Admitted

func (receipt SendReceipt) Admitted() bool

Admitted reports whether operation policy has already committed this exact message. It is primarily useful for idempotent CANCEL, whose local lifecycle completion must not wait for best-effort wire delivery.

func (SendReceipt) Await

func (receipt SendReceipt) Await(ctx context.Context) SendCompletion

Await atomically retracts an item while the writer can still abandon it without consuming wire sequence. Once sealing begins or operation policy admits the message, cancellation can no longer prove a pre-transport drop; the caller receives an unsettled Unknown completion while the writer publishes the result.

func (SendReceipt) Done

func (receipt SendReceipt) Done() <-chan struct{}

func (SendReceipt) ObserveSettlement

func (receipt SendReceipt) ObserveSettlement(
	correlation SendAttemptCorrelation,
	producer observationstream.Producer[SendAttemptSettlement],
) bool

ObserveSettlement registers at most once, including when completion raced ahead of registration. The return value reports registration ownership, not queue admission: exhausted observation capacity cannot affect send behavior.

func (SendReceipt) ReleaseLeaseOnSettlement

func (receipt SendReceipt) ReleaseLeaseOnSettlement(lease *OutboundOperationLease)

ReleaseLeaseOnSettlement transfers a generation lease from a caller that can no longer wait to the writer's eventual physical completion.

func (SendReceipt) Wait

func (receipt SendReceipt) Wait(ctx context.Context) (SendOutcome, error)

type SenderControlAuthenticator

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

SenderControlAuthenticator is receiver-side proof that traffic-key authority did not substitute for sender-key authority. Its lane binding is fixed at construction; only the opener-authenticated sequence and decoded message vary.

func (*SenderControlAuthenticator) AuthenticateInbound

func (a *SenderControlAuthenticator) AuthenticateInbound(
	sequence uint64,
	message Message,
) (InboundAuthenticationResult, error)

func (*SenderControlAuthenticator) Verify

func (a *SenderControlAuthenticator) Verify(sequence uint64, message Message) error

Verify permits binary block fragments to proceed to their object verifier; every other sender-to-receiver message must carry a valid sender signature.

type SenderControlSemanticRegistry

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

func NewSenderControlSemanticRegistry

func NewSenderControlSemanticRegistry(
	rules ...SenderControlSemanticRule,
) (*SenderControlSemanticRegistry, error)

func (*SenderControlSemanticRegistry) ValidateSenderControl

func (registry *SenderControlSemanticRegistry) ValidateSenderControl(
	kind MessageKind,
	operationID OperationID,
	semantic []byte,
) error

type SenderControlSemanticRule

type SenderControlSemanticRule struct {
	Kind     MessageKind
	Validate SenderControlSemanticValidatorFunc
}

SenderControlSemanticRule binds one signed sender control kind to its typed decoder. Keeping this registry at the authentication boundary prevents a new final kind from silently bypassing semantic validation before routing.

type SenderControlSemanticValidator

type SenderControlSemanticValidator interface {
	ValidateSenderControl(MessageKind, OperationID, []byte) error
}

type SenderControlSemanticValidatorFunc

type SenderControlSemanticValidatorFunc func(MessageKind, OperationID, []byte) error

func (SenderControlSemanticValidatorFunc) ValidateSenderControl

func (validate SenderControlSemanticValidatorFunc) ValidateSenderControl(
	kind MessageKind,
	operationID OperationID,
	semantic []byte,
) error

type ServerHello

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

func NewServerHello

func NewServerHello(
	client ClientHello,
	senderNonce []byte,
	senderPublic *ecdh.PublicKey,
	initialLaneID uint32,
	senderSigningKey ed25519.PrivateKey,
) (ServerHello, error)

func ParseServerHello

func ParseServerHello(encoded []byte, client ClientHello, sender *senderauth.Verifier) (ServerHello, error)

func (ServerHello) Body

func (h ServerHello) Body() []byte

func (ServerHello) Encoded

func (h ServerHello) Encoded() []byte

func (ServerHello) InitialLaneEpoch

func (h ServerHello) InitialLaneEpoch() uint32

func (ServerHello) InitialLaneID

func (h ServerHello) InitialLaneID() uint32

func (ServerHello) SenderNonce

func (h ServerHello) SenderNonce() []byte

func (ServerHello) SenderPublicKey

func (h ServerHello) SenderPublicKey() *ecdh.PublicKey

type SessionKeys

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

func DeriveReceiverSession

func DeriveReceiverSession(
	receiverPrivate *ecdh.PrivateKey,
	sessionAuthKey []byte,
	client ClientHello,
	server ServerHello,
) (SessionKeys, error)

func DeriveSenderSession

func DeriveSenderSession(
	senderPrivate *ecdh.PrivateKey,
	sessionAuthKey []byte,
	client ClientHello,
	server ServerHello,
) (SessionKeys, error)

func (*SessionKeys) Destroy

func (k *SessionKeys) Destroy()

func (SessionKeys) ProtocolSessionID

func (k SessionKeys) ProtocolSessionID() ProtocolSessionID

func (SessionKeys) ReceiverToSender

func (k SessionKeys) ReceiverToSender() TrafficKey

func (SessionKeys) SenderToReceiver

func (k SessionKeys) SenderToReceiver() TrafficKey

func (SessionKeys) TranscriptHash

func (k SessionKeys) TranscriptHash() TranscriptHash

type SessionTerminal

type SessionTerminal struct {
	Code    uint16
	Message string
}

func DecodeSessionTerminal

func DecodeSessionTerminal(encoded []byte) (SessionTerminal, error)

type SessionWriter

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

func NewSessionWriter

func NewSessionWriter(
	channel FrameChannel,
	sealer OutboundEnvelopeSealer,
	policy OutboundMessagePolicy,
) (*SessionWriter, error)

func (*SessionWriter) Accepting

func (writer *SessionWriter) Accepting() bool

Accepting reports whether this writer can still acquire a new message lifecycle. It closes the gap where terminal acceptance or Run completion has changed writer authority before an owning lane publishes its closing state.

func (*SessionWriter) Done

func (writer *SessionWriter) Done() <-chan struct{}

func (*SessionWriter) Err

func (writer *SessionWriter) Err() error

func (*SessionWriter) Run

func (writer *SessionWriter) Run(ctx context.Context) error

Run is the only code path that calls Send or SendTerminal. A second call is rejected before it can create a competing transport writer.

func (*SessionWriter) TryAuthorizedControl

func (writer *SessionWriter) TryAuthorizedControl(
	message Message,
	authority OutboundOperationPermit,
) (SendReceipt, error)

func (*SessionWriter) TryAuthorizedData

func (writer *SessionWriter) TryAuthorizedData(
	message Message,
	authority OutboundOperationPermit,
) (SendReceipt, error)

func (*SessionWriter) TryAuthorizedSenderControl

func (writer *SessionWriter) TryAuthorizedSenderControl(
	control PreparedSenderControl,
	authority OutboundOperationPermit,
) (SendReceipt, error)

func (*SessionWriter) TryControl

func (writer *SessionWriter) TryControl(message Message) (SendReceipt, error)

func (*SessionWriter) TryControlObservingAuthenticatedViolations

func (writer *SessionWriter) TryControlObservingAuthenticatedViolations(
	message Message,
	handler func(AuthenticatedOperationViolation),
) (SendReceipt, error)

TryControlObservingAuthenticatedViolations installs the exact-generation observer after operation admission but before the writer seals or exposes the request to the transport. The peer therefore cannot answer in the gap between generation creation and observer registration.

func (*SessionWriter) TryControlReplay

func (writer *SessionWriter) TryControlReplay(
	message Message,
	permit OutboundReplayPermit,
) (SendReceipt, error)

TryControlReplay queues the exact initial receiver request authorized by an ambiguous settled send before dependent controls on a replacement lane.

func (*SessionWriter) TryData

func (writer *SessionWriter) TryData(message Message) (SendReceipt, error)

func (*SessionWriter) TryDataReplay

func (writer *SessionWriter) TryDataReplay(
	message Message,
	permit OutboundReplayPermit,
) (SendReceipt, error)

TryDataReplay carries the identical authenticated operation fragment over a replacement lane after an ambiguous or proven pre-transport failure.

func (*SessionWriter) TrySenderControl

func (writer *SessionWriter) TrySenderControl(control PreparedSenderControl) (SendReceipt, error)

TrySenderControl is the only sender-to-receiver control admission path. The prepared callback signs inside the writer goroutine with the exact sequence read immediately before envelope sealing.

func (*SessionWriter) TrySenderControlReplay

func (writer *SessionWriter) TrySenderControlReplay(
	control PreparedSenderControl,
	permit OutboundReplayPermit,
) (SendReceipt, error)

TrySenderControlReplay rebuilds one previously attempted semantic response with this writer's lane binding and sequence. Operation policy admits only an exact permit for the same operation generation and canonical fingerprint.

type TrafficKey

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

TrafficKey carries its derivation direction so the two transcript keys cannot be interchanged at a lane boundary. Direction in envelope AAD detects a peer mismatch, but rejecting the mistake locally avoids emitting an undecryptable first frame and consuming the lane sequence.

func TrafficKeyFromBytes

func TrafficKeyFromBytes(raw []byte, direction Direction) (TrafficKey, error)

func (TrafficKey) Bytes

func (k TrafficKey) Bytes() []byte

func (*TrafficKey) Destroy

func (k *TrafficKey) Destroy()

func (TrafficKey) Equal

func (k TrafficKey) Equal(other TrafficKey) bool

type TranscriptHash

type TranscriptHash [TranscriptHashBytes]byte

func (TranscriptHash) Bytes

func (h TranscriptHash) Bytes() []byte

func (TranscriptHash) Equal

func (h TranscriptHash) Equal(other TranscriptHash) bool

Jump to

Keyboard shortcuts

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