mixdog 0.9.152 → 0.9.154
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/LICENSES/browser-import-NOTICE.txt +11 -0
- package/NOTICE.md +11 -0
- package/README.md +8 -10
- package/package.json +19 -3
- package/scripts/computer-task-cost-report.mjs +144 -0
- package/scripts/run-office-live-tests.mjs +32 -0
- package/src/agents/front-worker/AGENT.md +13 -0
- package/src/agents/front-worker/agent.json +6 -0
- package/src/agents/heavy-worker/AGENT.md +10 -11
- package/src/agents/heavy-worker/agent.json +1 -1
- package/src/agents/maintainer/AGENT.md +0 -2
- package/src/agents/reviewer/AGENT.md +9 -13
- package/src/agents/reviewer/agent.json +1 -1
- package/src/agents/security/AGENT.md +14 -0
- package/src/agents/security/agent.json +6 -0
- package/src/agents/worker/AGENT.md +8 -8
- package/src/agents/worker/agent.json +1 -1
- package/src/agents/writer/AGENT.md +14 -0
- package/src/agents/writer/agent.json +6 -0
- package/src/rules/agent/00-common.md +4 -7
- package/src/rules/lead/01-general.md +0 -3
- package/src/rules/shared/10-tool-workflow.md +10 -2
- package/src/rules/shared/60-verification.md +2 -0
- package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs +183 -26
- package/src/runtime/agent/orchestrator/agent-runtime/session-builder.mjs +4 -0
- package/src/runtime/agent/orchestrator/cache-break-trace.mjs +109 -0
- package/src/runtime/agent/orchestrator/config.mjs +7 -2
- package/src/runtime/agent/orchestrator/providers/admission-scheduler.mjs +16 -3
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +9 -1
- package/src/runtime/agent/orchestrator/providers/media-normalization.mjs +30 -9
- package/src/runtime/agent/orchestrator/providers/openai-codex-metadata.mjs +18 -26
- package/src/runtime/agent/orchestrator/providers/openai-oauth-http-sse.mjs +25 -2
- package/src/runtime/agent/orchestrator/providers/openai-oauth-ws.mjs +103 -10
- package/src/runtime/agent/orchestrator/providers/openai-turn-state.mjs +68 -0
- package/src/runtime/agent/orchestrator/providers/openai-ws-delta.mjs +36 -11
- package/src/runtime/agent/orchestrator/providers/openai-ws-pool.mjs +140 -86
- package/src/runtime/agent/orchestrator/providers/openai-ws-stream.mjs +9 -13
- package/src/runtime/agent/orchestrator/session/agent-loop.mjs +72 -4
- package/src/runtime/agent/orchestrator/session/browser-snapshot-supersession.mjs +61 -0
- package/src/runtime/agent/orchestrator/session/compact/handoff.mjs +0 -22
- package/src/runtime/agent/orchestrator/session/compact/messages.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/compact/runner.mjs +11 -23
- package/src/runtime/agent/orchestrator/session/compact/summary.mjs +28 -269
- package/src/runtime/agent/orchestrator/session/compact.mjs +0 -6
- package/src/runtime/agent/orchestrator/session/context-utils.mjs +86 -11
- package/src/runtime/agent/orchestrator/session/eager-dispatch.mjs +17 -1
- package/src/runtime/agent/orchestrator/session/image-strip-recovery.mjs +12 -8
- package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +110 -2
- package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +3 -16
- package/src/runtime/agent/orchestrator/session/loop/recall-fasttrack.mjs +80 -18
- package/src/runtime/agent/orchestrator/session/loop/steering.mjs +6 -0
- package/src/runtime/agent/orchestrator/session/loop/tool-exec.mjs +3 -0
- package/src/runtime/agent/orchestrator/session/loop/tool-helpers.mjs +6 -0
- package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +80 -21
- package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +33 -72
- package/src/runtime/agent/orchestrator/session/manager/session-crud.mjs +21 -2
- package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +25 -51
- package/src/runtime/agent/orchestrator/session/manager/status-telemetry.mjs +3 -0
- package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +4 -110
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-journal.mjs +39 -15
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint.mjs +14 -4
- package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +41 -8
- package/src/runtime/agent/orchestrator/session/provider-prefix-guard.mjs +129 -12
- package/src/runtime/agent/orchestrator/session/send-with-recovery.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/store/listing.mjs +8 -1
- package/src/runtime/agent/orchestrator/session/store/save-worker.mjs +15 -1
- package/src/runtime/agent/orchestrator/session/store-summary-index.mjs +36 -2
- package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +157 -30
- package/src/runtime/agent/orchestrator/session/store-summary-visibility.mjs +57 -0
- package/src/runtime/agent/orchestrator/session/store.mjs +3 -1
- package/src/runtime/agent/orchestrator/session/tool-batch.mjs +22 -0
- package/src/runtime/agent/orchestrator/tools/builtin/read-special-files.mjs +6 -6
- package/src/runtime/agent/orchestrator/tools/progress-message.mjs +4 -0
- package/src/runtime/attachments/pdf-extract.mjs +3 -0
- package/src/runtime/attachments/pdfjs-runtime.mjs +13 -0
- package/src/runtime/browser-bridge/action-schema.mjs +251 -0
- package/src/runtime/browser-bridge/client.mjs +75 -26
- package/src/runtime/browser-bridge/tool-defs.mjs +132 -15
- package/src/runtime/computer-bridge/action-schema.mjs +653 -0
- package/src/runtime/computer-bridge/client.mjs +211 -28
- package/src/runtime/computer-bridge/tool-defs.mjs +25 -45
- package/src/runtime/office/assurance-benchmark.mjs +358 -0
- package/src/runtime/office/assurance.mjs +833 -0
- package/src/runtime/office/benchmark.mjs +496 -0
- package/src/runtime/office/capabilities.mjs +551 -0
- package/src/runtime/office/com-adapter.mjs +283 -0
- package/src/runtime/office/content-model.mjs +183 -0
- package/src/runtime/office/contract-benchmark.mjs +105 -0
- package/src/runtime/office/design-library.mjs +1562 -0
- package/src/runtime/office/design-system.mjs +1966 -0
- package/src/runtime/office/index.mjs +2413 -0
- package/src/runtime/office/journal.mjs +82 -0
- package/src/runtime/office/office-com-host.ps1 +3781 -0
- package/src/runtime/office/office-com-session-host.ps1 +855 -0
- package/src/runtime/office/ooxml-validator.mjs +271 -0
- package/src/runtime/office/pagination.mjs +132 -0
- package/src/runtime/office/pdf-adapter.mjs +591 -0
- package/src/runtime/office/pdf-analysis.mjs +372 -0
- package/src/runtime/office/pdf-render.mjs +167 -0
- package/src/runtime/office/pdf-security.mjs +63 -0
- package/src/runtime/office/polish-benchmark.mjs +190 -0
- package/src/runtime/office/portable-ooxml.mjs +1867 -0
- package/src/runtime/office/quality-live-benchmark.mjs +486 -0
- package/src/runtime/office/quality-pipeline.mjs +136 -0
- package/src/runtime/office/tabular.mjs +302 -0
- package/src/runtime/office/templates/mixdog-executive.pptx +0 -0
- package/src/runtime/office/templates/mixdog-executive.pptx.mixdog.json +190 -0
- package/src/runtime/office/tool-defs.mjs +113 -0
- package/src/runtime/office/visual-diff.mjs +89 -0
- package/src/runtime/office/xlsx-assertions.mjs +172 -0
- package/src/runtime/office/xlsx-contract.mjs +147 -0
- package/src/runtime/shared/agent-route-config.mjs +9 -0
- package/src/runtime/shared/tool-execution-contract.mjs +16 -0
- package/src/runtime/shared/tool-surface.mjs +9 -0
- package/src/session-runtime/context-status.mjs +9 -3
- package/src/session-runtime/deferred-tool-delta.mjs +104 -0
- package/src/session-runtime/goal-runtime.mjs +617 -197
- package/src/session-runtime/lifecycle-api.mjs +50 -8
- package/src/session-runtime/provider-request-snapshot.mjs +33 -9
- package/src/session-runtime/resource-api.mjs +31 -94
- package/src/session-runtime/runtime-core.mjs +78 -26
- package/src/session-runtime/session-lifecycle.mjs +34 -12
- package/src/session-runtime/session-title.mjs +2 -2
- package/src/session-runtime/session-turn-api.mjs +15 -14
- package/src/session-runtime/tool-catalog-data.mjs +1 -1
- package/src/session-runtime/tool-catalog.mjs +38 -99
- package/src/session-runtime/tool-defs.mjs +6 -1
- package/src/session-runtime/tool-surface.mjs +18 -8
- package/src/session-runtime/workflow-agents-api.mjs +8 -25
- package/src/session-runtime/workflow.mjs +8 -6
- package/src/standalone/agent-tool/helpers.mjs +2 -2
- package/src/standalone/agent-tool/job-views.mjs +3 -1
- package/src/standalone/agent-tool/notify.mjs +5 -1
- package/src/standalone/agent-tool/render.mjs +3 -0
- package/src/standalone/agent-tool/spawn-flow.mjs +61 -16
- package/src/standalone/agent-tool/tool-def.mjs +1 -1
- package/src/standalone/agent-tool/worker-index.mjs +123 -0
- package/src/standalone/agent-tool/worker-rows.mjs +2 -1
- package/src/standalone/agent-tool.mjs +57 -10
- package/src/standalone/daemon.mjs +105 -6
- package/src/standalone/session-runtime-host.mjs +61 -48
- package/src/standalone/session-runtime-inline-host.mjs +34 -127
- package/src/standalone/session-runtime-worker.mjs +20 -198
- package/src/standalone/session-service.mjs +632 -7
- package/src/tui/dist/index.mjs +24 -1
- package/src/tui/lib/voice-setup.mjs +4 -1
- package/src/tui/session/context-state.mjs +2 -13
- package/src/tui/session/goal-continuation.mjs +38 -7
- package/src/tui/session/session-api-ext.mjs +9 -0
- package/src/tui/session/session-api.mjs +15 -1
- package/src/tui/session/session-flow.mjs +25 -1
- package/src/tui/session/turn.mjs +88 -16
- package/src/tui/session-local.mjs +25 -3
- package/src/vendor/statusline/src/gateway/route-meta.mjs +31 -0
- package/scripts/generate-voice-runtime-manifest.test.mjs +0 -135
- package/scripts/native-binary-arch.test.mjs +0 -111
- package/scripts/patch-replay.test.mjs +0 -94
- package/src/headless-exec.test.mjs +0 -539
- package/src/runtime/agent/orchestrator/agent-trace-timing.test.mjs +0 -57
- package/src/runtime/agent/orchestrator/context/collect-skills.test.mjs +0 -153
- package/src/runtime/agent/orchestrator/mcp/cancellation.test.mjs +0 -139
- package/src/runtime/agent/orchestrator/mcp/features.test.mjs +0 -66
- package/src/runtime/agent/orchestrator/mcp/security.test.mjs +0 -80
- package/src/runtime/agent/orchestrator/providers/anthropic-fast-mode.test.mjs +0 -90
- package/src/runtime/agent/orchestrator/providers/anthropic-server-fallback.test.mjs +0 -215
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth.test.mjs +0 -165
- package/src/runtime/agent/orchestrator/providers/media-parity.test.mjs +0 -142
- package/src/runtime/agent/orchestrator/providers/openai-codex-identity.test.mjs +0 -153
- package/src/runtime/agent/orchestrator/providers/openai-codex-model.test.mjs +0 -24
- package/src/runtime/agent/orchestrator/providers/openai-ws-delta-parity.test.mjs +0 -190
- package/src/runtime/agent/orchestrator/providers/provider-replay.test.mjs +0 -235
- package/src/runtime/agent/orchestrator/providers/sse-framing.test.mjs +0 -719
- package/src/runtime/agent/orchestrator/session/cache/prefetch-cache.test.mjs +0 -40
- package/src/runtime/agent/orchestrator/session/compact-policy.test.mjs +0 -176
- package/src/runtime/agent/orchestrator/session/compaction-read-reset.test.mjs +0 -161
- package/src/runtime/agent/orchestrator/session/eager-dispatch.test.mjs +0 -115
- package/src/runtime/agent/orchestrator/session/evidence-union.test.mjs +0 -228
- package/src/runtime/agent/orchestrator/session/image-strip-recovery.test.mjs +0 -245
- package/src/runtime/agent/orchestrator/session/lossless-tool-output.test.mjs +0 -125
- package/src/runtime/agent/orchestrator/session/manager/pending-messages-persistence.test.mjs +0 -325
- package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.test.mjs +0 -70
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-journal.test.mjs +0 -457
- package/src/runtime/agent/orchestrator/session/provider-prefix-guard.test.mjs +0 -117
- package/src/runtime/agent/orchestrator/session/reduction-metrics.test.mjs +0 -87
- package/src/runtime/agent/orchestrator/session/store/serialize.test.mjs +0 -60
- package/src/runtime/agent/orchestrator/session/store-summary-reader.test.mjs +0 -583
- package/src/runtime/agent/orchestrator/session/task-wait-control.test.mjs +0 -78
- package/src/runtime/agent/orchestrator/tools/builtin/absence-absorption.test.mjs +0 -43
- package/src/runtime/agent/orchestrator/tools/builtin/absolute-glob-expand.test.mjs +0 -63
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool-cwd-env.test.mjs +0 -14
- package/src/runtime/agent/orchestrator/tools/builtin/edit-encoding-eol.test.mjs +0 -224
- package/src/runtime/agent/orchestrator/tools/builtin/edit-sequential-occupation.test.mjs +0 -224
- package/src/runtime/agent/orchestrator/tools/builtin/enoent-outside-project.test.mjs +0 -56
- package/src/runtime/agent/orchestrator/tools/builtin/find-search-budget.test.mjs +0 -103
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-policy.test.mjs +0 -30
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.test.mjs +0 -390
- package/src/runtime/agent/orchestrator/tools/builtin/git-repo-rw-lock.test.mjs +0 -83
- package/src/runtime/agent/orchestrator/tools/builtin/grep-output-budget.test.mjs +0 -31
- package/src/runtime/agent/orchestrator/tools/builtin/grep-single-file-rescue.test.mjs +0 -106
- package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-job-records.test.mjs +0 -102
- package/src/runtime/agent/orchestrator/tools/builtin/list-tool-integrity.test.mjs +0 -152
- package/src/runtime/agent/orchestrator/tools/builtin/native-search-health.test.mjs +0 -24
- package/src/runtime/agent/orchestrator/tools/builtin/native-search-transport.test.mjs +0 -24
- package/src/runtime/agent/orchestrator/tools/builtin/noise-dir-visibility.test.mjs +0 -69
- package/src/runtime/agent/orchestrator/tools/builtin/read-glob-survey.test.mjs +0 -71
- package/src/runtime/agent/orchestrator/tools/builtin/runtime-capabilities.test.mjs +0 -56
- package/src/runtime/agent/orchestrator/tools/builtin/search-builders.test.mjs +0 -16
- package/src/runtime/agent/orchestrator/tools/builtin/search-glob-top-k.test.mjs +0 -39
- package/src/runtime/agent/orchestrator/tools/builtin/write-symlink.test.mjs +0 -153
- package/src/runtime/agent/orchestrator/tools/code-graph/aggregate-anchor-relocation.test.mjs +0 -55
- package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.test.mjs +0 -88
- package/src/runtime/agent/orchestrator/tools/code-graph/loose-file-target.test.mjs +0 -72
- package/src/runtime/agent/orchestrator/tools/code-graph/memory-cache.test.mjs +0 -54
- package/src/runtime/agent/orchestrator/tools/code-graph/search-references.test.mjs +0 -20
- package/src/runtime/agent/orchestrator/tools/code-graph/symbol-search-scope.test.mjs +0 -55
- package/src/runtime/agent/orchestrator/tools/code-graph/text-span-mask.test.mjs +0 -268
- package/src/runtime/agent/orchestrator/tools/env-scrub.test.mjs +0 -57
- package/src/runtime/agent/orchestrator/tools/graph-binary-fetcher.test.mjs +0 -19
- package/src/runtime/agent/orchestrator/tools/lib/native-spawn-client.test.mjs +0 -104
- package/src/runtime/agent/orchestrator/tools/patch/engine-contract-gate.test.mjs +0 -661
- package/src/runtime/agent/orchestrator/tools/patch/patch-codec-eol.test.mjs +0 -552
- package/src/runtime/agent/orchestrator/tools/patch/patch-symlink.test.mjs +0 -141
- package/src/runtime/agent/orchestrator/tools/patch/v4a-pure-move.test.mjs +0 -57
- package/src/runtime/agent/orchestrator/tools/patch/v4a-section-coalesce.test.mjs +0 -81
- package/src/runtime/agent/orchestrator/tools/spawn-binary-fetcher.test.mjs +0 -52
- package/src/runtime/attachments/store.test.mjs +0 -209
- package/src/runtime/channels/lib/voice-runtime-fetcher.test.mjs +0 -17
- package/src/runtime/channels/lib/webhook/deliveries.test.mjs +0 -18
- package/src/runtime/channels/lib/webhook/relay-tunnel.test.mjs +0 -68
- package/src/runtime/media/adapters/codex-image.test.mjs +0 -22
- package/src/runtime/media/download.test.mjs +0 -52
- package/src/runtime/media/renditions.test.mjs +0 -99
- package/src/runtime/media/store.test.mjs +0 -159
- package/src/runtime/memory/lib/archive-security.test.mjs +0 -128
- package/src/runtime/memory/lib/embedding-model-config.test.mjs +0 -33
- package/src/runtime/memory/lib/http-wire.test.mjs +0 -15
- package/src/runtime/memory/lib/memory-cycle-packets.test.mjs +0 -49
- package/src/runtime/memory/lib/memory-cycle2-shared.test.mjs +0 -78
- package/src/runtime/memory/lib/memory-embedding-migration.test.mjs +0 -50
- package/src/runtime/memory/lib/pg/process.test.mjs +0 -36
- package/src/runtime/memory/lib/trace-store.test.mjs +0 -57
- package/src/runtime/memory/lib/transcript-ingest.test.mjs +0 -52
- package/src/runtime/shared/background-tasks.test.mjs +0 -78
- package/src/runtime/shared/bounded-download.test.mjs +0 -41
- package/src/runtime/shared/channel-notification-routing.test.mjs +0 -25
- package/src/runtime/shared/child-spawn-remote.test.mjs +0 -124
- package/src/runtime/shared/remote-intent.test.mjs +0 -40
- package/src/runtime/shared/resource-admission.test.mjs +0 -43
- package/src/runtime/shared/runtime-root.test.mjs +0 -34
- package/src/runtime/shared/schedule-time.test.mjs +0 -29
- package/src/runtime/shared/session-runtime-health.test.mjs +0 -83
- package/src/runtime/shared/skill-document.test.mjs +0 -81
- package/src/runtime/shared/tool-surface.test.mjs +0 -87
- package/src/runtime/shared/update-checker.test.mjs +0 -33
- package/src/runtime/shared/user-cwd.test.mjs +0 -43
- package/src/runtime/shared/webhook-session-run.test.mjs +0 -14
- package/src/session-runtime/agent-disable.test.mjs +0 -123
- package/src/session-runtime/cwd-plugins.test.mjs +0 -75
- package/src/session-runtime/cwd-tool-routing.test.mjs +0 -61
- package/src/session-runtime/global-extensions.test.mjs +0 -28
- package/src/session-runtime/goal-runtime.test.mjs +0 -108
- package/src/session-runtime/lifecycle-api.test.mjs +0 -21
- package/src/session-runtime/model-settings-persist.test.mjs +0 -105
- package/src/session-runtime/notification-bus.test.mjs +0 -148
- package/src/session-runtime/plugin-mcp-standard.test.mjs +0 -177
- package/src/session-runtime/prewarm.test.mjs +0 -52
- package/src/session-runtime/provider-request-snapshot.test.mjs +0 -37
- package/src/session-runtime/resource-api-global.test.mjs +0 -69
- package/src/session-runtime/session-lifecycle.test.mjs +0 -125
- package/src/session-runtime/session-title.test.mjs +0 -36
- package/src/session-runtime/skills-api.test.mjs +0 -99
- package/src/session-runtime/tool-policy-surface.test.mjs +0 -331
- package/src/standalone/agent-tool/helpers.test.mjs +0 -62
- package/src/standalone/agent-tool/notify.test.mjs +0 -37
- package/src/standalone/agent-tool/spawn-flow.test.mjs +0 -63
- package/src/standalone/channel-restart.test.mjs +0 -145
- package/src/standalone/channel-session-router.test.mjs +0 -37
- package/src/standalone/channel-worker-heartbeat.test.mjs +0 -30
- package/src/standalone/hook-bus/handlers.test.mjs +0 -88
- package/src/standalone/plugin-admin.test.mjs +0 -173
- package/src/standalone/session-runtime-agent-control-client.test.mjs +0 -71
- package/src/standalone/session-runtime-dispatch-cancel.test.mjs +0 -139
- package/src/standalone/session-runtime-host-factory.test.mjs +0 -31
- package/src/standalone/session-runtime-host-health.test.mjs +0 -160
- package/src/standalone/session-runtime-inline-host.test.mjs +0 -83
- package/src/standalone/session-runtime-provider-cooldown.test.mjs +0 -80
- package/src/standalone/session-runtime-shard-host.test.mjs +0 -569
- package/src/standalone/session-runtime-shard-router.test.mjs +0 -101
- package/src/tui/app/live-spinner-visibility.test.mjs +0 -44
- package/src/tui/app/panel-epoch.test.mjs +0 -1009
- package/src/tui/app/panel-handoff.test.mjs +0 -311
- package/src/tui/app/prompt-submit.test.mjs +0 -206
- package/src/tui/session/completion-card-restore.test.mjs +0 -111
- package/src/tui/session/goal-continuation.test.mjs +0 -84
- package/src/tui/session/oauth-flows.test.mjs +0 -134
- package/src/tui/session/queue-helpers.test.mjs +0 -46
- package/src/tui/session/session-action-surface.test.mjs +0 -108
- package/src/tui/session/task-wait-submit.test.mjs +0 -80
- package/src/tui/session/tool-result-status.test.mjs +0 -131
- package/src/tui/session/tui-steering-persist.test.mjs +0 -104
package/src/runtime/agent/orchestrator/session/manager/pending-messages-persistence.test.mjs
DELETED
|
@@ -1,325 +0,0 @@
|
|
|
1
|
-
// Regression coverage for the three audited user-input-loss modes of the
|
|
2
|
-
// pending-message spool:
|
|
3
|
-
// 1. a FAILED durable commit must retry itself (an enqueue that reported
|
|
4
|
-
// success may not stay process-local after transient lock contention),
|
|
5
|
-
// 2. a taken foreign injection must stay durable until the consumer owns it
|
|
6
|
-
// (an owner crash in the handoff window must not lose accepted input),
|
|
7
|
-
// 3. shutdown must have a public, runtime-safe drain that actually flushes.
|
|
8
|
-
import assert from 'node:assert/strict';
|
|
9
|
-
import { spawnSync } from 'node:child_process';
|
|
10
|
-
import { mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
11
|
-
import { tmpdir } from 'node:os';
|
|
12
|
-
import { join } from 'node:path';
|
|
13
|
-
import test from 'node:test';
|
|
14
|
-
|
|
15
|
-
// Every env var must be set BEFORE the modules are loaded (lock timeout and
|
|
16
|
-
// handoff grace are captured at import time), so the module under test is
|
|
17
|
-
// imported dynamically.
|
|
18
|
-
const HANDOFF_GRACE_MS = 4000;
|
|
19
|
-
const root = mkdtempSync(join(tmpdir(), 'mixdog-pending-persist-'));
|
|
20
|
-
mkdirSync(root, { recursive: true });
|
|
21
|
-
process.env.MIXDOG_DATA_DIR = root;
|
|
22
|
-
process.env.MIXDOG_LOCK_TIMEOUT_MS = '120';
|
|
23
|
-
process.env.MIXDOG_FOREIGN_HANDOFF_RELEASE_MS = String(HANDOFF_GRACE_MS);
|
|
24
|
-
process.on('exit', () => { try { rmSync(root, { recursive: true, force: true }); } catch { /* best-effort */ } });
|
|
25
|
-
|
|
26
|
-
const {
|
|
27
|
-
_dropPendingMessageState,
|
|
28
|
-
_setPendingPersistTailForTest,
|
|
29
|
-
_settlePendingMessageWrites,
|
|
30
|
-
drainForeignUserInjections,
|
|
31
|
-
enqueuePendingMessage,
|
|
32
|
-
enqueueRemotePendingMessage,
|
|
33
|
-
pendingMessagesSpoolPath,
|
|
34
|
-
settlePendingMessageWrites,
|
|
35
|
-
} = await import('./pending-messages.mjs');
|
|
36
|
-
|
|
37
|
-
const sleep = (ms) => new Promise((resolve) => { setTimeout(resolve, ms); });
|
|
38
|
-
const moduleUrl = new URL('./pending-messages.mjs', import.meta.url).href;
|
|
39
|
-
|
|
40
|
-
// A REAL second live process against the same spool: the cross-process rules
|
|
41
|
-
// (double-take suppression, recovery hydrate) cannot be observed by faking
|
|
42
|
-
// module state inside one process.
|
|
43
|
-
function runInLiveChildProcess(source) {
|
|
44
|
-
const result = spawnSync(process.execPath, ['--input-type=module', '-e', source], {
|
|
45
|
-
encoding: 'utf8',
|
|
46
|
-
env: {
|
|
47
|
-
...process.env,
|
|
48
|
-
MIXDOG_DATA_DIR: root,
|
|
49
|
-
MIXDOG_LOCK_TIMEOUT_MS: '2000',
|
|
50
|
-
MIXDOG_FOREIGN_HANDOFF_RELEASE_MS: String(HANDOFF_GRACE_MS),
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
assert.equal(result.status, 0, `child process failed: ${result.stderr}`);
|
|
54
|
-
const out = String(result.stdout || '').trim().split('\n').pop();
|
|
55
|
-
return JSON.parse(out);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const childDrainSource = (sessionId) => `
|
|
59
|
-
const mod = await import(${JSON.stringify(moduleUrl)});
|
|
60
|
-
const taken = await mod.drainForeignUserInjections(${JSON.stringify(sessionId)});
|
|
61
|
-
process.stdout.write(JSON.stringify(taken.map((item) => item.id)));
|
|
62
|
-
`;
|
|
63
|
-
|
|
64
|
-
const childHydrateSource = (sessionId) => `
|
|
65
|
-
const mod = await import(${JSON.stringify(moduleUrl)});
|
|
66
|
-
const count = await mod.hydratePendingMessages(${JSON.stringify(sessionId)});
|
|
67
|
-
process.stdout.write(JSON.stringify(count));
|
|
68
|
-
`;
|
|
69
|
-
|
|
70
|
-
function spoolRows(sessionId) {
|
|
71
|
-
try {
|
|
72
|
-
const raw = JSON.parse(readFileSync(pendingMessagesSpoolPath(), 'utf8'));
|
|
73
|
-
const rows = raw?.sessions?.[sessionId];
|
|
74
|
-
return Array.isArray(rows) ? rows : [];
|
|
75
|
-
} catch {
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
async function waitFor(predicate, timeoutMs = 6000) {
|
|
81
|
-
const deadline = Date.now() + timeoutMs;
|
|
82
|
-
while (Date.now() < deadline) {
|
|
83
|
-
if (predicate()) return true;
|
|
84
|
-
await sleep(25);
|
|
85
|
-
}
|
|
86
|
-
return Boolean(predicate());
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
test('a failed durable commit retries itself once the spool lock releases', async () => {
|
|
90
|
-
const sessionId = `sess_persist_retry_${process.pid}`;
|
|
91
|
-
const messageId = 'inj_persist_retry';
|
|
92
|
-
const lockPath = `${pendingMessagesSpoolPath()}.lock`;
|
|
93
|
-
// Live-holder lock (our pid + a foreign token is never reclaimed): every
|
|
94
|
-
// commit attempt fails with ELOCKTIMEOUT exactly like the reproduced
|
|
95
|
-
// cross-process contention.
|
|
96
|
-
writeFileSync(lockPath, `${process.pid} ${Date.now()} deadbeefdeadbeefdeadbeef\n`, 'utf8');
|
|
97
|
-
let lockHeld = true;
|
|
98
|
-
try {
|
|
99
|
-
// The submit reports success to the caller...
|
|
100
|
-
assert.equal(enqueueRemotePendingMessage(sessionId, { id: messageId, content: 'final remote submit' }), 1);
|
|
101
|
-
await sleep(350);
|
|
102
|
-
// ...while nothing could reach the spool yet.
|
|
103
|
-
assert.equal(spoolRows(sessionId).some((row) => row.id === messageId), false);
|
|
104
|
-
|
|
105
|
-
unlinkSync(lockPath);
|
|
106
|
-
lockHeld = false;
|
|
107
|
-
// No explicit settle/flush and no further enqueue: the module itself
|
|
108
|
-
// must retry the requeued batch.
|
|
109
|
-
assert.ok(
|
|
110
|
-
await waitFor(() => spoolRows(sessionId).some((row) => row.id === messageId)),
|
|
111
|
-
'requeued batch was never retried after the lock released',
|
|
112
|
-
);
|
|
113
|
-
assert.equal(
|
|
114
|
-
spoolRows(sessionId).find((row) => row.id === messageId)?.message,
|
|
115
|
-
'final remote submit',
|
|
116
|
-
);
|
|
117
|
-
} finally {
|
|
118
|
-
if (lockHeld) { try { unlinkSync(lockPath); } catch { /* ignore */ } }
|
|
119
|
-
_dropPendingMessageState(sessionId);
|
|
120
|
-
await settlePendingMessageWrites({ timeoutMs: 4000 });
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
test('a taken foreign injection is never re-taken by a second live process', async () => {
|
|
125
|
-
const sessionId = `sess_foreign_handoff_${process.pid}`;
|
|
126
|
-
const messageId = 'inj_foreign_handoff';
|
|
127
|
-
try {
|
|
128
|
-
assert.equal(enqueueRemotePendingMessage(sessionId, { id: messageId, content: 'remote user submit' }), 1);
|
|
129
|
-
assert.equal(await settlePendingMessageWrites({ timeoutMs: 4000 }), true);
|
|
130
|
-
|
|
131
|
-
const taken = await drainForeignUserInjections(sessionId);
|
|
132
|
-
assert.deepEqual(taken.map((item) => item.id), [messageId]);
|
|
133
|
-
// The row survives the take: the consumer queues it in memory only
|
|
134
|
-
// after this point, so a crash here must not lose the input.
|
|
135
|
-
assert.ok(
|
|
136
|
-
spoolRows(sessionId).some((row) => row.id === messageId),
|
|
137
|
-
'taken injection must stay durable while the handoff is in flight',
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
// A SECOND LIVE PROCESS drains the same session inside the grace: the
|
|
141
|
-
// parked row belongs to a live owner, so it must not be re-delivered.
|
|
142
|
-
assert.deepEqual(runInLiveChildProcess(childDrainSource(sessionId)), []);
|
|
143
|
-
// ...and this owner does not take it twice either.
|
|
144
|
-
assert.deepEqual(await drainForeignUserInjections(sessionId), []);
|
|
145
|
-
|
|
146
|
-
// A fresh process taking the session over still RECOVERS the input
|
|
147
|
-
// through the ordinary hydrate path (at-least-once, never lost).
|
|
148
|
-
assert.equal(runInLiveChildProcess(childHydrateSource(sessionId)), 1);
|
|
149
|
-
} finally {
|
|
150
|
-
_dropPendingMessageState(sessionId);
|
|
151
|
-
await settlePendingMessageWrites({ timeoutMs: 4000 });
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
test('an expired handoff parked by a DEAD owner is taken over', async () => {
|
|
156
|
-
const sessionId = `sess_dead_owner_${process.pid}`;
|
|
157
|
-
const messageId = 'inj_dead_owner';
|
|
158
|
-
// A process that has already exited: its pid is a corpse owner.
|
|
159
|
-
const deadPid = spawnSync(process.execPath, ['-e', '0']).pid;
|
|
160
|
-
assert.ok(deadPid > 0);
|
|
161
|
-
try {
|
|
162
|
-
const now = Date.now();
|
|
163
|
-
writeFileSync(pendingMessagesSpoolPath(), `${JSON.stringify({
|
|
164
|
-
version: 1,
|
|
165
|
-
updatedAt: now,
|
|
166
|
-
sessions: {
|
|
167
|
-
[sessionId]: [{
|
|
168
|
-
id: messageId,
|
|
169
|
-
message: 'submit stranded by a crashed owner',
|
|
170
|
-
enqueuedAt: now,
|
|
171
|
-
handoffAt: now - HANDOFF_GRACE_MS - 1000,
|
|
172
|
-
handoffPid: deadPid,
|
|
173
|
-
}],
|
|
174
|
-
},
|
|
175
|
-
sessionTouchedAt: { [sessionId]: now },
|
|
176
|
-
})}\n`, 'utf8');
|
|
177
|
-
|
|
178
|
-
const taken = await drainForeignUserInjections(sessionId);
|
|
179
|
-
assert.deepEqual(taken.map((item) => item.id), [messageId]);
|
|
180
|
-
} finally {
|
|
181
|
-
_dropPendingMessageState(sessionId);
|
|
182
|
-
await settlePendingMessageWrites({ timeoutMs: 4000 });
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
test('a dead owner\'s row observed BEFORE expiry is still recovered after the grace', async () => {
|
|
187
|
-
const sessionId = `sess_dead_owner_transition_${process.pid}`;
|
|
188
|
-
const messageId = 'inj_dead_owner_transition';
|
|
189
|
-
const deadPid = spawnSync(process.execPath, ['-e', '0']).pid;
|
|
190
|
-
assert.ok(deadPid > 0);
|
|
191
|
-
const spoolPath = pendingMessagesSpoolPath();
|
|
192
|
-
try {
|
|
193
|
-
const now = Date.now();
|
|
194
|
-
writeFileSync(spoolPath, `${JSON.stringify({
|
|
195
|
-
version: 1,
|
|
196
|
-
updatedAt: now,
|
|
197
|
-
sessions: {
|
|
198
|
-
[sessionId]: [{
|
|
199
|
-
id: messageId,
|
|
200
|
-
message: 'submit parked shortly before the owner died',
|
|
201
|
-
enqueuedAt: now,
|
|
202
|
-
// Expires ~1.2s from now: the successor below sees it first
|
|
203
|
-
// INSIDE the grace window.
|
|
204
|
-
handoffAt: now - (HANDOFF_GRACE_MS - 1200),
|
|
205
|
-
handoffPid: deadPid,
|
|
206
|
-
}],
|
|
207
|
-
},
|
|
208
|
-
sessionTouchedAt: { [sessionId]: now },
|
|
209
|
-
})}\n`, 'utf8');
|
|
210
|
-
|
|
211
|
-
// A persistent successor observes the row while it is still respected.
|
|
212
|
-
// This scan memoizes the spool mtime.
|
|
213
|
-
assert.deepEqual(await drainForeignUserInjections(sessionId), []);
|
|
214
|
-
const mtimeAfterFirstScan = statSync(spoolPath).mtimeMs;
|
|
215
|
-
await sleep(1600);
|
|
216
|
-
// Nothing wrote the spool in between — post-expiry recovery must not
|
|
217
|
-
// depend on an incidental mtime change (nor on being a fresh process).
|
|
218
|
-
assert.equal(
|
|
219
|
-
statSync(spoolPath).mtimeMs,
|
|
220
|
-
mtimeAfterFirstScan,
|
|
221
|
-
'the spool must stay untouched for this regression to be meaningful',
|
|
222
|
-
);
|
|
223
|
-
assert.deepEqual(
|
|
224
|
-
(await drainForeignUserInjections(sessionId)).map((item) => item.id),
|
|
225
|
-
[messageId],
|
|
226
|
-
);
|
|
227
|
-
} finally {
|
|
228
|
-
_dropPendingMessageState(sessionId);
|
|
229
|
-
await settlePendingMessageWrites({ timeoutMs: 4000 });
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
test('a parked handoff row is released on schedule, without any later spool write', async () => {
|
|
234
|
-
const sessionId = `sess_handoff_release_${process.pid}`;
|
|
235
|
-
const messageId = 'inj_handoff_release';
|
|
236
|
-
try {
|
|
237
|
-
assert.equal(enqueueRemotePendingMessage(sessionId, { id: messageId, content: 'released after grace' }), 1);
|
|
238
|
-
assert.equal(await settlePendingMessageWrites({ timeoutMs: 4000 }), true);
|
|
239
|
-
assert.deepEqual(
|
|
240
|
-
(await drainForeignUserInjections(sessionId)).map((item) => item.id),
|
|
241
|
-
[messageId],
|
|
242
|
-
);
|
|
243
|
-
assert.ok(spoolRows(sessionId).some((row) => row.id === messageId));
|
|
244
|
-
|
|
245
|
-
// Nothing below writes the spool: the release must be SCHEDULED, not a
|
|
246
|
-
// side effect of some incidental later transaction (the per-session
|
|
247
|
-
// mtime memo suppresses the next scan of an otherwise idle spool).
|
|
248
|
-
assert.ok(
|
|
249
|
-
await waitFor(
|
|
250
|
-
() => !spoolRows(sessionId).some((row) => row.id === messageId),
|
|
251
|
-
HANDOFF_GRACE_MS + 6000,
|
|
252
|
-
),
|
|
253
|
-
'parked handoff row was never released after the grace window',
|
|
254
|
-
);
|
|
255
|
-
} finally {
|
|
256
|
-
_dropPendingMessageState(sessionId);
|
|
257
|
-
await settlePendingMessageWrites({ timeoutMs: 4000 });
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
test('a closed session never resurrects its persist retry', async () => {
|
|
262
|
-
const sessionId = `sess_closed_retry_${process.pid}`;
|
|
263
|
-
const lockPath = `${pendingMessagesSpoolPath()}.lock`;
|
|
264
|
-
writeFileSync(lockPath, `${process.pid} ${Date.now()} deadbeefdeadbeefdeadbeef\n`, 'utf8');
|
|
265
|
-
let lockHeld = true;
|
|
266
|
-
try {
|
|
267
|
-
assert.ok(enqueuePendingMessage(sessionId, 'input during contention') > 0);
|
|
268
|
-
// At least one commit fails and requeues while the lock is held.
|
|
269
|
-
await sleep(350);
|
|
270
|
-
assert.equal(spoolRows(sessionId).length, 0);
|
|
271
|
-
|
|
272
|
-
// Close tears the pending state down; in-flight failures must not
|
|
273
|
-
// rebuild the buffer or re-arm the retry timer behind it.
|
|
274
|
-
_dropPendingMessageState(sessionId);
|
|
275
|
-
// ...and the fence must survive the state map's size trim: an evicted
|
|
276
|
-
// entry that decays into "never closed" would let the in-flight failure
|
|
277
|
-
// compare equal again (ABA) and resurrect the retry.
|
|
278
|
-
for (let i = 0; i < 700; i += 1) {
|
|
279
|
-
_dropPendingMessageState(`sess_evict_${process.pid}_${i}`, { clearPersisted: false });
|
|
280
|
-
}
|
|
281
|
-
unlinkSync(lockPath);
|
|
282
|
-
lockHeld = false;
|
|
283
|
-
await sleep(900);
|
|
284
|
-
assert.deepEqual(spoolRows(sessionId), []);
|
|
285
|
-
} finally {
|
|
286
|
-
if (lockHeld) { try { unlinkSync(lockPath); } catch { /* ignore */ } }
|
|
287
|
-
_dropPendingMessageState(sessionId);
|
|
288
|
-
await settlePendingMessageWrites({ timeoutMs: 4000 });
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
test('the manager facade exposes the shutdown drain under its public name', async () => {
|
|
293
|
-
const facade = await import('../manager.mjs');
|
|
294
|
-
assert.equal(typeof facade.settlePendingMessageWrites, 'function');
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
test('settlePendingMessageWrites is the public, runtime-safe shutdown drain', async () => {
|
|
298
|
-
const sessionId = `sess_shutdown_drain_${process.pid}`;
|
|
299
|
-
const stuckSessionId = `sess_shutdown_stuck_${process.pid}`;
|
|
300
|
-
try {
|
|
301
|
-
assert.equal(typeof settlePendingMessageWrites, 'function');
|
|
302
|
-
assert.ok(enqueuePendingMessage(sessionId, 'queued right before exit') > 0);
|
|
303
|
-
// Buffered-only so far: shutdown that exits without draining loses it.
|
|
304
|
-
assert.equal(await settlePendingMessageWrites({ timeoutMs: 4000 }), true);
|
|
305
|
-
assert.ok(spoolRows(sessionId).some((row) => row.message === 'queued right before exit'));
|
|
306
|
-
|
|
307
|
-
// A stuck spool tail must not break (or hang) an exit path...
|
|
308
|
-
_setPendingPersistTailForTest(stuckSessionId, new Promise(() => {}));
|
|
309
|
-
assert.equal(await settlePendingMessageWrites({ timeoutMs: 80 }), false);
|
|
310
|
-
// ...while the underscore alias keeps its strict test semantics, and a
|
|
311
|
-
// caller cannot switch that strictness off through the options bag.
|
|
312
|
-
await assert.rejects(
|
|
313
|
-
() => _settlePendingMessageWrites({ timeoutMs: 80 }),
|
|
314
|
-
/did not settle/,
|
|
315
|
-
);
|
|
316
|
-
await assert.rejects(
|
|
317
|
-
() => _settlePendingMessageWrites({ timeoutMs: 80, throwOnTimeout: false }),
|
|
318
|
-
/did not settle/,
|
|
319
|
-
);
|
|
320
|
-
} finally {
|
|
321
|
-
_setPendingPersistTailForTest(stuckSessionId, Promise.resolve());
|
|
322
|
-
_dropPendingMessageState(sessionId);
|
|
323
|
-
await settlePendingMessageWrites({ timeoutMs: 4000 });
|
|
324
|
-
}
|
|
325
|
-
});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { test } from 'node:test';
|
|
3
|
-
import { resolveSessionContextMeta } from './context-meta.mjs';
|
|
4
|
-
import { contextSeedForRouteUpdate, _refreshSessionRuleVariantsForModel } from './session-lifecycle.mjs';
|
|
5
|
-
import { _buildSharedRules } from './rules-cache.mjs';
|
|
6
|
-
|
|
7
|
-
test('a cold Cursor route uses 200k instead of inheriting another model window', () => {
|
|
8
|
-
const seed = contextSeedForRouteUpdate({
|
|
9
|
-
selectedContextWindow: 272_000,
|
|
10
|
-
contextWindow: 272_000,
|
|
11
|
-
rawContextWindow: 272_000,
|
|
12
|
-
compactBoundaryTokens: 272_000,
|
|
13
|
-
}, true);
|
|
14
|
-
assert.deepEqual(seed, {});
|
|
15
|
-
const meta = resolveSessionContextMeta(
|
|
16
|
-
{ name: 'cursor-oauth' },
|
|
17
|
-
'gemini-3.7-flash',
|
|
18
|
-
seed,
|
|
19
|
-
);
|
|
20
|
-
assert.equal(meta.contextWindow, 200_000);
|
|
21
|
-
assert.equal(meta.rawContextWindow, 200_000);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test('a cold Cursor route does not use another provider exact-id window', () => {
|
|
25
|
-
const meta = resolveSessionContextMeta(
|
|
26
|
-
{ name: 'cursor-oauth' },
|
|
27
|
-
'gpt-5.4',
|
|
28
|
-
{},
|
|
29
|
-
);
|
|
30
|
-
assert.equal(meta.contextWindow, 200_000);
|
|
31
|
-
assert.equal(meta.rawContextWindow, 200_000);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('an explicitly selected context window survives a route update', () => {
|
|
35
|
-
assert.deepEqual(contextSeedForRouteUpdate({
|
|
36
|
-
selectedContextWindow: 300_000,
|
|
37
|
-
contextWindow: 300_000,
|
|
38
|
-
}, true, true), {
|
|
39
|
-
selectedContextWindow: 300_000,
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('an empty-session route change re-renders the edit-dialect rule variants', () => {
|
|
44
|
-
const gptRules = _buildSharedRules({ omitTools: ['edit'] });
|
|
45
|
-
const claudeRules = _buildSharedRules({ omitTools: ['apply_patch'] });
|
|
46
|
-
assert.notEqual(gptRules, claudeRules);
|
|
47
|
-
const session = {
|
|
48
|
-
model: 'claude-fable-5',
|
|
49
|
-
messages: [
|
|
50
|
-
{ role: 'system', content: gptRules },
|
|
51
|
-
{ role: 'system', content: 'profile block' },
|
|
52
|
-
{ role: 'system', content: 'core block', cacheTier: 'tier3' },
|
|
53
|
-
],
|
|
54
|
-
};
|
|
55
|
-
// GPT-created session switched to Claude: BP1 flips to the edit variant.
|
|
56
|
-
assert.equal(_refreshSessionRuleVariantsForModel(session, 'gpt-5.6-sol'), true);
|
|
57
|
-
assert.equal(session.messages[0].content, claudeRules);
|
|
58
|
-
assert.match(session.messages[0].content, /`edit`/);
|
|
59
|
-
assert.doesNotMatch(session.messages[0].content, /apply_patch/);
|
|
60
|
-
// Untouched blocks keep their identity and content.
|
|
61
|
-
assert.equal(session.messages[1].content, 'profile block');
|
|
62
|
-
assert.equal(session.messages[2].cacheTier, 'tier3');
|
|
63
|
-
// Same edit dialect on both sides is a no-op.
|
|
64
|
-
assert.equal(_refreshSessionRuleVariantsForModel(session, 'claude-opus-5'), false);
|
|
65
|
-
// A layout without the expected BP1 content is left untouched.
|
|
66
|
-
assert.equal(_refreshSessionRuleVariantsForModel({
|
|
67
|
-
model: 'claude-fable-5',
|
|
68
|
-
messages: [{ role: 'system', content: 'custom prompt' }],
|
|
69
|
-
}, 'gpt-5.6-sol'), false);
|
|
70
|
-
});
|