Skip to content

fix: replace widget file FFI with simplifile - #24

Merged
GG-O-BP merged 1 commit into
mainfrom
fix/issue-14-simplifile-boundary
Sep 7, 2026
Merged

fix: replace widget file FFI with simplifile#24
GG-O-BP merged 1 commit into
mainfrom
fix/issue-14-simplifile-boundary

Conversation

@GG-O-BP

@GG-O-BP GG-O-BP commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Closes #14.

Summary

Moves the widget-definition file boundary (src/glendix/define/file_boundary.gleam) off the handwritten Node fs / JSON.parse adapter and onto simplifile (existence checks, UTF-8 read/write) and gleam_json (a small widgetName decoder), mapping simplifile.FileError / gleam_json.DecodeError into the existing public FileError taxonomy in pure Gleam.

Acceptance criteria

  • read / write / find_widget_xml delegate to simplifile and gleam_json; no handwritten fs / JSON.parse remains in this boundary.
  • src/glendix/define/file_boundary_ffi.mjs removed (no longer referenced).
  • Public FileError variants and their path / reason fields are unchanged.
  • Tests cover missing package.json, missing/empty widgetName, missing XML file, successful read/write, and read/write failure paths.
  • FFI contract checks report no stale external declarations or exports.
  • glendix -> mendraw retains its declared Hex dependency source form.

Behavior preservation & edge cases

  • Missing / empty / whitespace-only widgetName -> WidgetNameWasNotDeclared.
  • Missing src/<widgetName>.xml -> WidgetXmlWasNotFound.
  • Read / write OS failures -> FileCouldNotBeRead / FileCouldNotBeWritten.
  • reason text is now package-derived and deterministic (via simplifile.describe_error and a stable gleam_json.DecodeError description) instead of raw Node error.message.
  • Malformed JSON -> FileCouldNotBeRead with a deterministic reason.
  • Non-object valid JSON and null / non-string widgetName -> WidgetNameWasNotDeclared, matching the original adapter's observable behavior while also removing a latent uncaught TypeError the old adapter threw for a top-level null document.
  • A directory at the XML path is not accepted as the widget file.

Verification

Validated after rebasing onto main at 5071385:

  • gleam format --check src test, gleam check, gleam build --warnings-as-errors, gleam docs build
  • gleam test --runtime bun — 51 tests passed
  • ./scripts/check-all.sh — style, boundaries, 313 FFI export contracts, and generated-source diff passed
  • ./scripts/family.sh widget-build — valid MPK produced
  • ./scripts/family.sh lustre-e2e — browser smoke check passed
  • Mendix prepare/build plus the managed runtime/browser E2E — passed using explicit alternate ports because host port 8080 is occupied by an unrelated root-owned listener

./scripts/test-all.sh was also attempted after the rebase. Dependency-mode and Codex tests plus the glendam, glendix, and mendraw standalone consumers passed; the final fresh mxpak consumer resolution was blocked by the shared Hex API rate limit. Direct package/browser suites and the end-to-end routes passed independently.

@GG-O-BP
GG-O-BP merged commit 027be9d into main Sep 7, 2026
1 check passed
@GG-O-BP
GG-O-BP deleted the fix/issue-14-simplifile-boundary branch September 7, 2026 03:28
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.

[ffi] Move the widget-definition file boundary to simplifile and gleam_json

1 participant