Documentation
¶
Overview ¶
Package validate provides shared input-validation helpers enforcing the filesystem-safety invariants in AGENTS.md:
- Reject file paths containing "..", absolute paths, or null bytes.
- Sanitize names (memory names, project slugs, note slugs) for filesystem safety.
Ported from Seam v1 (internal/validate) with one deliberate change: Title no longer rejects "..". Titles are slugified before any filesystem use, and the old check bounced legitimate titles such as "summary 2026-07-05..08" (a 37% error rate on create in v1). Name and Path keep the ".." guard because their inputs feed filesystem operations directly.
Index ¶
Constants ¶
const ( // GlobalProject is the human-facing token for the project-less scope. GlobalProject = "global" // AllProjects is reserved for operations that deliberately widen across // every project; it can never be an ordinary project slug. AllProjects = "all" )
Variables ¶
var ( // ErrPathTraversal is returned when a path contains "..", is absolute, or // contains null bytes. ErrPathTraversal = errors.New("path contains traversal sequence, absolute path, or null bytes") // ErrUnsafeName is returned when a name contains filesystem-unsafe // characters or patterns. ErrUnsafeName = errors.New("name contains unsafe characters") )
Functions ¶
func Name ¶
Name rejects names used to build filenames (memory names, project/note slugs) that are unsafe on any supported platform. The corpus is routinely synced or restored across operating systems, so accepting a name only Unix can create would turn a later Windows checkout into a partial, misleading corpus.
func Path ¶
Path rejects file paths that could escape a base directory. It checks for ".." components, absolute paths, and null bytes.
func PathWithinDir ¶
PathWithinDir validates a path and then verifies the resolved absolute path stays within the given base directory.
func Project ¶ added in v0.4.9
Project normalizes the two global-scope spellings and validates an ordinary project slug with Name. The cross-project widening token is reserved rather than accepted as a project that other surfaces could never address.
func Title ¶
Title validates human-facing titles and descriptions. It is more permissive than Name: it allows "/" (e.g. "TCP/IP", "A/B testing") and ".." (e.g. date ranges like "2026-07-05..08") because titles are slugified before any filesystem use. It rejects empty strings, null bytes, backslashes, and lengths over 255.
Types ¶
This section is empty.