|
| 1 | +# Data Mode Review Fixes Implementation Plan |
| 2 | + |
| 3 | +> **For Codex:** Follow the repository's test-first and verification rules for |
| 4 | +> each task. Keep the final implementation in one focused follow-up commit. |
| 5 | +
|
| 6 | +**Goal:** Resolve every verified PR #1166 review finding and restore merge |
| 7 | +readiness without changing Data mode's core architecture. |
| 8 | + |
| 9 | +**Architecture:** Preserve the existing SQLite/PostgreSQL/DuckDB shared data |
| 10 | +models and candidate pipeline. Extend inventory identity metadata to retain |
| 11 | +merged keys, keep filtered PostgreSQL publications privacy-safe, and reuse the |
| 12 | +incremental append's existing session read. |
| 13 | + |
| 14 | +**Tech stack:** Go, SQLite, PostgreSQL, DuckDB, Svelte 5, TypeScript, Paraglide, |
| 15 | +Vitest. |
| 16 | + |
| 17 | +______________________________________________________________________ |
| 18 | + |
| 19 | +### Task 1: Lock down the critical regressions |
| 20 | + |
| 21 | +**Files:** |
| 22 | + |
| 23 | +- Modify: `internal/postgres/push_pgtest_test.go` |
| 24 | +- Modify: `internal/db/orphaned_test.go` |
| 25 | +- Modify: `internal/db/worktree_mappings_test.go` |
| 26 | +- Modify: `internal/sync/engine_bench_test.go` |
| 27 | + |
| 28 | +1. Add or tighten tests that reproduce the PostgreSQL INSERT failure, the v70 |
| 29 | + snapshot overwrite, normalized persisted paths, and incremental allocation |
| 30 | + regression. |
| 31 | +1. Run each focused test or benchmark and confirm the expected failure. |
| 32 | +1. Repair the placeholder sequence and upgrade gate. |
| 33 | +1. Normalize cross-platform expectations. |
| 34 | +1. Remove the duplicate incremental session read and rerun the benchmark. |
| 35 | + |
| 36 | +### Task 2: Preserve merged project selection |
| 37 | + |
| 38 | +**Files:** |
| 39 | + |
| 40 | +- Modify: `internal/db/project_inventory.go` |
| 41 | +- Modify: `internal/db/project_inventory_test.go` |
| 42 | +- Modify: `internal/db/worktree_candidates.go` |
| 43 | +- Modify: `internal/db/worktree_candidates_test.go` |
| 44 | +- Modify: PostgreSQL and DuckDB parity implementations/tests as needed |
| 45 | +- Regenerate: frontend API models |
| 46 | +- Modify: `frontend/src/lib/stores/data.svelte.ts` |
| 47 | +- Modify: `frontend/src/lib/stores/data.test.ts` |
| 48 | + |
| 49 | +1. Add tests for colliding display labels with distinct project keys and a deep |
| 50 | + link through a non-canonical key. |
| 51 | +1. Add `project_keys` while retaining the canonical `project_key`. |
| 52 | +1. Select candidate sessions for every key in a validated merged row. |
| 53 | +1. Update frontend row resolution and refresh behavior. |
| 54 | +1. Run backend parity and frontend store/component tests. |
| 55 | + |
| 56 | +### Task 3: Repair publication scope and query bounds |
| 57 | + |
| 58 | +**Files:** |
| 59 | + |
| 60 | +- Modify: `internal/postgres/worktree_mappings_push.go` |
| 61 | +- Modify: `internal/postgres/worktree_mappings_push_pgtest_test.go` |
| 62 | +- Modify: `internal/db/project_inventory.go` |
| 63 | +- Modify: `internal/db/project_inventory_test.go` |
| 64 | +- Modify: `internal/db/project_identity.go` |
| 65 | +- Modify: `internal/db/project_identity_test.go` |
| 66 | + |
| 67 | +1. Add a filtered-push test proving unrelated mapping paths are not published. |
| 68 | +1. Skip mapping publication for filtered pushes. |
| 69 | +1. Add cardinality tests over backend bind limits. |
| 70 | +1. Chunk machine candidate reads and aggregate rebuilds transactionally. |
| 71 | +1. Run SQLite and PostgreSQL focused suites. |
| 72 | + |
| 73 | +### Task 4: Align behavior and error handling |
| 74 | + |
| 75 | +**Files:** |
| 76 | + |
| 77 | +- Modify: `internal/db/worktree_candidates.go` |
| 78 | +- Modify: `internal/db/worktree_reclassification.go` |
| 79 | +- Modify: `internal/server/huma_routes_settings.go` |
| 80 | +- Modify: associated Go tests |
| 81 | + |
| 82 | +1. Add tests for zero-message candidates, writer-closed preview, legacy update |
| 83 | + duplicate handling, and token changes. |
| 84 | +1. Align session predicates to visible sessions. |
| 85 | +1. Map writer closure and uniqueness errors correctly. |
| 86 | +1. Include `original_project` in tokens and split the evaluator helper. |
| 87 | +1. Run focused DB and server tests. |
| 88 | + |
| 89 | +### Task 5: Surface stale inventory and fix localized copy |
| 90 | + |
| 91 | +**Files:** |
| 92 | + |
| 93 | +- Modify: `frontend/src/lib/stores/data.svelte.ts` |
| 94 | +- Modify: `frontend/src/lib/components/data/DataPage.svelte` |
| 95 | +- Modify: associated frontend tests |
| 96 | +- Modify: all `frontend/messages/*.json` |
| 97 | + |
| 98 | +1. Add a component regression test for a failed foreground reload after a |
| 99 | + successful load. |
| 100 | +1. Render the error and retry control above retained stale inventory. |
| 101 | +1. Replace the Activity-scoped no-candidate text with archive-wide wording in |
| 102 | + every locale. |
| 103 | +1. Run `npm run i18n:compile`, focused Vitest tests, and `npm run check`. |
| 104 | + |
| 105 | +### Task 6: Finish parity and maintenance cleanup |
| 106 | + |
| 107 | +**Files:** |
| 108 | + |
| 109 | +- Modify: inventory timestamp handling and tests across backends |
| 110 | +- Modify: PostgreSQL mapping ordering and parity tests |
| 111 | +- Modify: stale comments identified by review |
| 112 | + |
| 113 | +1. Add malformed-timestamp and deterministic-order regressions. |
| 114 | +1. Make SQLite and PostgreSQL observable behavior match. |
| 115 | +1. Correct stale bind-limit and collation comments. |
| 116 | +1. Run focused parity suites. |
| 117 | + |
| 118 | +### Task 7: Verify and publish |
| 119 | + |
| 120 | +1. Run Go formatting and vet. |
| 121 | +1. Run targeted and broad Go tests, PostgreSQL integration tests, frontend |
| 122 | + tests/checks, and benchmark comparison. |
| 123 | +1. Inspect the final diff and run the private-data scrub. |
| 124 | +1. Use the commit workflow to create one conventional follow-up commit. |
| 125 | +1. Push the current branch. |
| 126 | +1. Replace the PR body with a concise rationale-first summary with no test |
| 127 | + section or checklist. |
0 commit comments