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 ¶
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 ¶
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 ¶
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 )