Skip to content

refactor(investigations): drop the lane table and the fan-out columns - #901

Open
Makisuo wants to merge 1 commit into
inv/03-web-single-agentfrom
inv/04-drop-lane-schema
Open

Makisuo wants to merge 1 commit into
inv/03-web-single-agentfrom
inv/04-drop-lane-schema

Conversation

@Makisuo

@Makisuo Makisuo commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Stack 4 of 4 — based on the web PR. Drops what the fan-out stored.

What changes

  • investigation_lens_runs is dropped, along with investigations.fanout_*, plan_json, planner_*, validator_* and workflow_instance_id (migration 0058_drop_investigation_lanes, which also removes the lane table from the Electric publication).
  • InvestigationDocument and the v2 Investigation resource lose lens_runs, validator and fanout. Both were documented as evolving shapes; nothing in the web app or the iOS app reads them after the previous PR.
  • InvestigationService no longer loads lanes; the stale sweep has one 15-minute budget; the pass count is the run count; the diagnosis writers drop the fan-out bookkeeping.
  • The Electric proxy drops the lane shape and the fan-out columns from the investigation shape.

Deploy note

Prod migrations are applied by hand. 0058 drops a table and ten columns; nothing reads them after PRs 1–3 are deployed, so apply it after those are live.

Verified

Typechecks on packages/domain, packages/backend, apps/api, apps/ai, apps/web, apps/electric-sync; vitest for the migration journal (the idempotent-replay test now replays 0035 at its own point in history), the investigation service and enqueue paths, the electric shapes, the v2 investigation routes and the web collection mapper. db:generate reports no further schema changes.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Changes
    • Investigation results and API responses no longer include lens-run, validator, or fan-out metadata.
    • Investigation processing now follows a single diagnosis path without fan-out lanes or related workflow tracking.
    • Stale investigations use one 15-minute timeout, regardless of workflow state.
    • Usage limits count one pass per investigation.
    • Database synchronization now scopes investigation data by investigation ID and no longer syncs separate lens-run records.
    • A database migration removes legacy investigation workflow fields and lens-run storage.

Nothing reads them after the web change. `investigation_lens_runs` goes,
along with `investigations.fanout_*`, `plan_json`, `planner_*`,
`validator_*` and `workflow_instance_id` (0058, which also removes the
lane table from the Electric publication). `InvestigationDocument` and
the v2 resource lose `lens_runs`, `validator` and `fanout`; the service
stops loading lanes, the stale sweep has one budget, the pass count is
the run count, and the Electric proxy drops the lane shape.

The migration test that replays 0035 now does so at its own point in
history: a later migration may legitimately drop what an earlier one
added, and what has to hold is that a half-applied branch converged at
the time.
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: ca78f48f-57d5-404d-a305-d8056e82b978

📥 Commits

Reviewing files that changed from the base of the PR and between f9cbff8 and 36916e9.

📒 Files selected for processing (26)
  • apps/api/src/routes/v2/investigations.http.ts
  • apps/api/src/routes/v2/phase1-resources.http.test.ts
  • apps/electric-sync/src/electric/ElectricClient.test.ts
  • apps/electric-sync/src/shapes/registry.test.ts
  • apps/electric-sync/src/shapes/registry.ts
  • apps/electric-sync/src/shapes/request.test.ts
  • apps/web/src/components/investigations/flow/provenance-canvas.test.tsx
  • apps/web/src/components/investigations/flow/provenance-graph.test.ts
  • apps/web/src/lib/collections/investigations.test.ts
  • apps/web/src/lib/collections/investigations.ts
  • packages/backend/src/services/errors/AiTriageService.test.ts
  • packages/backend/src/services/errors/InvestigationService.test.ts
  • packages/backend/src/services/errors/InvestigationService.ts
  • packages/backend/src/services/errors/ai-triage-enqueue.test.ts
  • packages/backend/src/services/errors/ai-triage-enqueue.ts
  • packages/backend/src/services/errors/apply-diagnosis.ts
  • packages/backend/src/services/errors/investigation-quota.ts
  • packages/backend/src/services/errors/investigation-stale.ts
  • packages/backend/src/services/org/OrganizationService.ts
  • packages/db/drizzle/0058_drop_investigation_lanes.sql
  • packages/db/drizzle/meta/0058_snapshot.json
  • packages/db/drizzle/meta/_journal.json
  • packages/db/src/migrations.test.ts
  • packages/db/src/schema/investigations.ts
  • packages/domain/src/http/investigations.ts
  • packages/domain/src/http/v2/investigations.ts
💤 Files with no reviewable changes (9)
  • apps/web/src/components/investigations/flow/provenance-graph.test.ts
  • packages/backend/src/services/errors/ai-triage-enqueue.test.ts
  • packages/backend/src/services/org/OrganizationService.ts
  • apps/web/src/lib/collections/investigations.test.ts
  • apps/api/src/routes/v2/investigations.http.ts
  • apps/web/src/components/investigations/flow/provenance-canvas.test.tsx
  • apps/api/src/routes/v2/phase1-resources.http.test.ts
  • apps/web/src/lib/collections/investigations.ts
  • packages/domain/src/http/v2/investigations.ts

Included review availability: Your plan provides up to 4 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The change removes fan-out and lens-run data from investigation contracts, database persistence, backend processing, Electric synchronization, API responses, and web mappings. Stale handling and quota accounting now use single-investigation rules.

Changes

Single-Agent Investigation Model

Layer / File(s) Summary
Investigation contracts and API shape
packages/domain/src/http/investigations.ts, packages/domain/src/http/v2/investigations.ts, apps/api/src/routes/v2/investigations.http.ts, apps/api/src/routes/v2/phase1-resources.http.test.ts
Domain and V2 API models no longer define or serialize lens_runs, validator, or fanout. API fixtures match the reduced response shape.
Investigation persistence removal
packages/db/src/schema/investigations.ts, packages/db/drizzle/0058_drop_investigation_lanes.sql, packages/db/drizzle/meta/_journal.json, packages/db/src/migrations.test.ts, packages/backend/src/services/org/OrganizationService.ts
The schema and migration remove fan-out columns and the investigation_lens_runs table. Migration and organization cleanup no longer treat the table as active.
Backend single-agent flow
packages/backend/src/services/errors/InvestigationService.ts, packages/backend/src/services/errors/investigation-stale.ts, packages/backend/src/services/errors/ai-triage-enqueue.ts, packages/backend/src/services/errors/apply-diagnosis.ts, packages/backend/src/services/errors/investigation-quota.ts, packages/backend/src/services/errors/*test.ts
Investigation mapping, restart handling, diagnosis writes, stale detection, and quota usage no longer use fan-out state or lens-run rows. Stale detection uses one 15-minute budget, and each investigation counts as one pass.
Electric synchronization shapes
apps/electric-sync/src/shapes/registry.ts, apps/electric-sync/src/shapes/request.test.ts, apps/electric-sync/src/shapes/registry.test.ts, apps/electric-sync/src/electric/ElectricClient.test.ts
Electric synchronization keeps the scoped investigation shape, removes fan-out columns, and removes the investigation_lens_runs shape. Tests verify the updated scope and projection.
Web investigation mapping and fixtures
apps/web/src/lib/collections/investigations.ts, apps/web/src/lib/collections/investigations.test.ts, apps/web/src/components/investigations/flow/*test.*
The web row schema, mapped investigation object, and provenance fixtures no longer include fan-out, validator, or lens-run fields.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to 36916

The single-agent investigation model is consistently reflected across the provided contracts, persistence, backend flow, and synchronization shapes. No actionable issue remains before merge.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main changes: removing the investigation lane table and fan-out columns.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch inv/04-drop-lane-schema

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Makisuo
Makisuo added this pull request to stack #902 September 14, 2026 22:42
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