@microdelta/tracking
v0.2.0
Published
Existing tracking context capability; implementation incomplete
Readme
Tracking & Observation
This package owns the scaffold's process-local tags, capture frames, cells, and reactive derivations. A tag or revision is not durable across processes.
The project-private createTrackingObserver(machine) alpha contract composes
those local utilities with Value's selected-fact encoding. Its
tracked(value, binding) method accepts supported objects, arrays, or functions
and copies the structural binding descriptor. Scalar reads and actually called
function code can be captured as immutable, versioned evidence. Reading through a tracked
container does not materialize unread siblings; returning a wrapper from capture
also does not make its contents an output dependency. A materializer can use the
narrow materialization.owns() and materialization.read() bridge to select
output fields without obtaining a raw source object.
materialization.lazyView(binding, source) creates an observer-owned view over
retained content that a materializer supplies node by node through a synchronous
ITrackedNodeSource. Its reads, lengths, in checks, keys(), hasOwn() and
explicit output detachment record the same evidence an in-memory wrapper records
for the same data; navigating through a container requests only that node's shape
and records nothing. The source answers one exact request at a time and is never
asked for siblings, the root payload or a whole subtree except for explicit
output. Asynchronous-only storage cannot implement the port.
An async callback that returns a tracked wrapper is subject to JavaScript Promise
thenable assimilation. For object and array wrappers, the runtime's then lookup
is captured as an actual consumed fact, including an absent then. Function
wrappers instead treat that probe as neutral: they return undefined without
recording an observation or invoking custom metadata. A non-configurable,
non-writable own data then with a non-undefined value cannot legally be hidden
by a Proxy and produces an explicit unsupported diagnostic. Ordinary function
calls are unchanged.
compareCurrent() asks a caller-owned provider to resolve each binding and its
current full path before comparing facts. Its comparison result is evidence only: it does not decide reuse, establish source freshness, or
reconstruct a durable definition. A called function contributes emitted
Function.prototype.toString() evidence and observed tracked reads; this does
not make arbitrary closure captures sound, and wrapping a function does not
memoize it. Only ordinary calls are supported: native or bound functions,
construction, and other function metadata/property access fail visibly. Explicit
keys() and hasOwn() helpers capture those operations. Native reflection,
unsupported Value inputs, native array methods, and unobservable object
identity/coercion are outside this bounded surface.
untracked(view, key) is the explicit, observed untracked read: it returns one
scalar member (or an array's length) of an observer-owned view without
consuming its fact. Inside a capture it records an untracked-read observation
(binding and address, MDU1; never the value read), and
untrackedReadObserved() reports whether the active capture has made such a
read, directly or through a replayed derivation. Comparison skips these
observations: they carry no fact. A consumer such as Reuse Resolution uses the
query to mark later derived work as unjustified by recorded evidence.
These runnable alpha owner contracts are not the complete durable authoring API. History persistence, binding registry, output materialization and reuse eligibility remain separate owners. See the package map.
