[GH-ISSUE #1466] [Issue]: Long-Term Memory: 75 strict TypeScript errors with no gate, and a typecheck script that passes without tsc #745

Closed
opened 2026-10-20 17:30:20 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @Promansis on GitHub (Oct 19, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1466

Originally assigned to: @SpicyMarinara, @Promansis on GitHub.

Summary

Long-Term Memory has 44 strict TypeScript errors in its server and shared code and 31 in its client code, and nothing gates them. The server and shared count is the same 44 errors it had at 1.4.8. Three of them point at real failure modes that no current caller reaches. Separately, scripts/typecheck-packages.mjs reports success when tsc cannot be started.

Affected package

long-term-memory 1.4.53 (upstream/staging 2a3c37bb2), and scripts/typecheck-packages.mjs.

  • S = packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory
  • H = packages/long-term-memory/src/engine/packages/shared/src/features/agents/long-term-memory
  • C = packages/long-term-memory/src/engine/packages/client/src/features/long-term-memory

Expected behavior

  • The LTM server, shared and client files typecheck cleanly under strict tsc with the Engine's dependency types, and CI keeps them at zero.
  • typecheck-packages.mjs fails when it cannot run tsc.

Actual behavior

Server and shared: 44 errors (shared 0).

By folder Errors
extraction 20
persistence 8
sources 6
drafts 5
identity 5
  • 41 are type-only, from 22 root causes. One annotation, : LtmMode on DEFAULT_LTM_IMPORTED_SOURCE_MODE at H/constants.ts:9, clears 12. The rest are annotations, literal narrowing and 2–3 small value changes that match what the schema default already produces at runtime.
  • 3 are latent bugs:
    • S/extraction/source-extraction.ts:312 and S/extraction/candidate-reconciliation.ts:134 pass an optional root to retrieveLongTermMemory, which needs one. An undefined root reaches path.resolve(undefined) in the vault lock and throws ERR_INVALID_ARG_TYPE. Every production entry point (routes/notes.ts, sources/interop.ts) passes runtime.root today.
    • S/identity/subject-identity.ts:658: a cast hides entries whose aliases is a Set<string> being stored where string[] is declared. Today's readers use only subject.key and sourceScope.

Client: 31 errors, from about 9 root causes. Narrowing ambiguousLinkDetails() clears 8, typing the useInfiniteQuery pages clears 4, the scope and sample unions clear 11, and lib ES2023 (the Engine client's setting) clears 2.

Flags. Only strictNullChecks (21 server errors) and noImplicitAny (2) matter; 21 errors need no strict flag at all. Phasing in strictNullChecks first does not help: alone it gives 49. strict: false is not a usable floor, because zod 3 needs strictNullChecks for correct z.infer types.

Script. typecheck-packages.mjs:100-101 treats any execFileSync failure as compiler output. When node_modules/.bin/tsc is missing, the error is ENOENT with no stdout or stderr, the output is empty, and the script prints "no syntax errors, undefined names or unresolved modules" and exits 0. CI runs npm ci first, so CI is not affected; a fresh worktree is.

Steps to reproduce

  1. Build the same overlay as typecheck-packages.mjs, then link the Engine's node_modules into it so zod, fastify, @types/node, react, @tanstack/react-query and lucide-react resolve.
  2. Run tsc --noEmit --skipLibCheck --jsx react-jsx --target es2022 --module esnext --moduleResolution bundler --strict --types node over the LTM server and shared files, and separately over the client files. Do not filter the diagnostics.
  3. For the script: run node scripts/typecheck-packages.mjs long-term-memory in a worktree without node_modules. It prints success.

Without the Engine's dependency types the same strict run reports 1,015 mostly spurious errors and hides 27 of the 44 real ones.

Minimal fix

Two PRs. Fix to zero, then gate at zero; staging the gate by flag buys nothing.

PR 1: server, shared, script and gate (patch bump)

  • scripts/typecheck-packages.mjs: fail when tsc cannot be spawned (an error.code such as ENOENT, or no output and no exit status).
  • Fix the 44 server and shared errors, starting with H/constants.ts:9.
  • Latent items: make root required on the two extraction paths, since every caller already passes it, and store aliases as an array at S/identity/subject-identity.ts:658.
  • Gate: extend typecheck-packages.mjs rather than adding a script. When an Engine root is provided, link its node_modules into the overlay and, for an opt-in strict-clean package list (long-term-memory first), report every diagnostic unfiltered with types: ["node"] (about 4 s). Run it in .github/workflows/ltm-browser.yml, which already checks out Engine staging and installs its dependencies (about +10 s). pull-request-checks.yml has no Engine checkout.
  • CHANGELOG under ## Unreleased: one bullet for the latent fixes.

PR 2: client

  • Fix the 31 client errors and add a second strict tsc run for the client files with lib: ["ES2023", "DOM", "DOM.Iterable"] (about 5.5 s).

If the gate must land before the fixes: use a checked-in baseline keyed by file, TS code and message, not line numbers (#1464 moved every line). Fail on any new key, and fail when a baselined key disappears without the baseline shrinking. A count-only ratchet would let a new error hide behind a fixed one.

Not included: other packages in typecheck:packages. They can opt in later.

Caveat: an Engine staging dependency bump can turn the gate red without an Agents change, as the browser regression already can.

Regression proof

  • The strict gate itself, at zero, for server and shared (PR 1) and client (PR 2).
  • typecheck-packages.mjs exits non-zero when tsc is missing: a small regression that runs it against a tree without node_modules.
  • The latent root fix is a type change; the existing extraction regressions keep passing.

Environment

  • Marinara Engine version: 2.5.0 line (staging 2039583ca)
  • Package version: long-term-memory 1.4.53 (upstream/staging 2a3c37bb2); also 1.4.8 (4eee7a26e) for the baseline
  • Install type: source
  • OS + version: not platform-specific; tsc 6.0.3, Node 24.15.0
  • Browser or app shell: n/a

Logs, screenshots, or video

Strict run timing: server and shared 3.4–4.2 s, client 5.0–5.8 s.

Additional context

Tracker item RT-5 (runtime architecture audit, step 7: add a strict tsc job). The 44-error baseline from 1.4.8 was re-run against 1.4.8 and 2a3c37bb2; the errors are identical apart from line numbers and folders after #1464.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Oct 19, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1466 Originally assigned to: @SpicyMarinara, @Promansis on GitHub. ## Summary Long-Term Memory has 44 strict TypeScript errors in its server and shared code and 31 in its client code, and nothing gates them. The server and shared count is the same 44 errors it had at 1.4.8. Three of them point at real failure modes that no current caller reaches. Separately, `scripts/typecheck-packages.mjs` reports success when `tsc` cannot be started. ## Affected package `long-term-memory` 1.4.53 (`upstream/staging` 2a3c37bb2), and `scripts/typecheck-packages.mjs`. - `S` = `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory` - `H` = `packages/long-term-memory/src/engine/packages/shared/src/features/agents/long-term-memory` - `C` = `packages/long-term-memory/src/engine/packages/client/src/features/long-term-memory` ## Expected behavior - The LTM server, shared and client files typecheck cleanly under strict `tsc` with the Engine's dependency types, and CI keeps them at zero. - `typecheck-packages.mjs` fails when it cannot run `tsc`. ## Actual behavior **Server and shared: 44 errors** (shared 0). | By folder | Errors | |---|---| | `extraction` | 20 | | `persistence` | 8 | | `sources` | 6 | | `drafts` | 5 | | `identity` | 5 | - 41 are type-only, from 22 root causes. One annotation, `: LtmMode` on `DEFAULT_LTM_IMPORTED_SOURCE_MODE` at `H/constants.ts:9`, clears 12. The rest are annotations, literal narrowing and 2–3 small value changes that match what the schema default already produces at runtime. - 3 are latent bugs: - `S/extraction/source-extraction.ts:312` and `S/extraction/candidate-reconciliation.ts:134` pass an optional `root` to `retrieveLongTermMemory`, which needs one. An undefined root reaches `path.resolve(undefined)` in the vault lock and throws `ERR_INVALID_ARG_TYPE`. Every production entry point (`routes/notes.ts`, `sources/interop.ts`) passes `runtime.root` today. - `S/identity/subject-identity.ts:658`: a cast hides entries whose `aliases` is a `Set<string>` being stored where `string[]` is declared. Today's readers use only `subject.key` and `sourceScope`. **Client: 31 errors**, from about 9 root causes. Narrowing `ambiguousLinkDetails()` clears 8, typing the `useInfiniteQuery` pages clears 4, the scope and sample unions clear 11, and `lib` ES2023 (the Engine client's setting) clears 2. **Flags.** Only `strictNullChecks` (21 server errors) and `noImplicitAny` (2) matter; 21 errors need no strict flag at all. Phasing in `strictNullChecks` first does not help: alone it gives 49. `strict: false` is not a usable floor, because zod 3 needs `strictNullChecks` for correct `z.infer` types. **Script.** `typecheck-packages.mjs:100-101` treats any `execFileSync` failure as compiler output. When `node_modules/.bin/tsc` is missing, the error is ENOENT with no stdout or stderr, the output is empty, and the script prints "no syntax errors, undefined names or unresolved modules" and exits 0. CI runs `npm ci` first, so CI is not affected; a fresh worktree is. ## Steps to reproduce 1. Build the same overlay as `typecheck-packages.mjs`, then link the Engine's `node_modules` into it so zod, fastify, `@types/node`, react, `@tanstack/react-query` and lucide-react resolve. 2. Run `tsc --noEmit --skipLibCheck --jsx react-jsx --target es2022 --module esnext --moduleResolution bundler --strict --types node` over the LTM server and shared files, and separately over the client files. Do not filter the diagnostics. 3. For the script: run `node scripts/typecheck-packages.mjs long-term-memory` in a worktree without `node_modules`. It prints success. Without the Engine's dependency types the same strict run reports 1,015 mostly spurious errors and hides 27 of the 44 real ones. ## Minimal fix Two PRs. Fix to zero, then gate at zero; staging the gate by flag buys nothing. **PR 1: server, shared, script and gate (patch bump)** - `scripts/typecheck-packages.mjs`: fail when `tsc` cannot be spawned (an `error.code` such as ENOENT, or no output and no exit status). - Fix the 44 server and shared errors, starting with `H/constants.ts:9`. - Latent items: make `root` required on the two extraction paths, since every caller already passes it, and store `aliases` as an array at `S/identity/subject-identity.ts:658`. - Gate: extend `typecheck-packages.mjs` rather than adding a script. When an Engine root is provided, link its `node_modules` into the overlay and, for an opt-in strict-clean package list (long-term-memory first), report every diagnostic unfiltered with `types: ["node"]` (about 4 s). Run it in `.github/workflows/ltm-browser.yml`, which already checks out Engine staging and installs its dependencies (about +10 s). `pull-request-checks.yml` has no Engine checkout. - CHANGELOG under `## Unreleased`: one bullet for the latent fixes. **PR 2: client** - Fix the 31 client errors and add a second strict `tsc` run for the client files with `lib: ["ES2023", "DOM", "DOM.Iterable"]` (about 5.5 s). **If the gate must land before the fixes:** use a checked-in baseline keyed by file, TS code and message, not line numbers (#1464 moved every line). Fail on any new key, and fail when a baselined key disappears without the baseline shrinking. A count-only ratchet would let a new error hide behind a fixed one. **Not included:** other packages in `typecheck:packages`. They can opt in later. **Caveat:** an Engine staging dependency bump can turn the gate red without an Agents change, as the browser regression already can. ## Regression proof - The strict gate itself, at zero, for server and shared (PR 1) and client (PR 2). - `typecheck-packages.mjs` exits non-zero when `tsc` is missing: a small regression that runs it against a tree without `node_modules`. - The latent `root` fix is a type change; the existing extraction regressions keep passing. ## Environment - Marinara Engine version: 2.5.0 line (`staging` 2039583ca) - Package version: long-term-memory 1.4.53 (`upstream/staging` 2a3c37bb2); also 1.4.8 (4eee7a26e) for the baseline - Install type: source - OS + version: not platform-specific; `tsc` 6.0.3, Node 24.15.0 - Browser or app shell: n/a ## Logs, screenshots, or video Strict run timing: server and shared 3.4–4.2 s, client 5.0–5.8 s. ## Additional context Tracker item RT-5 (runtime architecture audit, step 7: add a strict `tsc` job). The 44-error baseline from 1.4.8 was re-run against 1.4.8 and 2a3c37bb2; the errors are identical apart from line numbers and folders after #1464. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:30:20 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Oct 19, 2026):

@Promansis the maintainer asked us to land this for the upcoming release, so both parts are in one PR: Pasta-Devs/Marinara-Agents#1473 (separate commits for the script and server/shared fix and gate, the client fix and second strict run, and the 1.4.55 rebuild).

  • typecheck-packages.mjs now fails when tsc exits with no status or prints nothing. A new regression runs it without node_modules.
  • With MARINARA_ENGINE_ROOT set, it links the Engine's node_modules and runs unfiltered --strict --types node over the LTM server and shared files, then over the client files with ES2023, DOM, DOM.Iterable. ltm-browser.yml runs it as its last steps.
  • Both strict runs are at zero. Against unchanged staging the same gate reports 44 and 29 (31 without the ES2023 lib).
  • Latent fixes as you proposed: root is required on the extraction paths, and aliases is stored as an array in subject-identity.ts.

Built against Engine staging a2e3f13d8, which reproduces 1.4.53 byte for byte.

<!-- gh-comment-id:6264468954 --> @SpicyMarinara commented on GitHub (Oct 19, 2026): @Promansis the maintainer asked us to land this for the upcoming release, so both parts are in one PR: Pasta-Devs/Marinara-Agents#1473 (separate commits for the script and server/shared fix and gate, the client fix and second strict run, and the 1.4.55 rebuild). - `typecheck-packages.mjs` now fails when tsc exits with no status or prints nothing. A new regression runs it without `node_modules`. - With `MARINARA_ENGINE_ROOT` set, it links the Engine's `node_modules` and runs unfiltered `--strict --types node` over the LTM server and shared files, then over the client files with `ES2023, DOM, DOM.Iterable`. `ltm-browser.yml` runs it as its last steps. - Both strict runs are at zero. Against unchanged staging the same gate reports 44 and 29 (31 without the ES2023 lib). - Latent fixes as you proposed: `root` is required on the extraction paths, and `aliases` is stored as an array in `subject-identity.ts`. Built against Engine staging a2e3f13d8, which reproduces 1.4.53 byte for byte.
Author
Owner

@SpicyMarinara commented on GitHub (Oct 19, 2026):

Fixed on staging by #1473.

<!-- gh-comment-id:6266203108 --> @SpicyMarinara commented on GitHub (Oct 19, 2026): Fixed on staging by #1473.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Agents#745
No description provided.