Activity: sources, the ask stamp and the committed snapshot
activity/sources.ts and the ask stamp in app.contract: how the inbox is requested with a signed time, and how a write's snapshot reaches the next read.

src/activity/sources.ts holds the two sources the root contract asks for the Activity tab. Two mechanisms around them deserve their own page: the ask stamp, which decides when a signed read happens, and the committed snapshot, which makes a write visible without a second request.

Sources

Source

Arguments

Behaviour

activityLoad

[server, account, active, offset, now]

Not active: an empty page with no account. No local key: emptyPage(server, account), without fetching. Otherwise resolve the notify URL, send a signed read and present it.

activityApply

[server, account, kind, value, eventAt, now, offset]

Builds one NotifyAction from kind, sends a signed write, and returns {ok, error, page}. Never throws.

kind is one of set-config (value is the email, validated by emailInput), mark-event-read (value is the event id, eventAt its time), mark-all-read, resend-config-verification, remove-config. Errors: Choose an identity in Me to manage activity., Unknown notification action., Could not update notifications., or the client's message.

The committed snapshot

A write returns the full canonical snapshot. The module keeps the resulting page in committed and hands it to the next activityLoad for the same account and server exactly once (L6-L8, L13-L18): "so a successful write never depends on a second HTTP request to become visible". Because the mutation is declared refreshes activityData, that next load is the mutation's own refresh.

The ask stamp

The comment at L126-L128 explains the design (review item B7): the inbox is asked with a signed time, "so its arguments are a stamp one action writes (activityAsk), never a clock read per frame". activityAskAt == 0 means not asking. Server and account are copied in the same action, "so an argument change always arrives with a fresh time inside notify's ±20 s window".

activityAsk stores performanceNow() in activityTick, copies server and currentAccount, and sets activityAskAt to time.epochAtZero + at, or to the previous value plus 1 when that would not be larger ("Retry at the same instant still asks again"). activityAskAt is passed after with, so it reaches the source as now and triggers a new request without being part of the answer's identity (The Contract language).

Why it matters

    The notify service accepts a signed time only within 20 seconds of its own clock. A resource whose argument was a live clock would either sign on every frame or go stale; the stamp makes each request an explicit event.

    The Contract test "a minute on the inbox signs one request" counts signed POSTs on the mock notify service to pin this.

    The Bun test "a successful mutation becomes visible from its snapshot even if the next network read fails" pins the committed handoff.

The general pattern is in State, refresh and stale-reply patterns.

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime

Connections0
Linked document · Outgoing linkLinked documentLinked document · Outgoing linkLinked documentLinked document · Outgoing linkLinked documentLinked document · Outgoing linkLinked documentLinked document · Outgoing linkLinked documentLinked document · Outgoing linkLinked documentLinked document · Outgoing linkLinked documentLinked document · Outgoing linkLinked documentLinked document · Outgoing linkLinked documentLinked document · Outgoing linkLinked documentLinked document · Outgoing linkLinked documentActivity: sources, the ask stamp and the committed snapshotActivity: sources, the as…
Citations 0Children & links 11

Loading child documents…

Connections show where other documents or comments link to this document.

Related documents

Loading connections…