Skip to content

fix(memory,mcp): add migration 111 + real Zod schemas for substrate dispatch tools - #198

Closed
KooshaPari wants to merge 1 commit into
mainfrom
fix/typecheck-errors
Closed

KooshaPari wants to merge 1 commit into
mainfrom
fix/typecheck-errors

Conversation

@KooshaPari

@KooshaPari KooshaPari commented Jul 2, 2026 •

Copy link
Copy Markdown
Owner

Rebased onto current origin/main. PR #196 already resolved the shared 19 typecheck errors; this PR is now reduced to the two changes that #196 left as latent runtime bugs:

  1. src/lib/db/migrations/111_memory_typed_decay.sql — main's src/lib/memory/store.ts reads/writes access_count and last_accessed_at (9 references) but no migration on main creates those columns (max migration was 107). Without this, memory access-tracking SQL throws no such column at runtime. Adds the two columns (TV6 typed-decay telemetry, default-off).

  2. open-sse/mcp-server/tools/dispatchTools.ts — the 3 substrate tools declared inputSchema as a plain JSON-schema object literal, but server.ts calls inputSchema.parse(). fix(typecheck): resolve 20 remaining type errors #196 silenced the type error with as unknown as z.ZodTypeAny, but a plain object has no .parse() method, so the tools would crash on first invocation. Converts them to real z.object({...}) schemas (satisfies Hard Rule chore(OmniRoute): hygiene cleanup #7: validate inputs with Zod) so .parse() works at runtime.

Verified npm run typecheck:core = 0 errors on the rebased branch.

Post-merge type/export skew across 6 subsystems (typecheck:core now clean):

- executors: re-export mergeAbortSignals from base.ts barrel so ./antigravity
  keeps resolving it (extracted leaf lost its barrel re-export in the merge).
- translator: add missing GEMINI_CLI member to FORMATS (responseTranslator
  branches on it).
- memory: restore TV6 access telemetry dropped by the merge — access_count /
  last_accessed_at columns (migration 111), accessCount/lastAccessedAt on the
  Memory rows, createMemory Omit, and the recordMemoryAccess export retrieval.ts
  depends on.
- combos: add first-class ComboModelStep.allowedConnectionIds (diegosouzapw#3266) parsed in
  normalizeComboStep; let normalizeStoredCombo return the narrowed ComboRecord
  shape so getComboById/getComboByName type-check.
- mcp dispatch: type substrate dispatchTools inputSchema as real Zod schemas so
  server.registerTool accepts them and .parse() is valid.
- types/validation: drop stale re-exports with no backing member
  (ProviderConnection/ProviderNode, ValidationResult).
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@KooshaPari, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 1 second

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c777e61c-ad12-411b-8152-ec07e0cf8123

📥 Commits

Reviewing files that changed from the base of the PR and between 45c8bb2 and b2e777b.

📒 Files selected for processing (10)
  • open-sse/executors/base.ts
  • open-sse/mcp-server/server.ts
  • open-sse/mcp-server/tools/dispatchTools.ts
  • open-sse/translator/formats.ts
  • src/lib/combos/steps.ts
  • src/lib/db/combos.ts
  • src/lib/db/migrations/111_memory_typed_decay.sql
  • src/lib/memory/store.ts
  • src/shared/validation/schemas.ts
  • src/types/index.ts

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key: "review"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/typecheck-errors

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@KooshaPari

Copy link
Copy Markdown
Owner Author

Superseded by #196 which merged the same typecheck fixes. Main is now at 0 typecheck errors.

@KooshaPari KooshaPari closed this Jul 2, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b2e777bce9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@@ -0,0 +1,10 @@
-- TV6 — Typed memory decay: track access frequency so decay can grant access-based immunity.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Renumber the migration to avoid new gaps

Adding this migration as 111 while the highest existing migration before it is 107 introduces new unexplained gaps 108, 109, and 110. I checked scripts/check/check-migration-numbering.mjs: its frozen gap allowlist only permits 026 and 055, so this new file adds fresh migration-numbering anomalies that the repo's migration-numbering test/gate will report. Please either use the next contiguous slot or add documented compatibility/allowlist handling for the skipped versions.

Useful? React with 👍 / 👎.

@KooshaPari KooshaPari changed the title fix(types): resolve 19 typecheck:core errors from botched-merge recovery fix(memory,mcp): add migration 111 + real Zod schemas for substrate dispatch tools Jul 2, 2026
@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

Comment thread src/lib/memory/store.ts
try {
const db = getDbInstance();
const placeholders = unique.map(() => "?").join(", ");
const stmt = db.prepare(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: Unbounded IN clause may hit SQLite parameter limit

recordMemoryAccess builds WHERE id IN (...) with one placeholder per id. SQLite defaults to SQLITE_MAX_VARIABLE_NUMBER = 999, so arrays larger than ~990 IDs cause prepare() to throw "too many SQL variables". The catch swallows it, but the entire batch fails silently. The current call site (retrieval.ts:237) stays well under the limit, but this is an exported helper so future callers could exceed it. Consider batching or capping the array size.

--
-- `access_count` increments each time a memory is injected into a prompt; `last_accessed_at`
-- records the most recent injection (and re-bases the decay clock so recently-used memories
-- survive). Both default to a never-accessed baseline, so every pre-existing row behaves as

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: Comment says "Both default" but last_accessed_at has no DEFAULT clause

Line 5-8 states both columns "default to a never-accessed baseline", but migration line 10 adds last_accessed_at as plain TEXT with no DEFAULT. Existing rows receive NULL, not a concrete default value. The code tolerates NULL (mapped to lastAccessedAt: null in rowToMemory), so runtime behavior is correct, but the comment overstates the column definition.

@kilo-code-bot

kilo-code-bot Bot commented Jul 3, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: 2 Issues Found | Recommendation: Notes

Overview

Severity Count
WARNING 0
SUGGESTION 2
Issue Details (click to expand)

SUGGESTION

File Line Issue
src/lib/memory/store.ts 571 Unbounded IN clause may hit SQLite parameter limit if recordMemoryAccess receives a large array
src/lib/db/migrations/111_memory_typed_decay.sql 5 Comment claims both columns default to a baseline, but last_accessed_at has no DEFAULT clause
Files Reviewed (10 files)
  • open-sse/executors/base.ts - re-export fix
  • open-sse/mcp-server/server.ts - Zod cast fix
  • open-sse/mcp-server/tools/dispatchTools.ts - real Zod schemas
  • open-sse/translator/formats.ts - missing GEMINI_CLI format
  • src/lib/combos/steps.ts - allowedConnectionIds on combo steps
  • src/lib/db/combos.ts - narrowed normalizeStoredCombo return type
  • src/lib/db/migrations/111_memory_typed_decay.sql - access tracking columns
  • src/lib/memory/store.ts - access tracking read + write paths
  • src/shared/validation/schemas.ts - removed stale re-export
  • src/types/index.ts - removed stale re-exports

Reply with @kilocode-bot fix it to have Kilo Code address these issues.


Reviewed by step-3.7-flash-20260528 · Input: 373.2K · Output: 31.5K · Cached: 3.3M

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant