From 03e10c95c623f3c9ecb5a7990634871eb0a5938c Mon Sep 17 00:00:00 2001 From: Day Dreamer <87640074+HugoXK@users.noreply.github.com> Date: Fri, 20 Nov 2026 08:33:30 +0800 Subject: [PATCH] fix(meetings): read the standing dissent from the current positions A meeting stamped `meeting.dissent` once, when a participant first dissented: a participant who later changed stance left the withdrawn objection printed as the meeting's dissent, and a second dissenter overwrote the first objection, so only the last one stayed on the record. The view and the archived decision now read the dissent back from the participants' positions: only a participant whose current stance is `dissent` with text is on the record, each under their own name. The stored single `dissent` follows the first objection that still stands, an explicit `dissent` passed to `decide` stays an override printed beside them, and a `decide` without one recomputes the record before it writes. Tests hold the withdrawal, two dissenters and the override; the subsystem doc and a changelog fragment follow. Fixes #3203 --- changelog.d/3203-standing-dissent.fixed.md | 1 + core/src/host/meetings.js | 55 +++++++++++++++++--- core/test/meetings.test.js | 58 ++++++++++++++++++++++ docs/subsystems/core-host.md | 12 +++-- patches/ds-bot/files/src/host/meetings.js | 55 +++++++++++++++++--- patches/ds-bot/files/test/meetings.test.js | 58 ++++++++++++++++++++++ 6 files changed, 222 insertions(+), 17 deletions(-) create mode 100644 changelog.d/3203-standing-dissent.fixed.md diff --git a/changelog.d/3203-standing-dissent.fixed.md b/changelog.d/3203-standing-dissent.fixed.md new file mode 100644 index 000000000..870fff90a --- /dev/null +++ b/changelog.d/3203-standing-dissent.fixed.md @@ -0,0 +1 @@ +A meeting's Dissent section and its archived `dissent:` line now follow the positions as they stand: a participant who withdraws an objection takes it off the record, and when two participants dissent both objections stay on the record under their own names ([#3203](https://github.com/ThinkFlowLab/FlyBot/issues/3203)). diff --git a/core/src/host/meetings.js b/core/src/host/meetings.js index 42b7e694d..61c601f7c 100644 --- a/core/src/host/meetings.js +++ b/core/src/host/meetings.js @@ -136,6 +136,44 @@ export function proxyRefusal(meeting) { return undefined } +// #3203: what the meeting's dissent *is* gets read back from the positions as they stand now, +// not stamped once when the first participant dissents. A participant who changes their stance +// takes their objection with them, and every participant who still dissents stays on the record +// under their own name — one owner per objection, so a second dissenter does not overwrite the +// first. +const recordedDissent = participant => { + const position = participant?.position + if (position?.stance !== 'dissent') return undefined + const text = oneLine(position.text, TEXT_MAX) + return text === '' ? undefined : { text, owner: participant.name } +} + +const standingDissents = meeting => (Array.isArray(meeting.participants) ? meeting.participants : []) + .map(recordedDissent) + .filter(record => record !== undefined) + +// What the view and the archived file print: the standing dissents, plus an explicit `dissent` a +// `decide` set (the override the tool offers) when it names an objection the positions do not +// already carry. A decided record keeps that line as history; an open one reads only the +// positions, so a stale stamp from an older build cannot outlive the stance behind it. +const dissentRecords = meeting => { + const standing = standingDissents(meeting) + const recorded = meeting.status === 'decided' ? meeting.dissent : undefined + const text = oneLine(recorded?.text, TEXT_MAX) + if (text === '') return standing + const owner = oneLine(recorded.owner, NAME_MAX) + if (standing.some(record => record.owner === owner && record.text === text)) return standing + return [{ text, owner }, ...standing] +} + +// The stored single `dissent` follows the positions: the first objection that still stands, or +// none at all. It stays the shape the governance check and older readers know. +const syncDissent = meeting => { + const [first] = standingDissents(meeting) + if (first === undefined) delete meeting.dissent + else meeting.dissent = first +} + export function governanceRefusal(meeting) { if (!OPEN_STATES.has(meeting.status)) return `the meeting is ${meeting.status}, not open or deliberating` const proxied = proxyRefusal(meeting) @@ -202,9 +240,10 @@ const decisionBody = (meeting, file, at) => { lines.push(`- **${participant.name}** — ${said}${proxy === '' ? '' : ` (speaks for ${proxy})`}`) } lines.push('', '## Dissent', '') - lines.push(meeting.dissent === undefined - ? 'none recorded' - : `${oneLine(meeting.dissent.text, TEXT_MAX)} — **${oneLine(meeting.dissent.owner, NAME_MAX)}**`) + const dissents = dissentRecords(meeting) + if (dissents.length === 0) lines.push('none recorded') + else if (dissents.length === 1) lines.push(`${dissents[0].text} — **${dissents[0].owner}**`) + else for (const record of dissents) lines.push(`- ${record.text} — **${record.owner}**`) lines.push('', '## Status', '', 'accepted', '') lines.push('## Links', '', `- Decision file: ${file}`) if (meeting.issue !== undefined) lines.push(`- Issue: #${meeting.issue}`) @@ -278,9 +317,7 @@ export function install(rt) { if (spokenFor === '') delete participant.speaksFor else participant.speaksFor = spokenFor participant.position = { stance: chosen, text: oneLine(text, TEXT_MAX), at: now, ...(spokenFor === '' ? {} : { speaksFor: spokenFor }) } - if (chosen === 'dissent' && oneLine(text, TEXT_MAX) !== '') { - meeting.dissent = { text: oneLine(text, TEXT_MAX), owner: name } - } + syncDissent(meeting) if (meeting.status === 'open') meeting.status = 'deliberating' meeting.updatedAt = now return meeting @@ -384,6 +421,10 @@ export function install(rt) { const ownerName = oneLine(args.dissent?.owner, NAME_MAX) if (text === '') throw refuse('invalid', 'a dissent needs the objection it records') candidate.dissent = { text, owner: ownerName } + } else { + // #3203: the record follows the positions at the moment it is written, so a dissent that + // was withdrawn before `decide` never reaches the file. + syncDissent(candidate) } const reason = governanceRefusal(candidate) if (reason !== undefined) throw refuse('governance', reason) @@ -521,7 +562,7 @@ export function install(rt) { lines.push(`level: ${level}${(meeting.recipients ?? []).length === 0 ? '' : ` | recipients: ${(meeting.recipients ?? []).join(', ')}`}`) const paused = advanceRefusal(meeting) if (paused !== undefined) lines.push(`paused: ${paused}`) - if (meeting.dissent !== undefined) lines.push(`dissent: ${meeting.dissent.text} — ${meeting.dissent.owner}`) + for (const record of dissentRecords(meeting)) lines.push(`dissent: ${record.text} — ${record.owner}`) if (meeting.blockingQuestion !== undefined) lines.push(`blocking: ${meeting.blockingQuestion}`) if (meeting.blockingAnswer !== undefined) lines.push(`answer: ${meeting.blockingAnswer}`) if (meeting.decisionFile !== undefined) lines.push(`decision file: ${meeting.decisionFile}`, `tasks: ${meeting.taskIds.join(', ') || 'none'}`) diff --git a/core/test/meetings.test.js b/core/test/meetings.test.js index a5da1b0e5..530f281ea 100644 --- a/core/test/meetings.test.js +++ b/core/test/meetings.test.js @@ -279,3 +279,61 @@ test('#1861: the decision card exposes the participants and their proxies', asyn { name: 'Owner', speaksFor: null, stance: null, silent: false }, ]) }) + +// #3203: the Dissent record is read back from the positions as they stand now, not stamped once +// when someone first dissents. A withdrawn objection leaves the record (the Dissent line and the +// participant's own row agree), and every objection that still stands is named with its author. +test('#3203: a withdrawn dissent leaves the record, and the participant row agrees with it', async (t) => { + const { rt, dir, meeting, open, stop } = await boot() + t.after(stop) + const id = await open('Should Stage 4 reuse the existing store?', ['Chief', 'Dev', 'Reviewer']) + await meeting({ action: 'position', meeting: id, as: 'Chief', stance: 'agree', text: 'the existing store is fine' }) + await meeting({ action: 'position', meeting: id, as: 'Dev', stance: 'agree', text: 'the existing store' }) + const stance = await meeting({ action: 'position', meeting: id, as: 'Reviewer', stance: 'dissent', text: 'a second store is cleaner to audit' }) + assert.match(stance, /dissent: a second store is cleaner to audit — Reviewer/, 'the live dissent is on the view') + const view = await meeting({ action: 'position', meeting: id, as: 'Reviewer', stance: 'agree', text: 'the existing store is fine after all' }) + assert.doesNotMatch(view, /a second store is cleaner to audit/, 'the withdrawn objection is no longer the meeting dissent') + assert.doesNotMatch(view, /^dissent:/m, 'the view names no standing dissent') + assert.match(view, /- Reviewer: agree — the existing store is fine after all/, 'the participant row says agree') + await meeting({ action: 'decide', meeting: id, owner: 'Chief', decision: 'Keep the existing store.', evidence: [{ pr: 3203 }] }) + assert.equal(rt.state.meetings[id].dissent, undefined, 'the withdrawn dissent is not stored') + const body = readFileSync(join(dir, rt.state.meetings[id].decisionFile), 'utf8') + assert.match(body, /## Dissent\n\nnone recorded/) + assert.doesNotMatch(body, /a second store is cleaner to audit/) + assert.match(body, /\*\*Reviewer\*\* — agree — the existing store is fine after all/) +}) + +test('#3203: two dissenters are both on the record with their own authors', async (t) => { + const { rt, dir, meeting, open, stop } = await boot() + t.after(stop) + const id = await open('Should Stage 4 reuse the existing store?', ['Chief', 'Dev', 'Reviewer']) + const first = await meeting({ action: 'position', meeting: id, as: 'Chief', stance: 'dissent', text: 'two people must sign' }) + assert.match(first, /dissent: two people must sign — Chief/) + const second = await meeting({ action: 'position', meeting: id, as: 'Dev', stance: 'dissent', text: 'a second signature is a second risk' }) + assert.match(second, /dissent: two people must sign — Chief/, 'the first dissenter stays on the view') + assert.match(second, /dissent: a second signature is a second risk — Dev/, 'the second dissenter is on the view too') + await meeting({ action: 'position', meeting: id, as: 'Reviewer', stance: 'agree', text: 'the existing store' }) + await meeting({ action: 'decide', meeting: id, owner: 'Chief', decision: 'Keep the existing store.', evidence: [{ pr: 3203 }] }) + const body = readFileSync(join(dir, rt.state.meetings[id].decisionFile), 'utf8') + assert.match(body, /two people must sign — \*\*Chief\*\*/, 'the first objection is archived with its author') + assert.match(body, /a second signature is a second risk — \*\*Dev\*\*/, 'the second objection is archived with its author') +}) + +test('#3203: decide keeps the explicit dissent override, and an empty one is still refused', async (t) => { + const { rt, dir, meeting, open, stop } = await boot() + t.after(stop) + const id = await open('Should Stage 4 reuse the existing store?', ['Chief', 'Dev']) + await meeting({ action: 'position', meeting: id, as: 'Chief', stance: 'agree', text: 'the existing store' }) + await meeting({ action: 'position', meeting: id, as: 'Dev', stance: 'agree', text: 'no second store' }) + await assert.rejects( + meeting({ action: 'decide', meeting: id, owner: 'Chief', decision: 'Keep the existing store.', dissent: { text: ' ' }, evidence: [{ pr: 3203 }] }), + /a dissent needs the objection it records/, + ) + await meeting({ + action: 'decide', meeting: id, owner: 'Chief', decision: 'Keep the existing store.', + dissent: { text: 'the objection raised in the thread still stands', owner: 'Chief' }, evidence: [{ pr: 3203 }], + }) + assert.deepEqual(rt.state.meetings[id].dissent, { text: 'the objection raised in the thread still stands', owner: 'Chief' }) + const body = readFileSync(join(dir, rt.state.meetings[id].decisionFile), 'utf8') + assert.match(body, /the objection raised in the thread still stands — \*\*Chief\*\*/) +}) diff --git a/docs/subsystems/core-host.md b/docs/subsystems/core-host.md index f4f00c9f8..20ba2c21f 100644 --- a/docs/subsystems/core-host.md +++ b/docs/subsystems/core-host.md @@ -800,9 +800,15 @@ no second store, no UI-only path and no cron. positions, options and evidence, writes the `blockingAnswer`, clears the blocked stamp and moves the meeting back to `deliberating`. `decided` is terminal — `resume` on it is refused `closed`. - **Positions.** An invited participant records `agree`, `dissent` or `abstain` with a line of text. - A name that was not invited is refused `not-invited`; a dissent with text is also kept as the - meeting's standing dissent, owned by the participant who recorded it. A participant who never - answers and is not recorded `silent` keeps the meeting from closing. + A name that was not invited is refused `not-invited`; a dissent with text is the meeting's + standing dissent, owned by the participant who recorded it. Since #3203 that dissent is read back + from the positions as they stand now instead of stamped once: a participant who later records + another stance takes their objection with them (once nobody dissents, the Dissent section and the + archived file print `none recorded`), and when two participants dissent both objections are on the + record under their own names. The stored single `dissent` follows the positions (the first + objection that still stands); an explicit `dissent` passed to `decide` stays an override that is + printed beside the standing ones, and a `decide` without one recomputes the record before writing + it. A participant who never answers and is not recorded `silent` keeps the meeting from closing. - **The governance check is code.** `governanceRefusal(meeting)` is the one refusal `decide` runs before it writes anything: every invited participant has a position or is recorded silent, the decision names an `owner`, a dissent carries its own `owner`, and the decision states what was diff --git a/patches/ds-bot/files/src/host/meetings.js b/patches/ds-bot/files/src/host/meetings.js index 42b7e694d..61c601f7c 100644 --- a/patches/ds-bot/files/src/host/meetings.js +++ b/patches/ds-bot/files/src/host/meetings.js @@ -136,6 +136,44 @@ export function proxyRefusal(meeting) { return undefined } +// #3203: what the meeting's dissent *is* gets read back from the positions as they stand now, +// not stamped once when the first participant dissents. A participant who changes their stance +// takes their objection with them, and every participant who still dissents stays on the record +// under their own name — one owner per objection, so a second dissenter does not overwrite the +// first. +const recordedDissent = participant => { + const position = participant?.position + if (position?.stance !== 'dissent') return undefined + const text = oneLine(position.text, TEXT_MAX) + return text === '' ? undefined : { text, owner: participant.name } +} + +const standingDissents = meeting => (Array.isArray(meeting.participants) ? meeting.participants : []) + .map(recordedDissent) + .filter(record => record !== undefined) + +// What the view and the archived file print: the standing dissents, plus an explicit `dissent` a +// `decide` set (the override the tool offers) when it names an objection the positions do not +// already carry. A decided record keeps that line as history; an open one reads only the +// positions, so a stale stamp from an older build cannot outlive the stance behind it. +const dissentRecords = meeting => { + const standing = standingDissents(meeting) + const recorded = meeting.status === 'decided' ? meeting.dissent : undefined + const text = oneLine(recorded?.text, TEXT_MAX) + if (text === '') return standing + const owner = oneLine(recorded.owner, NAME_MAX) + if (standing.some(record => record.owner === owner && record.text === text)) return standing + return [{ text, owner }, ...standing] +} + +// The stored single `dissent` follows the positions: the first objection that still stands, or +// none at all. It stays the shape the governance check and older readers know. +const syncDissent = meeting => { + const [first] = standingDissents(meeting) + if (first === undefined) delete meeting.dissent + else meeting.dissent = first +} + export function governanceRefusal(meeting) { if (!OPEN_STATES.has(meeting.status)) return `the meeting is ${meeting.status}, not open or deliberating` const proxied = proxyRefusal(meeting) @@ -202,9 +240,10 @@ const decisionBody = (meeting, file, at) => { lines.push(`- **${participant.name}** — ${said}${proxy === '' ? '' : ` (speaks for ${proxy})`}`) } lines.push('', '## Dissent', '') - lines.push(meeting.dissent === undefined - ? 'none recorded' - : `${oneLine(meeting.dissent.text, TEXT_MAX)} — **${oneLine(meeting.dissent.owner, NAME_MAX)}**`) + const dissents = dissentRecords(meeting) + if (dissents.length === 0) lines.push('none recorded') + else if (dissents.length === 1) lines.push(`${dissents[0].text} — **${dissents[0].owner}**`) + else for (const record of dissents) lines.push(`- ${record.text} — **${record.owner}**`) lines.push('', '## Status', '', 'accepted', '') lines.push('## Links', '', `- Decision file: ${file}`) if (meeting.issue !== undefined) lines.push(`- Issue: #${meeting.issue}`) @@ -278,9 +317,7 @@ export function install(rt) { if (spokenFor === '') delete participant.speaksFor else participant.speaksFor = spokenFor participant.position = { stance: chosen, text: oneLine(text, TEXT_MAX), at: now, ...(spokenFor === '' ? {} : { speaksFor: spokenFor }) } - if (chosen === 'dissent' && oneLine(text, TEXT_MAX) !== '') { - meeting.dissent = { text: oneLine(text, TEXT_MAX), owner: name } - } + syncDissent(meeting) if (meeting.status === 'open') meeting.status = 'deliberating' meeting.updatedAt = now return meeting @@ -384,6 +421,10 @@ export function install(rt) { const ownerName = oneLine(args.dissent?.owner, NAME_MAX) if (text === '') throw refuse('invalid', 'a dissent needs the objection it records') candidate.dissent = { text, owner: ownerName } + } else { + // #3203: the record follows the positions at the moment it is written, so a dissent that + // was withdrawn before `decide` never reaches the file. + syncDissent(candidate) } const reason = governanceRefusal(candidate) if (reason !== undefined) throw refuse('governance', reason) @@ -521,7 +562,7 @@ export function install(rt) { lines.push(`level: ${level}${(meeting.recipients ?? []).length === 0 ? '' : ` | recipients: ${(meeting.recipients ?? []).join(', ')}`}`) const paused = advanceRefusal(meeting) if (paused !== undefined) lines.push(`paused: ${paused}`) - if (meeting.dissent !== undefined) lines.push(`dissent: ${meeting.dissent.text} — ${meeting.dissent.owner}`) + for (const record of dissentRecords(meeting)) lines.push(`dissent: ${record.text} — ${record.owner}`) if (meeting.blockingQuestion !== undefined) lines.push(`blocking: ${meeting.blockingQuestion}`) if (meeting.blockingAnswer !== undefined) lines.push(`answer: ${meeting.blockingAnswer}`) if (meeting.decisionFile !== undefined) lines.push(`decision file: ${meeting.decisionFile}`, `tasks: ${meeting.taskIds.join(', ') || 'none'}`) diff --git a/patches/ds-bot/files/test/meetings.test.js b/patches/ds-bot/files/test/meetings.test.js index a5da1b0e5..530f281ea 100644 --- a/patches/ds-bot/files/test/meetings.test.js +++ b/patches/ds-bot/files/test/meetings.test.js @@ -279,3 +279,61 @@ test('#1861: the decision card exposes the participants and their proxies', asyn { name: 'Owner', speaksFor: null, stance: null, silent: false }, ]) }) + +// #3203: the Dissent record is read back from the positions as they stand now, not stamped once +// when someone first dissents. A withdrawn objection leaves the record (the Dissent line and the +// participant's own row agree), and every objection that still stands is named with its author. +test('#3203: a withdrawn dissent leaves the record, and the participant row agrees with it', async (t) => { + const { rt, dir, meeting, open, stop } = await boot() + t.after(stop) + const id = await open('Should Stage 4 reuse the existing store?', ['Chief', 'Dev', 'Reviewer']) + await meeting({ action: 'position', meeting: id, as: 'Chief', stance: 'agree', text: 'the existing store is fine' }) + await meeting({ action: 'position', meeting: id, as: 'Dev', stance: 'agree', text: 'the existing store' }) + const stance = await meeting({ action: 'position', meeting: id, as: 'Reviewer', stance: 'dissent', text: 'a second store is cleaner to audit' }) + assert.match(stance, /dissent: a second store is cleaner to audit — Reviewer/, 'the live dissent is on the view') + const view = await meeting({ action: 'position', meeting: id, as: 'Reviewer', stance: 'agree', text: 'the existing store is fine after all' }) + assert.doesNotMatch(view, /a second store is cleaner to audit/, 'the withdrawn objection is no longer the meeting dissent') + assert.doesNotMatch(view, /^dissent:/m, 'the view names no standing dissent') + assert.match(view, /- Reviewer: agree — the existing store is fine after all/, 'the participant row says agree') + await meeting({ action: 'decide', meeting: id, owner: 'Chief', decision: 'Keep the existing store.', evidence: [{ pr: 3203 }] }) + assert.equal(rt.state.meetings[id].dissent, undefined, 'the withdrawn dissent is not stored') + const body = readFileSync(join(dir, rt.state.meetings[id].decisionFile), 'utf8') + assert.match(body, /## Dissent\n\nnone recorded/) + assert.doesNotMatch(body, /a second store is cleaner to audit/) + assert.match(body, /\*\*Reviewer\*\* — agree — the existing store is fine after all/) +}) + +test('#3203: two dissenters are both on the record with their own authors', async (t) => { + const { rt, dir, meeting, open, stop } = await boot() + t.after(stop) + const id = await open('Should Stage 4 reuse the existing store?', ['Chief', 'Dev', 'Reviewer']) + const first = await meeting({ action: 'position', meeting: id, as: 'Chief', stance: 'dissent', text: 'two people must sign' }) + assert.match(first, /dissent: two people must sign — Chief/) + const second = await meeting({ action: 'position', meeting: id, as: 'Dev', stance: 'dissent', text: 'a second signature is a second risk' }) + assert.match(second, /dissent: two people must sign — Chief/, 'the first dissenter stays on the view') + assert.match(second, /dissent: a second signature is a second risk — Dev/, 'the second dissenter is on the view too') + await meeting({ action: 'position', meeting: id, as: 'Reviewer', stance: 'agree', text: 'the existing store' }) + await meeting({ action: 'decide', meeting: id, owner: 'Chief', decision: 'Keep the existing store.', evidence: [{ pr: 3203 }] }) + const body = readFileSync(join(dir, rt.state.meetings[id].decisionFile), 'utf8') + assert.match(body, /two people must sign — \*\*Chief\*\*/, 'the first objection is archived with its author') + assert.match(body, /a second signature is a second risk — \*\*Dev\*\*/, 'the second objection is archived with its author') +}) + +test('#3203: decide keeps the explicit dissent override, and an empty one is still refused', async (t) => { + const { rt, dir, meeting, open, stop } = await boot() + t.after(stop) + const id = await open('Should Stage 4 reuse the existing store?', ['Chief', 'Dev']) + await meeting({ action: 'position', meeting: id, as: 'Chief', stance: 'agree', text: 'the existing store' }) + await meeting({ action: 'position', meeting: id, as: 'Dev', stance: 'agree', text: 'no second store' }) + await assert.rejects( + meeting({ action: 'decide', meeting: id, owner: 'Chief', decision: 'Keep the existing store.', dissent: { text: ' ' }, evidence: [{ pr: 3203 }] }), + /a dissent needs the objection it records/, + ) + await meeting({ + action: 'decide', meeting: id, owner: 'Chief', decision: 'Keep the existing store.', + dissent: { text: 'the objection raised in the thread still stands', owner: 'Chief' }, evidence: [{ pr: 3203 }], + }) + assert.deepEqual(rt.state.meetings[id].dissent, { text: 'the objection raised in the thread still stands', owner: 'Chief' }) + const body = readFileSync(join(dir, rt.state.meetings[id].decisionFile), 'utf8') + assert.match(body, /the objection raised in the thread still stands — \*\*Chief\*\*/) +})