feat: add include_cold param to list_notes for knowledge tiering #191
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/pal-e-api!191
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "190-include-cold-param-list-notes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds knowledge tiering to
list_notesvia aninclude_coldquery parameter. Cold notes (status in completed/done/deprecated/deferred/archived) are excluded by default, reducing session injection from ~131 notes to ~60 for pal-e-agency. Explicitstatus=param overrides the exclusion, andinclude_cold=truerestores full backward-compatible behavior.Changes
src/pal_e_docs/routes/notes.py-- AddedCOLD_STATUSESfrozenset constant,include_coldQuery param onlist_notes, and filter logic that skips cold exclusion whenstatusis explicitly provided. Handles NULL status correctly viaor_clause.tests/test_include_cold.py-- 6 new tests covering default exclusion, include_cold=true, explicit status override, done status, project filter + cold exclusion, and project filter + include_cold.Test Plan
pytest tests/ -x -q-- all 638 tests pass (632 existing + 6 new)ruff formatandruff checkcleaninclude_cold=truereturns all notesstatus=completedreturns completed notes even with defaultinclude_cold=falsestatus=donereturns done notesReview Checklist
Related
plan-2026-03-16-knowledge-architecturePR #191 Review
DOMAIN REVIEW
Tech stack: Python / FastAPI / SQLAlchemy (ORM queries) / pytest with TestClient
Route logic (
src/pal_e_docs/routes/notes.py)COLD_STATUSESis declared as a module-levelfrozenset[str]-- immutable, type-annotated, well-documented. Good.The
include_coldQuery parameter defaults toFalsewith a clear description string. Placement beforelimit/offsetin the parameter list is consistent with filter params above.The filter logic at line 412-413 is correct and clean:
statusis explicitly provided, the cold filter is skipped entirely -- this is the right approach because the caller is explicitly asking for that status.Note.status.is_(None)correctly handles NULL status values so notes without a status are never accidentally excluded.or_import was added to the existingsqlalchemyimport line. Clean diff.The filter is placed AFTER the
parent_slugfilter and BEFORE the ordering logic. This is the correct position -- it does not interfere with parent resolution or ordering.Search endpoints (
/notes/search,/notes/semantic-search) are correctly NOT affected. They use raw SQL via_build_filter_clauses/text()and have their ownstatusparameter. The cold exclusion is scoped only to the ORM-basedlist_notes.COLD_STATUSES consistency check against VALID_STATUSES:
completed: appears in plan, phase, sprint, milestone -- correct to be cold.done: appears in todo -- correct to be cold.deprecated: appears in sop, convention, template, skill, agent -- correct to be cold.deferred: appears in plan, phase -- correct to be cold.archived: appears in project-page, doc, sprint, post -- correct to be cold.resolved(incident): arguably cold, but incidents are a different lifecycle. Reasonable to leave out for now.published(journal, post): active content, NOT cold. Correct exclusion from the set.All five cold statuses are terminal/inactive states. The set is well-chosen.
Tests (
tests/test_include_cold.py)6 tests covering:
include_cold=truereturns all 10 notes.status=completedoverrides cold exclusion -- returns only completed notes.status=doneoverrides cold exclusion -- returns only done notes.project=agencycombined with cold exclusion -- verifies project filter and cold filter compose correctly.project=agency&include_cold=true-- verifies project filter with cold inclusion returns all 9 project notes.Tests use the shared
_seed_noteshelper which creates a realistic mix of hot/cold/NULL-status notes across a project. The helper asserts creation success, which is good defensive testing.The
clientfixture usesautouse=Truesetup_dbwhich drops/recreates all tables between tests, so test isolation is solid.PEP compliance:
frozenset[str],bool,str | None).BLOCKERS
None.
include_coldis aboolQuery param, FastAPI validates it automatically.NITS
Missing
note_type+ cold exclusion test: Whennote_type=phaseis specified butstatusis NOT, the cold filter still applies (becausestatus is Nonein the condition). This meansGET /notes?note_type=phasewould return only non-cold phases. This is correct behavior, but there is no test coveringnote_typefilter combined with cold exclusion. Consider adding one in a follow-up._seed_notesdocstring says "Returns a dict" but the function returnsNone. The docstring is inaccurate -- it is a void helper. Minor copy-paste artifact.resolvedstatus consideration: Incidentresolvedstatus could arguably be cold. Worth a brief comment in theCOLD_STATUSESdefinition noting the intentional exclusion ofresolved(since incidents have a different lifecycle). Not blocking -- the current set is defensible.SOP COMPLIANCE
190-include-cold-param-list-notesreferences issue #190plan-2026-03-16-knowledge-architecturereferenced,Closes #190presentPROCESS OBSERVATIONS
include_coldget the new filtering behavior, which is the intended optimization. The explicitstatus=override ensures no breaking change for callers that filter by specific statuses.VERDICT: APPROVED