Repository navigation
Split investigationEvidence into a directory, one adapter per tool family - #1731
Conversation
One file per concern, one adapter per tool family. Adding a tool now means a
new file under adapters/ and a line in the ADAPTERS registry, instead of
another few hundred lines in a file every other adapter is also editing.
types.ts the wire and projection types
identity.ts evidence refs, source ids, DOM ids
parse.ts payload coercion shared across adapters
observations.ts ProjectionBuilder, relevance, limitations, observations
adapters/ changes diagnose events helm issues logs
permissions prometheus resource topology
builder.ts the adapter registry and projectInvestigationEvidence
index.ts the public surface
index.ts re-exports exactly the 46 names the single file exported, and every
call site already imports "./investigationEvidence", which now resolves to the
directory â so no importer changes and no compatibility shim is left behind.
Symbols a sibling needs are exported at file level but deliberately kept out of
index.ts; the module's public surface is unchanged.
Pure move: no behaviour change. The token stream of the moved code is identical
to the original (39252 tokens, 1892 distinct, zero difference), the only edits
being added import/export lines and Prettier re-wrapping eleven signatures that
the export keyword pushed past the print width.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0125QDX24TNuod7FKLwTDhvW
PR Summary by QodoModularize investigation evidence by tool family
AI Description
Diagram
High-Level Assessment
Files changed (16)
|
Code Review by Qodo
1.
|
Visual regression checkRan the rendered surface against a real saved investigation, not just unit tests â the refactor reshapes the ESM module graph, which type-checking and Vitest's dev transform don't fully cover. Method. Built both Result: the rendered Findings pane is byte-identical â 12,505 bytes on both builds. That covers the Assessment block, the "Evidence coverage is incomplete" limitation banner with both sub-limitations, log cards with selected excerpts and Previous observations, the ConfigMap card with all 13 keys, StatefulSet and Deployment cards with conditions and HPA scaling, three diagnose metric charts, the Also checked:
|
The index comment described the export set by comparing it to the file the directory replaced, which records a migration rather than an invariant and puts a count in a comment that any new export invalidates. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0125QDX24TNuod7FKLwTDhvW
Closes #1732. `investigationEvidence.test.ts` was **6,617 lines** â the largest file in `web/src/components/diagnose/` after #1731 split the source it covers into a directory. It was deliberately left alone by that PR, because the evidence the move preserved behaviour *was* that the tests did not change and still passed. That reason expires now. ## What changed The suite follows the same seams as the module, each file beside the code it pins: | | | |---|---| | `identity.test.ts` | source ids, subject refs, provenance, root-cause resolution | | `projection.test.ts` | the shared model â relevance, proof scope, merging, retirement, receipts | | `adapters/*.test.ts` | `diagnose` `helm` `logs` `permissions` `prometheus` `resource` | | `evidenceFixtures.ts` | fixtures more than one suite needs | **The adapter suites split by producer; the model suites deliberately do not.** Relevance, proof scope and retirement are one behaviour observed through whichever tool happened to report it â filing those under an adapter would scatter a single contract across six files and make it harder to find, not easier. That is why `projection.test.ts` stays the largest of them. `evidenceFixtures.ts` follows the existing `reachFixtures.ts` convention. It holds only what more than one suite uses: the target, the tool-result builder, the projection helper, and the workload-log payload shared by the logs and `query_prometheus` suites. ## Verification - **Token-for-token identical to the original** â 46,137 tokens, zero difference in either direction, comparing the original file against all new files with import lines normalised away. No assertion was added, changed, or dropped. - **Same test count**: `1147` before and after, measured on this same commit of `main` rather than quoted from memory. Test files 92 â 99. - `tsc --noEmit` clean, `eslint` clean, `prettier --check` clean. ## Note `src/api/client.authRedirect.test.ts` fails intermittently in full-suite runs on a loaded machine â on `main` as well as here, and in a directory this PR does not touch. It is #1735, not a regression from this change. ðĪ Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0125QDX24TNuod7FKLwTDhvW <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Test-only refactor with no production code changes; behavior is preserved by moving existing assertions unchanged. > > **Overview** > **Removes** the 6,617-line monolithic `investigationEvidence.test.ts` and **re-homes** the same Vitest coverage under `investigationEvidence/`, aligned with how the implementation is already split after #1731. > > New layout: **`identity.test.ts`** (source IDs, subject refs, provenance, root-cause linking), **`projection.test.ts`** (shared projection rulesârelevance, merging, retirement, receipts), **`adapters/*.test.ts`** per producer (`diagnose`, `helm`, `logs`, `permissions`, `prometheus`, `resource`), and **`evidenceFixtures.ts`** for cross-suite helpers (`target`, `tool`, `project`, shared payloads). Per the PR, assertions are unchangedâthis is organizational only; test count stays at 1147. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 811ba37. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Closes #1730.
investigationEvidence.tshad grown to 5,572 lines with 46 exports â the largest file inweb/src/components/diagnose/. Every tool adapter, the observation model, the projection builder and the shared types lived in it, so each new tool landed in the same file and every change competed for the same merge surface.What changed
The module is now a directory, one file per concern and one adapter per tool family:
types.tsidentity.tsparse.tsobservations.tsProjectionBuilder, relevance, limitations, observation addersadapters/changesdiagnoseeventshelmissueslogspermissionsprometheusresourcetopologybuilder.tsADAPTERSregistry andprojectInvestigationEvidenceindex.tsAdding a tool is now a new file under
adapters/plus a registry line.No importer changed and no shim was left behind. All 16 call sites already import
"./investigationEvidence", which now resolves to the directory'sindex.ts. That file re-exports exactly the 46 names the single file exported â verified as an exact set comparison, nothing added, nothing dropped. Symbols that only a sibling needs are exported at file level but deliberately kept out ofindex.ts, so the module's public surface is unchanged rather than widened by the split.The dependency graph is acyclic by construction:
typesâparse/identityâobservationsâadaptersâbuilderâindex.Verification
This is a pure move, and it is checked as one rather than asserted:
exportkeyword pushed past the print width.investigationEvidence.test.ts(6,617 lines) is not modified by this PR â that is what makes the suite an independent check rather than a circular one.npm testâ 1,135 passed (90 files), identical to the baseline measured on the same commit with these changes stashed.tsc --noEmitclean,eslintclean,prettier --checkclean.Notes
Splitting
investigationEvidence.test.tsalong the same seams is deliberately deferred to a follow-up. Doing it here would remove the property that makes this PR verifiable: the evidence that the move preserves behaviour is precisely that the tests did not change and still pass.ðĪ Generated with Claude Code
https://claude.ai/code/session_0125QDX24TNuod7FKLwTDhvW
Note
Low Risk
Structural refactor with unchanged public API and unchanged tests; no intended runtime or diagnosis behavior change.
Overview
Replaces the 5,572-line monolithic
investigationEvidence.tswith aninvestigationEvidence/package so tool-specific logic and shared projection code live in separate files instead of one merge hotspot.The layout separates types, identity/DOM helpers, payload parsing, observations (
ProjectionBuilderand shared adders), per-tool adapters underadapters/, and builder (ADAPTERSregistry plusprojectInvestigationEvidence).index.tsre-exports the same 46 public symbols as before, so existing imports of"./investigationEvidence"stay valid with no call-site or shim changes.This is intended as a behavior-preserving move (logic moved verbatim; tests unchanged). New investigation tools can be added as an adapter file plus one registry entry rather than extending the giant single file.
Reviewed by Cursor Bugbot for commit 95d5741. Bugbot is set up for automated code reviews on this repo. Configure here.