Adopt Mesh release APIs and client package identity

This commit is contained in:
waozi committed 2026-11-17 16:46:46 -03:00
1 parent 0d726f2a96
commit 40f598a171
7 files changed
+61 -59

No files matched your search

+2
View File
@@ -2,6 +2,8 @@
## [Unreleased]
- Use Mesh release APIs and package imports without changing signed release messages or cached catalog formats.
- Offer each host only node releases it can run: the publisher checks each payload's ZX revision against the ledger, the remote catalog names its revision and oldest host interface, and the node's history keeps the newest release of every format, ZX revision and interface. Publish an optional signed WebAssembly variant of a node app for web hosts.
- Validate signed package sizes against checked integer ranges instead of a universal 64 MiB limit, and verify public payloads incrementally without weakening signatures or exact digests.
+7 -7
View File
@@ -1,6 +1,6 @@
#import "apps/host"
Hash :: #import "crypto/sha256";
Daochi :: #import "daochi_client/crypto";
Mesh :: #import "mesh_client/crypto";
#import "std/c_string"
#import "std/text_buffer"
@@ -11,19 +11,19 @@ Check :: () -> s32 {
input: [3]u8 = .[97, 98, 99]
first: [32]u8; second: [32]u8
first_hex: [65]u8; second_hex: [65]u8
Hash.Sha256(*input[0], 3, *first[0]); Daochi.Sha256(*input[0], 3, *second[0])
Hash.Sha256(*input[0], 3, *first[0]); Mesh.Sha256(*input[0], 3, *second[0])
if Hash.BytesToHex(*first[0], 32, *first_hex[0], 65) != 1 ||
Daochi.BytesToHex(*second[0], 32, *second_hex[0], 65) != 1 ||
Mesh.BytesToHex(*second[0], 32, *second_hex[0], 65) != 1 ||
TextUntilNul(first_hex[:]) != known || TextUntilNul(second_hex[:]) != known { return 2 }
Hash.Sha256Hex(*input[0], 3, *first_hex[0]); Daochi.Sha256Hex(*input[0], 3, *second_hex[0])
Hash.Sha256Hex(*input[0], 3, *first_hex[0]); Mesh.Sha256Hex(*input[0], 3, *second_hex[0])
if TextUntilNul(first_hex[:]) != known || TextUntilNul(second_hex[:]) != known { return 3 }
if Hash.HexToBytes(known, *first[0], 32) != 1 || Daochi.HexToBytes(known, *second[0], 32) != 1 { return 4 }
if Hash.HexToBytes(known, *first[0], 32) != 1 || Mesh.HexToBytes(known, *second[0], 32) != 1 { return 4 }
key: [3]u8 = .[107, 101, 121]
if Hash.HmacSha256(*key[0], 3, *input[0], 3, *first[0]) != 1 ||
Daochi.HmacSha256(*key[0], 3, *input[0], 3, *second[0]) != 1 { return 5 }
Mesh.HmacSha256(*key[0], 3, *input[0], 3, *second[0]) != 1 { return 5 }
for at: cast(s32)0..31 { if first[at] != second[at] { return 6 } }
if Hash.HmacSha256Text(*key[0], 3, "abc", *first[0]) != 1 ||
Daochi.HmacSha256Text(*key[0], 3, "abc", *second[0]) != 1 { return 7 }
Mesh.HmacSha256Text(*key[0], 3, "abc", *second[0]) != 1 { return 7 }
for at: cast(s32)0..31 { if first[at] != second[at] { return 8 } }
return 0
}
+2 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Sign, check and publish the Daochi releases of apps the node offers.
"""Sign, check and publish the Mesh releases of apps the node offers.
The node serves each app as signed release v2 metadata beside its immutable
ZX portable executable. ZX hosts ask the node with format=zx and the ZX
@@ -591,7 +591,7 @@ def publish_node_app(store, name, target, remote_store, app_id=None):
if not re.fullmatch(r"[a-zA-Z0-9_.@-]+", target) or target.startswith("-"):
raise ValueError("invalid SSH target")
if not remote_store.startswith("/") or "\n" in remote_store:
raise ValueError("Daochi package store must be an absolute path")
raise ValueError("Mesh package store must be an absolute path")
with tempfile.TemporaryDirectory(prefix="inbe-upload-") as staging:
archive = Path(staging) / "packages.tar"
directory = store / (app_id or "inbe." + name)
+27 -27
View File
@@ -13,7 +13,7 @@
#import "kryon/http_transfer"
#import "catalog"
#import "protocol"
Release :: #import "daochi_client/release";
Release :: #import "mesh_client/release";
APP_REMOTE_METADATA_LIMIT :: 65536
APP_REMOTE_CATALOG_LIMIT :: 262144
@@ -35,7 +35,7 @@ AppRemoteSource :: struct {
AppRemoteCatalog :: struct {
source: AppRemoteSource
files: *AppFiles
verify: Release.DaochiReleaseVerify
verify: Release.MeshReleaseVerify
allowed: bool
failed: bool
changed: bool
@@ -46,14 +46,14 @@ AppRemoteCatalog :: struct {
response: [APP_REMOTE_METADATA_LIMIT + 1]u8
allocation: *u8
pending_metadata: string
pending_release: Release.DaochiRelease
pending_release: Release.MeshRelease
metadata: string
bytes: string
release: Release.DaochiRelease
release: Release.MeshRelease
// Retained until the consumer stops using its previous root collection.
previous_metadata: string
previous_bytes: string
previous_release: Release.DaochiRelease
previous_release: Release.MeshRelease
}
remote_memory :: #system_library "c";
@@ -81,12 +81,12 @@ AppRemoteOriginValid :: (origin: string) -> bool {
AppRemoteSourceValid :: (source: *AppRemoteSource) -> bool {
return source != null && AppRemoteOriginValid(TextUntilNul(source.origin[:])) &&
Release.DaochiIdentifierValid(TextUntilNul(source.app_id[:])) &&
Release.DaochiIdentifierValid(TextUntilNul(source.key_id[:])) &&
Release.DaochiHashValid(TextUntilNul(source.public_key[:])) &&
source.oldest_host_api > 0 && source.oldest_host_api <= source.host_api &&
source.host_api <= 65535 && source.module_api > 0 && source.module_api <= 65535 &&
source.minimum_sequence >= 0 && source.minimum_sequence <= 2147483647
Release.MeshIdentifierValid(TextUntilNul(source.app_id[:])) &&
Release.MeshIdentifierValid(TextUntilNul(source.key_id[:])) &&
Release.MeshHashValid(TextUntilNul(source.public_key[:])) &&
source.oldest_host_api > 0 && source.oldest_host_api <= source.host_api &&
source.host_api <= 65535 && source.module_api > 0 && source.module_api <= 65535 &&
source.minimum_sequence >= 0 && source.minimum_sequence <= 2147483647
}
AppRemoteSourceRead :: (json: string, at: s32, source: *AppRemoteSource) -> bool {
@@ -100,13 +100,13 @@ AppRemoteSourceRead :: (json: string, at: s32, source: *AppRemoteSource) -> bool
if cast(float64)source.minimum_sequence != number.value { return false }
}
return AppsReadText(json, at, "origin", source.origin[:]) &&
AppsReadText(json, at, "app_id", source.app_id[:]) &&
AppsReadText(json, at, "key_id", source.key_id[:]) &&
AppsReadText(json, at, "public_key", source.public_key[:]) && AppRemoteSourceValid(source)
AppsReadText(json, at, "app_id", source.app_id[:]) &&
AppsReadText(json, at, "key_id", source.key_id[:]) &&
AppsReadText(json, at, "public_key", source.public_key[:]) && AppRemoteSourceValid(source)
}
AppRemoteParse :: (remote: *AppRemoteCatalog, metadata: string) -> Release.DaochiRelease {
signed := Release.DaochiParseRelease(metadata, TextUntilNul(remote.source.public_key[:]),
AppRemoteParse :: (remote: *AppRemoteCatalog, metadata: string) -> Release.MeshRelease {
signed := Release.MeshParseRelease(metadata, TextUntilNul(remote.source.public_key[:]),
67108864, remote.verify)
if !signed.valid || TextUntilNul(signed.app_id[:]) != TextUntilNul(remote.source.app_id[:]) ||
TextUntilNul(signed.key_id[:]) != TextUntilNul(remote.source.key_id[:]) ||
@@ -115,7 +115,7 @@ AppRemoteParse :: (remote: *AppRemoteCatalog, metadata: string) -> Release.Daoch
signed.module_api != remote.source.module_api || signed.data_schema != 0 ||
signed.dependency_count != 0 || signed.sequence < remote.source.minimum_sequence ||
signed.artifacts[0].size > APP_REMOTE_CATALOG_LIMIT {
return Release.DaochiRelease.{}
return Release.MeshRelease.{}
}
return signed
}
@@ -132,16 +132,16 @@ AppRemoteRead :: (files: *AppFiles, name: string, maximum: s64) -> string {
return AppFileRead(files, name)
}
AppRemotePayloadName :: (release: *Release.DaochiRelease) -> string {
AppRemotePayloadName :: (release: *Release.MeshRelease) -> string {
name: Vec(u8)
BuilderPrint(*name, "%.zx", TextUntilNul(release.artifacts[0].sha256[:]))
return BuilderFinish(name)
}
AppRemoteCollectionValid :: (remote: *AppRemoteCatalog, bytes: string,
release: *Release.DaochiRelease) -> bool {
release: *Release.MeshRelease) -> bool {
if !release.valid || bytes.count != release.artifacts[0].size ||
!Release.DaochiSha256Matches(bytes, TextUntilNul(release.artifacts[0].sha256[:])) { return false }
!Release.MeshSha256Matches(bytes, TextUntilNul(release.artifacts[0].sha256[:])) { return false }
opened: HostedApp
if !HostedAppOpen(*opened, bytes) { return false }
defer { HostedAppClose(*opened) }
@@ -154,7 +154,7 @@ AppRemoteCollectionValid :: (remote: *AppRemoteCatalog, bytes: string,
// No network request is made here. Invalid cache bytes remain unexecuted.
// The AppFiles namespace belongs to this one configured collection.
AppRemoteCatalogOpen :: (remote: *AppRemoteCatalog, source: AppRemoteSource,
files: *AppFiles, verify: Release.DaochiReleaseVerify) -> bool {
files: *AppFiles, verify: Release.MeshReleaseVerify) -> bool {
if remote == null || remote.files != null || files == null || verify == null ||
!AppRemoteSourceValid(*source) { return false }
remote.source = source
@@ -184,7 +184,7 @@ AppRemoteCancelTransfer :: (remote: *AppRemoteCatalog) {
if remote.allocation != null { AppRemoteFree(remote.allocation); remote.allocation = null }
AppFileFree(remote.pending_metadata)
remote.pending_metadata = ""
remote.pending_release = Release.DaochiRelease.{}
remote.pending_release = Release.MeshRelease.{}
remote.stage = 0
}
@@ -237,7 +237,7 @@ AppRemoteFail :: (remote: *AppRemoteCatalog) {
remote.failed = true
}
AppRemoteAccept :: (remote: *AppRemoteCatalog, release: Release.DaochiRelease,
AppRemoteAccept :: (remote: *AppRemoteCatalog, release: Release.MeshRelease,
metadata: string, bytes: string) -> bool {
name := AppRemotePayloadName(*release)
defer { AppFileFree(name) }
@@ -271,7 +271,7 @@ AppRemoteCatalogPump :: (remote: *AppRemoteCatalog) {
signed := AppRemoteParse(remote, metadata)
if !signed.valid || (remote.ready && (signed.sequence < remote.release.sequence ||
(signed.sequence == remote.release.sequence &&
TextUntilNul(signed.artifacts[0].sha256[:]) != TextUntilNul(remote.release.artifacts[0].sha256[:])))) {
TextUntilNul(signed.artifacts[0].sha256[:]) != TextUntilNul(remote.release.artifacts[0].sha256[:])))) {
AppFileFree(metadata)
AppRemoteFail(remote)
return
@@ -320,7 +320,7 @@ AppRemoteCatalogCollect :: (remote: *AppRemoteCatalog) {
AppFileFree(remote.previous_bytes)
remote.previous_metadata = ""
remote.previous_bytes = ""
remote.previous_release = Release.DaochiRelease.{}
remote.previous_release = Release.MeshRelease.{}
remote.changed = false
AppRemotePruneCache(remote)
}
@@ -347,7 +347,7 @@ AppRemotePruneCache :: (remote: *AppRemoteCatalog) {
if !entry.valid { break }
name := TextUntilNul(entry.name[:])
if (entry.kind != .Regular && entry.kind != .Unknown) || name.count != 67 ||
name[64:] != ".zx" || !Release.DaochiHashValid(name[:64]) ||
name[64:] != ".zx" || !Release.MeshHashValid(name[:64]) ||
name[:64] == current_hash || (fallback.valid && name[:64] == previous_hash) { continue }
// AppFiles validates every component and refuses symbolic links.
path := AppFilePath(remote.files, name, false)
@@ -366,7 +366,7 @@ AppRemoteCatalogRestore :: (remote: *AppRemoteCatalog) -> bool {
remote.release = remote.previous_release
remote.previous_metadata = ""
remote.previous_bytes = ""
remote.previous_release = Release.DaochiRelease.{}
remote.previous_release = Release.MeshRelease.{}
remote.changed = false
remote.failed = true
return restored
+9 -9
View File
@@ -1,4 +1,4 @@
"""Link actual Apps and DaochiClient against an explicit canonical Crypto source.
"""Link actual Apps and Mesh Client against an explicit canonical Crypto source.
No package checkout, generated-code patch or consumer lock edit is involved.
The independent fixture uses real package-qualified imports on retained IR55.
@@ -18,7 +18,7 @@ def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("runtime", type=Path)
parser.add_argument("--crypto-source", type=Path, required=True)
parser.add_argument("--daochi-source", type=Path, required=True)
parser.add_argument("--mesh-source", type=Path, required=True)
args = parser.parse_args()
for name in ("DISPLAY", "WAYLAND_DISPLAY", "XAUTHORITY", "DBUS_SESSION_BUS_ADDRESS"):
os.environ.pop(name, None)
@@ -30,14 +30,14 @@ def main():
package = "p0000000000000001"
crypto_id = next(row.split("\t")[3] for row in mapping_rows if row.startswith("D\troot\tcrypto/sha256\t"))
old_crypto = next(row.split("\t")[2] for row in mapping_rows if row.startswith("P\t" + crypto_id + "\t"))
# Keep the resolved Daochi identity and its dependency edges when testing
# Keep the resolved Mesh identity and its dependency edges when testing
# another source root; the same file cannot be a second package module.
dao_id = next(row.split("\t")[3] for row in mapping_rows
if row.startswith("D\troot\tdaochi_client/crypto\t"))
old_dao = next(row.split("\t")[2] for row in mapping_rows
if row.startswith("P\t" + dao_id + "\t"))
mesh_id = next(row.split("\t")[3] for row in mapping_rows
if row.startswith("D\troot\tmesh_client/crypto\t"))
old_mesh = next(row.split("\t")[2] for row in mapping_rows
if row.startswith("P\t" + mesh_id + "\t"))
sources = [(old_crypto, args.crypto_source.resolve()),
(old_dao, args.daochi_source.resolve())]
(old_mesh, args.mesh_source.resolve())]
for row in mapping_rows:
fields = row.split("\t")
if len(fields) > 1 and fields[1] == "root":
@@ -68,7 +68,7 @@ def main():
"-I" + str(toolchain / "include"), *includes, *map(str, sorted(output.rglob("*.c"))),
str(args.runtime.resolve()), "-Wl,--gc-sections", "-lm", "-lpthread", "-o", str(WORK / "test")], check=True)
subprocess.run([str(WORK / "test")], check=True)
print("IR55 external Apps + DaochiClient + Crypto native link and unchanged SHA256/hex/HMAC APIs passed")
print("IR55 external Apps + Mesh Client + Crypto native link and unchanged SHA256/hex/HMAC APIs passed")
if __name__ == "__main__":
+11 -11
View File
@@ -72,15 +72,6 @@
"ref": "360553150917f352e49e1beb78917370792ccaef",
"url": "https://github.com/ziranlang/image-codec.git"
},
{
"commit": "970d5e44b1702158cb16469892da6ff50f142427",
"dependencies": {"crypto": "pc23fbf455e97614d", "oqs": "p7098ac9cd92f7e5f"},
"dependency_refs": {"crypto": "master", "oqs": "master"},
"id": "p6af0b5bd9fd0cd31",
"name": "DaochiClient",
"ref": "970d5e44b1702158cb16469892da6ff50f142427",
"url": "https://github.com/ziranlang/daochi-client.git"
},
{
"commit": "22d2ddbdc236796953c905a05a2cebf5ab1b4ff3",
"dependencies": {"liboqs": "p983c695d118b6109"},
@@ -99,6 +90,15 @@
"source": true,
"url": "https://aomedia.googlesource.com/aom"
},
{
"commit": "c1ac6095d01bcfdd4c5ae49c4636aaf9a0303449",
"dependencies": {"crypto": "pc23fbf455e97614d", "oqs": "p7098ac9cd92f7e5f"},
"dependency_refs": {"crypto": "master", "oqs": "master"},
"id": "p8204ae87a845c1c3",
"name": "mesh_client",
"ref": "c1ac6095d01bcfdd4c5ae49c4636aaf9a0303449",
"url": "https://github.com/ziranlang/mesh-client.git"
},
{
"commit": "e77d81dab791c13bf1c4e5d9a7160c403be9bbe0",
"dependencies": {},
@@ -181,8 +181,8 @@
}
],
"root": {
"dependencies": {"crypto": "pc23fbf455e97614d", "daochi_client": "p6af0b5bd9fd0cd31", "kryon": "peb1e86e2b07f33bb"},
"dependency_refs": {"crypto": "master", "daochi_client": "970d5e44b1702158cb16469892da6ff50f142427", "kryon": "3f72441949d4e16094834fa9220e5d7fa77a0ac0"},
"dependencies": {"crypto": "pc23fbf455e97614d", "kryon": "peb1e86e2b07f33bb", "mesh_client": "p8204ae87a845c1c3"},
"dependency_refs": {"crypto": "master", "kryon": "3f72441949d4e16094834fa9220e5d7fa77a0ac0", "mesh_client": "c1ac6095d01bcfdd4c5ae49c4636aaf9a0303449"},
"name": "Apps"
},
"toolchain": {
+3 -3
View File
@@ -31,6 +31,6 @@ ref = "3f72441949d4e16094834fa9220e5d7fa77a0ac0"
git = "https://github.com/ziranlang/crypto.git"
ref = "master"
[dependencies.daochi_client]
git = "https://github.com/ziranlang/daochi-client.git"
ref = "970d5e44b1702158cb16469892da6ff50f142427"
[dependencies.mesh_client]
git = "https://github.com/ziranlang/mesh-client.git"
ref = "c1ac6095d01bcfdd4c5ae49c4636aaf9a0303449"