FE-555: Parts-based persistence + context builders#19
Conversation
🤖 Augment PR SummarySummary: This PR introduces parts-based persistence for turns and splits prompt construction into dedicated context builders. Changes:
Technical Notes: Client hydration still uses scalar 🤖 Was this summary useful? React with 👍 or 👎 |
| describe('interviewer-context-equivalence', () => { | ||
| it('returns prompt as-is when no turns — matches formatHistory', () => { | ||
| const result = buildInterviewerContext([], 'hello'); | ||
| const expected = formatHistory([], 'hello'); |
There was a problem hiding this comment.
src/server/context.test.ts:12 — Since formatHistory() now delegates to buildInterviewerContext(), these comparisons are effectively testing a function against itself and won’t catch behavior drift from the pre-refactor formatter. Consider asserting against an explicit expected string/snapshot (or keeping the old formatter in-test) so I19 is actually exercised.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| } | ||
| break; | ||
| } | ||
| case 'stream-end': { |
There was a problem hiding this comment.
src/server/parts.ts:110 — assembleAssistantParts() currently drops any in-progress tool call if a stream ends without a matching tool-call-end (the toolArgs map is never flushed). That could make persisted assistant_parts miss tool state on early termination/cancellation; consider emitting a partial tool part on stream-end.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
Schema migration adds user_parts and assistant_parts JSON columns to turn table. Parts assembler converts DomainEvents into typed UIMessage parts (reasoning, text, tool-invocation) persisted on stream finish. Data Part schemas (data-option-selection, data-confirmation) defined with Zod validation. Context builders (buildInterviewerContext, buildObserverContext) replace monolithic formatHistory — different consumers get different projections from the same turn tree. Establishes I17 (Data Part schema validation), I18 (parts round-trip fidelity), I19 (context builder equivalence). 24 new tests (112 total). Made-with: Cursor
…ablished Mark slice 4a done in PLAN.md. Graduate A22 and A23 to validated in SPEC.md. Update invariant table with test file references and current coverage section with new test files (parts.test.ts, context.test.ts). Made-with: Cursor
eab0a09 to
26ec729
Compare

feat: parts-based persistence + context builders
Schema migration adds user_parts and assistant_parts JSON columns to
turn table. Parts assembler converts DomainEvents into typed UIMessage
parts (reasoning, text, tool-invocation) persisted on stream finish.
Data Part schemas (data-option-selection, data-confirmation) defined
with Zod validation. Context builders (buildInterviewerContext,
buildObserverContext) replace monolithic formatHistory — different
consumers get different projections from the same turn tree.
Establishes I17 (Data Part schema validation), I18 (parts round-trip
fidelity), I19 (context builder equivalence). 24 new tests (112 total).
Made-with: Cursor
spec/plan: traceability for slice 4a — A22/A23 validated, I17-I19 established
Mark slice 4a done in PLAN.md. Graduate A22 and A23 to validated in
SPEC.md. Update invariant table with test file references and current
coverage section with new test files (parts.test.ts, context.test.ts).
Made-with: Cursor