mixdog 1.4.0 → 1.4.1

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.
Files changed (236) hide show
  1. package/package.json +1 -1
  2. package/scripts/check-voice-runtime-inputs.mjs +25 -0
  3. package/scripts/gate-local.mjs +12 -3
  4. package/scripts/latest-guard.mjs +21 -9
  5. package/scripts/lib/isolated-test-env.mjs +10 -5
  6. package/scripts/lib/run-node-tests.mjs +37 -37
  7. package/scripts/lib/scoped-temp.d.mts +16 -0
  8. package/scripts/lib/scoped-temp.mjs +123 -0
  9. package/scripts/lib/stale-temp.mjs +44 -0
  10. package/scripts/post-release-check.mjs +1 -6
  11. package/scripts/pptx-kit-index.mjs +17 -4
  12. package/scripts/suite-health.mjs +10 -1
  13. package/scripts/test-data-dir.mjs +10 -7
  14. package/src/app.mjs +4 -0
  15. package/src/defaults/shipped-history.json +5 -0
  16. package/src/defaults/skills/browser-use/SKILL.md +6 -4
  17. package/src/defaults/skills/computer-use/SKILL.md +4 -2
  18. package/src/lib/rules-builder.cjs +29 -12
  19. package/src/output-styles/common.md +2 -2
  20. package/src/output-styles/simple.md +1 -1
  21. package/src/rules/agent/AGENT.md +5 -4
  22. package/src/rules/lead/LEAD.md +10 -5
  23. package/src/rules/shared/10-tool-workflow.md +3 -1
  24. package/src/rules/shared/45-destructive.md +0 -2
  25. package/src/rules/shared/50-execution.md +2 -0
  26. package/src/rules/shared/70-delivery.md +7 -9
  27. package/src/runtime/agent/orchestrator/agent-runtime/agent-progress-watchdog.mjs +29 -6
  28. package/src/runtime/agent/orchestrator/cache-break-trace.mjs +2 -0
  29. package/src/runtime/agent/orchestrator/context/deferred-tools.mjs +1 -1
  30. package/src/runtime/agent/orchestrator/context/skill-catalog.mjs +3 -1
  31. package/src/runtime/agent/orchestrator/mcp/oauth-login.mjs +5 -2
  32. package/src/runtime/agent/orchestrator/providers/account-pool.mjs +11 -0
  33. package/src/runtime/agent/orchestrator/providers/anthropic-api-recovery.mjs +1 -1
  34. package/src/runtime/agent/orchestrator/providers/anthropic-api-request.mjs +7 -3
  35. package/src/runtime/agent/orchestrator/providers/anthropic-api-transport.mjs +8 -2
  36. package/src/runtime/agent/orchestrator/providers/anthropic-max-tokens-recovery.mjs +6 -2
  37. package/src/runtime/agent/orchestrator/providers/anthropic-messages.mjs +2 -2
  38. package/src/runtime/agent/orchestrator/providers/anthropic-oauth-request/initial-status.mjs +3 -1
  39. package/src/runtime/agent/orchestrator/providers/anthropic-oauth.mjs +14 -3
  40. package/src/runtime/agent/orchestrator/providers/anthropic-sse.mjs +6 -0
  41. package/src/runtime/agent/orchestrator/providers/anthropic-turn-result.mjs +2 -2
  42. package/src/runtime/agent/orchestrator/providers/command-code-oauth-login.mjs +1 -10
  43. package/src/runtime/agent/orchestrator/providers/cursor.mjs +3 -0
  44. package/src/runtime/agent/orchestrator/providers/devin-wire-transport.mjs +1 -1
  45. package/src/runtime/agent/orchestrator/providers/devin.mjs +3 -0
  46. package/src/runtime/agent/orchestrator/providers/grok-oauth-login.mjs +210 -20
  47. package/src/runtime/agent/orchestrator/providers/lib/anthropic-prefix-trace.mjs +76 -11
  48. package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +45 -6
  49. package/src/runtime/agent/orchestrator/providers/lib/first-output-window.mjs +58 -0
  50. package/src/runtime/agent/orchestrator/providers/lib/listen-on.mjs +14 -0
  51. package/src/runtime/agent/orchestrator/providers/mimo-oauth-login.mjs +1 -10
  52. package/src/runtime/agent/orchestrator/providers/openai-compat-chat-send.mjs +1 -0
  53. package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/chunk-events.mjs +9 -2
  54. package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/stream-state.mjs +7 -0
  55. package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream.mjs +14 -3
  56. package/src/runtime/agent/orchestrator/providers/openai-compat-responses-events.mjs +4 -2
  57. package/src/runtime/agent/orchestrator/providers/openai-compat-responses.mjs +1 -0
  58. package/src/runtime/agent/orchestrator/providers/openai-compat-stream-common.mjs +5 -3
  59. package/src/runtime/agent/orchestrator/providers/openai-compat-stream.mjs +16 -3
  60. package/src/runtime/agent/orchestrator/providers/openai-compat-xai-send.mjs +1 -0
  61. package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-events/output-items.mjs +5 -2
  62. package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-events.mjs +13 -3
  63. package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state.mjs +13 -2
  64. package/src/runtime/agent/orchestrator/providers/openai-http-sse-watchdogs.mjs +81 -42
  65. package/src/runtime/agent/orchestrator/providers/openai-oauth-http-sse.mjs +8 -0
  66. package/src/runtime/agent/orchestrator/providers/openai-oauth-login.mjs +136 -5
  67. package/src/runtime/agent/orchestrator/providers/openai-ws-stream/event-switch.mjs +20 -12
  68. package/src/runtime/agent/orchestrator/providers/openai-ws-stream.mjs +7 -1
  69. package/src/runtime/agent/orchestrator/providers/openai-ws-watchdogs.mjs +48 -22
  70. package/src/runtime/agent/orchestrator/providers/registry.mjs +12 -0
  71. package/src/runtime/agent/orchestrator/runtime-core/ask-user-tool-defs.mjs +41 -13
  72. package/src/runtime/agent/orchestrator/runtime-core/orchestration.mjs +7 -6
  73. package/src/runtime/agent/orchestrator/runtime-core/session-text.mjs +7 -3
  74. package/src/runtime/agent/orchestrator/runtime-core/tool-defs.mjs +3 -1
  75. package/src/runtime/agent/orchestrator/runtime-core/workflow.mjs +5 -2
  76. package/src/runtime/agent/orchestrator/session/cache/scoped-cache.mjs +1 -3
  77. package/src/runtime/agent/orchestrator/session/cache-warm.mjs +8 -2
  78. package/src/runtime/agent/orchestrator/session/catalog-db/schema.mjs +4 -1
  79. package/src/runtime/agent/orchestrator/session/compact/execution-tail.mjs +1 -8
  80. package/src/runtime/agent/orchestrator/session/compact/messages.mjs +23 -0
  81. package/src/runtime/agent/orchestrator/session/compact/observation-supersession.mjs +103 -23
  82. package/src/runtime/agent/orchestrator/session/compact/runner.mjs +160 -36
  83. package/src/runtime/agent/orchestrator/session/context-utils.mjs +13 -1
  84. package/src/runtime/agent/orchestrator/session/conversation-import/claude.mjs +163 -22
  85. package/src/runtime/agent/orchestrator/session/conversation-import/codex.mjs +132 -17
  86. package/src/runtime/agent/orchestrator/session/conversation-import/convert.mjs +38 -7
  87. package/src/runtime/agent/orchestrator/session/conversation-import/imported-session.mjs +3 -0
  88. package/src/runtime/agent/orchestrator/session/conversation-import/turns.mjs +90 -22
  89. package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +33 -3
  90. package/src/runtime/agent/orchestrator/session/loop/fresh-context.mjs +7 -2
  91. package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +1 -1
  92. package/src/runtime/agent/orchestrator/session/loop/provider-tool-exclusions.mjs +13 -5
  93. package/src/runtime/agent/orchestrator/session/loop/route-fallback.mjs +14 -0
  94. package/src/runtime/agent/orchestrator/session/loop/send-phase.mjs +13 -1
  95. package/src/runtime/agent/orchestrator/session/loop/tool-exec/before-hook.mjs +2 -2
  96. package/src/runtime/agent/orchestrator/session/loop/tool-exposure-migration.mjs +39 -21
  97. package/src/runtime/agent/orchestrator/session/manager/ask-turn-loop-options.mjs +3 -3
  98. package/src/runtime/agent/orchestrator/session/manager/ask-turn-settle.mjs +3 -1
  99. package/src/runtime/agent/orchestrator/session/manager/owner-route-fallbacks.mjs +2 -2
  100. package/src/runtime/agent/orchestrator/session/manager/route-fallback-chain.mjs +2 -1
  101. package/src/runtime/agent/orchestrator/session/manager/rules-cache.mjs +27 -9
  102. package/src/runtime/agent/orchestrator/session/manager/runtime-liveness.mjs +61 -6
  103. package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +19 -8
  104. package/src/runtime/agent/orchestrator/session/manager/session-prompt-composition.mjs +12 -5
  105. package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +3 -3
  106. package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-context.mjs +4 -0
  107. package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint.mjs +3 -0
  108. package/src/runtime/agent/orchestrator/session/manager/turn-interruption.mjs +9 -0
  109. package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +5 -1
  110. package/src/runtime/agent/orchestrator/session/prompt-cache-touch-store.mjs +30 -7
  111. package/src/runtime/agent/orchestrator/session/restart-prefix-parity.fixture.mjs +154 -0
  112. package/src/runtime/agent/orchestrator/session/store/session-delete.mjs +7 -0
  113. package/src/runtime/agent/orchestrator/session/store-summary-catalog.mjs +4 -0
  114. package/src/runtime/agent/orchestrator/session/store-summary-fields.mjs +15 -0
  115. package/src/runtime/agent/orchestrator/session/store-summary-index.mjs +37 -8
  116. package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +9 -1
  117. package/src/runtime/agent/orchestrator/session/transcript-restore/restore.mjs +61 -2
  118. package/src/runtime/agent/orchestrator/stall-policy.mjs +23 -0
  119. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/invocation-plan.mjs +2 -2
  120. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/spawn-env.mjs +4 -2
  121. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +6 -1
  122. package/src/runtime/agent/orchestrator/tools/builtin/builtin-tools.mjs +46 -20
  123. package/src/runtime/agent/orchestrator/tools/builtin/cache-layers.mjs +7 -1
  124. package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.mjs +31 -5
  125. package/src/runtime/agent/orchestrator/tools/builtin/git-worktree-tool.mjs +22 -8
  126. package/src/runtime/agent/orchestrator/tools/builtin/lib/scoped-search-flight.mjs +9 -5
  127. package/src/runtime/agent/orchestrator/tools/builtin/read-single-stream.mjs +7 -1
  128. package/src/runtime/agent/orchestrator/tools/builtin/read-streaming.mjs +6 -3
  129. package/src/runtime/agent/orchestrator/tools/builtin/read-tool/batch-dispatch.mjs +1 -1
  130. package/src/runtime/agent/orchestrator/tools/builtin/read-tool/batch-publication.mjs +23 -12
  131. package/src/runtime/agent/orchestrator/tools/builtin/read-tool/batch-snapshot.mjs +6 -1
  132. package/src/runtime/agent/orchestrator/tools/builtin/read-tool.mjs +1 -8
  133. package/src/runtime/agent/orchestrator/tools/code-graph/dispatch/federation.mjs +3 -1
  134. package/src/runtime/agent/orchestrator/tools/code-graph-tool-defs.mjs +1 -1
  135. package/src/runtime/agent/orchestrator/tools/graph-manifest.json +13 -13
  136. package/src/runtime/agent/orchestrator/tools/lib/isolated-test-env.mjs +4 -3
  137. package/src/runtime/agent/orchestrator/tools/lib/shell-warm-standby.mjs +26 -4
  138. package/src/runtime/channels/lib/webhook/signature.mjs +4 -1
  139. package/src/runtime/channels/lib/whisper-port.mjs +10 -1
  140. package/src/runtime/computer-bridge/action-schema.mjs +2 -2
  141. package/src/runtime/computer-bridge/core-actions.mjs +2 -2
  142. package/src/runtime/computer-bridge/error-recovery.mjs +5 -4
  143. package/src/runtime/computer-bridge/linux-action-capabilities.mjs +24 -5
  144. package/src/runtime/computer-bridge/linux-readiness.d.mts +7 -2
  145. package/src/runtime/local-provider/server-process.mjs +2 -1
  146. package/src/runtime/media/adapters/gemini-video.mjs +4 -1
  147. package/src/runtime/media/adapters/xai-media.mjs +2 -1
  148. package/src/runtime/memory/lib/embedding-worker.mjs +6 -3
  149. package/src/runtime/memory/lib/memory-action-handlers/cycle-backfill-action.mjs +1 -7
  150. package/src/runtime/memory/lib/memory-chunk-quality.mjs +1 -6
  151. package/src/runtime/office/authoring/pdf-author-action.mjs +1 -6
  152. package/src/runtime/office/design/design-art-direction.mjs +29 -27
  153. package/src/runtime/office/pdf/pdf-writer.mjs +6 -1
  154. package/src/runtime/office/portable/portable-snapshot-docx.mjs +7 -1
  155. package/src/runtime/office/portable/portable-snapshot-shared.mjs +6 -1
  156. package/src/runtime/office/quality/assurance-rendered.mjs +9 -2
  157. package/src/runtime/office/quality/assurance-structure-docx.mjs +3 -1
  158. package/src/runtime/office/quality/design-review.mjs +1 -5
  159. package/src/runtime/office/quality/document-brief.mjs +1 -5
  160. package/src/runtime/office/quality/forced-break-pages.mjs +9 -6
  161. package/src/runtime/office/quality/quality-pipeline.mjs +1 -1
  162. package/src/runtime/shared/bot-owned-work.mjs +56 -0
  163. package/src/runtime/shared/defaults-separation.mjs +1 -4
  164. package/src/runtime/shared/fetch-safe-listen.d.mts +16 -0
  165. package/src/runtime/shared/fetch-safe-listen.mjs +50 -0
  166. package/src/runtime/shared/handoff-artifacts.d.mts +2 -1
  167. package/src/runtime/shared/handoff-artifacts.mjs +18 -8
  168. package/src/runtime/shared/idle-auto-clear-gate.mjs +29 -7
  169. package/src/runtime/shared/llm/cost.mjs +5 -1
  170. package/src/runtime/shared/loopback-listener.mjs +25 -2
  171. package/src/runtime/shared/model-route-chain.d.mts +7 -2
  172. package/src/runtime/shared/model-route-chain.mjs +22 -4
  173. package/src/runtime/shared/open-url.mjs +10 -0
  174. package/src/runtime/shared/session-activity-signal.mjs +14 -0
  175. package/src/runtime/shared/session-scratch.mjs +37 -0
  176. package/src/runtime/shared/tool-card-model/agent-surface.mjs +1 -3
  177. package/src/runtime/shared/tool-card-model/card-status.mjs +15 -2
  178. package/src/runtime/shared/tool-result-summary.mjs +1 -1
  179. package/src/runtime/shared/tool-surface.mjs +3 -0
  180. package/src/runtime/shared/tool-work-units.mjs +2 -0
  181. package/src/runtime/shared/turn-snapshot-store.mjs +13 -6
  182. package/src/runtime/shared/worktrees/contract.mjs +4 -1
  183. package/src/runtime/shared/worktrees/git.mjs +15 -0
  184. package/src/runtime/shared/worktrees/manager.mjs +87 -38
  185. package/src/runtime/shared/worktrees/test-support.mjs +6 -10
  186. package/src/runtime/visualize-bridge/client.mjs +2 -0
  187. package/src/session-runtime/agent-home-delivery.mjs +41 -0
  188. package/src/session-runtime/agent-task-sessions.mjs +152 -63
  189. package/src/session-runtime/agent-tool-routing.mjs +8 -41
  190. package/src/session-runtime/boot/tools.mjs +5 -1
  191. package/src/session-runtime/bot-status.mjs +12 -6
  192. package/src/session-runtime/bot-target.mjs +38 -0
  193. package/src/session-runtime/channel-config-api.mjs +6 -1
  194. package/src/session-runtime/conversation-import/codex-titles.mjs +88 -0
  195. package/src/session-runtime/conversation-import/discovery.mjs +271 -25
  196. package/src/session-runtime/conversation-import/service.mjs +26 -5
  197. package/src/session-runtime/handoff-attachments.mjs +82 -31
  198. package/src/session-runtime/internal-tool-executor/ask-user-tool.mjs +12 -13
  199. package/src/session-runtime/internal-tool-executor/bridge-tools.mjs +1 -0
  200. package/src/session-runtime/internal-tool-executor/reaction-tool.mjs +4 -1
  201. package/src/session-runtime/internal-tool-executor/workspace-tools.mjs +8 -2
  202. package/src/session-runtime/lifecycle/cold-heir.mjs +11 -6
  203. package/src/session-runtime/lifecycle/session-catalog.mjs +9 -1
  204. package/src/session-runtime/model-route/set-route.mjs +11 -2
  205. package/src/session-runtime/provider-catalog-cache.mjs +82 -36
  206. package/src/session-runtime/provider-models/catalog-load.mjs +23 -6
  207. package/src/session-runtime/provider-models.mjs +4 -2
  208. package/src/session-runtime/resource-recall-api.mjs +6 -1
  209. package/src/session-runtime/runtime-feature-gates.mjs +5 -1
  210. package/src/session-runtime/services/agent-tool/execute.mjs +14 -9
  211. package/src/session-runtime/services/agent-tool/job-views/agent-list.mjs +20 -4
  212. package/src/session-runtime/services/agent-tool/model-select.mjs +48 -7
  213. package/src/session-runtime/services/agent-tool/render.mjs +71 -17
  214. package/src/session-runtime/services/agent-tool/spawn-preset.mjs +6 -2
  215. package/src/session-runtime/services/agent-tool/tool-def.mjs +9 -9
  216. package/src/session-runtime/services/provider-admin.mjs +2 -1
  217. package/src/session-runtime/tool-policy/policy-stage.mjs +1 -0
  218. package/src/session-runtime/workflow-agents-api/agent-editor.mjs +5 -1
  219. package/src/session-runtime/workflow-agents-api/agent-route.mjs +15 -4
  220. package/src/session-runtime/workflow-agents-api/onboarding.mjs +3 -3
  221. package/src/session-runtime/workspace/transitions.mjs +25 -0
  222. package/src/session-runtime/workspace/worktree-tool.mjs +26 -9
  223. package/src/standalone/daemon-session-control.mjs +18 -2
  224. package/src/standalone/session-service/agent-tree/agent-turns.mjs +16 -12
  225. package/src/standalone/session-service/session-calls/session-action.mjs +10 -3
  226. package/src/standalone/session-transport/client-registry/client-grace.mjs +12 -9
  227. package/src/tui/app/app-view/floating-panel.jsx +7 -4
  228. package/src/tui/app/model-picker/route-selection/fast-parameters.mjs +1 -3
  229. package/src/tui/app/model-picker/route-selection.mjs +5 -6
  230. package/src/tui/app/provider-setup/oauth-actions.mjs +38 -20
  231. package/src/tui/app/provider-setup/provider-items.mjs +8 -2
  232. package/src/tui/app/provider-setup-picker.mjs +9 -5
  233. package/src/tui/components/QuestionPanel.jsx +13 -4
  234. package/src/tui/dist/index.mjs +75 -28
  235. package/src/tui/session/session-flow/queue/take-entries.mjs +11 -0
  236. package/src/ui/statusline-agents.mjs +1 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mixdog",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Open-source coding agent that matches Codex on Terminal-Bench 2.1 with 63% fewer tokens.",
@@ -0,0 +1,25 @@
1
+ // Release Gate guard for the immutable voice runtime release. Deploy reuses the
2
+ // published runtime only while the build-input hash of the checkout matches it,
3
+ // so a change to any hash input (scripts/voice-runtime-config.json, the build
4
+ // scripts and workflow, generate-voice-runtime-manifest.mjs) without a
5
+ // runtimeVersion bump fails here on push instead of stopping a live Deploy.
6
+ // A formatter pass that only re-indents those files counts as a change.
7
+ // Run it on a Linux checkout: the hash covers the files as checked out there.
8
+ import { readFile } from 'node:fs/promises';
9
+
10
+ import {
11
+ VOICE_RUNTIME_VERSION,
12
+ assertVoiceRuntimeManifestIdentity,
13
+ compareSemver,
14
+ } from './generate-voice-runtime-manifest.mjs';
15
+
16
+ const bundled = JSON.parse(
17
+ await readFile(new URL('../src/runtime/channels/data/voice-runtime-manifest.json', import.meta.url), 'utf8')
18
+ );
19
+
20
+ if (compareSemver(VOICE_RUNTIME_VERSION, bundled.version) > 0) {
21
+ console.log(`voice runtime ${VOICE_RUNTIME_VERSION} is not released yet; Deploy builds it`);
22
+ } else {
23
+ await assertVoiceRuntimeManifestIdentity(bundled);
24
+ console.log(`voice runtime ${bundled.version} build inputs match the published runtime`);
25
+ }
@@ -21,6 +21,7 @@ import os from 'node:os';
21
21
  import path from 'node:path';
22
22
  import { fileURLToPath } from 'node:url';
23
23
  import { gateTestBudget, runGateLegs } from './lib/gate-scheduler.mjs';
24
+ import { pruneStaleTempDirs, removeTempDirSync } from './lib/stale-temp.mjs';
24
25
 
25
26
  const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
26
27
  const started = Date.now();
@@ -47,8 +48,15 @@ if (build.status !== 0) {
47
48
  process.exit(1);
48
49
  }
49
50
 
50
- const logDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mixdog-gate-local-'));
51
- const resourceDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mixdog-gate-resources-'));
51
+ // Each run owns its log directory, so concurrent runs never touch each other's
52
+ // logs and the paths the summary prints stay valid after any outcome. Log
53
+ // directories are kept until they go stale; a resources directory a killed
54
+ // run left behind goes the same way. Both are swept at start.
55
+ const LOG_PREFIX = 'mixdog-gate-local-';
56
+ const RESOURCE_PREFIX = 'mixdog-gate-resources-';
57
+ pruneStaleTempDirs([LOG_PREFIX, RESOURCE_PREFIX]);
58
+ const logDir = fs.mkdtempSync(path.join(os.tmpdir(), LOG_PREFIX));
59
+ const resourceDir = fs.mkdtempSync(path.join(os.tmpdir(), RESOURCE_PREFIX));
52
60
  const budget = gateTestBudget();
53
61
  // weight: relative worker share, roughly each leg's measured duration x its 3 workers
54
62
  // (runtime ~440s, runtime-slow ~545s, desktop fast ~390s, desktop slow ~280s).
@@ -66,6 +74,7 @@ function runCmd(cmd, logFd, concurrency) {
66
74
  const child = spawn(cmd, {
67
75
  cwd: root,
68
76
  shell: true,
77
+ windowsHide: true,
69
78
  stdio: ['ignore', logFd, logFd],
70
79
  env: {
71
80
  ...process.env,
@@ -99,7 +108,7 @@ try {
99
108
  await runLeg(legs.at(-1), budget);
100
109
  await runGateLegs(legs.slice(0, -1), budget, runLeg);
101
110
  } finally {
102
- fs.rmSync(resourceDir, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });
111
+ removeTempDirSync(resourceDir);
103
112
  }
104
113
 
105
114
  console.log('\n=== gate:local summary ===');
@@ -17,10 +17,20 @@ function report(text) {
17
17
  }
18
18
 
19
19
  function openIssue(repo, body) {
20
- const existing = JSON.parse(gh([
21
- 'issue', 'list', '--repo', repo, '--state', 'open', '--search', `"${ISSUE_TITLE}" in:title`,
22
- '--json', 'number,title',
23
- ])).find((issue) => issue.title === ISSUE_TITLE);
20
+ const existing = JSON.parse(
21
+ gh([
22
+ 'issue',
23
+ 'list',
24
+ '--repo',
25
+ repo,
26
+ '--state',
27
+ 'open',
28
+ '--search',
29
+ `"${ISSUE_TITLE}" in:title`,
30
+ '--json',
31
+ 'number,title',
32
+ ])
33
+ ).find((issue) => issue.title === ISSUE_TITLE);
24
34
  if (existing) {
25
35
  gh(['issue', 'comment', String(existing.number), '--repo', repo, '--body', body]);
26
36
  return `commented on issue #${existing.number}`;
@@ -44,11 +54,13 @@ export function main(repo = process.env.GITHUB_REPOSITORY) {
44
54
  const problem = `GitHub Latest was \`${actual ?? 'none'}\` but the newest published app release is \`${expected.tag_name}\`.`;
45
55
  gh(['release', 'edit', expected.tag_name, '--repo', repo, '--latest']);
46
56
  const repaired = currentLatestTag(repo);
47
- const outcome = repaired === expected.tag_name
48
- ? `Set Latest back to \`${expected.tag_name}\`.`
49
- : `Could not set Latest to \`${expected.tag_name}\`; it is now \`${repaired ?? 'none'}\`.`;
50
- const detail = `${problem}\n${outcome}\n\nWorkflow run: ${process.env.GITHUB_SERVER_URL ?? ''}/${repo}/actions/runs/${process.env.GITHUB_RUN_ID ?? ''}\n`
51
- + 'Check which release or workflow published a non-app release without `--latest=false` / `make_latest: false`.';
57
+ const outcome =
58
+ repaired === expected.tag_name
59
+ ? `Set Latest back to \`${expected.tag_name}\`.`
60
+ : `Could not set Latest to \`${expected.tag_name}\`; it is now \`${repaired ?? 'none'}\`.`;
61
+ const detail =
62
+ `${problem}\n${outcome}\n\nWorkflow run: ${process.env.GITHUB_SERVER_URL ?? ''}/${repo}/actions/runs/${process.env.GITHUB_RUN_ID ?? ''}\n` +
63
+ 'Check which release or workflow published a non-app release without `--latest=false` / `make_latest: false`.';
52
64
  report(`## Latest release guard\n${detail}`);
53
65
  try {
54
66
  report(`Issue: ${openIssue(repo, detail)}.`);
@@ -2,15 +2,20 @@
2
2
  // evaluates imports in order) so the data/home dirs resolve to a scratch dir
3
3
  // before any module under test reads them, even under plain `node --test` from a
4
4
  // shell that exports the signed-in profile's MIXDOG_DATA_DIR.
5
- import { mkdtempSync, rmSync } from 'node:fs';
5
+ import { mkdtempSync } from 'node:fs';
6
6
  import { tmpdir } from 'node:os';
7
7
  import { join } from 'node:path';
8
+ import { registerOwnedTempDir } from './scoped-temp.mjs';
9
+ import { pruneStaleTempDirs, removeTempDirSync } from './stale-temp.mjs';
8
10
 
9
- const root = mkdtempSync(join(tmpdir(), 'mixdog-test-profile-'));
11
+ // The exit handler below never runs for a killed process, so each start sweeps
12
+ // what earlier killed processes left.
13
+ const PREFIX = 'mixdog-test-profile-';
14
+ pruneStaleTempDirs([PREFIX]);
15
+ const root = mkdtempSync(join(tmpdir(), PREFIX));
16
+ registerOwnedTempDir(root);
10
17
  process.env.MIXDOG_DATA_DIR = join(root, 'data');
11
18
  process.env.MIXDOG_HOME = join(root, 'home');
12
19
  process.on('exit', () => {
13
- try {
14
- rmSync(root, { recursive: true, force: true });
15
- } catch {}
20
+ removeTempDirSync(root);
16
21
  });
@@ -1,8 +1,9 @@
1
1
  import { spawn } from 'node:child_process';
2
- import { appendFile, mkdtemp, readdir, readFile, rm, stat } from 'node:fs/promises';
2
+ import { appendFile, mkdtemp, readFile, rm } from 'node:fs/promises';
3
3
  import { availableParallelism, tmpdir } from 'node:os';
4
4
  import { join } from 'node:path';
5
5
  import { setTimeout as delay } from 'node:timers/promises';
6
+ import { pruneStaleTempDirs } from './stale-temp.mjs';
6
7
  import { FAILURE_RECORDS_ENV, spawnLedgerPath } from './test-failure-records.mjs';
7
8
  import { classifyRerunOutcomes, formatFailureSummary } from './test-failure-summary.mjs';
8
9
 
@@ -20,28 +21,14 @@ const HEAP_FLAG = /^--(?:max-old-space-size|max-semi-space-size)=\d+$/;
20
21
  // An argument costs its own characters plus the separator and its quotes.
21
22
  const argCost = (arg) => arg.length + 3;
22
23
 
23
- // Full logs are kept for reading after the run; older ones are stale.
24
+ // A green run removes its log directory; a failed run keeps it (the failure
25
+ // summary points at it) until the start-of-run prune finds it stale. The
26
+ // failure and scratch directories are removed when their run ends, so only a
27
+ // killed runner leaves them for that same prune.
24
28
  const TEST_LOG_PREFIX = 'mixdog-test-output-';
25
- const TEST_LOG_RETENTION_MS = 3 * 24 * 60 * 60 * 1000;
26
-
27
- async function pruneStaleTestLogs(root) {
28
- let names = [];
29
- try {
30
- names = await readdir(root);
31
- } catch {
32
- return;
33
- }
34
- const cutoff = Date.now() - TEST_LOG_RETENTION_MS;
35
- for (const name of names) {
36
- if (!name.startsWith(TEST_LOG_PREFIX)) continue;
37
- const path = join(root, name);
38
- try {
39
- if ((await stat(path)).mtimeMs < cutoff) await rm(path, { recursive: true, force: true });
40
- } catch {
41
- /* another run may own or be removing it */
42
- }
43
- }
44
- }
29
+ const TEST_FAILURES_PREFIX = 'mixdog-test-failures-';
30
+ const TEST_SCRATCH_PREFIX = 'mixdog-test-scratch-';
31
+ export const RUNNER_TEMP_PREFIXES = [TEST_LOG_PREFIX, TEST_FAILURES_PREFIX, TEST_SCRATCH_PREFIX];
45
32
 
46
33
  // Batches keep the file order Node was given; a single path larger than the
47
34
  // budget still gets its own batch rather than being dropped. An empty list
@@ -331,14 +318,14 @@ function spawnBatch(args, env, { files, ledger, scratchDir, timeoutMs }) {
331
318
  // rm's own maxRetries re-walks the tree on every nested retry, so one held
332
319
  // file a few directories down multiplied its delay into hours. Each pass here
333
320
  // is a single bounded walk.
334
- async function removeScratch(dir) {
321
+ async function removeTempDir(dir) {
335
322
  for (let attempt = 1; ; attempt += 1) {
336
323
  try {
337
324
  await rm(dir, { recursive: true, force: true });
338
325
  return;
339
326
  } catch (error) {
340
327
  if (attempt === 5) {
341
- console.error(`Test scratch left behind (${error.code}): ${dir}`);
328
+ console.error(`Test temp dir left behind (${error.code}): ${dir}`);
342
329
  return;
343
330
  }
344
331
  await delay(200 * attempt);
@@ -372,21 +359,37 @@ async function readFailureRecords(path) {
372
359
  // log can still name what failed.
373
360
  //
374
361
  // `testTimeoutMs` is the per-file --test-timeout default (see testTimeoutArg).
375
- export async function runNodeTests(
376
- nodeArgs,
377
- fileArgs,
378
- { argBudget = ARG_BUDGET, coverage = false, rerunFailed = 0, testTimeoutMs = DEFAULT_TEST_TIMEOUT_MS } = {}
379
- ) {
380
- await pruneStaleTestLogs(tmpdir());
381
- const logPath = join(await mkdtemp(join(tmpdir(), TEST_LOG_PREFIX)), 'full.log');
362
+ export async function runNodeTests(nodeArgs, fileArgs, options = {}) {
363
+ pruneStaleTempDirs(RUNNER_TEMP_PREFIXES);
364
+ const outputDir = await mkdtemp(join(tmpdir(), TEST_LOG_PREFIX));
365
+ const logPath = join(outputDir, 'full.log');
382
366
  console.error(`Full test log: ${logPath}`);
383
367
  // Failure records live outside the log directory: the log directory holds
384
368
  // exactly one merged log, and these records are an internal artifact.
385
- const failureDir = await mkdtemp(join(tmpdir(), 'mixdog-test-failures-'));
369
+ const failureDir = await mkdtemp(join(tmpdir(), TEST_FAILURES_PREFIX));
386
370
  // Test processes get a private temp root that is removed after the run, so
387
371
  // every fixture directory a test forgets to delete goes with it instead of
388
372
  // piling up in the system temp directory.
389
- const scratchDir = await mkdtemp(join(tmpdir(), 'mixdog-test-scratch-'));
373
+ const scratchDir = await mkdtemp(join(tmpdir(), TEST_SCRATCH_PREFIX));
374
+ let status = 1;
375
+ try {
376
+ status = await executeRun(nodeArgs, fileArgs, options, { logPath, failureDir, scratchDir });
377
+ } finally {
378
+ await removeTempDir(failureDir);
379
+ // Leftover processes are already killed; what a process outside the run
380
+ // still holds stays behind.
381
+ await removeTempDir(scratchDir);
382
+ // A throw keeps the log too: the run did not pass.
383
+ if (status === 0) await removeTempDir(outputDir);
384
+ }
385
+ }
386
+
387
+ async function executeRun(
388
+ nodeArgs,
389
+ fileArgs,
390
+ { argBudget = ARG_BUDGET, coverage = false, rerunFailed = 0, testTimeoutMs = DEFAULT_TEST_TIMEOUT_MS },
391
+ { logPath, failureDir, scratchDir }
392
+ ) {
390
393
  // The explicit entry also accepts Node options alongside its file paths.
391
394
  const concurrencyArg = testConcurrencyArg([...nodeArgs, ...fileArgs]);
392
395
  const timeoutArg = testTimeoutArg([...nodeArgs, ...fileArgs], process.env, testTimeoutMs);
@@ -509,10 +512,6 @@ export async function runNodeTests(
509
512
  status = 0;
510
513
  process.exitCode = status;
511
514
 
512
- await rm(failureDir, { recursive: true, force: true });
513
- // Leftover processes are already killed; what a process outside the run
514
- // still holds stays behind.
515
- await removeScratch(scratchDir);
516
515
  if (coverageDir) {
517
516
  const { reportCoverage } = await import('./coverage.mjs');
518
517
  await reportCoverage(coverageDir);
@@ -520,4 +519,5 @@ export async function runNodeTests(
520
519
  }
521
520
  // Last line of the run, after every reporter and the coverage report.
522
521
  process.stdout.write(`\n${formatFailureSummary({ failed, flaky, rerunFailed, hung, exitCode: status })}`);
522
+ return status;
523
523
  }
@@ -0,0 +1,16 @@
1
+ export function makeTempDirSync(prefix: string): string;
2
+ export function registerOwnedTempDir(dir: string): string;
3
+ export function redirectSystemTemp(prefix?: string): string;
4
+ export function removeTempDirSync(dir: string): void;
5
+ export function removeTempDir(dir: string): Promise<void>;
6
+ export function tempDirFor(t: { after(fn: () => unknown): void }, prefix: string): string;
7
+ export interface ScopedTempDir {
8
+ path: string;
9
+ join(...parts: string[]): string;
10
+ remove(): Promise<void>;
11
+ removeSync(): void;
12
+ [Symbol.asyncDispose](): Promise<void>;
13
+ [Symbol.dispose](): void;
14
+ }
15
+ export function scopedTempDir(prefix: string): ScopedTempDir;
16
+ export function withTempDir<T>(prefix: string, fn: (dir: string) => T | Promise<T>): Promise<T>;
@@ -0,0 +1,123 @@
1
+ // Scoped scratch directories for tests: every directory this module creates is
2
+ // named `mixdog-<prefix>-*` in the system temp dir and is removed whether the
3
+ // test passed or failed. Removal retries a bounded number of times, because on
4
+ // Windows a just-closed file or a just-exited child can hold a path for a
5
+ // moment (EBUSY / EPERM / ENOTEMPTY).
6
+ //
7
+ // Pick the narrowest scope that fits the test:
8
+ // tempDirFor(t, prefix) removed after the node:test context `t`
9
+ // scopedTempDir(prefix) `.path` + dispose; use `await using` on
10
+ // Node 24+, or `try { } finally { await d.remove() }`
11
+ // withTempDir(prefix, fn) removed when `fn` settles
12
+ // makeTempDirSync(prefix) removed by removeTempDirSync, and always swept at
13
+ // process exit (a late write may recreate it)
14
+ // Close anything holding files inside the directory (sqlite handles, servers,
15
+ // child processes) before the removal runs.
16
+ import { mkdtempSync } from 'node:fs';
17
+ import { tmpdir } from 'node:os';
18
+ import { basename, dirname, join, resolve } from 'node:path';
19
+ import { removeTempDirSync as removeDirWithRetrySync } from './stale-temp.mjs';
20
+
21
+ const live = new Set();
22
+ let exitHookInstalled = false;
23
+
24
+ function directoryPrefix(prefix) {
25
+ const bare = String(prefix)
26
+ .replace(/^mixdog-/, '')
27
+ .replace(/-+$/, '');
28
+ return `mixdog-${bare}-`;
29
+ }
30
+
31
+ function removeAllAtExit() {
32
+ for (const dir of live) removeDirWithRetrySync(dir);
33
+ }
34
+
35
+ function installExitHook() {
36
+ if (exitHookInstalled) return;
37
+ exitHookInstalled = true;
38
+ process.on('exit', removeAllAtExit);
39
+ // A module under test may add its own exit handler (a final flush can
40
+ // recreate its directory), so keep this one the last to run.
41
+ process.on('newListener', (event, listener) => {
42
+ if (event !== 'exit' || listener === removeAllAtExit) return;
43
+ queueMicrotask(() => {
44
+ process.removeListener('exit', removeAllAtExit);
45
+ process.on('exit', removeAllAtExit);
46
+ });
47
+ });
48
+ }
49
+
50
+ /** Creates `mixdog-<prefix>-*` in the system temp dir; removed at process exit unless removed sooner. */
51
+ export function makeTempDirSync(prefix) {
52
+ const dir = mkdtempSync(join(tmpdir(), directoryPrefix(prefix)));
53
+ live.add(dir);
54
+ installExitHook();
55
+ return dir;
56
+ }
57
+
58
+ /**
59
+ * Registers a directory its creator made as test-owned, so it is swept again
60
+ * as the last exit step (a late write by the code under test can recreate it
61
+ * after the creator's own exit handler ran). Only an exact `mixdog-*` child of
62
+ * the system temp dir is accepted; nothing is ever inferred from an env var.
63
+ */
64
+ export function registerOwnedTempDir(dir) {
65
+ const resolved = resolve(dir);
66
+ const same = (a, b) => (process.platform === 'win32' ? a.toLowerCase() === b.toLowerCase() : a === b);
67
+ if (!basename(resolved).startsWith('mixdog-') || !same(dirname(resolved), resolve(tmpdir()))) {
68
+ throw new Error(`refusing to own a directory outside the system temp root: ${dir}`);
69
+ }
70
+ live.add(resolved);
71
+ installExitHook();
72
+ return resolved;
73
+ }
74
+ /**
75
+ * For code under test that makes its own mixdog-* directories in the system
76
+ * temp dir: points TEMP/TMP/TMPDIR at one scoped directory for the rest of the
77
+ * process, so everything created there is removed with it at exit.
78
+ */
79
+ export function redirectSystemTemp(prefix = 'temp-root') {
80
+ const dir = makeTempDirSync(prefix);
81
+ process.env.TEMP = dir;
82
+ process.env.TMP = dir;
83
+ process.env.TMPDIR = dir;
84
+ return dir;
85
+ }
86
+
87
+ export function removeTempDirSync(dir) {
88
+ if (!removeDirWithRetrySync(dir)) process.stderr.write(`scratch folder ${dir} could not be removed\n`);
89
+ }
90
+
91
+ export async function removeTempDir(dir) {
92
+ removeTempDirSync(dir);
93
+ }
94
+
95
+ /** A directory removed after the node:test context (test or suite) `t` finishes, pass or fail. */
96
+ export function tempDirFor(t, prefix) {
97
+ const dir = makeTempDirSync(prefix);
98
+ t.after(() => removeTempDir(dir));
99
+ return dir;
100
+ }
101
+
102
+ /** A directory with `.path`, `join()` and `remove()`; also `await using` / `using` disposable. */
103
+ export function scopedTempDir(prefix) {
104
+ const path = makeTempDirSync(prefix);
105
+ return {
106
+ path,
107
+ join: (...parts) => join(path, ...parts),
108
+ remove: () => removeTempDir(path),
109
+ removeSync: () => removeTempDirSync(path),
110
+ [Symbol.asyncDispose]: () => removeTempDir(path),
111
+ [Symbol.dispose]: () => removeTempDirSync(path),
112
+ };
113
+ }
114
+
115
+ /** Runs `fn(dir)` with a fresh directory and removes it when `fn` settles. */
116
+ export async function withTempDir(prefix, fn) {
117
+ const dir = makeTempDirSync(prefix);
118
+ try {
119
+ return await fn(dir);
120
+ } finally {
121
+ await removeTempDir(dir);
122
+ }
123
+ }
@@ -0,0 +1,44 @@
1
+ // Temp dirs a test run or the local gate owns. A normal exit removes them, but
2
+ // a killed process runs no exit handler, so each run starts by sweeping what an
3
+ // earlier killed run left behind.
4
+ import { lstatSync, readdirSync, rmSync } from 'node:fs';
5
+ import { tmpdir } from 'node:os';
6
+ import { join } from 'node:path';
7
+
8
+ // How long a kept test log stays readable; also what counts as a leftover.
9
+ export const STALE_TEMP_MS = 3 * 24 * 60 * 60 * 1000;
10
+
11
+ // rmSync retries the lock errors itself (EBUSY, EPERM, ENOTEMPTY, ...) a
12
+ // bounded number of times per entry before it throws. Returns whether the
13
+ // directory is gone; a held file leaves it for the next start-of-run sweep.
14
+ export function removeTempDirSync(dir) {
15
+ try {
16
+ rmSync(dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
17
+ return true;
18
+ } catch {
19
+ return false;
20
+ }
21
+ }
22
+
23
+ // Removes every directory in `root` whose name starts with one of `prefixes`
24
+ // and whose mtime is older than `maxAgeMs`.
25
+ export function pruneStaleTempDirs(prefixes, { root = tmpdir(), maxAgeMs = STALE_TEMP_MS, now = Date.now() } = {}) {
26
+ let names = [];
27
+ try {
28
+ names = readdirSync(root);
29
+ } catch {
30
+ return;
31
+ }
32
+ const cutoff = now - maxAgeMs;
33
+ for (const name of names) {
34
+ if (!prefixes.some((prefix) => name.startsWith(prefix))) continue;
35
+ const path = join(root, name);
36
+ try {
37
+ // lstat: a link or a plain file that merely matches the prefix is not ours to remove.
38
+ const info = lstatSync(path);
39
+ if (info.isDirectory() && info.mtimeMs < cutoff) removeTempDirSync(path);
40
+ } catch {
41
+ /* another run may own or be removing it */
42
+ }
43
+ }
44
+ }
@@ -215,12 +215,7 @@ export function getReleaseByTag(repo, tag, run = gh) {
215
215
  * rethrown, so an API outage fails the job instead of silently skipping
216
216
  * verification of a release that may be public.
217
217
  */
218
- export async function detectPublished({
219
- fetchRelease,
220
- sleep = defaultSleep,
221
- attempts = 5,
222
- firstDelayMs = 2000,
223
- }) {
218
+ export async function detectPublished({ fetchRelease, sleep = defaultSleep, attempts = 5, firstDelayMs = 2000 }) {
224
219
  let delay = firstDelayMs;
225
220
  for (let attempt = 1; ; attempt++) {
226
221
  try {
@@ -22,7 +22,11 @@ const SOURCES = [
22
22
  const WHOLE_STATEMENT = 240;
23
23
 
24
24
  const propertyName = (property) =>
25
- property.type === 'Property' ? String(property.key.name ?? property.key.value ?? '') : property.type === 'SpreadElement' ? '…' : '';
25
+ property.type === 'Property'
26
+ ? String(property.key.name ?? property.key.value ?? '')
27
+ : property.type === 'SpreadElement'
28
+ ? '…'
29
+ : '';
26
30
 
27
31
  // The keys an object literal offers a script, one level into object-valued keys ("body: { x, y, w, h }"). A table of
28
32
  // like entries (STYLES: an id per style, each with the same fields) reads as its ids and the fields each carries.
@@ -30,7 +34,9 @@ function objectShape(node) {
30
34
  const properties = node.properties.filter((property) => propertyName(property));
31
35
  const nested = properties.filter((property) => property.value?.type === 'ObjectExpression');
32
36
  if (properties.length >= 4 && nested.length === properties.length) {
33
- const fields = [...new Set(nested.flatMap((property) => property.value.properties.map(propertyName)))].filter(Boolean);
37
+ const fields = [...new Set(nested.flatMap((property) => property.value.properties.map(propertyName)))].filter(
38
+ Boolean
39
+ );
34
40
  return `{ ${properties.map(propertyName).join(', ')} } each { ${fields.join(', ')} }`;
35
41
  }
36
42
  const keys = properties.map((property) =>
@@ -48,7 +54,8 @@ function returnedShape(fn) {
48
54
  const visit = (node) => {
49
55
  if (!node || typeof node.type !== 'string') return;
50
56
  if (node !== fn.body && /Function/.test(node.type)) return;
51
- if (node.type === 'ReturnStatement' && node.argument?.type === 'ObjectExpression') shapes.push(objectShape(node.argument));
57
+ if (node.type === 'ReturnStatement' && node.argument?.type === 'ObjectExpression')
58
+ shapes.push(objectShape(node.argument));
52
59
  for (const value of Object.values(node)) {
53
60
  if (Array.isArray(value)) value.forEach(visit);
54
61
  else if (value && typeof value === 'object' && typeof value.type === 'string') visit(value);
@@ -116,7 +123,13 @@ function summarizeFile({ file, prose }) {
116
123
  output.push('```js', summarizeCode(part).trimEnd(), '```');
117
124
  return;
118
125
  }
119
- const kept = prose === 'all' ? part.trim() : part.split('\n').filter((line) => /^#{1,3} /.test(line)).join('\n');
126
+ const kept =
127
+ prose === 'all'
128
+ ? part.trim()
129
+ : part
130
+ .split('\n')
131
+ .filter((line) => /^#{1,3} /.test(line))
132
+ .join('\n');
120
133
  if (kept) output.push(kept.replace(/^# /m, '## '));
121
134
  });
122
135
  return [`# ${file}`, ...output].join('\n\n');
@@ -59,6 +59,13 @@ export function selectSuiteScripts(scripts, exclusions) {
59
59
  return names.filter((name) => !(name in exclusions));
60
60
  }
61
61
 
62
+ const lastLines = (text) =>
63
+ String(text || '')
64
+ .trim()
65
+ .split('\n')
66
+ .slice(-25)
67
+ .join('\n');
68
+
62
69
  function runSweep() {
63
70
  const failures = [];
64
71
  const reportLines = [];
@@ -79,7 +86,9 @@ function runSweep() {
79
86
  reportLines.push(`- ${label}: OK (${seconds}s)`);
80
87
  console.log(`${label}: OK (${seconds}s)`);
81
88
  } else {
82
- const tail = `${child.stdout || ''}\n${child.stderr || ''}`.trim().split('\n').slice(-25).join('\n');
89
+ // Tail each stream on its own: a long stderr (cargo build chatter) must
90
+ // not push the test failure summary on stdout out of the report.
91
+ const tail = `${lastLines(child.stdout)}\n${lastLines(child.stderr)}`.trim();
83
92
  failures.push(`- ${label}: FAILED (${seconds}s)\n\n\`\`\`\n${tail}\n\`\`\``);
84
93
  reportLines.push(`- ${label}: FAILED (${seconds}s)`);
85
94
  console.error(`${label}: FAILED (${seconds}s)\n${tail}`);
@@ -1,19 +1,22 @@
1
1
  // Side-effect module: import FIRST in tests that touch the read-snapshot store.
2
2
  // Points the Mixdog data dir at a per-run temp dir before snapshot-store.mjs
3
3
  // resolves SNAPSHOT_DIR at module load, so tests never write to the real one.
4
- import { mkdtempSync, rmSync } from 'node:fs';
4
+ import { mkdtempSync } from 'node:fs';
5
5
  import { tmpdir } from 'node:os';
6
6
  import { join } from 'node:path';
7
+ import { registerOwnedTempDir } from './lib/scoped-temp.mjs';
8
+ import { pruneStaleTempDirs, removeTempDirSync } from './lib/stale-temp.mjs';
7
9
 
8
10
  if (!process.env.MIXDOG_TEST_DATA_DIR_OWNED) {
9
- const dir = mkdtempSync(join(tmpdir(), 'mixdog-test-data-'));
11
+ // The exit handler never runs for a killed process, so each start sweeps
12
+ // what earlier killed processes left.
13
+ const prefix = 'mixdog-test-data-';
14
+ pruneStaleTempDirs([prefix]);
15
+ const dir = mkdtempSync(join(tmpdir(), prefix));
16
+ registerOwnedTempDir(dir);
10
17
  process.env.MIXDOG_DATA_DIR = dir;
11
18
  process.env.MIXDOG_TEST_DATA_DIR_OWNED = '1';
12
19
  process.on('exit', () => {
13
- try {
14
- rmSync(dir, { recursive: true, force: true });
15
- } catch {
16
- /* best effort */
17
- }
20
+ removeTempDirSync(dir);
18
21
  });
19
22
  }
package/src/app.mjs CHANGED
@@ -24,6 +24,10 @@ export { parseHeadlessExecCommand };
24
24
  * running behavior will NOT match the tree, so warn loudly.
25
25
  */
26
26
  function warnWhenTuiBundleStale(bundle) {
27
+ // Only a source checkout can drift from its bundle: src/tui/dev is left out
28
+ // of the npm package, and an npm install stamps every file with its own
29
+ // extraction time, so the mtime comparison below would misfire there.
30
+ if (!existsSync(join(__dirname, 'tui', 'dev', 'jit-rebuild.mjs'))) return;
27
31
  try {
28
32
  const bundleMtime = statSync(bundle).mtimeMs;
29
33
  const hotSources = [
@@ -114,6 +114,7 @@
114
114
  "3f5915d27c7659ad82cdbda064acfbfa",
115
115
  "4e6134d60ee5c54c2888e874653bcdad",
116
116
  "4ecd89b0c07ad8a81aa1f84882cf1b00",
117
+ "88ac40e616f4c181583c35e591c32952",
117
118
  "899529696b7d6d3373ae83a76976ab48",
118
119
  "8d343d0a406fd5817b7fd98a3ac47010",
119
120
  "a1b73ce404125d3ce0a5762e4a1e1555",
@@ -163,6 +164,7 @@
163
164
  "simple.md": [
164
165
  "07c197ff8f20e24c65d844cd91711216",
165
166
  "16d8b5e7757001c614dae62f18f63aa1",
167
+ "2d33871a37ab8672ea550c6bfb4ba64d",
166
168
  "56b61d99f3179018f65b530d9b1491d7",
167
169
  "6e1749aa66d4416cadad4bcd26eb807a",
168
170
  "75ca4c5ec12866b2052a6d08b023759d",
@@ -180,6 +182,7 @@
180
182
  "00085086a7649ec6631f5cf0a3bbbf60",
181
183
  "08eee52328524eb032fd14f342742c41",
182
184
  "25a6744e7591ea5597abbda008d123fe",
185
+ "2e536962f4ff0b8f8028141050c7e7ab",
183
186
  "43eeb0b9c5792f08f2223c76846926cb",
184
187
  "4ab5316454013712cedb25d9b75f4e43",
185
188
  "4f042de090d853ed38aaa82b88d301ac",
@@ -232,6 +235,7 @@
232
235
  "8236330f56f27dd283bda6da1239285d",
233
236
  "8bc93c9320b83de81baa8cf242af5c0b",
234
237
  "8fe64c8f6d81bee2120134adf0d6a471",
238
+ "9d5afe7dfa82ea3f4c627f71ccdca331",
235
239
  "9e7a48df5065f5073bbab6f9db3e4061",
236
240
  "b46617cc619e09c35b6bad8f6177e722",
237
241
  "c2b0c50791e358064e22be87bdab4707",
@@ -329,6 +333,7 @@
329
333
  "48247c1645fd94aad7711082d4512c49",
330
334
  "4f94016363acccd788a724a2d414744e",
331
335
  "56e474f78faafae39aebe921ccff112d",
336
+ "5bd2e944160a64669a3e2f09466590b3",
332
337
  "60a1e22fd0c32aa283c64a2cc05b7889",
333
338
  "6358ad25dd07a2f92ad65c249a4f360b",
334
339
  "7fb12aeb07b79ae113c0deb0a90c6da7",