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
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import {
|
|
3
|
-
existsSync,
|
|
4
|
-
mkdirSync,
|
|
5
|
-
mkdtempSync,
|
|
6
|
-
readFileSync,
|
|
7
|
-
rmSync,
|
|
8
|
-
writeFileSync,
|
|
9
|
-
} from 'node:fs';
|
|
10
|
-
import { tmpdir } from 'node:os';
|
|
11
|
-
import { join } from 'node:path';
|
|
12
|
-
import { test } from 'node:test';
|
|
13
|
-
|
|
14
|
-
test('media assets are organized by kind, provider, model, and local date while flat files migrate', async () => {
|
|
15
|
-
const root = mkdtempSync(join(tmpdir(), 'mixdog-media-store-'));
|
|
16
|
-
const previousDataDir = process.env.MIXDOG_DATA_DIR;
|
|
17
|
-
process.env.MIXDOG_DATA_DIR = root;
|
|
18
|
-
const assetsDir = join(root, 'media', 'assets');
|
|
19
|
-
const createdAt = new Date(2026, 6, 5, 12, 0, 0).getTime();
|
|
20
|
-
mkdirSync(assetsDir, { recursive: true });
|
|
21
|
-
writeFileSync(join(assetsDir, 'legacy-image.jpg'), Buffer.from('image'));
|
|
22
|
-
writeFileSync(join(assetsDir, 'legacy-video.mp4'), Buffer.from('video'));
|
|
23
|
-
writeFileSync(join(root, 'media', 'index.json'), JSON.stringify({
|
|
24
|
-
version: 1,
|
|
25
|
-
assets: [
|
|
26
|
-
{
|
|
27
|
-
id: 'legacy-image',
|
|
28
|
-
file: 'legacy-image.jpg',
|
|
29
|
-
kind: 'image',
|
|
30
|
-
lane: 'gemini',
|
|
31
|
-
model: 'image-alpha',
|
|
32
|
-
prompt: 'image',
|
|
33
|
-
options: { aspectRatio: '4:3' },
|
|
34
|
-
mime: 'image/jpeg',
|
|
35
|
-
bytes: 5,
|
|
36
|
-
createdAt,
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
id: 'legacy-video',
|
|
40
|
-
file: 'legacy-video.mp4',
|
|
41
|
-
kind: 'video',
|
|
42
|
-
lane: 'grok',
|
|
43
|
-
model: 'video-beta',
|
|
44
|
-
prompt: 'video',
|
|
45
|
-
options: { aspectRatio: '16:9' },
|
|
46
|
-
mime: 'video/mp4',
|
|
47
|
-
bytes: 5,
|
|
48
|
-
createdAt,
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
}));
|
|
52
|
-
|
|
53
|
-
try {
|
|
54
|
-
const store = await import(`./store.mjs?test=${Date.now()}`);
|
|
55
|
-
assert.deepEqual(
|
|
56
|
-
store.mediaOpenCommand('C:\\Media Assets\\clip.mp4', {
|
|
57
|
-
reveal: true,
|
|
58
|
-
platform: 'win32',
|
|
59
|
-
}),
|
|
60
|
-
['explorer.exe', ['/select,', 'C:\\Media Assets\\clip.mp4']],
|
|
61
|
-
);
|
|
62
|
-
assert.deepEqual(
|
|
63
|
-
store.mediaOpenCommand('/Users/me/Media Assets/image.png', {
|
|
64
|
-
reveal: true,
|
|
65
|
-
platform: 'darwin',
|
|
66
|
-
}),
|
|
67
|
-
['open', ['-R', '/Users/me/Media Assets/image.png']],
|
|
68
|
-
);
|
|
69
|
-
const beforeMigration = store.listMediaAssets({ limit: 10 }).assets;
|
|
70
|
-
assert.equal(beforeMigration[0].file, 'legacy-image.jpg',
|
|
71
|
-
'read-only listing must not run the write-side layout migration');
|
|
72
|
-
const saved = store.saveMediaAsset({
|
|
73
|
-
kind: 'video',
|
|
74
|
-
lane: 'gemini',
|
|
75
|
-
model: 'veo:3/preview',
|
|
76
|
-
prompt: 'new clip',
|
|
77
|
-
options: { aspectRatio: '16:9' },
|
|
78
|
-
mime: 'video/mp4',
|
|
79
|
-
bytes: Buffer.from('new-video'),
|
|
80
|
-
});
|
|
81
|
-
const migrated = store.listMediaAssets({ limit: 10 }).assets;
|
|
82
|
-
const listed = ['legacy-image', 'legacy-video'].map((id) =>
|
|
83
|
-
migrated.find((entry) => entry.id === id));
|
|
84
|
-
assert.equal(listed[0].file, 'images/gemini/image-alpha/2026-07-05/legacy-image.jpg');
|
|
85
|
-
assert.equal(listed[1].file, 'videos/grok/video-beta/2026-07-05/legacy-video.mp4');
|
|
86
|
-
assert.equal(existsSync(join(assetsDir, ...listed[0].file.split('/'))), true);
|
|
87
|
-
assert.equal(existsSync(join(assetsDir, ...listed[1].file.split('/'))), true);
|
|
88
|
-
assert.equal(existsSync(join(assetsDir, 'legacy-image.jpg')), false);
|
|
89
|
-
const cacheBeforeReads = store.mediaStoreCacheStats();
|
|
90
|
-
await Promise.all([
|
|
91
|
-
store.resolveMediaFile('legacy-image'),
|
|
92
|
-
store.resolveMediaFile('legacy-video'),
|
|
93
|
-
store.resolveMediaFile('legacy-image'),
|
|
94
|
-
]);
|
|
95
|
-
const cacheAfterReads = store.mediaStoreCacheStats();
|
|
96
|
-
assert.equal(cacheAfterReads.indexDiskReads, cacheBeforeReads.indexDiskReads,
|
|
97
|
-
'a thumbnail-resolution burst must reuse the parsed media index');
|
|
98
|
-
assert.ok(cacheAfterReads.indexCacheHits >= cacheBeforeReads.indexCacheHits + 3);
|
|
99
|
-
const cachedOnlyMiss = await store.resolveMediaFile('legacy-image', {
|
|
100
|
-
variant: 'thumb',
|
|
101
|
-
generate: false,
|
|
102
|
-
});
|
|
103
|
-
assert.equal(cachedOnlyMiss.available, false,
|
|
104
|
-
'a local protocol probe must not start native rendition generation on a cache miss');
|
|
105
|
-
assert.equal(
|
|
106
|
-
(await store.readMediaAsset('legacy-video')).base64,
|
|
107
|
-
Buffer.from('video').toString('base64'),
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
// A tile-sized rendition is impossible for these stub bytes (and video
|
|
111
|
-
// needs ffmpeg): the read must REPORT the miss instead of quietly
|
|
112
|
-
// shipping the original, which is what made the remote gallery slow.
|
|
113
|
-
const missing = await store.readMediaAsset('legacy-image', {
|
|
114
|
-
variant: 'thumb',
|
|
115
|
-
generate: false,
|
|
116
|
-
});
|
|
117
|
-
assert.equal(missing.available, false);
|
|
118
|
-
assert.equal(missing.base64, '');
|
|
119
|
-
// Callers that can afford full-size bytes (local IPC) opt in explicitly
|
|
120
|
-
// and get them labelled as a downgrade.
|
|
121
|
-
const downgraded = await store.readMediaAsset('legacy-image', {
|
|
122
|
-
variant: 'thumb',
|
|
123
|
-
allowOriginal: true,
|
|
124
|
-
generate: false,
|
|
125
|
-
});
|
|
126
|
-
assert.equal(downgraded.variant, 'original');
|
|
127
|
-
assert.equal(downgraded.downgraded, true);
|
|
128
|
-
assert.equal(downgraded.base64, Buffer.from('image').toString('base64'));
|
|
129
|
-
const browserThumb = Buffer.from('browser-generated-thumbnail');
|
|
130
|
-
const cached = store.cacheMediaThumbnail('legacy-video', {
|
|
131
|
-
mime: 'image/jpeg',
|
|
132
|
-
base64: browserThumb.toString('base64'),
|
|
133
|
-
durationSeconds: 7,
|
|
134
|
-
});
|
|
135
|
-
assert.equal(cached.available, true);
|
|
136
|
-
const cachedTarget = await store.resolveMediaFile('legacy-video', {
|
|
137
|
-
variant: 'thumb',
|
|
138
|
-
generate: false,
|
|
139
|
-
});
|
|
140
|
-
assert.equal(cachedTarget.available, true,
|
|
141
|
-
'a cache-only local protocol probe must serve a browser-generated rendition');
|
|
142
|
-
const cachedRead = await store.readMediaAsset('legacy-video', { variant: 'thumb' });
|
|
143
|
-
assert.equal(cachedRead.mime, 'image/jpeg');
|
|
144
|
-
assert.equal(cachedRead.base64, browserThumb.toString('base64'));
|
|
145
|
-
assert.equal(cachedRead.durationSeconds, 7);
|
|
146
|
-
|
|
147
|
-
assert.match(saved.file, /^videos\/gemini\/veo-3-preview\/\d{4}-\d{2}-\d{2}\/[0-9a-f-]+\.mp4$/);
|
|
148
|
-
assert.equal(existsSync(join(assetsDir, ...saved.file.split('/'))), true);
|
|
149
|
-
assert.equal(store.deleteMediaAsset(saved.id).removed, true);
|
|
150
|
-
assert.equal(existsSync(join(assetsDir, ...saved.file.split('/'))), false);
|
|
151
|
-
|
|
152
|
-
const persisted = JSON.parse(readFileSync(join(root, 'media', 'index.json'), 'utf8'));
|
|
153
|
-
assert.equal(persisted.version, 2);
|
|
154
|
-
} finally {
|
|
155
|
-
if (previousDataDir === undefined) delete process.env.MIXDOG_DATA_DIR;
|
|
156
|
-
else process.env.MIXDOG_DATA_DIR = previousDataDir;
|
|
157
|
-
rmSync(root, { recursive: true, force: true });
|
|
158
|
-
}
|
|
159
|
-
});
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import test from 'node:test'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
import { createHash } from 'node:crypto'
|
|
4
|
-
import { mkdtempSync, mkdirSync, readFileSync, rmSync } from 'node:fs'
|
|
5
|
-
import { tmpdir } from 'node:os'
|
|
6
|
-
import { join } from 'node:path'
|
|
7
|
-
import { gzipSync } from 'node:zlib'
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
_extractTar,
|
|
11
|
-
_kiwiBuildArgs,
|
|
12
|
-
_resolveKoMorphIdleTimeout,
|
|
13
|
-
_verifyKiwiModelArchive,
|
|
14
|
-
} from './ko-morph.mjs'
|
|
15
|
-
import { _validateRuntimeTarEntries } from './runtime-fetcher.mjs'
|
|
16
|
-
|
|
17
|
-
const REQUIRED = ['combiningRule.txt', 'default.dict', 'extract.mdl', 'sj.knlm', 'sj.morph']
|
|
18
|
-
|
|
19
|
-
test('Kiwi recall build excludes optional dictionaries and releases after two minutes', () => {
|
|
20
|
-
const modelFiles = { 'sj.knlm': new Uint8Array([1]) }
|
|
21
|
-
assert.deepEqual(_kiwiBuildArgs(modelFiles), {
|
|
22
|
-
modelFiles,
|
|
23
|
-
modelType: 'knlm',
|
|
24
|
-
loadDefaultDict: true,
|
|
25
|
-
loadMultiDict: false,
|
|
26
|
-
loadTypoDict: false,
|
|
27
|
-
typos: 'none',
|
|
28
|
-
})
|
|
29
|
-
assert.equal(_resolveKoMorphIdleTimeout(undefined), 120_000)
|
|
30
|
-
assert.equal(_resolveKoMorphIdleTimeout('0'), 0)
|
|
31
|
-
assert.equal(_resolveKoMorphIdleTimeout('45000'), 45_000)
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
function tarEntry(name, body = Buffer.alloc(0), type = '0') {
|
|
35
|
-
const bytes = Buffer.from(body)
|
|
36
|
-
const header = Buffer.alloc(512)
|
|
37
|
-
header.write(name, 0, 100, 'utf8')
|
|
38
|
-
header.write(bytes.length.toString(8).padStart(11, '0'), 124, 11, 'ascii')
|
|
39
|
-
header[135] = 0
|
|
40
|
-
header[156] = type.charCodeAt(0)
|
|
41
|
-
const padding = Buffer.alloc((512 - (bytes.length % 512)) % 512)
|
|
42
|
-
return Buffer.concat([header, bytes, padding])
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function modelTar(extra = []) {
|
|
46
|
-
return Buffer.concat([
|
|
47
|
-
tarEntry('base/', '', '5'),
|
|
48
|
-
...REQUIRED.map((name) => tarEntry(`base/${name}`, `data:${name}`)),
|
|
49
|
-
...extra,
|
|
50
|
-
Buffer.alloc(1024),
|
|
51
|
-
])
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
test('Kiwi archive verifies size and sha256 and caps decompression', () => {
|
|
55
|
-
const payload = modelTar()
|
|
56
|
-
const gz = gzipSync(payload)
|
|
57
|
-
const sha256 = createHash('sha256').update(gz).digest('hex')
|
|
58
|
-
assert.deepEqual(_verifyKiwiModelArchive(gz, {
|
|
59
|
-
expectedBytes: gz.length,
|
|
60
|
-
expectedSha256: sha256,
|
|
61
|
-
maxTarBytes: payload.length,
|
|
62
|
-
}), payload)
|
|
63
|
-
assert.throws(() => _verifyKiwiModelArchive(gz, {
|
|
64
|
-
expectedBytes: gz.length,
|
|
65
|
-
expectedSha256: '0'.repeat(64),
|
|
66
|
-
maxTarBytes: payload.length,
|
|
67
|
-
}), /sha256 mismatch/)
|
|
68
|
-
assert.throws(() => _verifyKiwiModelArchive(gz, {
|
|
69
|
-
expectedBytes: gz.length,
|
|
70
|
-
expectedSha256: sha256,
|
|
71
|
-
maxTarBytes: 512,
|
|
72
|
-
}), /decompression failed or exceeds/)
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
test('Kiwi tar writes only the pinned regular file set', () => {
|
|
76
|
-
const root = mkdtempSync(join(tmpdir(), 'mixdog-kiwi-tar-'))
|
|
77
|
-
const dest = join(root, 'model')
|
|
78
|
-
mkdirSync(dest)
|
|
79
|
-
try {
|
|
80
|
-
const written = _extractTar(modelTar([tarEntry('base/typo.dict', 'optional')]), dest)
|
|
81
|
-
assert.deepEqual(written.sort(), [...REQUIRED, 'typo.dict'].sort())
|
|
82
|
-
assert.equal(readFileSync(join(dest, 'default.dict'), 'utf8'), 'data:default.dict')
|
|
83
|
-
assert.throws(
|
|
84
|
-
() => _extractTar(modelTar([tarEntry('base/escape', 'bad')]), dest),
|
|
85
|
-
/unexpected file/,
|
|
86
|
-
)
|
|
87
|
-
assert.throws(
|
|
88
|
-
() => _extractTar(modelTar([tarEntry('base/link', '', '2')]), dest),
|
|
89
|
-
/unsupported entry type/,
|
|
90
|
-
)
|
|
91
|
-
} finally {
|
|
92
|
-
rmSync(root, { recursive: true, force: true })
|
|
93
|
-
}
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
test('native runtime tar allows internal links and rejects unsafe entries', () => {
|
|
97
|
-
const base = join(tmpdir(), 'mixdog-runtime-staging')
|
|
98
|
-
assert.doesNotThrow(() => _validateRuntimeTarEntries(
|
|
99
|
-
['./runtime/', './runtime/bin/tool', './runtime/link', './runtime/hard'],
|
|
100
|
-
[
|
|
101
|
-
'drwxr-xr-x user/group 0 date ./runtime/',
|
|
102
|
-
'-rwxr-xr-x user/group 1 date ./runtime/bin/tool',
|
|
103
|
-
'lrwxrwxrwx user/group 0 date ./runtime/link -> bin/tool',
|
|
104
|
-
'hrw-r--r-- user/group 0 date ./runtime/hard link to ./runtime/bin/tool',
|
|
105
|
-
],
|
|
106
|
-
base,
|
|
107
|
-
))
|
|
108
|
-
assert.throws(
|
|
109
|
-
() => _validateRuntimeTarEntries(['../escape'], ['-rw-r--r-- escape'], base),
|
|
110
|
-
/unsafe entry/,
|
|
111
|
-
)
|
|
112
|
-
assert.throws(
|
|
113
|
-
() => _validateRuntimeTarEntries(['runtime/link'], ['lrwxrwxrwx runtime/link -> outside'], base),
|
|
114
|
-
/link target is unsafe/,
|
|
115
|
-
)
|
|
116
|
-
assert.throws(
|
|
117
|
-
() => _validateRuntimeTarEntries(
|
|
118
|
-
['runtime/link', 'runtime/target'],
|
|
119
|
-
['lrwxrwxrwx runtime/link -> ../../../outside', '-rw-r--r-- runtime/target'],
|
|
120
|
-
base,
|
|
121
|
-
),
|
|
122
|
-
/link target is unsafe/,
|
|
123
|
-
)
|
|
124
|
-
assert.throws(
|
|
125
|
-
() => _validateRuntimeTarEntries(['runtime/fifo'], ['prw-r--r-- runtime/fifo'], base),
|
|
126
|
-
/entry type is unsafe/,
|
|
127
|
-
)
|
|
128
|
-
})
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict'
|
|
2
|
-
import test from 'node:test'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
getEmbeddingModelLoadOptions,
|
|
6
|
-
getEmbeddingOutputName,
|
|
7
|
-
getEmbeddingPooling,
|
|
8
|
-
getKnownEmbeddingDims,
|
|
9
|
-
normalizeEmbeddingDtype,
|
|
10
|
-
normalizeEmbeddingInputType,
|
|
11
|
-
prepareEmbeddingInput,
|
|
12
|
-
} from './embedding-model-config.mjs'
|
|
13
|
-
|
|
14
|
-
const HARRIER = 'onnx-community/harrier-oss-v1-270m-ONNX'
|
|
15
|
-
|
|
16
|
-
test('Harrier uses its fixed ONNX profile and last-token pooling', () => {
|
|
17
|
-
assert.equal(getKnownEmbeddingDims(HARRIER), 640)
|
|
18
|
-
assert.equal(normalizeEmbeddingDtype(HARRIER, ''), 'q4')
|
|
19
|
-
assert.deepEqual(getEmbeddingModelLoadOptions(HARRIER), { model_file_name: 'model' })
|
|
20
|
-
assert.equal(getEmbeddingOutputName(HARRIER), 'sentence_embedding')
|
|
21
|
-
assert.equal(getEmbeddingPooling(HARRIER), 'last_token')
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
test('Harrier applies its retrieval instruction only to queries', () => {
|
|
25
|
-
const text = 'Windows 음성 런타임의 메모리 사용량'
|
|
26
|
-
assert.equal(normalizeEmbeddingInputType('QUERY'), 'query')
|
|
27
|
-
assert.equal(normalizeEmbeddingInputType('passage'), 'document')
|
|
28
|
-
assert.equal(prepareEmbeddingInput(text, 'document', HARRIER), text)
|
|
29
|
-
assert.equal(
|
|
30
|
-
prepareEmbeddingInput(text, 'query', HARRIER),
|
|
31
|
-
`Instruct: Given a web search query, retrieve relevant passages that answer the query\nQuery: ${text}`,
|
|
32
|
-
)
|
|
33
|
-
})
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
|
|
4
|
-
import { isLocalOrigin } from './http-wire.mjs';
|
|
5
|
-
|
|
6
|
-
test('memory HTTP requests require loopback Host, Origin, and Referer values', () => {
|
|
7
|
-
assert.equal(isLocalOrigin({ headers: { host: '127.0.0.1:37777' } }), true);
|
|
8
|
-
assert.equal(isLocalOrigin({
|
|
9
|
-
headers: { host: 'localhost:37777', origin: 'http://localhost:4100' },
|
|
10
|
-
}), true);
|
|
11
|
-
assert.equal(isLocalOrigin({ headers: { host: 'memory.attacker.test:37777' } }), false);
|
|
12
|
-
assert.equal(isLocalOrigin({
|
|
13
|
-
headers: { host: '127.0.0.1:37777', origin: 'https://attacker.test' },
|
|
14
|
-
}), false);
|
|
15
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import test from 'node:test'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
import { packCycle1Windows } from './memory-cycle1.mjs'
|
|
4
|
-
import { packUnifiedGatePackets } from './memory-cycle2-gate.mjs'
|
|
5
|
-
import { periodicCycleDue } from './cycle-scheduler.mjs'
|
|
6
|
-
|
|
7
|
-
test('cycle1 packets cap each agent at 50 rows and each cycle at four agents', () => {
|
|
8
|
-
const rowsBySession = new Map([
|
|
9
|
-
['a', Array.from({ length: 130 }, (_, i) => ({ id: 130 - i }))],
|
|
10
|
-
['b', Array.from({ length: 130 }, (_, i) => ({ id: 260 - i }))],
|
|
11
|
-
])
|
|
12
|
-
const packets = packCycle1Windows(rowsBySession, 100, 10)
|
|
13
|
-
assert.equal(packets.length, 4)
|
|
14
|
-
assert.ok(packets.every(packet => packet.length <= 50))
|
|
15
|
-
assert.equal(packets.reduce((sum, packet) => sum + packet.length, 0), 180)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test('cycle2 counts roots and lineage together inside the 50-material packet cap', () => {
|
|
19
|
-
const rows = Array.from({ length: 50 }, (_, i) => ({ id: i + 1 }))
|
|
20
|
-
const candidates = new Map(rows.map(row => [
|
|
21
|
-
row.id,
|
|
22
|
-
Array.from({ length: 6 }, (_, i) => ({ older_id: row.id * 100 + i })),
|
|
23
|
-
]))
|
|
24
|
-
const packed = packUnifiedGatePackets(rows, candidates, { materialCap: 50, maxPackets: 4 })
|
|
25
|
-
assert.equal(packed.packets.length, 4)
|
|
26
|
-
assert.ok(packed.packets.every(packet => packet.materialCount <= 50))
|
|
27
|
-
assert.equal(packed.packets.reduce((sum, packet) => sum + packet.rows.length, 0), 28)
|
|
28
|
-
assert.equal(packed.deferredIds.length, 22)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
test('cycle2 can place 50 roots without lineage in one disposable agent packet', () => {
|
|
32
|
-
const rows = Array.from({ length: 50 }, (_, i) => ({ id: i + 1 }))
|
|
33
|
-
const packed = packUnifiedGatePackets(rows, new Map())
|
|
34
|
-
assert.equal(packed.packets.length, 1)
|
|
35
|
-
assert.equal(packed.packets[0].materialCount, 50)
|
|
36
|
-
assert.equal(packed.deferredIds.length, 0)
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
test('a never-run periodic cycle gets one startup interval of grace', () => {
|
|
40
|
-
const startedAt = 1_000_000
|
|
41
|
-
assert.equal(periodicCycleDue(0, startedAt, 600_000, startedAt + 599_999), false)
|
|
42
|
-
assert.equal(periodicCycleDue(0, startedAt, 600_000, startedAt + 600_000), true)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
test('an overdue periodic cycle stays due across a runtime restart', () => {
|
|
46
|
-
const lastSuccess = 1_000_000
|
|
47
|
-
const restartedAt = 2_000_000
|
|
48
|
-
assert.equal(periodicCycleDue(lastSuccess, restartedAt, 600_000, restartedAt), true)
|
|
49
|
-
})
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import test from 'node:test'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
MEMORY_STORE_FAULT_CODE,
|
|
6
|
-
MemoryStoreFault,
|
|
7
|
-
isStoreFault,
|
|
8
|
-
markStoreFault,
|
|
9
|
-
} from './memory-cycle2-shared.mjs'
|
|
10
|
-
|
|
11
|
-
test('a foreign error is never classified by its text', () => {
|
|
12
|
-
// The exact former marker text, now owned by nobody: a provider/DB error that
|
|
13
|
-
// happens to read this way must stay an ordinary, recoverable action error.
|
|
14
|
-
const lookalikeMessage = new Error('MemoryStoreFault: connection reset by peer')
|
|
15
|
-
assert.equal(isStoreFault(lookalikeMessage), false)
|
|
16
|
-
|
|
17
|
-
const lookalikeName = new Error('connection reset by peer')
|
|
18
|
-
lookalikeName.name = 'MemoryStoreFault'
|
|
19
|
-
assert.equal(isStoreFault(lookalikeName), false)
|
|
20
|
-
|
|
21
|
-
const lookalikeBoth = new Error('MemoryStoreFault: rollback')
|
|
22
|
-
lookalikeBoth.name = 'MemoryStoreFault:Error'
|
|
23
|
-
assert.equal(isStoreFault(lookalikeBoth), false)
|
|
24
|
-
|
|
25
|
-
// A half-claimed field is not a claim either.
|
|
26
|
-
const halfClaim = new Error('nope')
|
|
27
|
-
halfClaim.isMemoryStoreFault = true
|
|
28
|
-
assert.equal(isStoreFault(halfClaim), false)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
test('markStoreFault produces a typed fault and preserves the original', () => {
|
|
32
|
-
const original = new Error('rollback')
|
|
33
|
-
const fault = markStoreFault(original)
|
|
34
|
-
assert.ok(fault instanceof MemoryStoreFault)
|
|
35
|
-
assert.equal(isStoreFault(fault), true)
|
|
36
|
-
assert.equal(fault.code, MEMORY_STORE_FAULT_CODE)
|
|
37
|
-
// Message stays verbatim — it is not a classification channel.
|
|
38
|
-
assert.equal(fault.message, 'rollback')
|
|
39
|
-
assert.equal(fault.cause, original)
|
|
40
|
-
assert.equal(original.message, 'rollback')
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
test('frozen, sealed and non-Error inputs still yield a typed fault', () => {
|
|
44
|
-
const frozen = Object.freeze(new Error('commit ambiguous'))
|
|
45
|
-
const fromFrozen = markStoreFault(frozen)
|
|
46
|
-
assert.equal(isStoreFault(fromFrozen), true)
|
|
47
|
-
assert.equal(fromFrozen.cause, frozen)
|
|
48
|
-
assert.equal(frozen.message, 'commit ambiguous')
|
|
49
|
-
|
|
50
|
-
const sealed = Object.seal(new Error('sealed write'))
|
|
51
|
-
assert.equal(isStoreFault(markStoreFault(sealed)), true)
|
|
52
|
-
|
|
53
|
-
const fromString = markStoreFault('boom')
|
|
54
|
-
assert.equal(isStoreFault(fromString), true)
|
|
55
|
-
assert.equal(fromString.message, 'boom')
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
test('marking is idempotent and non-faults stay unclassified', () => {
|
|
59
|
-
const fault = markStoreFault(new Error('rollback'))
|
|
60
|
-
assert.equal(markStoreFault(fault), fault)
|
|
61
|
-
|
|
62
|
-
assert.equal(isStoreFault(new Error('guard mismatch')), false)
|
|
63
|
-
assert.equal(isStoreFault(null), false)
|
|
64
|
-
assert.equal(isStoreFault(undefined), false)
|
|
65
|
-
assert.equal(isStoreFault('MemoryStoreFault: not an error'), false)
|
|
66
|
-
assert.equal(isStoreFault({}), false)
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
test('an explicitly tagged cross-realm fault is recognised without instanceof', () => {
|
|
70
|
-
// Second copy of the module (different realm/registry): instanceof fails, the
|
|
71
|
-
// explicit field pair still classifies.
|
|
72
|
-
const crossRealm = Object.assign(new Error('rollback'), {
|
|
73
|
-
isMemoryStoreFault: true,
|
|
74
|
-
code: MEMORY_STORE_FAULT_CODE,
|
|
75
|
-
})
|
|
76
|
-
assert.equal(crossRealm instanceof MemoryStoreFault, false)
|
|
77
|
-
assert.equal(isStoreFault(crossRealm), true)
|
|
78
|
-
})
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict'
|
|
2
|
-
import test from 'node:test'
|
|
3
|
-
|
|
4
|
-
import { resetEmbeddingColumnsForModel } from './memory.mjs'
|
|
5
|
-
|
|
6
|
-
function mockDb({ entriesDims = 640, coreDims = 640, identityMatches = true } = {}) {
|
|
7
|
-
const execs = []
|
|
8
|
-
const queries = []
|
|
9
|
-
return {
|
|
10
|
-
execs,
|
|
11
|
-
queries,
|
|
12
|
-
async exec(sql) {
|
|
13
|
-
execs.push(sql)
|
|
14
|
-
},
|
|
15
|
-
async query(sql, params = []) {
|
|
16
|
-
queries.push({ sql, params })
|
|
17
|
-
if (sql.includes('FROM pg_attribute')) {
|
|
18
|
-
return { rows: [{ atttypmod: params[0] === 'entries' ? entriesDims : coreDims }] }
|
|
19
|
-
}
|
|
20
|
-
if (sql.includes('SELECT value = $2::jsonb')) {
|
|
21
|
-
return { rows: identityMatches ? [{ matches: true }] : [] }
|
|
22
|
-
}
|
|
23
|
-
return { rows: [] }
|
|
24
|
-
},
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const identity = { model: 'onnx-community/harrier-oss-v1-270m-ONNX', dtype: 'q4' }
|
|
29
|
-
|
|
30
|
-
test('matching embedding dimensions and identity keep stored vectors', async () => {
|
|
31
|
-
const db = mockDb()
|
|
32
|
-
assert.equal(await resetEmbeddingColumnsForModel(db, 640, identity), false)
|
|
33
|
-
assert.deepEqual(db.execs, [])
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
test('a model identity change invalidates vectors even at the same dimensions', async () => {
|
|
37
|
-
const db = mockDb({ identityMatches: false })
|
|
38
|
-
assert.equal(await resetEmbeddingColumnsForModel(db, 640, identity), true)
|
|
39
|
-
assert.ok(db.execs.some((sql) => sql.includes('UPDATE entries SET embedding = NULL')))
|
|
40
|
-
assert.ok(db.execs.some((sql) => sql.includes('UPDATE core_entries SET embedding = NULL')))
|
|
41
|
-
assert.ok(db.execs.some((sql) => sql.includes('DROP TABLE IF EXISTS memory.embedding_cache')))
|
|
42
|
-
assert.ok(db.queries.some(({ params }) => params[0] === 'embedding.current_model'))
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
test('a dimension change rebuilds both halfvec columns', async () => {
|
|
46
|
-
const db = mockDb({ entriesDims: 384, coreDims: 384 })
|
|
47
|
-
assert.equal(await resetEmbeddingColumnsForModel(db, 640, identity), true)
|
|
48
|
-
assert.ok(db.execs.some((sql) => sql.includes('ALTER TABLE entries ALTER COLUMN embedding TYPE halfvec(640)')))
|
|
49
|
-
assert.ok(db.execs.some((sql) => sql.includes('ALTER TABLE core_entries ALTER COLUMN embedding TYPE halfvec(640)')))
|
|
50
|
-
})
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
|
|
4
|
-
import { classifyOrphanTempPostmaster } from './process.mjs';
|
|
5
|
-
|
|
6
|
-
const tempRoot = process.platform === 'win32'
|
|
7
|
-
? 'C:/Users/test/AppData/Local/Temp'
|
|
8
|
-
: '/tmp';
|
|
9
|
-
const args = `"${tempRoot}/mixdog-headless-pristine-test/data/runtime/bin/postgres" `
|
|
10
|
-
+ `-D "${tempRoot}/mixdog-headless-pristine-test/data/pgdata"`;
|
|
11
|
-
|
|
12
|
-
test('old unowned temp postmasters are sweep candidates', () => {
|
|
13
|
-
assert.equal(classifyOrphanTempPostmaster({
|
|
14
|
-
args,
|
|
15
|
-
uptimeSec: 3600,
|
|
16
|
-
tempRoot,
|
|
17
|
-
ownerAlive: false,
|
|
18
|
-
}), true);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('a live owner protects a long-running temp postmaster', () => {
|
|
22
|
-
assert.equal(classifyOrphanTempPostmaster({
|
|
23
|
-
args,
|
|
24
|
-
uptimeSec: 3600,
|
|
25
|
-
tempRoot,
|
|
26
|
-
ownerAlive: true,
|
|
27
|
-
}), false);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('the official data directory is never a sweep candidate', () => {
|
|
31
|
-
assert.equal(classifyOrphanTempPostmaster({
|
|
32
|
-
args: 'postgres -D "/home/test/.mixdog/data/pgdata"',
|
|
33
|
-
uptimeSec: 3600,
|
|
34
|
-
tempRoot,
|
|
35
|
-
}), false);
|
|
36
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import { insertAgentCalls, insertTraceEvents } from './trace-store.mjs';
|
|
4
|
-
|
|
5
|
-
const toolError = {
|
|
6
|
-
ts: 1_786_000_000_000,
|
|
7
|
-
session_id: 'trace-error-test',
|
|
8
|
-
iteration: 3,
|
|
9
|
-
kind: 'tool',
|
|
10
|
-
tool_name: 'glob',
|
|
11
|
-
tool_kind: 'builtin',
|
|
12
|
-
tool_ms: 12,
|
|
13
|
-
tool_args: { pattern: '**/*.mjs' },
|
|
14
|
-
result_kind: 'error',
|
|
15
|
-
result_error_category: 'runtime/failure',
|
|
16
|
-
result_error_first_line: 'Error: diagnostic probe',
|
|
17
|
-
payload: {},
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
test('trace_events persists tool result metadata', async () => {
|
|
21
|
-
const calls = [];
|
|
22
|
-
const db = {
|
|
23
|
-
query: async (sql, params) => {
|
|
24
|
-
calls.push({ sql, params });
|
|
25
|
-
return { rowCount: 1, rows: [] };
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
await insertTraceEvents(db, [toolError]);
|
|
30
|
-
assert.equal(calls.length, 1);
|
|
31
|
-
const { sql, params } = calls[0];
|
|
32
|
-
const columns = sql.match(/trace_events \(([^)]+)\)/)?.[1].split(',').map((part) => part.trim()) || [];
|
|
33
|
-
assert.equal(params[columns.indexOf('result_kind')], 'error');
|
|
34
|
-
assert.equal(params[columns.indexOf('result_error_category')], 'runtime/failure');
|
|
35
|
-
assert.equal(params[columns.indexOf('result_error_first_line')], 'Error: diagnostic probe');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('agent_calls persists tool result metadata', async () => {
|
|
39
|
-
const calls = [];
|
|
40
|
-
const client = {
|
|
41
|
-
query: async (sql, params) => {
|
|
42
|
-
calls.push({ sql, params });
|
|
43
|
-
return { rowCount: 1, rows: [] };
|
|
44
|
-
},
|
|
45
|
-
release() {},
|
|
46
|
-
};
|
|
47
|
-
const db = { _pool: { connect: async () => client } };
|
|
48
|
-
|
|
49
|
-
const result = await insertAgentCalls(db, [toolError]);
|
|
50
|
-
assert.deepEqual(result, { calls: 1, llm: 0 });
|
|
51
|
-
const insert = calls.find(({ sql }) => sql.includes('INSERT INTO agent_calls'));
|
|
52
|
-
assert.ok(insert);
|
|
53
|
-
assert.match(insert.sql, /result_kind,result_error_category,result_error_first_line/);
|
|
54
|
-
assert.deepEqual(insert.params[7], ['error']);
|
|
55
|
-
assert.deepEqual(insert.params[8], ['runtime/failure']);
|
|
56
|
-
assert.deepEqual(insert.params[9], ['Error: diagnostic probe']);
|
|
57
|
-
});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict'
|
|
2
|
-
import { mkdtemp, mkdir, rm, writeFile } from 'node:fs/promises'
|
|
3
|
-
import { tmpdir } from 'node:os'
|
|
4
|
-
import path from 'node:path'
|
|
5
|
-
import test from 'node:test'
|
|
6
|
-
|
|
7
|
-
import { createTranscriptIngest } from './transcript-ingest.mjs'
|
|
8
|
-
|
|
9
|
-
test('transcript watcher initialization waits for the first active-session sweep', async () => {
|
|
10
|
-
const root = await mkdtemp(path.join(tmpdir(), 'mixdog-transcript-watch-'))
|
|
11
|
-
const projectDir = path.join(root, 'project')
|
|
12
|
-
const sessionId = 'sess_readiness_regression'
|
|
13
|
-
const transcriptPath = path.join(projectDir, `${sessionId}.jsonl`)
|
|
14
|
-
const inserts = []
|
|
15
|
-
let offsets = '{}'
|
|
16
|
-
let watcher = null
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
await mkdir(projectDir, { recursive: true })
|
|
20
|
-
await writeFile(transcriptPath, `${JSON.stringify({
|
|
21
|
-
type: 'user',
|
|
22
|
-
timestamp: new Date().toISOString(),
|
|
23
|
-
cwd: projectDir,
|
|
24
|
-
message: { content: 'persisted before memory readiness' },
|
|
25
|
-
})}\n`)
|
|
26
|
-
|
|
27
|
-
const ingest = createTranscriptIngest({
|
|
28
|
-
getDb: () => ({
|
|
29
|
-
async query(_sql, values) {
|
|
30
|
-
inserts.push(values)
|
|
31
|
-
return { rowCount: 1 }
|
|
32
|
-
},
|
|
33
|
-
}),
|
|
34
|
-
loadMeta: async () => offsets,
|
|
35
|
-
persistMeta: async (value) => { offsets = value },
|
|
36
|
-
projectsRoot: () => root,
|
|
37
|
-
resolveProjectId: () => 'project-readiness',
|
|
38
|
-
firstTextContent: (value) => String(value ?? ''),
|
|
39
|
-
cleanMemoryText: (value) => String(value ?? '').trim(),
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
await ingest.loadTranscriptOffsets()
|
|
43
|
-
watcher = await ingest.initTranscriptWatcher()
|
|
44
|
-
|
|
45
|
-
assert.equal(inserts.length, 1)
|
|
46
|
-
assert.equal(inserts[0][2], 'persisted before memory readiness')
|
|
47
|
-
assert.equal(inserts[0][4], sessionId)
|
|
48
|
-
} finally {
|
|
49
|
-
watcher?.stop()
|
|
50
|
-
await rm(root, { recursive: true, force: true })
|
|
51
|
-
}
|
|
52
|
-
})
|