Closes ARCHITECTURE_DEBT.md #1 — protocol action items now promote to
standalone decisions instead of voting via the parallel
protocol_decision_* system.
Migration 086 applied to prod Neon (0 votes/outcomes existed there —
clean cutover, no data migration needed).
New flow:
1. Action item with item_type='decision' shows a "Als Entscheidung
verschieben" CTA (creator-only)
2. Click → POST /api/decisions with protocol_id + action_item_id +
voting_method='thumbs_up_down' + title from description +
initialStatus='voting'
3. Card now shows the decision's status badge + tally + "Zur
Entscheidung" link to the full standalone decision page
4. Voting/closure/task-creation all happen via the standalone system
Code changes:
- DecisionBridge.tsx (new) — the thin wrapper, takes
linkedDecision summary + isProtocolCreator
- DecisionActions.tsx (deleted) — legacy inline thumbs voting
- decisions-crud.ts — createDecision accepts protocolId/actionItemId;
new getDecisionsByProtocolId() service
- createDecisionSchema — accepts optional protocolId + actionItemId
- review.ts — counts now use ProtocolDecisionSummary instead of
decisionVotes/outcomes; openDecisions = decisions without a linked
standalone OR linked but not closed
- protocols.ts service — exports getDecisionsByProtocolId; legacy
voting service marked deprecated (still exported until separate
cleanup commit drops the routes + tables)
- ProtocolDetailClient — prop name shift: decisionVotes+decisionOutcomes
→ protocolDecisions
- ProtocolActionItemsList — same prop name shift; ActionRow renders
DecisionBridge instead of DecisionActions
- Tests updated to use protocolDecisions: []
Remaining cleanup (future commit):
- /api/protocols/[id]/decisions/{vote,close,propose,create-tasks} routes
- protocols-voting.ts service
- protocol_decision_votes + protocol_decision_outcomes tables (DROP via
new migration 087)
- DecisionVoteRecord + DecisionOutcomeRecord types
typecheck: clean. production build: succeeds. 593/593 protocol+
decisions tests pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two pieces:
1. docs/ARCHITECTURE_DEBT.md — punch list from the spaghetti-hunt
subagent. Three significant parallel-implementation patterns
identified, each with a concrete migration plan and effort estimate:
#1 — Two decision/voting systems (protocol-embedded vs standalone)
#2 — Two notification pipelines (IT-Hilfe bypasses central)
#3 — Three incompatible booking/appointment status enums
Plus minor findings (permission system is clean, marketplace split
is intentional, escaped-bracket directory artifact).
2. Step 1 of decision-systems unification (the user's stated priority):
- scripts/db/migrations/086_decisions_protocol_link.sql — adds
nullable protocol_id (FK) and action_item_id (text) columns to
the decisions table, plus a unique partial index on the pair.
Safe additive change; existing decisions get NULL for both.
- src/db/schema/decisions.ts — Drizzle schema mirrored to match.
Migration NOT yet applied to prod Neon (requires explicit user
green light per safety policy). Apply via:
`psql $DATABASE_URL -f scripts/db/migrations/086_decisions_protocol_link.sql`
This is groundwork for the bigger UI/data migration documented in
ARCHITECTURE_DEBT.md #1. Next steps in a dedicated session:
- Add 'thumbs_up_down' voting method to VOTING_METHODS
- Wire protocol UI to create standalone decisions FK-linked back
- Migrate existing protocol_decision_votes data
- Drop the protocol_decision_* tables
Verified: typecheck clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>