apps 0.0.1-beta.76 → 0.0.1-beta.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,12 @@ export interface CacheGet<A> {
21
21
  /** Create a scoped cache client; a background runner must retain all task resources until completion. */
22
22
  export declare const makeCache: (host: CacheTransport, background: (task: Effect.Effect<void, unknown>) => Effect.Effect<void>, scope?: Schema.Json,
23
23
  /** The caller's own deadline, when the host supplies one. Waiting never runs past it. */
24
- deadline?: number) => {
24
+ deadline?: number,
25
+ /**
26
+ * Wraps the time this caller waits on another caller's load of the same entry, polls included,
27
+ * so the host can trace it and count it as waiting rather than as its own work.
28
+ */
29
+ leaseWait?: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>) => {
25
30
  /** Read arbitrary retained JSON entries without initiating a refresh. Missing and null are distinct. */
26
31
  read: (keys: readonly Schema.Json[]) => Effect.Effect<readonly ({
27
32
  readonly value: Schema.Json;
@@ -730,6 +730,13 @@ export declare const InvocationTiming: Schema.Struct<{
730
730
  readonly upstreamMs: Schema.Finite;
731
731
  readonly elicitationMs: Schema.Finite;
732
732
  readonly authoredMs: Schema.Finite;
733
+ /** Waiting on another call that holds the lease to load a cache entry this call needs. */
734
+ readonly leaseMs: Schema.optionalKey<Schema.Finite>;
735
+ /**
736
+ * How long background work, such as a stale cache entry's refresh, ran within the invocation.
737
+ * It runs beside the invocation, so it is not part of the division above.
738
+ */
739
+ readonly backgroundMs: Schema.optionalKey<Schema.Finite>;
733
740
  }>;
734
741
  export type InvocationTiming = typeof InvocationTiming.Type;
735
742
  /** Receives the invocation's timing once it is over; hosts that do not return it ignore it. */
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Divide a tool invocation's time, on its own isolate's clock, by who the work belonged to:
3
- * Executor, the app's authored code, upstream providers, or a person answering an elicitation.
3
+ * Executor, the app's authored code, upstream providers, a person answering an elicitation, or
4
+ * another call loading a cache entry this one waits for. Background work no caller waits on runs
5
+ * beside the division and is reported apart.
4
6
  * Each boundary declares its owner where the work starts (see `owned`); the invocation's own span is
5
7
  * Executor's. The host adds the other isolates' parts.
6
8
  */
@@ -3,7 +3,9 @@
3
3
  * starts work for someone other than its caller declares the owner with `ownedBy`; any other span
4
4
  * works for whoever its parent works for. Each instant then belongs to the innermost boundary in
5
5
  * progress, so Executor's work inside an upstream session stays Executor's, and an app's callback
6
- * inside Executor's cache stays the app's.
6
+ * inside Executor's cache stays the app's. Background work is the exception: everything inside it
7
+ * is background, and it runs beside its caller rather than inside it. It takes no instant from the
8
+ * caller's window; how long it ran within the window is reported beside the division.
7
9
  *
8
10
  * Workers clocks advance only on I/O, so durations are comparable within one isolate and not across
9
11
  * isolates: each isolate measures its own part, and the spans that already bracket the work define
@@ -11,10 +13,11 @@
11
13
  */
12
14
  import { Context, Effect, Tracer } from "effect";
13
15
  /**
14
- * Executor's own work; the app's authored code; waiting on an upstream provider; or waiting on a
15
- * person's answer.
16
+ * Executor's own work; the app's authored code; waiting on an upstream provider; waiting on a
17
+ * person's answer; waiting on another call that holds the lease to load a cache entry; or work
18
+ * handed to the background, such as refreshing a stale cache entry, that no caller waits on.
16
19
  */
17
- export type Owner = "executor" | "app" | "upstream" | "person";
20
+ export type Owner = "executor" | "app" | "upstream" | "person" | "lease" | "background";
18
21
  /** The attribute that shows a boundary's owner in the trace; the telemetry tracer sets it. */
19
22
  export declare const ownerAttribute = "executor.owner";
20
23
  /** The owner a span declared when it started, if it is an ownership boundary. */
@@ -44,6 +47,7 @@ export declare const measuredSpan: (name: string, options: Tracer.SpanOptionsNoT
44
47
  * instant, the work in progress is the innermost span of each branch: a span with no child still
45
48
  * open. Its owner takes the instant. With nothing open inside the window, `owner` takes it. Spans
46
49
  * are counted as they open and end, in constant time each, and only spans still open are kept.
50
+ * `background` is not part of the division: it is how long background work was in progress.
47
51
  */
48
52
  export declare const makeOwnershipAccounting: (origin: bigint, owner: Owner) => {
49
53
  /** Run `effect` with the spans it opens observed, including spans it hands to later work. */