0
Fork 0
mirror of https://github.com/mastra-ai/mastra.git synced 2026-11-17 08:44:46 +00:00
mastra/scripts/check-core-imports.ts
mastra-platform[bot] 353b4811df
test(libsql): port T81 recovered-history cross-process coverage (#27945)
Ports T81 using a real child process, shared LibSQL storage and
UNIX-socket pubsub. The original parks in a blocking tool; the
replacement confirms live-owner recovery is refused, waits for real
lease expiry while the original is SIGSTOPped, then recovers without
force. After SIGCONT and full original execution settlement, persisted
history must still contain exactly one replacement-authored final answer
with unchanged message IDs, ordering and content. Existing pause/resume
helpers are reused; only a test and fixture are added, with no runtime
changes or changeset.

Both durable and evented controls are enabled, as is durable recovery.
Evented recovery is explicitly skipped: one uninstrumented run stalled
in recover() before returning its stream (20s guard, repetition 8); 50
instrumented repeats passed without explaining it. The assertions remain
in-tree for re-enablement after diagnosis. This is not COR-1334
reproduction, a runtime fix, or proof that a stale write was attempted
and rejected.

Validation: 20 final uninstrumented fresh-process runs, each 3 passed /
1 explicitly skipped; 28 neighboring helper, ownership, T79 and T80
tests passed; temporary stale-overwrite and duplicate-answer negative
controls failed on the intended assertions for both engines and were
removed. Package tsc --noEmit, type-aware lint, formatting and git diff
--check pass. No orphan T81 peers or cross-process sockets remain.
Independent final reviews found no remaining must-fix issues.

Test command: pnpm --filter @mastra/libsql exec vitest run
src/__tests__/cross-process/xproc-recovered-original-write.test.ts

Related:
https://linear.app/kepler-crm/issue/COR-1444/port-t81-xproc-recovered-original-write-pause-and-resume-a-cross.
Records the in-tree port for COR-1388; does not close COR-1334. Evented
recovery coverage remains incomplete as documented above.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## ELI5

This PR adds a test that starts work in one process, pauses it, and
checks that another process can safely finish it after the first process
loses its lease. It confirms that the saved conversation has one correct
final answer and no duplicate messages.

## Changes

- Added the `t81-peer` cross-process fixture.
- Added durable LibSQL recovery coverage with:
  - A real child process.
  - Shared LibSQL storage.
  - UNIX-socket pubsub.
  - Lease-expiry handling.
  - `SIGSTOP` and resume behavior.
  - Message ID, order, content, and replacement-author checks.
- Added a control test for normal completion.
- Confirmed recovery is rejected while the original process still owns
the run.
- Skipped evented recovery because an instrumented setup stall remains
unresolved.
- Added no runtime changes or changeset.

## Validation

The PR reports passing results for:

- 20 fresh-process runs.
- 28 neighboring tests.
- Type checking.
- Linting.
- Formatting.
- Diff checks.

Validation command:

```bash
pnpm --filter @mastra/libsql exec vitest run src/__tests__/cross-process/xproc-recovered-original-write.test.ts
```

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: NikAiyer <nick.aiyer@gmail.com>
Co-authored-by: mastra-platform[bot] <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-10-21 10:20:41 -05:00

503 lines
16 KiB