Skip to content

Conversation

@hartra344
Copy link
Collaborator

@hartra344 hartra344 commented Jan 22, 2026

Commit Type

  • feature - New functionality
  • fix - Bug fix
  • refactor - Code restructuring without behavior change
  • perf - Performance improvement
  • docs - Documentation update
  • test - Test-related changes
  • chore - Maintenance/tooling

Risk Level

  • Low - Minor changes, limited scope
  • Medium - Moderate changes, some user impact
  • High - Major changes, significant user/system impact

What & Why

This change fundamentally shifts how Data Mapper v2 stores and loads maps by making XSLT the authoritative source for map definitions instead of LML files.

Why this change?

  • Single file format - Users manage one XSLT file instead of separate LML, XSLT, and metadata files
  • Simplified workflow - Eliminates file synchronization issues between map definition and generated XSLT
  • Better portability - XSLT files are self-contained with embedded metadata (v3 format)

Impact of Change

  • Users:

    • Maps are now saved/loaded directly from XSLT files
    • Existing LML-based maps will auto-migrate on open
    • Single file to manage per data map
  • Developers:

    • New XsltParser extracts map definitions from XSLT text value templates
    • New XsltMetadataSerializer for v3 metadata format (UI layout embedded in XSLT)
    • Removed LML embedding in XSLT comments (v2 format deprecated)
    • VS Code extension file service updated for direct XSLT content handling
  • System:

    • File structure changes: metadata now embedded in XSLT rather than separate files
    • XPath to LML conversion includes: quote normalization, math operator conversion, namespace prefix removal, operator flattening

Core Changes

Component Change
XsltParser New - Extracts map definitions from XSLT <xsl:text> and <xsl:value-of> templates
XsltMetadataSerializer New - v3 metadata format for UI layout (positions, canvas rect)
DataMapperPanel.ts Updated load/save flow to use XSLT content directly
dataMapperFileService.ts New methods for XSLT content operations

XPath → LML Conversions

The parser handles several XPath-to-LML transformations:

  • Single-quoted strings → double quotes ('text'"text")
  • Infix math operators → function calls (a + badd(a, b))
  • Namespace prefixes removed (math:sqrtsqrt)
  • Associative operators flattened (a + b + cadd(a, b, c))

Bug Fixes Included

  • Delete button not working for custom values in unbounded inputs
  • Node position changes not triggering dirty state (Save button)

Test Plan

  • Unit tests added/updated
  • E2E tests added/updated
  • Manual testing completed
  • Tested in: VS Code extension, Standalone dev environment

New Test Coverage

  • XsltParser.spec.ts - 446 lines covering XSLT parsing, XPath conversion
  • XsltMetadataSerializer.spec.ts - 384 lines covering metadata embedding/extraction

Contributors

Screenshots/Videos


Design Document: See docs/plans/2026-01-21-lml-to-xslt-migration-design.md for full architecture details.

This change fundamentally shifts how Data Mapper v2 stores and loads maps:

**Core Changes:**
- XSLT is now the authoritative source for map definitions
- Added XsltParser to extract map definitions from XSLT text value templates
- Added XsltMetadataSerializer for v3 metadata format (UI layout only)
- Removed LML embedding in XSLT comments (v2 format deprecated)

**XPath to LML Conversion:**
- Convert single-quoted string literals to double quotes for LML compatibility
- Convert XPath infix math operators (+, -, *, div, mod) to function calls
- Remove namespace prefixes (math:, xs:, etc.) from function names
- Flatten associative operators (+, *) to multi-argument function calls

**Bug Fixes:**
- Fix delete button not working for custom values in unbounded inputs
- Fix node position changes not triggering dirty state (Save button)

**VS Code Extension:**
- Update file service to use XSLT content directly
- Add commands for loading/saving XSLT content
Copilot AI review requested due to automatic review settings January 22, 2026 16:22
@github-actions
Copy link

github-actions bot commented Jan 22, 2026

🤖 AI PR Validation Report

PR Review Results

Thank you for your submission! Here's detailed feedback on your PR title and body compliance:

PR Title

  • Current: feat(data-mapper-v2): Make XSLT the source of truth for map definitions
  • Issue: None — title follows conventional commit style and clearly describes the feature change.
  • Recommendation: Keep as-is.

Commit Type

  • Properly selected (feature).
  • Note: Only one commit type was selected which is correct.

Risk Level

  • The PR body marks this change as High and the repository labels include risk:high.
  • Assessment: The advised risk (based on the diff — large feature, many files, new runtime/exec usage, new dependencies, migration behavior) is also High and matches the submitter's selection.

What & Why

  • Current: The PR includes a clear description of the design decision: XSLT becomes the authoritative file, metadata embedded in XSLT, new parsers/serializers, migration strategy, and reasons.
  • Issue: None — good concise context and rationale.
  • Recommendation: Optionally add a short note on rollback/backups during migration so reviewers understand how the system prevents data loss.

⚠️ Impact of Change

  • Impact is described for Users, Developers, and System and there is a detailed list of core changes.
  • Issue: This is a broad, impactful change (many files touched and new behaviors); you did a good job enumerating effects. A few extra items to add explicitly would help reviewers:
    • How will pre-existing CI/CD pipelines be impacted by new dependencies (saxon-js, xslt3)?
    • Are there any publishing or extension marketplace impacts from adding node-native execution (e.g., VS Code extension size/packaging)?
  • Recommendation:
    • Users: note that auto-migration will create XSLT files and delete legacy LML files — remind to backup before large rollouts.
    • Developers: call out explicitly that the extension now runs a local compilation step (execSync of xslt3) and uses SaxonJS, and that this requires install-time validation.
    • System: mention any changes to CI, build caching, and required dev environment steps for running the extension locally.

Test Plan

  • The PR claims Unit tests added and Manual testing completed; E2E tests not added.
  • Assessment: The diff adds an extensive number of unit tests (many new __test__ files), which substantiates the "Unit tests added/updated" claim.
  • Issue / Recommendation:
    • E2E tests: since this is a large migration touching persistence, loading/saving, and VS Code extension behavior, consider adding at least one E2E test or integration test that runs the full migration flow (open legacy LML → generate XSLT with metadata → save, then re-open) or explain in the Test Plan why an E2E test is not included (e.g., blocked by infra) and provide a follow-up ticket.
    • Add explicit unit/integration coverage for the new handleTestXsltTransform path (including failures of xslt3 detection and large-XSLT handling).

⚠️ Contributors

  • Current: Empty section in PR body.
  • Assessment: This is optional and not required to pass.
  • Recommendation: If others contributed (PM, designers, reviewers), add them for traceability. If not, it is fine to leave blank.

⚠️ Screenshots/Videos

  • Current: Marked as not applicable (no visual change). That is fine for a non-UI-first change.
  • Recommendation: None unless follow-on UI changes are added.

Summary Table

Section Status Recommendation
Title Keep as-is.
Commit Type Correct (feature).
Risk Level Matches code changes (High).
What & Why Good; optionally add brief rollback/backups note.
Impact of Change ⚠️ Add notes on CI/dev environment and extension packaging; mention backup during migration.
Test Plan Unit tests present; add E2E/integration test or explanation why not.
Contributors ⚠️ Optional: add contributors if applicable.
Screenshots/Videos ⚠️ Not required here.

Final assessment: This PR passes the PR title/body validation and the advised risk level is risk:high, which matches your PR label.

Actionable recommendations before merge (high priority):

  • Security & execution hardening
    • The extension now calls execSync to run xslt3 (node) and writes temp files. Please:
      • Prefer execFile / spawn with arg arrays to avoid shell injection or ensure inputs are strictly sanitized/quoted. The current command builds a single string; edge cases can lead to shell interpretation issues.
      • Add unit/integration tests that simulate malformed or malicious XSLT content to ensure no shell injection or unexpected behavior.
      • Confirm the xslt3 binary path resolution and fallback behavior (require.resolve) work in production packaging (VS Code extension packaging / hoisted node_modules). Add a clear error message and remediation steps in the UI if not found.
      • Document the required runtime and pre-conditions (e.g., which package versions are required, how the extension will ensure xslt3 is available in the production extension runtime).
  • Temp file handling & resource limits
    • You added MAX_XSLT_SIZE and temp file cleanup — good. Please also consider:
      • Using unique temp directories (you already use os.tmpdir + Date.now(); consider crypto.randomUUID for extra uniqueness in concurrent runs).
      • Fail-safe cleanup on unexpected crashes and signal handling if needed.
      • Unit tests for the cleanup path and for very-large XSLT failure mode.
  • Dependency & licensing
    • Pinpoint and document the new dependencies (saxon-js, xslt3) in the PR description with a short note on license and any packaging implications. CI maintainers will want to know these additions.
  • Migration safety
    • The migration strategy is present — ensure you add an explicit, user-facing hint that legacy files will be removed and how users can opt out or backup (e.g., create a local backup before migration, or create an automatic backup copy in a backups folder before deleting legacy LML files).
  • Tests & CI
    • Add at least one integration or E2E test that validates open/migrate/save cycle across the extension boundary, or add a short explanation in Test Plan and an issue to add it. This is especially important because the change adds many cross-layer interactions (webview ↔ extension host ↔ filesystem ↔ xslt3).
  • Telemetry & error messages
    • Ensure errors from xslt3 compilation are captured with enough telemetry (but no sensitive data). The code logs stderr; ensure you don't send large binary data into telemetry and that error text is user friendly.

If you address the above security/process items (exec/escape, packaging, backups/migration safety, and E2E/integration coverage or explicit justification), this large and impactful PR will be in good shape for final review and merge.

Thanks — this is a comprehensive, well-documented migration. Please reply with any follow-ups or if you want me to re-run a focused check on the test-plan vs files added.


Last updated: Thu, 22 Jan 2026 17:18:07 GMT

@github-actions
Copy link

📊 Coverage check completed. See workflow run for details.

@hartra344 hartra344 added the risk:high High risk change requiring careful review label Jan 22, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements a major architectural change to make XSLT the source of truth for Data Mapper v2 definitions, replacing the previous LML (Logic Mapper Language) file format. The change consolidates three separate files (LML definition, XSLT transformation, and metadata JSON) into a single XSLT file with embedded metadata in an XML comment.

Changes:

  • Introduces XSLT parsing and metadata serialization utilities to embed/extract map definitions and UI layout from XSLT files
  • Implements local XSLT 3.0 transformation testing using SaxonJS, eliminating the macOS testing limitation
  • Updates the save workflow to generate XSLT with embedded v3 metadata (layout only) where mapping logic is derived from XSLT content
  • Adds backward compatibility for loading legacy LML files with automatic migration

Reviewed changes

Copilot reviewed 28 out of 29 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
turbo.json Adds build dependency for proper monorepo build ordering
pnpm-lock.yaml Adds saxon-js and xslt3 dependencies for XSLT processing
libs/vscode-extension/src/lib/models/extensioncommand.ts Adds commands for XSLT transform testing
libs/vscode-extension/src/lib/models/dataMapper.ts Adds v3 format types and test result types
libs/data-mapper-v2/src/utils/index.ts Exports new XSLT parser and serializer utilities
libs/data-mapper-v2/src/mapHandling/test/XsltParser.spec.ts Comprehensive tests for XSLT parsing including Data Mapper backend format
libs/data-mapper-v2/src/mapHandling/test/XsltMetadataSerializer.spec.ts Tests for metadata embedding/extraction and round-trip serialization
libs/data-mapper-v2/src/mapHandling/XsltParser.ts Core XSLT parsing logic to derive map definitions from XSLT content
libs/data-mapper-v2/src/mapHandling/XsltMetadataSerializer.ts Utilities for embedding/extracting metadata in XSLT comments
libs/data-mapper-v2/src/core/state/DataMapSlice.ts Updates function position tracking and connection deletion logic
libs/data-mapper-v2/src/core/services/dataMapperFileService/dataMapperFileService.ts Adds saveMapXsltCall method and deprecates legacy save methods
libs/data-mapper-v2/src/core/DataMapDataProvider.tsx Handles XSLT transform test results from extension
libs/data-mapper-v2/src/components/test/TestPanel.tsx Updates to use local XSLT transformation instead of backend API
libs/data-mapper-v2/src/components/commandBar/EditorCommandBar.tsx Updates save workflow to generate and embed metadata in XSLT
libs/data-mapper-v2/src/components/codeView/CodeViewPanelBody.tsx Changes code view to display XSLT instead of LML
docs/plans/2026-01-21-lml-to-xslt-migration-design.md Design document explaining the migration strategy
apps/vs-code-react/src/webviewCommunication.tsx Handles v3 format by parsing XSLT to derive map definitions
apps/vs-code-react/src/state/DataMapSliceV2.ts Adds state for test transform results
apps/vs-code-react/src/run-service/types.ts Defines message types for XSLT transform results
apps/vs-code-react/src/app/dataMapper/services/dataMapperFileService.ts Implements saveMapXsltCall and testXsltTransform methods
apps/vs-code-react/src/app/dataMapper/appV2.tsx Passes test results to DataMapDataProvider
apps/vs-code-designer/src/package.json Adds saxon-js and xslt3 dependencies
apps/vs-code-designer/src/main.ts Updates context to support both XSLT and legacy file extensions
apps/vs-code-designer/src/app/commands/dataMapper/extensionConfig.ts Adds XSLT as primary file format and deprecates LML paths
apps/vs-code-designer/src/app/commands/dataMapper/dataMapper.ts Implements loading from XSLT files with migration from LML
apps/vs-code-designer/src/app/commands/dataMapper/DataMapperPanel.ts Adds handleTestXsltTransform for local XSLT transformation
apps/vs-code-designer/src/app/commands/dataMapper/DataMapperExt.ts Adds metadata extraction utilities for v2/v3 formats
apps/vs-code-designer/package.json Adds saxon-js and xslt3 dependencies to extension
Localize/lang/strings.json Adds localization strings for XSLT-related messages
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

libs/data-mapper-v2/src/components/commandBar/EditorCommandBar.tsx:140

  • The save workflow generates XSLT from the backend, embeds metadata, and saves it. However, if the backend XSLT generation fails (catch block at line 133), the metadata is never saved and the user loses their work. The earlier saveDataMap dispatch (line 108) has already marked the map as saved in Redux state, creating an inconsistency. Consider rolling back the Redux state or showing a more prominent error if XSLT generation fails.
      dispatch(
        saveDataMap({
          sourceSchemaExtended: sourceSchema,
          targetSchemaExtended: targetSchema,
        })
      );

      // Generate XSLT from the backend, then embed metadata and save
      generateDataMapXslt(dataMapDefinition.definition)
        .then((xsltStr) => {
          // Embed metadata into the XSLT as a comment
          const xsltWithMetadata = embedMetadataInXslt(xsltStr, xsltMetadata);

          // Update XSLT content in state for code view display
          dispatch(setXsltContent(xsltWithMetadata));

          // Save the combined XSLT file (this is now the only file we need)
          DataMapperFileService().saveMapXsltCall(xsltWithMetadata);

          LoggerService().log({
            level: LogEntryLevel.Verbose,
            area: `${LogCategory.DataMapperDesigner}/onSaveClick`,
            message: 'Successfully saved map with embedded metadata',
          });
        })
        .catch((error: Error) => {
          LoggerService().log({
            level: LogEntryLevel.Error,
            area: `${LogCategory.DataMapperDesigner}/onSaveClick`,
            message: JSON.stringify(error.message),
          });
          DataMapperFileService().sendNotification(failedXsltMessage, error.message, LogEntryLevel.Error);
        });

… robustness

Security fixes:
- Replace polynomial regex with string-based parsing in XsltMetadataSerializer
- Add prototype pollution protection in XsltParser with safe property assignment

Robustness improvements:
- Add robust xslt3 path resolution checking multiple locations
- Add XSLT size validation (5MB limit) before processing
- Add XSLT parsing error handling with user-friendly messages
- Handle empty map definition with null-coalescing fallback
- Prevent stale test results with ref-based deduplication
- Add detailed temp file cleanup logging

Performance optimization:
- Optimize position updates to avoid flooding undo history

Testing:
- Add comprehensive test suites for Redux slices, utilities, and query hooks
- 217 new tests added (484 total tests now passing)
@github-actions
Copy link

📊 Coverage check completed. See workflow run for details.

@Azure Azure deleted a comment from github-actions bot Jan 22, 2026
@github-actions
Copy link

📊 Coverage check completed. See workflow run for details.

@github-actions
Copy link

📊 Coverage check completed. See workflow run for details.

1 similar comment
@github-actions
Copy link

📊 Coverage check completed. See workflow run for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-validated risk:high High risk change requiring careful review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants