@plurnk/plurnk-schemes-http 1.4.0 → 1.6.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 +10 -40
- package/README.md +38 -34
- package/SPEC.md +260 -227
- 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/Guard.d.ts.map +1 -1
- package/dist/Guard.js +2 -3
- package/dist/Guard.js.map +1 -1
- package/dist/Http.d.ts +5 -18
- package/dist/Http.d.ts.map +1 -1
- package/dist/Http.js +216 -233
- 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 +58 -24
- package/dist/WebFetcher.d.ts.map +1 -1
- package/dist/WebFetcher.js +485 -108
- package/dist/WebFetcher.js.map +1 -1
- package/dist/Ws.d.ts +3 -2
- package/dist/Ws.d.ts.map +1 -1
- package/dist/Ws.js +132 -94
- package/dist/Ws.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/docs/http.md +74 -59
- package/docs/wss.md +19 -14
- package/package.json +3 -5
- package/dist/Browser.d.ts +0 -75
- package/dist/Browser.d.ts.map +0 -1
- package/dist/Browser.js +0 -295
- package/dist/Browser.js.map +0 -1
package/SPEC.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# plurnk-schemes-http — Specification
|
|
2
2
|
|
|
3
3
|
This package owns the `http(s)://` request/response scheme, the `ws(s)://`
|
|
4
|
-
full-duplex scheme, plus automatic entry-acquisition and
|
|
5
|
-
foundations. Both handlers implement the DB-free `SchemeCtx` author contract.
|
|
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
6
|
|
|
7
7
|
## §http-manifest §1 HTTP manifest
|
|
8
8
|
|
|
@@ -16,11 +16,11 @@ foundations. Both handlers implement the DB-free `SchemeCtx` author contract.
|
|
|
16
16
|
| Requires web | `true` |
|
|
17
17
|
| Default channel | `body` |
|
|
18
18
|
|
|
19
|
-
| Channel | Seed type
|
|
20
|
-
| -------- |
|
|
21
|
-
| `body` | `application/octet-stream`
|
|
22
|
-
| `header` | `text/plain`
|
|
23
|
-
| `html` | `text/html`
|
|
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
24
|
|
|
25
25
|
`package.json#plurnk.schemes` registers `http` through the default export and
|
|
26
26
|
`wss` through `Ws`.
|
|
@@ -32,26 +32,25 @@ duplicate names, and an explicit empty `?` remain significant. The fragment is
|
|
|
32
32
|
a Plurnk channel selector and never enters network identity or transport.
|
|
33
33
|
Request metadata affects transport but not identity. URL userinfo is rejected;
|
|
34
34
|
neither credentials nor metadata are reconstructed from `raw`. Within storage
|
|
35
|
-
pathnames, `%28` and `%29` canonicalize to literal parentheses
|
|
36
|
-
encode them again.
|
|
35
|
+
pathnames, `%28` and `%29` canonicalize to literal parentheses.
|
|
37
36
|
|
|
38
37
|
## §op-surface §2 HTTP operation surface
|
|
39
38
|
|
|
40
|
-
| Operation
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
| Operation | Remote action | Contract |
|
|
40
|
+
| ------------------------------------------ | ------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
41
|
+
| Exact `## READ0 (url) <scope?>` | GET unless a fresh GET copy is usable | Prepare one complete canonical representation, then let core select and project it |
|
|
42
|
+
| Exact `## FIND0 (url)` | GET only when acquisition is required | Use the same preparation, then universal query, matcher, weighting, and pagination |
|
|
43
|
+
| `## FIND0 (pattern-url)` | None | Query already-materialized web entries; a path pattern does not discover the remote web |
|
|
44
|
+
| `## SEND0 [200] (url)` with body | POST | Stream and persist the response under the addressed URL |
|
|
45
|
+
| `## EDIT0 (url)` with body | PUT | Replace the whole remote resource; a line marker is invalid |
|
|
46
|
+
| `## KILL0 (url)` | DELETE | Delete the remote resource and stream its response |
|
|
47
|
+
| `## SEND0 [410] (url)` | None | Delete the local stored entry |
|
|
48
|
+
| `## SEND0 [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
|
|
53
52
|
headers are ordered target metadata: one trailing `{Key: value}` block per
|
|
54
|
-
header.
|
|
53
|
+
header. A loop SEND signal is never the remote HTTP status; remote status and
|
|
55
54
|
headers are persisted in `header`.
|
|
56
55
|
Exact-versus-pattern FIND preparation uses the shared
|
|
57
56
|
`PathSyntax.hasGlob` classifier {§path-glob}; HTTP owns no reduced
|
|
@@ -61,90 +60,63 @@ path-pattern grammar.
|
|
|
61
60
|
|
|
62
61
|
```mermaid
|
|
63
62
|
flowchart TD
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
prefetchClass -->|text| prefetchText["Materialize complete UTF-8 text"]
|
|
86
|
-
prefetchClass -->|binary| prefetchBinary["Bounded readable-byte projection"]
|
|
87
|
-
prefetchHtml -->|present, including empty| materialize["Write entry"]
|
|
88
|
-
prefetchHtml -->|absent| noProjection["422 no-readable-projection"]
|
|
89
|
-
prefetchText --> materialize
|
|
90
|
-
prefetchBinary -->|present, including empty| materialize
|
|
91
|
-
prefetchBinary -->|absent| noProjection
|
|
92
|
-
prefetchBinary -->|input ceiling| inputLimit["413 projection-input-limit"]
|
|
93
|
-
materialize --> query
|
|
94
|
-
|
|
95
|
-
stream --> response{"Response path"}
|
|
96
|
-
response -->|304 with stored GET| restore["Restore stored channels and refresh stamp"]
|
|
97
|
-
response -->|GET + HTML| render["Browser → rendered HTML"]
|
|
98
|
-
response -->|GET + SSE| acquired["Persist header → READ 102"]
|
|
99
|
-
acquired --> events["Detached event data → body chunks"]
|
|
100
|
-
response -->|other| representation{"Body representation"}
|
|
101
|
-
representation -->|none| empty["Header only"]
|
|
102
|
-
representation -->|configured text| text["UTF-8 response chunks → body"]
|
|
103
|
-
representation -->|configured binary| binaryProjection["Bounded readable-byte projection"]
|
|
104
|
-
binaryProjection -->|present, including empty| projected["Derived Unicode → body"]
|
|
105
|
-
binaryProjection -->|absent| binary["Cancel bytes → typed empty marker + 415"]
|
|
106
|
-
binaryProjection -->|input ceiling| binaryLimit["Typed empty marker + 413"]
|
|
107
|
-
restore --> close["Persist/publish → close exact result"]
|
|
108
|
-
render --> directHtml["Shared HTML materialization"]
|
|
109
|
-
directHtml -->|present, including empty| close
|
|
110
|
-
directHtml -->|absent| noProjection
|
|
111
|
-
events --> close
|
|
112
|
-
empty --> close
|
|
113
|
-
text --> close
|
|
114
|
-
projected --> close
|
|
115
|
-
binary --> close
|
|
116
|
-
binaryLimit --> close
|
|
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"]
|
|
117
84
|
```
|
|
118
85
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
|
127
|
-
|
|
|
128
|
-
|
|
|
129
|
-
|
|
|
130
|
-
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
evidence
|
|
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.
|
|
137
109
|
|
|
138
110
|
### §http-text-decoding Text response decoding
|
|
139
111
|
|
|
140
112
|
| Surface | Contract |
|
|
141
113
|
| ----------------------------- | ------------------------------------------------------------------------------------------------ |
|
|
142
114
|
| Response media type | WHATWG `MIMEType` essence; absent or unparseable metadata becomes `application/octet-stream` |
|
|
143
|
-
|
|
|
144
|
-
|
|
|
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 |
|
|
145
117
|
| `charset` parameter | Preserve in `header` as origin evidence; it does not replace Fetch text decoding |
|
|
146
118
|
| JSON and XML textual families | Use the same HTTP byte-to-string rule; format projections consume the resulting Unicode string |
|
|
147
|
-
| Direct HTML GET |
|
|
119
|
+
| Direct HTML GET | Fetch UTF-8 decoding of origin server HTML |
|
|
148
120
|
| Server-sent events | UTF-8 only under the HTML event-stream standard |
|
|
149
121
|
| Malformed UTF-8 | Preserve the Encoding Standard's replacement-character behavior |
|
|
150
122
|
|
|
@@ -156,62 +128,127 @@ durable channel.
|
|
|
156
128
|
### §html-materialization Readable materialization
|
|
157
129
|
|
|
158
130
|
`WebFetcher.materialize` is the shared readable-representation seam for exact
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
|
164
|
-
|
|
|
165
|
-
| Configured
|
|
166
|
-
| Configured binary
|
|
167
|
-
|
|
|
168
|
-
|
|
|
169
|
-
|
|
|
170
|
-
| HTML
|
|
171
|
-
|
|
|
172
|
-
|
|
|
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` |
|
|
173
148
|
|
|
174
149
|
A projection object is present even when its content is `""`; only `null`
|
|
175
150
|
denotes absence. A materialization exception retains its original `cause`; it
|
|
176
151
|
never enters the absence channel.
|
|
177
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
|
+
|
|
178
207
|
## §http-status §4 HTTP status mapping
|
|
179
208
|
|
|
180
|
-
| Outcome
|
|
181
|
-
|
|
|
182
|
-
|
|
|
183
|
-
| Exact FIND
|
|
184
|
-
| Exact acquisition returns no WebFetcher value
|
|
185
|
-
|
|
|
186
|
-
|
|
|
187
|
-
|
|
|
188
|
-
|
|
|
189
|
-
|
|
|
190
|
-
|
|
|
191
|
-
|
|
|
192
|
-
|
|
|
193
|
-
|
|
|
194
|
-
|
|
|
195
|
-
|
|
|
196
|
-
|
|
|
197
|
-
|
|
|
198
|
-
|
|
|
199
|
-
|
|
|
200
|
-
|
|
|
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 signal `410` | Exact entry-delete result |
|
|
223
|
+
| Routed SEND signal `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`) |
|
|
201
234
|
|
|
202
235
|
An HTTP error status is still a successfully acquired direct response: its
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
|
206
242
|
`PLURNK_SCHEMES_HTTP_ERROR_DETAIL_LIMIT` in model-facing detail while complete
|
|
207
243
|
errors remain in daemon diagnostics.
|
|
208
244
|
|
|
209
|
-
A
|
|
245
|
+
A binary response first asks the installed mimetype family for a bounded
|
|
210
246
|
readable projection. A present result stores only its derived Unicode and
|
|
211
247
|
appends authoritative `x-plurnk-projection-id` evidence after the origin and
|
|
212
|
-
acquisition fields.
|
|
213
|
-
|
|
214
|
-
|
|
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.
|
|
215
252
|
These statuses describe Plurnk's materialization boundary, not the remote HTTP
|
|
216
253
|
outcome—a POST, PUT, or DELETE might already have changed the remote resource.
|
|
217
254
|
Missing or malformed `Content-Type` becomes `application/octet-stream`; the
|
|
@@ -223,36 +260,17 @@ handler does not sniff or guess unknown bytes.
|
|
|
223
260
|
| ----------------- | --------------------------------------------------------------------------------------------------------- |
|
|
224
261
|
| Platform | Node ≥26 native fetch, streams, abort signals, decoding, DNS, and `WebSocket` |
|
|
225
262
|
| SSE | `eventsource-parser` for bounded WHATWG event-stream framing |
|
|
226
|
-
|
|
|
263
|
+
| Tavily Extract | Optional Tavily Extract API primitive when `TAVILY_API_KEY` is present |
|
|
227
264
|
|
|
228
265
|
### §http-config Operator configuration
|
|
229
266
|
|
|
230
|
-
| Concern
|
|
231
|
-
|
|
|
232
|
-
| Canonical registry
|
|
233
|
-
| Required values
|
|
234
|
-
|
|
|
235
|
-
|
|
|
236
|
-
|
|
|
237
|
-
|
|
238
|
-
`Http.ready()` verifies the selected browser route before the handler is
|
|
239
|
-
advertised. Disabled rendering is a valid configured route and fails clearly
|
|
240
|
-
if an HTML operation later requires the browser.
|
|
241
|
-
|
|
242
|
-
### §browser-provisioning Browser provisioning
|
|
243
|
-
|
|
244
|
-
| Component or method | Contract |
|
|
245
|
-
| ------------------- | ---------------------------------------------------------------------------------------------------- |
|
|
246
|
-
| Playwright client | Required runtime dependency; lazy import keeps non-render paths from initializing it |
|
|
247
|
-
| `launch` | Requires an operator-provisioned compatible browser, selected by Playwright, channel, or exact path |
|
|
248
|
-
| `connect` | Requires an external Playwright endpoint; no local browser executable |
|
|
249
|
-
| `connectOverCDP` | Requires an external Chromium CDP endpoint; no local browser executable |
|
|
250
|
-
| `disabled` | Requires no browser executable; a render attempt fails clearly |
|
|
251
|
-
|
|
252
|
-
The package has no browser-install lifecycle script and never assigns
|
|
253
|
-
`PLAYWRIGHT_BROWSERS_PATH`. Operators may provision the standard compatible
|
|
254
|
-
Chromium with `npx playwright install chromium`; methods never fall back into
|
|
255
|
-
one another.
|
|
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` |
|
|
256
274
|
|
|
257
275
|
### §automatic-fetch-check Automatic acquisition URL check
|
|
258
276
|
|
|
@@ -260,10 +278,10 @@ one another.
|
|
|
260
278
|
acquisition, it accepts credential-free HTTP(S) targets only when every
|
|
261
279
|
resolved address is ordinary globally reachable unicast, and repeats the check
|
|
262
280
|
before every manually followed redirect. A refused or unresolvable target is
|
|
263
|
-
the ordinary unavailable `null` result.
|
|
281
|
+
the ordinary unavailable `null` result. A transport failure after public
|
|
282
|
+
admission may still enter Tavily page production.
|
|
264
283
|
|
|
265
|
-
Direct HTTP operations
|
|
266
|
-
subresources, and Playwright/CDP endpoints do not use this check. Loopback,
|
|
284
|
+
Direct HTTP operations and WebSocket connections do not use this check. Loopback,
|
|
267
285
|
private, and link-local destinations are therefore valid explicit targets.
|
|
268
286
|
|
|
269
287
|
Redirect transitions follow WHATWG Fetch: 301/302 rewrite POST to GET; 303
|
|
@@ -272,26 +290,24 @@ A body rewrite removes body headers, cross-origin redirects remove
|
|
|
272
290
|
`Authorization`, and followed redirect bodies are cancelled. The configured
|
|
273
291
|
hop limit returns the last redirect rather than following beyond the limit.
|
|
274
292
|
Validation-time DNS answers are not pinned to connection-time resolution. This
|
|
275
|
-
check therefore makes no DNS-rebinding
|
|
293
|
+
check therefore makes no DNS-rebinding or total-egress claim.
|
|
276
294
|
|
|
277
|
-
## §
|
|
295
|
+
## §materialization-lifecycle §6 Materialization lifecycle
|
|
278
296
|
|
|
279
|
-
| Concern
|
|
280
|
-
|
|
|
281
|
-
| Direct gate
|
|
282
|
-
|
|
|
283
|
-
|
|
|
284
|
-
|
|
|
285
|
-
| Projection
|
|
286
|
-
| Cancellation
|
|
287
|
-
| Page cleanup | Close each opened page once and await it; preserve its failure alone or aggregate it after a primary failure |
|
|
288
|
-
| Shutdown | Attempt every context and browser close, await all, then aggregate failures under {§handler-lifecycle} |
|
|
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 |
|
|
289
305
|
|
|
290
306
|
### §host-rewrite Acquisition target rewrite
|
|
291
307
|
|
|
292
308
|
Only acquisition GETs are eligible for host rewriting. A GitHub
|
|
293
309
|
`…/blob/…` address uses the corresponding `raw.githubusercontent.com` source for
|
|
294
|
-
|
|
310
|
+
byte transport. Direct READ, exact FIND, and
|
|
295
311
|
WebFetcher prefetch share that rule. The originally addressed GitHub URL remains
|
|
296
312
|
entry identity. POST, PUT, and DELETE are never retargeted. Rewritten targets
|
|
297
313
|
are checked under {§automatic-fetch-check} only when `WebFetcher` acquires them.
|
|
@@ -300,8 +316,10 @@ are checked under {§automatic-fetch-check} only when `WebFetcher` acquires them
|
|
|
300
316
|
|
|
301
317
|
Acquired responses append package-owned `x-plurnk-request-method`,
|
|
302
318
|
`x-plurnk-fetched-at`, and `x-plurnk-cache-variant` fields after origin headers.
|
|
303
|
-
|
|
304
|
-
|
|
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.
|
|
305
323
|
Plurnk stores one representation per canonical URL rather than a variant set:
|
|
306
324
|
|
|
307
325
|
| Acquisition context | Package variant | Later cache use |
|
|
@@ -318,11 +336,11 @@ restored representation's package marker to `bypass`.
|
|
|
318
336
|
|
|
319
337
|
Only an eligible GET representation can supply a direct READ's body, TTL stamp,
|
|
320
338
|
conditional validators, or exact-FIND preparation. Completion comes from
|
|
321
|
-
channel lifecycle, not body length:
|
|
322
|
-
|
|
323
|
-
`errored
|
|
324
|
-
reuse eligibility remain distinct: an acquired response stays
|
|
325
|
-
when its origin policy prevents later cache use.
|
|
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.
|
|
326
344
|
|
|
327
345
|
| Stored origin policy | Direct READ after acquisition | Exact FIND after acquisition |
|
|
328
346
|
| ------------------------------------- | ------------------------------------------------------ | ---------------------------------------- |
|
|
@@ -340,10 +358,10 @@ stamp. A representation is fresh only while both origin lifetime and operator
|
|
|
340
358
|
ceiling permit it. Unknown cache extensions are inert. Stale content is never
|
|
341
359
|
served, so `must-revalidate` requires no separate path.
|
|
342
360
|
|
|
343
|
-
Outside the fresh window,
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
representation:
|
|
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:
|
|
347
365
|
|
|
348
366
|
| 304 validator | Correspondence requirement |
|
|
349
367
|
| ----------------------------------------------------- | ------------------------------------------- |
|
|
@@ -352,7 +370,7 @@ representation:
|
|
|
352
370
|
| No ETag; Last-Modified | Same valid stored Last-Modified instant |
|
|
353
371
|
| Missing, malformed, unsolicited, or non-corresponding | Invalid acquisition; `502` (`fetch-failed`) |
|
|
354
372
|
|
|
355
|
-
A corresponding 304 restores the stored channels without
|
|
373
|
+
A corresponding 304 restores the stored channels without rematerializing and
|
|
356
374
|
updates the header under the following ownership rule; any other response
|
|
357
375
|
replaces the channels:
|
|
358
376
|
|
|
@@ -362,21 +380,30 @@ replaces the channels:
|
|
|
362
380
|
| Origin fields absent from the 304 | Preserve |
|
|
363
381
|
| `Content-Type`, `Content-Encoding`, `Content-Range`, `Content-Length` | Preserve metadata describing the already-processed body |
|
|
364
382
|
| Package method, acquisition stamp, and variant | Rebuild authoritatively; refresh stamp and variant |
|
|
365
|
-
| Projection
|
|
383
|
+
| Projection evidence | Preserve |
|
|
366
384
|
|
|
367
385
|
A 304-provided `Vary`, `no-store`, `no-cache`, expiry, or validator
|
|
368
386
|
therefore governs the next operation without relabeling derived Unicode as a
|
|
369
387
|
different source representation.
|
|
370
388
|
|
|
371
|
-
A stored derived representation
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
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.
|
|
375
402
|
|
|
376
403
|
POST, PUT, and DELETE responses retain their method marker but cannot satisfy a
|
|
377
404
|
later GET or exact-FIND acquisition. An unmarked authored entry and an eligible
|
|
378
405
|
stored GET remain visible to universal FIND as durable evidence; exact HTTP
|
|
379
|
-
preparation applies the policy above. `
|
|
406
|
+
preparation applies the policy above. SEND signal `410` deletes the stored entry.
|
|
380
407
|
|
|
381
408
|
### §sse Server-sent events
|
|
382
409
|
|
|
@@ -392,26 +419,25 @@ operation is cancelled.
|
|
|
392
419
|
|
|
393
420
|
## §prefetch §7 WebFetcher
|
|
394
421
|
|
|
395
|
-
| Result
|
|
396
|
-
|
|
|
397
|
-
|
|
|
398
|
-
|
|
|
399
|
-
|
|
|
400
|
-
|
|
|
401
|
-
|
|
|
402
|
-
|
|
|
403
|
-
|
|
|
404
|
-
|
|
|
405
|
-
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
handler lifecycle closes the shared browser.
|
|
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.
|
|
415
441
|
|
|
416
442
|
## §ws §8 WebSocket
|
|
417
443
|
|
|
@@ -430,25 +456,32 @@ stateDiagram-v2
|
|
|
430
456
|
Claimed --> Idle: setup or construction failure
|
|
431
457
|
Connecting --> Open: native open; messages active; READ 102
|
|
432
458
|
Connecting --> Settling: pre-open close/error, KILL, cancel, activation failure, or shutdown
|
|
433
|
-
Open --> Open: ordered inbound frame or SEND
|
|
459
|
+
Open --> Open: ordered inbound frame, EDIT, or SEND 200
|
|
434
460
|
Open --> Settling: closing state, close/error, KILL, cancel, binary frame, persistence failure, or shutdown
|
|
435
461
|
Settling --> Idle: await retained work, close subscription, release claim
|
|
436
462
|
```
|
|
437
463
|
|
|
438
464
|
| Operation or event | Contract |
|
|
439
465
|
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
|
440
|
-
|
|
|
466
|
+
| `## READ0 (ws(s)://…)` | Claim, seed/subscribe, construct `CONNECTING`, then return `102` after native `open` plus durable activation |
|
|
441
467
|
| Concurrent duplicate READ | `409` in `claimed`, `connecting`, `open`, or `settling`; cleanup releases the only claim |
|
|
442
|
-
|
|
|
443
|
-
|
|
|
444
|
-
|
|
|
468
|
+
| `## EDIT0 (ws(s)://…)` | Send one whole text frame only for an open owner; line ranges and multi-statement batches are rejected |
|
|
469
|
+
| `## SEND0 [200] (ws(s)://…)` | Send only for owner `open` plus native `readyState=OPEN`; absent or non-open owner is `409`; send throw is `502` |
|
|
470
|
+
| `## SEND0 [499] (ws(s)://…)` | Engine-routed cancellation closes the owning READ; scheme dispatch returns `200` |
|
|
471
|
+
| `## KILL0 (ws(s)://…)` | Close/cancel the claimed owner; no owner is `404`; an attempted close throw is `502` |
|
|
445
472
|
| Inbound frame after native `open` | Join the owner's persistence chain; the next write begins only after the preceding write succeeds |
|
|
446
|
-
| Binary frame after native `open` | Retain the text prefix, prune the binary and later frames, settle `415 binary-frame-unsupported`, close `
|
|
473
|
+
| 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` |
|
|
447
474
|
| First inbound persistence failure | Retain the successful prefix, prune queued and later frames, and settle with `500 message-persistence-failed` |
|
|
448
475
|
| Socket closes before `open` | Close subscription with `502 connection-failed`; the pending READ returns that exact failure |
|
|
449
476
|
| Socket closes after `open` | Drain the accepted frame prefix; initial READ remains `102`; settle with `200` unless a drained write fails |
|
|
450
477
|
| Failure after `open` | Initial READ remains `102`; persist the exact terminal failure and wake through subscription settlement |
|
|
451
478
|
|
|
479
|
+
Markerless single-statement EDIT and SEND with signal `200` converge on one
|
|
480
|
+
outbound text-frame path and have the same connection and transport outcomes.
|
|
481
|
+
Dispatcher phase order ({§op-mode-phases}) runs EDIT before READ and SEND after
|
|
482
|
+
READ, so an EDIT requires an owner opened before the turn while SEND can follow
|
|
483
|
+
the opening READ in the same turn.
|
|
484
|
+
|
|
452
485
|
The in-instance registry is keyed by workspace, addressed protocol, and
|
|
453
486
|
canonical network pathname. The claim remains registered through terminal
|
|
454
487
|
cleanup, so a new READ cannot overlap an owner's subscription settlement. Every
|
|
@@ -461,7 +494,7 @@ transport-close failures under {§handler-lifecycle}.
|
|
|
461
494
|
|
|
462
495
|
| Transport limit | Current contract |
|
|
463
496
|
| ------------------ | ------------------------------------------------------------------------------------------------------- |
|
|
464
|
-
| Payload projection | String event data only into `text/plain`; binary data terminates with Plurnk `415` and WebSocket `
|
|
497
|
+
| Payload projection | String event data only into `text/plain`; binary data terminates with Plurnk `415` and private-use WebSocket code `4003` |
|
|
465
498
|
| Reconnection | None; READ again after terminal cleanup |
|
|
466
499
|
| Handshake metadata | Default global-WebSocket identity; custom target headers are not applied |
|
|
467
500
|
| Runtime | Node ≥26 |
|