Skip to content

test: cover entity schema cache isolation by scope (PR #396)#397

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/missing-test-coverage-cfd5
Draft

test: cover entity schema cache isolation by scope (PR #396)#397
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/missing-test-coverage-cfd5

Conversation

@cursor

@cursor cursor Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds regression tests for the scope-aware live entity schema cache fix in #396. The production fix changed cache keys and bundled snapshot matching, but several critical paths lacked direct test coverage.

Risky behavior now covered

  • buildLiveSchemaCacheKey — cache keys must include orgId/projectId for org/project scopes so different tenants do not share cached schemas
  • bundledSnapshotMatchesScope — bundled snapshots tied to a specific org/project must not be served to callers with different scope identifiers
  • Org-level cache isolation — two org-scoped harness_schema calls with different org_id values must not reuse each other's cached live schemas
  • Preload cache warmingpreloadBundledEntitySchemas must warm scope-specific keys so preloaded entries do not leak across org/project boundaries

Test files added/updated

File Changes
tests/tools/entity-schema-cache-keys.test.ts New — unit tests for buildLiveSchemaCacheKey / buildBundledSchemaKey
tests/tools/entity-schema-bundled.test.ts bundledSnapshotMatchesScope, org-scope fallback, preload key isolation
tests/tools/harness-schema-tool.test.ts Org-level live schema cache isolation

Why these tests reduce regression risk

The original bug caused wrong YAML schemas to be returned when agents queried harness_schema for a different org/project than a prior call — a silent data correctness failure with high blast radius across all live entity types (connector, environment, service, etc.). These tests lock the contract at three layers: pure cache-key generation, bundled snapshot gating, and end-to-end tool behavior.

Validation

pnpm test tests/tools/entity-schema-cache-keys.test.ts tests/tools/entity-schema-bundled.test.ts tests/tools/harness-schema-tool.test.ts
# 34 passed
Open in Web View Automation 

cursoragent and others added 2 commits June 24, 2026 11:08
Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
Add focused regression tests for PR #396 scope-aware cache behavior:
- buildLiveSchemaCacheKey unit tests for account/org/project key shapes
- bundledSnapshotMatchesScope direct tests against vendored metadata
- org-scope bundled fallback rejection and preload cache key isolation
- org-level live schema cache isolation in harness_schema tool

Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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