Phase 4: Knowledge tiering — include_cold param on list_notes #190
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#190
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Lineage
plan-2026-03-16-knowledge-architecture→ Phase 4 (Knowledge Tiering — list_notes Default Exclusion)Repo
forgejo_admin/pal-e-docsUser Story
As a session startup hook querying
list_notes(project="pal-e-agency"),I want completed/historical notes to be excluded by default,
so that the response is ~60 notes instead of ~131 and I don't burn 21K tokens on dead weight every session.
Context
list_notescurrently returns ALL notes matching filters — no concept of lifecycle tiering. The pal-e-agency project has ~131 notes, but ~70 are completed phases, done TODOs, or deprecated notes that aren't relevant to active work. Session injection pays the full cost every time.Tiering rules (computed, not stored):
{completed, done, deprecated, deferred, archived}— excluded by defaultThis is the simple, first-pass rule (status-based only). Parent-chain recursive CTE (notes under completed milestones) is a stretch goal for a subphase.
File Targets
Files to modify:
src/pal_e_docs/routes/notes.pyline 360-410 (list_notesendpoint) — addinclude_cold: bool = Query(False, ...)param. DefineCOLD_STATUSES = {"completed", "done", "deprecated", "deferred", "archived"}as a module-level constant. Wheninclude_coldis False, add.filter(Note.status.notin_(COLD_STATUSES))to the query. The filter should be applied AFTER existing filters (tags, project, note_type, status, parent_slug) so explicitstatus=completedstill works even withinclude_cold=False.Important edge case: When the caller explicitly passes
status=completed(or any cold status), they clearly want cold notes. In this case,include_coldfiltering should NOT override the explicit status filter. Implementation: skip the cold exclusion filter whenstatusis explicitly provided.Files NOT to touch:
src/pal_e_docs/routes/notes.pysearch endpoints — semantic_search and search_notes are unaffectedsrc/pal_e_docs/models.py— no schema changesAcceptance Criteria
include_coldboolean query param onGET /notes— defaultfalseCOLD_STATUSESconstant defined at module level:{"completed", "done", "deprecated", "deferred", "archived"}include_cold=false(default), notes with status in COLD_STATUSES are excludedinclude_cold=true, all notes returned (existing behavior)status=completedis explicitly provided, cold exclusion is skipped (explicit status overrides)parent_slugqueries still work correctly (child notes of a parent returned regardless of cold status if include_cold=true)pytest tests/)Test Expectations
list_noteswith default params excludes completed/done/deprecated noteslist_notes(include_cold=true)returns all notes including completedlist_notes(status=completed)returns completed notes even with include_cold=falselist_notes(project=X)with mix of hot and cold notes returns only hot by defaultpytest tests/ -x -qConstraints
list_notes(FastAPI Query params)COLD_STATUSESshould be a frozenset for immutability and O(1) lookup.filter()added to the queryChecklist
Related
project-pal-e-docs— project this affectsplan-2026-03-16-knowledge-architecture— parent planphase-2026-03-16-2-milestone-note-type— prerequisite (milestone note_type exists)