Skip to content

[ponytail] _core shrink: SessionStore on LRUCache, parseDateHint grammar, schema/scan/config one-liners #120

Closed

Description

@devinmlowe

Cut

Same logic, fewer lines, in src/_core.

Findings

  • yagni: SessionStore re-implements TTL plus LRU eviction that src/_core/cache/LRUCache already provides (src/_core/search/session.ts:76). Back it with new LRUCache<string, RecallSession>({maxSize: 10, ttlMs: 30 * 60 * 1000}) and delete evictExpired, evictLRU and the manual lastAccessedAt bookkeeping (~45 lines).
  • shrink: parseDateHint has 24 regex branches (src/_core/search/dates.ts:160). Keep every phrasing the recall tool description promises (today, yesterday, this/last week|month|year, N days|weeks|months ago, this day last year, in , , since , before , on this day, ISO date/month) and drop the rest ("this date in history", "every year on this day", "day before yesterday", spelled-out numbers, "10 march 2026") together with the word-number table and their tests (~120 lines).
  • stdlib: pad() and toIsoDay() hand-format a UTC date (src/_core/search/dates.ts:57). toIsoDay(d) is d.toISOString().slice(0, 10); the remaining pad calls are String(n).padStart(2, "0") (~8 lines).
  • shrink: CREATE TABLE IF NOT EXISTS schema_migrations is copy-pasted into all five checkpointed migrate functions (src/_core/db/schema.ts:608). Hoist into one ensureMigrationsTable(db) (~25 lines).
  • shrink: migrateExpandedTypes keeps a SAVEPOINT + INSERT + ROLLBACK probe under the sqlite_master DDL fast-path that already answers the same question (src/_core/db/schema.ts:487, ~16 lines). Check issue [db] migrateExpandedTypes fails with FOREIGN KEY constraint failed on any database with relationships rows, leaves entities_new behind, and then fails every subsequent init #101 first; if the fix for it lands on the probe path, coordinate rather than delete blindly.
  • shrink: the dedup branch in src/_core/search/scan.ts:245 rebuilds the numbered-context window inline, duplicating extractContext. Give extractContext explicit start/end arguments (~20 lines).
  • yagni: describeModelCacheDir reverse-engineers the precedence resolveModelCacheLocation just computed (src/_core/config/index.ts:74). Keep the ModelCacheResolution on the config (~13 lines).
  • yagni: resolveModelCacheDir is an exported one-liner with one caller (src/_core/embeddings/model-cache.ts:20). Inline (~6 lines).
  • shrink: budgetResults is a deprecated alias for allocateBudget with two callers (src/_core/search/orchestrator.ts:39). Inline and drop the export (~12 lines).

Verification

npm run build and npm run test:run green before and after. The dates tests for every kept phrasing still pass; removed phrasings get their tests removed in the same commit and listed in the PR.

Activity

  1. added
    sub-issueChild task of a parent issue
    ponytailOver-engineering audit cut (2026-09-20)
    on Sep 21, 2026
  2. devinmlowe commented on Sep 21, 2026

    @devinmlowe
    OwnerAuthor

    PR: #135 (branch ponytail/core-shrink).

  3. added a commit that references this issue on Sep 21, 2026
  4. devinmlowe commented on Sep 21, 2026

    @devinmlowe
    OwnerAuthor

    Merged PR #135 into main with --no-ff (commit dfbbb5c). Post-merge on main: build clean, 131 test files / 1679 tests passing (was 131 / 1689; the 10 dropped cases covered removed date phrasings, the manual session LRU bookkeeping and resolveModelCacheDir).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    ponytailOver-engineering audit cut (2026-09-20)sub-issueChild task of a parent issue

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions