Repository navigation
Description
Problem
When a codebase analytics or indexing run is killed (exit -9: OOM, a signal, or a time limit), the findings it had already stored are shown afterwards as if they were the complete result. Nothing records that the run did not finish, so the UI cannot say so.
Evidence
From the owner's evidence comment on #20493 (2026-11-02, read-only observation of stored data and task records; timestamps UTC):
Cause of the top-level-only results, for the whole-repo source: an indexing run was killed partway, and its partial findings are shown as if they were the result.
| Evidence | Value |
|---|---|
| Findings stored for that source | 2,300 |
| Written between | 14:43:43 and 14:54:51 UTC on 2026-11-01 |
| Latest task record | failed, started 14:25:50, ended 14:54:53, Indexing subprocess crashed (exit code -9) |
| Previous task record | the same failure, 10:54:21 to 11:23:31 |
| Stats document for that source | none; the other source, whose run completed, has one |
autobot-backend files with findings |
88, none below its top level (the repo has 5,187 Python files there, 169 at the top level) |
The kill came 2 seconds after the last finding was written. Files were analysed first and stored in walk order, so a run cut off during storing leaves mostly shallow paths.
Why the run was killed isn't established: both failed runs lasted about 29 minutes, which suggests a limit, and
_wait_with_watchdogand the hard timeout both return-9. No log line for it survives. The kernel log showed nothing, but that's weak evidence here.
The task records do not name their source, so tying the failed record to this source rests on timing. The owner's comment states that the page "shows results from a failed run with nothing saying so".
Impact
- Code-smell and other analytics results from a killed run look like a whole-repo result. bug(analytics): code smell results look limited to top-level files, and counts disagree with their cards #20493 reports findings confined to top-level files, and card counts that disagree with the JSON.
- Users and maintainers act on incomplete findings (triage, sizing, "is this file clean?") without any signal that coverage was partial.
- The same gap hides a failed run's status: there is no stats document for the failed source, so the reader falls back to whatever findings exist.
Related
- bug(analytics): code smell results look limited to top-level files, and counts disagree with their cards #20493 (the symptom that exposed this defect)
- fix(analytics): code smell counts derive from the returned list, shared root-relative discovery (#20493) #21002 (fix PR for bug(analytics): code smell results look limited to top-level files, and counts disagree with their cards #20493)
- bug(analytics): opening Codebase Analytics starts scans, last results can't be viewed, and no reindex or change tracking #20491 (analytics page starts scans and cannot show the last run's results)
- umbrella(codebase-analytics): runs are not durable — persist, resume, and compare against the previous run #18115 (umbrella: runs are not durable)
- Indexing is killed by its own watchdog right after the scan, so nothing is ever persisted #18055 (the run is killed by its own watchdog, so nothing persists; the opposite face of the same kill)
Acceptance criteria
- A run records a terminal status (
completed,failedorkilled), with the reason, on every exit path, and the UI labels any result from a non-completed run as partial. - A run with no
completedstatus is never presented as the latest complete result; the last completed run is shown instead, with a visible note that a newer run did not finish. - A test simulates a killed run (subprocess exits -9 after storing some findings) and asserts the recorded status is
killedand the UI or API response marks the results partial. - The reason for the kill is investigated (memory limit or time limit, using the watchdog and hard-timeout values and the process exit path) and the determined reason is recorded in the run record and in this issue.
Notes
- Fix one defect in one place: the run-status record and the read path that chooses "latest result". Do not patch each analytics panel separately.
- The cause investigation is open per the evidence comment; the AC is to determine and record it, not to assume it.
Activity
github-actions commentedon Nov 7, 2026
needs-structurecleared: goal milestone, matching phase label and native parent (or sub-issues) are all present (#19522).mrveiss commentedon Nov 7, 2026
Progress on #21003: backend half done locally, kill cause not established
The backend half is committed locally as
c7603b3f74(not pushed). The UI banner and thestats/reportwiring are not done yet.Lifecycle trace (paths under
autobot-backend/api/codebase_analytics/)endpoints/indexing.py(around line 250) calls_run_indexing_subprocessinsubprocess_runner.py, which launchesindexing_worker.py.indexing_task:<id>with a 24h TTL (progress_tracker.py,_TASK_REDIS_TTL). Status is written by_create_initial_task_state,_mark_task_completedand_mark_task_failed. After 24h the failed run's record is gone.problem_storage.py(_store_problems_batch_to_chromadb) upserts in chunks. Thecodebase_stats_<source>document is written inchromadb_storage.pybefore the run finishes.endpoints/stats.py,report.pyandcharts.pyquery{"type": "problem"}and the stats document. None looks at run status.subprocess_runner.py_handle_subprocess_crashonly marked the taskfailed. No durable record was kept.task_routes.add_clear_stuck_routeis a no-op (security(api): routes with no auth beside gated siblings — public /api/redis-service/status, analytics task status and clear-stuck, batch-jobs load/chat-init #18718), so there was nothing to reuse.Design (in the local commit)
run_status.py: one durable record per source (codebase_run_<source_id>) in the same ChromaDB collection as the findings, which is the system of record forcodebase_analytics.latest_*(run id, status, reason, times) and alast_completed_*pointer. Only acompletedfinish advances the pointer. A failed, killed or abandoned run never moves it.completed.running,completed,failed,killed,abandoned,cancelled. Exit -9 (SIGKILL) maps tokilled; any other non-zero exit maps tofailed.scanner.pyrecordscompletedorfailedfrom the worker.subprocess_runner.pyrecordsrunningat start andkilledorfailedon a crash, with the reason.runningpast the hard timeout plus 300s is markedabandonedon read.GET /api/analytics/codebase/index/run-state?source_id=returns the status, apartialflag, the reason and the last completed run.run_status_21003_test.py): killed run keeps the previous completed pointer and is partial; killed first run has an empty pointer; completed advances the pointer; abandoned sweep with a not-yet-overdue control; exit -9 maps tokilledend to end through the crash handler. Result: 13 passed (withprogress_tracker_test.py).Kill cause: not established
Two code paths can send SIGKILL (-9); both return -9, so before this change the history could not tell them apart:
_SUBPROCESS_HARD_TIMEOUT, default 1800s (indexing_executor.py:44, envAUTOBOT_INDEXING_HARD_TIMEOUT), enforced byasyncio.wait_forinsubprocess_runner.py_run_indexing_subprocess, which callsproc.kill()._SUBPROCESS_PROGRESS_TIMEOUT, default 300s (indexing_executor.py:47, checked every 30s), enforced insubprocess_runner.py_wait_with_watchdog, which callsproc.kill().Both failed runs lasted about 29 minutes, which fits the 1800s hard timeout but does not prove it. An OOM kill cannot be excluded from code. I found no Celery hard time limit on this path.
Host evidence that would settle it:
AUTOBOT_INDEXING_HARD_TIMEOUTandAUTOBOT_INDEXING_PROGRESS_TIMEOUTin the running backend.dmesgorjournalctl -kfor oom-kill entries around 14:54 UTC on 2026-11-01.From now on each kill records its cause in the run record.
Remaining scope (follows once #21008 lands, rebased onto it)
/index/run-state.partialand the last completed run wired into thestatsandreportresponses.Proposals (not applied)
run_idand filter readers onlast_completed_run_id, so a killed run's upserts cannot overwrite a previous complete result. Without it, the pointer alone does not preserve earlier content when ids are reused.mrveiss commentedon Nov 12, 2026
Owner decision, 2026-11-12 — how a killed run is presented
Every per-source reindex first deletes that source's previous findings, so after a killed run there is no earlier complete result left to show. Asked which way to go, the owner chose: show the partial findings clearly marked as partial, with the time of the last completed run (banner), rather than tagging findings with a run id so the previous complete run survives.
Consequences for the fix:
c7603b3f74, 7 files): (1) the run record carriessource_idin its metadata, so the next run's per-source delete removes the record and its last-completed pointer — the record needs a key the delete does not match; (2) the newGET /index/run-stateroute takes an optional source with a default, which the source-scoping rule forbids — it must require the source.fix(analytics): an overdue running record no longer blocks a newer ru…
chore(types): regenerate api.ts for the run-state route and the sourc…
docs(changelog): fragments for the analytics run-state batch (#21003)
fix(analytics): run-state reads fail loudly, ended jobs resolve their…
fix(analytics): a queued request that never ran announces nothing, an…
mrveiss commentedon Nov 13, 2026
Residual noted by the review of PR #21478 (non-blocking, recorded here so it is not lost): the page remembers the first run it knew when a wait began. In the sequence queued → that request is tracked as a job → a second request queues without the polling being restarted, the remembered run stays the first one; if the second request then never runs, the earlier tracked job's own outcome is announced once more, late. It is a real outcome of a real job — nothing wrong is announced and nothing right is suppressed — but the announcement is redundant. Fix direction: re-capture the remembered run when a job id is set.
github-actions commentedon Nov 13, 2026
Landed via the merge train (#21500, merge
470d3627d8) via #21478mrveiss commentedon Nov 13, 2026
Landed in #21478 (merge 470d362)
autobot-backend/api/codebase_analytics/run_status.py:94-101(statuses,PARTIAL_STATUSES);scanner.py:432,440(completed, failed);subprocess_runner.py:208,217(cancelled, start failure) plus supervisor kills;autobot-frontend/src/components/analytics/RunStateNotice.vue:16(v-if="run && run.partial")killed, results marked partial)run_status_21003_test.py:79-86asserts("killed", True, "exit -9");run_status_21003_test.py:92for a first runRemaining
fix(analytics): record a terminal run status and never present a kill…
fix(analytics): keep the run record out of the per-source delete, sco…
fix(analytics): label every results route partial when its run did no…
fix(frontend): label a killed or failed run's findings as partial wit…
fix(analytics): kill and record a cancelled run, take over a lost sta…
fix(frontend): key the partial notice on the contract flag, and drop …
fix(analytics): a late report from an older run never takes over a ne…
test(frontend): give every useAnalyticsDataFetchers construction its …
mrveiss commentedon Nov 22, 2026
Branch closed: its content is on main, see #22071.