@plurnk/plurnk-schemes-http 1.3.12 → 1.5.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/.env.defaults +18 -46
- package/README.md +74 -23
- package/SPEC.md +487 -124
- package/dist/Config.d.ts +3 -0
- package/dist/Config.d.ts.map +1 -0
- package/dist/Config.js +18 -0
- package/dist/Config.js.map +1 -0
- package/dist/ContentType.d.ts +2 -0
- package/dist/ContentType.d.ts.map +1 -0
- package/dist/ContentType.js +15 -0
- package/dist/ContentType.js.map +1 -0
- package/dist/ErrorDetail.d.ts +6 -0
- package/dist/ErrorDetail.d.ts.map +1 -0
- package/dist/ErrorDetail.js +19 -0
- package/dist/ErrorDetail.js.map +1 -0
- package/dist/Guard.d.ts +1 -1
- package/dist/Guard.d.ts.map +1 -1
- package/dist/Guard.js +95 -55
- package/dist/Guard.js.map +1 -1
- package/dist/Http.d.ts +3 -16
- package/dist/Http.d.ts.map +1 -1
- package/dist/Http.js +817 -331
- package/dist/Http.js.map +1 -1
- package/dist/TavilyExtract.d.ts +35 -0
- package/dist/TavilyExtract.d.ts.map +1 -0
- package/dist/TavilyExtract.js +204 -0
- package/dist/TavilyExtract.js.map +1 -0
- package/dist/WebFetcher.d.ts +88 -18
- package/dist/WebFetcher.d.ts.map +1 -1
- package/dist/WebFetcher.js +588 -70
- package/dist/WebFetcher.js.map +1 -1
- package/dist/Ws.d.ts +7 -3
- package/dist/Ws.d.ts.map +1 -1
- package/dist/Ws.js +432 -96
- package/dist/Ws.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -10
- package/dist/index.js.map +1 -1
- package/docs/http.md +108 -53
- package/docs/wss.md +39 -43
- package/package.json +14 -13
- package/dist/Browser.d.ts +0 -84
- package/dist/Browser.d.ts.map +0 -1
- package/dist/Browser.js +0 -273
- package/dist/Browser.js.map +0 -1
- package/scripts/install-browser.mjs +0 -19
package/SPEC.md
CHANGED
|
@@ -1,130 +1,493 @@
|
|
|
1
1
|
# plurnk-schemes-http — Specification
|
|
2
2
|
|
|
3
|
-
`http(s)://` scheme
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
3
|
+
This package owns the `http(s)://` request/response scheme, the `ws(s)://`
|
|
4
|
+
full-duplex scheme, plus automatic entry-acquisition, Tavily Extract, and local
|
|
5
|
+
HTML projection foundations. Both handlers implement the DB-free `SchemeCtx` author contract.
|
|
6
|
+
|
|
7
|
+
## §http-manifest §1 HTTP manifest
|
|
8
|
+
|
|
9
|
+
| Field | Value |
|
|
10
|
+
| --------------- | ----------------------------- |
|
|
11
|
+
| Registered name | `http` (`https` routes to it) |
|
|
12
|
+
| Category | `data` |
|
|
13
|
+
| Writers | `model`, `client` |
|
|
14
|
+
| Volatile | `true` |
|
|
15
|
+
| Model-visible | `true` |
|
|
16
|
+
| Requires web | `true` |
|
|
17
|
+
| Default channel | `body` |
|
|
18
|
+
|
|
19
|
+
| Channel | Seed type | Meaning |
|
|
20
|
+
| -------- | --------------------------- | ------------------------------------------------------------------------------ |
|
|
21
|
+
| `body` | `application/octet-stream` | Source text, derived Unicode, binary marker, SSE data, or HTML-page Markdown |
|
|
22
|
+
| `header` | `text/plain` | Origin, acquisition, materializer, projection, provider, and usage evidence |
|
|
23
|
+
| `html` | `text/html` | Original server-source HTML when an HTML representation can be acquired |
|
|
24
|
+
|
|
25
|
+
`package.json#plurnk.schemes` registers `http` through the default export and
|
|
26
|
+
`wss` through `Ws`.
|
|
27
|
+
|
|
28
|
+
Routing is not identity. `NetworkAddress` {§network-address} retains the exact
|
|
29
|
+
addressed protocol and stores
|
|
30
|
+
`/<host>[:<non-default-port>]<path>[?<serialized-query>]`. Query ordering,
|
|
31
|
+
duplicate names, and an explicit empty `?` remain significant. The fragment is
|
|
32
|
+
a Plurnk channel selector and never enters network identity or transport.
|
|
33
|
+
Request metadata affects transport but not identity. URL userinfo is rejected;
|
|
34
|
+
neither credentials nor metadata are reconstructed from `raw`. Within storage
|
|
35
|
+
pathnames, `%28` and `%29` canonicalize to literal parentheses.
|
|
36
|
+
|
|
37
|
+
## §op-surface §2 HTTP operation surface
|
|
38
|
+
|
|
39
|
+
| Operation | Remote action | Contract |
|
|
40
|
+
| --------------------------------- | ------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
41
|
+
| Exact `READ(url)<scope?>` | GET unless a fresh GET copy is usable | Prepare one complete canonical representation, then let core select and project it |
|
|
42
|
+
| Exact `FIND(url)` | GET only when acquisition is required | Use the same preparation, then universal query, matcher, weighting, and pagination |
|
|
43
|
+
| `FIND(pattern-url)` | None | Query already-materialized web entries; a path pattern does not discover the remote web |
|
|
44
|
+
| `SEND[200](url):body:` | POST | Stream and persist the response under the addressed URL |
|
|
45
|
+
| `EDIT(url):body:` | PUT | Replace the whole remote resource; a line marker is invalid |
|
|
46
|
+
| `KILL(url)` | DELETE | Delete the remote resource and stream its response |
|
|
47
|
+
| `SEND[410](url)` | None | Delete the local stored entry |
|
|
48
|
+
| `SEND[499](url)` | Cancellation is engine-routed | The routed subscription handle aborts the live owner; scheme dispatch is a `200` no-op |
|
|
49
|
+
|
|
50
|
+
Finite GET uses scope-blind representation preparation; POST, PUT, DELETE,
|
|
51
|
+
and genuinely live GET responses retain the subscription path. Request
|
|
52
|
+
headers are ordered target metadata: one trailing `{Key: value}` block per
|
|
53
|
+
header. The loop `SEND[code]` is never the remote HTTP status; remote status and
|
|
54
|
+
headers are persisted in `header`.
|
|
55
|
+
Exact-versus-pattern FIND preparation uses the shared
|
|
56
|
+
`PathSyntax.hasGlob` classifier {§path-glob}; HTTP owns no reduced
|
|
57
|
+
path-pattern grammar.
|
|
58
|
+
|
|
59
|
+
## §http-lifecycle §3 Acquisition, materialization, and query lifecycle
|
|
60
|
+
|
|
61
|
+
```mermaid
|
|
62
|
+
flowchart TD
|
|
63
|
+
get["GET acquisition"] --> live{"text/event-stream?"}
|
|
64
|
+
live -->|yes| subscription["Seed canonical channels<br/>retain subscription; return 102"]
|
|
65
|
+
live -->|no| origin{"Finite origin outcome"}
|
|
66
|
+
origin -->|text/markdown| markdown["Use origin Markdown as body<br/>and request an HTML variant"]
|
|
67
|
+
origin -->|server HTML| source["Retain exact server HTML"]
|
|
68
|
+
origin -->|transport unavailable<br/>after public admission| noSource["No HTML source"]
|
|
69
|
+
source --> eligible{"Generic public request<br/>with Tavily configured?"}
|
|
70
|
+
noSource --> eligible
|
|
71
|
+
eligible -->|no| local["Installed HTML projection"]
|
|
72
|
+
eligible -->|yes| tavily["Tavily Extract Markdown"]
|
|
73
|
+
tavily -->|success| providerBody["Tavily body"]
|
|
74
|
+
tavily -->|recoverable failure<br/>and source exists| recovery["Local projection; body 203"]
|
|
75
|
+
tavily -->|hard failure or<br/>no recovery source| bodyError["Body errored"]
|
|
76
|
+
local -->|present, including empty| localBody["Local body"]
|
|
77
|
+
local -->|absent or no source| bodyError
|
|
78
|
+
markdown --> settle["Write complete canonical channels<br/>and durable producer results"]
|
|
79
|
+
providerBody --> settle
|
|
80
|
+
recovery --> settle
|
|
81
|
+
localBody --> settle
|
|
82
|
+
bodyError --> settle
|
|
83
|
+
settle --> core["Core selects channel<br/>and projects authored text scope"]
|
|
22
84
|
```
|
|
23
85
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
`
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
86
|
+
The same page producer serves exact GET preparation, exact FIND, and executor
|
|
87
|
+
entry acquisition. Their outer policies differ: authored GET accepts explicit
|
|
88
|
+
targets and HTTP error responses; automatic acquisition first admits a public
|
|
89
|
+
credential-free target and treats non-2xx responses as unavailable. READ scope
|
|
90
|
+
and channel selection never enter the producer. Freshness may avoid transport,
|
|
91
|
+
but cold and warm representations pass through the same core projection.
|
|
92
|
+
|
|
93
|
+
| Response | `body` | Auxiliary materialization | Completion |
|
|
94
|
+
| --------------------------------------- | -------------------------------------------------------- | --------------------------------------------------------- | ------------------------------------------- |
|
|
95
|
+
| Negotiated origin Markdown | Exact origin Markdown | Independently acquired server source in `html` when found | Static representation, then core projection |
|
|
96
|
+
| HTML-page production | Tavily Markdown, local Markdown, or independent error | Exact server source in `html` when origin supplied it | Static representation, then core projection |
|
|
97
|
+
| `text/event-stream` | One `data` value plus newline per `text/plain` chunk | Initial response in `header` | `102`; origin close settles subscription |
|
|
98
|
+
| No response body | Present empty text | Response and package metadata in `header` | Static representation; body READ is `204` |
|
|
99
|
+
| Origin HTTP `4xx`/`5xx` | Preserve available origin or independently produced text | Exact response evidence; origin-backed channels errored | Selected channel's durable outcome |
|
|
100
|
+
| Configured textual type | Complete Fetch-decoded Unicode | Response and package metadata in `header` | Static representation |
|
|
101
|
+
| Readable binary type | Derived Unicode under the projection output type | Origin type and projection identity in `header` | Static representation; bytes never durable |
|
|
102
|
+
| Unreadable binary or unknown bytes | No representation is fabricated | Exact non-retryable Problem | `415 binary-response-unsupported` |
|
|
103
|
+
| Binary input exceeds configured bound | No representation is fabricated | Exact size evidence in the Problem | `413 projection-input-limit` |
|
|
104
|
+
|
|
105
|
+
The producer persists every available channel; core publishes only the channel
|
|
106
|
+
selected by the fragment, or `body` by default. Broad FIND returns standard
|
|
107
|
+
resource metadata; exact matcher FIND returns flat match locations. Exact READ
|
|
108
|
+
returns the selected channel's requested text projection.
|
|
109
|
+
|
|
110
|
+
### §http-text-decoding Text response decoding
|
|
111
|
+
|
|
112
|
+
| Surface | Contract |
|
|
113
|
+
| ----------------------------- | ------------------------------------------------------------------------------------------------ |
|
|
114
|
+
| Response media type | WHATWG `MIMEType` essence; absent or unparseable metadata becomes `application/octet-stream` |
|
|
115
|
+
| Finite GET text | Fetch `Response.text()` UTF-8 decoding; buffering does not select a different character encoding |
|
|
116
|
+
| Streamed mutation response | Incremental replacement-mode UTF-8 through `TextDecoder`, preserving response backpressure |
|
|
117
|
+
| `charset` parameter | Preserve in `header` as origin evidence; it does not replace Fetch text decoding |
|
|
118
|
+
| JSON and XML textual families | Use the same HTTP byte-to-string rule; format projections consume the resulting Unicode string |
|
|
119
|
+
| Direct HTML GET | Fetch UTF-8 decoding of origin server HTML |
|
|
120
|
+
| Server-sent events | UTF-8 only under the HTML event-stream standard |
|
|
121
|
+
| Malformed UTF-8 | Preserve the Encoding Standard's replacement-character behavior |
|
|
122
|
+
|
|
123
|
+
This decoder boundary remains text normalization, not a media-format processor.
|
|
124
|
+
A configured binary type bypasses it and enters the mimetype family's bounded
|
|
125
|
+
readable-byte projection {§mimetype-binary-input}; raw bytes never become a
|
|
126
|
+
durable channel.
|
|
127
|
+
|
|
128
|
+
### §html-materialization Readable materialization
|
|
129
|
+
|
|
130
|
+
`WebFetcher.materialize` is the shared readable-representation seam for exact
|
|
131
|
+
GET/FIND preparation and executor entry acquisition. It returns complete
|
|
132
|
+
Unicode channel material for one atomic canonical entry write; only SSE and
|
|
133
|
+
mutation responses retain incremental streaming.
|
|
134
|
+
|
|
135
|
+
| Input or event | Action | Result |
|
|
136
|
+
| ------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------------ |
|
|
137
|
+
| Configured non-HTML text | Decode with Fetch UTF-8 | Original representation in `body` |
|
|
138
|
+
| Configured binary with reader | Apply the bounded byte projection | Derived Unicode plus source type and identity |
|
|
139
|
+
| Configured binary without reader | Cancel without retaining bytes | `null`; the consumer applies its absence policy |
|
|
140
|
+
| Binary input exceeds the common bound | Cancel and preserve the typed cause | `WebMaterializationError` caused by `ProjectionInputLimitError` |
|
|
141
|
+
| Negotiated origin `text/markdown` | Accept it without Tavily | Exact Markdown in `body`; independently requested source in `html` |
|
|
142
|
+
| Eligible HTML with Tavily configured | Use Tavily as the body producer | Tavily Markdown in `body`; origin server source in `html` |
|
|
143
|
+
| Ineligible HTML or Tavily not configured | Use the installed HTML projection | Local Markdown in `body`; origin server source in `html` |
|
|
144
|
+
| Recoverable Tavily failure with source HTML | Use the installed projection as recovery | Local Markdown in `body` with terminal `203`; source in `html` |
|
|
145
|
+
| Hard Tavily failure | Preserve evidence; do not run local recovery | `body` errored; independently successful `html`/`header` survive |
|
|
146
|
+
| Tavily success after origin transport loss | Preserve provider body and origin failure | `body` static; `html` errored |
|
|
147
|
+
| Projection implementation throws | Stop and preserve the cause | `WebMaterializationError` with stage `projection` |
|
|
148
|
+
|
|
149
|
+
A projection object is present even when its content is `""`; only `null`
|
|
150
|
+
denotes absence. A materialization exception retains its original `cause`; it
|
|
151
|
+
never enters the absence channel.
|
|
152
|
+
|
|
153
|
+
#### §tavily-extract Tavily Extract boundary
|
|
154
|
+
|
|
155
|
+
Tavily is eligible only for a credential-free generic request whose target has
|
|
156
|
+
been admitted as public. Authored request metadata—including an authored
|
|
157
|
+
`Accept` field—makes the request ineligible. The package-generated Markdown
|
|
158
|
+
negotiation, browser-compatible `User-Agent`, and conditional cache fields are
|
|
159
|
+
transport mechanics, not authored metadata. No target headers or origin
|
|
160
|
+
credentials cross the provider boundary.
|
|
161
|
+
|
|
162
|
+
When no `Accept` is authored, origin acquisition offers
|
|
163
|
+
`text/markdown, text/html;q=0.9, */*;q=0.1`. An origin `text/markdown`
|
|
164
|
+
representation wins and Tavily is skipped; a second origin request with
|
|
165
|
+
`Accept: text/html` may populate `html`. An authored `Accept` value is sent
|
|
166
|
+
unchanged and makes any returned HTML use the local projection route.
|
|
167
|
+
|
|
168
|
+
One provider request is `POST https://api.tavily.com/extract` with bearer
|
|
169
|
+
authentication and exactly one URL, configured `basic` or `advanced` depth,
|
|
170
|
+
`format: "markdown"`, and `include_usage: true`. A package-owned abort timeout
|
|
171
|
+
bounds the call. Success requires Markdown plus `request_id` and
|
|
172
|
+
`usage.credits`; those facts remain durable in `header`.
|
|
173
|
+
|
|
174
|
+
| Provider outcome | Classification | Body behavior when server HTML exists |
|
|
175
|
+
| ---------------------------------------- | -------------- | ------------------------------------------------------ |
|
|
176
|
+
| Success with required evidence | Success | Use Tavily Markdown |
|
|
177
|
+
| Caller cancellation | Cancelled | Return exact `499`; no recovery |
|
|
178
|
+
| Client timeout or transport failure | Recoverable | Local projection, terminal `203` |
|
|
179
|
+
| `429`, `5xx`, or `failed_results` | Recoverable | Local projection, terminal `203` |
|
|
180
|
+
| `401` or `403` | Hard | `tavily-authentication-failed`; no local projection |
|
|
181
|
+
| Other `4xx` | Hard | `tavily-provider-rejected`; no local projection |
|
|
182
|
+
| Malformed success or missing evidence | Hard | `tavily-invalid-response`; no local projection |
|
|
183
|
+
|
|
184
|
+
Without server HTML, no local recovery input exists. A Tavily success can still
|
|
185
|
+
close `body`, but every Tavily failure remains the body failure and `html`
|
|
186
|
+
closes errored.
|
|
187
|
+
|
|
188
|
+
#### §http-channel-outcomes Channel outcomes
|
|
189
|
+
|
|
190
|
+
For finite HTML-page production, `body`, `header`, and `html` have independent
|
|
191
|
+
durable outcomes and are written atomically. The selected channel alone
|
|
192
|
+
determines the projected operation result: successful `#html` or `#header` can
|
|
193
|
+
be read when `body` failed, and a successful default `body` is not invalidated
|
|
194
|
+
by unavailable `html`. Unselected failures remain `errored` channels carrying
|
|
195
|
+
their exact `producerResult`. A recoverable local body remains a static readable
|
|
196
|
+
channel with producer status `203`, so cold and warm READ both return its
|
|
197
|
+
content with that same status.
|
|
198
|
+
|
|
199
|
+
Exact READ, exact FIND, and executor materialization preserve the same channel
|
|
200
|
+
representation. A missing source variant is an explicit empty `errored`
|
|
201
|
+
channel, never an absent fact that later cache use can reinterpret as successful
|
|
202
|
+
empty content. A direct non-success HTTP response likewise remains available as
|
|
203
|
+
evidence, while each origin-backed channel carries an exact
|
|
204
|
+
`http-response-status` producer Problem. A Tavily-produced body and the
|
|
205
|
+
acquisition `header` remain independent of an unavailable origin source.
|
|
206
|
+
|
|
207
|
+
## §http-status §4 HTTP status mapping
|
|
208
|
+
|
|
209
|
+
| Outcome | Operation status |
|
|
210
|
+
| ------------------------------------------------------------- | -------------------------------------------------------- |
|
|
211
|
+
| Finite exact READ after preparation | Universal selected-channel result (`200`, `204`, or producer status) |
|
|
212
|
+
| Exact FIND after preparation | Exact universal query result |
|
|
213
|
+
| Exact acquisition returns no WebFetcher value | `404` (`not-materialized`) |
|
|
214
|
+
| Selected origin-backed channel received HTTP `4xx`/`5xx` | Exact durable `http-response-status` Problem |
|
|
215
|
+
| Selected HTML-page channel fails | That channel's exact durable producer Problem |
|
|
216
|
+
| Local HTML projection is absent | `422` (`no-readable-projection`) |
|
|
217
|
+
| Recoverable Tavily failure uses local projection | Readable body with durable status `203` |
|
|
218
|
+
| Finite textual or projected-binary response | Universal READ result |
|
|
219
|
+
| Finite empty text response | `204` |
|
|
220
|
+
| Finite binary response has no readable projection | `415` (`binary-response-unsupported`) |
|
|
221
|
+
| Binary projection input exceeds the configured byte bound | `413` (`projection-input-limit`) |
|
|
222
|
+
| `SEND[410]` | Exact entry-delete result |
|
|
223
|
+
| Routed `SEND[499]` dispatch | `200` |
|
|
224
|
+
| Client-cancelled finite acquisition | `499` (`cancelled`) |
|
|
225
|
+
| SSE after acquisition | `102` initial; terminal selected-channel result |
|
|
226
|
+
| SSE cancellation after acquisition | `102` initial; terminal `499` |
|
|
227
|
+
| SSE parser/transfer failure after acquisition | `102` initial; terminal `502` |
|
|
228
|
+
| Multi-statement HTTP edit batch | `409` (`non-atomic-edit-batch`) |
|
|
229
|
+
| Invalid target, channel, line edit, or URL userinfo | `400` with the corresponding stable Problem kind |
|
|
230
|
+
| Non-corresponding 304 | `502` (`fetch-failed`) |
|
|
231
|
+
| Acquisition failure without a successful provider body | `502` (`fetch-failed`) |
|
|
232
|
+
| Projection exception | `500` (`projection-failed`) |
|
|
233
|
+
| Uninterpreted SEND status | `501` (`send-status-unsupported`) |
|
|
234
|
+
|
|
235
|
+
An HTTP error status is still a successfully acquired direct response: its
|
|
236
|
+
content and response evidence are preserved, and origin-backed channels carry
|
|
237
|
+
that exact status as durable producer evidence. HTML still enters page
|
|
238
|
+
production, so a successful Tavily `body` can remain readable while the origin
|
|
239
|
+
`html` records the HTTP error. Automatic WebFetcher acquisition instead treats
|
|
240
|
+
a non-2xx response as unavailable. Handler failures use RFC 9457 Problem Details.
|
|
241
|
+
Caught direct-acquisition diagnostics are bounded by
|
|
242
|
+
`PLURNK_SCHEMES_HTTP_ERROR_DETAIL_LIMIT` in model-facing detail while complete
|
|
243
|
+
errors remain in daemon diagnostics.
|
|
244
|
+
|
|
245
|
+
A binary response first asks the installed mimetype family for a bounded
|
|
246
|
+
readable projection. A present result stores only its derived Unicode and
|
|
247
|
+
appends authoritative `x-plurnk-projection-id` evidence after the origin and
|
|
248
|
+
acquisition fields. A finite GET with no projection returns non-retryable `415`
|
|
249
|
+
without fabricating a text entry; exceeding the input ceiling similarly returns
|
|
250
|
+
`413` with configured and observed sizes. A streamed mutation response already
|
|
251
|
+
owns a seeded lifecycle entry and settles its typed channel as errored instead.
|
|
252
|
+
These statuses describe Plurnk's materialization boundary, not the remote HTTP
|
|
253
|
+
outcome—a POST, PUT, or DELETE might already have changed the remote resource.
|
|
254
|
+
Missing or malformed `Content-Type` becomes `application/octet-stream`; the
|
|
255
|
+
handler does not sniff or guess unknown bytes.
|
|
256
|
+
|
|
257
|
+
## §5 Dependencies and configuration
|
|
258
|
+
|
|
259
|
+
| Surface | Runtime contract |
|
|
260
|
+
| ----------------- | --------------------------------------------------------------------------------------------------------- |
|
|
261
|
+
| Platform | Node ≥26 native fetch, streams, abort signals, decoding, DNS, and `WebSocket` |
|
|
262
|
+
| SSE | `eventsource-parser` for bounded WHATWG event-stream framing |
|
|
263
|
+
| Tavily Extract | Optional Tavily Extract API primitive when `TAVILY_API_KEY` is present |
|
|
264
|
+
|
|
265
|
+
### §http-config Operator configuration
|
|
266
|
+
|
|
267
|
+
| Concern | Contract |
|
|
268
|
+
| --------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
269
|
+
| Canonical registry | Shipped `.env.defaults`; the daemon assembles it as a set-if-unset floor {§operator-config-env-defaults} |
|
|
270
|
+
| Required values | Missing or invalid required values fail at readiness/owning read; code carries no hidden fallback |
|
|
271
|
+
| Tavily API Key | Optional `# TAVILY_API_KEY=`; enables Tavily Extract for eligible public HTML |
|
|
272
|
+
| Tavily Extract Depth | `PLURNK_SCHEMES_HTTP_TAVILY_DEPTH=basic`; only `basic` or `advanced` |
|
|
273
|
+
| Tavily client timeout | Positive `PLURNK_SCHEMES_HTTP_TAVILY_TIMEOUT_MS=30000` |
|
|
274
|
+
|
|
275
|
+
### §automatic-fetch-check Automatic acquisition URL check
|
|
276
|
+
|
|
277
|
+
`WebFetcher` is the sole caller of `Guard.fetch`. Before automatic byte
|
|
278
|
+
acquisition, it accepts credential-free HTTP(S) targets only when every
|
|
279
|
+
resolved address is ordinary globally reachable unicast, and repeats the check
|
|
280
|
+
before every manually followed redirect. A refused or unresolvable target is
|
|
281
|
+
the ordinary unavailable `null` result. A transport failure after public
|
|
282
|
+
admission may still enter Tavily page production.
|
|
283
|
+
|
|
284
|
+
Direct HTTP operations and WebSocket connections do not use this check. Loopback,
|
|
285
|
+
private, and link-local destinations are therefore valid explicit targets.
|
|
286
|
+
|
|
287
|
+
Redirect transitions follow WHATWG Fetch: 301/302 rewrite POST to GET; 303
|
|
288
|
+
rewrites methods other than GET/HEAD to GET; 307/308 preserve method and body.
|
|
289
|
+
A body rewrite removes body headers, cross-origin redirects remove
|
|
290
|
+
`Authorization`, and followed redirect bodies are cancelled. The configured
|
|
291
|
+
hop limit returns the last redirect rather than following beyond the limit.
|
|
292
|
+
Validation-time DNS answers are not pinned to connection-time resolution. This
|
|
293
|
+
check therefore makes no DNS-rebinding or total-egress claim.
|
|
294
|
+
|
|
295
|
+
## §materialization-lifecycle §6 Materialization lifecycle
|
|
296
|
+
|
|
297
|
+
| Concern | Contract |
|
|
298
|
+
| -------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
299
|
+
| Direct gate | Explicit targets use native origin transport; only a generic public request grants Tavily authority |
|
|
300
|
+
| Automatic gate | Target and redirects require public admission; accepted generic HTML follows the same page producer |
|
|
301
|
+
| Body owner | Origin Markdown wins; otherwise configured eligible Tavily is structural, with one local projection floor |
|
|
302
|
+
| Source owner | `html` is exact server-source HTML; it is never provider-generated or DOM-generated |
|
|
303
|
+
| Projection | A present projection, including `""`, becomes `body`; `null` alone means absence |
|
|
304
|
+
| Cancellation | One caller signal spans origin, auxiliary origin, projection, and Tavily work |
|
|
305
|
+
|
|
306
|
+
### §host-rewrite Acquisition target rewrite
|
|
307
|
+
|
|
308
|
+
Only acquisition GETs are eligible for host rewriting. A GitHub
|
|
309
|
+
`…/blob/…` address uses the corresponding `raw.githubusercontent.com` source for
|
|
310
|
+
byte transport. Direct READ, exact FIND, and
|
|
311
|
+
WebFetcher prefetch share that rule. The originally addressed GitHub URL remains
|
|
312
|
+
entry identity. POST, PUT, and DELETE are never retargeted. Rewritten targets
|
|
313
|
+
are checked under {§automatic-fetch-check} only when `WebFetcher` acquires them.
|
|
314
|
+
|
|
315
|
+
### §revalidation GET representation freshness
|
|
316
|
+
|
|
317
|
+
Acquired responses append package-owned `x-plurnk-request-method`,
|
|
318
|
+
`x-plurnk-fetched-at`, and `x-plurnk-cache-variant` fields after origin headers.
|
|
319
|
+
Page bodies append `x-plurnk-materializer-id`; local projections append
|
|
320
|
+
`x-plurnk-projection-id`; Tavily appends status, route, request, usage, timing,
|
|
321
|
+
and bounded failure evidence. Only package metadata after the acquisition stamp
|
|
322
|
+
is authoritative.
|
|
323
|
+
Plurnk stores one representation per canonical URL rather than a variant set:
|
|
324
|
+
|
|
325
|
+
| Acquisition context | Package variant | Later cache use |
|
|
326
|
+
| -------------------------------------------- | --------------- | --------------- |
|
|
327
|
+
| No explicit target metadata; no `Vary` | `default` | Eligible |
|
|
328
|
+
| Any explicit target metadata | `bypass` | Ineligible |
|
|
329
|
+
| No explicit target metadata; any `Vary` | `bypass` | Ineligible |
|
|
330
|
+
| Stored response lacks authoritative evidence | Marker absent | Ineligible |
|
|
331
|
+
|
|
332
|
+
This conservative selection avoids persisting request values or fabricating a
|
|
333
|
+
multi-variant store. Exact FIND passes target metadata through acquisition but
|
|
334
|
+
does not reuse that response later. A `304` that introduces `Vary` changes the
|
|
335
|
+
restored representation's package marker to `bypass`.
|
|
336
|
+
|
|
337
|
+
Only an eligible GET representation can supply a direct READ's body, TTL stamp,
|
|
338
|
+
conditional validators, or exact-FIND preparation. Completion comes from
|
|
339
|
+
channel lifecycle, not body length: `body` and `header` must be successful
|
|
340
|
+
(`static` or `closed`), and every channel must be terminal. An auxiliary channel
|
|
341
|
+
may be `errored`; `active` or unknown state is ineligible. Durable operation
|
|
342
|
+
evidence and HTTP reuse eligibility remain distinct: an acquired response stays
|
|
343
|
+
in the entry even when its origin policy prevents later cache use.
|
|
344
|
+
|
|
345
|
+
| Stored origin policy | Direct READ after acquisition | Exact FIND after acquisition |
|
|
346
|
+
| ------------------------------------- | ------------------------------------------------------ | ---------------------------------------- |
|
|
347
|
+
| `no-store` | Full acquisition without stored validators | Full acquisition |
|
|
348
|
+
| `no-cache` (qualified or unqualified) | Validate when a stored validator exists; else acquire | Full acquisition |
|
|
349
|
+
| Valid `max-age` | Serve only inside origin lifetime and operator ceiling | Reuse only while fresh under both limits |
|
|
350
|
+
| Valid `Expires`, without `max-age` | Same, using the origin expiration lifetime | Same |
|
|
351
|
+
| Invalid or ambiguous explicit expiry | Treat as stale; validate or acquire | Full acquisition |
|
|
352
|
+
| No explicit origin lifetime | Use the operator TTL as Plurnk's heuristic | Reuse inside the operator TTL |
|
|
353
|
+
|
|
354
|
+
The operator ceiling is `PLURNK_SCHEMES_HTTP_TTL_MS`; `0` disables every
|
|
355
|
+
validation-free reuse. Origin age is the greater of the response's `Age` value
|
|
356
|
+
and apparent age from `Date`, plus residence since the authoritative package
|
|
357
|
+
stamp. A representation is fresh only while both origin lifetime and operator
|
|
358
|
+
ceiling permit it. Unknown cache extensions are inert. Stale content is never
|
|
359
|
+
served, so `must-revalidate` requires no separate path.
|
|
360
|
+
|
|
361
|
+
Outside the fresh window, a representation without a materializer identity may
|
|
362
|
+
send a stored ETag or Last-Modified only when that field is singular and
|
|
363
|
+
syntactically valid. A 304 can restore those stored channels only when its
|
|
364
|
+
validator corresponds to the nominated stored representation:
|
|
365
|
+
|
|
366
|
+
| 304 validator | Correspondence requirement |
|
|
367
|
+
| ----------------------------------------------------- | ------------------------------------------- |
|
|
368
|
+
| Strong ETag | Same stored strong ETag |
|
|
369
|
+
| Weak ETag | Same opaque tag under weak comparison |
|
|
370
|
+
| No ETag; Last-Modified | Same valid stored Last-Modified instant |
|
|
371
|
+
| Missing, malformed, unsolicited, or non-corresponding | Invalid acquisition; `502` (`fetch-failed`) |
|
|
372
|
+
|
|
373
|
+
A corresponding 304 restores the stored channels without rematerializing and
|
|
374
|
+
updates the header under the following ownership rule; any other response
|
|
375
|
+
replaces the channels:
|
|
376
|
+
|
|
377
|
+
| 304 metadata class | Stored-header action |
|
|
378
|
+
| --------------------------------------------------------------------- | ------------------------------------------------------- |
|
|
379
|
+
| Present end-to-end origin fields, including cache and validators | Replace prior fields of the same case-insensitive name |
|
|
380
|
+
| Origin fields absent from the 304 | Preserve |
|
|
381
|
+
| `Content-Type`, `Content-Encoding`, `Content-Range`, `Content-Length` | Preserve metadata describing the already-processed body |
|
|
382
|
+
| Package method, acquisition stamp, and variant | Rebuild authoritatively; refresh stamp and variant |
|
|
383
|
+
| Projection evidence | Preserve |
|
|
384
|
+
|
|
385
|
+
A 304-provided `Vary`, `no-store`, `no-cache`, expiry, or validator
|
|
386
|
+
therefore governs the next operation without relabeling derived Unicode as a
|
|
387
|
+
different source representation.
|
|
388
|
+
|
|
389
|
+
A stored derived representation requires the current projection identity. A
|
|
390
|
+
stored page body also requires its current route: negotiated origin Markdown,
|
|
391
|
+
local projection while Tavily is unconfigured, metadata-ineligible local
|
|
392
|
+
projection, configured Tavily depth/version, or the corresponding recoverable
|
|
393
|
+
local-fallback route. Enabling Tavily or changing depth invalidates the affected
|
|
394
|
+
route.
|
|
395
|
+
|
|
396
|
+
Once a page representation leaves its fresh window, Plurnk performs complete
|
|
397
|
+
reacquisition without old origin validators. Origin `304` can certify origin
|
|
398
|
+
bytes, but it cannot certify a composite that may also contain a fresh Tavily
|
|
399
|
+
extraction, a newly negotiated Markdown representation, or an independently
|
|
400
|
+
acquired HTML variant. Projection or materializer mismatch likewise invalidates
|
|
401
|
+
body, TTL, and validators together.
|
|
402
|
+
|
|
403
|
+
POST, PUT, and DELETE responses retain their method marker but cannot satisfy a
|
|
404
|
+
later GET or exact-FIND acquisition. An unmarked authored entry and an eligible
|
|
405
|
+
stored GET remain visible to universal FIND as durable evidence; exact HTTP
|
|
406
|
+
preparation applies the policy above. `SEND[410]` deletes the stored entry.
|
|
407
|
+
|
|
408
|
+
### §sse Server-sent events
|
|
409
|
+
|
|
410
|
+
A direct GET whose response is `text/event-stream` feeds the bounded parser.
|
|
411
|
+
Each event's joined `data` value plus a newline becomes one `text/plain` body
|
|
412
|
+
chunk. Comments and `event`, `id`, and `retry` metadata are not projected.
|
|
413
|
+
The response plus persisted header is the acquisition boundary: READ returns
|
|
414
|
+
`102`, and parsing continues through the retained `StreamSubscription` without
|
|
415
|
+
retaining `SchemeCtx`. Buffer exhaustion and post-acquisition transport failure
|
|
416
|
+
settle that subscription at `502`; cancellation settles it at `499`. The
|
|
417
|
+
handler does not reconnect; events accumulate until the origin closes or the
|
|
418
|
+
operation is cancelled.
|
|
419
|
+
|
|
420
|
+
## §prefetch §7 WebFetcher
|
|
421
|
+
|
|
422
|
+
| Result | Meaning |
|
|
423
|
+
| ------------------------------------ | ---------------------------------------------------------------------------------------- |
|
|
424
|
+
| Origin HTML | Exact source text, MIME type, package-stamped evidence, and page-producer eligibility |
|
|
425
|
+
| Negotiated origin Markdown | Exact body plus independent HTML-variant outcome |
|
|
426
|
+
| Other accepted body | One unconsumed byte stream, MIME type, package-stamped headers, and cancellation owner |
|
|
427
|
+
| Admitted origin transport failure | Bounded origin failure plus eligibility for provider-only page production |
|
|
428
|
+
| Materialized configured text | Complete Fetch-decoded UTF-8 body |
|
|
429
|
+
| Materialized readable binary | Bounded derived Unicode plus source type, projection identity, and enriched header |
|
|
430
|
+
| Materialized HTML page | Independent body/html outcomes and complete route/provider evidence |
|
|
431
|
+
| Automatic top-level `null` | Refused target, non-2xx response, or unavailable response with no provider route |
|
|
432
|
+
| Non-page materialization `null` | No final readable binary projection |
|
|
433
|
+
| Caller-cancelled acquisition | Rejects with the caller signal's exact reason |
|
|
434
|
+
|
|
435
|
+
Top-level `null` is an automatic-acquisition liveness value rather than a thrown
|
|
436
|
+
failure. Caller cancellation is not liveness: a pre-aborted caller fails before
|
|
437
|
+
acquisition and a caller abort wins with its exact reason. Package-owned origin
|
|
438
|
+
and Tavily timeouts are ordinary classified acquisition outcomes. WebFetcher
|
|
439
|
+
owns no entry identity, registry selection, selected-channel policy, or query
|
|
440
|
+
policy; its consumers supply those boundaries and the projection capability.
|
|
441
|
+
|
|
442
|
+
## §ws §8 WebSocket
|
|
443
|
+
|
|
444
|
+
`wss` is a first-class data scheme; `ws` routes to the same handler. WebSocket
|
|
445
|
+
is bidirectional and stateful, not an HTTP content type. It uses `messages` as a
|
|
446
|
+
`text/plain` default channel and the same canonical network address contract
|
|
447
|
+
{§network-address}.
|
|
448
|
+
|
|
449
|
+
### §ws-lifecycle Socket ownership and settlement
|
|
450
|
+
|
|
451
|
+
```mermaid
|
|
452
|
+
stateDiagram-v2
|
|
453
|
+
[*] --> Idle
|
|
454
|
+
Idle --> Claimed: claim canonical workspace address
|
|
455
|
+
Claimed --> Connecting: seed entry, open subscription, construct socket
|
|
456
|
+
Claimed --> Idle: setup or construction failure
|
|
457
|
+
Connecting --> Open: native open; messages active; READ 102
|
|
458
|
+
Connecting --> Settling: pre-open close/error, KILL, cancel, activation failure, or shutdown
|
|
459
|
+
Open --> Open: ordered inbound frame or SEND[200]
|
|
460
|
+
Open --> Settling: closing state, close/error, KILL, cancel, binary frame, persistence failure, or shutdown
|
|
461
|
+
Settling --> Idle: await retained work, close subscription, release claim
|
|
109
462
|
```
|
|
110
463
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
464
|
+
| Operation or event | Contract |
|
|
465
|
+
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
|
466
|
+
| `READ(ws(s)://…)` | Claim, seed/subscribe, construct `CONNECTING`, then return `102` after native `open` plus durable activation |
|
|
467
|
+
| Concurrent duplicate READ | `409` in `claimed`, `connecting`, `open`, or `settling`; cleanup releases the only claim |
|
|
468
|
+
| `SEND[200](ws(s)://…)` | Send only for owner `open` plus native `readyState=OPEN`; absent or non-open owner is `409`; send throw is `502` |
|
|
469
|
+
| `SEND[499](ws(s)://…)` | Engine-routed cancellation closes the owning READ; scheme dispatch returns `200` |
|
|
470
|
+
| `KILL(ws(s)://…)` | Close/cancel the claimed owner; no owner is `404`; an attempted close throw is `502` |
|
|
471
|
+
| Inbound frame after native `open` | Join the owner's persistence chain; the next write begins only after the preceding write succeeds |
|
|
472
|
+
| Binary frame after native `open` | Retain the text prefix, prune the binary and later frames, settle `415 binary-frame-unsupported`, close with private-use code `4003` |
|
|
473
|
+
| First inbound persistence failure | Retain the successful prefix, prune queued and later frames, and settle with `500 message-persistence-failed` |
|
|
474
|
+
| Socket closes before `open` | Close subscription with `502 connection-failed`; the pending READ returns that exact failure |
|
|
475
|
+
| Socket closes after `open` | Drain the accepted frame prefix; initial READ remains `102`; settle with `200` unless a drained write fails |
|
|
476
|
+
| Failure after `open` | Initial READ remains `102`; persist the exact terminal failure and wake through subscription settlement |
|
|
477
|
+
|
|
478
|
+
The in-instance registry is keyed by workspace, addressed protocol, and
|
|
479
|
+
canonical network pathname. The claim remains registered through terminal
|
|
480
|
+
cleanup, so a new READ cannot overlap an owner's subscription settlement. Every
|
|
481
|
+
terminal path drains retained owner work, closes the transport when necessary,
|
|
482
|
+
closes the durable subscription, then releases the claim. A persistence failure
|
|
483
|
+
found while draining supersedes a graceful terminal result; cancellation and
|
|
484
|
+
transport failures retain their exact result. Handler shutdown requests
|
|
485
|
+
settlement for every remainder, awaits every owner, and aggregates
|
|
486
|
+
transport-close failures under {§handler-lifecycle}.
|
|
487
|
+
|
|
488
|
+
| Transport limit | Current contract |
|
|
489
|
+
| ------------------ | ------------------------------------------------------------------------------------------------------- |
|
|
490
|
+
| Payload projection | String event data only into `text/plain`; binary data terminates with Plurnk `415` and private-use WebSocket code `4003` |
|
|
491
|
+
| Reconnection | None; READ again after terminal cleanup |
|
|
492
|
+
| Handshake metadata | Default global-WebSocket identity; custom target headers are not applied |
|
|
493
|
+
| Runtime | Node ≥26 |
|