Skip to content

Add labcoat generate web: deterministic TypeScript browser read artifacts - #40

Merged
jonatns merged 2 commits into
mainfrom
claude/labcoat-web-integration-69elna
Aug 18, 2026
Merged

Add labcoat generate web: deterministic TypeScript browser read artifacts#40
jonatns merged 2 commits into
mainfrom
claude/labcoat-web-integration-69elna

Conversation

@jonatns

@jonatns jonatns commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Milestone 1 of Overwrite's Labcoat web integration plan (jonatns/strata docs/labcoat-web-integration-plan.md): the general capability that lets application repos generate a browser read client instead of wrapping the CLI. The companion strata PR consumes these artifacts.

What

A new Generate subcommand backed by labcoat-core::generate. labcoat generate web --out-dir <dir> derives a self-contained TypeScript module tree from labcoat.lock, built build/*.abi.json artifacts, and the resolved network settings — no network access at generation time:

  • manifest.ts — network target, Bitcoin network, unified RPC endpoint, the chain instance id when every record agrees, and one record per lockfile contract, each linked to the local build artifact whose ABI describes it (wasm sha256 match first, artifact name second).
  • abi/document.ts, abi/<artifact>.ts, abi/index.ts — typed method descriptors (opcode as bigint, param/return type names) derived from the existing ABI model.
  • client.ts — a dependency-free fetch read client for the unified JSON-RPC endpoint: indexed height (secondaryheight), Alkanes balances summed across an address's outpoints (secondaryviewprotorunesbyaddress), and ABI-typed simulate (secondaryviewsimulate over a cellpack-carrying MessageContextParcel), decoding u128 as bigint, ids as canonical decimal strings, and Vec<u8> as Uint8Array. No signing, no key material, no state mutation. The client takes a baseUrl, so apps proxy through their own dev rewrite and Labcoat needs no CORS changes.

Regeneration deletes exactly the .ts files carrying the generated header, so removed contracts leave no dead modules while hand-written files in the same directory survive. Wire protocol details were taken from the pinned alkanes-rs provider (secondaryheight/secondaryview translation in qubitcoin mode) and are documented inline.

Tests and docs

  • Golden-file codegen tests (crates/labcoat-core/tests/generate_web.rs) pin the output byte-for-byte from fixture lock + ABI files; bless intentional changes with LABCOAT_BLESS=1. Unit tests cover artifact linking, chain-id folding, TS escaping, and stale-file cleanup.
  • docs/GENERATE-WEB.md records the design (derived code over verified state, read-only boundary, stale-chain detection) and the manual against-live check; labcoat docs picks up the subcommand from the clap registry plus a new protocol note; CHANGELOG entry under Unreleased.
  • cargo fmt --check, cargo clippy --workspace --locked -- -D warnings, and cargo test --workspace --locked are green.

Verification beyond CI (done in this session against a live stack)

Ran labcoat up, seeded the Overwrite project, generated artifacts inside strata, and exercised the emitted client from Node against the live endpoint: indexed height, ABI-typed simulate (get_series returned the exact 208-byte buffer labcoat simulate reports, typed bigint/string decodes correct), raw-opcode calls, revert surfacing (series already funded), and balances byte-identical to labcoat balance. The generated tree also type-checks under strata web/'s strict TS config (Milestone 1 exit criteria).

🤖 Generated with Claude Code

https://claude.ai/code/session_01B4BQvfMDvaiM34o73CF6fP


Generated by Claude Code

…facts

Add a Generate subcommand backed by a new labcoat-core::generate module.
`labcoat generate web --out-dir <dir>` derives a self-contained TypeScript
module tree from labcoat.lock, built build/*.abi.json artifacts, and the
resolved network settings — no network access:

- manifest.ts: network target, unified RPC endpoint, common chain instance
  id, and one record per lockfile contract, each linked to the local build
  artifact whose ABI describes it (wasm sha256 match first, name second)
- abi/document.ts, abi/<artifact>.ts, abi/index.ts: typed method
  descriptors (opcode as bigint) derived from the existing ABI model
- client.ts: a dependency-free fetch read client for the unified JSON-RPC
  endpoint — indexed height (secondaryheight), Alkanes balances summed
  across outpoints (secondaryview protorunesbyaddress), and ABI-typed
  simulate (secondaryview simulate over a cellpack-carrying
  MessageContextParcel), decoding u128 as bigint, ids as canonical decimal
  strings, and Vec<u8> as Uint8Array; no signing, no key material

Regeneration deletes exactly the .ts files carrying the generated header,
so removed contracts leave no dead modules while hand-written files
survive. Golden-file codegen tests (bless with LABCOAT_BLESS=1) pin the
output byte-for-byte, and docs/GENERATE-WEB.md records the design and the
manual against-live check.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B4BQvfMDvaiM34o73CF6fP
@vercel

vercel Bot commented Aug 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
labcoat-web Ready Ready Preview Aug 18, 2026 9:07pm

CI's sync-reference guard flagged apps/web's generated CLI reference as
stale after adding `labcoat generate web`. Regenerated with
pnpm sync:web-reference (additive: the generate command group and the
generated-web-client protocol note).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B4BQvfMDvaiM34o73CF6fP
@jonatns
jonatns merged commit 4746fd2 into main Aug 18, 2026
6 checks passed
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.

2 participants