Add labcoat generate web: deterministic TypeScript browser read artifacts - #40
Merged
Merged
Conversation
…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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
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.
Milestone 1 of Overwrite's Labcoat web integration plan (
jonatns/stratadocs/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
Generatesubcommand backed bylabcoat-core::generate.labcoat generate web --out-dir <dir>derives a self-contained TypeScript module tree fromlabcoat.lock, builtbuild/*.abi.jsonartifacts, 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 asbigint, 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 (secondaryview→protorunesbyaddress), and ABI-typedsimulate(secondaryview→simulateover a cellpack-carryingMessageContextParcel), decodingu128asbigint, ids as canonical decimal strings, andVec<u8>asUint8Array. No signing, no key material, no state mutation. The client takes abaseUrl, so apps proxy through their own dev rewrite and Labcoat needs no CORS changes.Regeneration deletes exactly the
.tsfiles 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/secondaryviewtranslation in qubitcoin mode) and are documented inline.Tests and docs
crates/labcoat-core/tests/generate_web.rs) pin the output byte-for-byte from fixture lock + ABI files; bless intentional changes withLABCOAT_BLESS=1. Unit tests cover artifact linking, chain-id folding, TS escaping, and stale-file cleanup.docs/GENERATE-WEB.mdrecords the design (derived code over verified state, read-only boundary, stale-chain detection) and the manual against-live check;labcoat docspicks 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, andcargo test --workspace --lockedare 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_seriesreturned the exact 208-byte bufferlabcoat simulatereports, typedbigint/string decodes correct), raw-opcode calls, revert surfacing (series already funded), and balances byte-identical tolabcoat balance. The generated tree also type-checks under strataweb/'s strict TS config (Milestone 1 exit criteria).🤖 Generated with Claude Code
https://claude.ai/code/session_01B4BQvfMDvaiM34o73CF6fP
Generated by Claude Code