feat(adr): add manage-adr MCP tool + CLI command backed by SQLite (closes #16)#143
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…oses #16) Architecture Decision Records give agents persistent memory of *why* the codebase is structured the way it is, so they don't propose refactors that violate intentional constraints. New files: - scripts/adr_engine.py — SQLite-backed ADR manager (create/list/get/update/ deprecate/delete). Single-table schema: id, title, context, decision, status, superseded_by, created_at, updated_at. Statuses: proposed, accepted, deprecated, rejected. Supersession links ADRs and forbids self-reference. Missing-id operations return 'not_found' rather than raising. Dangling superseded_by refs are cleared on delete. - scripts/commands/adr.py — CLI command registered as 'codelens adr <create|list|get|update|deprecate|delete>'. Thin argparse wrapper that delegates to adr_engine.manage_adr() (single entry point shared with MCP). - tests/test_adr.py — 50 tests covering CRUD, status validation, supersession integrity, missing-id soft-fails, CLI registration, MCP tool schema, file headers, and end-to-end lifecycle. Modified: - scripts/mcp_server.py — add 'manage-adr' to _TOOL_DEFINITIONS (static schema with action enum, status enum, superseded_by, status_filter). - README/SKILL/SKILL-QUICK/pyproject.toml/skill.json/graph_model.py — command count synced 69->70, MCP static 54->55 via sync_command_count.py --apply. Test results: 50/50 new tests pass. Existing command_count + command_registry tests pass (counts are in sync). No regressions in the safe-to-run test subset; pre-existing failures (test_codelensignore, tree-sitter-dependent tests) are unchanged and documented in CONTEXT.md.
107b513 to
2187a39
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Closes #16
Summary
Adds Architecture Decision Records (ADR) — persistent memory of why the codebase is structured the way it is, so AI agents don't propose refactors that violate intentional constraints.
What changed
New files:
scripts/adr_engine.py— SQLite-backed ADR manager with single-table schema (id, title, context, decision, status, superseded_by, created_at, updated_at). Statuses: proposed/accepted/deprecated/rejected. Single entry pointmanage_adr()dispatches all 6 actions (create/list/get/update/deprecate/delete).scripts/commands/adr.py— CLI commandcodelens adr <action>auto-registered viacommands/__init__.py. Thin argparse wrapper aroundmanage_adr().tests/test_adr.py— 50 tests covering CRUD, status validation, supersession integrity, missing-id soft-fails, CLI registration, MCP tool schema, file headers, and full lifecycle.Modified:
scripts/mcp_server.py— addedmanage-adrto_TOOL_DEFINITIONS(static schema with action enum, status enum, superseded_by, status_filter).README.md/SKILL.md/SKILL-QUICK.md/pyproject.toml/skill.json/scripts/graph_model.py— command count synced 69→70, MCP static 54→55 viasync_command_count.py --apply.Design decisions
.codelens/adrs.dbordocs/adr/markdown. Chose SQLite for: (1) atomic transactions, (2) structured querying (filter by status, join on superseded_by), (3) consistency with existingpersistent_registry.pyandgraph_model.pypatterns, (4) no file-name-as-id ambiguity. Markdown export can be added later as a--format markdownflag if desired.deprecateoverdeletefor history: deprecate preserves the record and links to a replacement viasuperseded_by. Delete is still available but discouraged. Self-supersession is forbidden; deprecating with a non-existent replacement returns a structured error (not a crash).get/update/deprecate/deletereturn{status: not_found}rather than raising, so MCP clients get structured feedback they can act on.superseded_by=2, ADR feat: add codelens-watch.py — file watcher with auto outline.json generation #1'ssuperseded_byis set to NULL rather than blocking the delete.Test results
tests/test_adr.pypass.tests/test_command_count.py(4 tests) pass — counts are in sync.tests/test_command_registry.py(2 tests) pass —adrcommand auto-registers correctly.test_codelensignore.pythat is unchanged by this PR — see CONTEXT.md).Acceptance criteria from issue
manage_adrMCP tool backed by SQLite table.codelens/adrs.db(survives session resets)sync_command_count.py --apply