feat: per-connection publish governance — auto, 1-admin, majority, consensus

Per the owner's spec: each social connection gets publishGovernance in its
fields — unset = manual publish (today), auto = dispatch on approval,
admin1/admin_majority/admin_consensus = a publish-phase chatgov poll
(subject draft_publish, its own open-poll slot, no collision with review
gates). Dispatch holds until the publish poll passes (E3 pre-dispatch
check); auto dispatches on approval. Includes migration 033, the PATCH
/connections/:id/publish-governance route (chatgov.manage), and 19+31 new
tests. Implementation by the branding-panel process (claude/opus), lint
and integration fixes here.
This commit is contained in:
glass beadian 2026-10-14 08:04:56 +00:00
parent f2eb14956e
commit b89dea5c93
26 changed files with 1637 additions and 31 deletions

View file

@ -2,6 +2,7 @@ import { ConflictException } from '@nestjs/common';
import { canonicalPostHash } from '@tactical-media-broadcast-hub/publishing-execution';
import type { PoolClient } from 'pg';
import { ApprovalGateService } from './approval-gate.service.js';
import { onDraftApproved } from './publish-governance.js';
import type { DraftPost } from './publishing.service.js';
/** E2's transactional publishing seam. A System audit actor delegates to a
@ -42,4 +43,12 @@ export async function transitionPollDraft(client: PoolClient, input: {
input.passed ? 'draft.approved' : 'draft.rejected', input.draftId,
{ actor: `system:chat-poll-gate:${input.pollId}`, pollId: input.pollId,
authorizingUserId: reviewer, from: current.state, to: input.passed ? 'approved' : 'rejected', reason: input.reason }]);
// Execute-on-vote for the target connection's publish governance (auto →
// schedule now; gate modes → open the publish poll). The scheduler sweep
// starts the workflow for the committed pending row.
if (input.passed) {
await onDraftApproved(client, { workspaceId: input.workspaceId, draftId: input.draftId,
providerMetadata: (draft.post as DraftPost).providerMetadata ?? {}, preferredUserId: reviewer,
actor: { userId: null, role: 'System' } });
}
}