Repository navigation
refactor: remove layered fallbacks that hide failures - #563
Conversation
Implement the simplifications from docs/layered-fallback-audit-2026-11-24.md. Data integrity: - Add TimeWorklogRepository.CreateDetail, which inserts the worklog and reads the joined display row in one transaction. TimeWorklogService.Create uses it, so a failed post-insert read rolls back instead of leaving committed time a caller retry can double-book. The id-returning Create stays for callers that only need the id. - PriorityRepository.Create/Update now write the priority, transfer default status, and replace configuration-set memberships in one transaction. preparePriority no longer writes, and duplicate membership ids are treated as a set so they cannot surface as a misleading name conflict. - collectionPreferences keeps the actual unsaved patch per authenticated session and discards it on reset, instead of re-marking dirty scope names that a later flush reconstructs into a delete from the current snapshot. Conflicting decisions: - BookDraft now returns the recorded Booking and resolves replay/conflict through one comparison. Every transaction outcome uses the same (user, key, draft) check, so a reused key never reports another draft's worklog as this draft's success. - Failed lookups propagate instead of falling back to an unrestricted result: workspace priority assignment, test coverage summaries/requirements, and the asset default-status query. Delete duplicate ownership: - timeLogStore's picker promise represents only an in-flight load; a failed directory stays retryable and last-good data stays displayed. - Delete the unused item-detail time-modal picker loader. - moduleSettings exposes ensureLoaded with a real early return and a shared in-flight request; a failed fetch stays retryable, and the authenticated-page call sites no longer issue a second GET after shell hydration. Consistency: - Item updates select one emitter at construction. The legacy emitter and the coordinator share one changed-fields action payload builder, and the fallback-only setters and second payload builder are removed. - PriorityPicker loads the target workspace's priorities through the workspace-priorities API; collectionEditorOptions no longer reimplements assignment/scoped/global resolution. Transition/approval atomicity is intentionally left for its own design review.
|
Size Change: 0 B 🆕 Total Size: 0 B |
|
I’d request changes on
The four new companion Go regressions passed on both SQLite and PostgreSQL, and all 90 tests in the six affected frontend suites passed. The failures above came from additional tests for overlapping transactions, out-of-order responses, and the real workspace-store integration. |
1. BookDraft claims the draft with the conditional delete before inserting
the worklog. A losing transaction previously inserted a worklog and then
returned the winner's booking without rolling back, so two requests could
book 60 minutes for one 30-minute draft. The claim now precedes the insert,
so a replay has nothing to roll back. The regression asserts persisted row
count and minutes, not just matching return IDs.
2. Enforce at most one default priority in the database with a partial unique
index, and clear the old default before writing the new one in the same
transaction. Two concurrent saves can no longer both become default. The
index violation maps to ErrDefaultConflict ("another priority is already
the default") instead of a duplicate-name conflict. The migration collapses
any pre-existing duplicate defaults before creating the index.
3. workspacesStore.load no longer caches a failure as an empty, loaded
directory: it preserves the last good list and leaves a failed load
retryable, so the time picker's next open issues a fresh workspace GET.
4. moduleSettings tags each load with a generation. Only the current request
may publish or clear itself, and reload()/hydrate() supersede a pending
GET, so a slow response cannot overwrite a forced reload or shell snapshot.
|
Addressed all four findings in
Verification on the clean |
|
I’d merge
One non-blocking test improvement: keep the overlapping same-draft, same-key case in the companion suite. The committed row-count assertion is useful, but it runs two different drafts sequentially and would also pass with the old insert-before-delete ordering. The overlapping case directly guards the double-booking fix. |
Implements the simplifications from
docs/layered-fallback-audit-2026-11-24.md.Data integrity
TimeWorklogRepository.CreateDetailinserts the row and reads the joined display row in one transaction.TimeWorklogService.Createuses it, so a failed post-insert read rolls the insert back instead of leaving committed time that a caller retry can double-book. The id-returningCreatestays for callers that only need the id (internal/aitools).PriorityRepository.Create/Updatewrite the priority, transfer default status, and replace configuration-set memberships in one transaction.preparePriorityno longer clears other defaults, and duplicate membership ids are treated as a set, so the repeated-id case can no longer trip the membership unique index and surface ascatalog name already exists.collectionPreferenceskeeps the actual unsaved patch for the session that produced it and discards it on reset, instead of re-marking dirty scope names that a later flush reconstructs into{saved_filters: {scope: null}}from the current snapshot.Conflicting decisions
BookDraftreturns the recordedBooking; the service resolves replay vs. conflict throughbookingWorklog. Every transaction outcome uses the same(user, key, draft)check, so reusing a key never reports another draft's worklog as this draft's success while the caller's draft still exists.IsPriorityAllowedInWorkspacechecks the query error before treating a nil assignment as unrestricted.CoverageSummary/CoverageRequirementscheck the error before treating empty type ids as an empty summary.AssetRepository.GetDefaultStatuschecks the error before treating an invalid id as "no default".Delete duplicate ownership
loadTimeModalDataand its controller/promise/loaded flag/reset plumbing). Item detail already uses the global store.reload()remains the explicit forced refresh.Consistency
buildItemUpdatedActionEvent, which uses the actual changed fields.GET /workspaces/{id}/priorities) and renders the result;collectionEditorOptionsno longer reimplements assignment → scoped → global resolution, and the picker no longer double-loads on mount plus effect.Rule decision for the workspace-priority row
The audit asked to settle the rule for unassigned workspace + curated default set first. Listing (
ListForWorkspace) and write validation (IsPriorityAllowedInWorkspace) already agree on the explicit-assignment rule, and the existing tests assert it, so this change makes the UI agree with them rather than changing the backend rule. TheResolveEffectiveinheritance difference is left for a follow-up once the product rule is decided.Not included
Transition/approval atomicity is intentionally left for its own design review, per the audit.
Verification
go test ./internal/services ./internal/repository ./internal/validation ./internal/handlersvia the core-tests overlay (only the pre-existingTestAddMilestoneWithContextStoresAutomationMetadataandTestCompactCatalogContainsExactlyRetainedMigrationsfailures remain, both failing onmaintoo).TestCreateDetailRollsBackWhenJoinedReadFails,TestBookDraftConflictingKeyDoesNotReplayAnotherDraft,TestCreatePriorityDeduplicatesConfigurationSetMemberships,TestIsPriorityAllowedInWorkspacePropagatesLookupError.maindelta is the pre-existing in-flightsaveFieldfix that lives uncommitted in the main worktree.moduleSettings.ensureLoaded.golangci-lint,svelte-check, andbiome checkclean.