computesrc

package
v0.2.45 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package computesrc is the source of a compute op, kept beside the wasm it was built from so the admin can show what a `compute://sha256/<digest>` does. The wasm is compiled with javy's `source=omitted`, so without this the authored JS/TS never reaches the chassis at all.

`txco apply` encodes one Bundle per compute it builds from source and uploads it to the hash-addressed file store (filecas). The stack version then carries one fingerprint-only row per compute it uses:

COMPUTES/<wasm digest>.json   content "", content_hash = sha256(bundle)

so an unchanged compute costs each new version one small row and its bytes are stored once. The admin reads a bundle only through such a row in the caller's own stack — never by hash alone.

This file is the leaf layer: the reserved-path vocabulary and the bundle codec, with no dependency on stores, so the CLI, the admin API and the control-event applier can import it cheaply.

Index

Constants

View Source
const Dir = "COMPUTES"

Dir is the reserved top-level directory for compute-source rows.

View Source
const Version = 1

Version is the bundle format version.

Variables

This section is empty.

Functions

func DigestFromPath

func DigestFromPath(p string) string

DigestFromPath returns the wasm digest a COMPUTES/ row names, or "" when p is not exactly COMPUTES/<64 lowercase hex>.json.

func IsPath

func IsPath(p string) bool

IsPath reports whether a stack_files path lives under COMPUTES/.

func Path

func Path(digest string) string

Path is the stack_files path that records the source of the compute whose wasm digest (sha256, lowercase hex) is digest.

Types

type Bundle

type Bundle struct {
	V     int    `json:"v"`
	Entry string `json:"entry"`
	Files []File `json:"files"`
}

Bundle is a compute's source: its entry file plus every local file the entry imports. The embedded @txco/op SDK is not included.

func Decode

func Decode(data []byte) (Bundle, error)

Decode parses and checks a bundle read back from the store.

func (Bundle) Encode

func (b Bundle) Encode() ([]byte, string, error)

Encode returns the bundle's canonical bytes and their sha256 (lowercase hex) — the filecas key. Files are sorted by path, so equal sources encode identically on any machine.

type File

type File struct {
	Path    string `json:"path"`
	Content string `json:"content"`
}

File is one source file of a compute. Path is relative to the entry's directory, slash-separated ("pull_plan.js", "../lib/util.js"), so the same source gives the same bundle wherever the stack sits on disk.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL