feat(truapi): localStorage.subscribe and worker pending operations (RFC 0027) - #603
Draft
johnthecat wants to merge 3 commits into
Draft
feat(truapi): localStorage.subscribe and worker pending operations (RFC 0027)#603johnthecat wants to merge 3 commits into
johnthecat wants to merge 3 commits into
Conversation
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
2 tasks
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.endOperationkeep the worker alive while an operation is open. Worker execution kind only;ProductOperationsis a required host trait.