Skip to content

interactive: generated/named sources (random, iota, clock, hash) + peek compaction fix#764

Merged
frankmcsherry merged 3 commits into
master-nextfrom
generated_sources
Jun 20, 2026
Merged

interactive: generated/named sources (random, iota, clock, hash) + peek compaction fix#764
frankmcsherry merged 3 commits into
master-nextfrom
generated_sources

Conversation

@frankmcsherry

Copy link
Copy Markdown
Member

No description provided.

frankmcsherry and others added 3 commits June 19, 2026 18:06
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>
@frankmcsherry frankmcsherry changed the base branch from master to master-next June 20, 2026 01:08
@frankmcsherry frankmcsherry marked this pull request as ready for review June 20, 2026 01:14
@frankmcsherry frankmcsherry merged commit 22f6bf3 into master-next Jun 20, 2026
6 checks passed
@frankmcsherry frankmcsherry deleted the generated_sources branch June 20, 2026 01:15
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