Skip to content

test(nix): guard root dependency module identity - #56881

Closed
albertominetti wants to merge 1 commit into
anomalyco:devfrom
albertominetti:fix/nix-dedupe-store
Closed

albertominetti wants to merge 1 commit into
anomalyco:devfrom
albertominetti:fix/nix-dedupe-store

Conversation

@albertominetti

@albertominetti albertominetti commented Oct 18, 2026 •

Copy link
Copy Markdown

Issue for this PR

Follow-up regression coverage for #56856. The production fix was independently merged in #56889 and is already in dev; this PR does not change the Nix install or dependency hashes.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement

What does this PR do?

Adds a regression test that:

  • checks theme colors survive spinner conversion (the e.replace is not a function crash path),
  • checks every OpenTUI consumer resolves one runtime entrypoint,
  • guards against collapsing distinct Zod and OpenTelemetry peer contexts now that root dependencies participate in the filtered install.

nix/scripts is not a turbo workspace, so the tests are also run explicitly in the Linux unit job of check-test.

How did you verify your code works?

  • On the current dev merge, bun install --frozen-lockfile --ignore-scripts --no-progress succeeded.
  • bun test in nix/scripts: 5 passed, 0 failed, 13 expectations.
  • oxlint nix/scripts/dependency-identity.test.ts: 0 warnings, 0 errors; Prettier clean.
  • Nix is not installed locally, so the derivation was not rebuilt here.

Screenshots / recordings

Not applicable; this PR adds tests.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@opencode-agent opencode-agent Bot left a comment

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.

This fixes the crash from #56856, but merging every same-version duplicate looks too broad to me.

How I checked: in this checkout and the base, I installed with the nix/node_modules.nix steps (filtered install, canonicalize, normalize-binaries) and built with the nix/opencode.nix steps (bun 1.4.2).

  • Base: packages/theme uses a different @opentui/core copy (+eff4d38d…) from packages/tui and packages/cli (+d25f280c…). The binary goes straight to the crash screen with e.replace is not a function.
  • This PR: all three use one copy, and the TUI reaches the home screen with an empty config.
  • Tests: the new test passes.

Public API: unchanged. The change only affects the node_modules layout of the Nix build. The node_modules hash in nix/hashes.json will change.

Main concern: the script merges all 15 duplicate groups in this install, not just @opentui/core. Several of them use different versions of their own dependencies, and the copy that's kept is whichever comes first alphabetically by hash. For example, the @ai-sdk/provider-utils@4.0.23 copy that packages/core uses links to zod@4.1.8. It gets replaced by a copy that links to zod@3.25.76. The @opentelemetry/* copies linked to @opentelemetry/api@1.9.1 are replaced by ones linked to 1.9.0. That changes which dependency versions run in the Nix build compared with every other build, and could cause problems in the provider and telemetry code. Details are in the inline comment.

After


for (const [slug, list] of versions) {
for (const entry of list) {
const key = slug + "@" + entry.version.split("+")[0]

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.

This merges all copies with the same version string, whatever their dependencies are, and keeps whichever comes first alphabetically by hash. On the filtered install, some of the 15 merged groups use different versions of their own dependencies:

  • @ai-sdk/provider-utils@4.0.23: +d6123d32… (used by packages/core and @ai-sdk/openai-compatible) links to zod@4.1.8. It is replaced by +27912429…, which links to zod@3.25.76.
  • @opentelemetry/core, resources, sdk-* and the other @opentelemetry/* copies: the +e40b0dfd… copies link to @opentelemetry/api@1.9.1 and are replaced by +460773ef… copies that link to 1.9.0.

Could you merge only copies whose dependency links point to the same targets, treating dependencies that were themselves merged as the same? For @opentui/core, the two copies differ only in bun-ffi-structs, which is itself a same-version duplicate, so that would still fix #56856 without changing what other packages resolve. Restricting the merge to the packages that need a single copy (@opentui/*) would also work.

@jerome-benoit

Copy link
Copy Markdown
Contributor

Verified a smaller alternative at the affected base 501b15af: 8464469 (patch). No duplicate PR opened.

Replace --filter '!./' with --filter './', keeping the CLI/Desktop/App selectors. Including root dependencies gives Bun the normal peer-resolution context; neither normalization script needs changing.

Checked with Bun 1.4.2 on Linux x86_64:

  • Original filtered install reproduces the real theme-to-spinner RGBA failure before either normalization. Its compiled binary shows the reported crash with isolated HOME/XDG.
  • Root-inclusive install shares OpenTUI across seven workspaces, Solid and opentui-spinner. Zod 3/4 and OpenTelemetry API 1.9.0/1.9.1 contexts remain distinct.
  • Actual Nix dependency output built; six behavior tests pass after copying it out of the store, including relative/internal links. Linux hash: sha256-WU71OJbvZSJqHXiU8xcEw34SQWOs7z/IyZn0tGYJ4yQ=.
  • Full Nix CLI build succeeds and its TUI reaches the welcome screen with empty HOME/XDG and --standalone. A separate source-only override supplies root script/ for the still-open nix run failure x86 with opencode-2.0.28+5aabb61.drv #55328 / fix(nix): ship the root script/ dir to the CLI build #55494 prerequisite; that workaround is not in this patch. Architecture verification remains enabled.
  • bun run check passes (1306 lint warnings, zero errors; 34 typecheck tasks successful, cached).

I also ran this PR's current 2755df75 script on a fresh filtered install: it collapses 15 groups. Its own test passes, but both added peer-context tests fail: provider-utils switches Zod 4 to 3, and OpenTelemetry core switches API 1.9.1 to 1.9.0. The suggested recursive-equivalence approach also needs care: the two bun-ffi-structs copies resolve different TypeScript peers (5.4.5 versus the TypeScript 6 alias), not equivalent dependency graphs.

Only the verified x86_64-linux hash is updated. ARM Linux/macOS hashes remain unchanged and need platform-local regeneration before claiming those builds work. Investigation and patch prepared with AI assistance.

@albertominetti albertominetti changed the title fix(nix): deduplicate same-version store entries fix(nix): preserve root dependency peer context Oct 18, 2026
@albertominetti albertominetti changed the title fix(nix): preserve root dependency peer context test(nix): guard root dependency module identity Oct 20, 2026
Cover the crash from anomalyco#56856: theme colors must survive spinner
conversion, every OpenTUI consumer must resolve one runtime entrypoint,
and the install must keep distinct Zod and OpenTelemetry peer contexts
now that root dependencies participate in the filtered install (anomalyco#56889).

nix/scripts is not a workspace, so turbo never runs these tests; run
them explicitly in the Linux unit job.
@albertominetti

Copy link
Copy Markdown
Author

Rebased onto current dev and reduced this to the regression test only:

  • Dropped the hand-written CHANGELOG.md entry: the changelog is generated at release time from merged PRs by script/changelog.ts, and the entry had landed in the already released v2.1.4 notes.
  • Dropped the dedupe script that the review flagged; the root-inclusive install from fix(nix): preserve root dependency peer context #56889 is what dev ships, so the test asserts that layout instead of rewriting it: one @opentui/core entrypoint across consumers, and distinct Zod/OpenTelemetry peer contexts preserved.
  • nix/scripts is not a turbo workspace, so the test never ran anywhere. It now runs in the Linux unit job of check-test.

Verified on this head: bun install --frozen-lockfile --ignore-scripts, then bun test in nix/scripts (5 passed, 13 expectations), oxlint and Prettier clean.

The PR workflows are currently waiting on maintainer approval to run (action_required), so the checks below are still pending.

@albertominetti
albertominetti deleted the fix/nix-dedupe-store branch November 15, 2026 18:49
@albertominetti

Copy link
Copy Markdown
Author

Superseded by #64111. Renaming the head branch to follow the current branch naming rule closed this PR, so the same commit and description now live there.

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