Skip to content

Fix module-loader cache expiry and concurrency - #1753

Merged
Zetazzz merged 5 commits into
mainfrom
agent/express-context-loader-bounds
Sep 8, 2026
Merged

Fix module-loader cache expiry and concurrency#1753
Zetazzz merged 5 commits into
mainfrom
agent/express-context-loader-bounds

Conversation

@Zetazzz

@Zetazzz Zetazzz commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Frequent cache hits could keep module configuration cached indefinitely.
Concurrent cache misses could also start duplicate queries, and queries
that completed after invalidation could repopulate the cache with old results.

  • Stop extending the TTL on cache hits.
  • Share one in-flight resolution for concurrent misses with the same key
    within each loader instance.
  • Prevent invalidated resolutions from repopulating the cache or removing
    newer pending work.
  • Read cached values with a single get and log the cache size before clearing.

Related: constructive-io/constructive-planning#1693 (F11).

Behavior

The existing databaseId / optional apiId key, invalidate(databaseId?) API,
default 60-second TTL, and default 100-entry cache limit are retained.
TTL resolution uses the lru-cache default.

undefined results and PostgreSQL 42P01 results remain uncached.
Other resolution errors continue to propagate.

Invalidation does not cancel running queries: existing callers may still
receive their results, but those results cannot repopulate the cache.

Validation

  • All 119 express-context tests passed across 8 suites.
  • Full CI passed: 17/17 jobs on e71a1910b7e2.
  • Tests cover cache isolation and reuse, concurrent coalescing, invalidation
    races, capacity limits, uncached absence, error propagation, and registry
    forwarding.

@Zetazzz
Zetazzz force-pushed the agent/express-context-loader-bounds branch from e8438de to d5dac4d Compare September 6, 2026 01:51
@Zetazzz
Zetazzz force-pushed the test/performance-harness-core branch from 45cbb07 to 658736e Compare September 6, 2026 01:51
@Zetazzz
Zetazzz force-pushed the test/performance-harness-core branch from 658736e to f7c63ec Compare September 7, 2026 03:22
@Zetazzz
Zetazzz changed the base branch from test/performance-harness-core to main September 7, 2026 03:23
@Zetazzz
Zetazzz marked this pull request as ready for review September 7, 2026 03:23
@tenki-reviewer

tenki-reviewer Bot commented Sep 7, 2026

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This PR introduces two new capabilities: an LRU-cached, coalescing module loader in packages/express-context and a new packages/perf-harness package for spawning benchmark workers, collecting metrics, and producing reports.

Files Change
packages/express-context/src/loaders/* + cache-lifecycle test Adds a bounded LRU loader with hard TTL, concurrent-miss coalescing, and exact/logical invalidation.
packages/perf-harness/src/process.ts, run.ts, index.ts, stock-worker.ts Implements the worker spawn CLI protocol, base64url envelope, and secret handling.
packages/perf-harness/src/metrics.ts, report.ts, types.ts Adds metrics collection and report aggregation with median/min/max and percent-change math.
packages/perf-harness/src/fixture.ts Generates a seeded PostgreSQL fixture schema with identifier quoting and bounds checks.
packages/perf-harness/src/schedule.ts Provides seeded deterministic benchmark case ordering.
.github/workflows/run-tests.yaml + perf-harness tests/config Wires the new package into CI and adds unit tests across process, run, report, schedule, and fixture.

Reviewed commit: d5dac4d

@Zetazzz
Zetazzz force-pushed the agent/express-context-loader-bounds branch from d5dac4d to ca37b7c Compare September 7, 2026 03:23
@Zetazzz Zetazzz changed the title Isolate and bound control-plane loader caches Fix module-loader cache expiry and concurrency Sep 7, 2026
@Zetazzz
Zetazzz merged commit 252564c into main Sep 8, 2026
20 checks passed
@Zetazzz
Zetazzz deleted the agent/express-context-loader-bounds branch September 8, 2026 01:40
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.

2 participants