Files
gitmost/apps/server/src/integrations/queue/constants/queue.interface.ts
T
agent_coder 1542c99979 feat(#370): page-history intentionality tiers — kind column + intentional/idle/boundary triggers (PR-1 core)
PR-1 'core' of #370: introduces page_history.kind ('manual'|'agent'|'idle'|
'boundary'; legacy null = autosave) and rebuilds the snapshot triggers around a
three-tier intentionality model. Draft durability (pages/ydoc hocuspocus
autosave) is unchanged; only the frequency and labelling of history points change.

- Migration 20260705T120000: page_history.kind nullable varchar(20), no default.
- Manual Save: one stateless 'save-version' path for human AND agent; kind is
  derived SERVER-SIDE from the signed context.actor (never the payload), readOnly
  connections rejected, the fresh ydoc runs through the existing store path (no
  REST race), then broadcasts version.saved.
- Idle-flush: trailing debounce (one BullMQ job per page, remove-then-readd) with
  IDLE_INTERVAL_USER=60m / AGENT=15m AND a max-wait ceiling
  (IDLE_MAX_WAIT_USER=10m / AGENT=5m) so a continuous editing session can't starve
  the autosnapshot (review round-1 WARNING).
- Boundary: generalized from the user→agent special-case to ANY lastUpdatedSource
  transition (user↔agent↔git), same isDeepStrictEqual gate — covers git-sync free.
- Removed the agent delay=0 fast path and the old HISTORY_FAST_* constants; the
  agent joins the common idle pipeline.
- Promote-not-dup: a manual save on unchanged content promotes the latest
  autosave's kind in place (or no-ops if already manual) instead of duplicating a
  heavy content row.
- Client: mod+S hotkey + menu button (hidden when readOnly), history-panel kind
  badges, dimmed autosaves, a 'versions only' filter (indices map to the full
  list so diff/restore still target the true previous snapshot), live refresh on
  version.saved.

Internal review: APPROVE-with-suggestions; the round-1 WARNING (idle starvation)
is fixed here via the max-wait ceiling, and the generalized-boundary + ceiling
behaviours are pinned with new tests (115 collab/repo specs green, server tsc 0).

Deferred to later PRs: shares.published_mode (PR-2), the save_page_version MCP
tool + role prompts (PR-3), actor='git' wiring into #359 (PR-4).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-05 05:00:12 +03:00

139 lines
3.1 KiB
TypeScript

import { MentionNode } from '../../../common/helpers/prosemirror/utils';
export interface IPageBacklinkJob {
pageId: string;
workspaceId: string;
mentions: MentionNode[];
internalLinkSlugIds?: string[];
}
export interface IAddPageWatchersJob {
userIds: string[];
pageId: string;
spaceId: string;
workspaceId: string;
}
export interface IStripeSeatsSyncJob {
workspaceId: string;
}
export interface IPageHistoryJob {
pageId: string;
// #370 — intentionality tier the worker stamps on the snapshot. All jobs on
// this queue are trailing idle-flush autosnapshots, so this is 'idle' (absent
// → treated as 'idle' by the processor).
kind?: 'idle';
}
/**
* AI_QUEUE payload for a content change that should trigger a RAG reindex
* (§6.7 stage D / §14[M1]). Produced by the collab persistence extension on
* `onStoreDocument` and by the page-delete path (the delete case carries the
* ids of pages whose embeddings must be purged).
*/
export interface IPageContentUpdatedJob {
pageIds: string[];
workspaceId: string;
}
/**
* AI_QUEUE payload for workspace-wide RAG embedding jobs
* (WORKSPACE_CREATE_EMBEDDINGS / WORKSPACE_DELETE_EMBEDDINGS).
*/
export interface IWorkspaceEmbeddingsJob {
workspaceId: string;
}
export interface INotificationCreateJob {
userId: string;
workspaceId: string;
type: string;
actorId?: string;
pageId?: string;
spaceId?: string;
commentId?: string;
data?: Record<string, unknown>;
}
export interface ICommentNotificationJob {
commentId: string;
parentCommentId?: string;
pageId: string;
spaceId: string;
workspaceId: string;
actorId: string;
mentionedUserIds: string[];
notifyWatchers: boolean;
}
export interface ICommentResolvedNotificationJob {
commentId: string;
commentCreatorId: string;
pageId: string;
spaceId: string;
workspaceId: string;
actorId: string;
}
export interface IPageMentionNotificationJob {
userMentions: { userId: string; mentionId: string; creatorId: string }[];
oldMentionedUserIds: string[];
pageId: string;
spaceId: string;
workspaceId: string;
}
export interface IPageUpdateNotificationJob {
pageId: string;
spaceId: string;
workspaceId: string;
actorIds: string[];
}
export interface IPermissionGrantedNotificationJob {
userIds: string[];
pageId: string;
spaceId: string;
workspaceId: string;
actorId: string;
role: string;
}
export interface IVerificationExpiringNotificationJob {
verificationId: string;
}
export interface IVerificationExpiredNotificationJob {
verificationId: string;
}
export interface IVerificationReconcileJob {
// no payload
}
export interface IPageVerifiedNotificationJob {
pageId: string;
spaceId: string;
workspaceId: string;
actorId: string;
verifierIds: string[];
}
export interface IApprovalRequestedNotificationJob {
pageId: string;
spaceId: string;
workspaceId: string;
actorId: string;
verifierIds: string[];
}
export interface IApprovalRejectedNotificationJob {
pageId: string;
spaceId: string;
workspaceId: string;
actorId: string;
requestedById: string;
comment?: string;
}