Skip to content

fix(ui): resolve backend-workspace typecheck break in apps/gittensory-ui - #3710

Merged
JSONbored merged 1 commit into
mainfrom
fix/ui-workspace-env-typecheck
Jul 6, 2026
Merged

fix(ui): resolve backend-workspace typecheck break in apps/gittensory-ui#3710
JSONbored merged 1 commit into
mainfrom
fix/ui-workspace-env-typecheck

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Main's CI has been red on validate-code since commit d333463 (bisected directly against main's own CI run history: c4c977ba was the last green run, d3334632 the first red one, every commit since has stayed red), blocking every open PR — including PRs that never touched anything related to this.

Root cause: apps/gittensory-ui/src/lib/registration-workspace.ts has a long-standing import reaching directly into the backend — import { isFocusManifestPublicSafe } from "../../../../src/signals/focus-manifest". This pulls focus-manifest.ts and its transitive dependencies into the UI package's own, separate tsconfig.json, which never loaded worker-configuration.d.ts or src/env.d.ts (the two files that together declare the global Env interface). Every backend file that transitively references Env failed to resolve it under the UI's compile unit.

Fix

  • apps/gittensory-ui/tsconfig.json: add worker-configuration.d.ts and src/env.d.ts to include. Both use declare global { interface Env {...} } and merge into one complete type — including only one left most fields missing (confirmed by testing each addition independently).
  • apps/gittensory-ui/src/lib/error-capture.ts: explicitly type two addEventListener callback parameters. Loading worker-configuration.d.ts also introduces a global Workers-runtime addEventListener overload (keyed by WorkerGlobalScopeEventMap, which has no "unhandledrejection" key) that collided with DOM's own overload for that one call site, widening the inferred parameter to any.
  • src/utils/crypto.ts, src/orb/relay.ts, src/review/visual/shot.ts: cast a handful of Uint8Array values to Uint8Array<ArrayBuffer> at their exact Web Crypto / Response call sites. These buffers are never actually SharedArrayBuffer-backed; DOM's BufferSource/BodyInit types (only reachable once the UI's DOM-lib tsconfig transitively reaches these files) exclude SharedArrayBuffer from the wider ArrayBufferLike default that a bare Uint8Array annotation carries.
    • These are deliberately local casts at the call site, not signature changes. I first tried narrowing the function signatures themselves (e.g. salt: Uint8Array<ArrayBuffer>), but that broke the root tsconfig's own typecheck in the opposite direction — the root config's own crypto.getRandomValues typing (from worker-configuration.d.ts, no DOM lib) doesn't narrow its return type to plain ArrayBuffer the way DOM's does, so a stricter parameter type rejected values that were previously accepted. Local casts avoid the ripple entirely.

Validation

  • npx tsc --noEmit (root) clean.
  • npx tsc --noEmit inside apps/gittensory-ui — clean (was the failing job; verified with a real npm ci, not just a partial local check).
  • Full local suite: 498 files, 10041 passed / 7 skipped, 0 failed (npx vitest run) — including the specific test files covering every touched function (crypto.test.ts, crypto-secret.test.ts, crypto-jwt.test.ts, orb-relay-policy.test.ts, visual-shot.test.ts, integration/orb-relay.test.ts, 122 tests total), confirming the casts are purely type-level with zero runtime behavior change.
  • git diff --check clean.
  • npm audit --audit-level=moderate — 0 vulnerabilities.

No linked issue — this isn't a feature, it's restoring main to green.

apps/gittensory-ui/src/lib/registration-workspace.ts imports directly from
src/signals/focus-manifest.ts, pulling backend code into the UI's own separate
tsconfig — which never loaded worker-configuration.d.ts or src/env.d.ts, so
every transitively-reached Env usage failed to resolve. Main's CI has been red
since commit d333463 (bisected against main's own CI run history) with this
exact failure, blocking every open PR's validate-code check.

Fixes:
- Include worker-configuration.d.ts + src/env.d.ts in the UI's own tsconfig so
  Env resolves fully (both ambient-global files merge into one Env interface;
  including only one left most fields missing).
- error-capture.ts: explicitly type the addEventListener callbacks — the
  newly-visible Workers-runtime global addEventListener overload (keyed by
  WorkerGlobalScopeEventMap, which has no "unhandledrejection") collided with
  DOM's overload for that one call site, widening the inferred parameter to
  implicit any.
- crypto.ts / orb/relay.ts / review/visual/shot.ts: cast a handful of
  Uint8Array values to Uint8Array<ArrayBuffer> at their Web Crypto / Response
  call sites. These buffers are never actually SharedArrayBuffer-backed; DOM's
  BufferSource/BodyInit types (only reachable from the UI's own DOM-lib
  tsconfig) exclude SharedArrayBuffer from the wider ArrayBufferLike default,
  which the backend's non-DOM tsconfig doesn't. Deliberately local casts, not
  signature changes — narrowing the function signatures themselves broke the
  root tsconfig's own typecheck the opposite way (its crypto.getRandomValues
  typing doesn't narrow to plain ArrayBuffer the way DOM's does).
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
gittensory-ui 1e29103 Commit Preview URL

Branch Preview URL
Jul 06 2026, 05:28 AM

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 6, 2026
@loopover-orb

loopover-orb Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-06 05:28:58 UTC

5 files · 1 AI reviewer · 2 blockers · readiness 93/100 · CI pending · blocked

⏸️ Suggested Action - Manual Review

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.

Review summary
This PR fixes a real cross-workspace type-checking break: the UI package's tsconfig never loaded worker-configuration.d.ts/env.d.ts, so any file pulled in transitively (via the backend import in registration-workspace.ts) that referenced the global Env interface failed to resolve it. Adding both declaration files to the UI tsconfig's include list is the correct root-cause fix rather than removing the backend import. The remaining changes (explicit event-parameter typing in error-capture.ts, and Uint8Array<ArrayBuffer> casts in crypto.ts/relay.ts/shot.ts) are downstream type-only adjustments needed once DOM lib types become reachable from the UI's stricter tsconfig, and are runtime no-ops.

Nits — 6 non-blocking
  • The Uint8Array<ArrayBuffer> generic parameterization used in src/utils/crypto.ts, src/orb/relay.ts, and src/review/visual/shot.ts requires a sufficiently recent TypeScript/lib.dom.d.ts version (TS 5.7+) — worth confirming the repo's pinned TS version actually supports this syntax, since a mismatch would reintroduce a compile break.
  • No tests were added, but this is a type-only fix (tsconfig include + casts + explicit param types) with no behavior change, so the missing test coverage is reasonable here rather than a real gap.
  • Per repo convention, contributor PRs should link the open issue they close — the description doesn't reference one, worth confirming there's an authorized issue for this CI-unblocking fix.
  • The comments on each cast site are repetitive boilerplate (same 'plain, never shared, ArrayBuffer view' explanation four times) — could be consolidated into a single shared note or a short module-level comment in crypto.ts.
  • Confirm the pinned TypeScript version in package.json/tsconfig supports generic Uint8Array<ArrayBuffer> before merging, since that's the one part of this fix that could silently fail elsewhere.
  • Code changes lack test evidence — Add focused regression tests or explain why existing coverage is sufficient.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
Signal Result Evidence
Code review ❌ 2 blockers 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 54 registered-repo PR(s), 46 merged, 439 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 54 PR(s), 439 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: Python, TypeScript, JavaScript, Ruby, Go, Kotlin, MDX, Shell
  • Official Gittensor activity: 54 PR(s), 439 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • No action.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.36%. Comparing base (1c0a636) to head (1e29103).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3710   +/-   ##
=======================================
  Coverage   93.36%   93.36%           
=======================================
  Files         315      315           
  Lines       32204    32204           
  Branches    11812    11812           
=======================================
  Hits        30066    30066           
  Misses       1507     1507           
  Partials      631      631           
Files with missing lines Coverage Δ
src/orb/relay.ts 100.00% <100.00%> (ø)
src/review/visual/shot.ts 83.72% <100.00%> (ø)
src/utils/crypto.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored
JSONbored merged commit 1b2ec00 into main Jul 6, 2026
12 checks passed
@JSONbored
JSONbored deleted the fix/ui-workspace-env-typecheck branch July 6, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant