Skip to content

TrustRecordSchema superRefine mutates record during validation #154

Description

@flyingrobots

Migrated from Method backlog

GitHub Issues are now the live work tracker. Repository docs remain Method evidence.

Field Value
Source backlog docs/method/backlog/bad-code/BND_schemas-refine-mutation.md
Archived source docs/archive/backlog/github-issue-migration-2026-06-01/docs/method/backlog/bad-code/BND_schemas-refine-mutation.md
Original lane bad-code
Original id BND_schemas-refine-mutation
Original legend BND
Original feature merge-strands-worldlines
Original release home v19.0.0

Original backlog card

TrustRecordSchema superRefine mutates record during validation

Effort: S

Problem

The Zod superRefine callback mutates record.subject, replacing it
with the parsed sub-schema result. Zod schemas should be pure validators;
mutation during refinement is surprising and fragile. It makes the
validation step order-dependent and hard to reason about.

Suggested Fix

Use .transform() instead of superRefine for the mutation step, or
parse the subject separately and merge the results. Keep refinement
callbacks pure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:runtimePrimary work area: runtime.feature:merge-strands-worldlinesMethod feature merge-strands-worldlines.legend:bndMethod legend bnd.priority:laterDeferred or speculative work.release-home:v19.0.0Method release home v19.0.0.status:availableOpen and available for prioritization; not blocked or actively in progress.type:debtDebt, rot, or structural risk.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions