test(evals): require fresh notification comment boundary

This commit is contained in:
Dotta committed 2026-10-28 13:30:48 -05:00
1 parent 1b7e97ef16
commit bcdcd0b242
3 files changed
+4

No files matched your search

@@ -58,6 +58,7 @@ async function armProbe(probe: ObserverProbe) {
finally { await session.dispose(); }
if (personId !== probe.principalId) throw new Error("Notification observer session principal mismatch");
const rows = await publicProbeRows(probe);
if (rows.comments.length || rows.activity.some(row => row.action === "issue.comment_added")) throw new Error("Notification observer requires the fresh comment boundary before the participation control");
probe.baseline = { sessionPrincipalId: probe.principalId, activityIds: rows.activity.map(row => String(row.id)), commentIds: rows.comments.map(row => String(row.id)) };
probe.frames.length = 0;
}
@@ -20,6 +20,8 @@ it("binds actual public shapes without details to exact saved comments and commo
it.each([
["wrong principal",(o:ReturnType<typeof example>)=>{o[1].principalId="alex";}],
["wrong signed-in session",(o:ReturnType<typeof example>)=>{o[1].sessionPrincipalId="other";}],
["prior comment boundary",(o:ReturnType<typeof example>)=>{o.forEach(p=>p.baselineCommentIds.push("older-unobserved-comment"));}],
["prior comment audit",(o:ReturnType<typeof example>)=>{o.forEach(p=>p.baselineActivityIds.push("audit-1"));}],
["capture overflow",(o:ReturnType<typeof example>)=>{o[0].overflow=true;}],
["missing recipient event",(o:ReturnType<typeof example>)=>{o[1].frames.pop();}],
["different received event ID",(o:ReturnType<typeof example>)=>{o[1].frames[0]!.eventId=99;}],
@@ -28,6 +28,7 @@ export function bindNotificationPublicEvents(companyId: string, taskId: string,
const reject = (reason: string) => ({ complete: false, reason, frames: [[], []] as NotificationBoundFrame[][] });
if (!companyId || !taskId || observers[0].principalId === observers[1].principalId
|| observers.some(o => !o.principalId || o.principalId !== o.sessionPrincipalId || o.overflow)) return reject("principal-or-capture-invalid");
if (observers.some(o => o.baselineCommentIds.length || o.activity.some(a => o.baselineActivityIds.includes(String(a.id)) && a.entityType === "issue" && a.entityId === taskId && a.action === "issue.comment_added"))) return reject("not-a-fresh-comment-boundary");
const normalized = [];
for (const observer of observers) {
if (new Set(observer.frames.map(f => f.eventId)).size !== observer.frames.length) return reject("duplicate-public-event");