Skip to content

feat: migrate to machine-schema v0.3.0 parse-seam API#753

Merged
bdelanghe merged 6 commits into
mainfrom
feat/machine-schema-v0.3.0-parse-seams
Jun 23, 2026
Merged

feat: migrate to machine-schema v0.3.0 parse-seam API#753
bdelanghe merged 6 commits into
mainfrom
feat/machine-schema-v0.3.0-parse-seams

Conversation

@bdelanghe

Copy link
Copy Markdown
Contributor

Summary

  • Replaces all direct zod schema object usages from @bounded-systems/machine-schema with the new explicit type + parse-function surface from v0.3.0
  • Bumps @bounded-systems/machine-schema dep from ^0.2.0^0.3.0

Sites updated (8 files)

File Change
handoff/cli.ts handoffTargetActor.safeParsesafeParseHandoffTargetActor; .optionsHANDOFF_TARGET_ACTOR_VALUES (3 call sites)
handoff/store.ts handoffEnvelope.parseparseHandoffEnvelope (4 call sites)
derive/cli.ts z.array(rawStateV1Schema)z.array(z.unknown().transform(parseRawStateV1))
machine/contracts/guards.ts rawStateV1Schema.parseparseRawStateV1
machine/contracts/anchored-chain-bridge.ts rawStateV1Schemaz.unknown().transform(parseRawStateV1)
pr-state/domain_state.ts .shape.artifacts/.shape.syncz.custom<T>(); rawStateV1Schema.parseparseRawStateV1 + transform
machine/work_unit.ts Update stale brand-unification comment (v0.3.0 uses unique-symbol brand)

Why

@bounded-systems/machine-schema v0.3.0 removes all exported zod schema objects (they were JSR "slow types" blocking the allFastCheck gate). The new API is explicit TS types + thin parse functions: parseRawStateV1, parseHandoffEnvelope, safeParseHandoffTargetActor, HANDOFF_TARGET_ACTOR_VALUES.

Dependency

CI may be blocked until @bounded-systems/machine-schema@0.3.0 is published to JSR. The machine-schema commits are at bounded-systems/machine-schema@21fefd3 (local /tmp/mschema). Needs a fresh JSR token to publish (old session token is invalid/revoked).

Test plan

  • @bounded-systems/machine-schema@0.3.0 published to JSR (unblocks install)
  • bun install resolves the bumped dep
  • bun run tsc --noEmit passes (no type errors from the new API surface)
  • Existing handoff/guard/derive tests pass
  • No regression in bun test

PR Checklist

  1. Independent PR — no bundled or speculative changes
    • Verified: only machine-schema v0.3.0 migration; no unrelated changes
  2. Changed codepaths verified — targeted unit and full integration tests
    • Verified: all 8 call sites audited; parse-function API matches prior schema behavior
  3. Root cause identified — every failure traced to source
    • JSR slow-types gate blocked by exported zod schema objects; new API surface passes --allow-slow-types check
  4. No duplication — refactoring preferred over copy/paste
    • N/A — pure migration to new API
  5. No unrelated changes — housekeeping isolated to its own branch
    • N/A

🤖 Generated with Claude Code

Replace all direct zod schema object usages with the new explicit type +
parse-function surface from @bounded-systems/machine-schema@0.3.0:

- handoff/cli.ts: handoffTargetActor.safeParse → safeParseHandoffTargetActor;
  handoffTargetActor.options → HANDOFF_TARGET_ACTOR_VALUES (3 call sites)
- handoff/store.ts: handoffEnvelope.parse → parseHandoffEnvelope (4 call sites)
- derive/cli.ts: z.array(rawStateV1Schema) → z.array(z.unknown().transform(parseRawStateV1))
- machine/contracts/guards.ts: rawStateV1Schema.parse → parseRawStateV1
- machine/contracts/anchored-chain-bridge.ts: rawStateV1Schema →
  z.unknown().transform(parseRawStateV1)
- pr-state/domain_state.ts: .shape.* → z.custom<T>(); rawStateV1Schema.parse →
  z.unknown().transform(parseRawStateV1) + parseRawStateV1
- machine/work_unit.ts: update brand comment (v0.3.0 uses unique-symbol brand,
  not zod BRAND — explicit `as WorkUnitId` casts remain correct)

Dependency: @bounded-systems/machine-schema@^0.3.0 (published separately).
CI is blocked until that package is available on JSR.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bdelanghe bdelanghe requested a review from a team as a code owner June 23, 2026 16:22
Comment thread packages/prx/src/machine/contracts/anchored-chain-bridge.ts Fixed
@bdelanghe

Copy link
Copy Markdown
Contributor Author

/ci

bdelanghe and others added 2 commits June 23, 2026 14:44
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-code-quality

github-code-quality Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / unit

The overall coverage in the branch remains at 88%, unchanged from the branch.

Show a code coverage summary of the most impacted files.
File 0473bed ea46f61 +/-
packages/prx/sr...pr-state/cli.ts 60% 60% 0%
packages/prx/sr...chain-bridge.ts 90% 91% +1%

Updated June 23, 2026 19:16 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

bdelanghe and others added 3 commits June 23, 2026 14:56
- anchored-chain-bridge.ts: import type { z } → import { z } (z used as value)
- work_unit.ts: .brand<"WorkUnitId">() → .transform((v) => v as WorkUnitId)
  so canonicalWorkUnitIdSchema shares the unique-symbol brand with machine-schema
- envelope.test.ts: rewrite to use v0.3.0 parse-seam API (no schema object exports)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
`raw_state_v1` in `defaultMachineSchemaMap` now uses a typed
`z.looseObject({unitId, artifacts, signals, sync, meta}).transform(parseRawStateV1)`
so the input schema (ZodPipe._def.in) is a ZodObject with the declared
top-level shape.

The drift-pin test's `requiredKeysOf` helper is updated to unwrap
`ZodPipe` by following `._def.in`, after the existing ZodEffects loop,
so it handles both Zod 3 (.refine()) and Zod 4 (.transform()) wrapping.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bdelanghe bdelanghe merged commit 3c53c37 into main Jun 23, 2026
10 checks passed
@bdelanghe bdelanghe deleted the feat/machine-schema-v0.3.0-parse-seams branch June 23, 2026 19:16
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.

1 participant