@vellumai/assistant 0.12.4 → 0.12.5-dev.202609251017.e467a6c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/architecture/memory.md +9 -1
- package/docs/architecture/scheduling.md +13 -5
- package/docs/desktop-browser-cli.md +3 -2
- package/docs/guardian-request-flow.md +1 -1
- package/node_modules/@vellumai/avatar-manifest/src/__tests__/notification-avatar.test.ts +48 -4
- package/node_modules/@vellumai/avatar-manifest/src/notification-avatar.ts +12 -8
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/guardian-requests.test.ts +26 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/guardian-requests.ts +77 -3
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/guardian-requests.test.ts +26 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/guardian-requests.ts +77 -3
- package/node_modules/@vellumai/gateway-client/src/outbound-contract.ts +2 -4
- package/node_modules/@vellumai/service-contracts/src/__tests__/guardian-requests.test.ts +26 -0
- package/node_modules/@vellumai/service-contracts/src/guardian-requests.ts +77 -3
- package/openapi.yaml +152 -3
- package/package.json +1 -1
- package/src/__tests__/agent-loop.test.ts +76 -0
- package/src/__tests__/anthropic-error-formatting.test.ts +9 -0
- package/src/__tests__/background-shell-bash.test.ts +34 -0
- package/src/__tests__/background-shell-host-bash.test.ts +98 -1
- package/src/__tests__/background-tool-registry.test.ts +39 -0
- package/src/__tests__/channel-readiness-discord.test.ts +8 -0
- package/src/__tests__/channel-readiness-slack-remote.test.ts +8 -0
- package/src/__tests__/client-os-metadata-persistence.test.ts +4 -20
- package/src/__tests__/conversation-agent-loop.test.ts +529 -1
- package/src/__tests__/conversation-error.test.ts +18 -0
- package/src/__tests__/conversation-pairing.test.ts +69 -0
- package/src/__tests__/conversation-queue.test.ts +257 -4
- package/src/__tests__/conversation-runtime-assembly.test.ts +27 -0
- package/src/__tests__/emit-signal-routing-intent.test.ts +62 -0
- package/src/__tests__/evict-conversations-for-reload.test.ts +21 -0
- package/src/__tests__/gemini-provider.test.ts +9 -0
- package/src/__tests__/host-cu-proxy.test.ts +79 -0
- package/src/__tests__/host-cu-routes-targeted.test.ts +14 -5
- package/src/__tests__/introduction-card-resolver.test.ts +53 -8
- package/src/__tests__/job-handler-registration-guard.test.ts +1 -0
- package/src/__tests__/non-member-access-request.test.ts +48 -0
- package/src/__tests__/notification-events-source-context-probe.test.ts +48 -1
- package/src/__tests__/notification-platform-adapter.test.ts +97 -0
- package/src/__tests__/notification-vellum-adapter.test.ts +103 -3
- package/src/__tests__/platform-callback-registration.test.ts +46 -1
- package/src/__tests__/plugin-import-boundary-guard.test.ts +3 -0
- package/src/__tests__/scaffold-managed-skill-tool.test.ts +116 -66
- package/src/__tests__/scheduler-disk-pressure.test.ts +1 -0
- package/src/__tests__/scheduler-result-notification.test.ts +521 -7
- package/src/__tests__/scheduler-wake.test.ts +1 -0
- package/src/__tests__/skill-load-inline-command.test.ts +35 -0
- package/src/__tests__/subagent-cron-run-attribution.test.ts +41 -2
- package/src/__tests__/subagent-manager-notify.test.ts +48 -0
- package/src/__tests__/trusted-contact-inline-approval-integration.test.ts +6 -6
- package/src/__tests__/usage-attribution.test.ts +31 -0
- package/src/__tests__/wake-schedule-escalation.test.ts +1 -0
- package/src/agent/loop.ts +23 -0
- package/src/api/ask-question-tool.ts +50 -0
- package/src/api/events/generation-handoff.ts +4 -0
- package/src/api/events/message-complete.ts +4 -0
- package/src/api/events/tool-result.ts +11 -0
- package/src/api/index.ts +11 -0
- package/src/api/requests/guardian-actions.test.ts +45 -0
- package/src/api/requests/guardian-actions.ts +20 -0
- package/src/api/responses/conversation-message.ts +4 -0
- package/src/api/responses/home.ts +27 -0
- package/src/approvals/guardian-decision-primitive.ts +6 -4
- package/src/approvals/guardian-request-resolvers.ts +35 -30
- package/src/avatar/notification-avatar.test.ts +42 -34
- package/src/avatar/notification-avatar.ts +1 -0
- package/src/calls/__tests__/call-controller.test.ts +18 -0
- package/src/calls/__tests__/voice-control-protocol.test.ts +6 -1
- package/src/calls/__tests__/voice-leg-coordinator.test.ts +70 -0
- package/src/calls/__tests__/voice-session-bridge.test.ts +116 -4
- package/src/calls/__tests__/voice-triage-escalate.test.ts +77 -11
- package/src/calls/call-controller.ts +3 -1
- package/src/calls/voice-control-protocol.ts +12 -4
- package/src/calls/voice-escalation-judge.ts +2 -2
- package/src/calls/voice-leg-coordinator.ts +23 -5
- package/src/calls/voice-screen-annotation.ts +44 -0
- package/src/calls/voice-session-bridge.ts +63 -20
- package/src/calls/voice-triage-escalate.ts +82 -27
- package/src/cli/commands/__tests__/conversations-clear.test.ts +156 -0
- package/src/cli/commands/conversations.help.ts +7 -2
- package/src/cli/commands/conversations.ts +36 -30
- package/src/cli/commands/oauth/index.help.ts +8 -2
- package/src/cli/commands/oauth/request.test.ts +32 -0
- package/src/cli/commands/platform/index.help.ts +2 -1
- package/src/cli/commands/platform/index.ts +8 -2
- package/src/cli/lib/__tests__/plugin-catalog-cache.test.ts +60 -0
- package/src/cli/lib/__tests__/plugin-catalog-platform.test.ts +66 -2
- package/src/cli/lib/bundled-marketplace.json +35 -0
- package/src/cli/lib/bundled-plugin-packages.json +21 -0
- package/src/cli/lib/plugin-catalog-cache.ts +17 -2
- package/src/cli/lib/plugin-catalog-platform.ts +48 -9
- package/src/config/__tests__/default-profile-catalog.test.ts +28 -0
- package/src/config/__tests__/platform-identity.test.ts +59 -0
- package/src/config/__tests__/profile-order.test.ts +19 -0
- package/src/config/__tests__/sync-gated-profiles.test.ts +71 -0
- package/src/config/bundled-skills/computer-use/SKILL.md +20 -0
- package/src/config/bundled-skills/computer-use/TOOLS.json +11 -11
- package/src/config/bundled-skills/screen-annotation/SKILL.md +41 -29
- package/src/config/bundled-skills/screen-annotation/TOOLS.json +5 -5
- package/src/config/call-site-defaults.ts +6 -0
- package/src/config/default-profile-catalog.ts +30 -1
- package/src/config/default-profile-names.ts +36 -2
- package/src/config/feature-flag-registry.json +9 -1
- package/src/config/platform-identity.ts +22 -5
- package/src/config/profile-order.ts +7 -1
- package/src/config/schemas/call-site-catalog.ts +7 -0
- package/src/config/schemas/llm.ts +21 -5
- package/src/config/sync-gated-profiles.ts +96 -44
- package/src/daemon/__tests__/abort-null-controller.test.ts +135 -1
- package/src/daemon/__tests__/auto-profile-router.test.ts +380 -0
- package/src/daemon/__tests__/turn-tail-assistant-reply-notify.test.ts +16 -0
- package/src/daemon/activity-trail.test.ts +206 -0
- package/src/daemon/activity-trail.ts +190 -0
- package/src/daemon/auto-profile-router.ts +431 -0
- package/src/daemon/computer-use-observation.test.ts +81 -0
- package/src/daemon/computer-use-observation.ts +23 -0
- package/src/daemon/conversation-agent-loop-handlers.ts +11 -0
- package/src/daemon/conversation-agent-loop.ts +157 -32
- package/src/daemon/conversation-error.ts +19 -0
- package/src/daemon/conversation-lifecycle.ts +70 -7
- package/src/daemon/conversation-media-retry.ts +1 -2
- package/src/daemon/conversation-messaging.ts +31 -2
- package/src/daemon/conversation-process.ts +107 -16
- package/src/daemon/conversation-queue-manager.ts +7 -0
- package/src/daemon/conversation-runtime-assembly.ts +1 -0
- package/src/daemon/conversation-turn-finalize.ts +14 -0
- package/src/daemon/conversation.ts +25 -6
- package/src/daemon/event-loop-watchdog.test.ts +201 -2
- package/src/daemon/event-loop-watchdog.ts +182 -6
- package/src/daemon/host-cu-proxy.ts +34 -3
- package/src/daemon/pkb-reminder-builder.test.ts +10 -3
- package/src/daemon/pkb-reminder-builder.ts +1 -1
- package/src/daemon/wake-conversation-ops.ts +4 -2
- package/src/desktop/desktop-computer-use.test.ts +14 -4
- package/src/home/feed-types.ts +2 -0
- package/src/inbound/platform-callback-registration.ts +19 -6
- package/src/live-voice/__tests__/live-voice-agent-turn.test.ts +27 -0
- package/src/live-voice/__tests__/live-voice-flux-turn-end.test.ts +83 -0
- package/src/live-voice/__tests__/live-voice-triage-escalate.test.ts +48 -1
- package/src/live-voice/__tests__/live-voice-vad.test.ts +34 -2
- package/src/live-voice/__tests__/protocol.test.ts +22 -0
- package/src/live-voice/continuation-judge.ts +1 -1
- package/src/live-voice/live-voice-session.ts +25 -19
- package/src/live-voice/protocol.ts +16 -5
- package/src/messaging/providers/discord/withdraw.ts +4 -5
- package/src/messaging/providers/gmail/client.ts +4 -0
- package/src/messaging/providers/slack/withdraw.ts +5 -5
- package/src/messaging/providers/telegram-bot/withdraw.ts +4 -5
- package/src/monitoring/__tests__/proc-fixtures.ts +28 -0
- package/src/monitoring/__tests__/proc-wait-state.test.ts +232 -0
- package/src/monitoring/__tests__/process-usage.test.ts +243 -0
- package/src/monitoring/proc-wait-state.ts +366 -0
- package/src/monitoring/process-memory.ts +4 -3
- package/src/monitoring/process-usage.ts +215 -0
- package/src/monitoring/resource-sample-types.ts +8 -0
- package/src/monitoring/resource-sampler.ts +17 -2
- package/src/monitoring/stall-capture.ts +12 -0
- package/src/notifications/README.md +88 -9
- package/src/notifications/__tests__/assistant-reply-producer.test.ts +390 -119
- package/src/notifications/__tests__/background-result-producer.test.ts +1272 -0
- package/src/notifications/__tests__/broadcaster.test.ts +292 -1
- package/src/notifications/__tests__/completion-policy.test.ts +243 -0
- package/src/notifications/__tests__/decision-engine.test.ts +51 -4
- package/src/notifications/__tests__/has-pending-background-work.test.ts +281 -0
- package/src/notifications/__tests__/home-feed-side-effect.test.ts +161 -3
- package/src/notifications/__tests__/resolve-visible-in-source.test.ts +110 -1
- package/src/notifications/__tests__/schedule-result-producer.test.ts +11 -4
- package/src/notifications/adapters/macos.ts +24 -12
- package/src/notifications/adapters/platform.ts +16 -5
- package/src/notifications/assistant-reply-producer.ts +96 -71
- package/src/notifications/background-result-producer.ts +369 -0
- package/src/notifications/broadcaster.ts +28 -8
- package/src/notifications/completion-policy.ts +115 -0
- package/src/notifications/completion-work.ts +46 -0
- package/src/notifications/conversation-pairing.ts +32 -13
- package/src/notifications/decision-engine.ts +18 -24
- package/src/notifications/emit-signal.ts +16 -1
- package/src/notifications/events-store.ts +4 -0
- package/src/notifications/has-pending-background-work.ts +91 -0
- package/src/notifications/home-feed-mirror.ts +44 -0
- package/src/notifications/home-feed-side-effect.ts +54 -28
- package/src/notifications/resolve-visible-in-source.ts +56 -2
- package/src/notifications/result-output.ts +154 -0
- package/src/notifications/schedule-result-producer.ts +6 -187
- package/src/notifications/types.ts +2 -0
- package/src/oauth/AGENTS.md +9 -1
- package/src/oauth/byo-connection.test.ts +28 -0
- package/src/persistence/__tests__/recent-conversation-messages.test.ts +41 -0
- package/src/persistence/conversation-crud.ts +26 -0
- package/src/persistence/conversation-types.ts +15 -37
- package/src/persistence/embeddings/__tests__/embedding-local-lifecycle.test.ts +85 -14
- package/src/persistence/jobs-store.ts +229 -0
- package/src/persistence/migrations/383-normalize-opencode-host-connections.ts +44 -0
- package/src/persistence/migrations/__tests__/383-normalize-opencode-host-connections.test.ts +102 -0
- package/src/persistence/steps.ts +12 -0
- package/src/platform/sync-avatar.test.ts +29 -0
- package/src/plugins/defaults/memory/AGENTS.md +5 -3
- package/src/plugins/defaults/memory/__tests__/skill-update-receipt-boundary-guard.test.ts +45 -0
- package/src/plugins/defaults/memory/__tests__/skill-update-receipt-job.test.ts +580 -0
- package/src/plugins/defaults/memory/__tests__/turn-retrieval.test.ts +21 -0
- package/src/plugins/defaults/memory/graph/tools.ts +9 -5
- package/src/plugins/defaults/memory/hooks/conversation-deleted.ts +4 -0
- package/src/plugins/defaults/memory/hooks/user-prompt-submit.ts +7 -3
- package/src/plugins/defaults/memory/job-handlers.ts +8 -2
- package/src/plugins/defaults/memory/skill-update-receipt-job.ts +334 -0
- package/src/plugins/defaults/memory/tools.test.ts +17 -0
- package/src/plugins/defaults/memory/turn-retrieval.ts +8 -0
- package/src/plugins/defaults/memory/v3/__tests__/injection.test.ts +24 -0
- package/src/plugins/defaults/memory/v3/injector.ts +4 -4
- package/src/plugins/types.ts +2 -0
- package/src/providers/__tests__/search-provider-catalog.test.ts +8 -0
- package/src/providers/anthropic/client.ts +4 -0
- package/src/providers/gemini/client.ts +7 -1
- package/src/providers/inference/auth.ts +25 -0
- package/src/providers/inference/profile-probe.ts +1 -0
- package/src/{calls/__tests__/typesafe-noul.test.ts → providers/jev/ask.test.ts} +4 -4
- package/src/{calls/typesafe-noul.ts → providers/jev/ask.ts} +67 -34
- package/src/providers/openai/__tests__/api-error-normalization.test.ts +12 -0
- package/src/providers/openai/api-error-normalization.ts +4 -0
- package/src/providers/retry.ts +2 -0
- package/src/providers/search-provider-catalog.ts +10 -0
- package/src/providers/types.ts +7 -0
- package/src/providers/usage-tracking.ts +5 -3
- package/src/runtime/__tests__/agent-wake.test.ts +308 -0
- package/src/runtime/access-request-helper.ts +16 -9
- package/src/runtime/agent-wake-queue.ts +52 -0
- package/src/runtime/agent-wake.ts +111 -18
- package/src/runtime/channel-approval-types.ts +6 -38
- package/src/runtime/channel-approvals.ts +4 -5
- package/src/runtime/http-server.ts +4 -1
- package/src/runtime/introduction-policy.test.ts +17 -1
- package/src/runtime/introduction-policy.ts +25 -7
- package/src/runtime/migrations/vbundle-builder.ts +9 -0
- package/src/runtime/routes/__tests__/inference-profiles-routes.test.ts +21 -1
- package/src/runtime/routes/__tests__/inference-provider-connection-routes.test.ts +60 -0
- package/src/runtime/routes/__tests__/oauth-proxy-routes.test.ts +61 -3
- package/src/runtime/routes/auto-profile-routes.ts +83 -0
- package/src/runtime/routes/conversation-management-routes.ts +1 -3
- package/src/runtime/routes/conversation-routes.ts +9 -0
- package/src/runtime/routes/guardian-action-routes.ts +8 -23
- package/src/runtime/routes/host-cu-routes.ts +3 -1
- package/src/runtime/routes/index.ts +2 -0
- package/src/runtime/routes/inference-profiles-routes.ts +5 -2
- package/src/runtime/routes/inference-provider-connection-routes.ts +25 -8
- package/src/runtime/routes/migration-routes.ts +8 -2
- package/src/runtime/routes/oauth-proxy-passthrough.test.ts +32 -0
- package/src/runtime/routes/platform-routes.ts +6 -1
- package/src/runtime/routes/user-route-dispatcher.ts +1 -2
- package/src/runtime/web-presence.ts +3 -4
- package/src/schedule/schedule-store.ts +10 -0
- package/src/schedule/scheduler.ts +92 -24
- package/src/subagent/manager.ts +32 -12
- package/src/telegram/__tests__/webhook-health.test.ts +8 -0
- package/src/telemetry/telemetry-wire-source.json +1 -1
- package/src/telemetry/telemetry-wire.generated.ts +1 -0
- package/src/tools/background-tool-registry.ts +30 -3
- package/src/tools/browser/cdp-client/local-cdp-client.ts +1 -2
- package/src/tools/host-terminal/host-shell.ts +7 -0
- package/src/tools/network/__tests__/web-fetch-firecrawl.test.ts +28 -1
- package/src/tools/network/__tests__/web-fetch-metadata.test.ts +34 -0
- package/src/tools/network/__tests__/web-fetch-tinyfish.test.ts +35 -1
- package/src/tools/network/__tests__/web-search.test.ts +96 -0
- package/src/tools/network/web-fetch.ts +30 -9
- package/src/tools/network/web-search.ts +235 -4
- package/src/tools/skills/load.ts +13 -17
- package/src/tools/skills/scaffold-managed.ts +86 -71
- package/src/tools/terminal/shell-launch.test.ts +27 -1
- package/src/tools/terminal/shell.ts +4 -0
- package/src/tools/workspace-tools/loader.ts +1 -2
- package/src/usage/attribution.ts +18 -1
- package/src/util/abort-reasons.ts +2 -0
- package/src/util/errors.ts +1 -0
- package/src/util/oauth-request-body.test.ts +5 -1
- package/src/util/provider-error-patterns.ts +11 -0
- package/src/util/single-flight.test.ts +6 -0
- package/src/util/single-flight.ts +2 -0
- package/src/util/worker-pipe.test.ts +56 -10
- package/src/util/worker-pipe.ts +9 -4
- package/src/workspace/git-service.ts +6 -1
- package/src/workspace/migrations/158-repoint-opencode-host-provider-fragments.ts +163 -0
- package/src/workspace/migrations/__tests__/158-repoint-opencode-host-provider-fragments.test.ts +188 -0
- package/src/workspace/migrations/registry.ts +2 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-process CPU and memory in the assistant container, sampled by the
|
|
3
|
+
* resource monitor.
|
|
4
|
+
*
|
|
5
|
+
* The cgroup counters show that the container hit its CPU quota or filled
|
|
6
|
+
* its memory, not which process did it. Background work can slow the
|
|
7
|
+
* daemon without blocking its event loop: a worker, Qdrant, or a browser
|
|
8
|
+
* uses the container's shared CPU while the daemon waits for a turn on it.
|
|
9
|
+
* This tracker names the processes using the container's resources, so a
|
|
10
|
+
* slow daemon can be told apart from a starved one.
|
|
11
|
+
*
|
|
12
|
+
* CPU is a rate, so it needs two readings: each scan reads every process's
|
|
13
|
+
* cumulative CPU ticks from `/proc/<pid>/stat` and compares them with the
|
|
14
|
+
* previous scan. Memory is the resident set size from the same file.
|
|
15
|
+
*
|
|
16
|
+
* Names are metadata only: the daemon is "daemon", the assistant's own
|
|
17
|
+
* worker scripts use a fixed label from an allowlist, and any other process
|
|
18
|
+
* uses its kernel `comm` (15 bytes, no arguments). Command-line content never
|
|
19
|
+
* leaves the machine.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
23
|
+
import { join } from "node:path";
|
|
24
|
+
|
|
25
|
+
import {
|
|
26
|
+
CLOCK_TICKS_PER_SECOND,
|
|
27
|
+
parseProcStat,
|
|
28
|
+
readKernelPageSizeBytes,
|
|
29
|
+
} from "./proc-wait-state.js";
|
|
30
|
+
|
|
31
|
+
/** Processes reported by CPU, busiest first. */
|
|
32
|
+
const TOP_BY_CPU = 4;
|
|
33
|
+
/** Further processes reported by resident memory, largest first. */
|
|
34
|
+
const TOP_BY_MEMORY = 2;
|
|
35
|
+
/** Minimum time between scans; a shorter tick reuses the last result. */
|
|
36
|
+
const DEFAULT_MIN_SCAN_INTERVAL_MS = 1_000;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The assistant's own worker scripts, matched on the trailing path of a
|
|
40
|
+
* command-line argument. Only these fixed labels are ever reported; any
|
|
41
|
+
* other process is named by its kernel comm.
|
|
42
|
+
*/
|
|
43
|
+
const KNOWN_WORKERS: ReadonlyArray<{ pattern: RegExp; name: string }> = [
|
|
44
|
+
{
|
|
45
|
+
pattern: /(?:^|\/)src\/schedule\/worker\.[cm]?[jt]s$/,
|
|
46
|
+
name: "schedule-worker",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
pattern: /(?:^|\/)defaults\/memory\/worker\.[cm]?[jt]s$/,
|
|
50
|
+
name: "memory-worker",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
pattern: /(?:^|\/)src\/monitoring\/worker\.[cm]?[jt]s$/,
|
|
54
|
+
name: "monitoring-worker",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
pattern: /(?:^|\/)src\/routes\/worker\.[cm]?[jt]s$/,
|
|
58
|
+
name: "routes-worker",
|
|
59
|
+
},
|
|
60
|
+
{ pattern: /(?:^|\/)embed-worker\.mjs$/, name: "embed-worker" },
|
|
61
|
+
{ pattern: /(?:^|\/)rerank-worker\.mjs$/, name: "rerank-worker" },
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
export interface ProcessUsage {
|
|
65
|
+
pid: number;
|
|
66
|
+
/** "daemon", an assistant worker name, or the kernel comm. */
|
|
67
|
+
name: string;
|
|
68
|
+
/** CPU used since the previous scan, as a percentage of one core. */
|
|
69
|
+
cpuPct: number;
|
|
70
|
+
rssMb: number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface ProcessCounters {
|
|
74
|
+
cpuTicks: number;
|
|
75
|
+
startTicks: number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface ProcessUsageTracker {
|
|
79
|
+
/**
|
|
80
|
+
* Busiest processes since the previous scan, or null before the first
|
|
81
|
+
* two scans complete or when `/proc` is unreadable. `nowMs` must be read
|
|
82
|
+
* at the call, so the time between scans matches the counters' interval.
|
|
83
|
+
*/
|
|
84
|
+
sample(nowMs: number, daemonPid: number | null): ProcessUsage[] | null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function readText(path: string): string | null {
|
|
88
|
+
try {
|
|
89
|
+
return readFileSync(path, "utf-8");
|
|
90
|
+
} catch {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** A telemetry-safe name: never includes command-line arguments. */
|
|
96
|
+
function processName(
|
|
97
|
+
procRoot: string,
|
|
98
|
+
pid: number,
|
|
99
|
+
comm: string,
|
|
100
|
+
daemonPid: number | null,
|
|
101
|
+
): string {
|
|
102
|
+
if (pid === daemonPid) {
|
|
103
|
+
return "daemon";
|
|
104
|
+
}
|
|
105
|
+
const cmdline = readText(join(procRoot, String(pid), "cmdline"));
|
|
106
|
+
for (const arg of cmdline?.split("\0") ?? []) {
|
|
107
|
+
const path = arg.replaceAll("\\", "/");
|
|
108
|
+
const worker = KNOWN_WORKERS.find(({ pattern }) => pattern.test(path));
|
|
109
|
+
if (worker) {
|
|
110
|
+
return worker.name;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return comm;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function createProcessUsageTracker(
|
|
117
|
+
options: {
|
|
118
|
+
procRoot?: string;
|
|
119
|
+
minScanIntervalMs?: number;
|
|
120
|
+
pageSizeBytes?: number;
|
|
121
|
+
} = {},
|
|
122
|
+
): ProcessUsageTracker {
|
|
123
|
+
const procRoot = options.procRoot ?? "/proc";
|
|
124
|
+
const pageSizeBytes =
|
|
125
|
+
options.pageSizeBytes ?? readKernelPageSizeBytes(procRoot);
|
|
126
|
+
const minScanIntervalMs =
|
|
127
|
+
options.minScanIntervalMs ?? DEFAULT_MIN_SCAN_INTERVAL_MS;
|
|
128
|
+
let previous: Map<number, ProcessCounters> | null = null;
|
|
129
|
+
let previousAt = 0;
|
|
130
|
+
let last: ProcessUsage[] | null = null;
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
sample(nowMs: number, daemonPid: number | null): ProcessUsage[] | null {
|
|
134
|
+
if (previous != null && nowMs - previousAt < minScanIntervalMs) {
|
|
135
|
+
return last;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
let pids: number[];
|
|
139
|
+
try {
|
|
140
|
+
pids = readdirSync(procRoot)
|
|
141
|
+
.filter((entry) => /^\d+$/.test(entry))
|
|
142
|
+
.map(Number);
|
|
143
|
+
} catch {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const elapsedSeconds = (nowMs - previousAt) / 1000;
|
|
148
|
+
const current = new Map<number, ProcessCounters>();
|
|
149
|
+
const usage: Array<ProcessUsage & { comm: string }> = [];
|
|
150
|
+
for (const pid of pids) {
|
|
151
|
+
const raw = readText(join(procRoot, String(pid), "stat"));
|
|
152
|
+
const stat = raw != null ? parseProcStat(raw) : null;
|
|
153
|
+
if (stat == null) {
|
|
154
|
+
// Exited between readdir and read.
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
current.set(pid, {
|
|
158
|
+
cpuTicks: stat.cpuTicks,
|
|
159
|
+
startTicks: stat.startTicks,
|
|
160
|
+
});
|
|
161
|
+
const before = previous?.get(pid);
|
|
162
|
+
// A reused pid starts a new process; its old counters do not apply.
|
|
163
|
+
if (before == null || before.startTicks !== stat.startTicks) {
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
const cpuSeconds =
|
|
167
|
+
(stat.cpuTicks - before.cpuTicks) / CLOCK_TICKS_PER_SECOND;
|
|
168
|
+
usage.push({
|
|
169
|
+
pid,
|
|
170
|
+
comm: stat.comm,
|
|
171
|
+
name: "",
|
|
172
|
+
cpuPct:
|
|
173
|
+
elapsedSeconds > 0
|
|
174
|
+
? Math.round((cpuSeconds / elapsedSeconds) * 100)
|
|
175
|
+
: 0,
|
|
176
|
+
rssMb: Math.round((stat.rssPages * pageSizeBytes) / (1024 * 1024)),
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const hadPrevious = previous != null;
|
|
181
|
+
previous = current;
|
|
182
|
+
previousAt = nowMs;
|
|
183
|
+
if (!hadPrevious) {
|
|
184
|
+
last = null;
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// The busiest by CPU, then the largest by memory (an idle process can
|
|
189
|
+
// still fill the cgroup), then the daemon for comparison.
|
|
190
|
+
const byCpu = [...usage].sort(
|
|
191
|
+
(a, b) => b.cpuPct - a.cpuPct || b.rssMb - a.rssMb,
|
|
192
|
+
);
|
|
193
|
+
const reported = byCpu.slice(0, TOP_BY_CPU);
|
|
194
|
+
const byMemory = [...usage].sort((a, b) => b.rssMb - a.rssMb);
|
|
195
|
+
for (const entry of byMemory) {
|
|
196
|
+
if (reported.length >= TOP_BY_CPU + TOP_BY_MEMORY) {
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
if (!reported.includes(entry)) {
|
|
200
|
+
reported.push(entry);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const daemon = usage.find((entry) => entry.pid === daemonPid);
|
|
204
|
+
if (daemon && !reported.includes(daemon)) {
|
|
205
|
+
reported.push(daemon);
|
|
206
|
+
}
|
|
207
|
+
// Names are read only for the reported processes.
|
|
208
|
+
last = reported.map(({ comm, ...entry }) => ({
|
|
209
|
+
...entry,
|
|
210
|
+
name: processName(procRoot, entry.pid, comm, daemonPid),
|
|
211
|
+
}));
|
|
212
|
+
return last;
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
}
|
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
ContainerReclaimCounters,
|
|
12
12
|
} from "../util/cgroup-memory.js";
|
|
13
13
|
import type { ActiveConversation } from "./active-conversations.js";
|
|
14
|
+
import type { ProcessUsage } from "./process-usage.js";
|
|
14
15
|
|
|
15
16
|
export interface ResourceSampleMemory {
|
|
16
17
|
currentBytes: number;
|
|
@@ -68,4 +69,11 @@ export interface ResourceSample {
|
|
|
68
69
|
* Null when nothing is processing or the database is unavailable.
|
|
69
70
|
*/
|
|
70
71
|
activeConversations: ActiveConversation[] | null;
|
|
72
|
+
/**
|
|
73
|
+
* Busiest processes in the container since the previous process scan, so
|
|
74
|
+
* a CPU- or memory-starved daemon names what it was competing with. Null
|
|
75
|
+
* until two scans have run or where `/proc` is unreadable. Absent on
|
|
76
|
+
* samples written before this field existed.
|
|
77
|
+
*/
|
|
78
|
+
processes?: ProcessUsage[] | null;
|
|
71
79
|
}
|
|
@@ -44,9 +44,14 @@ import {
|
|
|
44
44
|
listProcesses,
|
|
45
45
|
} from "../util/process-tree.js";
|
|
46
46
|
import { readActiveConversations } from "./active-conversations.js";
|
|
47
|
+
import { readDaemonHeartbeat } from "./daemon-heartbeat.js";
|
|
47
48
|
import { topProcessesByFd } from "./file-descriptors.js";
|
|
48
49
|
import { getTrackedDataFiles, readFileResidency } from "./page-cache.js";
|
|
49
50
|
import { topProcessesByMemory } from "./process-memory.js";
|
|
51
|
+
import {
|
|
52
|
+
createProcessUsageTracker,
|
|
53
|
+
type ProcessUsageTracker,
|
|
54
|
+
} from "./process-usage.js";
|
|
50
55
|
import { prunePrefixedJsonFiles } from "./prune-snapshots.js";
|
|
51
56
|
import type {
|
|
52
57
|
ResourceSample,
|
|
@@ -94,6 +99,7 @@ export function computeSampleDeltas(
|
|
|
94
99
|
export async function takeSample(
|
|
95
100
|
now: number,
|
|
96
101
|
prev: ResourceSample | null = null,
|
|
102
|
+
processUsage: ProcessUsageTracker | null = null,
|
|
97
103
|
): Promise<ResourceSample> {
|
|
98
104
|
const currentBytes = getContainerMemoryUsageBytes();
|
|
99
105
|
const limitBytes = getContainerMemoryLimitBytes();
|
|
@@ -129,6 +135,11 @@ export async function takeSample(
|
|
|
129
135
|
}
|
|
130
136
|
: null,
|
|
131
137
|
activeConversations: readActiveConversations(),
|
|
138
|
+
// Timestamped at the scan, not the tick start: the disk read above can
|
|
139
|
+
// take seconds, and the CPU rate needs the counters' real interval.
|
|
140
|
+
processes:
|
|
141
|
+
processUsage?.sample(Date.now(), readDaemonHeartbeat(now)?.pid ?? null) ??
|
|
142
|
+
null,
|
|
132
143
|
};
|
|
133
144
|
if (prev != null) {
|
|
134
145
|
sample.deltas = computeSampleDeltas(prev, sample);
|
|
@@ -252,6 +263,7 @@ export function startResourceSampler(
|
|
|
252
263
|
// Watches the daemon's event-loop heartbeat; captures the daemon main
|
|
253
264
|
// thread's kernel state mid-stall when the heartbeat goes stale.
|
|
254
265
|
const stallCapture = createStallCaptureMonitor(dataDir);
|
|
266
|
+
const processUsage = createProcessUsageTracker();
|
|
255
267
|
|
|
256
268
|
// Skip ticks while a sample is in flight: the disk measurement can take
|
|
257
269
|
// seconds (du over the workspace), and overlapping ticks would all delta
|
|
@@ -273,7 +285,7 @@ export function startResourceSampler(
|
|
|
273
285
|
const now = clock();
|
|
274
286
|
let sample: ResourceSample;
|
|
275
287
|
try {
|
|
276
|
-
sample = await takeSample(now, prevSample);
|
|
288
|
+
sample = await takeSample(now, prevSample, processUsage);
|
|
277
289
|
prevSample = sample;
|
|
278
290
|
buffer.append(sample);
|
|
279
291
|
} catch (err) {
|
|
@@ -282,7 +294,10 @@ export function startResourceSampler(
|
|
|
282
294
|
}
|
|
283
295
|
|
|
284
296
|
try {
|
|
285
|
-
|
|
297
|
+
// Judge staleness at capture time, not tick start: sampling can take
|
|
298
|
+
// seconds, and a stall that ended meanwhile must not be captured from
|
|
299
|
+
// the recovered daemon.
|
|
300
|
+
stallCapture.check(sample, clock());
|
|
286
301
|
} catch (err) {
|
|
287
302
|
log.warn({ err }, "Daemon stall check failed");
|
|
288
303
|
}
|
|
@@ -22,6 +22,7 @@ import { join } from "node:path";
|
|
|
22
22
|
import { getLogger } from "../util/logger.js";
|
|
23
23
|
import { getMonitoringDataDir } from "../util/platform.js";
|
|
24
24
|
import { readDaemonHeartbeat } from "./daemon-heartbeat.js";
|
|
25
|
+
import { readStallWaitState, type StallWaitState } from "./proc-wait-state.js";
|
|
25
26
|
import { prunePrefixedJsonFiles } from "./prune-snapshots.js";
|
|
26
27
|
import type { ResourceSample } from "./resource-sample-types.js";
|
|
27
28
|
|
|
@@ -78,6 +79,13 @@ export interface StallCapture {
|
|
|
78
79
|
kernelStack: string | null;
|
|
79
80
|
/** Daemon state from `/proc/<pid>/stat` (R running, S sleeping, D uninterruptible). */
|
|
80
81
|
processState: string | null;
|
|
82
|
+
/**
|
|
83
|
+
* What the daemon was waiting on: the main thread's syscall and epoll set,
|
|
84
|
+
* its children, and its threads' wait channels. Tells a stalled event loop
|
|
85
|
+
* apart from a nested synchronous wait. Absent on captures written before
|
|
86
|
+
* this field existed.
|
|
87
|
+
*/
|
|
88
|
+
waitState?: StallWaitState;
|
|
81
89
|
/** The resource sample taken this tick — its deltas classify the stall. */
|
|
82
90
|
sample: ResourceSample;
|
|
83
91
|
}
|
|
@@ -119,6 +127,7 @@ export function createStallCaptureMonitor(
|
|
|
119
127
|
`/proc/${heartbeat.pid}/task/${heartbeat.pid}/stack`,
|
|
120
128
|
),
|
|
121
129
|
processState: statRaw != null ? parseProcStatState(statRaw) : null,
|
|
130
|
+
waitState: readStallWaitState(heartbeat.pid),
|
|
122
131
|
sample,
|
|
123
132
|
};
|
|
124
133
|
|
|
@@ -140,6 +149,9 @@ export function createStallCaptureMonitor(
|
|
|
140
149
|
daemonPid: heartbeat.pid,
|
|
141
150
|
heartbeatAgeMs: heartbeat.ageMs,
|
|
142
151
|
processState: capture.processState,
|
|
152
|
+
syscall: capture.waitState?.syscall,
|
|
153
|
+
epollListeningSockets: capture.waitState?.epoll?.listeningSockets,
|
|
154
|
+
childCount: capture.waitState?.children.length,
|
|
143
155
|
pgscanDirectDelta: sample.deltas?.reclaim?.pgscanDirect,
|
|
144
156
|
throttledUsecDelta: sample.deltas?.cpu?.throttledUsec,
|
|
145
157
|
},
|
|
@@ -2,6 +2,77 @@
|
|
|
2
2
|
|
|
3
3
|
Signal-driven notification architecture where producers emit free-form events and an LLM-backed decision engine determines whether, where, and how to notify the user.
|
|
4
4
|
|
|
5
|
+
## Completion alerts
|
|
6
|
+
|
|
7
|
+
`chat.assistant_reply`, `schedule.result`, and explicitly user-facing
|
|
8
|
+
`activity.complete` signals use the available subset of `vellum` and
|
|
9
|
+
`platform`. A self-hosted assistant can deliver through `vellum` without
|
|
10
|
+
mobile push. `completion-policy.ts` owns local presentation: selected
|
|
11
|
+
completions can banner at medium urgency, unrelated low/medium notifications
|
|
12
|
+
remain silent, and explicitly quiet work stays silent. The broadcaster resolves
|
|
13
|
+
the existing `silent` contract once for the local intent and paired-conversation
|
|
14
|
+
event; clients continue honoring it.
|
|
15
|
+
|
|
16
|
+
Local completion delivery requires the active Vellum guardian principal from
|
|
17
|
+
the resolved destination. The broadcaster checks that identity before pairing,
|
|
18
|
+
and the adapter targets the event hub's `targetActorPrincipalId` before sending
|
|
19
|
+
title or body. Missing identity, or a background completion naming a different
|
|
20
|
+
recipient, fails closed without an unrestricted broadcast. The
|
|
21
|
+
`targetGuardianPrincipalId` payload marker is reserved for guardian-sensitive
|
|
22
|
+
cards, whose legacy client gate rejects unknown and local assistant versions.
|
|
23
|
+
Completion intents use the authenticated event-hub scope without that marker,
|
|
24
|
+
so self-hosted assistants can deliver alerts before version hydration.
|
|
25
|
+
|
|
26
|
+
Background completions opt in with typed `contextPayload.completion` provenance:
|
|
27
|
+
the stable work ID, result conversation ID, recipient principal ID, and owning
|
|
28
|
+
path (`parent_continuation`). Ordinary maintenance events
|
|
29
|
+
without that context retain their existing policy. Declared ownership must
|
|
30
|
+
validate before pairing or delivery. Owned completions can only reach `vellum`
|
|
31
|
+
and `platform` with a matching recipient; channel allowlists and model routing
|
|
32
|
+
cannot widen that scope. Producers persist the
|
|
33
|
+
user-facing result before emitting. Reply previews and these explicit background
|
|
34
|
+
previews link to that result without appending another transcript row.
|
|
35
|
+
Recipient-owned `activity.complete` signals do not mirror into the Home feed or
|
|
36
|
+
notification bell, regardless of whether scoped delivery succeeds. The feed is
|
|
37
|
+
assistant-wide and has no per-recipient read policy, so confirming the active
|
|
38
|
+
guardian alone does not make a shared preview private. A declared but malformed
|
|
39
|
+
completion ownership payload is excluded too. Ordinary activity notifications
|
|
40
|
+
and skill-update receipts retain their existing feed behavior.
|
|
41
|
+
|
|
42
|
+
`background-result-producer.ts` owns successful subagent parent continuations
|
|
43
|
+
and background-tool completion wakes in user conversations. It waits for
|
|
44
|
+
user-facing work and queued continuations to settle, preserves scheduled-run
|
|
45
|
+
ownership, and reads the same public-result projection as scheduled delivery.
|
|
46
|
+
An external-origin continuation remains eligible: its inherited channel metadata
|
|
47
|
+
does not acknowledge a channel delivery. Recorded result notifications and
|
|
48
|
+
successful messaging-tool deliveries suppress the completion fallback.
|
|
49
|
+
When a sibling fails or is cancelled, settlement can recover an earlier unseen
|
|
50
|
+
successful result from persisted conversation rows in pages of 200. Recovery stops
|
|
51
|
+
at a user prompt and preserves prior delivery and quiet decisions. It uses
|
|
52
|
+
insertion order, so same-millisecond messages stay in their actual turns.
|
|
53
|
+
Coalesced completion messages share their final member's successful synthesis;
|
|
54
|
+
`turnBatchedInto` links that result to a successful member even when the final
|
|
55
|
+
sibling failed, was cancelled, or is another internal or automated trigger.
|
|
56
|
+
Only a validated completed task or command owns the shared result. A failed
|
|
57
|
+
synthesis remains ineligible.
|
|
58
|
+
Failed-only work cannot create a completion candidate. Command wakes check
|
|
59
|
+
settlement after releasing their wake queue entry, including empty or failed
|
|
60
|
+
continuations; pending cancellation callbacks still count as unfinished work.
|
|
61
|
+
Approval prompts do not count as prior result delivery. Internal jobs and
|
|
62
|
+
workflow-manager wakes retain their existing behavior; workflow wakes need
|
|
63
|
+
explicit run and quiet-mode provenance before they can use this producer.
|
|
64
|
+
|
|
65
|
+
The recipient is the assistant's active Vellum guardian, as for ordinary
|
|
66
|
+
replies. Completion signals retain the pipeline's permanent deduplication
|
|
67
|
+
claims and existing best-effort delivery semantics. There is no new retry
|
|
68
|
+
queue for a signal whose transports all fail.
|
|
69
|
+
|
|
70
|
+
The local send waits for the bounded platform outcome and carries its accepted
|
|
71
|
+
mobile platforms, preserving remote/local mobile deduplication. A successful
|
|
72
|
+
local adapter send means the scoped intent was handed to the event hub; it is
|
|
73
|
+
not proof that an OS banner appeared. Client delivery acknowledgements retain
|
|
74
|
+
their existing handled/suppressed semantics.
|
|
75
|
+
|
|
5
76
|
## Lifecycle
|
|
6
77
|
|
|
7
78
|
```
|
|
@@ -13,7 +84,7 @@ Producer → NotificationSignal → Source-Active Gate → Candidate Generation
|
|
|
13
84
|
|
|
14
85
|
### 1. Signal
|
|
15
86
|
|
|
16
|
-
A producer calls `emitNotificationSignal()` with a free-form event name, attention hints (urgency, requiresAction, deadlineAt), and a context payload. The signal is persisted as a `notification_events` row.
|
|
87
|
+
A producer calls `emitNotificationSignal()` with a free-form event name, attention hints (urgency, requiresAction, deadlineAt), and a context payload. The signal is persisted as a `notification_events` row. A `dedupeKey` the producer passes is claimed by that row on insert, with no time window: a later signal carrying a key an existing row holds gets no row of its own and returns `deduplicated: true` before anything below runs. See [Choosing `dedupeKey`](#choosing-dedupekey).
|
|
17
88
|
|
|
18
89
|
Immediately after persistence, a **source-active pre-gate** runs (`checkSourceActiveSuppression`): when `visibleInSourceNow` is set, a hard signal-only invariant the decision engine cannot override, the signal is suppressed and short-circuits here, before candidate generation and the LLM decision. This keeps an always-suppressed signal (e.g. trusted-contact `verification_sent`) from spending an LLM inference whose result would be discarded. The `notification_events` row is still written for the audit trail.
|
|
19
90
|
|
|
@@ -65,7 +136,7 @@ Hard invariants that the LLM cannot override:
|
|
|
65
136
|
|
|
66
137
|
- **Schema validity** -- fail-closed if the decision is malformed
|
|
67
138
|
- **Channel availability** -- at least one selected channel must be connected
|
|
68
|
-
- **Deduplication** --
|
|
139
|
+
- **Deduplication** -- the decision's `dedupeKey` matches another event row younger than the dedupe window (1 hour default). This is the engine's own key; the producer's key was already checked at event insert in step 1, with no window.
|
|
69
140
|
- **Rendered copy quality** -- fail-closed on empty copy or a fallback leak (body equal to the raw event name)
|
|
70
141
|
|
|
71
142
|
Source-active suppression depends only on the signal, so it runs earlier — as the pre-decision gate in `emit-signal.ts` (see step 1), not as a pre-send check here.
|
|
@@ -222,11 +293,11 @@ Schedules (both recurring and one-shot) carry optional routing metadata that con
|
|
|
222
293
|
|
|
223
294
|
The `routing_intent` field on each `schedule_jobs` row specifies the desired channel coverage:
|
|
224
295
|
|
|
225
|
-
| Intent | Behavior | When to use
|
|
226
|
-
| ---------------- | ----------------------------------------------------- |
|
|
227
|
-
| `single_channel` |
|
|
228
|
-
| `multi_channel` | Ensures delivery on 2+ channels when 2+ are connected | Important schedules the user wants on both desktop and phone
|
|
229
|
-
| `all_channels` | Forces delivery on every connected channel | Critical schedules that must reach the user everywhere
|
|
296
|
+
| Intent | Behavior | When to use |
|
|
297
|
+
| ---------------- | ----------------------------------------------------- | ------------------------------------------------------------ |
|
|
298
|
+
| `single_channel` | Delivers on exactly one channel | Schedules that should reach the user in one place |
|
|
299
|
+
| `multi_channel` | Ensures delivery on 2+ channels when 2+ are connected | Important schedules the user wants on both desktop and phone |
|
|
300
|
+
| `all_channels` | Forces delivery on every connected channel | Critical schedules that must reach the user everywhere |
|
|
230
301
|
|
|
231
302
|
The default is `all_channels`. Routing intent is persisted in the `schedule_jobs` table (`routing_intent` column) and carried through the notification signal as `routingIntent`.
|
|
232
303
|
|
|
@@ -254,7 +325,7 @@ The `enforceRoutingIntent()` function in `decision-engine.ts` runs after the LLM
|
|
|
254
325
|
|
|
255
326
|
- **`all_channels`**: Replaces `selectedChannels` with all connected channels (from `getConnectedChannels()`).
|
|
256
327
|
- **`multi_channel`**: If the LLM selected fewer than 2 channels but 2+ are connected, expands `selectedChannels` to at least two connected channels.
|
|
257
|
-
- **`single_channel`**:
|
|
328
|
+
- **`single_channel`**: Caps delivery to one channel: the signal's source channel when it is connected, otherwise the first channel the LLM selected. A signal with no routing intent keeps the LLM's selection.
|
|
258
329
|
|
|
259
330
|
When enforcement changes the decision, the updated channel selection is re-persisted to the `notification_decisions` table so the stored decision matches what was actually dispatched. The `reasoningSummary` is annotated with the enforcement action (e.g. `[routing_intent=all_channels enforced: vellum, telegram]`).
|
|
260
331
|
|
|
@@ -470,7 +541,15 @@ Step 1 suppresses on this hint before anything else runs, and nothing downstream
|
|
|
470
541
|
- **Opt in only when the notification duplicates something that conversation has already rendered, and only behind a flag that names your producer.** `resolveVisibleInSourceNow()` reads `activity-presence-suppression`, which gates the background-activity failure producer alone, so a new producer needs its own flag or an extension of that one before it calls the resolver. Otherwise the flag silently governs a producer its description does not cover. Having a conversation id in scope is not sufficient; the producer must know that _this_ arrival put the announced thing on screen there. `runtime/background-job-runner.ts` is the worked example: one catch block is reached from several directions, and it passes `presenceConversationId` only when the failure carries a `turnFailure`, the one arrival whose conversation is guaranteed to have emitted a `conversation_error` the user can read. A runner timeout leaves the turn still rendering as in progress and a bootstrap throw never reaches the agent loop, so both keep notifying.
|
|
471
542
|
- **Pass a literal `false` for global and infra signals.** Heartbeat, credential health, webhook health, and worker liveness have no source surface to watch, so there is nothing to duplicate.
|
|
472
543
|
- **Never opt in a `guardian.question` producer.** The card _is_ the prompt, so a `true` suppresses the question's only rendering and the tool hangs until the prompt timeout. `runtime/question-request-guardian-bridge.ts` carries the rationale at its hint block, and three regression pins hold the line: `runtime/__tests__/question-request-guardian-bridge.test.ts`, `__tests__/confirmation-request-guardian-bridge.test.ts`, and `__tests__/notification-guardian-path.test.ts`.
|
|
473
|
-
- **A producer running
|
|
544
|
+
- **A producer running outside the main assistant process cannot read presence at all.** The schedule worker (`schedule/worker.ts`) and the memory jobs worker (`plugins/defaults/memory/worker.ts`) are standalone OS processes, while the resolver reads `assistantEventHub` through `isWebConversationFocused()` and that hub's SSE clients exist only in the assistant process. Every presence read from a worker resolves `false`, whatever the user is watching. The trap is in testing: a test that drives the producer and mocks presence in one process passes while the shipped worker suppresses nothing. Tracked as JARVIS-1711. The boundary runs the other way too: a hub publish from a worker is forwarded to the assistant process best-effort (`runtime/assistant-event-hub.ts`, logged rather than thrown on failure). A worker-side producer is therefore guaranteed its event row and nothing past it: the home-feed write is best-effort in every process (`writeHomeFeedItemForSignal` returns `null` for an ineligible signal, a missing summary, or a failed write, and `emit-signal.ts` only logs a rejection), and the live push to open clients depends on the forward as well.
|
|
545
|
+
|
|
546
|
+
### Choosing `dedupeKey`
|
|
547
|
+
|
|
548
|
+
There are two keys and they do different jobs. Choose the producer's by what it names, not by how often it fires.
|
|
549
|
+
|
|
550
|
+
- **The producer's key is a permanent claim, not a rate limit.** `createEvent` refuses a second row for a key any row already holds (`events-store.ts`), however old that row is. Key on a durable identity (a job row, a request id) to attempt a thing at most once ever; key on that identity plus a time bucket to attempt it at most once per bucket. A key with no identity in it silences every later instance for the whole bucket, whether or not it was the same thing. At most once, not exactly once: the claim lands at insert, before the decision and dispatch, so a process that dies between the two leaves the key claimed with nothing announced, and the retry short-circuits `deduplicated: true` and reports success. A producer that must not lose an announcement across a mid-pipeline shutdown (routine during an app update) needs its own record of delivery, not the key.
|
|
551
|
+
- **A failed pipeline releases the claim; a retry re-emits.** When the pipeline fails after the row landed and no channel ran (`hasChannelSideEffect` is false), `emit-signal.ts` writes the key back to `null`, so the same producer can retry the same key. When any channel already ran, the claim stays: releasing it would double-send to those channels. This is what makes a crash retry idempotent against a double send for a producer keyed on a durable row id: `plugins/defaults/memory/skill-update-receipt-job.ts` keys on its job row, so a retry past the event row meets the claim, is reported `deduplicated: true, pipelineFailed: false`, and completes.
|
|
552
|
+
- **The decision's key is windowed.** The engine picks its own key per decision; step 4 checks it against event rows inside the 1-hour window and writes it onto the row only when the producer passed none. A producer never passes the engine's key and never appeals its verdict.
|
|
474
553
|
|
|
475
554
|
## Audit Trail
|
|
476
555
|
|