skip to main content

kb ingest — inline [[wikilink]] concept tagging — Implementation Plan

See wikilink-tagging-design.md for the full rationale and confirmed decisions. Work items ordered W1 → W5. TDD-first: each phase’s tests are written and confirmed red before its implementation.


W1 — Schema + core knowledge package primitives

Files to modify

records.go — append to recordsSchema (after record_relations):

CREATE TABLE IF NOT EXISTS record_concepts (
    record_id  INTEGER REFERENCES records(id)  ON DELETE CASCADE,
    concept_id INTEGER REFERENCES concepts(id) ON DELETE CASCADE,
    PRIMARY KEY (record_id, concept_id)
);

knowledge.go — two new methods, placed near LinkObservationConcept/ LinkProjectConcept and ObservationSources respectively:

Tests to add (knowledge_test.go)

Acceptance criteria


Files to modify

cmd/kb/ingest.go:

Tests to add (cmd/kb/ingest_test.go, alongside

TestCmdIngest_InitiativeBecomesAConcept)

Acceptance criteria


W3 — Read path: kb record concepts ID

Files to modify

cmd/kb/record.go:

Tests to add (cmd/kb/record_test.go)

Acceptance criteria


W4 — Portability: merge + JSON-L export/import

Files to modify

knowledge_merge.go:

jsonl.go:

Tests to add

knowledge_merge_test.go — TestMergeKnowledgeBases_RecordConcepts, mirroring TestMergeKnowledgeBases_ProjectConcepts’s structure (seed two source databases, merge, assert exactly the expected row count and that it appears in the summary).

jsonl_test.go — TestExportRecordConcepts_RoundTrips (export then re-import into a fresh database, assert the link survives), TestImportRecordConcept_SkipsWhenEndpointMissing (mirrors whatever the existing project_concept/observation_concept import tests do for a dangling uuid reference).

Acceptance criteria


W5 — Documentation

Files to modify

cmd/kb/helptext.go:

Regeneration (do not hand-edit .1.md files — they are generated)

make kb-topics-help   # regenerates kb-ingest.1.md and kb-record.1.md
make man              # (if HTML/man output is otherwise part of the normal build)

Acceptance criteria