fix(core): honor zero prompt cache TTL
PR Checklist
- Conventional commit message
- Related issue linked
- Regression tests added
- Patch changeset added
Current behavior
A per-prompt ttl: 0 is treated as absent when reading an existing cache entry. Even an entry originally cached with zero TTL can be reused when the next lookup occurs in the same millisecond.
New behavior
Honor zero explicitly and expire it immediately. Positive and default TTL behavior, including the existing positive-TTL expiry boundary, is unchanged.
Part of #1493, only its prompt-cache TTL correctness item. This does not close the broader issue or change MCP authentication, sandboxing, logging, or cache-key selection. #1522 excludes this item; #1521 concerns cache keys.
Validation
- Seven new tests exercise the real prompt manager and API client with only the fetch boundary replaced by synthetic JSON responses and a fake clock. Unchanged base: 4 failed, 3 passed. Fixed: 7 passed.
- New and existing prompt manager/API-client selection: 57 passed.
- Full core with an explicit process-local
OTEL_TRACES_SAMPLER=always_on: 1,407 passed, 2 skipped, 1 todo across 111 files; type tests passed. The clean base under the same condition passed 1,400 tests, with the same 2 skips and 1 todo. - The inherited environment used
parentbased_traceidratiowith ratio0.01. Its first core runs failed the same 16 named observability tests on both base and fixed code. Those results are retained; no global or production sampling setting was changed. - Core TypeScript checking, strict checking of the new tests, internal/logger/core builds, repository Biome, changeset formatting, and core
publint --strictpassed. Biome reported 5 existing complexity warnings; publint reported 2 suggestions. - Independent AI review repeated the 4-fail/3-pass to 7-pass result and checked two additional boundaries: exact positive TTL expiration and normal caching after a one-call zero override.
Environment: Linux, Node 24.22.1, pnpm 8.10.5, frozen repository lockfile. Dependency setup completed with optional native-build warnings; unrelated browser and CUDA downloads were skipped using their supported settings. No dependency or lockfile changes are included.
No live VoltOps/model calls, full-monorepo build/test, or Node 20/22 matrix was performed. The seven new cases are included in the larger totals above, not additive. Draft CI is configured upstream to skip its jobs, so local validation is not remote-CI success.
Notes for reviewers
Prepared, tested, and independently reviewed with OpenAI Codex assistance. No prior human or maintainer approval is claimed. The patch is limited to TTL handling, seven regressions, and its changeset.
Summary by cubic
Honors a prompt cache TTL of zero so cached prompts expire immediately. Previously ttl: 0 was treated as absent, letting an entry cached with zero TTL be reused; now it expires even when the next lookup happens in the same millisecond. Positive and default TTL behavior are unchanged. This addresses only the prompt-cache TTL correctness item in #1493; MCP authentication, sandboxing, logging, and cache-key selection (#1521, #1522) are untouched.
Tests
- Adds seven regression tests covering global and per-prompt zero TTL, same-millisecond lookups, and TTL override precedence.