Skip to content

feat(query): add temporal_relation and evidence_request plan steps - #147

Open
Sidra-009 wants to merge 3 commits into
grayhatdevelopers:mainfrom
Sidra-009:feature/llm-query-planning
Open

Sidra-009 wants to merge 3 commits into
grayhatdevelopers:mainfrom
Sidra-009:feature/llm-query-planning

Conversation

@Sidra-009

Copy link
Copy Markdown

Related issue

Related to #84

Summary

Extends the local-model query-planning path with support for temporal
relations, occurrence modes, and evidence-delivery requests, per the
examples listed in #84.

  • Adds OccurrenceMode (first / best / all) to SearchMomentsPlanStep.
  • Adds TemporalRelationPlanStep for before/after/during queries between
    two searches.
  • Adds EvidenceRequestPlanStep for requesting a board or exact
    clips/frames as evidence.
  • Adds matching opt-in flags (temporal_relations_allowed,
    evidence_requests_allowed) to QueryPlanningRequest, defaulting to
    False.
  • Updates _default_plan, _valid_plan, and GroundedQueryService.plan
    in query_service.py to accept and validate the new step types, with
    the same default-False opt-in behavior.

This is an internal, application-layer change: no CLI, HTTP, MCP, or
frontend surface calls the new parameters yet, and existing callers are
unaffected since all new parameters default to False.

Out of scope for this PR (left as follow-up per #84, to keep this PR
focused on one outcome):

  • Recording which local model and planning-rules version produced a
    plan, for reproducibility.
  • The evidence-review guardrail for generated names/biographies/
    descriptions.

Validation

uv run --no-sync ruff check .

All checks passed!

uv run --no-sync pytest tests/test_query_service.py tests/test_application.py tests/test_control_plane.py tests/test_job_contracts.py --tb=short

65 passed in 3.43s

The full pytest -q suite could not be run end-to-end locally: several
unrelated test modules fail to collect because of pre-existing missing
optional dependencies (torch, streamlit, fastapi, httpx,
cryptography, alembic, numpy, etc.) unrelated to this change, and
uv sync --extra local-worker timed out downloading torch due to a
local network issue. These gaps were present before this change as well.

@tulayha tulayha left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Keeping this focused on planning is fine, but accepted plans must stay within supported behavior. Please address the two inline findings and keep temporal/evidence steps disabled until execution supports them.

Please also remove the unrelated pytest dev-group and lockfile changes; the repository already provides a test extra.

kind: Literal["search_moments"] = "search_moments"
modality: Identifier
query: SearchQuery
occurrence_mode: OccurrenceMode = OccurrenceMode.best

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

first and all pass plan validation, but execution ignores this field and performs the usual ranked search. Please implement the selected mode or reject unsupported modes so the existing fallback is used. Add coverage for this behavior.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed first/all now reject at plan validation and fall back to the existing ranked search, best stays supported. added test coverage for both the rejection and fallback paths..........

evidence_steps = sum(
isinstance(step, EvidenceRequestPlanStep) for step in plan.steps
)
if not temporal_relations and temporal_steps > 0:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This checks whether temporal steps are enabled, but does not validate their target modality. A plan with target_modality="nonexistent" passes when temporal planning is enabled. Please check it against search_modalities and cover rejection and fallback.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed......... target_modality on TemporalRelationPlanStep now gets checked against search_modalities, unknown modality gets rejected using the same fallback pattern as the rest of the file. added tests for rejection + fallback here too

… target_modality

- Reject first/all occurrence modes, fall back to ranked search since
  execution doesn't implement them yet
- Validate TemporalRelationPlanStep.target_modality against
  search_modalities, reject unknown modalities with existing fallback
- Add test coverage for both rejection paths
- Remove unrelated pytest dev-group from pyproject.toml/uv.lock

Addresses review comments from @tulayha on grayhatdevelopers#147
@Sidra-009

Copy link
Copy Markdown
Author

@tulayha also removed the unrelated pytest dev-group + lockfile changes from pyproject.toml/uv.lock, using the existing test extra now like u mentioned

ruff clean, 71 passed............ lmk if anything else needs work

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.

2 participants