Unexport ulidPattern (extraction shape, not a validator) · Entire
Unexport ulidPattern (extraction shape, not a validator)
500e7e3→main·
After moving ULID validation to oklog/ulid, the ULID regex no longer validates — it only composes CheckpointPattern to extract a candidate ID token from free text (the Entire-Checkpoint trailer). Nothing outside the id package referenced the exported ULIDPattern, and an exported "shape" regex that looks like a validator is a footgun, so unexport it to ulidPattern. Pattern stays exported (run IDs in investigate/provenance use it); CheckpointPattern stays exported (trailer scan).
Sessions
428eb6d04543View transcript
Changes
1
cmd/entire/cli/checkpoint/id
Mid.go+11/-10
28 unmodified lines
// CheckpointPattern for matching a checkpoint ID that may be either format.
const Pattern = `[0-9a-f]{12}`
// ULIDPattern is the regex SHAPE of a ULID checkpoint ID: 26 Crockford base32
// characters (digits plus uppercase A-Z excluding I, L, O, U). It exists to
// extract a candidate checkpoint ID from free text (see CheckpointPattern); it
// is intentionally looser than the authoritative validation in KindOf/Validate,
// which decode the value via oklog/ulid (rejecting e.g. a timestamp overflow the
// char class alone would accept). Future checkpoint IDs are expected to be ULIDs
// so they sort lexicographically by creation time.
const ULIDPattern = `[0-9ABCDEFGHJKMNPQRSTVWXYZ]{26}`
// ulidPattern is the regex SHAPE of a ULID checkpoint ID: 26 Crockford base32
// characters (digits plus uppercase A-Z excluding I, L, O, U). It exists only to
// compose CheckpointPattern for extracting a candidate ID from free text; it is
// deliberately NOT exported and NOT the validator. Authoritative validation
// decodes the value via oklog/ulid (see KindOf/isULID), which additionally
// rejects e.g. a timestamp overflow the char class alone would accept.
const ulidPattern = `[0-9ABCDEFGHJKMNPQRSTVWXYZ]{26}`
// CheckpointPattern matches a checkpoint ID in free text in either format
// (legacy 12-hex or ULID). Use this — not Pattern — when scanning text such as
// the Entire-Checkpoint commit trailer for a checkpoint ID.
const CheckpointPattern = `(?:` + Pattern + `|` + ULIDPattern + `)`
// the Entire-Checkpoint commit trailer for a candidate checkpoint ID, then
// validate the captured token via NewCheckpointID/Validate (CheckpointPattern is
// a loose shape, not authoritative validation).
const CheckpointPattern = `(?:` + Pattern + `|` + ulidPattern + `)`
// ShortIDLength is the standard length for truncating IDs for display purposes.
// Used for tool use IDs, session IDs, and commit hashes in logs and messages.
Mcmd/entire/cli/checkpoint/id/id.go+11/-10