Skip to content

refactor(kb): one definition per fact, one setting per style (v0.13.1) - #7

Merged
cskwork merged 1 commit into
mainfrom
refactor/kb-dry
Sep 21, 2026
Merged

cskwork merged 1 commit into
mainfrom
refactor/kb-dry

Conversation

@cskwork

@cskwork cskwork commented Sep 21, 2026

Copy link
Copy Markdown
Owner

v0.13.1 — kb.sh without the duplication v0.13.0 shipped with

A refactor of tools/kb.sh with one intentional behaviour change. Output of
show, index, list, search and harvest is unchanged byte for byte
except where noted; the gates are untouched.

Changes

  • One definition of "unmerged harvest". index and harvest each had their
    own loop deciding which open features still hold candidates; both now read
    kb_unmerged. index's two passes over the features (overview table, then
    one section each) share kb_meta for state, date, tags and title instead of
    extracting them twice.
  • kb_get replaces the nine kb_real "$(kb_field …)" idioms; kb_closed
    replaces the three awk one-liners over CLOSED.
  • Dropped: the ## Summary-inside-intent.md fallback. It supported a format
    no store ever wrote — designed and abandoned inside the v0.13.0 work — and its
    helper kb_summary_where with it. summary.md is the digest.
  • Dropped: index --obsidian. The page style is a property of the store, and
    init.sh and close.sh regenerate the page without flags, so
    index_style: obsidian in the store's config.md was already the setting
    that mattered. One setting, one place; the flag is now an unknown option.
  • Fixed on the way: show printed Tags: only when the intent carried them,
    although the tags live in summary.md — the meta line now uses the same
    kb_tags the page uses. A feature that carries a CLOSED record but was never
    archived (an interrupted close) is now treated as closed everywhere on the
    page — sorted by closed_at and labelled closed <date> — where before only
    archive/ entries were.
  • Internal record lines use \037 as separator, not a tab: a tab is IFS
    whitespace, so read collapses adjacent tabs and an empty field (no tags, no
    date) shifted the fields after it.
  • Header comment shortened; tools/kb.sh 605 → 538 lines.

Checked against a real store (84 open, 2 archived, Korean records): the page
and the show digests are byte-identical to v0.13.0 except for the two lines
the fixes above describe; harvest output is identical.

Validation

  • bash gates/knowledge-test.sh → KNOWLEDGE-TEST PASS, 144 assertions
    (section H rewritten for the config-only style; the flag refusal is asserted)
  • bash gates/selftest.sh → SELFTEST PASS
  • bash gates/e2e.sh → E2E PASS, 152 · bash gates/autotest.sh → AUTOTEST PASS, 195

- kb_unmerged is the single source for "open features with an unmerged harvest"
  (index and harvest both read it); kb_meta feeds both index passes; kb_get
  replaces nine kb_real/kb_field idioms; kb_closed replaces three awk one-liners
- drop the intent.md `## Summary` fallback (a format no store ever wrote) and
  kb_summary_where with it
- drop `index --obsidian`: the style is a store setting (config.md index_style),
  which is what init.sh/close.sh already honour; the flag is an unknown option
- fix: `show` now prints Tags from summary.md (it read only intent.md); a CLOSED
  record outside archive/ sorts and labels as closed
- record lines use \037, not tab: a tab is IFS whitespace, so `read` collapsed
  adjacent tabs and an empty tags/date field shifted the fields after it
- tools/kb.sh 605 → 538 lines; knowledge-test section H rewritten for the
  config-only style (144 assertions)

Validation: knowledge-test 144/0, selftest PASS, e2e 152/0, autotest 195/0;
page and digests byte-identical to v0.13.0 on a real store except the two
fixes above.
@cskwork
cskwork merged commit d2cd02d into main Sep 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant