Skip to content

feat: lessons as a typed artifact with follow-through tracking (#428)#472

Open
Tet-9 wants to merge 1 commit into
vouchdev:testfrom
Tet-9:feat/428-lessons-follow-through
Open

feat: lessons as a typed artifact with follow-through tracking (#428)#472
Tet-9 wants to merge 1 commit into
vouchdev:testfrom
Tet-9:feat/428-lessons-follow-through

Conversation

@Tet-9

@Tet-9 Tet-9 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #428

What's included
ClaimType.LESSON — resurfaces through the normal retrieval path like any claim, no special-casing
kb.mark_lesson_followed(claim_id, followed, context?) — append-only observation appended to audit.log.jsonl as a lesson.followed event; never edits the claim's text/status/any field
Registered across all four surfaces: CLI (vouch mark-lesson-followed), MCP tool, JSONL handler, capabilities.METHODS, and the _STANDARD tool profile
Repeat guard: no new code needed — propose_claim already runs find_similar_on_propose (#147) for every claim type, so proposing a near-duplicate lesson already surfaces a non-blocking similar_approved/similar_pending warning
Deliberately out of scope
The issue names an "effectiveness computation" system (cross-referenced as #2) as a downstream consumer of these events. That reference resolves to an unrelated PR, and no such system exists anywhere in this codebase under any name (verified via grep across src/vouch/). Rather than invent an unspecified analytics/scoring system, this PR ships events shaped for such a consumer (followed, context, claim_type fields) without building the consumer itself.
Design note
mark_lesson_followed isn't restricted to ClaimType.LESSON — it accepts any claim id, matching the issue's own proposed surface ("either a new ClaimType.LESSON or a flag on workflow/warning claims"). Covered by a dedicated test.

Testing

tests/test_lessons.py: 13 tests — claim type, retrieval resurfacing, observe-not-edit invariant, repeated observations, missing-claim error, not-restricted-to-LESSON, registration across capabilities/JSONL/MCP, and the repeat-guard warning
Full suite: ruff check / mypy clean, existing test_capabilities.py and similarity-warning tests (test_propose_similarity.py) unaffected
CHANGELOG.md updated under [Unreleased]

Summary by CodeRabbit

  • New Features

    • Added support for lesson claims.
    • Added lesson follow-through tracking with optional context through the CLI, MCP, and JSONL interfaces.
    • Follow-through records are stored as append-only audit observations without changing existing claims.
    • Added capability reporting and packaging updates for the new command.
  • Documentation

    • Added release notes for version 1.2.2, including MCP registry publication details and a vouch-kb command alias.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Adds a new lesson claim type (ClaimType.LESSON) and a kb.mark_lesson_followed operation that appends an append-only lesson.followed audit event, wired through CLI, MCP server, JSONL server, capabilities, and hot memory exclusion. Includes tests, CHANGELOG updates, and extensive formatting-only reflows across multiple files.

Changes

Lesson Follow-Through Feature

Layer / File(s) Summary
ClaimType.LESSON schema and model
schemas/claim.schema.json, src/vouch/models.py
Adds lesson to the ClaimType enum in both the JSON schema and the Python model, with an explanatory comment on follow-through semantics.
mark_lesson_followed lifecycle operation
src/vouch/lifecycle.py
Adds mark_lesson_followed(...) which loads a claim and appends a lesson.followed audit event with followed/context/claim type, without mutating the claim; includes formatting-only reflows of other audit.log_event calls and cite.
Capability, JSONL, and MCP wiring
src/vouch/capabilities.py, src/vouch/jsonl_server.py, src/vouch/server.py, src/vouch/hot_memory.py, src/vouch/mcp_profiles.py
Registers kb.mark_lesson_followed in METHODS, adds a JSONL handler/dispatch entry, adds MCP tool kb_mark_lesson_followed, and excludes the method from hot-memory sidebar decoration; also includes unrelated formatting-only reflows across these files.
CLI mark-lesson-followed command
src/vouch/cli.py
Adds vouch mark-lesson-followed command calling life.mark_lesson_followed(...); includes widespread formatting-only reflows of unrelated click.option declarations and call arguments.
Lesson tests and repeat-guard coverage
tests/test_lessons.py, tests/test_propose_similarity.py
Adds tests covering lesson persistence/retrieval, mark_lesson_followed immutability and audit behavior, cross-surface registration, and propose-time repeat-guard similarity warnings; updates embedder registry restoration in similarity tests.
CHANGELOG documentation
CHANGELOG.md
Documents the lesson claim type/kb.mark_lesson_followed feature and a separate 1.2.2 packaging release section.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • vouchdev/vouch#356: Extends the same kb.* method/capability registries and handler tables that this PR also modifies to add kb.mark_lesson_followed.

Suggested reviewers: plind-junior, jsdevninja, dripsmvcp

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.81% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Clear, specific title matches the lesson artifact and follow-through tracking changes.
Linked Issues check ✅ Passed Adds lesson claim type, append-only follow-through events, repeat warnings, registrations, and tests, matching #428's core requirements.
Out of Scope Changes check ✅ Passed No clear unrelated changes; edits stay within lesson support, registration, tests, and changelog updates.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added docs documentation, specs, examples, and repo guidance cli command line interface mcp mcp, jsonl, and http surfaces storage kb storage, migrations, schemas, and proposals tests tests and fixtures size: XL 1000 or more changed non-doc lines labels Jul 13, 2026
@Tet-9
Tet-9 force-pushed the feat/428-lessons-follow-through branch from 2d075f3 to f1b51cc Compare July 13, 2026 19:31
@Tet-9

Tet-9 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

@plind-junior , on for review

@Tet-9
Tet-9 force-pushed the feat/428-lessons-follow-through branch from f1b51cc to 3094bcf Compare July 14, 2026 03:05
@github-actions github-actions Bot added retrieval context, search, synthesis, and evaluation schemas json schemas and generated schema assets labels Jul 14, 2026
@Tet-9

Tet-9 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

@plind-junior , if you may review this now

@Tet-9
Tet-9 force-pushed the feat/428-lessons-follow-through branch from 3094bcf to 798e412 Compare July 16, 2026 06:23
@Tet-9
Tet-9 requested a review from plind-junior as a code owner July 16, 2026 06:23
@Tet-9

Tet-9 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

@plind-junior , if you may review this

@plind-junior

Copy link
Copy Markdown
Member

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

…dev#428)

Adds ClaimType.LESSON and kb.mark_lesson_followed -- an append-only
observation of whether a surfaced lesson was actually followed in a given
turn. Never edits the claim; appends a lesson.followed audit event with
followed, optional context, and claim_type.

Registered across all four surfaces: CLI (mark-lesson-followed), MCP
(kb_mark_lesson_followed), JSONL (kb.mark_lesson_followed), and
capabilities.METHODS. Added to the _STANDARD MCP tool profile alongside
kb.confirm, its closest existing analogue.

Lessons resurface through the normal retrieval path with no special-casing
anywhere in context.py -- verified directly, not assumed. The propose-time
repeat guard (vouchdev#147) comes for free: propose_claim already runs
find_similar_on_propose for every claim type regardless, so no new code was
needed for that acceptance criterion.

Not restricted to ClaimType.LESSON: mark_lesson_followed accepts any claim
id, matching the issue's own proposed surface ("either a new ClaimType.LESSON
or a flag on workflow/warning claims").

Deliberately does not build the "effectiveness computation" system vouchdev#428
names as a downstream consumer (vouchdev#2) -- that reference resolves to an
unrelated PR and no such system exists anywhere in this codebase under any
name (verified via grep). These events are shaped for such a consumer to
exist later; inventing an unspecified analytics system was out of scope.

tests/test_lessons.py: 13 tests covering the claim type, retrieval
resurfacing, the observe-not-edit invariant, multiple observations, missing-
claim handling, the not-restricted-to-LESSON case, registration in
capabilities/JSONL/MCP, and the repeat-guard warning.
@Tet-9
Tet-9 force-pushed the feat/428-lessons-follow-through branch from 798e412 to 382d1f9 Compare July 17, 2026 05:36

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/test_lessons.py`:
- Around line 161-174: Add a failure-path test alongside
test_jsonl_mark_lesson_followed_end_to_end that calls kb.mark_lesson_followed
with a missing claim_id and asserts the JSONL response preserves the request id,
sets ok to false, and includes an error field.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1161ef72-c121-4778-a019-9f52a647f07f

📥 Commits

Reviewing files that changed from the base of the PR and between af8bd61 and 382d1f9.

📒 Files selected for processing (12)
  • CHANGELOG.md
  • schemas/claim.schema.json
  • src/vouch/capabilities.py
  • src/vouch/cli.py
  • src/vouch/hot_memory.py
  • src/vouch/jsonl_server.py
  • src/vouch/lifecycle.py
  • src/vouch/mcp_profiles.py
  • src/vouch/models.py
  • src/vouch/server.py
  • tests/test_lessons.py
  • tests/test_propose_similarity.py

Comment thread tests/test_lessons.py
Comment on lines +161 to +174
def test_jsonl_mark_lesson_followed_end_to_end(store: KBStore, monkeypatch) -> None:
monkeypatch.chdir(store.root)
_lesson(store)
resp = handle_request(
{
"id": "r1",
"method": "kb.mark_lesson_followed",
"params": {"claim_id": "lesson-mypy", "followed": True},
}
)
assert resp["ok"] is True, resp
assert resp["result"]["id"] == "lesson-mypy"
assert resp["result"]["followed"] is True

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Add a test for the JSONL envelope failure shape.

As per path instructions and coding guidelines, every new kb.* method must include a test asserting the JSONL envelope shape for both success ({"id", "ok", "result"}) and failure ({"id", "ok": false, "error"}). This file currently only tests the success path for kb.mark_lesson_followed over JSONL.

💡 Proposed failure test
def test_jsonl_mark_lesson_followed_failure(store: KBStore, monkeypatch) -> None:
    monkeypatch.chdir(store.root)
    resp = handle_request(
        {
            "id": "r2",
            "method": "kb.mark_lesson_followed",
            "params": {"claim_id": "missing-claim", "followed": True},
        }
    )
    assert resp["ok"] is False
    assert resp["id"] == "r2"
    assert "error" in resp
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_lessons.py` around lines 161 - 174, Add a failure-path test
alongside test_jsonl_mark_lesson_followed_end_to_end that calls
kb.mark_lesson_followed with a missing claim_id and asserts the JSONL response
preserves the request id, sets ok to false, and includes an error field.

Sources: Coding guidelines, Path instructions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli command line interface docs documentation, specs, examples, and repo guidance mcp mcp, jsonl, and http surfaces retrieval context, search, synthesis, and evaluation schemas json schemas and generated schema assets size: XL 1000 or more changed non-doc lines storage kb storage, migrations, schemas, and proposals tests tests and fixtures

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants