fix(rectification): preserve assistant turns in dossier
This commit is contained in:
@@ -399,3 +399,53 @@ test("birth-context activity migration stays out of the identity migration tree"
|
||||
"business migration must not be copied into frontend/db/migrations (BUG-127/BUG-144)",
|
||||
);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 20260813030000_rectification_turn_message_projection.sql
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const turnMessageProjectionMigration = readFileSync(
|
||||
new URL(
|
||||
"../supabase/migrations/20260813030000_rectification_turn_message_projection.sql",
|
||||
import.meta.url,
|
||||
),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
const turnMessageProjectionMigrationCopy = fileURLToPath(
|
||||
new URL(
|
||||
"../db/migrations/20260813030000_rectification_turn_message_projection.sql",
|
||||
import.meta.url,
|
||||
),
|
||||
);
|
||||
|
||||
test("rectification turn projection migration follows the V9 activity migration", () => {
|
||||
assert.ok(
|
||||
"20260813030000_rectification_turn_message_projection.sql" >
|
||||
"20260813020000_rectification_birth_context_activity.sql",
|
||||
);
|
||||
assert.match(turnMessageProjectionMigration, /^-- Preserve both logical messages[\s\S]*\nbegin;[\s\S]*^commit;$/m);
|
||||
});
|
||||
|
||||
test("rectification dossier expands each physical turn into user and assistant messages", () => {
|
||||
assert.match(
|
||||
turnMessageProjectionMigration,
|
||||
/cross join lateral \(\s*values\s*\(1, 'user'::text, t\.user_message\),\s*\(2, 'assistant'::text, t\.assistant_message\)\s*\) as message\(ordinal, role, text\)/,
|
||||
);
|
||||
assert.match(turnMessageProjectionMigration, /'role', message\.role/);
|
||||
assert.match(turnMessageProjectionMigration, /'text', message\.text/);
|
||||
assert.match(turnMessageProjectionMigration, /order by t\.created_at, message\.ordinal/);
|
||||
assert.match(turnMessageProjectionMigration, /and message\.text is not null/);
|
||||
assert.doesNotMatch(
|
||||
turnMessageProjectionMigration,
|
||||
/coalesce\(t\.user_message, t\.assistant_message\)/,
|
||||
);
|
||||
});
|
||||
|
||||
test("rectification turn projection migration stays out of the identity migration tree", () => {
|
||||
assert.equal(
|
||||
existsSync(turnMessageProjectionMigrationCopy),
|
||||
false,
|
||||
"business migration must not be copied into frontend/db/migrations (BUG-127/BUG-144)",
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user