Skip to content

feat(truapi): localStorage.subscribe and worker pending operations (RFC 0027) - #603

Draft
johnthecat wants to merge 3 commits into
mainfrom
rfc-0027-pending-operations
Draft

feat(truapi): localStorage.subscribe and worker pending operations (RFC 0027)#603
johnthecat wants to merge 3 commits into
mainfrom
rfc-0027-pending-operations

Conversation

@johnthecat

@johnthecat johnthecat commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Implements RFC 0027 (docs/rfcs/0027-storage-subscriptions-pending-operations.md).

  • localStorage.subscribe(key) streams a key's value within the product's namespace. The core skips byte-identical writes.
  • worker.beginOperation / worker.endOperation keep the worker alive while an operation is open. Worker execution kind only; ProductOperations is a required host trait.
  • Wire ids 198-205. Dispatcher, WASM bridge, codegen goldens, UniFFI bindings, and the iOS/Android/TS/CLI hosts are wired.

RFC 0027. Two additions so a background worker can finish a multi-step
task and coordinate with the app through storage:

- localStorage.subscribe(key) streams a key's value on every change,
  within the product's own namespace.
- worker.beginOperation() / worker.endOperation(id) declare a pending
  operation; the host keeps the worker running while any operation is
  open. endOperation is idempotent.

Adds wire ids 198-205, the canonical trait surface, v01/versioned
plumbing, dispatcher and bridge codegen, host-cli and native/wasm
runtime wiring, and the iOS/Android/TS host bindings.

Claude-Session: https://claude.ai/code/session_01BedPRKxjb918nanVEz1gpM
…paths

The web host runtime tracks open operations as a set of host-assigned
ids instead of a counter, so ending an unknown or already-ended id
releases no other operation's hold. The begin response arrives as SCALE
bytes from the raw callback, so the runtime decodes it to read the id.

Add core tests against the stub platform for storage subscriptions
(current value first, write, byte-identical rewrite skipped before the
platform, clear, product scoping) and for begin/end reaching the
platform under the calling product. The stub now records writes, pushes
storage changes to subscribers, and records operations.

Shorten RFC 0027 to the design itself: no wire ids, no justification
prose, and every stated behavior matches the code (core skips identical
writes, ProductOperations is required, nothing persists operations).

Claude-Session: https://claude.ai/code/session_01RToiDVG81smFNdDAo53WuF
The guard compared CHAT_DIAGNOSIS_METHODS against every service that
requires Worker execution. The Worker service (begin_operation and
end_operation) is also Worker-only, so the Chat-specific diagnosis no
longer matched. Filter by service name instead.
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.

1 participant