platform

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

This file implements the process exit-code contract defined in ADR 0005: 0=success, 1=findings at/above threshold, 2=usage error, 3=runtime error.

Package platform holds cross-cutting concerns that are neither domain logic nor application orchestration: version metadata and the process exit-code contract. It depends only on the standard library.

Index

Constants

View Source
const PreWalkReadCap int64 = 1 << 20 // 1 MiB

PreWalkReadCap is the size cap (in bytes) for files matlatl reads at the scan root BEFORE/OUTSIDE the per-file walk cap — currently `.matlatlignore` (fsscanner) and `.matlatl.yml` (config). Those reads happen before the walk's per-file MaxFileSizeBytes guard applies, so a hostile repo could otherwise hand us a multi-GB file and OOM the scan. This is the single audit point for that cap (ADR 0003 invariant 3): 1 MiB is far more than any real ignore/config file needs, and an oversized file is skipped (treated like a missing file) rather than read into memory. Combined with the YAML decoder's built-in alias-expansion budget, it also bounds the .matlatl.yml decode against alias/billion-laughs bombs.

Variables

View Source
var (
	// Version is the semantic version of the build (e.g. "1.2.3").
	Version = "dev"
	// Commit is the git commit hash the build was produced from.
	Commit = "dev"
	// Date is the build timestamp.
	Date = "dev"
)

Build metadata. These are overridden at link time via -ldflags, e.g.:

go build -ldflags "-X github.com/stacklok/matlatl/internal/platform.Version=1.2.3 ..."

They default to "dev" for local/unstamped builds.

Functions

func BuildInfo

func BuildInfo() string

BuildInfo returns a human-readable, single-line description of the build. It is deliberately not named String to avoid visual collision with the fmt.Stringer convention on a package-level function.

Types

type ExitCode

type ExitCode int

ExitCode is the process exit status returned by matlatl. The mapping is a stable contract that CI pipelines depend on (see ADR 0005).

const (
	// ExitOK signals success: no findings at or above the failure threshold.
	// An empty corpus (no markdown found) is also success.
	ExitOK ExitCode = 0
	// ExitFindings signals that findings exist at or above the failure
	// threshold (broken links/anchors; orphans and ambiguous links only under
	// --strict).
	ExitFindings ExitCode = 1
	// ExitUsage signals a usage error: bad flags or arguments.
	ExitUsage ExitCode = 2
	// ExitRuntime signals a runtime error: unreadable path, I/O failure, or an
	// internal error.
	ExitRuntime ExitCode = 3
)

func (ExitCode) String

func (c ExitCode) String() string

String returns a short identifier for the exit code, useful in logs.

Jump to

Keyboard shortcuts

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