godiscovery

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 17 Imported by: 0

Documentation

Overview

Package godiscovery decodes the closed Go 1.27 package-discovery stream. It never executes Go or reads repository files; callers supply independently verified path, mode, and content commitments for every consumed input.

Index

Constants

View Source
const (
	MaxDiscoveryBytes = 16 << 20
	MaxPackages       = 4_096
	MaxStringBytes    = 1 << 20
	MaxJSONDepth      = 16
	MaxArgvBytes      = 4 << 20
)
View Source
const ClosedFields = "" /* 259-byte string literal not displayed */
View Source
const DiscoveryProfile = "go-live-discovery/0"

Variables

This section is empty.

Functions

func Hash

func Hash(kind, profile string, body []byte) (string, error)

func VerifyDocument

func VerifyDocument(document Document, encoded []byte) error

VerifyDocument rejects any structural, identity, or canonical-byte drift in a composed discovery document. External materialization verification remains the caller's responsibility; this verifies the closed discovery transcript.

Types

type Code

type Code string
const (
	CodeDecode Code = "DISCOVERY_DECODE"
	CodeInput  Code = "DISCOVERY_INPUT"
	CodeLimit  Code = "LIMIT_EXCEEDED"
)

type Commitments

type Commitments struct {
	DependencyMaterializationSHA256 string
	ModuleMode                      ModuleMode
	ModulePaths                     []PathCommitment
	Packages                        []PackageMaterial
	SourceWSI                       string
}

type Document

type Document struct {
	Argv                            []string
	DependencyMaterializationSHA256 string
	EnvironmentSHA256               string
	ExitCode                        string
	ID                              string
	InputsSHA256                    string
	ModuleMode                      ModuleMode
	Packages                        []Package
	Profile                         string
	RawStderrSHA256                 string
	RawStdoutSHA256                 string
	RequestedRunnerPackages         []string
	SourceWSI                       string
	ToolchainID                     string
}

func Compose

func Compose(manifest Manifest, input DocumentInput) (Document, []byte, error)

type DocumentInput

type DocumentInput struct {
	EnvironmentSHA256 string
	PackagePatterns   []string
	RawStderrSHA256   string
	ToolchainID       string
}

type Error

type Error struct {
	Code Code
}

func (*Error) Error

func (e *Error) Error() string

type FileCommitment

type FileCommitment struct {
	Field       FileField
	ListedName  string
	Role        InputRole
	Mode        string
	Namespace   PathNamespace
	LogicalPath string
	PathSHA256  string
	RawSHA256   string
}

type FileField

type FileField string
const (
	FieldGoFiles         FileField = "GoFiles"
	FieldCgoFiles        FileField = "CgoFiles"
	FieldCFiles          FileField = "CFiles"
	FieldCXXFiles        FileField = "CXXFiles"
	FieldMFiles          FileField = "MFiles"
	FieldHFiles          FileField = "HFiles"
	FieldFFiles          FileField = "FFiles"
	FieldSFiles          FileField = "SFiles"
	FieldSwigFiles       FileField = "SwigFiles"
	FieldSwigCXXFiles    FileField = "SwigCXXFiles"
	FieldSysoFiles       FileField = "SysoFiles"
	FieldEmbedFiles      FileField = "EmbedFiles"
	FieldTestGoFiles     FileField = "TestGoFiles"
	FieldXTestGoFiles    FileField = "XTestGoFiles"
	FieldTestEmbedFiles  FileField = "TestEmbedFiles"
	FieldXTestEmbedFiles FileField = "XTestEmbedFiles"
)

type InputFile

type InputFile struct {
	Mode       string
	PathSHA256 string
	RawSHA256  string
}

type InputRole

type InputRole string
const (
	RoleSource            InputRole = "SOURCE"
	RoleGeneratedTestMain InputRole = "GENERATED_TEST_MAIN"
)

type Manifest

type Manifest struct {
	DependencyMaterializationSHA256 string
	InputsSHA256                    string
	ModuleMode                      ModuleMode
	Packages                        []Package
	RawStdoutBytes                  uint64
	RawStdoutSHA256                 string
	RequestedRunnerPackages         []string
	SourceWSI                       string
	// contains filtered or unexported fields
}

func Decode

func Decode(reader io.Reader, commitments Commitments) (Manifest, error)

type Module

type Module struct {
	DirPathSHA256   *string
	GoModPathSHA256 *string
	GoModSum        *string
	GoVersion       *string
	Indirect        bool
	Main            bool
	Path            string
	Replace         *Module
	Sum             *string
	TimeRaw         *string
	Version         *string
}

type ModuleMode

type ModuleMode string
const (
	ModuleModeModule    ModuleMode = "MODULE"
	ModuleModeWorkspace ModuleMode = "WORKSPACE"
	ModuleModeVendor    ModuleMode = "VENDOR"
)

type Package

type Package struct {
	DepOnly          bool
	DirPathSHA256    string
	ForTest          *string
	ID               string
	ImportPath       string
	InputFiles       []InputFile
	InputFilesSHA256 string
	Imports          []string
	Kind             PackageKind
	Match            []string
	Module           *Module
	ModuleSHA256     *string
	Name             string
	TestImports      []string
	XTestImports     []string
}

type PackageKind

type PackageKind string
const (
	Dependency  PackageKind = "DEPENDENCY"
	Requested   PackageKind = "REQUESTED"
	TestMain    PackageKind = "TEST_MAIN"
	TestVariant PackageKind = "TEST_VARIANT"
)

type PackageMaterial

type PackageMaterial struct {
	ImportPath     string
	RawDir         string
	DirNamespace   PathNamespace
	DirLogicalPath string
	DirPathSHA256  string
	Files          []FileCommitment
}

type PathCommitment

type PathCommitment struct {
	RawPath     string
	Namespace   PathNamespace
	LogicalPath string
	PathSHA256  string
}

type PathNamespace

type PathNamespace string
const (
	NamespaceSource     PathNamespace = "SOURCE"
	NamespaceDependency PathNamespace = "DEPENDENCY"
	NamespaceToolchain  PathNamespace = "TOOLCHAIN"
)

Jump to

Keyboard shortcuts

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