fix(recovery): stop an agent configuration write from re-checking every task of the company (#21861)

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The recovery queues check each assigned task to find work that has
no live run and no queued wake
> - On a nearly idle hosted instance, these queues still re-check almost
every task of a company in bursts, at about 22 read-only statements per
task
> - #21831 stopped a run start from re-checking all of its agent's
tasks, but bursts continued after writes to an agent row during a long
run
> - The cause is not the changed-rows backstop. An agent configuration
write publishes the company-wide task recovery hint, so every task queue
reloads and checks every assigned task of the company
> - This pull request makes an agent configuration write signal only the
company-level recovery queues and the run dispatch queues, not the
per-task queues
> - The benefit is that a configuration write during a long run no
longer re-checks hundreds of settled tasks

## Linked Issues or Issue Description

Refs #21831

**What happened?**
A write to an agent's configuration (for example `PATCH /agents/:id`, an
instructions save that rebinds the entry file, a skill or connection
change) calls `notifyRunDispatch({ companyId })`. That function sends
the company hint to the task queues (`stranded-assignments`,
`assigned-work-invariant`, `resolved-dependencies`,
`stale-issue-locks`). A company hint is not a backstop hint, so the
queue loads every eligible task of the company with no changed-rows
filter and checks each one. In a staging-shaped fixture (780 settled
reviews), each configuration write caused 780 checks and about 16,000
statements. The agent row keeps status `running` and its old
`last_heartbeat_at`, which matches the writes seen on staging.

**Expected behavior**
A configuration write does not re-check tasks. Only a change that can
strand a task (pause, resume, hold release, termination) re-checks
tasks, and those changes keep their own lifecycle hint.

**Steps to reproduce**
1. Seed one agent with 700 settled in-review tasks and a second agent
with 80, each with one live native run.
2. Start the recovery workers with the debug flag
`PAPERCLIP_DEBUG_WORK_SIGNALS=stranded-assignments:1`.
3. Update the agent's `runtimeConfig` or `adapterConfig` through
`agentService(db).update`.
4. See 780 `check` events with `wake: "company"`.

**Paperclip version or commit**
`master` at c5218f5ec4.

## What Changed

- `run-dispatch-notifications.ts`: split the dispatch queue hints out of
`notifyRunDispatch` and add `notifyAgentConfigurationDispatch`. It sends
the company-level recovery hints and the dispatch hints, but no
task-queue hint.
- `issue-recovery-notifications.ts`: add `notifyCompanyRecovery`, which
signals only the company-level recovery queues (orphan blockers, active
recovery actions, task watchdogs).
- `agent-configuration.ts`: a configuration write uses
`notifyAgentConfigurationDispatch` instead of `notifyRunDispatch`.
- New census test `issue-recovery-agent-row-write-census.test.ts`. It
uses real workers, a fake clock and a staging-shaped fixture. It drives
five agent-row writers through their real code paths over 35 simulated
minutes, and it adds guard tests.

## Verification

Red/green census (`issue-recovery-agent-row-write-census.test.ts`, 35
simulated minutes, five writes: runtime config on the big agent, adapter
config on the second agent, execution start rewrite, permissions,
adapter config on the big agent):

| | Settled-task checks | Stranded checks by wake | Statements |
| --- | --- | --- | --- |
| Before | 2,340 | company 2,346, hint 204, backstop 6 | 51,497 |
| After | 0 | hint 210, backstop 7 | 4,580 |

The execution start rewrite and the permissions write caused 0 settled
checks before and after. Only the three configuration writes caused the
whole-company reloads.

Guard tests (pass before and after):
- A task of the running agent that becomes stranded after a
configuration write is checked within the backstop bound.
- An idle agent's tasks are still checked within the backstop bound
after its configuration is written (the agent clause of the changed-rows
backstop).
- A hold release through the lifecycle status-change effect checks the
waiting task within one minute.
- Pause and termination through the lifecycle check the agent's tasks
within one minute.
- The hourly full pass still checks every settled task.

Focused suites: `cd server && npx vitest run` on 19 files (recovery
work, census, backstop, debug attribution, signal fanout, run dispatch,
agent configuration, budget configuration, agent timers, lifecycle): 278
passed, 1 skipped. `pnpm verify` returned exit 2 (opaque setup
dependency), so required CI supplies broad coverage. Server `tsc
--noEmit` passed.

## Risks

- A configuration write no longer re-checks the company's tasks at once.
Agent status changes still send the company hint through the lifecycle
effect. For a non-running agent, the changed-rows backstop still picks
up its tasks within the existing 5-minute bound. The hourly full pass is
unchanged.
- The stranded check reads agent status, holds and budget, not
configuration, so a configuration change cannot strand a task by itself.
- Low risk otherwise. No schema change.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use and code
execution in Claude Code.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DottaandClaude Opus 5.5 authored and GitHub committed 2026-11-15 23:46:49 -06:00
1 parent 29903bed59
commit 94cb7ad359
5 files changed
+257 -3

No files matched your search

@@ -0,0 +1,207 @@
import { setImmediate as immediate } from "node:timers/promises";
import { eq } from "drizzle-orm";
import { expect, it, vi } from "vitest";
import { agents, heartbeatRuns, issues } from "@paperclipai/db";
import { workSignalDebug } from "@paperclipai/db/work-signal-debug";
import { ISSUE_RECOVERY_BACKSTOP_MS, ISSUE_RECOVERY_FULL_BACKSTOP_MS, notifyIssueGraphRecovery }
from "../services/issue-recovery-notifications.js";
import { agentService } from "../services/agents.js";
import { createAgentLifecycle, createAgentLifecycleEffects } from "../services/agent-lifecycle.js";
import { describeIssueRecovery, issueRecoveryFixture } from "./issue-recovery.test-fixture.js";
vi.hoisted(() => { process.env.PAPERCLIP_DEBUG_WORK_SIGNALS = "stranded-assignments:1,assigned-work-invariant:1"; });
const MINUTE = 60_000;
const HOUR = 60 * MINUTE;
const TOPICS = new Set(["stranded-assignments", "assigned-work-invariant"]);
type Recorded = { at: number; topic: string; name: string; fields: Record<string, unknown> };
describeIssueRecovery("agent row writes during a long run (census)", () => {
const state = issueRecoveryFixture({ meter: true });
async function advance(ms: number, onTick?: () => Promise<unknown>) {
const until = Date.now() + ms;
let nextTick = Date.now();
while (Date.now() < until) {
if (onTick && Date.now() >= nextTick) { await onTick(); nextTick = Date.now() + 10_000; }
await vi.advanceTimersByTimeAsync(Math.min(1000, until - Date.now()));
await Promise.allSettled([...state.passes]); await immediate();
}
}
function record() {
const events: Recorded[] = [];
vi.spyOn(workSignalDebug, "event").mockImplementation((topic, name, fields = {}) => {
if (TOPICS.has(topic)) events.push({ at: Date.now(), topic, name, fields });
});
return events;
}
function byWake(events: Recorded[]) {
const counts: Record<string, Record<string, number>> = {};
for (const event of events) if (event.name === "check") {
const topic = counts[event.topic] ??= {};
topic[String(event.fields.wake)] = (topic[String(event.fields.wake)] ?? 0) + 1;
}
return counts;
}
async function seed() {
const f = await state.fixture();
const config = { adapterType: "process", adapterConfig: { command: process.execPath, args: ["-e", "0"], cwd: process.cwd() },
runtimeConfig: { heartbeat: { enabled: false, intervalSec: 0, wakeOnDemand: true } }, role: "engineer" };
const old = new Date(Date.now() - 2 * HOUR);
const [big, second, held] = await state.db.insert(agents).values([
{ ...config, companyId: f.companyId, name: "Big worker", status: "idle", createdAt: old, updatedAt: old, lastHeartbeatAt: old },
{ ...config, companyId: f.companyId, name: "Second worker", status: "idle", createdAt: old, updatedAt: old, lastHeartbeatAt: old },
{ ...config, companyId: f.companyId, name: "Held worker", status: "paused", lifecycleHolds: ["manual"], pauseReason: "manual",
createdAt: old, updatedAt: old },
]).returning({ id: agents.id });
const finishedAt = new Date(Date.now() - HOUR);
const reviews = async (agentId: string, count: number) => {
const rows = await state.db.insert(issues).values(Array.from({ length: count }, (_, index) => ({ companyId: f.companyId,
title: `Review ${index}`, status: "in_review", assigneeAgentId: agentId, createdAt: old, updatedAt: old })))
.returning({ id: issues.id });
await state.db.insert(heartbeatRuns).values(rows.map(row => ({ companyId: f.companyId, agentId, status: "succeeded",
runtimeMode: "native", startedAt: finishedAt, finishedAt, updatedAt: finishedAt, contextSnapshot: { issueId: row.id } })));
return rows.map(row => row.id);
};
const bigTasks = await reviews(big!.id, 700);
const secondTasks = await reviews(second!.id, 80);
const [bigLive, secondLive, waiting] = await state.db.insert(issues).values([
{ companyId: f.companyId, title: "Big live task", status: "in_progress", assigneeAgentId: big!.id },
{ companyId: f.companyId, title: "Second live task", status: "in_progress", assigneeAgentId: second!.id },
{ companyId: f.companyId, title: "Waits for its agent", status: "todo", assigneeAgentId: held!.id, createdAt: old, updatedAt: old },
]).returning({ id: issues.id });
return { ...f, bigId: big!.id, secondId: second!.id, heldId: held!.id, bigTasks, secondTasks,
bigLiveTask: bigLive!.id, secondLiveTask: secondLive!.id, waitingTask: waiting!.id };
}
async function boot() {
const f = await seed();
const events = record();
vi.useFakeTimers({ toFake: ["Date", "setTimeout", "clearTimeout"] });
await state.start({});
const startRun = async (agentId: string, issueId: string) => {
const [run] = await state.db.insert(heartbeatRuns).values({ companyId: f.companyId, agentId, status: "running", runtimeMode: "native",
startedAt: new Date(), contextSnapshot: { issueId }, nativeIssueId: issueId })
.returning({ id: heartbeatRuns.id });
await state.db.update(issues).set({ executionRunId: run!.id }).where(eq(issues.id, issueId));
await state.db.update(agents).set({ status: "running", updatedAt: new Date() }).where(eq(agents.id, agentId));
return run!.id;
};
const bigRun = await startRun(f.bigId, f.bigLiveTask);
await startRun(f.secondId, f.secondLiveTask);
const tick = () => state.db.transaction(async tx => {
await tx.update(heartbeatRuns).set({ updatedAt: new Date() }).where(eq(heartbeatRuns.id, bigRun));
await notifyIssueGraphRecovery(tx, { companyId: f.companyId, runId: bigRun });
});
await advance(12 * MINUTE, tick);
events.length = 0;
return { ...f, events, bigRun, tick };
}
const checksOf = (events: Recorded[], issueId: string) =>
events.filter(event => event.topic === "stranded-assignments" && event.name === "check" && event.fields.issueId === issueId);
it("does not re-check either running agent's settled tasks when their rows are written during the runs", async () => {
const f = await boot();
const svc = agentService(state.db);
const before = state.meter.read();
const writes: Array<[string, () => Promise<unknown>]> = [
["big agent runtime configuration", () => svc.update(f.bigId,
{ runtimeConfig: { heartbeat: { enabled: false, intervalSec: 0, wakeOnDemand: true }, revision: 1 } })],
["second agent adapter configuration", () => svc.update(f.secondId,
{ adapterConfig: { command: process.execPath, args: ["-e", "1"], cwd: process.cwd() } })],
["big agent execution start", () => state.db.update(agents).set({ status: "running", updatedAt: new Date() })
.where(eq(agents.id, f.bigId))],
["big agent permissions", () => svc.updatePermissions(f.bigId, { canCreateAgents: false })],
["big agent adapter configuration", () => svc.update(f.bigId,
{ adapterConfig: { command: process.execPath, args: ["-e", "2"], cwd: process.cwd() } })],
];
for (const [, write] of writes) {
await write();
await advance(7 * MINUTE, f.tick);
}
const after = state.meter.read();
const settled = new Set([...f.bigTasks, ...f.secondTasks]);
const settledChecks = f.events.filter(event => event.name === "check" && settled.has(String(event.fields.issueId))).length;
const result = { writes: writes.map(([label]) => label), minutes: writes.length * 7, settledChecks, byWake: byWake(f.events),
statements: after.statements - before.statements };
console.info(`agent-row census: ${JSON.stringify(result)}`);
expect(settledChecks).toBe(0);
expect(result.byWake["stranded-assignments"]?.company ?? 0).toBe(0);
expect(result.byWake["stranded-assignments"]?.reload ?? 0).toBe(0);
}, 1_800_000);
it("still checks a running agent's task within the backstop bound when it becomes stranded after a configuration write", async () => {
const f = await boot();
await agentService(state.db).update(f.bigId, { runtimeConfig: { heartbeat: { enabled: false, intervalSec: 0, wakeOnDemand: true }, revision: 2 } });
await advance(MINUTE, f.tick);
f.events.length = 0;
const target = f.bigTasks[17]!;
const changedAt = Date.now();
await state.db.update(issues).set({ status: "todo", updatedAt: new Date() }).where(eq(issues.id, target));
await advance(ISSUE_RECOVERY_BACKSTOP_MS + 2 * MINUTE, f.tick);
const [checked] = checksOf(f.events, target);
expect(checked).toBeDefined();
expect(checked!.at - changedAt).toBeLessThanOrEqual(ISSUE_RECOVERY_BACKSTOP_MS + 2 * MINUTE);
}, 1_800_000);
it("still checks an idle agent's tasks within the backstop bound after its configuration is written", async () => {
const f = await boot();
await state.db.update(heartbeatRuns).set({ status: "succeeded", finishedAt: new Date(), updatedAt: new Date() })
.where(eq(heartbeatRuns.agentId, f.secondId));
await state.db.update(agents).set({ status: "idle", lastHeartbeatAt: new Date(), updatedAt: new Date() })
.where(eq(agents.id, f.secondId));
await advance(11 * MINUTE, f.tick);
f.events.length = 0;
const changedAt = Date.now();
await agentService(state.db).update(f.secondId, { adapterConfig: { command: process.execPath, args: ["-e", "3"], cwd: process.cwd() } });
await advance(ISSUE_RECOVERY_BACKSTOP_MS + 2 * MINUTE, f.tick);
const [checked] = checksOf(f.events, f.secondTasks[5]!);
expect(checked).toBeDefined();
expect(checked!.at - changedAt).toBeLessThanOrEqual(ISSUE_RECOVERY_BACKSTOP_MS + 2 * MINUTE);
}, 1_800_000);
it("still checks a held agent's waiting task promptly when its hold is released", async () => {
const f = await boot();
const changedAt = Date.now();
await state.db.transaction(async tx => {
await createAgentLifecycleEffects().beforeStatusChange(tx as never, f.companyId, f.heldId, "paused", "idle");
await tx.update(agents).set({ status: "idle", lifecycleHolds: [], pauseReason: null, pausedAt: null, updatedAt: new Date() })
.where(eq(agents.id, f.heldId));
});
await advance(2 * MINUTE, f.tick);
const [checked] = checksOf(f.events, f.waitingTask);
expect(checked).toBeDefined();
expect(checked!.at - changedAt).toBeLessThanOrEqual(MINUTE);
}, 1_800_000);
it("still checks a running agent's tasks promptly when the agent is paused or terminated", async () => {
const f = await boot();
const lifecycle = createAgentLifecycle(state.db);
let changedAt = Date.now();
await lifecycle.pauseAgent(f.secondId);
await advance(2 * MINUTE, f.tick);
let [checked] = checksOf(f.events, f.secondTasks[3]!);
expect(checked).toBeDefined();
expect(checked!.at - changedAt).toBeLessThanOrEqual(MINUTE);
f.events.length = 0;
changedAt = Date.now();
await lifecycle.terminateAgent(f.bigId);
await advance(2 * MINUTE, f.tick);
[checked] = checksOf(f.events, f.bigTasks[9]!);
expect(checked).toBeDefined();
expect(checked!.at - changedAt).toBeLessThanOrEqual(MINUTE);
}, 1_800_000);
it("still re-checks every settled task in the hourly full pass after configuration writes", async () => {
const f = await boot();
await agentService(state.db).update(f.bigId, { runtimeConfig: { heartbeat: { enabled: false, intervalSec: 0, wakeOnDemand: true }, revision: 3 } });
await advance(ISSUE_RECOVERY_FULL_BACKSTOP_MS + 5 * MINUTE, f.tick);
const checked = new Set(f.events.filter(event => event.topic === "stranded-assignments" && event.name === "check")
.map(event => String(event.fields.issueId)));
expect([...f.bigTasks, ...f.secondTasks].filter(id => !checked.has(id))).toEqual([]);
}, 1_800_000);
});
+2 -2
View File
@@ -6,7 +6,7 @@ import { notifyMuseContactVerification } from "../modules/external-agents/index.
import { assertEphemeralAgentInstructions } from "./agent-instructions.js"; import { assertEphemeralAgentInstructions } from "./agent-instructions.js";
import { notifyStrandedAgentStatus } from "./live-run-recovery-notifications.js"; import { notifyStrandedAgentStatus } from "./live-run-recovery-notifications.js";
import { notifyDeferredExecutionEligibility } from "./deferred-execution-notifications.js"; import { notifyDeferredExecutionEligibility } from "./deferred-execution-notifications.js";
import { notifyRunDispatch } from "./run-dispatch-notifications.js"; import { notifyAgentConfigurationDispatch } from "./run-dispatch-notifications.js";
import { notifyAttentionRetentionWork } from "./retention-work-notifications.js"; import { notifyAttentionRetentionWork } from "./retention-work-notifications.js";
import { notifySkillVersionPinChange } from "./skill-version-retention-notifications.js"; import { notifySkillVersionPinChange } from "./skill-version-retention-notifications.js";
import { DELIVERY_QUEUES, notifyDeliveryWork } from "./delivery-work-notifications.js"; import { DELIVERY_QUEUES, notifyDeliveryWork } from "./delivery-work-notifications.js";
@@ -127,7 +127,7 @@ export async function prepareAgentConfiguration(db: Db, existing: AgentConfigura
||normalizedPatch.adapterConfig!==undefined&&!jsonEqual(normalizedPatch.adapterConfig,existing.adapterConfig)) ||normalizedPatch.adapterConfig!==undefined&&!jsonEqual(normalizedPatch.adapterConfig,existing.adapterConfig))
await notifyMuseContactVerification(db,{companyId:existing.companyId,agentId:existing.id}); await notifyMuseContactVerification(db,{companyId:existing.companyId,agentId:existing.id});
await notifyStrandedAgentStatus(db, { companyId: existing.companyId, agentId: existing.id }); await notifyStrandedAgentStatus(db, { companyId: existing.companyId, agentId: existing.id });
await notifyRunDispatch(db, { companyId: existing.companyId }); await notifyAgentConfigurationDispatch(db, { companyId: existing.companyId });
await notifyDeferredExecutionEligibility(db, { companyId: existing.companyId }); await notifyDeferredExecutionEligibility(db, { companyId: existing.companyId });
if (normalizedPatch.runtimeConfig !== undefined || normalizedPatch.reportsTo !== undefined) { if (normalizedPatch.runtimeConfig !== undefined || normalizedPatch.reportsTo !== undefined) {
await notifyDeliveryWork(db, DELIVERY_QUEUES.agentTimers); await notifyDeliveryWork(db, DELIVERY_QUEUES.agentTimers);
@@ -24,6 +24,11 @@ export async function notifyIssueRecovery(transaction: object, scope?: IssueReco
for (const queue of TASK_QUEUES) await notifyDeliveryWork(transaction, queue, issueHint); for (const queue of TASK_QUEUES) await notifyDeliveryWork(transaction, queue, issueHint);
} }
export async function notifyCompanyRecovery(transaction: object, companyId: string) {
const companyHint = JSON.stringify({ companyId });
for (const queue of COMPANY_QUEUES) await notifyDeliveryWork(transaction, queue, companyHint);
}
export function issueRecoveryBackstopHint(companyId: string) { export function issueRecoveryBackstopHint(companyId: string) {
return JSON.stringify({ companyId, backstop: true }); return JSON.stringify({ companyId, backstop: true });
} }
@@ -0,0 +1,33 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
const signals = vi.hoisted(() => [] as Array<[string, string | undefined]>);
vi.mock("./delivery-work-notifications.js", async importOriginal => ({
...(await importOriginal<typeof import("./delivery-work-notifications.js")>()),
notifyDeliveryWork: async (_transaction: object, queue: string, hint?: string) => { signals.push([queue, hint]); },
}));
const { notifyAgentConfigurationDispatch, notifyRunDispatch } = await import("./run-dispatch-notifications.js");
const TASK_QUEUES = ["stranded-assignments", "assigned-work-invariant", "resolved-dependencies", "stale-issue-locks"];
const company = JSON.stringify({ companyId: "company-1" });
describe("run dispatch notifications", () => {
beforeEach(() => { signals.length = 0; });
it("wakes the company recovery and dispatch queues on an agent configuration write, but no task queue", async () => {
await notifyAgentConfigurationDispatch({}, { companyId: "company-1" });
expect(signals).toEqual([
["orphan-blockers", company], ["active-recovery-actions", company], ["task-watchdogs", company],
["native-process-sessions", company], ["execution-replacement", company], ["queued-run-dispatch", company],
]);
expect(signals.filter(([queue]) => TASK_QUEUES.includes(queue))).toEqual([]);
});
it("still wakes every task queue with the company hint for a company run dispatch", async () => {
await notifyRunDispatch({}, { companyId: "company-1" });
for (const queue of TASK_QUEUES) expect(signals).toContainEqual([queue, JSON.stringify({ companyId: "company-1" })]);
for (const queue of ["native-process-sessions", "execution-replacement", "queued-run-dispatch"]) {
expect(signals).toContainEqual([queue, company]);
}
});
});
@@ -1,4 +1,4 @@
import { notifyIssueRecovery, notifyIssueGraphRecovery } from "./issue-recovery-notifications.js"; import { notifyCompanyRecovery, notifyIssueRecovery, notifyIssueGraphRecovery } from "./issue-recovery-notifications.js";
import { DELIVERY_QUEUES, notifyDeliveryWork } from "./delivery-work-notifications.js"; import { DELIVERY_QUEUES, notifyDeliveryWork } from "./delivery-work-notifications.js";
export type RunDispatchScope = { companyId: string; issueId?: string | null; runId?: string | null }; export type RunDispatchScope = { companyId: string; issueId?: string | null; runId?: string | null };
@@ -11,6 +11,15 @@ export async function notifyQueuedRunDispatch(transaction: object, scope?: RunDi
export async function notifyRunDispatch(transaction: object, scope?: RunDispatchScope) { export async function notifyRunDispatch(transaction: object, scope?: RunDispatchScope) {
if (scope?.issueId || scope?.runId) await notifyIssueGraphRecovery(transaction, scope); if (scope?.issueId || scope?.runId) await notifyIssueGraphRecovery(transaction, scope);
else await notifyIssueRecovery(transaction, scope ? { companyId: scope.companyId } : undefined); else await notifyIssueRecovery(transaction, scope ? { companyId: scope.companyId } : undefined);
await notifyDispatchQueues(transaction, scope);
}
export async function notifyAgentConfigurationDispatch(transaction: object, scope: { companyId: string }) {
await notifyCompanyRecovery(transaction, scope.companyId);
await notifyDispatchQueues(transaction, scope);
}
async function notifyDispatchQueues(transaction: object, scope?: RunDispatchScope) {
const hint = scope ? JSON.stringify({ companyId: scope.companyId }) : "*"; const hint = scope ? JSON.stringify({ companyId: scope.companyId }) : "*";
await notifyDeliveryWork(transaction, DELIVERY_QUEUES.nativeProcessSessions, hint); await notifyDeliveryWork(transaction, DELIVERY_QUEUES.nativeProcessSessions, hint);
await notifyDeliveryWork(transaction, DELIVERY_QUEUES.executionReplacement, hint); await notifyDeliveryWork(transaction, DELIVERY_QUEUES.executionReplacement, hint);