Skip to content

Backfill prompt sessions for origin filters - #98

Draft
tony wants to merge 1 commit into
masterfrom
fix/origin-filter-session-prompts
Draft

Backfill prompt sessions for origin filters#98
tony wants to merge 1 commit into
masterfrom
fix/origin-filter-session-prompts

Conversation

@tony

@tony tony commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Keep prompt-scope searches on the prompt-history fast path for bare text queries.
  • Backfill prompt-capable session/conversation sources when prompt-scope searches include origin filters such as cwd, repo, worktree, or project fields.
  • Preserve prompt result filtering while allowing metadata-bearing session stores to participate.

Verification

  • rm -rf docs/_build; uv run ruff check . --fix --show-fixes; uv run ruff format .; uv run ty check; uv run py.test --reruns 0 -vvv; just build-docs;

Goal

Idempotent completion condition for /goal. It asserts an end state, not an action: if the state already holds, the first evaluation passes and nothing is edited.

/goal Work only in a worktree on PR #98's branch fix/origin-filter-session-prompts at the pushed PR head; its existing worktree is 249 commits stale, so refresh it. Never touch the shared master tree, never push. First report git rev-parse --abbrev-ref HEAD, git rev-list --count HEAD..master (23 today), rg -c origin_fields src/agentgrep/query/compile.py (2 here, 0 on master) and ls tests/test_origin_prompt_sources.py (absent today). If they read that branch, 0, 2 and a module that exists and passes, make no edits and stop. End state there: rebased onto local master, with tests/test_origin_prompt_sources.py present and green under .venv/bin/python -m pytest, proving that a prompt-scope search with an origin constraint (cwd, repo, worktree or branch; as an explicit filter and as a compiled query field) surfaces prompts from the origin-bearing session stores of an agent that also has a prompt-history store, while the same query without one still takes the prompt-history-only path and opens no session store. Constraints: keep the five-file engine change in shape, no unrelated refactor; prompt scope still emits only prompt-kind records; CompiledQuery.origin_fields stays planner-internal - no facade re-export, frontend consumption or public-API docs. Do not frame this as an implicit deep search and add no also-search-conversations flag: scope keeps selecting record kinds while a later effort axis selects how much source material is read. PR #72 also extends CompiledQuery there; do not pre-resolve that conflict. Finally report exiting 0: rm -rf docs/_build; uv run ruff check . --fix; uv run ty check; NO_COLOR=1 env -u VIRTUAL_ENV -u UV_NO_SYNC .venv/bin/python -m pytest -m "" --reruns 0 -q; just build-docs. Or stop after 12 turns and report what remains.
  • Proofgit rev-parse --abbrev-ref HEAD; git rev-list --count HEAD..master; rg -c origin_fields src/agentgrep/query/compile.py; NO_COLOR=1 env -u VIRTUAL_ENV -u UV_NO_SYNC .venv/bin/python -m pytest tests/test_origin_prompt_sources.py -q; rm -rf docs/_build; uv run ruff check . --fix; uv run ty check; NO_COLOR=1 env -u VIRTUAL_ENV -u UV_NO_SYNC .venv/bin/python -m pytest -m "" --reruns 0 -q; just build-docs
  • Idempotence — Once the worktree HEAD is the branch, its behind-count against local master is 0 and the regression module exists and passes, the probes report satisfied on the next turn and no rebase or edit happens.
  • Blocked by — nothing - the branch merges into master today; its only overlap is Add OpenTelemetry local observability #72, which also extends CompiledQuery in query/compile.py and is explicitly left unreconciled here
  • Blocks — nothing
  • Preserves — scope stays a record-kind selector and is never fused with effort, so a later progressive-depth ladder still owns how much source material is read; CompiledQuery.origin_fields stays planner-internal so predicate placement can move without a public-field break; the Add OpenTelemetry local observability #72 field-predicate overlap is left for its own reconciliation

@tony
tony force-pushed the fix/origin-filter-session-prompts branch from b8fb9e4 to c7aeffc Compare July 11, 2026 00:02
@tony
tony force-pushed the fix/origin-filter-session-prompts branch from c7aeffc to a5b00d9 Compare July 18, 2026 11:19
@tony
tony force-pushed the fix/origin-filter-session-prompts branch from a5b00d9 to 9ef8c18 Compare July 19, 2026 00:40
@tony
tony force-pushed the fix/origin-filter-session-prompts branch from 9ef8c18 to 4fe20ec Compare July 19, 2026 01:40
@tony
tony force-pushed the fix/origin-filter-session-prompts branch from 4fe20ec to 6965ea2 Compare July 19, 2026 16:48
@tony
tony force-pushed the fix/origin-filter-session-prompts branch from 6965ea2 to 4f4eee8 Compare July 19, 2026 23:14
@tony
tony force-pushed the fix/origin-filter-session-prompts branch from 4f4eee8 to 16641c7 Compare August 1, 2026 18:22
why: Project-scoped prompt queries should return prompt records even when the matching project metadata lives in session stores rather than dedicated prompt-history files. Without a targeted backfill, origin filters can miss prompt records unless users know to widen scope manually.

what:
- Track origin fields on compiled queries so prompt searches can distinguish project filters from unrelated compiled predicates.
- Backfill conversation/session sources for prompt-scope origin filters while preserving the bare prompt-history fast path.
- Cover query-language cwd filters, explicit origin filters, and plan-time scope pruning.
@tony
tony force-pushed the fix/origin-filter-session-prompts branch from 16641c7 to cc5161f Compare August 9, 2026 12:05
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