@loomwork/ui-changes 0.0.0-stage → 0.1.0
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.
- package/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +134 -2
- package/dist/conformance.d.ts +18 -0
- package/dist/conformance.d.ts.map +1 -0
- package/dist/conformance.js +243 -0
- package/dist/conformance.js.map +1 -0
- package/dist/cursor.d.ts +43 -0
- package/dist/cursor.d.ts.map +1 -0
- package/dist/cursor.js +50 -0
- package/dist/cursor.js.map +1 -0
- package/dist/esm/conformance.js +239 -0
- package/dist/esm/conformance.js.map +1 -0
- package/dist/esm/cursor.js +44 -0
- package/dist/esm/cursor.js.map +1 -0
- package/dist/esm/feed.js +301 -0
- package/dist/esm/feed.js.map +1 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/signal.js +141 -0
- package/dist/esm/signal.js.map +1 -0
- package/dist/esm/untrusted.js +14 -0
- package/dist/esm/untrusted.js.map +1 -0
- package/dist/feed.d.ts +125 -0
- package/dist/feed.d.ts.map +1 -0
- package/dist/feed.js +305 -0
- package/dist/feed.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/signal.d.ts +33 -0
- package/dist/signal.d.ts.map +1 -0
- package/dist/signal.js +145 -0
- package/dist/signal.js.map +1 -0
- package/dist/untrusted.d.ts +5 -0
- package/dist/untrusted.d.ts.map +1 -0
- package/dist/untrusted.js +17 -0
- package/dist/untrusted.js.map +1 -0
- package/package.json +60 -3
- package/src/conformance.ts +248 -0
- package/src/cursor.ts +89 -0
- package/src/feed.ts +446 -0
- package/src/index.ts +18 -0
- package/src/signal.ts +200 -0
- package/src/untrusted.ts +16 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
package/NOTICE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
loom-ui
|
|
2
|
+
Copyright 2026 Sushil Chhetri
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this project except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
package/README.md
CHANGED
|
@@ -1,3 +1,135 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @loomwork/ui-changes
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Ambient change delivery.** When an experience changes while nobody is looking, the people it
|
|
4
|
+
concerns should hear about it at the right volume, and never about content they may not see.
|
|
5
|
+
This package is the server-side half: a feed over the lineage log, a per-viewer unread cursor, and
|
|
6
|
+
signals that say "this experience has a new head". It is **optional** and **server-side** (it reads
|
|
7
|
+
the lineage and content stores; `hydration`'s client guards name it among the packages a client
|
|
8
|
+
graph must not reach). The pure half is in `@loomwork/ui-core`: `describeChange`, `boundSummary`,
|
|
9
|
+
the attention vocabulary and the `HeadSignal` types (types only, so a browser can implement one
|
|
10
|
+
with a `fetch` loop).
|
|
11
|
+
|
|
12
|
+
## Install / import
|
|
13
|
+
|
|
14
|
+
```jsonc
|
|
15
|
+
// package.json of a consumer checked out beside this repo (the packages are not published)
|
|
16
|
+
"@loomwork/ui-changes": "link:../loom-ui/packages/changes"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Entry point: `@loomwork/ui-changes` (server-side only; Node, CommonJS and ESM).
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { describeChange } from "@loomwork/ui-core";
|
|
25
|
+
import { LineageChangeFeed, pollingHeadSignal, InMemoryUnreadStore, unreadChanges, markRead } from "@loomwork/ui-changes";
|
|
26
|
+
|
|
27
|
+
const feed = new LineageChangeFeed({ lineage, events, signal: pollingHeadSignal(events) });
|
|
28
|
+
// The feed inherits `lineage.readPolicy`; pass `readPolicy` here to bind more. `describe`'s per-call
|
|
29
|
+
// `declaredToolClasses` / `undeclared` only ADD to it, and a bound `projections` catalogue is not replaced.
|
|
30
|
+
feed.subscribe("exp-1", async (event) => {
|
|
31
|
+
const d = await feed.describe(event, { viewer }); // viewer-safe; see below
|
|
32
|
+
if (d.ok && d.description.attention !== "none") notify(viewer, d.description);
|
|
33
|
+
}, { after: savedCursor });
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Design
|
|
37
|
+
|
|
38
|
+
**A change event says THAT, never WHAT.** `ChangeEvent` is `{ id, experienceId, sequence, at, kind,
|
|
39
|
+
versionHash, base }` (`kind`: composed / reverted / branched / promoted; `base`: what it replaced).
|
|
40
|
+
No node, no data, no text: the log holds content some viewer may not see, and what a change *means*
|
|
41
|
+
is per viewer. `feed.describe(event, { viewer })` loads the two artifacts and runs `describeChange`.
|
|
42
|
+
The event is a CLAIM, not the log: `describe` looks the record up by (experience, sequence) and
|
|
43
|
+
refuses an event whose `kind`, `versionHash` or `base` differs from it (`event-mismatch`; a forged
|
|
44
|
+
`base` cannot make it describe another line). It takes `projections` (the same `ProjectionCatalog`
|
|
45
|
+
`compile` takes) at construction: absent, every projection-bound node is hidden from every viewer;
|
|
46
|
+
an unknown id or a drifted version pin hides it too.
|
|
47
|
+
|
|
48
|
+
**Delivery.** The cursor is the log's own dense sequence, so it survives a restart. `id` is
|
|
49
|
+
`<experienceId>#<sequence>`, a pure function of the log position: re-reading a range, or
|
|
50
|
+
resubscribing from an older cursor, yields the same ids, so at-least-once delivery is made
|
|
51
|
+
idempotent by deduping on `id`. `subscribe` catches up from `after`, then follows; events arrive in
|
|
52
|
+
order, one at a time. A handler that throws (or a read that fails) is reported (`onError`) and the
|
|
53
|
+
event is NOT advanced past: it is retried on a bounded, jittered exponential backoff (`retry: {
|
|
54
|
+
baseMs, maxMs }`, default 250ms to 30s; `unref`'d, cleared on unsubscribe), WITHOUT waiting for a
|
|
55
|
+
new append, so a quiet line is never stuck. A poison event (one that fails every time) stalls only
|
|
56
|
+
its own subscription. Two ways out: `onPoison(event, attempts)` returns `true` to skip it (a host
|
|
57
|
+
dead-letters there), or the host resubscribes with `after: <poison sequence>`. `read` folds and
|
|
58
|
+
validates the whole line, so it costs O(log length) per call; cache above the seam. A malformed log
|
|
59
|
+
is a finding, never partial events. `checkChangeFeedConformance(make)` is the kit any feed must
|
|
60
|
+
pass.
|
|
61
|
+
|
|
62
|
+
**Unread.** `unreadChanges` counts every event past the cursor, including ones that are
|
|
63
|
+
all-restricted for the viewer: that is the same existence signal `restricted-changed` gives, by
|
|
64
|
+
design. `UnreadStore` holds one cursor per (viewer, experience) and only moves it forward (`advance`
|
|
65
|
+
= max; a replayed acknowledgement is harmless). `markRead` clamps to the log's tip, so a viewer
|
|
66
|
+
cannot pre-read the future. `viewerId` is the caller's claim: no authentication here.
|
|
67
|
+
`checkUnreadStoreConformance(make)` is the kit; `InMemoryUnreadStore` is the reference.
|
|
68
|
+
|
|
69
|
+
**Describing a change (`describeChange(prev, next, opts)`, core).** Pure and deterministic, bounded
|
|
70
|
+
(`maxEntries`, default 50, hard cap 500; `omitted` says how many were left out). Kinds: node added /
|
|
71
|
+
removed / moved / rebound / reclassified / edited, provider added / removed / changed, intent
|
|
72
|
+
changed, and `restricted-changed`. `ops`, when the caller has them, add whether a prompt produced
|
|
73
|
+
it.
|
|
74
|
+
|
|
75
|
+
*Viewer-safe, fail-closed.* A node is restricted if the viewer may not see its class in EITHER
|
|
76
|
+
version (a node that became classified counts; so does one that was declassified); a provider by its
|
|
77
|
+
effective handle class; the intent by its own class. Every change touching restricted content
|
|
78
|
+
collapses into **one bare `restricted-changed` entry** (no id, type, handle, kind-of-change or
|
|
79
|
+
count), so "a restricted node was edited" and "a different restricted node was removed" are
|
|
80
|
+
byte-identical: no existence oracle, consistent with the restricted placeholder `compile` draws. No
|
|
81
|
+
viewer is the most restrictive viewer. The identity report covers only visible nodes. Unreadable
|
|
82
|
+
input yields `restricted-changed`, never a throw and never a clean "nothing changed".
|
|
83
|
+
|
|
84
|
+
**Attention.** `none | info | attention | urgent`. The default classifier maps change kinds to
|
|
85
|
+
levels (edits and moves are `info`; add/remove/rebind/provider/intent changes are `attention`;
|
|
86
|
+
restricted content is `info`, pinned by a test; a truncated description is at least `attention`). A
|
|
87
|
+
host passes `classify(description)` to decide for itself; it receives the REDACTED description, so
|
|
88
|
+
it cannot leak what the viewer may not see, and a throwing or out-of-vocabulary answer falls back to
|
|
89
|
+
the default.
|
|
90
|
+
|
|
91
|
+
**The summary is model text.** `PlanResult.summary` (planner) is bounded and stripped of control and
|
|
92
|
+
bidi characters, handed to `lineage.compose({ summary, summaryClass })` (stored on the
|
|
93
|
+
`EXPERIENCE_COMPOSED` event, bounded again when read, since the log is untrusted), and surfaces on a
|
|
94
|
+
description as `UntrustedText { untrusted: true, text }`: display it as text, never act on it, never
|
|
95
|
+
trust it as a statement of what the ops do. **It is written from the WHOLE experience, not the
|
|
96
|
+
diff**, so it is shown only when the viewer may see the strictest class of everything either version
|
|
97
|
+
carries (every node, effective handle/tool/projection class, both intents: `experienceClassFloor`)
|
|
98
|
+
AND of what the planner read (`summaryClass`, host-stamped on the event, off the content address).
|
|
99
|
+
It is also dropped when restricted content changed or a projection node is hidden from everyone. The
|
|
100
|
+
reference planner stamps `PlanResult.summaryClass` from the experience it saw and `contextClass`
|
|
101
|
+
(`ComposeInput` / `ReviseInput`); **a host whose planner read classified context or tool samples
|
|
102
|
+
MUST pass `contextClass`** (the planner cannot classify them), else only the floor gates the
|
|
103
|
+
summary. To hand a summary to another model, use `summaryAsTainted(summary)` (loom's ADR 0085
|
|
104
|
+
`TaintedValue`, server-side only) and NEVER put it in a prompt's instruction position.
|
|
105
|
+
|
|
106
|
+
**Refresh / push providers.** `HeadSignal.watch(experienceId, onChange)` tells a reader "the log
|
|
107
|
+
moved past what you last saw" with `{ sequence, head, promoted }` (at-least-once; `sequence` is the
|
|
108
|
+
idempotency key; the first call reports the current state of a non-empty line).
|
|
109
|
+
- `pollingHeadSignal(store, { intervalMs })`: a timer, one read per tick per watcher. Works over any
|
|
110
|
+
`LineageStore`. A missed beat is only latency.
|
|
111
|
+
- `eventStoreHeadSignal(eventStore, store, { fallbackIntervalMs? })`: push (plus an optional
|
|
112
|
+
safety-net poll), via `EventStore.subscribe` on the line's stream. `@loomwork/live-query` was checked
|
|
113
|
+
and does not fit (it folds an *execution's* state, not a lineage stream); the push primitive
|
|
114
|
+
underneath it is used directly. A host with its own transport (websocket, SSE, a database notify)
|
|
115
|
+
implements `HeadSignal`, one method.
|
|
116
|
+
|
|
117
|
+
**Sealed lines.** Over a lineage sealed per owner (see the lineage README, "Erasure") the feed
|
|
118
|
+
INHERITS the lineage's `confirmErased` hook: `read`/`describe` refuse `line-erased` (confirmed) or
|
|
119
|
+
`line-unreadable` (not confirmed), and a subscription on a confirmed-erased line reports it once and
|
|
120
|
+
stops (no retry timer, no further wakes). An unconfirmed `line-unreadable` line keeps retrying, since
|
|
121
|
+
the key may come back to this node. A head signal is built over a store, so it takes its own
|
|
122
|
+
`confirmErased` option; it reports `LineErasedError` once and goes terminal, or
|
|
123
|
+
`LineUnreadableError` on every check.
|
|
124
|
+
|
|
125
|
+
## Not in this package
|
|
126
|
+
|
|
127
|
+
Authorization (who may see an experience at all), delivery transport (email, push, a toast), and
|
|
128
|
+
digesting/throttling notifications: those are the host's, built on the events and descriptions here.
|
|
129
|
+
|
|
130
|
+
## See also
|
|
131
|
+
|
|
132
|
+
- [../lineage/README.md](../lineage/README.md) — the event log this feed reads.
|
|
133
|
+
- [../core/README.md](../core/README.md) — `describeChange`, `boundSummary` and the `HeadSignal`
|
|
134
|
+
types.
|
|
135
|
+
- [../../README.md](../../README.md) — root overview.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Finding } from "@loomwork/ui-core";
|
|
2
|
+
import type { UnreadStore } from "./cursor";
|
|
3
|
+
import type { ChangeFeed } from "./feed";
|
|
4
|
+
export interface FeedHarness {
|
|
5
|
+
readonly feed: ChangeFeed;
|
|
6
|
+
/** Append one new version to `experienceId`'s line (the first call starts the line). */
|
|
7
|
+
compose(experienceId: string): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Force one wake of the feed's signal, for a deterministic harness (a manual-tick signal). Omit
|
|
10
|
+
* for a real timer/push signal: the kit then waits (up to `waitMs`) for delivery.
|
|
11
|
+
*/
|
|
12
|
+
tick?(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export declare function checkChangeFeedConformance(make: () => FeedHarness | Promise<FeedHarness>, opts?: {
|
|
15
|
+
waitMs?: number;
|
|
16
|
+
}): Promise<Finding[]>;
|
|
17
|
+
export declare function checkUnreadStoreConformance(make: () => UnreadStore | Promise<UnreadStore>): Promise<Finding[]>;
|
|
18
|
+
//# sourceMappingURL=conformance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance.d.ts","sourceRoot":"","sources":["../src/conformance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,QAAQ,CAAC;AAMtD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,wFAAwF;IACxF,OAAO,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C;;;OAGG;IACH,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAcD,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,EAC9C,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAC7B,OAAO,CAAC,OAAO,EAAE,CAAC,CA6IpB;AAED,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,GAC7C,OAAO,CAAC,OAAO,EAAE,CAAC,CAoEpB"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkChangeFeedConformance = checkChangeFeedConformance;
|
|
4
|
+
exports.checkUnreadStoreConformance = checkUnreadStoreConformance;
|
|
5
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
6
|
+
async function until(cond, tick, waitMs) {
|
|
7
|
+
const end = Date.now() + waitMs;
|
|
8
|
+
for (;;) {
|
|
9
|
+
if (tick !== undefined)
|
|
10
|
+
await tick();
|
|
11
|
+
if (cond())
|
|
12
|
+
return true;
|
|
13
|
+
if (Date.now() > end)
|
|
14
|
+
return false;
|
|
15
|
+
await sleep(5);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async function checkChangeFeedConformance(make, opts = {}) {
|
|
19
|
+
const findings = [];
|
|
20
|
+
const fail = (code, message) => findings.push({ code, severity: "error", message });
|
|
21
|
+
const waitMs = opts.waitMs ?? 1500;
|
|
22
|
+
const h = await make();
|
|
23
|
+
const read = async (id, o) => {
|
|
24
|
+
const r = await h.feed.read(id, o);
|
|
25
|
+
if (!r.ok)
|
|
26
|
+
throw new Error(`read failed: ${r.finding.message}`);
|
|
27
|
+
return r;
|
|
28
|
+
};
|
|
29
|
+
const cases = [
|
|
30
|
+
[
|
|
31
|
+
"an unknown line reads empty with tip 0",
|
|
32
|
+
async () => {
|
|
33
|
+
const r = await read("f-empty");
|
|
34
|
+
if (r.events.length !== 0 || r.cursor !== 0 || r.tip !== 0 || r.more)
|
|
35
|
+
fail("read-empty", `an unknown line read ${JSON.stringify(r)}`);
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
[
|
|
39
|
+
"events are dense, ordered, with unique ids that are stable across reads",
|
|
40
|
+
async () => {
|
|
41
|
+
for (let i = 0; i < 3; i++)
|
|
42
|
+
await h.compose("f-ids");
|
|
43
|
+
const a = await read("f-ids");
|
|
44
|
+
const b = await read("f-ids");
|
|
45
|
+
if (a.events.map((e) => e.sequence).join() !== "1,2,3")
|
|
46
|
+
fail("sequence", `sequences ${a.events.map((e) => e.sequence).join()} are not 1,2,3`);
|
|
47
|
+
if (new Set(a.events.map((e) => e.id)).size !== a.events.length)
|
|
48
|
+
fail("ids-unique", "two events share an id");
|
|
49
|
+
if (a.events.map((e) => e.id).join() !== b.events.map((e) => e.id).join())
|
|
50
|
+
fail("ids-stable", "re-reading the same range changed an id");
|
|
51
|
+
if (a.cursor !== 3 || a.tip !== 3)
|
|
52
|
+
fail("cursor", `cursor/tip were ${a.cursor}/${a.tip}`);
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
"reading after a cursor returns only later events",
|
|
57
|
+
async () => {
|
|
58
|
+
for (let i = 0; i < 3; i++)
|
|
59
|
+
await h.compose("f-resume");
|
|
60
|
+
const r = await read("f-resume", { after: 1 });
|
|
61
|
+
if (r.events.map((e) => e.sequence).join() !== "2,3")
|
|
62
|
+
fail("resume", `after 1 returned ${r.events.map((e) => e.sequence).join()}`);
|
|
63
|
+
const none = await read("f-resume", { after: 3 });
|
|
64
|
+
if (none.events.length !== 0 || none.cursor !== 3)
|
|
65
|
+
fail("resume-end", `after the tip returned ${JSON.stringify(none)}`);
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
[
|
|
69
|
+
"paging by limit visits every event once, in order",
|
|
70
|
+
async () => {
|
|
71
|
+
for (let i = 0; i < 5; i++)
|
|
72
|
+
await h.compose("f-page");
|
|
73
|
+
const seen = [];
|
|
74
|
+
let cursor = 0;
|
|
75
|
+
for (let guard = 0; guard < 10; guard++) {
|
|
76
|
+
const r = await read("f-page", { after: cursor, limit: 2 });
|
|
77
|
+
if (r.events.length > 2)
|
|
78
|
+
fail("limit", `limit 2 returned ${r.events.length}`);
|
|
79
|
+
seen.push(...r.events.map((e) => e.sequence));
|
|
80
|
+
cursor = r.cursor;
|
|
81
|
+
if (!r.more)
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
if (seen.join() !== "1,2,3,4,5")
|
|
85
|
+
fail("paging", `paging saw ${seen.join()}`);
|
|
86
|
+
const bad = await h.feed.read("f-page", { after: -1 });
|
|
87
|
+
if (bad.ok)
|
|
88
|
+
fail("cursor-invalid", "a negative cursor was accepted");
|
|
89
|
+
const badLimit = await h.feed.read("f-page", { limit: 0 });
|
|
90
|
+
if (badLimit.ok)
|
|
91
|
+
fail("limit-invalid", "a zero limit was accepted");
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
[
|
|
95
|
+
"subscribe catches up from a cursor, then follows live, in order",
|
|
96
|
+
async () => {
|
|
97
|
+
await h.compose("f-sub");
|
|
98
|
+
await h.compose("f-sub");
|
|
99
|
+
const got = [];
|
|
100
|
+
const off = h.feed.subscribe("f-sub", (e) => void got.push(e), { after: 1 });
|
|
101
|
+
const caught = await until(() => got.length >= 1, h.tick, waitMs);
|
|
102
|
+
if (!caught || got[0]?.sequence !== 2)
|
|
103
|
+
fail("sub-catchup", `catch-up from 1 delivered ${got.map((e) => e.sequence).join()}`);
|
|
104
|
+
await h.compose("f-sub");
|
|
105
|
+
const live = await until(() => got.length >= 2, h.tick, waitMs);
|
|
106
|
+
if (!live || got.map((e) => e.sequence).join() !== "2,3")
|
|
107
|
+
fail("sub-live", `live delivery gave ${got.map((e) => e.sequence).join()}`);
|
|
108
|
+
off();
|
|
109
|
+
await h.compose("f-sub");
|
|
110
|
+
await sleep(40);
|
|
111
|
+
if (h.tick)
|
|
112
|
+
await h.tick();
|
|
113
|
+
await sleep(20);
|
|
114
|
+
if (got.length !== 2)
|
|
115
|
+
fail("sub-off", "an event was delivered after unsubscribe");
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
[
|
|
119
|
+
"resubscribing from an older cursor redelivers the SAME ids (at-least-once, idempotent)",
|
|
120
|
+
async () => {
|
|
121
|
+
await h.compose("f-redo");
|
|
122
|
+
await h.compose("f-redo");
|
|
123
|
+
const first = [];
|
|
124
|
+
const offA = h.feed.subscribe("f-redo", (e) => void first.push(e.id));
|
|
125
|
+
await until(() => first.length >= 2, h.tick, waitMs);
|
|
126
|
+
offA();
|
|
127
|
+
const again = [];
|
|
128
|
+
const offB = h.feed.subscribe("f-redo", (e) => void again.push(e.id), { after: 0 });
|
|
129
|
+
await until(() => again.length >= 2, h.tick, waitMs);
|
|
130
|
+
offB();
|
|
131
|
+
if (first.join() !== again.join() || first.length !== 2)
|
|
132
|
+
fail("redelivery", `first ${first.join()} vs again ${again.join()}`);
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
[
|
|
136
|
+
"a throwing handler is reported, not advanced past, and the event is delivered again",
|
|
137
|
+
async () => {
|
|
138
|
+
await h.compose("f-throw");
|
|
139
|
+
const errors = [];
|
|
140
|
+
const ids = [];
|
|
141
|
+
let attempts = 0;
|
|
142
|
+
const off = h.feed.subscribe("f-throw", (e) => {
|
|
143
|
+
attempts += 1;
|
|
144
|
+
if (attempts === 1)
|
|
145
|
+
throw new Error("handler down");
|
|
146
|
+
ids.push(e.id);
|
|
147
|
+
}, { onError: (e) => void errors.push(e), retry: { baseMs: 5, maxMs: 20 } });
|
|
148
|
+
await until(() => errors.length >= 1, h.tick, waitMs);
|
|
149
|
+
if (errors.length < 1)
|
|
150
|
+
fail("handler-error", "a throwing handler was not reported");
|
|
151
|
+
// NO append and NO signal from here: a quiet line must still redeliver the failed event
|
|
152
|
+
// (a feed that retries only when the head moves leaves it stuck).
|
|
153
|
+
await until(() => ids.length >= 1, undefined, waitMs);
|
|
154
|
+
off();
|
|
155
|
+
if (ids.join() !== "f-throw#1")
|
|
156
|
+
fail("handler-retry", `after a throw on a quiet line the handler saw ${ids.join()}`);
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
];
|
|
160
|
+
for (const [name, run] of cases) {
|
|
161
|
+
try {
|
|
162
|
+
await run();
|
|
163
|
+
}
|
|
164
|
+
catch (e) {
|
|
165
|
+
fail("feed-threw", `${name}: ${e instanceof Error ? e.message : String(e)}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return findings;
|
|
169
|
+
}
|
|
170
|
+
async function checkUnreadStoreConformance(make) {
|
|
171
|
+
const findings = [];
|
|
172
|
+
const fail = (code, message) => findings.push({ code, severity: "error", message });
|
|
173
|
+
const s = await make();
|
|
174
|
+
const cases = [
|
|
175
|
+
[
|
|
176
|
+
"an unseen (viewer, line) is 0",
|
|
177
|
+
async () => {
|
|
178
|
+
if ((await s.get("u-none", "e")) !== 0)
|
|
179
|
+
fail("default", "an unseen cursor was not 0");
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
[
|
|
183
|
+
"advance moves forward, never back, and is idempotent",
|
|
184
|
+
async () => {
|
|
185
|
+
const a = await s.advance("u-fwd", "e", 5);
|
|
186
|
+
const b = await s.advance("u-fwd", "e", 3);
|
|
187
|
+
const c = await s.advance("u-fwd", "e", 5);
|
|
188
|
+
if (a !== 5 || b !== 5 || c !== 5 || (await s.get("u-fwd", "e")) !== 5)
|
|
189
|
+
fail("monotone", `advance returned ${[a, b, c].join()}`);
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
[
|
|
193
|
+
"invalid positions change nothing",
|
|
194
|
+
async () => {
|
|
195
|
+
await s.advance("u-bad", "e", 2);
|
|
196
|
+
for (const bad of [
|
|
197
|
+
-1,
|
|
198
|
+
1.5,
|
|
199
|
+
Number.NaN,
|
|
200
|
+
Number.POSITIVE_INFINITY,
|
|
201
|
+
"9",
|
|
202
|
+
]) {
|
|
203
|
+
const r = await s.advance("u-bad", "e", bad);
|
|
204
|
+
if (r !== 2)
|
|
205
|
+
fail("invalid", `advance(${String(bad)}) returned ${r}`);
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
[
|
|
210
|
+
"cursors are per viewer and per line, with no id collisions",
|
|
211
|
+
async () => {
|
|
212
|
+
await s.advance("u-a", "e1", 4);
|
|
213
|
+
await s.advance("u-c", "a:b", 9);
|
|
214
|
+
if ((await s.get("u-c:a", "b")) !== 0)
|
|
215
|
+
fail("collision", "ids that join to the same string share a cursor");
|
|
216
|
+
if ((await s.get("u-a", "e2")) !== 0)
|
|
217
|
+
fail("per-line", "another line shared a cursor");
|
|
218
|
+
if ((await s.get("u-b", "e1")) !== 0)
|
|
219
|
+
fail("per-viewer", "another viewer shared a cursor");
|
|
220
|
+
if ((await s.get("u-a", "e1")) !== 4)
|
|
221
|
+
fail("collision", "a joined-looking id disturbed a cursor");
|
|
222
|
+
},
|
|
223
|
+
],
|
|
224
|
+
[
|
|
225
|
+
"concurrent advances land on the maximum",
|
|
226
|
+
async () => {
|
|
227
|
+
await Promise.all([1, 7, 3, 5, 2].map((n) => s.advance("u-race", "e", n)));
|
|
228
|
+
if ((await s.get("u-race", "e")) !== 7)
|
|
229
|
+
fail("race", "concurrent advances did not end at the max");
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
];
|
|
233
|
+
for (const [name, run] of cases) {
|
|
234
|
+
try {
|
|
235
|
+
await run();
|
|
236
|
+
}
|
|
237
|
+
catch (e) {
|
|
238
|
+
fail("store-threw", `${name}: ${e instanceof Error ? e.message : String(e)}`);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return findings;
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=conformance.js.map
|
|
@@ -0,0 +1 @@
|
|
|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