Skip to content

fix: index scoping, outside-tree warnings, compile --json payload, and pass@1 qualifiers - #41

Merged
trakshan-mishra merged 3 commits into
mainfrom
fix/index-scoping-and-agent-json
Aug 23, 2026
Merged

fix: index scoping, outside-tree warnings, compile --json payload, and pass@1 qualifiers#41
trakshan-mishra merged 3 commits into
mainfrom
fix/index-scoping-and-agent-json

Conversation

@trakshan-mishra

Copy link
Copy Markdown
Owner

What

Two independently-revertable commits:

1. docs: oracle-seed and django-dominance qualifiers (docs only)

The front page states "context roughly quadruples pass@1: 5.5% → 25.8%" with no qualifiers. Two were missing, both already in RESULTS.md §6:

  • (a) seeds are oracle — extracted from the gold patch — so this measures "given correct localization, does context quality matter?", not end-to-end issue solving;
  • (b) 121 of 128 effective tasks are django.

Added wherever the number appears: README, CHANGELOG v0.5.0, docs/BENCHMARKS.md, website benchmarks.mdx, the measured-limits card (rendered by index.mdx), llms-status.md. Does not soften the result — states it precisely.

2. fix: index scoping + compile --json payload (source)

Task C — the scoping bug. diffcontext index . excluded tests/, benchmarks/, docs/ by default with no override and no explanation. A --ref change spanning an excluded dir produced 14 generic "typo, renamed, or deleted" warnings and omitted the changed file — the tool looked broken when it was merely mis-scoped.

  • find_python_files(..., include=...) + index_repository(repo, include=...) + --include <dir> flag on all commands. .gitignore still beats --include.
  • warn_unknown_symbols now names the excluded dir and says "re-run with --include <dir>" instead of the generic typo message.
  • diffcontext index prints a one-line scope summary (N files across which dirs, what was skipped).
  • Regression tests: tests/test_index_scoping.py (9 tests).

Task D — agent JSON payload. compile --json returned only counts + context text, so an agent couldn't inspect/filter the selection. Added included_symbols (id, role, score, tokens) and dropped_symbols (id, score). Existing keys kept for backwards compat.

Verification

  • ruff check diffcontext/ tests/ — clean
  • mypy diffcontext/ — clean (33 files)
  • pytest tests/ — 247 passed, 2 skipped

⚠️ Do not merge yet

This is held open pending a downstream pass@1 falsification test (Task A) comparing diffcontext vs bm25 vs samefile vs none on all 128 ContextBench tasks. If diffcontext does not beat bm25 downstream, the Task B wording needs another pass and should not be on main yet. Merge after that result lands.

The front page states 'context roughly quadruples pass@1: 5.5% -> 25.8%'
with no qualifiers. Two are missing, both already documented in
benchmarks/contextbench/RESULTS.md section 6:

(a) the seed functions given to every arm are ORACLE, extracted from the
    gold patch -- the real claim is 'given correct localization, does
    context quality matter?', not end-to-end issue solving;
(b) 121 of the 128 effective tasks are django, so this is largely a
    django result.

Added both qualifiers wherever the number appears: README, CHANGELOG
v0.5.0 notes, docs/BENCHMARKS.md, website benchmarks.mdx, the
measured-limits card rendered by index.mdx, and llms-status.md.

Does not soften the result -- states it precisely. Source unchanged.
Task C -- index scoping. `diffcontext index .` excluded tests/,
benchmarks/, docs/ by default (scanner.EXCLUDED_DIRS) with no way to
override and no explanation when a --ref change spanned an excluded dir
(the single biggest practical gotcha: 14 generic "typo, renamed, or
deleted" warnings and the changed file omitted entirely).

  - `find_source_files` / `find_python_files` take an `include` set of
    directory names to keep despite the default exclusions. .gitignore
    still applies (a gitignored dir is not indexed even with --include).
  - `index_repository(repo, include=...)` threads it through; the cache
    key covers the include set.
  - `--include <dir>` flag on index/impact/diff/compile/blast/verify.
  - `warn_unknown_symbols` now distinguishes "the symbol's file is in an
    excluded dir" from a real typo: it names the dir and says
    "re-run with --include <dir>" instead of the generic message.
  - `diffcontext index` prints a one-line scope summary: N files across
    which top-level dirs, and which source-like dirs were skipped.

Task D -- compile --json payload. `compile --json` returned only
symbol_count/token_estimate/total_repo_tokens/reduction_pct/context, so a
calling agent could not inspect or filter the selection (USAGE.md
advertises --json as "machine-readable, for scripts and agents").

  - Added `included_symbols` (id, role, score, tokens) and
    `dropped_symbols` (id, score) to the JSON payload. Existing keys
    kept for backwards compatibility.

Regression tests: tests/test_index_scoping.py (9 tests) pin the
outside-tree warning path, the --include override, and the gitignore
precedence. ruff + mypy + 247 tests clean.
@qa-tech-integration

Copy link
Copy Markdown

👀 QA.tech will run a exploratory tests to review this PR as soon as a deployment is available for this PR. Alternatively, you can comment @qa.tech to manually trigger a review.

Learn more about configuring preview deployments.

What happens next

  1. ⏳ Waiting for your preview deployment or a comment mentioning @qa.tech
  2. 🔍 Running full end-to-end tests to validate your changes
  3. 📝 Delivering detailed results and actionable feedback

🤖 AI end-to-end testing powered by QA.tech
For organization dc project Web app (kEw2). You can customize integration settings for this project.
💡 Comment @qa.tech to re-run tests, ask a follow-up, or request a focused review — e.g. @qa.tech test the checkout flow.

@qa-tech-integration

qa-tech-integration Bot commented Aug 23, 2026

Copy link
Copy Markdown

🤖 QA.tech is queued to run end-to-end and exploratory tests on this PR. We'll update this comment as the review progresses.

Track progress →

📋 Details

Repository: trakshan-mishra/Diffcontext
PR: #41
Commit: 1b0efc7


🤖 AI end-to-end testing powered by QA.tech
For organization dc project Web app (kEw2). You can customize integration settings for this project.
💡 Comment @qa.tech to re-run tests, ask a follow-up, or request a focused review — e.g. @qa.tech test the checkout flow.

…e vs none)

Task A -- the experiment that decides whether the project has a product
claim beyond 'context helps.' Four arms (none, diffcontext, bm25, samefile)
on the same 128 ContextBench tasks, same oracle seeds, same 4000-token
budget, same model (GLM 5.2), same prompt. The ONLY difference is which
supporters fill the budget after the seeds. All arms use a shared renderer
(seeds + render_context, no meta-header) via --shared-renderer, so no arm
gets DiffContext's graph-derived meta -- the selection algorithm is
isolated.

  --shared-renderer flag on run_glm_pass1.py routes diffcontext/bm25/samefile
  through compile_arm_context (seeds first, then render_context from
  benchmarks.downstream.providers). bm25/samefile are only meaningful with
  this flag; without it they fall back to empty context.

  analyze_arms.py: full 4-arm pass@1 with Wilson CIs + all 6 pairwise exact
  McNemar tests (not just the headline pair).

Results (128 attempted, 0 setup errors, 544 rows, provenance a494b47):

  none        10/128  7.8%  [0.043, 0.138]
  samefile    33/128 25.8%  [0.190, 0.340]
  bm25        37/128 28.9%  [0.218, 0.373]
  diffcontext 41/128 32.0%  [0.246, 0.405]

Context vs none replicates robustly (p < 1e-5 on all three context arms).
DiffContext does NOT beat bm25 (p=0.503) or samefile (p=0.115) at p<0.05
-- indistinguishable at n=128 with ~20 discordant pairs per comparison.
Directional ordering diffcontext > bm25 > samefile is consistent but not
resolvable at this sample size. samefile is competitive: 'just include the
rest of the file' solves 25 tasks none fails (vs 33 for diffcontext).

This is a falsification test, reported plainly. The honest framing:
structural retrieval matches lexical and same-file retrieval downstream at
this sample size, on django, under oracle localization. The graph is not
measurably earning its complexity yet. Resolving the directional signal
needs ~10x more tasks (cloning the other 17 ContextBench repos), not more
seeds.

Appended to benchmarks/contextbench/RESULTS.md as section 3b.
@trakshan-mishra
trakshan-mishra merged commit 60403b6 into main Aug 23, 2026
8 of 9 checks passed
@trakshan-mishra
trakshan-mishra deleted the fix/index-scoping-and-agent-json branch August 23, 2026 14:58
trakshan-mishra added a commit that referenced this pull request Aug 23, 2026
First release available as 'pip install diffcontext'. Restores the
trusted-publishing workflow deleted in 99b9eac (the pypi.org side was
never set up; now configured via OIDC trusted publisher, no API token).

Bumps 0.5.0 -> 0.5.1 because v0.5.0 tag already exists and re-pushing
won't retrigger the workflow. Includes the index scoping fix, compile
--json payload, and 4-arm falsification test from #41.

No functional changes to the retrieval pipeline.
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