Skip to content

Prototype task-conditioned program slicing for context packs #73

@mohanagy

Description

@mohanagy

Goal

Add a prototype slicer that turns a user task into anchors and computes a backward/forward program slice before building the context pack.

Why

Current retrieval can become inconsistent because nearby graph nodes are not always behaviorally relevant. For coding tasks, the useful unit is often the program slice: what affects this behavior, and what this behavior affects.

Target mental model

user task / PR diff
→ classify intent
→ extract anchors
→ compute backward + forward slice
→ rank evidence
→ pack under budget

Initial task modes

Start small:

  1. explain
  2. debug
  3. pr-review
  4. impact

Slice behavior by mode

explain

  • Anchor: matching symbol/file/route
  • Include: local implementation, direct callees, key callers, public signature, short behavior sketch
  • Avoid: broad unrelated callers, DTO/type-only noise unless boundary-relevant

debug

  • Anchor: error term, stack-trace path, symbol, route, or domain terms
  • Backward slice: inputs/config/env/guards/db reads
  • Forward slice: side effects, external calls, DB writes, queues/events
  • Include: tests and suspicious conditions when available

pr-review

  • Anchor: changed ranges → containing symbols
  • Include: callers/callees, public API boundary, tests, config/db/API contract edges
  • Exclude: generic utilities unless changed or directly on path

impact

  • Anchor: target symbol/file
  • Include: dependents, callers, runtime entrypoints, tests, contract boundaries

Deliverables

  • New internal slicer module
  • Task classifier/anchor extraction module, even if heuristic in v1
  • Context-pack integration behind an opt-in flag, e.g. --strategy slice or equivalent existing command surface
  • Unit tests with fixtures
  • Comparison docs showing current retrieval vs slicing prototype on at least 3 prompts

Acceptance criteria

  • Slicer can produce a bounded set of nodes/edges for explain/debug/pr-review/impact modes
  • It supports both backward and forward traversal directions
  • It respects an explicit token/node budget
  • It emits a reason for each selected node/path
  • It can be compared against existing retrieval without breaking current behavior

Suggested labels

enhancement, research, retrieval, context-quality, performance

Metadata

Metadata

Assignees

No one assigned

    Labels

    context-qualityQuality of the compiled context packenhancementNew feature or requestperformanceRuntime, latency, throughput, or token-cost workresearchResearch spike or measurement workretrievalGraph retrieval / search / candidate selection

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions