Skip to content

feat(rpc): report rule progress as built vs total rules#14985

Open
rgrinberg wants to merge 1 commit into
mainfrom
memo-rule-progress
Open

feat(rpc): report rule progress as built vs total rules#14985
rgrinberg wants to merge 1 commit into
mainfrom
memo-rule-progress

Conversation

@rgrinberg
Copy link
Copy Markdown
Member

@rgrinberg rgrinberg commented Jun 6, 2026

Rule progress now reports built vs total rules: the number of rules whose
value has been established this run, against the true total number of live
rules — instead of the previous "executed vs discovered", which counted only
the rules rebuilt this run (so an incremental build that was mostly cache hits
never approached 100%).

How

The counts are driven by Memo's on_event callback, wired into the rule and
anonymous-action memo nodes:

  • Live (a node becomes live this run) → number_of_rules_discovered. Because
    Live fires for every live rule, including cache-restored ones, this is now
    the true total.
  • Validated (its value established for the run) → the new
    number_of_rules_validated ("built").

in_progress = discovered - validated. The previous number_of_rules_executed
counter is no longer used and is removed.

Plumbing

on_event is a synchronous callback, so the build progress moves from a
Fiber.Svar.t to a plain ref. To keep the RPC server able to observe it,
Rpc.Server gains a long-poll Source: Svar (blocks on Svar.wait, as
before) or Computed (reads a thunk, polled every poll_every). The progress
poll uses a Computed source over the ref; errors and running-jobs keep
their Svars. The RPC wire type ({ complete; remaining; failed }) is
unchanged — only the values improve.

@rgrinberg rgrinberg force-pushed the memo-rule-progress branch from dd9f7af to 3fd483f Compare June 7, 2026 17:03
Rule progress now reports the number of rules whose value has been
established this run ("built") against the true total number of live rules,
rather than executed-vs-discovered counted only over the rules rebuilt this
run.

The counts are driven by Memo's [on_event] callback. [State.on_rule_event] is
wired into the rule and anonymous-action memo nodes: [Live] (a node becoming
live in the current run) increments [number_of_rules_discovered], and
[Validated] (its value established for the run) increments the new
[number_of_rules_validated]. Because [Live] fires for every live rule -
including ones restored from the cache - [number_of_rules_discovered] is now
the true total, not just the rules rebuilt this run. The previous
[number_of_rules_executed] counter, which counted only the rules rebuilt this
run, is no longer used and is removed.

[on_event] is a synchronous callback, so the build progress moves from a
[Fiber.Svar.t] to a plain [ref]. To keep the RPC server able to observe it,
[Rpc.Server] gains a long-poll [Source]: [Svar] (blocking on [Svar.wait], as
before) or [Computed] (read from a thunk and polled every [poll_every]). The
progress long poll uses a [Computed] source over the [ref]; the errors and
running-jobs long polls keep their [Svar]s. The status line and RPC progress
report built / total / in-progress.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
@rgrinberg rgrinberg force-pushed the memo-rule-progress branch from 3fd483f to 9df749a Compare June 7, 2026 17:47
@Alizter Alizter self-requested a review June 8, 2026 15:04
@Alizter Alizter self-assigned this Jun 8, 2026
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.

2 participants