Skip to main content

Schema Reference

All data files are validated against JSON Schema (Draft 2020-12). Schemas live in schemas/.


lessons.schema.json

Validates a deserialized lesson row from data/lessons.db (SQLite) — the source of truth for all lesson records. Fields match DB column names exactly; there is no lessons.json file.

Schema ID: https://github.com/joeblackwaslike/lessons-learned/schemas/lessons.schema.json

Lesson record

FieldTypeRequiredConstraintsDescription
idstringPattern: ^[0-9A-Z]{26}$ULID — collision-free, sortable by creation time
slugstringPattern: ^[a-z0-9]+(-[a-z0-9]+)*-[a-z0-9]{4}$kebab-case + 4-char random suffix
statusstringcandidate | reviewed | active | disabled | archivedLifecycle state. Only active/disabled appear in the manifest
typestringdirective | guard | hint | protocolAuthoritative injection behavior
summarystringMax 120 charsOne-line description; fallback injection text
problemstringRoot cause explanation
solutionstringConcrete fix
toolNamesstring[]Default: []Exact tool name match — first-pass filter at hook time
commandPatternsstring[]Default: []Regex patterns matched against Bash tool_input.command
pathPatternsstring[]Default: []Glob/regex patterns matched against Read/Edit/Write file paths
commandMatchTargetstring | null"full" (default) or "executable""executable" strips quoted strings before matching commandPatterns
modelPatternsstring[]Default: []AND-gate regex matched against command or file path
scopestring | nullDefault: nullnull = global; a project-ID string scopes to that project only
priorityinteger1–10Higher wins budget conflicts
confidencenumber0.0–1.0Below minConfidence → excluded from manifest
tagsstring[]Pattern: ^[a-z]+:[a-z0-9._-]+$category:value taxonomy
requiresobject | object[] | null{type, name} or {type: "github-issue", url}Excludes the lesson from the manifest unless the artifact is installed
duplicatedByobject | nullSame shapes as requiresExcludes the lesson when the named artifact IS installed
sourcestringstructured | heuristic | manualHow this lesson was discovered
sourceSessionIdsstring[]Default: []Session provenance
occurrenceCountintegerMin: 0Times pattern detected by scanner
sessionCountintegerMin: 0Number of distinct sessions this pattern was seen in
projectCountintegerMin: 0Number of distinct projects this pattern was seen in
contentHashstringPattern: ^sha256:[a-f0-9]{64}$Dedup hash of problem + solution + triggers
createdAtstringISO 8601Creation timestamp
updatedAtstringISO 8601Last update timestamp
reviewedAtstring | nullISO 8601Null for unreviewed candidates
archivedAtstring | nullISO 8601Null if not archived
archiveReasonstring | nullOptional explanation for why the lesson was archived

There is no needsReview column — manifest exclusion is computed from confidence/priority at build time, not stored on the record.


manifest.schema.json

Validates data/lesson-manifest.json — the pre-compiled runtime index read by the injection hook.

Schema ID: https://github.com/joeblackwaslike/lessons-learned/schemas/manifest.schema.json

Do not edit directly

lesson-manifest.json is generated by node scripts/lessons.mjs build. Edit lessons via the CLI (add, edit, promote) and rebuild instead.

Top-level

FieldTypeRequiredDescription
type"lessons-learned-manifest"Discriminator
version1Schema version
generatedAtstringISO 8601 build timestamp
configobjectConfig snapshot at build time
lessonsobjectLessons keyed by ULID

Config snapshot

The manifest embeds a snapshot of injection-relevant config fields so the hook never needs to read config.json:

FieldType
injectionBudgetBytesinteger
maxLessonsPerInjectioninteger
minConfidencenumber
minPriorityinteger
compactionReinjectionThresholdinteger

Manifest lesson record

FieldTypeRequiredDescription
slugstringFor logging and dedup claim filenames
typestringdirective | guard | hint | protocol
priorityintegerFor sort-time access
toolNamesstring[]First-pass filter before regex matching
commandRegexSourcesRegexSource[]Pre-compiled command pattern sources
commandMatchTargetstring"full" or "executable" (defaults to "executable" for guards)
pathRegexSourcesRegexSource[]Pre-compiled path pattern sources (globs converted at build time)
modelRegexSourcesRegexSource[]Pre-compiled model-pattern sources, AND-gated against the match
tagsstring[]For tag-based scoring
scopestring | nullnull = global; a project-ID string scopes to that project only
messagestringPre-rendered markdown — the only content read during injection
summarystringFallback if message exceeds remaining budget
problemstringCarried through for citation-fallback rendering
solutionstringCarried through for citation-fallback rendering
disabledbooleanOnly present (and true) when the source lesson's status is disabled

RegexSource object

Regex patterns are stored as { source, flags } pairs rather than regex strings because RegExp is not JSON-serializable. The hook reconstructs them with new RegExp(source, flags).

FieldTypeRequiredDescription
sourcestringRegex source string
flagsstringRegex flags (default: "")

config.schema.json

Validates data/config.json.

Schema ID: https://github.com/joeblackwaslike/lessons-learned/schemas/config.schema.json

See the Configuration Reference for full field documentation. The schema enforces:

FieldTypeMinMaxDefault
injectionBudgetBytesinteger2564096
maxLessonsPerInjectioninteger1103
minConfidencenumber0.01.00.5
minPriorityinteger1101
compactionReinjectionThresholdinteger1107
autoScanIntervalHoursinteger124
maxCandidatesPerScaninteger150

IDE validation

All data files include a $schema field pointing to the relevant schema. VS Code and other JSON-aware editors will validate the file on save and provide autocomplete for fields.

{
"$schema": "../schemas/config.schema.json",
...
}