Skip to content

🔧 Port Go file operations to TinyGo with WIT bindings #2

@avrabe

Description

@avrabe

Overview

Port the existing Go file operations from tools/file_ops/main.go in rules_wasm_component to TinyGo with proper WIT interface bindings.

Tasks

  • Create TinyGo module structure and go.mod
  • Port JSON batch processing functionality
  • Port individual file operations (copy_file, mkdir, etc.)
  • Implement WIT interface bindings using wit-bindgen
  • Add security validation and path traversal protection
  • Create comprehensive test suite
  • Add performance benchmarking
  • Document TinyGo-specific features and limitations

Key Operations to Port

  • copy_file: Single file copying with permissions
  • copy_directory_contents: Recursive directory copying
  • create_directory: Safe directory creation (mkdir -p equivalent)
  • run_command: Command execution (may need WASI limitations)
  • validate_config: JSON configuration validation
  • containsPathTraversal: Security validation

Acceptance Criteria

  • All JSON batch operations work identically to original Go version
  • WIT interface functions are properly exposed and functional
  • Security validation prevents path traversal attacks
  • Component compiles to valid WASM with TinyGo toolchain
  • Performance is within acceptable range of native Go version
  • Comprehensive test coverage matches original implementation

Technical Notes

  • Use TinyGo 0.38.0 with WASI Preview 2 support
  • Target wasm32-wasi architecture
  • Implement proper error handling and logging
  • Consider WASI limitations for command execution functionality

Related

Part of Phase 2 implementation. Depends on unified WIT interface design.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions