interactive: generated/named sources (random, iota, clock, hash) + peek compaction fix#764
Merged
Merged
Conversation
A program may `import` a recipe name instead of another program's export: `random:nodes=N,edges=E[,arity=A][,seed=S]` is a deterministic random graph (rows `(Tuple[a,b] ; ())`, the shape a raw input delivers). The first import installs the generator on demand; the source is content-addressed (canonicalized name, defaults filled), so two importers of the same recipe — in any key order — share one generated source, generated once. A generated source is modeled as an ordinary installed program: a one-input dataflow pre-filled with the recipe's rows at time 0 (sharded e%peers==index so the union is the full graph exactly once), published as a trace. It therefore advances on `tick`, is refcount-gated and `drop_dataflow`-torn-down like any program, and shows up in `list` tagged `[generated]`. It is not writable: `feed` to it is refused. This is the first step toward unifying `input` and `import` (a generated source is just an `import` whose data is computed); `Source::Input` is untouched for now. - ir/lib: `gen_row_seeded` (seed 0 reproduces `gen_row` exactly, so ddir_vec is unaffected); `Recipe` parse/canonicalize/row + `canonical_source_name` in the server, applied at install/feed/peek/drop so sources resolve by content. - examples/server: reach_gen.ddp, count_gen.ddp, sessions/generated.txt, README. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add the composable primitives behind generated sources, so a derived source is written in-language rather than baked in: - `iota:N` — a generated source of rows (0)..(N-1) (the minimal index source). - `clock` — a single-row ticking source holding the current epoch, advanced by one each tick as an O(1) change (retract old, add new), produced on worker 0; modeled as an `Origin::Clock` entry so it advances in `tick`, is gated/dropped like any source, and is refused by `feed`. - `hash(bound, keys…)` — a scalar `Term` builtin: a deterministic draw in `[0, bound)` from the key ints (raw non-negative hash if bound <= 0). With these, `random:…` is just sugar: import "iota:N" | map( hash(b,$0[0],0) ; hash(b,$0[0],1) ) `Recipe` becomes an enum (Random | Iota); `Installed.generated: bool` becomes `Installed.origin: Origin` (Program | Generated | Clock). A naive `iota × clock` generator is deliberately *not* shipped — it spends its time reconciling the input diff; the efficient log-work form is future work. Adds programs rand_reach.ddp, clock_watch.ddp and sessions derived.txt, clock.txt; README updated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
tick compacted traces to [epoch], but peek reads the closed past (t < epoch); once a batch merge advanced that history forward onto epoch it fell out of peek's window, leaving peek with only the latest epoch's delta. Hold compaction at epoch-1 to match peek's read frontier. saturating_sub guards epoch == 0 (tick only runs at epoch >= 1). Fixing on the compaction side is the right layer: peek's `t < epoch` filter is load-bearing — it excludes future-scheduled `time=` feeds — so "sum all times" is not a valid alternative on the peek side. Reported by a user; thank you. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.