Self-scan context pack: per-issue "read file:X-Y" pointers from the master DB for churn workers
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 44/100
Research direction
Start by reading tests/tools/self_scan.py, the self-scan orientation doc, and the master DB schema for file_data, function_data, class_data, fcall_data, and edge_data. Build the context pack around the issue text, then check its output and token cap against the listed fixture cases and five recent closed churn issues. Done means the tests pass, each pack stays within 3,000 tokens and names files changed by the merged PRs, runtime stays under 10 seconds, and the stated doc fixes are handled.
Written by the indexing model from the issue text.
Description
Why
A cost audit of nyx's churn workers (2026-10-18, 16 worker sessions, 10 merged PRs at ~$2/PR) found:
- Workers get only the issue number and title. Each one finds the code itself, taking 5-14 grep/
sed -nrequests before its first edit. Orientation accounts for ~45% of worker spend, though most of that is the fixed ~40k-token starting context that every request re-reads. - Whole-file reads are the main trap.
gitgalaxy/core/detector.pyis ~135k tokens, and seven files are over 60k tokens each. The golden-master JSON fixtures run up to 606k lines. - The self-scan already has what is needed to point a worker straight at the code, but nothing turns it into a per-issue slice:
- The master DB's
function_datahasstart_line,loc, complexity, fan-in/fan-out andtoken_mass. fcall_dataholds the resolved call graph andedge_datathe import edges.file_datahastoken_mass, churn and blast radius.- The existing LLM brief (
_llm.md) is ~137 KB (~34k tokens), too big to inject.
- The master DB's
What
Add a tool, e.g. tests/tools/context_pack.py <issue> [--db docs/self_scan/gitgalaxy_master.db] [--max-tokens 3000]. Given an issue, it would:
- Pull out the paths, file names, function, class and symbol names, and backticked identifiers named in the issue body and title (
gh issue view --json title,body). - Resolve them against the master DB (
file_data,function_data,class_data). Fuzzy-match bare names and rank matches by how often they are mentioned. - For each hit, emit
path:start-end(fromstart_line+loc), complexity and token size. Add one hop of callers and callees fromfcall_data, each with its ownpath:start-end, and import fan-in fromedge_data. - Flag large files (
token_mass> 8k, asdev_agent_firewalldoes) with "read only the named ranges". - Print a Markdown block capped at about 1-3k tokens that a worker brief can include verbatim. If nothing resolves, print nothing; never pad.
Freshness: keep one DB per origin/main commit (tests/tools/self_scan.py already does delta mode, ~6-8 s; a full scan is ~1.5 min). Run the pack before the worker launches, so a stale DB is off by at most the commits since the last refresh. Line ranges are hints and the worker still reads the code.
Integration (separate PR in squid-protocol/promoter-bot): churn worker runs the tool and adds its output to prompt.md under "Where to look". That is a few lines once the tool exists.
Related cleanups found during the audit
CLAUDE.md:103points agents atdocs/gitgalaxy_architecture_brief.md. That file moved to thegeneratedbranch, so a local checkout has nothing there.docs/agents/self-scan-orientation.mdsays the DB "has no line numbers". That is stale:function_data.start_lineis populated.- Delta-mode briefs written into worker worktrees (e.g.
churn-5464_galaxy_llm.md) report "0 analyzed artifact(s), 0 LOC". Either fix them or stop writing them.
Acceptance
-
context_pack.pyproduces a pack of 3k tokens or less for at least 5 recent closed churn issues, and for each one the pack names the file(s) the merged PR actually changed. Show the hit rate in the PR body. (#6354) - Unit tests on a small fixture DB: exact path, bare function name, class name, no matches (empty output) and the token cap. (#6145)
- Runs in under 10 s against an existing DB. It needs no network access apart from
gh issue view, and it accepts--body-filefor offline use. (#6145) - The doc fixes above. (#6145)
- Follow-up issue or PR filed on promoter-bot to wire it into
churn worker.
- Dominant language
- Python
- Stars
- 57
- Forks
- 11
- Avg merge
- 1h 35m
- Merged PRs (30d)
- 975
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from squid-protocol/gitgalaxy
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
squid-protocol/gitgalaxy#7827 · 1 comment ·
Maintainers usually reply within 1 day
-
scope:frontier
Difficulty 5/5 Over a week Newbie friendliness 18/100
squid-protocol/gitgalaxy#7900 ·
Maintainers usually reply within 1 day
-
core-engine scope:infra testing
Difficulty 4/5 3-5 days Newbie friendliness 54/100
squid-protocol/gitgalaxy#7863 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
squid-protocol/gitgalaxy#7834 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 56/100
squid-protocol/gitgalaxy#7828 · 1 comment ·
Maintainers usually reply within 1 day
All issues in squid-protocol/gitgalaxy
Similar issues
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
graphql-python/graphql-core#304 ·
Maintainers usually reply within 1 day
-
docs size:S
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
Gathin23/cleanyourtv#3464 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day