Skip to content

Develop toward an observable goal ​

Turn a feature request into an observable result before choosing an extension mechanism. Use a real user action, the component that owns the data, and one expected failure to define the first implementation.

Version scope: these source-level examples target v2.0.0.alpha.14. Use the Plugin SDK for current Wasm plugin authoring.

Start from user behavior rather than an attractive hook. This chapter applies “goal → contract → implementation → evidence” to XSR so an extension remains usable beyond its demo.

Define an outcome that can pass or fail ​

“Make an advanced theme” is vague. A testable goal is: “When the user releases the title-size slider, the current heading changes, remains readable in light/dark mode, survives restart, and a malformed manifest preserves the previous theme.” This defines the trigger, outcome, and failure behavior.

ItemQuestionTheme example
TriggerWho does what, and when?The user drags the title-size slider
Current factWho owns the authoritative value?Host-persisted options of the selected source
OutcomeWhere is success observable?Rendered title and options read after restart
BoundaryWhat is outside this feature?Business actions and installer icons
FailureWhat happens on error, navigation, retry?Keep drafts and last valid style; allow another save
EvidenceWhich checks demonstrate it?Light/dark, drag, invalid value, restart

Establish ownership and the upstream contract ​

Inspect the current implementation rather than inferring behavior from a type name.

  • If existing presentation capabilities meet the goal, use NTP instead of another process.
  • Put new behavior in Sidecar-owned logic, exchanging declared commands and state.
  • Select an admitted module slot and finite UI document for presentation. Host APIs are not page scripting services.
  • If the target is unavailable, describe the missing outcome, contract, and tests to Host maintainers. Do not work around it through reflection, arbitrary files, or ungranted hooks.

Architecture documents can describe future capabilities. Find the type, admission, actual consumer, and tests at the selected tag before claiming support. An enum entry alone does not mean a product page executes it.

Separate the four communication responsibilities ​

For “submit a note and display it on a resource extension card”:

RequirementContractReason
Submit a new noteCommand example.note.set, UTF-8 argumentRequests an effect with validation/completion
Display the last valid noteState example.note.current, UTF-8A newly opened page immediately sees current truth
Expose action availabilityState example.note.enabled, BooleanUI consumes facts rather than guessing process health
Announce a successful submissionEvent example.note.changedAn occurrence, not a replacement for current state
Calculate a one-off summaryQuery, only if neededA single result, never a query on every frame

Do not invent a query for every visual property. Registration snapshots populate the Host mirror, so rendering needs no round trip.

Deliver one complete vertical slice ​

Include argument validation, registration, initial snapshot, activation, one real command, state updates, cancellation, and teardown in the first slice. Drawing the form and returning hardcoded success while postponing permissions/errors is incomplete.

Implement business/value contracts, encode/decode behavior, lifecycle/self-test, finite UI, then native packaging and signature admission. Keep all work tied to this outcome instead of rebuilding unrelated modules.

Choose evidence that can expose mistakes ​

ScenarioObservable result
Valid submissionSuccessful command, updated state, matching presentation
Invalid argumentExplicit failure, unchanged prior value, no empty fake success
Navigation awayCaptured intents/results from the old exposure lose authority
Stop/restartPending exchanges finish; old numeric IDs are discarded; activation follows a new snapshot
Repeated inputBounded queues or documented coalescing
Missing resourceDeclared fallback or activation rejection preserving valid presentation

Test behavior rather than merely private method calls. Codec round trips prove encoding, a real child process proves IPC, and production admission proves publisher trust. Identify the evidence level honestly.

Stop when the outcome is delivered ​

After acceptance checks pass, record limitations and ship. Treat new requirements as another bounded slice. Record incidental findings with location/evidence/impact and return to the goal, unless they block it or create an actual hazard.

Continue with XSR responsibilities, then fill the contract table in the worked design.

Implementation references ​

Check your result ​

Write one successful scenario and one denied or cancelled scenario. If neither can be checked without naming internal classes, restate the outcome in terms the user can observe.

Site documentation: CC BY-SA 4.0. Imported SDK documents: Apache-2.0 as marked.