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
idstring✓Pattern: ^[0-9A-Z]{26}$ULID — collision-free, sortable by creation time
slugstring✓Pattern: ^[a-z0-9]+(-[a-z0-9]+)*-[a-z0-9]{4}$kebab-case + 4-char random suffix
statusstring✓candidate | reviewed | active | disabled | archivedLifecycle state. Only active/disabled appear in the manifest
typestring✓directive | guard | hint | protocolAuthoritative injection behavior
summarystring✓Max 120 charsOne-line description; fallback injection text
problemstring✓—Root cause explanation
solutionstring✓—Concrete 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 | null—Default: nullnull = global; a project-ID string scopes to that project only
priorityinteger✓1–10Higher wins budget conflicts
confidencenumber✓0.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 | null—Same shapes as requiresExcludes the lesson when the named artifact IS installed
sourcestring✓structured | heuristic | manualHow this lesson was discovered
sourceSessionIdsstring[]✓Default: []Session provenance
occurrenceCountinteger✓Min: 0Times pattern detected by scanner
sessionCountinteger✓Min: 0Number of distinct sessions this pattern was seen in
projectCountinteger✓Min: 0Number of distinct projects this pattern was seen in
contentHashstring✓Pattern: ^sha256:[a-f0-9]{64}$Dedup hash of problem + solution + triggers
createdAtstring✓ISO 8601Creation timestamp
updatedAtstring✓ISO 8601Last update timestamp
reviewedAtstring | null—ISO 8601Null for unreviewed candidates
archivedAtstring | null—ISO 8601Null if not archived
archiveReasonstring | null——Optional 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
version1✓Schema version
generatedAtstring✓ISO 8601 build timestamp
configobject✓Config snapshot at build time
lessonsobject✓Lessons 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
slugstring✓For logging and dedup claim filenames
typestring✓directive | guard | hint | protocol
priorityinteger✓For 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 | null—null = global; a project-ID string scopes to that project only
messagestring✓Pre-rendered markdown — the only content read during injection
summarystring✓Fallback if message exceeds remaining budget
problemstring—Carried through for citation-fallback rendering
solutionstring—Carried through for citation-fallback rendering
disabledboolean—Only 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
sourcestring✓Regex source string
flagsstring—Regex 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
injectionBudgetBytesinteger256—4096
maxLessonsPerInjectioninteger1103
minConfidencenumber0.01.00.5
minPriorityinteger1101
compactionReinjectionThresholdinteger1107
autoScanIntervalHoursinteger1—24
maxCandidatesPerScaninteger1—50

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",
...
}