Skip to content

feat!: simplify feature-knowledge system (write-through + dedicated MDS module)#247

Open
dean0x wants to merge 5 commits into
mainfrom
feat/simplify-feature-knowledge
Open

feat!: simplify feature-knowledge system (write-through + dedicated MDS module)#247
dean0x wants to merge 5 commits into
mainfrom
feat/simplify-feature-knowledge

Conversation

@dean0x

@dean0x dean0x commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Summary

Replaces the feature-knowledge detect-drift-then-background-repair machine with a write-through model and moves the two reusable command-level blocks into native MDS partials compiled by a dedicated build module. Net: a large deletion, far fewer runtime parts, and freshness that tracks usage.

Before: a ~650-line feature-knowledge.cjs engine + a SessionEnd hook (eval-knowledge) + a Dream refresh task (dream-knowledge) + an mkdir lock + per-session markers + three throttles + an index.json registry + a .create-result.json handoff — all to serve one weak git-mtime heuristic, and it produced ~zero real updates on this repo (empty index → every run found nothing stale and just advanced the throttle).

After: the workflow that does the work updates KNOWLEDGE.md now, in-context; readers verify against code on load. Loading/saving are direct agent file-I/O. Freshness = write-through + verify-on-read.

What changed (6 workstreams)

  • WS1 — Rewire load/save to two MDS call sites ({knowledge_load()} / {knowledge_writeback()}) across the 9 host commands, preserving the load/writeback asymmetry (explore/debug write-back only; the other 7 load up-front; implement/resolve/self-review also write back).
  • WS2 — Delete the maintenance machinery (in safe order): eval-knowledge, feature-knowledge.cjs, the dream-knowledge skill, knowledge-agent.ts, agent-result.ts, and the heavy CLI CRUD. Dream no longer has a knowledge task; dream-collect-tasks now sweeps stale knowledge.* markers (same pattern as memory.*/learning.*).
  • WS3 — Dedicated MDS module: new shared/knowledge/ source dir (_knowledge.mds partials + 9 host .mds) compiled by a standalone scripts/build-knowledge.ts (explicit 9-entry source→plugin map, per-file clean, hard-fail). The 9 plugins/*/commands/*.md are now generated (gitignored). build:recipes is untouched.
  • WS4 — Two migrations (auto-run on next devflow init): purge-knowledge-hooks-global-v1 (removes installed eval-knowledge + feature-knowledge.cjs) and purge-feature-knowledge-pipeline-v1 (removes dream knowledge.* markers, lock dirs/sentinels, renames index.jsonindex.json.deprecated). Both ENOENT-tolerant + idempotent; the dream-config knowledge gate is preserved.
  • WS5 — Skills + Knowledge agent: deleted dream-knowledge; slimmed apply-feature-knowledge (verify-against-code is now the freshness mechanism; dropped [STALE] handling); updated feature-knowledge author skill (agent writes the index.md line itself; dropped referencedFiles); simplified the Knowledge agent to dual direct writes (KNOWLEDGE.md + index.md line; no .create-result.json).
  • WS6 — Docs + tests: CLAUDE.md rewritten to the write-through model; deleted tests/feature-knowledge/*; added a build-knowledge smoke test + migration idempotency tests.

⚠️ Breaking changes

  • CLI surface: devflow knowledge create | check | refresh | remove are removed. devflow knowledge list and --enable/--disable/--status remain.
  • Behavior: feature knowledge is no longer auto-refreshed by a background pipeline; it is written through by the workflow that touches a documented area, gated by the single knowledge: true|false dream-config key (default true; gates write-back only — load is ungated). Existing KBs remain loadable via frontmatter fallback after index.json is deprecated.
  • Warrants a major version bump at release (current 2.0.0); per repo convention the bump is CI-derived from the feat!: commits, not done in this PR.

Testing

  • npm run build green (full chain incl. the new build:knowledge step — all 9 commands compile, 0 errors/warnings).
  • npm test: 1815 passing / 61 files (+38 new).
  • Independent QA pass: 10/10 scenarios (T1–T10), all 18 acceptance criteria (F1–F7, C1–C7, P1–P4) satisfied; build fail-loud verified; generated commands confirmed clean of old call-sites and brace-escape leaks.

Deploy note

The new commands/hooks/agents/migrations activate only after node dist/cli.js init (a global reinstall) — intentionally not run during implementation to avoid self-modifying the in-flight workflow.

🤖 Generated with Claude Code

dean0x and others added 5 commits June 28, 2026 13:44
…of 3)

WORKSTREAM 3: Add shared/knowledge/_knowledge.mds with knowledge_load()
and knowledge_writeback() partials — pure file-I/O, no subprocess/git calls,
no .cjs engine. knowledge_load reads index.md cache (falls back to globbing
frontmatter); knowledge_writeback conditionally spawns Knowledge agent to
write KNOWLEDGE.md + index.md line directly.

WORKSTREAM 1: Port all 9 command .md files to shared/knowledge/*.mds host
files that import and call the two partials. Asymmetry preserved: explore
and debug get writeback-only; the other 7 load up-front; implement/resolve/
self-review additionally write back. All prose braces escaped; code fences
use raw braces.

DELIVERABLE 3: scripts/build-knowledge.ts — explicit 9-entry source→plugin
map (not a glob), per-file clean (never wipes a whole dir), hard-fail on any
mds:: error, disjoint from build-recipes.ts.

DELIVERABLE 4: package.json wires build:knowledge after build:recipes in
the main build chain; .gitignore adds 9 per-file entries for generated
commands; git rm --cached untracks the now-generated .md files.

Old machinery (feature-knowledge.cjs, index.json, .create-result.json,
subprocess calls) remains untouched — this phase is purely additive.
Tree builds green; all 1880 tests pass.

TASK_ID: feat/simplify-feature-knowledge
…ls/agent (2/3)

WS2: delete eval-knowledge hook, feature-knowledge.cjs CJS library, dream-knowledge
skill, knowledge-agent.ts, agent-result.ts (sever references first, then delete).
Update session-start-context to drop _SC2_KNOW_EN; drop KNOWLEDGE_ENABLED arg from
dream_collect_tasks; make knowledge.* case unconditionally delete stale markers;
remove index.json bootstrap from ensure-devflow-init and init.ts. Add
devflow:dream-knowledge to LEGACY_SKILLS_V2X for cleanup on upgrade.

WS5: update apply-feature-knowledge skill to drop [STALE] handling and strengthen
verify-against-code as the freshness mechanism. Update feature-knowledge skill to
remove referencedFiles from frontmatter template and Result Output section; replace
with direct index.md write instructions (line format: - **{slug}** — {areas} — desc).
Rewrite knowledge agent to write KNOWLEDGE.md + index.md directly without any
intermediate .create-result.json or external scripts.

Test cleanup: delete tests/feature-knowledge/* (5 files, 1072 lines). Remove
knowledge assertions from shell-hooks.test.ts (throttle, sentinel, dream-evaluate
knowledge block, runCollectTasks knowEnabled param). Update project-paths.test.ts
to drop the 4 deleted helper assertions. All 1777 tests pass.

TASK_ID: feat/simplify-feature-knowledge
WS4: Two new migrations in MIGRATIONS registry:
- purge-knowledge-hooks-global-v1 (global): removes orphaned
  ~/.devflow/scripts/hooks/eval-knowledge and
  ~/.devflow/scripts/hooks/lib/feature-knowledge.cjs left by the
  additive installer after Phase 2 deleted them from source
- purge-feature-knowledge-pipeline-v1 (per-project): removes dream
  knowledge.* markers, .knowledge.lock/, .knowledge-last-refresh,
  .knowledge-refresh.lock, .disabled sentinel; renames index.json to
  index.json.deprecated; preserves knowledge gate in dream config

WS6 docs: CLAUDE.md fully updated to write-through model — Feature
Knowledge Bases paragraph rewritten; eval-knowledge removed from hooks
list and dream-evaluate description; dream-collect-tasks updated to
note knowledge.* deletion; Model Strategy drops knowledge=sonnet Dream
note; Migrations paragraph adds both new migrations; Project Structure
removes stale files (.disabled, .knowledge.lock, .knowledge-last-refresh,
index.json → index.md); build:knowledge added to build commands.

WS6 tests: 38 new tests across 2 files —
- tests/migrations.test.ts: 4 new entries in MIGRATIONS describe +
  idempotency/cleanup suites for both new migrations (30 new tests)
- tests/build-knowledge.test.ts: new file — SOURCE_TO_PLUGIN_MAP
  lock (9-entry explicit mapping), MDS compiler happy path, script
  subprocess contract (exits 0), compiled-output assertions (no stale
  call sites); 8 tests

Dogfood: .devflow/features/feature-knowledge-system/KNOWLEDGE.md
rewritten to document the new write-through architecture; index.json
renamed to index.json.deprecated; index.md created with new line format.

Final state: npm run build exits 0 (all 9 knowledge commands compiled);
npm test 1815/1815 passing (up from 1777 in Phase 2).

Co-Authored-By: Claude <noreply@anthropic.com>
…lish comments

Update Phase 1b of /release to load feature knowledge using the write-through
model: read index.md cache first, fall back to globbing KNOWLEDGE.md frontmatter
on absence, and load full KBs for relevant areas. Removes the deprecated
index.json load and feature-knowledge.cjs subprocess call.

Polish plugins.ts legacy-sweep comment to correctly mark dream-knowledge as
removed (not still-active) and clarify dream-decisions/dream-curation are the
active pair. Update init.ts knowledge feature description to describe the
write-through model accurately.
Phase 1 over-escaped braces inside column-0 fenced code blocks in the
.mds source files. MDS leaves fenced content untouched, so \{ passed
through literally into 9 generated commands (269 total leaked \{ across
implement 83, resolve 50, bug-analysis 33, debug 31, plan 25,
code-review 23, self-review 12, explore 9, research 3).

Un-escape \{ → { and \} → } inside column-0 fenced regions only.
Prose escapes (outside fences) are left intact — MDS compiles those
correctly. Build confirms no prose brace was wrongly un-escaped (a green
build is the safety net: wrong un-escape → MDS undefined-variable error).

Before: 269 leaked \{ across 9 generated commands
After: 0 leaked \{ (all 9 commands clean)
Tests: 1815/1815 passing
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