Documentation
¶
Overview ¶
Package integrity provides canonical content hashing, fail-closed verification, and drift classification for installed skills.
Index ¶
Constants ¶
const SkillFileName = "SKILL.md"
SkillFileName is the canonical skill manifest filename.
Variables ¶
This section is empty.
Functions ¶
func CompatHash ¶ added in v0.3.0
CompatHash computes the skills-lock.json "computedHash" for a skill directory using the same rules as the external lock producer (the vercel-labs/skills CLI, src/local-lock.ts computeSkillFolderHash):
- collect regular files recursively; directories named ".git" or "node_modules" are skipped at any depth
- symlinks are neither followed nor hashed; empty directories contribute nothing; file modes are ignored
- file bytes are hashed verbatim (no line-ending normalization)
- files sort by relative forward-slash path using locale-aware collation (JavaScript localeCompare)
- sha256 over the concatenation of each file's path then content, hex encoded with no prefix
Parity is pinned by TestCompatHashParity against hashes recorded from the reference implementation (testdata/compat). This is deliberately distinct from HashDir, gskill's own canonical hash, which stays in the namespaced gskill.storeHash field.
func HashContent ¶
HashContent returns the canonical hash of a single file's content, applying LF normalization to text. The result is prefixed with "sha256:".
func ValidateContent ¶ added in v0.4.0
ValidateContent scans a skill directory before it is staged or admitted to a store. It rejects symlinks that escape the skill directory (path-traversal / unsafe symlinks, FR-042) and returns warnings for executable-bit files, which gskill never runs (FR-043). Content is never executed.
Types ¶
type DriftStatus ¶
type DriftStatus string
DriftStatus classifies the state of an installed skill relative to the manifest, lockfile, and on-disk content, as surfaced by check and verify (FR-016).
const ( DriftInstalled DriftStatus = "installed" DriftMissing DriftStatus = "missing" DriftModified DriftStatus = "modified" DriftOutdated DriftStatus = "outdated" DriftOrphaned DriftStatus = "orphaned" DriftPartiallyInstalled DriftStatus = "partially-installed" DriftChecksumMismatch DriftStatus = "checksum-mismatch" )
Drift statuses (FR-016).
func Classify ¶
func Classify(s SkillState) DriftStatus
Classify maps a SkillState to a DriftStatus (FR-016, FR-017). The checks are ordered from most to least severe so the first matching condition wins.
func (DriftStatus) Clean ¶
func (s DriftStatus) Clean() bool
Clean reports whether s represents an in-sync installation needing no action.
func (DriftStatus) Valid ¶
func (s DriftStatus) Valid() bool
Valid reports whether s is a recognized drift status.
type Hashes ¶
type Hashes struct {
// ContentHash is the canonical recursive hash of the skill directory.
ContentHash string
// SkillFileHash is the hash of SKILL.md alone.
SkillFileHash string
}
Hashes holds the canonical content identity of an installed skill (FR-014).
type SkillState ¶
type SkillState struct {
InLock bool
SourceAvailable bool
ContentMismatch bool // installed content hash != locked hash (set only by content checks)
TargetsTotal int
TargetsPresent int
}
SkillState is the observed lock and filesystem state of one skill, used to classify its drift without coupling this package to the lock types.