Skip to content

feat: writable WASM sources (Phase C2) #216

Open

Description

@adnaan

Context

This is the final item from the progressive complexity plan. WASM sources currently implement Source (read-only). Extending them to implement WritableSource would let users build fully custom CRUD backends in TinyGo.

Progressive complexity tiers:

Task Description

Extend internal/wasm/source.go (WasmSource) to implement the WritableSource interface:

type WritableSource interface {
    Source
    WriteItem(ctx context.Context, action string, data map[string]interface{}) error
    IsReadonly() bool
}

The WASM module would need to export a WriteItem(action, data) function (or similar) that tinkerdown calls for Add/Update/Delete operations. The TinyGo WASM SDK would need a corresponding update.

Implementation notes

  • WasmSource already has IsReadonly() (returns true) — change to check if the module exports a write function
  • Add WriteItem that calls the WASM module's exported write function
  • Update the wasm-source template (cmd/tinkerdown/commands/templates/wasm-source/) to show a writable example
  • Update docs/sources/wasm.md

Files to modify

  • internal/wasm/source.go — implement WritableSource
  • cmd/tinkerdown/commands/templates/wasm-source/ — update template
  • docs/sources/wasm.md — document writable WASM

From the progressive complexity plan (Phase C2).

Activity

  1. added
    follow-upFollow-up task from PR review
    P3-lowLow: extended features, operational docs
    on Mar 25, 2026
  2. adnaan commented on Jul 24, 2026

    @adnaan
    ContributorAuthor

    Progress (M5 Phase 3, #310) — CLI parity landed; keeping this open

    tinkerdown cli now constructs wasm sources (createCLISource previously fell through to "unsupported source type for CLI"), so a WASM source has the same CRUD surface on the CLI as under serve. Also fixed a load-breaking bug found while writing the docs: docs/sources/wasm.md and the wasm-source template used a non-existent module: key (the real key is path:) and config: (real: options:), so following the docs failed to load. A Read-only vs. writable section now documents the write-export contract + CLI parity.

    Verified running: tinkerdown cli … list quotes returns rows; tinkerdown cli … add against a read-only module returns Error: source is read-only; a unit test covers construct + Fetch + IsReadonly + the WriteItem guard error.

    Why this stays open: the feature this issue names — a successful write through a write-exporting module — still has zero verified coverage in any transport (CLI or WebSocket). "Verify, don't infer" found the assumption that examples/lvt-source-wasm-test/ is a writable path to be wrong: quotes.wasm is read-only (no write export), it's the only .wasm in the repo, and there's no TinyGo in this environment to build a write-exporting fixture (a committed one that can't be rebuilt would be the #295/#297 provenance trap). Tracked as #311 — a reproducible TinyGo fixture wired into make + a write-landing test over CLI and WS. This issue closes when that write path is demonstrated end-to-end.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_018M9pJSPmG6i1D8s6rpEV4h

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3-lowLow: extended features, operational docsfollow-upFollow-up task from PR review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions