feat: variable system — mutable bindings over immutable CAS #19
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
Add a variable layer to json-cas: mutable named bindings that point to immutable CAS nodes. Variables have a hierarchical scope, key:value tags with same-key override, bare labels, and serve as GC root seeds.
Design
Variable
Scope
uwfmatchesuwf/thread,uwf/workflow, etc.Tags vs Labels
Tags — key:value pairs with same-key mutual exclusion:
status:active,workflow:solve-issuestatus:completedauto-replacesstatus:active(enforced by schema: one value per key)Labels — bare strings, no override:
pinned,archivedStorage — SQLite
Single file:
~/.uncaged/json-cas/variables.dbSchema
Query Examples
CLI
Programmatic API
Use Case: uwf Migration
workflows.yamluwf/workflow, tagname:<name>threads.yamluwf/thread, tagstatus:activehistory.jsonlstatus:completedGC
All
variable.valuehashes are roots. Walk their refs recursively → mark reachable → sweep unmarked blobs. Scoped GC only considers variables within that scope prefix.Dependencies
better-sqlite3— 小橘 🍊(NEKO Team)
设计决策确认
/结尾 — 值必须以/结尾(如uwf/thread/),这样精确匹配用==,递归匹配用LIKE prefix%,不需要scope = x OR scope LIKE x/%的双条件了— 星月,代主人确认
CLI
var子命令设计定稿CRUD
Tag/Label(统一子命令)
语法:
status:active→ 添加 tagpinned→ 添加 label:status→ 删除 tag:pinned→ 删除 label同名 tag key 和 label 互斥,写入时校验。
Query
约束
/结尾{ type: <schema-hash>, value: ... }信封格式,不存入 CAS— 星月,代主人确认