promptlearning

package
v0.2.0-beta.9 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package promptlearning contains the pure admission, sanitization, and fingerprinting boundary for prompt-learning samples. It deliberately has no persistence, transport, worker, relay, credential, or logging dependencies.

Index

Constants

View Source
const (
	DefaultMaxTextBytes = 64 * 1024
	MaxTextBytesLimit   = 1024 * 1024

	TextPolicyVersion        = "nfkc-lf-tab-cf-reject-v4"
	RedactionPolicyVersion   = "redaction-context-state-machine-v6"
	FingerprintPolicyVersion = "hmac-sha256-v2"
	OccurrencePolicyVersion  = "occurrence-v2"
)

Variables

View Source
var ErrInvalidConfig = errors.New("invalid prompt-learning kernel configuration")

Functions

This section is empty.

Types

type Confidence

type Confidence string

Confidence determines how a caller may use a reviewed sample. Trusted means only that a future persistence layer may attempt a unique occurrence insert; the kernel never declares an occurrence counted.

const (
	ConfidenceTrusted  Confidence = "trusted"
	ConfidenceMedium   Confidence = "medium"
	ConfidenceLow      Confidence = "low"
	ConfidenceRejected Confidence = "rejected"
)

type Config

type Config struct {
	ActiveKey    HMACKeyVersion
	RetiredKeys  []HMACKeyVersion
	MaxTextBytes int
}

type ExcludedContent

type ExcludedContent string

ExcludedContent identifies material that must never become a learning sample.

const (
	ContentHistory      ExcludedContent = "history"
	ContentSystem       ExcludedContent = "system"
	ContentDeveloper    ExcludedContent = "developer"
	ContentAssistant    ExcludedContent = "assistant"
	ContentTool         ExcludedContent = "tool"
	ContentAttachment   ExcludedContent = "attachment"
	ContentResponse     ExcludedContent = "response"
	ContentInternalTask ExcludedContent = "internal_task"
	ContentAutoAnalysis ExcludedContent = "automatic_analysis"
)

type HMACKeyVersion

type HMACKeyVersion struct {
	Version      string
	TransportKey []byte
	SemanticKey  []byte
}

HMACKeyVersion is one version of two domain-specific fingerprint keys. Key material is copied by NewKernel and is never returned by this package.

type Kernel

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

Kernel is immutable after construction and safe for concurrent use.

func NewKernel

func NewKernel(config Config) (*Kernel, error)

type Reason

type Reason string

Reason is deliberately machine-readable and never includes submitted text.

const (
	ReasonAcceptedLiveUserTurn    Reason = "accepted_live_user_turn"
	ReasonAcceptedTrustedImport   Reason = "accepted_trusted_import"
	ReasonAcceptedLegacyCandidate Reason = "accepted_legacy_candidate"
	ReasonAcceptedUntrustedClaim  Reason = "accepted_untrusted_candidate"
	ReasonUntrustedOriginClaim    Reason = "untrusted_origin_claim"
	ReasonHistoricalContent       Reason = "historical_content"
	ReasonSystemContent           Reason = "system_content"
	ReasonDeveloperContent        Reason = "developer_content"
	ReasonAssistantContent        Reason = "assistant_content"
	ReasonToolContent             Reason = "tool_content"
	ReasonAttachmentContent       Reason = "attachment_content"
	ReasonResponseContent         Reason = "response_content"
	ReasonInternalContent         Reason = "internal_content"
	ReasonInvalidCandidate        Reason = "invalid_candidate"
	ReasonInvalidProvenance       Reason = "invalid_provenance"
	ReasonTextTooLarge            Reason = "text_too_large"
	ReasonInvalidUTF8             Reason = "invalid_utf8"
	ReasonUnsupportedControl      Reason = "unsupported_control_character"
	ReasonUnsafeUnicodeFormat     Reason = "unsafe_unicode_format_character"
	ReasonEmptyText               Reason = "empty_text"
	ReasonRedactedTextTooLarge    Reason = "redacted_text_too_large"
	ReasonRedactionFailed         Reason = "redaction_failed"
)

type RedactionKind

type RedactionKind string
const (
	RedactionURLCredential RedactionKind = "url_credential"
	RedactionJWT           RedactionKind = "jwt"
	RedactionAPIKey        RedactionKind = "api_key"
	RedactionEmail         RedactionKind = "email"
	RedactionPhone         RedactionKind = "phone"
	RedactionSecret        RedactionKind = "secret"
	RedactionHighEntropy   RedactionKind = "high_entropy"
)

type RedactionSummary

type RedactionSummary map[RedactionKind]int

Jump to

Keyboard shortcuts

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