Skip to content

fix(workflow-executor): scope collection schema cache by rendering [PRD-440]#1660

Merged
christophebrun-forest merged 1 commit into
mainfrom
feature/prd-440-workflow-runs-can-use-a-collection-schema-from-the-wrong
Jun 12, 2026
Merged

fix(workflow-executor): scope collection schema cache by rendering [PRD-440]#1660
christophebrun-forest merged 1 commit into
mainfrom
feature/prd-440-workflow-runs-can-use-a-collection-schema-from-the-wrong

Conversation

@christophebrun-forest

@christophebrun-forest christophebrun-forest commented Jun 12, 2026

Copy link
Copy Markdown
Member

Problem

When workflows run on the same collection across different renderings, a run could operate with the collection schema (field display names and which fields are exposed, plus actions) belonging to a different rendering. Because workflow steps reference fields by their display name, this led to fields being mismatched or resolved incorrectly during a run.

Root cause

SchemaCache is a process-wide singleton keyed only by collectionName. The schema is fetched per run via getCollectionSchema(collectionName, runId) (the orchestrator resolves the rendering from the runId), so the fetched schema is rendering-specific — but the cache key dropped the rendering. Within the cache TTL (default 10 min):

Run A (rendering 100) → resolve("customers") → fetch schema(100) → cache["customers"] = schemaA
Run B (rendering 200) → resolve("customers") → cache HIT → returns schemaA  ❌

Fix

Key cache entries by (renderingId, collectionName):

  • SchemaCache — composite key; get/set(renderingId, …); the global iterator is replaced by entriesForRendering(renderingId) (NUL separator so rendering 1 is never confused with 11).
  • SchemaResolver — binds the run's renderingId and uses it for cache get/set.
  • StepExecutorFactory — passes step.user.renderingId to the resolver.
  • AgentClientAgentPort — builds action endpoints from the current user's rendering via entriesForRendering(user.renderingId) (iterating the whole cache would otherwise mix action schemas across renderings).

renderingId (not runId) is the cache dimension on purpose: two runs of the same rendering keep sharing the cache (efficiency), only different renderings are isolated. TTL/eviction logic is unchanged, just applied per (rendering, collection). No new dependency, no orchestrator contract change.

Testing

  • SchemaCache: rendering isolation, no 1/11 confusion, TTL per key, entriesForRendering scoping.
  • SchemaResolver: regression test — rendering B fetches its own schema instead of reusing rendering A's cached one.
  • AgentClientAgentPort + 8 executor tests updated to the new signatures.
  • 1002 tests pass, lint clean, build green.

fixes PRD-440

🤖 Generated with Claude Code

Note

Scope workflow-executor collection schema cache by rendering ID

  • SchemaCache now stores entries keyed by renderingId + collectionName composite key; get, set, and the new entriesForRendering method all require a renderingId, isolating cached schemas per rendering.
  • SchemaResolver accepts and stores a renderingId, passing it through to all cache reads and writes so resolvers never reuse schemas from other renderings.
  • AgentClientAgentPort.buildActionEndpoints now accepts a renderingId and iterates only over cache entries for that rendering, so action endpoints are scoped to the current user's rendering.
  • Behavioral Change: cache entries that were previously shared across all renderings are now isolated; any code constructing SchemaCache, SchemaResolver, or calling buildActionEndpoints must supply a renderingId.

Macroscope summarized f388e5f.

…RD-440]

The shared SchemaCache was keyed by collection name only, so a workflow run
could reuse a collection schema (display names, exposed fields, actions)
resolved for a different rendering within the TTL window — mismatching fields
during a run.

Key cache entries by (renderingId, collectionName): SchemaResolver now binds
the run's renderingId for get/set, and AgentClientAgentPort builds action
endpoints from the current user's rendering via entriesForRendering(renderingId).
Same rendering still shares the cache (efficiency); different renderings are
isolated.

fixes PRD-440

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@linear-code

linear-code Bot commented Jun 12, 2026

Copy link
Copy Markdown

PRD-440

@qltysh

qltysh Bot commented Jun 12, 2026

Copy link
Copy Markdown

1 new issue

Tool Category Rule Count
qlty Structure Function with many parameters (count = 4): constructor 1

@qltysh

qltysh Bot commented Jun 12, 2026

Copy link
Copy Markdown

Qlty


Coverage Impact

This PR will not change total coverage.

Modified Files with Diff Coverage (4)

RatingFile% DiffUncovered Line #s
Coverage rating: A Coverage rating: A
packages/workflow-executor/src/executors/step-executor-factory.ts100.0%
Coverage rating: A Coverage rating: A
packages/workflow-executor/src/schema-cache.ts100.0%
Coverage rating: A Coverage rating: A
...ages/workflow-executor/src/adapters/agent-client-agent-port.ts100.0%
Coverage rating: A Coverage rating: A
packages/workflow-executor/src/schema-resolver.ts100.0%
Total100.0%
🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

@christophebrun-forest christophebrun-forest merged commit 1284c9b into main Jun 12, 2026
30 checks passed
@christophebrun-forest christophebrun-forest deleted the feature/prd-440-workflow-runs-can-use-a-collection-schema-from-the-wrong branch June 12, 2026 12:02
forest-bot added a commit that referenced this pull request Jun 12, 2026
## @forestadmin/workflow-executor [1.1.5](https://github.com/ForestAdmin/agent-nodejs/compare/@forestadmin/workflow-executor@1.1.4...@forestadmin/workflow-executor@1.1.5) (2026-06-12)

### Bug Fixes

* **workflow-executor:** scope collection schema cache by rendering [PRD-440] ([#1660](#1660)) ([1284c9b](1284c9b))
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