Skip to content

perf: send a schema reference in get-block-data instead of the full schema - #6402

Open
vshvets-bc wants to merge 1 commit into
hashgraph:developfrom
Climission:perf/get-block-data-schema-reference
Open

perf: send a schema reference in get-block-data instead of the full schema#6402
vshvets-bc wants to merge 1 commit into
hashgraph:developfrom
Climission:perf/get-block-data-schema-reference

Conversation

@vshvets-bc

Copy link
Copy Markdown
Collaborator

Problem

requestVcDocumentBlock and requestVcDocumentBlockAddon getData() embed the full schema (document + context) in every form block. For policies with large schemas the same schema is serialized once per form block, so get-block-data responses can reach tens of MB. That payload is JSON.parse/JSON.stringify-d as it is relayed between services (which do not read it), kept in memory on the client, and re-fetched on every block update — the repeated multi-MB serialization blocks the single Node event loop and slows unrelated requests.

Change

Emit a lightweight schema reference { id, iri, uuid, name, version } instead of the full document/context. The frontend resolves the full schema once by id (cached and de-duplicated) via the existing GET /schema/:id.

  • Much smaller get-block-data responses for schema-heavy forms.
  • Backward-compatible: the frontend uses a full schema (with document) exactly as before, so the client change is a no-op until the backend sends a reference. The change is sequenced so the frontend can ship first.

Details

  • policy-service: request-vc-document-block.ts, request-vc-document-block-addon.tsgetData returns the reference.
  • frontend: SchemaService.getSchemaById + cached/de-duplicated/error-evicting resolveSchemaById; request-document-block(-addon) _onSuccess resolves a reference to the full schema before the existing render flow.

Tests

  • policy-service (new request-vc-getdata-reference.test.mjs): getData emits a reference, not document/context. Passing.
  • frontend (new schema.service.spec.ts): endpoint, concurrent-subscriber de-dup, cache-hit, and error-eviction/retry.

Notes for reviewers

  • The frontend package was not built in this environment; the policy-service change and its test build and pass.
  • Worth confirming there is no non-frontend consumer of get-block-data that relies on the embedded document/context (e.g. remote/multi-policy interaction). The id/iri are still present for anything that needs to look the schema up.

…chema

request-vc-document-block(-addon) getData embedded the full schema
(document + context) in every form block, so get-block-data responses
grew to tens of MB for policies with large schemas - parsed and
re-serialized across services and refetched by the client.

Emit a lightweight schema reference { id, iri, uuid, name, version };
the client resolves the full schema once by id (cached, de-duplicated)
via GET /schema/:id. The frontend is backward-compatible: a full schema
(document present) is used as before, so the client change is a no-op
until the backend sends a reference.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vshvets-bc
vshvets-bc requested review from a team as code owners July 21, 2026 18:49
@Pyatakov Pyatakov self-assigned this Jul 23, 2026
data.schema = full;
this._applyBlockData(data);
},
error: () => this._applyBlockData(data)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On resolution failure this renders with the bare reference schema. new Schema(reference) has no document, so parseDocument() is skipped (interfaces/src/models/schema.ts:234) and fields stays empty so the user gets a silently blank form. Route the failure through the existing error handler instead:

Suggested change
error: () => this._applyBlockData(data)
error: (e) => this._onError(e)

data.schema = full;
super._onSuccess(data);
},
error: () => super._onSuccess(data)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as the non-addon block: on error this falls back to the reference schema (no document) and renders an empty form. Use error: (e) => this._onError(e) so the failure goes through the normal error/loading path.

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