Repository navigation
Description
P2 · Reproduced locally at e3943c5f5c1e69c39309bb8f5b9cf5e63ce41672 with live sessions of an owner and two editors.
A task review that waits on a person stays with them after they stop being able to take it. Nobody who can act is asked, and the owner's bell stays silent. The board's Needs my review keeps the task only for the person who cannot act, or for nobody. Three admin actions cause it:
- R1: the reviewer is removed from the organization (Settings → Members → Delete, in the UI);
- R3: the reviewer's role is lowered to Member (read-only), through the members door the UI uses;
- R4: the reviewer is taken off the audience team of a team-restricted project, through the teams door.
Reproduction (R1)
- As the owner, on an org-wide project, create a task, set Reviewer to editor A and move the task to In review. A gets Review requested. The chip reads Waiting on Ava Editor on the other boards and Waiting on you on A's.
- In a second tab: Settings → Members → A's row menu → Delete → confirm.
- Back on the owner's board, and on editor B's board, look at the task: live, then after a reload, then under Filter → Review → Needs my review.
Expected: the open review moves along the reviewer chain, to the task creator and then the project creator, as Clear reviewer does, and the new reviewer is asked. A removed person's designation is cleared.
An erasure already does exactly this to the same review (erasure/service.ts:1176–1245). The task guide says:
- "Reviewer identifies the person to notify when an agent’s result needs review. Only members who can edit the project can be reviewers." (tasks.md:38)
- The designation "does not reserve the decision exclusively to that person. Another member with project edit access can also accept the result" (tasks.md:42).
Others can decide. The defect is that nobody who can decide is asked.
Actual:
- R1: both boards change to Waiting on 0TYNOKTY…, the removed person's raw user id (see "Related" below). The task still stores A as reviewer. Needs my review is empty for the owner and for B, and nobody gets a bell.
- R3: the chip still reads Waiting on Ava Editor. The owner's Needs my review is empty; A's still holds the task. A holds an unread Review requested that says "set it to Done to approve". But A's dialog is read-only, with no Status control, and the door refuses the move with 403
RBAC_FORBIDDEN"Editor role required". - R4: B can no longer read the task (403). The owner's chip still reads Waiting on Ben Editor, the owner's Needs my review is empty, and the owner is not told.
Also recorded as R2, which passes: A is designated while the task is To do and removed before review. At In review the chain skips A and asks the owner, whose chip reads Waiting on you. But the stored designation still names A, and the dialog shows A's raw id.
User impact
The review gate stalls without a signal. The only person asked cannot act, and the people who can act are neither asked nor shown the task in their review list. The work sits in In review until someone notices the board.
The workaround is manual: on each affected task, set Reviewer to someone else, or Clear reviewer (the control below). This is the recovery BL-3 documents for erasures made before #3554.
The members guide says "Review shared work and team responsibilities first" before removing someone (members-and-roles.md:67). It does not mention waiting reviews, and the role-change and team paths carry no such note.
Cause
resolveRevieweris "revalidated at every call so a designee who lost project access falls through the chain" (reviews.ts:122–158). It runs only when a review is minted, when its designation changes, and in the erasure pass.removeMembershipCascade(membership.ts:234–269) clears team memberships, preferences and competences, but no task reviews. It has three callers, all affected:- the members door
removeMember(members/service.ts:279); - SCIM;
- Better Auth's
afterRemoveMemberhook (auth.ts:1131–1134).
- the members door
updateMemberRole(members/service.ts:368) and the team membership removal (teams/routes.ts:349) do not touch tasks either.- The erasure pass shows the hand-over these doors need. For its subject it clears the designation, calls
retargetPendingTaskReviewwithexcludeUserId, and emits ataskhint in the same transaction. - Likely also affected, not tested: the Disabled role.
reviewerEligibilitytreats it asnot_member(reviews.ts:112).
Suggested acceptance test
An integration lane beside checkTasksCollabIntegrity. Start with a pending review on A, then run each of these:
- remove A from the organization, through both the members door and the Better Auth hook;
- lower A to Member;
- set A to Disabled;
- remove A from the project's only audience team.
After each, assert that:
- the pending
task_reviewrow'srequestedForbecomes the task creator, or the project creator; - that person has an unread Review requested;
- A's request is dismissed;
- the designation is cleared where A is no longer a member;
- a
taskhint is emitted.
In the app, the owner's board chip should read Waiting on you without a reload.
Evidence: frozen output (proof-f2-stuck-review.cjs, four fresh organizations)
R1 setup: org 9UuI0dJ7A2ztALq35Y0Y2nMPZbeSPMd9 | waiting on A: chips O[ Waiting on Ava Editor ] B[ Waiting on Ava Editor ] | A notes ["task_status_changed:UNREAD","task_review_requested:UNREAD"]
CONTROL handover to B (PROJ-F32): chips O[ Waiting on Ben Editor ] B[ Waiting on you ] | B notes ["task_review_requested:UNREAD"] | A notes ["task_status_changed:UNREAD","task_review_requested:read"]
R1 back on A: chips O[ Waiting on Ava Editor ] B[ Waiting on Ava Editor ]
CONFIRMED R1 A removed (Settings > Members): chips O[ Waiting on 0TYNOKTYN2i2rrTfvPSppt2Mebtjoun7 ] B[ Waiting on 0TYNOKTYN2i2rrTfvPSppt2Mebtjoun7 ] | bells O= 0 B= 0 | stored {"status":"in_review","reviewer":"A"}
CONFIRMED R1 after reload: Needs my review keeps the card for O = 0 | for B = 0 | O notes [] | B notes ["task_review_requested:read"]
R1 owner dialog Reviewer field = "0T\n0TYNOKTYN2i2rrTfvPSppt2Mebtjoun7"
CONTROL R1 Clear reviewer -> field "No reviewer"
CONTROL R1 after Clear: chips O[ Waiting on you ] B[ Waiting on Owner f2r1 ] | stored {"status":"in_review","reviewer":"(none)"}
R2 setup: org miSwAXnclFr9WMqLKPhhwNHNlqHEIl1y | A designated, then removed through the members door -> 200
R2 after In review: O chip [ Waiting on you ] | stored {"status":"in_review","reviewer":"A"} | O dialog Reviewer field = "QC\nQcRNIDihI5MSzAruZqWDSloe20U5b2Ij"
R3 setup: org EJmnUHy0emCSUZuUappANxkANkQovdQS | A lowered to Member -> 200
CONFIRMED R3 chips O[ Waiting on Ava Editor ] B[ Waiting on Ava Editor ] | bells O= 0 B= 0 | stored {"status":"in_review","reviewer":"A"}
CONFIRMED R3 Needs my review keeps the card for O = 0 | for A (read-only now) = 1
CONFIRMED R3 A sees chip [ Waiting on you ] with Status controls = 0 | A deciding through the door -> 403 {"error":"RBAC_FORBIDDEN","message":"Editor role required"} | A still holds ["task_status_changed:UNREAD","task_review_requested:UNREAD"]
R4 setup: org A1YrZwqF7dkkUKNPXFmu8sQxRYOlSDey | B taken off the audience team -> 200
CONFIRMED R4 O chip [ Waiting on Ben Editor ] | O bell = 0 | O Needs my review keeps the card = 0 | B reads the task -> 403 | stored {"status":"in_review","reviewer":"B"}
--- console/http log --- (none)
Controls in the same run:
- Handing the waiting review to B (PROJ-F32) moves the request and every chip.
- Clear reviewer on the stuck R1 task hands it to the creator.
Mocked boundary: none. Real SPA, backend, PostgreSQL and the /events stream; one browser context per person. R3 and R4 call the members and teams doors directly; the UI calls the same doors.
Related
- The raw id on the R1 and R2 chips and fields is filed as bug(platform): task views show a removed member as a raw user id #3788.
- R4 does not test notification delivery after the loss of access; that is Bug: Task notifications expose new task titles after project access is revoked #3631's subject.
Deduplication
Searched all 1,072 issues, in every state, for "Waiting on", "Needs my review", requestedFor, removed or demoted reviewers, and membership removal cascades. No issue covers a review left on a removed or demoted reviewer.
- fix(platform): close the reviewer edge cases after re-targeting #3554 (merged) moved reviews on erasure and refused ineligible designations.
- BL-3 in
not-a-finding.mdis only the leftover from erasures before fix(platform): close the reviewer edge cases after re-targeting #3554. - Bug: a source close takes ownership of a human review and a later reopen sends it to Backlog #3601 is about a source close taking a human review.
Found by the TALE-70 local audit. No production system, real provider, mailbox or external delivery was used.
Local stack (loopback only)
- Source: a detached worktree of
e3943c5f5c1e69c39309bb8f5b9cf5e63ce41672(origin/main on 2026-09-28) withbun install --frozen-lockfile. The code named in this issue is unchanged on maine71775a8b(9 commits later). On main,docs/en/platform/projects/tasks.mdandnot-a-finding.mdchanged only in unrelated sections: task limits, repeats, and debt entries BL-5 and BL-6 for accent colours. - Databases: PostgreSQL 16.14 (embedded-postgres binaries) with pgvector 0.8.6 on
127.0.0.1;tale_app, andtale_knowledgewithvector. No pg_search (not involved). - Backend, from
services/platform:node --experimental-transform-types --import ./backend/node-loader.mjs backend/main.tswithROLE=all PORT=3005 SITE_URL=http://localhost:3000 NODE_ENV=development, an emptyTALE_CONFIG_DIR,TALE_CONFIG_BUILTIN_DIR=configs/platform/custom,TALE_ALLOW_OPEN_SIGN_UP=true,TALE_DEV_SEED_USER=1, locally generatedBETTER_AUTH_SECRET/ENCRYPTION_SECRET_HEX/INSTANCE_SECRET, and no object store. Egress is blocked:NODE_USE_ENV_PROXY=1 HTTP_PROXY=HTTPS_PROXY=http://127.0.0.1:9 NO_PROXY=127.0.0.1,localhost,::1. - SPA:
bun --bun vite build, thenTALE_BACKEND_URL=http://127.0.0.1:3005 bunx --bun vite preview --port 3000(the production-build E2E serving path; the boot-shell prerender step was skipped). - Browser: Chromium 141.0.7390.37 headless, driven by the worktree's
playwright-core1.58.2 withserviceWorkers: 'block',en-US, 1280×900. - Fixtures: each proof signs up its own accounts and organization through
POST /api/auth/sign-up/emailandPOST /api/auth/organization/create. Credentials carry fake secrets that nothing tests; no provider, mailbox or other external service is reachable. - Replay:
T70_ROOT=<dir> node <proof>.cjs, where<dir>/taleis the worktree and<dir>/evidence/receives the log; adjust the Chromium path inlib.cjs.
probes/proof-f2-stuck-review.cjs
// PROOF F2: a review waiting on a person stays with them after they can no longer take it: nobody who can act
// is asked, the board's "Needs my review" keeps it only for the person who cannot act (or for nobody), and the
// owner's bell stays silent.
// R1 the reviewer is removed from the organization (owner's second tab, Settings > Members > Delete);
// R2 the reviewer is designated while To do and removed BEFORE review (the chain handles it; recorded);
// R3 the reviewer's role is lowered to Member (read-only) through the members door;
// R4 the reviewer is taken off a team-restricted project's audience team through the teams door.
// Controls: PROJ-F32 — handing the waiting review to B moves the request and every chip; Clear reviewer on the
// R1 task hands the stuck review to the creator. Every case is its own fresh org; boards are never reloaded
// unless stated. Mocked boundary: none (real SPA, backend, Postgres, /events).
const L = require('./lib.cjs'); const T = require('./tasklib.cjs');
const out = [];
const say = (...a) => { const s = a.map((x) => (typeof x === 'string' ? x : JSON.stringify(x))).join(' '); out.push(s); console.log(s); };
async function toggleNeedsMyReview(page) {
await page.getByRole('button', { name: /^Filter/ }).first().click();
const panel = page.getByRole('dialog', { name: 'Filters' });
await panel.waitFor();
const box = panel.getByRole('checkbox', { name: 'Needs my review' });
if (!(await box.isVisible())) await panel.getByRole('button', { name: 'Review' }).click();
await box.waitFor({ timeout: 5000 });
await box.click();
await L.sleep(800);
await page.keyboard.press('Escape'); await L.sleep(300); await page.keyboard.press('Escape'); await L.sleep(500);
}
async function needsMyReview(page, title) {
await toggleNeedsMyReview(page);
const n = await page.getByRole('button', { name: title, exact: true }).count();
await toggleNeedsMyReview(page);
return n;
}
const stored = async (s) => { const r = await L.api(s.o.ctx, 'GET', `/api/app/tasks/${s.taskId}?orgId=${s.o.orgId}`); const t = r.body.task ?? r.body; return { status: t.status, reviewer: t.reviewerUserId === s.a.userId ? 'A' : t.reviewerUserId === s.b.userId ? 'B' : t.reviewerUserId ?? '(none)' }; };
async function waitingOn(s, who, pO) {
await T.openTask(pO, s);
await T.pickReviewer(pO, who);
await T.pickStatus(pO, 'In review');
await pO.keyboard.press('Escape');
await L.sleep(2500);
}
(async () => {
const browser = await L.launch();
const log = [];
try {
// ---------- CONTROL (PROJ-F32) + R1 ----------
let s = await T.setupReviewOrg(browser, 'f2r1');
let [pO, pB] = [await s.o.ctx.newPage(), await s.b.ctx.newPage()];
L.watch(pO, log, '[R1 O]'); L.watch(pB, log, '[R1 B]');
await L.goto(pB, T.boardUrl(s), 1500);
await waitingOn(s, 'Ava Editor', pO);
say('R1 setup: org', s.o.orgId, '| waiting on A: chips O[', await T.chip(pO, s.title), '] B[', await T.chip(pB, s.title), '] | A notes', await T.notes(s.a, s.o.orgId));
await T.openTask(pO, s); await T.pickReviewer(pO, 'Ben Editor'); await pO.keyboard.press('Escape'); await L.sleep(2500);
say('CONTROL handover to B (PROJ-F32): chips O[', await T.chip(pO, s.title), '] B[', await T.chip(pB, s.title), '] | B notes', await T.notes(s.b, s.o.orgId), '| A notes', await T.notes(s.a, s.o.orgId));
await T.openTask(pO, s); await T.pickReviewer(pO, 'Ava Editor'); await pO.keyboard.press('Escape'); await L.sleep(2500);
say('R1 back on A: chips O[', await T.chip(pO, s.title), '] B[', await T.chip(pB, s.title), ']');
const pM = await s.o.ctx.newPage();
L.watch(pM, log, '[R1 O-members]');
await L.goto(pM, `/dashboard/${s.o.orgId}/settings/members`, 1500);
await pM.locator('tbody tr', { hasText: 'Ava Editor' }).getByRole('button', { name: /open menu/i }).click();
await pM.getByRole('menuitem', { name: /Delete|Remove/ }).click();
await pM.getByRole('dialog').getByRole('button', { name: /^(Delete|Remove)/ }).click();
await pM.getByRole('dialog').waitFor({ state: 'detached', timeout: 10000 }).catch(() => {});
await pM.close();
await L.sleep(3000);
say('CONFIRMED R1 A removed (Settings > Members): chips O[', await T.chip(pO, s.title), '] B[', await T.chip(pB, s.title), '] | bells O=', await T.bell(pO), 'B=', await T.bell(pB), '| stored', await stored(s));
await L.goto(pO, T.boardUrl(s), 2000); await L.goto(pB, T.boardUrl(s), 2000);
say('CONFIRMED R1 after reload: Needs my review keeps the card for O =', await needsMyReview(pO, s.title), '| for B =', await needsMyReview(pB, s.title), '| O notes', await T.notes(s.o, s.o.orgId), '| B notes', await T.notes(s.b, s.o.orgId));
await T.openTask(pO, s);
say('R1 owner dialog Reviewer field =', JSON.stringify(await T.reviewerField(pO)));
await L.shot(pO, 'f2-r1-owner-dialog');
say('CONTROL R1 Clear reviewer -> field', JSON.stringify(await T.pickReviewer(pO, 'clear')));
await pO.keyboard.press('Escape'); await L.sleep(2500);
say('CONTROL R1 after Clear: chips O[', await T.chip(pO, s.title), '] B[', await T.chip(pB, s.title), '] | stored', await stored(s));
// ---------- R2: designated while To do, removed before review ----------
s = await T.setupReviewOrg(browser, 'f2r2');
pO = await s.o.ctx.newPage();
L.watch(pO, log, '[R2 O]');
await T.openTask(pO, s);
await T.pickReviewer(pO, 'Ava Editor');
const del2 = await L.api(s.o.ctx, 'DELETE', `/api/app/members/${s.a.memberId}?orgId=${s.o.orgId}`);
await L.sleep(1500);
await T.pickStatus(pO, 'In review');
await pO.keyboard.press('Escape'); await L.sleep(2500);
say('R2 setup: org', s.o.orgId, '| A designated, then removed through the members door ->', del2.status);
await T.openTask(pO, s);
say('R2 after In review: O chip [', await T.chip(pO), '] | stored', await stored(s), '| O dialog Reviewer field =', JSON.stringify(await T.reviewerField(pO)));
// ---------- R3: demoted to Member ----------
s = await T.setupReviewOrg(browser, 'f2r3');
[pO, pB] = [await s.o.ctx.newPage(), await s.b.ctx.newPage()];
const pA = await s.a.ctx.newPage();
L.watch(pO, log, '[R3 O]'); L.watch(pA, log, '[R3 A]');
await L.goto(pB, T.boardUrl(s), 1500);
await waitingOn(s, 'Ava Editor', pO);
const role = await L.api(s.o.ctx, 'POST', `/api/app/members/${s.a.memberId}/role?orgId=${s.o.orgId}`, { role: 'member' });
await L.sleep(3000);
say('R3 setup: org', s.o.orgId, '| A lowered to Member ->', role.status);
say('CONFIRMED R3 chips O[', await T.chip(pO, s.title), '] B[', await T.chip(pB, s.title), '] | bells O=', await T.bell(pO), 'B=', await T.bell(pB), '| stored', await stored(s));
await L.goto(pO, T.boardUrl(s), 2000); await L.goto(pA, T.boardUrl(s), 2000);
say('CONFIRMED R3 Needs my review keeps the card for O =', await needsMyReview(pO, s.title), '| for A (read-only now) =', await needsMyReview(pA, s.title));
await L.goto(pA, `${T.boardUrl(s)}?task=${s.taskId}`, 2500);
const statusBtn = pA.getByRole('dialog').getByRole('button', { name: /^Status/ });
const decide = await L.api(s.a.ctx, 'POST', `/api/app/tasks/${s.taskId}/status?orgId=${s.o.orgId}`, { status: 'done' });
say('CONFIRMED R3 A sees chip [', await T.chip(pA, s.title), '] with Status controls =', await statusBtn.count(), '| A deciding through the door ->', decide.status, JSON.stringify(decide.body), '| A still holds', await T.notes(s.a, s.o.orgId));
await L.shot(pA, 'f2-r3-member-reviewer');
// ---------- R4: removed from the audience team ----------
s = await T.setupReviewOrg(browser, 'f2r4');
const team = await L.api(s.o.ctx, 'POST', '/api/auth/organization/create-team', { name: 'Launch', organizationId: s.o.orgId });
for (const u of [s.a, s.b, s.o]) await L.api(s.o.ctx, 'POST', `/api/app/teams/${team.body.id}/members?orgId=${s.o.orgId}`, { userId: u.userId });
const p = await L.api(s.o.ctx, 'POST', `/api/app/projects?orgId=${s.o.orgId}`, { name: 'Launch only', teamIds: [team.body.id] });
const t = await L.api(s.o.ctx, 'POST', `/api/app/tasks?orgId=${s.o.orgId}`, { projectId: p.body.projectId, title: 'Restricted review task', status: 'todo' });
s = { ...s, projectId: p.body.projectId, taskId: t.body.taskId, title: 'Restricted review task' };
pO = await s.o.ctx.newPage();
L.watch(pO, log, '[R4 O]');
await waitingOn(s, 'Ben Editor', pO);
const roster = await L.api(s.o.ctx, 'GET', `/api/app/teams/${team.body.id}/members?orgId=${s.o.orgId}`);
const rm = await L.api(s.o.ctx, 'DELETE', `/api/app/teams/members/by-id/${roster.body.members.find((x) => x.userId === s.b.userId).id}?orgId=${s.o.orgId}`);
await L.sleep(3000);
const bRead = await L.api(s.b.ctx, 'GET', `/api/app/tasks/${s.taskId}?orgId=${s.o.orgId}`);
say('R4 setup: org', s.o.orgId, '| B taken off the audience team ->', rm.status);
await L.goto(pO, T.boardUrl(s), 2000);
say('CONFIRMED R4 O chip [', await T.chip(pO, s.title), '] | O bell =', await T.bell(pO), '| O Needs my review keeps the card =', await needsMyReview(pO, s.title), '| B reads the task ->', bRead.status, '| stored', await stored(s));
} finally {
say('--- console/http log ---', log.length ? '' : '(none)');
for (const l of log) say(l);
L.fs.writeFileSync(L.path.join(L.ROOT, 'evidence/proof-f2-stuck-review.log'), out.join('\n') + '\n');
await browser.close();
}
})().catch((e) => { console.error(e); process.exit(1); });probes/tasklib.cjs
// Task-review helpers shared by the task probes: an owner and two editors of one fresh org, each in its own
// browser context (its own session cookies), with an org-wide project holding one task in To do.
const L = require('./lib.cjs');
async function setupReviewOrg(browser, label, opts = {}) {
const o = await L.freshOrg(browser, label);
const a = await L.addMember(browser, o, opts.aRole ?? 'editor', 'Ava Editor');
const b = await L.addMember(browser, o, opts.bRole ?? 'editor', 'Ben Editor');
const p = await L.api(o.ctx, 'POST', `/api/app/projects?orgId=${o.orgId}`, { name: opts.projectName ?? 'Review board', ...(opts.teamIds ? { teamIds: opts.teamIds } : {}) });
if (p.status !== 200) throw new Error(`project: ${p.status} ${JSON.stringify(p.body)}`);
const t = await L.api(o.ctx, 'POST', `/api/app/tasks?orgId=${o.orgId}`, { projectId: p.body.projectId, title: opts.title ?? 'Check the launch brief', status: 'todo' });
if (t.status !== 200) throw new Error(`task: ${t.status} ${JSON.stringify(t.body)}`);
return { o, a, b, projectId: p.body.projectId, taskId: t.body.taskId, title: opts.title ?? 'Check the launch brief' };
}
const boardUrl = (s) => `/dashboard/${s.o.orgId}/projects/${s.projectId}/tasks/board`;
/** The bell button's accessible name carries the unread count ("Notifications, 2 unread notifications"). */
async function bell(page) {
const label = await page.locator('button[aria-label^="Notifications"]').first().getAttribute('aria-label').catch(() => null);
const m = label && label.match(/(\d+) unread/);
return m ? Number(m[1]) : 0;
}
/** A user's task notifications in the org, newest first, as `kind:read|UNREAD`. */
async function notes(user, orgId) {
const r = await L.api(user.ctx, 'GET', `/api/app/collab/notifications?orgId=${orgId}`);
const list = r.body.rows ?? r.body.items;
if (!Array.isArray(list)) return [`(unexpected ${r.status}) ${JSON.stringify(r.body).slice(0, 200)}`];
return list.map((n) => `${n.type}:${n.read ? 'read' : 'UNREAD'}`);
}
/** The review chip(s) on the board ("Waiting on …"), or 'none'. Each proof board holds one task. */
async function chip(page) {
const c = page.locator('[aria-label^="Waiting on"], [aria-label="Needs review"]');
const labels = [];
for (let i = 0; i < (await c.count()); i++) labels.push(await c.nth(i).getAttribute('aria-label'));
return labels.length ? labels.join(' / ') : 'none';
}
async function openTask(page, s) {
await L.goto(page, `${boardUrl(s)}?task=${s.taskId}`, 1500);
await page.getByRole('dialog').waitFor();
}
/** In the open task dialog: pick a reviewer by visible name, or 'clear'. */
async function pickReviewer(page, who) {
const dlg = page.getByRole('dialog').first();
await dlg.getByRole('button', { name: 'Reviewer', exact: true }).click();
const list = page.getByRole('listbox', { name: 'Reviewer' });
await list.waitFor({ timeout: 5000 });
if (who === 'clear') {
await page.getByRole('button', { name: /Clear reviewer/ }).or(page.getByRole('option', { name: /Clear reviewer/ })).first().click();
} else {
await list.getByRole('option', { name: new RegExp(`^${who}`) }).first().click();
}
await L.sleep(1200);
return reviewerField(page);
}
/** The text the task dialog shows beside its Reviewer button (the designee's name, or No reviewer). */
async function reviewerField(page) {
return page.evaluate(() => {
const btn = document.querySelector('[role="dialog"] button[aria-label="Reviewer"]');
return btn ? (btn.parentElement.innerText || '').trim() : '(no Reviewer button)';
});
}
async function pickStatus(page, label) {
const dlg = page.getByRole('dialog').first();
await dlg.getByRole('button', { name: /^Status/ }).click();
await page.getByRole('listbox', { name: 'Status' }).getByRole('option', { name: new RegExp(`^${label}`) }).first().click();
await L.sleep(1200);
}
module.exports = { reviewerField, setupReviewOrg, boardUrl, bell, notes, chip, openTask, pickReviewer, pickStatus };probes/lib.cjs
// TALE-70 local audit probe helpers. Local stack only: SPA http://localhost:3000 (vite preview of the
// production build, proxying /api, /events, /dav to the backend on 127.0.0.1:3005). Every probe mints its
// own synthetic organization and accounts through the local sign-up door; nothing else is touched.
const path = require('node:path');
const fs = require('node:fs');
const ROOT = process.env.T70_ROOT || path.join(process.env.HOME, '.cache/t70');
const { chromium } = require(path.join(ROOT, 'tale/node_modules/playwright-core'));
const BASE = 'http://localhost:3000';
const ORIGIN = { origin: BASE };
const PW = 'TaleAudit!Passw0rd';
const SHOTS = path.join(ROOT, 'evidence/shots');
async function launch() {
return chromium.launch({
executablePath: '/opt/ms-playwright/chromium-1194/chrome-linux/chrome',
headless: true,
args: ['--disable-dev-shm-usage'],
});
}
async function newContext(browser, opts = {}) {
return browser.newContext({
baseURL: BASE,
serviceWorkers: 'block',
viewport: opts.viewport ?? { width: 1280, height: 900 },
locale: opts.locale ?? 'en-US',
colorScheme: opts.colorScheme ?? 'light',
reducedMotion: 'reduce',
});
}
async function api(ctx, method, url, data) {
const r = await ctx.request.fetch(url, { method, data, headers: ORIGIN });
const text = await r.text();
let body = text;
try { body = JSON.parse(text); } catch { /* keep text */ }
return { status: r.status(), body };
}
function stamp(label) { return `${label}-${Date.now().toString(36)}`; }
/** A fresh owner with a fresh organization (sign-up + organization/create + set-active). */
async function freshOrg(browser, label, opts = {}) {
const s = stamp(label);
const email = `t70-${s}@tale.test`;
const ctx = await newContext(browser, opts);
const su = await api(ctx, 'POST', '/api/auth/sign-up/email', { email, password: PW, name: `Owner ${label}` });
if (su.status !== 200) throw new Error(`sign-up ${email}: ${su.status} ${JSON.stringify(su.body)}`);
const org = await api(ctx, 'POST', '/api/auth/organization/create', { name: `T70 ${s}`, slug: `t70-${s}` });
if (org.status !== 200) throw new Error(`org create: ${org.status} ${JSON.stringify(org.body)}`);
await api(ctx, 'POST', '/api/auth/organization/set-active', { organizationId: org.body.id });
return { ctx, orgId: org.body.id, email, userId: su.body.user.id, stamp: s, name: `Owner ${label}` };
}
/** A second account added to the owner's organization with `role`, in its own browser context. */
async function addMember(browser, owner, role, name, opts = {}) {
const email = `t70-${owner.stamp}-${name.toLowerCase().replace(/[^a-z0-9]+/g, '-')}@tale.test`;
const ctx = await newContext(browser, opts);
const su = await api(ctx, 'POST', '/api/auth/sign-up/email', { email, password: PW, name });
if (su.status !== 200) throw new Error(`sign-up ${email}: ${su.status} ${JSON.stringify(su.body)}`);
const add = await api(owner.ctx, 'POST', `/api/app/members?orgId=${owner.orgId}`, { userId: su.body.user.id, role });
if (add.status !== 200) throw new Error(`add member ${role}: ${add.status} ${JSON.stringify(add.body)}`);
await api(ctx, 'POST', '/api/auth/organization/set-active', { organizationId: owner.orgId });
return { ctx, email, name, userId: su.body.user.id, memberId: add.body.memberId };
}
function watch(page, sink, tag = '') {
page.on('console', (m) => { if (['error', 'warning'].includes(m.type()) && !BENIGN.some((b) => b.test(m.text()))) sink.push(`${tag}[console.${m.type()}] ${m.text().slice(0, 300)}`); });
page.on('pageerror', (e) => sink.push(`${tag}[pageerror] ${String(e).slice(0, 300)}`));
page.on('response', (r) => { if (r.status() >= 400 && r.url().includes('/api/')) sink.push(`${tag}[http ${r.status()}] ${r.request().method()} ${r.url().replace(BASE, '')}`); });
}
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
/** One-line description of document.activeElement. */
const focusedDesc = (page) => page.evaluate(() => {
const e = document.activeElement;
if (!e || e === document.body) return 'BODY';
const name = (e.getAttribute('aria-label') || e.innerText || e.getAttribute('placeholder') || e.value || '').trim().split('\n')[0].slice(0, 60);
const role = e.getAttribute('role');
return `${e.tagName.toLowerCase()}${role ? `[role=${role}]` : ''} "${name}"`;
});
async function shot(page, name, opts = {}) {
fs.mkdirSync(SHOTS, { recursive: true });
const p = path.join(SHOTS, `${name}.png`);
await page.screenshot({ path: p, fullPage: opts.fullPage ?? false });
return p;
}
/** Horizontal overflow of the document and of every element wider than the viewport. */
const overflow = (page) => page.evaluate(() => {
const vw = document.documentElement.clientWidth;
const doc = document.documentElement.scrollWidth;
const wide = [];
for (const el of document.querySelectorAll('body *')) {
const r = el.getBoundingClientRect();
if (r.width > 0 && (r.right > vw + 1) && getComputedStyle(el).position !== 'fixed') {
// skip descendants of a horizontally scrollable ancestor (a table frame that scrolls on purpose)
let p = el.parentElement, clipped = false;
while (p && p !== document.body) {
const cs = getComputedStyle(p);
if (/(auto|scroll|hidden|clip)/.test(cs.overflowX)) { clipped = true; break; }
p = p.parentElement;
}
if (!clipped) wide.push(`${el.tagName.toLowerCase()}.${String(el.className).slice(0, 60)} right=${Math.round(r.right)}`);
}
}
return { viewport: vw, scrollWidth: doc, docOverflows: doc > vw + 1, wide: wide.slice(0, 8) };
});
/** Visible toasts (sonner region). */
const toasts = async (page) => (await page.locator('[role="region"] li').allInnerTexts()).map((s) => s.replace(/\s*\n+\s*/g, ' ').trim()).filter(Boolean);
/** Every toast shown since the page loaded (a MutationObserver installed before any script runs). */
const TOAST_RECORDER = () => {
window.__toasts = [];
const seen = new WeakSet();
const scan = () => {
for (const li of document.querySelectorAll('[role="region"] li')) {
if (seen.has(li)) continue;
const text = (li.innerText || '').replace(/\s*\n+\s*/g, ' ').trim();
if (text) { seen.add(li); window.__toasts.push(text); }
}
};
new MutationObserver(scan).observe(document, { subtree: true, childList: true, characterData: true });
};
async function recordToasts(ctx) { await ctx.addInitScript(TOAST_RECORDER); }
const allToasts = (page) => page.evaluate(() => window.__toasts || []);
// The /events SSE stream keeps the network busy, so never wait for networkidle.
async function goto(page, url, settleMs = 1200) {
await page.goto(url, { waitUntil: 'domcontentloaded' });
await page.locator('main').first().waitFor({ timeout: 15000 }).catch(() => {});
await sleep(settleMs);
}
// Harness artefacts (serviceWorkers: 'block', font preload hints, the route prefetcher's miss note).
const BENIGN = [/Service Worker registration blocked by Playwright/, /Service worker registration failed TypeError: Cannot read properties of undefined \(reading 'waiting'\)/, /was preloaded using link preload but not used/, /\[prefetch\] no 0\.5 row/];
module.exports = { recordToasts, allToasts, launch, newContext, api, freshOrg, addMember, watch, sleep, focusedDesc, shot, overflow, toasts, goto, BASE, ORIGIN, PW, ROOT, SHOTS, fs, path };
/** With a menu open, move keyboard focus with ArrowDown until the focused item matches `re`. */
async function focusMenuItem(page, re) {
await page.getByRole('menu').waitFor();
await sleep(150);
for (let i = 0; i < 12; i++) {
const cur = await focusedDesc(page);
if (/menuitem/.test(cur) && re.test(cur)) return cur;
await page.keyboard.press('ArrowDown');
await sleep(120);
}
throw new Error(`menu item ${re} never took focus`);
}
/** Inside an open dialog, Tab until the focused element matches `re`. */
async function tabTo(page, re, max = 12) {
for (let i = 0; i < max; i++) {
const cur = await focusedDesc(page);
if (re.test(cur)) return cur;
await page.keyboard.press('Tab');
await sleep(80);
}
throw new Error(`Tab never reached ${re}; at ${await focusedDesc(page)}`);
}
Object.assign(module.exports, { focusMenuItem, tabTo });
Activity