Skip to content

docs(tutorial): first-module walkthrough (BLEU-848)#20

Open
brunota20 wants to merge 1 commit into
feat/example-balance-tracker-bleu-847from
docs/tutorial-first-module-bleu-848
Open

docs(tutorial): first-module walkthrough (BLEU-848)#20
brunota20 wants to merge 1 commit into
feat/example-balance-tracker-bleu-847from
docs/tutorial-first-module-bleu-848

Conversation

@brunota20

Copy link
Copy Markdown
Collaborator

Summary

End-to-end cold-start guide. Target: <4h from "I cloned the repo" to "I see my module's first event in the engine log".

Scenario — stop-loss order: combines every load-bearing SDK pattern (block subscription, `chain::request` + ABI decode, `local-store` dedup, `cow_api::submit_order`, host-free tests via `MockHost`).

Sections + rough budgets

§ Topic Budget
0 Prerequisites (toolchain + example smoke test) 15m
1 Scaffold workspace member 15m
2 `module.toml` manifest 10m
3a Pure strategy (`on_block<H: Host>`) 30m
3b `Guest` adapter (wit-bindgen ↔ Host trait) 15m
3c Unit tests against `MockHost` 15m
4 Build `.wasm` 5m
5 `engine.toml` + run 10m
6 Where to go from here 10m

Total ≈ 2h 5m hands-on. Buffer for first-time setup pushes it toward the 4h target.

What's in the tutorial vs the repo

Pure docs change — no new module crate. Stacks on #19 (BLEU-847 balance-tracker) so the tutorial can reference both M3 examples directly.

Linear: BLEU-848.

Test plan

  • Tutorial renders cleanly in GitHub markdown (headings, tables, code fences).
  • External-reviewer dry run — pick one volunteer who has never touched the repo, hand them `docs/tutorial-first-module.md`, time-stamp each section. Iterate until <4h. Tracked as a follow-up in the M3 trailing-edge ticket.

End-to-end cold-start guide that takes an external developer from
"I cloned the repo" to "I see my module's first event in the
engine log" in under four hours.

Scenario: stop-loss order — combines every load-bearing pattern in
the SDK (block subscription, chain::request + ABI decode, local-
store dedup, cow_api::submit_order, host-free tests via MockHost).
The tutorial walks through each pattern via the four worked
examples already in the repo (price-alert, balance-tracker,
twap-monitor, shepherd-sdk-test) and stitches them into the stop-
loss module.

Sections + rough budgets:

  0. Prerequisites (15m)        — toolchain check; verify the
                                  example module runs.
  1. Scaffold workspace (15m)   — Cargo.toml template + workspace
                                  members entry.
  2. Manifest (10m)             — module.toml with the four
                                  capabilities + Sepolia
                                  [[subscription]] + [config]
                                  schema.
  3. Strategy (60m)
     3a. Pure logic             — on_block<H: Host>(...) using
                                  shepherd-sdk's chain helpers
                                  and AggregatorV3 sol! interface.
     3b. Guest adapter          — wit_bindgen::generate! + the
                                  WitBindgenHost struct that
                                  bridges to shepherd_sdk::host
                                  (one-time boilerplate per
                                  module).
     3c. Unit tests             — two MockHost tests: idle-above-
                                  trigger + triggers-and-dedups.
  4. Build (5m)                 — cargo build --target
                                  wasm32-wasip2 --release +
                                  size sanity.
  5. Run (10m)                  — engine.toml WS RPC for Sepolia
                                  + cargo run -p nexum-engine.
  6. Where to go (10m)          — production hardening + real
                                  order assembly (twap-monitor
                                  cross-ref) + multi-chain.

Pure docs change — no module added (the stop-loss in §3 is the
reader's exercise; build_order_body deliberately ends in a `todo!`
with a cross-reference to twap-monitor's canonical assembly path).
Worked artefacts referenced in the tutorial are the existing
examples landed in #18 / #19 plus shepherd-sdk + shepherd-sdk-test.

Cross-links: docs/sdk.md (BLEU-844), docs/deployment.md
(BLEU-836), ADR-0001 / 0006 / 0007.

Acceptance per the issue: the tutorial is reviewer-validatable.
Time-budget callout at the end asks for a tag `docs/tutorial` if
a section drags, so we tighten on feedback.
@linear-code

linear-code Bot commented Jun 17, 2026

Copy link
Copy Markdown

BLEU-848

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