boundary

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package boundary checks that the production core links none of the reflection-driven standard-library packages TinyGo cannot build faithfully (go list -deps over the core packages, the Go and the Wasm configuration).

Index

Constants

View Source
const WasmMain = "cmd/corewasm"

WasmMain is the reactor's main package (the one TinyGo builds); it is a root of the wasip1 closure only.

Variables

View Source
var CorePackages = []string{"abi", "jv", "internal/delta", "rec", "history", "store", "session/hopcost", "session", "docs", "inbox", "turn", "."}

CorePackages are the packages built into the Wasm module (ADR D15, LAYOUT.md), as import paths relative to durable/core.

View Source
var ForbiddenPackages = []string{
	"encoding/json", "encoding/json/v2", "encoding/json/jsontext", "reflect", "text/template", "text/template/parse", "html/template",
}

ForbiddenPackages are the packages the core must not link: each is reflection or reflection-driven (TinyGo supports them only partially, and they pull large runtime support into the Wasm module), so a core package that reached one would build under Go and break or bloat under TinyGo.

View Source
var NonCorePackages = []string{
	"abi/abitest", "abi/payload", "abi/spec", "abi/spec/cmd/abigen", "budget/coldhints", "budget/tinygo/patchdata", "cmd/corenative", "contracttest", "contracttest/binding", "contracttest/boundary",
	"contracttest/cmd/benchhost", "contracttest/cmd/countgate", "contracttest/cmd/replayhost", "contracttest/cmd/scprovider", "contracttest/counts",
	"contracttest/fuel", "contracttest/guard", "contracttest/storehost", "driver",
	"history/internal/buildcheck", "probe", "session/cmd/tgprobe", "session/sessiontest", "sqlhost", "sqlhost/cmd/bench",
}

NonCorePackages are the durable/core packages that are not built into the Wasm module: hosts, drivers, tooling and the test-only helpers. They may use the whole standard library.

View Source
var StdRoutes = map[string][]string{"encoding/binary": {"reflect"}}

StdRoutes are the standard-library edges to a forbidden package the core accepts: encoding/binary imports reflect for Read and Write on arbitrary values, and the core calls only the byte-order and Append functions, which the linker keeps without reflect's support. Every other standard-library route (fmt, encoding/gob, sort on Go versions that used reflect...) is a violation.

Functions

This section is empty.

Types

type Graph

type Graph map[string][]string

Graph maps an import path to the packages it imports (non-test files of one build configuration).

func ListGraph

func ListGraph(dir string, env []string, patterns ...string) (Graph, []string, error)

ListGraph runs `go list -deps` for the patterns in dir with the extra environment (GOOS, GOARCH) and returns the import graph of the non-test packages and the roots' import paths. cgo is off so the graph is the one a pure-Go build links.

type Violation

type Violation struct {
	Root      string
	Forbidden string
	Chain     []string // Root ... Forbidden
}

Violation is one forbidden dependency and the import chain that reaches it.

func CheckGraph

func CheckGraph(g Graph, roots, forbidden []string) []Violation

CheckGraph returns a violation for every root that reaches a forbidden package, by the shortest chain. A standard-library package (an import path without a dot in its first element) may import a forbidden package only along a StdRoutes edge; that edge is not followed, so the route is neither reported nor counted as the root reaching the package.

func CheckImportBoundary

func CheckImportBoundary(dir string, env []string, patterns ...string) ([]Violation, error)

CheckImportBoundary lists the patterns' dependency closure and returns its violations of ForbiddenPackages.

func (Violation) String

func (v Violation) String() string

Jump to

Keyboard shortcuts

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