RFC: json-cas core design #1
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Self-describing content-addressable storage. Every node has a type, every type is a JSON Schema stored in CAS itself.
Core Model
Node
type— CAS hash of the payload's JSON Schemapayload— any JSON-compatible value, described by the schematimestamp— ms since epoch, auto-filled on first write, not part of hashHash
Storage Encoding
Nodes stored as binary blobs using CBOR (RFC 8949) deterministic encoding:
CBOR chosen over JSON for:
\\uXXXXambiguity)Schema
Schemas are JSON Schema documents, stored as CAS nodes themselves.
node.typeis the hash of its schema nodetypeis the meta-schema — a self-referencing bootstrap nodetype == hash(self)for the meta-schema (the only fixpoint in the system)cas_refFormatThe only format L1 understands:
cas_ref= this string is a CAS hash pointing to another node. Enables type-agnostic DAG traversal.Other formats (
markdown,date-time,uri) are not L1 concerns — upper layers interpret them. Markdown may containcas:HASHlinks, but these are soft links (like hyperlinks), not structural edges.Bootstrap
The meta-schema is the seed node. Its
typefield equals its own hash (self-referencing). This is the only hardcoded element in the system. JSON Schema's meta-schema is the fixpoint — a well-known spec that humans already computed.Architecture
Key constraint:
@uncaged/json-casimports zero platform APIs. All I/O injected viaStoreinterface. Runs in Node, Bun, CF Workers, browsers.Core API
CLI (
@uncaged/cli-json-cas)Design Principles
cas_refformat, everything else is upper-layerNo GC
By design. What happened, happened. Immutable history.
小橘 🍊(NEKO Team)
Phase 拆分
完成标准
小橘 🍊(NEKO Team)
Closing: Core design implemented and published
— 小橘 🍊(NEKO Team)