Skip to content

Ariadne: a link: hole grants the subtree under its target - #905

Merged
transfix merged 1 commit into
masterfrom
feat/ariadne-link-subtree
Oct 30, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/ariadne-link-subtree

Conversation

@transfix

Copy link
Copy Markdown
Owner

Problem

A load: mount's link: hole is a transparent link on one node. Every reader (state_exec's state-* natives, bind.h) followed a link only on the last hop of a path, and findDescendant / operator() walk physical children. With link: {tree: s}, the module's bind: tree.a, (state-get "tree.a") and (state-children "tree.x") found the hole's own (empty) children, never s.a. So a view module could not be handed a parsed REST reply subtree (cypkg's search.res.packages.{i}.*, its roadmap item L14).

Fix: in cvc::state, as opt-in walks

The hole wiring cannot mirror a subtree the parent fills later, and changing findDescendant / operator() would change every state consumer (sync, JSON, sweeps, the link index). So cvc::state gains two path walks that follow a transparent link on every hop:

  • findThroughLinks(path): the read view. It creates nothing and follows the last hop too. A broken or cyclic link is walked as the plain node it is (resolvedValue's fallback).
  • childThroughLinks(path, refuse_read_only = false): the write view, create-or-get. A writable link continues at its target and throws read_only_error when unresolvable, as value(v) does. A read-only link continues at the link node's own children, so the write stays local, or the walk refuses when refuse_read_only is set. The last hop is left to value() / data().

Opaque links are never followed.

Users:

  • state_exec: state-get, state-exists, state-children, state-data-get and state-json read through the read view. state-set, state-data-set and state-from-json write through the write view. state-cas, state-swap and state-incr refuse a path through a read-only link, because their write would not land on the node a read sees (the rule they already follow for a read-only link at the last hop).
  • Ariadne: bind.h's read_or_seed, read_or, read_bool_or(_seed) and write, plus the Runtime's read_string. A widget bind under a hole works.

Default-deny

  • Only the hole's target and what is under it become reachable. A transparent link the parent keeps inside that subtree is followed, since it is part of the grant.
  • A read-only hole's writes stay on the hole's local children. Reads keep seeing the target.
  • Reconcile still clearLinks every hole, after which nothing under the old target is reachable (tested).
  • state-delete, the expiry natives and state-watch still act on the physical path and do not reach through a hole.

Tests

  • state_link_test: 11 StateLinkPath.* tests covering reads, the link's own children being ignored, opaque, broken, chain, cycle, rw / ro / refuse writes, an unresolvable rw link, and the last hop of a write.
  • state_exec_intrinsics_test: a hole chrooted at mod, with reads, rw writes (set, data-set, incr, cas) and ro writes. The ro case covers local writes, the atomics refusing, and from-json.
  • ariadne_runtime_test: a mount over search.res with a repeated tree.packages.{i}.name, an expression read, ro / rw slider commits, a later parent write showing through, and a reconcile tear-down.
  • ariadne_host_test: .ari load: modules with ro, rw and no grant, whose init: reads, lists, gets data and writes through the hole and cannot see the parent's search.secret.

All pass locally (Linux, RelWithDebInfo), as do 25 more suites touching ariadne, links and state_exec: ariadne_loader/bind/ftxui/scene_tf/requires/stream_view, state_test, state_link_*, state_transparent_link_index, state_exec_{scheduler,integration,advanced_integration,gaps,async,deep_data,data_steps,stdlib,exceptions}, world_clock, holon_sync, tf_editor and uri_http_cache.

Docs: ARIADNE.md §7.4 (the subtree grant and its ro/rw rules) and STATE_API.md (tree navigation).

Not changed (follow-ups)

  • state-children lists the whole subtree by full name (state::children(); fem_gallery.ari relies on that). Through a hole those are the target's absolute names: the module learns the parent's key names but cannot use them, since its paths stay chrooted. Same as before for a hole on one node.
  • The state:// URI resolver (uri_state.cpp) still follows a link on the last hop only.

A load: mount's link: hole was a transparent link on one node, and every reader
(state_exec's state-* natives, bind.h) followed a link only on the last hop of a
path. findDescendant and operator() walk physical children, so with
link: {tree: s} the module's bind: tree.a, (state-get "tree.a") and
(state-children "tree.x") found the hole's own (empty) children, never s.a. A
view module could not be handed a parsed reply subtree.

cvc::state gains two opt-in path walks that follow a transparent link on every
hop: findThroughLinks (read view, creates nothing, last hop followed) and
childThroughLinks (write view, create-or-get: a writable link continues at its
target, a read-only one at the link node's own children, or refuses with
refuse_read_only; the last hop is left to value()/data()). findDescendant and
operator() are unchanged.

state-get, state-exists, state-children, state-data-get and state-json read
through findThroughLinks; state-set, state-data-set and state-from-json write
through childThroughLinks; state-cas, state-swap and state-incr refuse a path
through a read-only link, since their write would not land on the node a read
sees. bind.h's read_or_seed / read_or / read_bool_or(_seed) / write and the
Runtime's read_string use the same walks, so a widget bind under a hole works.

Default-deny holds: only the hole's target and what is under it become
reachable, a read-only hole's writes stay local, and reconcile still clears the
holes. state-delete, the expiry natives and state-watch still act on the
physical path. Docs: ARIADNE.md 7.4, STATE_API.md tree navigation.
@transfix
transfix merged commit dc37ea0 into master Oct 30, 2026
20 of 26 checks passed
@transfix
transfix deleted the feat/ariadne-link-subtree branch October 30, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant