Skip to content

chore(deps): update @codaco packages and migrate collected categorica…#803

Merged
jthrilly merged 5 commits into
nextfrom
claude/naughty-kepler-404b3f
Jun 26, 2026
Merged

chore(deps): update @codaco packages and migrate collected categorica…#803
jthrilly merged 5 commits into
nextfrom
claude/naughty-kepler-404b3f

Conversation

@jthrilly

Copy link
Copy Markdown
Member

…l data

Bump all @codaco packages to latest, including @codaco/protocol-utilities 1.x -> 2.0.0. Adapt the generateNetwork call sites in the test-interview generator to the new options-object signature (seed moved into options).

@codaco/interview 1.1.0 stores categorical attribute values as arrays of selected option values, dropping the scalar-handling fallbacks. Add a one-time, idempotent migration that wraps scalar categorical values in collected interview networks into single-element arrays, resolving categorical variables from the protocol codebook. Wired into the build:platform migration step after the v8 protocol migration.

Closes #795

…l data

Bump all @codaco packages to latest, including @codaco/protocol-utilities
1.x -> 2.0.0. Adapt the generateNetwork call sites in the test-interview
generator to the new options-object signature (seed moved into options).

@codaco/interview 1.1.0 stores categorical attribute values as arrays of
selected option values, dropping the scalar-handling fallbacks. Add a
one-time, idempotent migration that wraps scalar categorical values in
collected interview networks into single-element arrays, resolving
categorical variables from the protocol codebook. Wired into the
build:platform migration step after the v8 protocol migration.

Closes #795
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 87a14039-12e3-42c2-a9bb-939432b27494

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/naughty-kepler-404b3f

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jthrilly jthrilly left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I am concerned about the scenario where the upgrade from version 3.x of Fresco (using the old interview module) to version 4.x fails. If any of the steps in setup-database fail, we need to revert data migrations so as not to cause issues for the user.

Wrap the protocol-v8 and interview-categorical data migrations in a single
interactive transaction so a failure during setup-database rolls them all
back. A partially-migrated database is dangerous on a failed 3.x -> 4.x
upgrade: the previous Fresco version keeps serving and would read
half-converted protocols/networks written for the new interview module.
All-or-nothing keeps the old version working on the old data.
@jthrilly

Copy link
Copy Markdown
Member Author

Good catch — addressed in 171f5cf.

The two in-place data migrations (migrateProtocolsToV8 + migrateInterviewCategoricals) now run together inside a single prisma.$transaction(...) in setup-database.ts. If either step throws, Prisma rolls the whole transaction back, so the database is left exactly as it was. That closes the dangerous window you identified: on a failed 3.x → 4.x deploy the previous Fresco version keeps serving, and it would now still be reading the old data format rather than half-converted protocols/networks.

Notes:

  • Both migrations had to share one transaction (not one each) — migrating protocols to v8 but leaving interview networks half-done would be just as broken for the old app, so it's genuinely all-or-nothing.
  • Schema migrations (prisma migrate deploy) stay outside the transaction: they run first, are additive/backward-compatible, and are tracked by Prisma's own migration system (this PR adds none).
  • I set a generous 30-minute transaction timeout (DATA_MIGRATION_TIMEOUT_MS) since these run at deploy time with no concurrent traffic. If a very large instance ever exceeds it, the fix is to raise that ceiling rather than split the migrations across transactions — I left a comment to that effect.

Full suite + typecheck green.

protocol-validation 11.7.0 added strict validation that a NameGeneratorRoster
dataSource (and Geospatial asset references) resolve to an entry in the
protocol's assetManifest. migrateProtocolsToV8 reconstructed the protocol from
only name/schemaVersion/stages/codebook, so the manifest was absent and
migration failed for any protocol with a roster:

  Roster dataSource "..." does not reference an asset in the manifest.

Fresco stores assets in a separate table, so rebuild the assetManifest from the
protocol's linked Asset rows and include it in the document passed to
migrateProtocol. The manifest is excluded from the protocol hash, so this does
not change computed hashes. Verified against the real validator with a roster
protocol.
…tract

createInitialNetwork and isValidAssetType were imported from the @codaco/interview
package root, whose single bundle evaluates React createContext at module load and
so crashes the RSC production build when pulled into server code (server action /
server component).

Import them instead from the new server-safe @codaco/interview/contract entry
(complexdatacollective/network-canvas-monorepo#705), and drop the temporary local
reimplementations so the factory stays single-sourced in the package.

NOTE: blocked on publishing @codaco/interview@1.2.0 with the ./contract export.
Until then the build/install is red (the subpath does not resolve against 1.1.0).
Once published, refresh the lockfile (pnpm install) to go green — no code change.
@jthrilly

Copy link
Copy Markdown
Member Author

Deploy-preview RSC build failure — fixed properly upstream

The deploy preview's next build was failing during page-data collection:

TypeError: (0 , l.createContext) is not a function
    at actions/interviews.ts (createInitialNetwork)

Root cause: @codaco/interview builds to a single ESM bundle that exports Shell alongside the React-free contract utilities, and evaluates React createContext at module top level. Importing even createInitialNetwork / isValidAssetType into a server module (server action / server component) therefore crashes the RSC build.

Rather than reimplement those utilities in Fresco (they're part of the package contract), the fix is upstream: network-canvas-monorepo#705 adds a separately-bundled, server-safe @codaco/interview/contract entry that re-exports only the React-free contract. Verified the contract bundle's closure imports only uuid + @codaco/shared-consts (no createContext/react); package tests (539) + typecheck pass.

This PR now imports createInitialNetwork / isValidAssetType from @codaco/interview/contract and requires @codaco/interview@^1.2.0.

Warning

Blocked / held red: this PR's build & deploy will stay red until #705 is merged and @codaco/interview@1.2.0 (with the ./contract export) is published. After publish, refresh the lockfile (pnpm install) and it goes green with no code change.

…export)

@codaco/interview@1.2.0 is published with the ./contract entry. Refresh the
lockfile so the @codaco/interview/contract imports resolve, unblocking the
RSC production build.
@jthrilly

Copy link
Copy Markdown
Member Author

Unblocked. @codaco/interview@1.2.0 (with the server-safe ./contract export) is published and the lockfile is refreshed (9be3549).

Verified locally: next build succeeds (the original RSC createContext failure is gone), typecheck clean, full test suite 355/355. The deploy preview should now go green.

@github-actions

Copy link
Copy Markdown

@jthrilly jthrilly merged commit 69b371c into next Jun 26, 2026
10 checks passed
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