@reticlehq/core 2.14.0 → 3.2.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/dist/{artifacts-entry.d.ts → artifacts/artifacts-entry.d.ts} +7 -7
- package/dist/{artifacts-entry.js → artifacts/artifacts-entry.js} +7 -7
- package/dist/artifacts/flow-composition.d.ts +30 -0
- package/dist/artifacts/flow-composition.js +19 -0
- package/dist/{flow-constants.d.ts → artifacts/flow-constants.d.ts} +99 -3
- package/dist/{flow-constants.js → artifacts/flow-constants.js} +108 -4
- package/dist/artifacts/flow-mutation-target.d.ts +39 -0
- package/dist/artifacts/flow-mutation-target.js +89 -0
- package/dist/artifacts/flow-order.d.ts +30 -0
- package/dist/artifacts/flow-order.js +49 -0
- package/dist/artifacts/flow-select.d.ts +56 -0
- package/dist/artifacts/flow-select.js +56 -0
- package/dist/artifacts/flow-step-tool.d.ts +31 -0
- package/dist/artifacts/flow-step-tool.js +31 -0
- package/dist/artifacts/flow-types.d.ts +3736 -0
- package/dist/artifacts/flow-types.js +463 -0
- package/dist/artifacts/flow-unreached.d.ts +12 -0
- package/dist/artifacts/flow-unreached.js +24 -0
- package/dist/{impact.d.ts → artifacts/impact.d.ts} +271 -103
- package/dist/{impact.js → artifacts/impact.js} +75 -5
- package/dist/artifacts/journal.d.ts +218 -0
- package/dist/artifacts/journal.js +130 -0
- package/dist/artifacts/step-effect.d.ts +29 -0
- package/dist/artifacts/step-effect.js +28 -0
- package/dist/hooks/hook-events.d.ts +311 -0
- package/dist/hooks/hook-events.js +127 -0
- package/dist/hooks/hooks-entry.d.ts +9 -0
- package/dist/hooks/hooks-entry.js +9 -0
- package/dist/identity/brand.d.ts +102 -0
- package/dist/{brand.js → identity/brand.js} +7 -0
- package/dist/{contract-fingerprint.d.ts → identity/contract-fingerprint.d.ts} +21 -3
- package/dist/{contract-fingerprint.js → identity/contract-fingerprint.js} +22 -4
- package/dist/{document-identity.d.ts → identity/document-identity.d.ts} +4 -5
- package/dist/{document-identity.js → identity/document-identity.js} +4 -5
- package/dist/{source-constants.d.ts → identity/source-constants.d.ts} +4 -4
- package/dist/{source-constants.js → identity/source-constants.js} +4 -4
- package/dist/index.d.ts +57 -43
- package/dist/index.js +66 -45
- package/dist/onboarding.d.ts +114 -0
- package/dist/onboarding.js +141 -0
- package/dist/realm/registry.d.ts +212 -0
- package/dist/realm/registry.js +302 -0
- package/dist/{dev-server-registry.d.ts → registry/dev-server-registry.d.ts} +6 -7
- package/dist/{dev-server-registry.js → registry/dev-server-registry.js} +28 -19
- package/dist/{project-registry.d.ts → registry/project-registry.d.ts} +5 -5
- package/dist/{project-registry.js → registry/project-registry.js} +5 -5
- package/dist/schema/command-name.json +31 -0
- package/dist/schema/event-payloads.json +795 -0
- package/dist/schema/hello-message.json +70 -2
- package/dist/schema/reticle-message.json +70 -2
- package/dist/telemetry-entry.d.ts +1 -1
- package/dist/telemetry-entry.js +1 -1
- package/dist/telemetry-feedback.d.ts +15 -16
- package/dist/telemetry-feedback.js +11 -12
- package/dist/telemetry-license.d.ts +1 -1
- package/dist/telemetry-license.js +1 -1
- package/dist/telemetry-refusal.d.ts +11 -11
- package/dist/telemetry-refusal.js +7 -8
- package/dist/telemetry-session.d.ts +51 -59
- package/dist/telemetry-session.js +47 -55
- package/dist/telemetry.d.ts +306 -222
- package/dist/telemetry.js +112 -99
- package/dist/tour-entry.d.ts +10 -0
- package/dist/tour-entry.js +10 -0
- package/dist/tour.d.ts +125 -0
- package/dist/tour.js +165 -0
- package/dist/{consequence.d.ts → verdict/consequence.d.ts} +32 -15
- package/dist/{consequence.js → verdict/consequence.js} +9 -31
- package/dist/{finding-fingerprint.js → verdict/finding-fingerprint.js} +1 -1
- package/dist/{findings.d.ts → verdict/findings.d.ts} +86 -39
- package/dist/{findings.js → verdict/findings.js} +103 -49
- package/dist/{instrumentation-gap.d.ts → verdict/instrumentation-gap.d.ts} +7 -14
- package/dist/{instrumentation-gap.js → verdict/instrumentation-gap.js} +7 -15
- package/dist/{intent.d.ts → verdict/intent.d.ts} +35 -46
- package/dist/{intent.js → verdict/intent.js} +11 -22
- package/dist/verdict/revision.d.ts +44 -0
- package/dist/verdict/revision.js +53 -0
- package/dist/{run-context.d.ts → verdict/run-context.d.ts} +13 -34
- package/dist/{run-context.js → verdict/run-context.js} +15 -36
- package/dist/{security.js → verdict/security.js} +12 -21
- package/dist/{verification-run.d.ts → verdict/verification-run.d.ts} +381 -105
- package/dist/{verification-run.js → verdict/verification-run.js} +157 -21
- package/dist/{verified-constants.d.ts → verdict/verified-constants.d.ts} +34 -13
- package/dist/{verified-constants.js → verdict/verified-constants.js} +34 -13
- package/dist/{verify-progress.d.ts → verdict/verify-progress.d.ts} +18 -22
- package/dist/{verify-progress.js → verdict/verify-progress.js} +6 -10
- package/dist/wire/channel.d.ts +46 -0
- package/dist/wire/channel.js +95 -0
- package/dist/{constants.d.ts → wire/constants/constants.d.ts} +179 -28
- package/dist/{constants.js → wire/constants/constants.js} +199 -28
- package/dist/{session-constants.d.ts → wire/constants/session-constants.d.ts} +23 -2
- package/dist/{session-constants.js → wire/constants/session-constants.js} +23 -2
- package/dist/{desktop-contract.js → wire/desktop-contract.js} +1 -1
- package/dist/{event-classification.js → wire/event-classification.js} +1 -1
- package/dist/{event-payloads.d.ts → wire/event-payloads.d.ts} +72 -13
- package/dist/{event-payloads.js → wire/event-payloads.js} +23 -3
- package/dist/{event-priority.d.ts → wire/event-priority.d.ts} +1 -4
- package/dist/{event-priority.js → wire/event-priority.js} +2 -5
- package/dist/{global-press.js → wire/global-press.js} +1 -1
- package/dist/{messages.d.ts → wire/messages.d.ts} +240 -48
- package/dist/{messages.js → wire/messages.js} +68 -5
- package/dist/wire/narrow.d.ts +39 -0
- package/dist/wire/narrow.js +45 -0
- package/dist/{net.d.ts → wire/net.d.ts} +36 -13
- package/dist/{net.js → wire/net.js} +36 -13
- package/dist/wire/platform.d.ts +37 -0
- package/dist/wire/platform.js +36 -0
- package/dist/{redaction.js → wire/redaction.js} +12 -12
- package/dist/wire/snapshot-tree.d.ts +33 -0
- package/dist/wire/snapshot-tree.js +43 -0
- package/dist/wire/tool-names.d.ts +133 -0
- package/dist/wire/tool-names.js +142 -0
- package/dist/{toon.js → wire/toon.js} +1 -1
- package/dist/{types.d.ts → wire/types.d.ts} +77 -76
- package/dist/{types.js → wire/types.js} +4 -3
- package/dist/{no-session-reason.d.ts → words/no-session-reason.d.ts} +7 -3
- package/dist/{no-session-reason.js → words/no-session-reason.js} +7 -3
- package/dist/{notices.d.ts → words/notices.d.ts} +8 -12
- package/dist/{notices.js → words/notices.js} +8 -12
- package/package.json +16 -7
- package/dist/brand.d.ts +0 -49
- package/dist/flow-types.d.ts +0 -1711
- package/dist/flow-types.js +0 -247
- package/dist/journal.d.ts +0 -122
- package/dist/journal.js +0 -57
- package/dist/{impact-savings.d.ts → artifacts/impact-savings.d.ts} +0 -0
- package/dist/{impact-savings.js → artifacts/impact-savings.js} +0 -0
- package/dist/{edit-epoch.d.ts → identity/edit-epoch.d.ts} +0 -0
- package/dist/{edit-epoch.js → identity/edit-epoch.js} +0 -0
- package/dist/{project-id.d.ts → identity/project-id.d.ts} +0 -0
- package/dist/{project-id.js → identity/project-id.js} +0 -0
- package/dist/{daemon-registry.d.ts → registry/daemon-registry.d.ts} +0 -0
- package/dist/{daemon-registry.js → registry/daemon-registry.js} +0 -0
- package/dist/{finding-fingerprint.d.ts → verdict/finding-fingerprint.d.ts} +0 -0
- package/dist/{security.d.ts → verdict/security.d.ts} +0 -0
- package/dist/{desktop-contract.d.ts → wire/desktop-contract.d.ts} +0 -0
- package/dist/{event-classification.d.ts → wire/event-classification.d.ts} +0 -0
- package/dist/{global-press.d.ts → wire/global-press.d.ts} +0 -0
- package/dist/{redaction.d.ts → wire/redaction.d.ts} +0 -0
- package/dist/{state-select.d.ts → wire/state-select.d.ts} +0 -0
- package/dist/{state-select.js → wire/state-select.js} +0 -0
- package/dist/{toon.d.ts → wire/toon.d.ts} +0 -0
- package/dist/{browser-misdirect.d.ts → words/browser-misdirect.d.ts} +0 -0
- package/dist/{browser-misdirect.js → words/browser-misdirect.js} +0 -0
- package/dist/{unreachable-notice.d.ts → words/unreachable-notice.d.ts} +0 -0
- package/dist/{unreachable-notice.js → words/unreachable-notice.js} +0 -0
- package/dist/{upgrade.d.ts → words/upgrade.d.ts} +2 -2
- /package/dist/{upgrade.js → words/upgrade.js} +0 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One record per realm, in a table the compiler refuses to leave a hole in.
|
|
3
|
+
*
|
|
4
|
+
* NOT the protocol's `Realm`. That is an abstract class in `open-verification` describing what
|
|
5
|
+
* a realm can DO -- eight questions an implementation answers. This describes what a realm IS LIKE:
|
|
6
|
+
* four fixed traits the rest of the codebase branches on. It is a lookup table, not a specification.
|
|
7
|
+
*
|
|
8
|
+
* A realm is the kind of place an app runs: a browser tab, an Electron window, a Tauri window. The
|
|
9
|
+
* four traits are whether it is a desktop shell, whether it draws with WebKit, whether its coverage
|
|
10
|
+
* warnings are its own, and whether its visual baselines get their own directory.
|
|
11
|
+
*
|
|
12
|
+
* Adding a realm is one row. `Record<AppRuntime, RealmTraits>` means leaving it out is a COMPILE
|
|
13
|
+
* error rather than a silent default — a scattered `if` gives a new realm the *web* answer, which
|
|
14
|
+
* is the answer most likely to look plausible and be wrong. That is the whole reason this is a
|
|
15
|
+
* table and not a lookup function with a fallback.
|
|
16
|
+
*
|
|
17
|
+
* Deliberately NOT here: anything a realm DOES rather than is. Which screenshot backend to call,
|
|
18
|
+
* how to patch a build config, what a connect snippet looks like — those are code and live with the
|
|
19
|
+
* code that runs them. This table holds facts you could write on an index card.
|
|
20
|
+
*/
|
|
21
|
+
import { type DeterminismProfile, Surface, type SubjectRef } from 'open-verification';
|
|
22
|
+
import { AppRuntime } from '../telemetry-feedback.js';
|
|
23
|
+
import { PlatformProfile } from '../wire/platform.js';
|
|
24
|
+
/** What Reticle needs to know about a realm that it cannot work out by looking. */
|
|
25
|
+
export interface RealmTraits {
|
|
26
|
+
/**
|
|
27
|
+
* Which of the protocol's surfaces this realm IS.
|
|
28
|
+
*
|
|
29
|
+
* Declared rather than derived. `surfaceOf` used to ask `isDesktopShell ? DESKTOP : WEB`, so of
|
|
30
|
+
* the six surfaces the protocol names — web, desktop, mobile, service, game, device — only two
|
|
31
|
+
* could ever be returned, while `DETERMINISM_BY_SURFACE` already carried a correct row for all
|
|
32
|
+
* six. A mobile, service, game or device realm had no way to be NAMED even though the rules
|
|
33
|
+
* governing it were written and waiting.
|
|
34
|
+
*
|
|
35
|
+
* A boolean answers two questions; a surface is not a question with two answers. With this here,
|
|
36
|
+
* adding a domain is a row in the table below rather than an edit to a branch — and the branch is
|
|
37
|
+
* the thing that would have answered `web` to everything it had not heard of.
|
|
38
|
+
*/
|
|
39
|
+
readonly surface: Surface;
|
|
40
|
+
/**
|
|
41
|
+
* Does the app run in a window of its own, rather than a browser tab?
|
|
42
|
+
*
|
|
43
|
+
* Decides whether advice about dev servers and tabs applies, and whether desktop-only coverage
|
|
44
|
+
* warnings are worth showing.
|
|
45
|
+
*/
|
|
46
|
+
readonly isDesktopShell: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Does it draw with WebKit?
|
|
49
|
+
*
|
|
50
|
+
* A hidden WebKit window stops executing while still answering screenshots, so a command that
|
|
51
|
+
* times out there needs different advice: park the window off-screen rather than hiding it.
|
|
52
|
+
*/
|
|
53
|
+
readonly usesWebKit: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Does it raise coverage warnings that make no sense for any other realm?
|
|
56
|
+
*
|
|
57
|
+
* Only Electron does, and this is narrower than "is a desktop shell", which is what it looks like
|
|
58
|
+
* at first glance. The warnings in question are about IPC going unobserved, and they exist because
|
|
59
|
+
* an Electron renderer needs a preload script to see its own IPC: without one, everything is
|
|
60
|
+
* unobserved and nothing says so.
|
|
61
|
+
*
|
|
62
|
+
* Tauri is a desktop shell and raises none of them, because its `invoke` travels as an ordinary
|
|
63
|
+
* fetch to a custom protocol and is already visible. A browser tab has no IPC at all.
|
|
64
|
+
*
|
|
65
|
+
* Reported for the wrong realm, a missing-preload warning reads as an un-instrumented app -- which
|
|
66
|
+
* is how a plain Vite page once looked like a broken Electron install.
|
|
67
|
+
*/
|
|
68
|
+
readonly ownsCoverageKinds: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Do its visual baselines live in a directory of their own?
|
|
71
|
+
*
|
|
72
|
+
* The web is the default and keeps the top-level directory it has always had; anything else is
|
|
73
|
+
* filed under its own name, so two realms of one project cannot overwrite each other's pictures.
|
|
74
|
+
*/
|
|
75
|
+
readonly hasOwnBaselineDirectory: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* How a project on disk says it is this realm, or `undefined` when nothing marks it.
|
|
78
|
+
*
|
|
79
|
+
* A fact you could write on an index card, which is why it belongs here: a Tauri project has a
|
|
80
|
+
* `src-tauri/tauri.conf.json`, an Electron project depends on `electron`. What to DO once you know
|
|
81
|
+
* stays where it is; this only answers which realm you are looking at.
|
|
82
|
+
*
|
|
83
|
+
* The web has no marker, and that is the point rather than an omission. A web project is a project
|
|
84
|
+
* with none of the others' markers, so giving it one would make every project match two realms.
|
|
85
|
+
*/
|
|
86
|
+
readonly projectMarker?: {
|
|
87
|
+
readonly file: string;
|
|
88
|
+
} | {
|
|
89
|
+
readonly dependency: string;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Every realm Reticle knows about.
|
|
94
|
+
*
|
|
95
|
+
* Adding one is a row here plus a value on `AppRuntime`. The compiler will not let you add the value
|
|
96
|
+
* without the row, which is the point: the alternative is a lookup that quietly answers "web".
|
|
97
|
+
*/
|
|
98
|
+
export declare const REALMS: Record<AppRuntime, RealmTraits>;
|
|
99
|
+
/**
|
|
100
|
+
* Is this a realm this build knows about?
|
|
101
|
+
*
|
|
102
|
+
* Asked where a runtime arrives from the page and has to be accepted or ignored. Derived from the
|
|
103
|
+
* table rather than listed again, because a list repeated somewhere else is a list that gets one
|
|
104
|
+
* entry behind: a realm missing from it is not rejected loudly, its name is simply dropped, and every
|
|
105
|
+
* later question about that session answers as though the page never said what it was.
|
|
106
|
+
*
|
|
107
|
+
* Written as a type guard so the caller gets the narrowing the hand-written chain of comparisons gave
|
|
108
|
+
* it for free. Without that, replacing the chain would have widened a field back to a plain string,
|
|
109
|
+
* and the compiler would stop catching a runtime this package does not know.
|
|
110
|
+
*/
|
|
111
|
+
export declare function isKnownRealm(runtime: string | undefined): runtime is AppRuntime;
|
|
112
|
+
/**
|
|
113
|
+
* Teach this process about a realm it does not ship.
|
|
114
|
+
*
|
|
115
|
+
* The `x-` prefix is required for two reasons that are both about the future: a third-party name
|
|
116
|
+
* can never collide with one this package later ships, and a reader can tell at a glance which
|
|
117
|
+
* realms this package ships and which a host added. It is the same convention `ChannelIdSchema` already
|
|
118
|
+
* enforces for channels.
|
|
119
|
+
*
|
|
120
|
+
* Throws rather than returning a result. A realm that failed to register would answer `web` to
|
|
121
|
+
* everything — the most plausible-looking wrong answer available — and the caller is a host at
|
|
122
|
+
* startup, where a throw is read immediately and a silent miss is not read at all.
|
|
123
|
+
*
|
|
124
|
+
* CEILING, invisible from the signature: there is no host seam in the daemon. `reticle serve`
|
|
125
|
+
* imports no user module, so nothing outside this repository has a moment in which to call this,
|
|
126
|
+
* and every realm Reticle ships is a row in `REALMS` rather than a registration. Adding a realm
|
|
127
|
+
* today means a change to `@reticlehq/core`.
|
|
128
|
+
*/
|
|
129
|
+
export declare function registerRealm(runtime: string, traits: RealmTraits): void;
|
|
130
|
+
/** Every runtime this process understands: the built-ins, plus whatever a host registered. */
|
|
131
|
+
export declare function knownRuntimes(): string[];
|
|
132
|
+
/** Forget every registered realm. For tests and for a host rebuilding its own registry. */
|
|
133
|
+
export declare function resetRegisteredRealms(): void;
|
|
134
|
+
export declare function realmOf(runtime: string | undefined): RealmTraits;
|
|
135
|
+
/**
|
|
136
|
+
* The protocol's surface for a realm.
|
|
137
|
+
*
|
|
138
|
+
* Reads `isDesktopShell` rather than testing the runtime again, which is the whole reason this
|
|
139
|
+
* table exists: a third place branching on `electron || tauri` is a third place to forget a realm,
|
|
140
|
+
* and the answer it would forget into is the web one -- the answer most likely to look plausible
|
|
141
|
+
* and be wrong.
|
|
142
|
+
*
|
|
143
|
+
* An unknown or absent runtime answers `web`, like everything else here. For a surface that IS an
|
|
144
|
+
* assumption rather than a fact: a `SubjectRef` requires one and the handshake carries no other
|
|
145
|
+
* tell, so the error is a desktop app identified as a page, which understates the subject rather
|
|
146
|
+
* than misdescribing it.
|
|
147
|
+
*/
|
|
148
|
+
export declare function surfaceOf(runtime: string | undefined): Surface;
|
|
149
|
+
/**
|
|
150
|
+
* What a subject's identity is read from.
|
|
151
|
+
*
|
|
152
|
+
* Structural rather than a `Session`, so the identity can be taken where a full session is not in
|
|
153
|
+
* hand -- the run artifact is assembled at teardown from a narrowed view of one. Naming it is the
|
|
154
|
+
* point: there is exactly ONE definition of what identifies a subject, and a second place
|
|
155
|
+
* computing `surface` and `instance` its own way is how two artifacts about the same session come
|
|
156
|
+
* to disagree about what was verified.
|
|
157
|
+
*/
|
|
158
|
+
export interface SubjectFacts {
|
|
159
|
+
readonly id: string;
|
|
160
|
+
readonly url: string;
|
|
161
|
+
readonly runtime?: string | undefined;
|
|
162
|
+
readonly currentDocumentId?: string | undefined;
|
|
163
|
+
readonly currentEditEpoch?: number | undefined;
|
|
164
|
+
}
|
|
165
|
+
/** The protocol's identity for a connected subject. */
|
|
166
|
+
export declare function subjectOf(facts: SubjectFacts): SubjectRef;
|
|
167
|
+
/**
|
|
168
|
+
* Which realm a project on disk is, judged only by its markers.
|
|
169
|
+
*
|
|
170
|
+
* A project can carry more than one marker, so precedence has to be decided rather than inherited
|
|
171
|
+
* from whatever order the table happens to be written in.
|
|
172
|
+
*
|
|
173
|
+
* A CONFIG FILE beats a DEPENDENCY. A file like `src-tauri/tauri.conf.json` exists because somebody
|
|
174
|
+
* set this project up to be that kind of app; a dependency can be transitive, vestigial, or left
|
|
175
|
+
* behind by something that was tried and abandoned. The stronger claim wins, which is also what the
|
|
176
|
+
* hand-written checks this replaces already did.
|
|
177
|
+
*
|
|
178
|
+
* Returns undefined rather than the web when nothing matches. "This is a plain web project" and "I
|
|
179
|
+
* could not tell" are the same observation here, and naming it `web` would state more than was seen.
|
|
180
|
+
*/
|
|
181
|
+
export declare function realmOfProject(hasFile: (path: string) => boolean, hasDependency: (name: string) => boolean): AppRuntime | undefined;
|
|
182
|
+
/** The kind of surface a shell presents, or undefined if we have never heard of the shell. */
|
|
183
|
+
export declare function profileOfRuntime(runtime: string | undefined): PlatformProfile | undefined;
|
|
184
|
+
/**
|
|
185
|
+
* How each kind of surface may be DRIVEN.
|
|
186
|
+
*
|
|
187
|
+
* "Resume is nearly free, just re-run the prefix at 27 ms a step" is true of a browser and FALSE
|
|
188
|
+
* AND DANGEROUS on hardware, where re-driving a prefix moves a physical
|
|
189
|
+
* arm, costs real time, and may not be idempotent. The protocol already decides this from a declared
|
|
190
|
+
* profile via `resumeStrategy`; what was missing was anywhere for server code to GET a profile,
|
|
191
|
+
* because a `Realm` object is constructed only by the conformance client and the code that resumes a
|
|
192
|
+
* replay has no realm to ask.
|
|
193
|
+
*
|
|
194
|
+
* A determinism profile is a property of the KIND of subject, not of one realm instance, so it lives
|
|
195
|
+
* here beside the other facts about kinds. That is what makes the rule enforceable on the path that
|
|
196
|
+
* actually resumes, today, rather than after some future wiring.
|
|
197
|
+
*
|
|
198
|
+
* Every surface the vocabulary names is declared. A missing entry would fall through to the web
|
|
199
|
+
* answer, and the web answer is the permissive one — which is the wrong direction to be wrong in
|
|
200
|
+
* when the question is "may I silently re-send this payment".
|
|
201
|
+
*/
|
|
202
|
+
export declare const DETERMINISM_BY_SURFACE: Record<Surface, DeterminismProfile>;
|
|
203
|
+
/** The declared profile for a surface. */
|
|
204
|
+
export declare function determinismFor(surface: Surface): DeterminismProfile;
|
|
205
|
+
/**
|
|
206
|
+
* May a resume re-drive the steps before the one asked for?
|
|
207
|
+
*
|
|
208
|
+
* The one question the resume path has to ask before it silently repeats somebody's actions. Derived
|
|
209
|
+
* through the protocol's own `resumeStrategy` rather than by reading `replayPrefix` here, so this
|
|
210
|
+
* cannot drift from the rule the specification publishes.
|
|
211
|
+
*/
|
|
212
|
+
export declare function mayResumeByReplayingPrefix(surface: Surface): boolean;
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One record per realm, in a table the compiler refuses to leave a hole in.
|
|
3
|
+
*
|
|
4
|
+
* NOT the protocol's `Realm`. That is an abstract class in `open-verification` describing what
|
|
5
|
+
* a realm can DO -- eight questions an implementation answers. This describes what a realm IS LIKE:
|
|
6
|
+
* four fixed traits the rest of the codebase branches on. It is a lookup table, not a specification.
|
|
7
|
+
*
|
|
8
|
+
* A realm is the kind of place an app runs: a browser tab, an Electron window, a Tauri window. The
|
|
9
|
+
* four traits are whether it is a desktop shell, whether it draws with WebKit, whether its coverage
|
|
10
|
+
* warnings are its own, and whether its visual baselines get their own directory.
|
|
11
|
+
*
|
|
12
|
+
* Adding a realm is one row. `Record<AppRuntime, RealmTraits>` means leaving it out is a COMPILE
|
|
13
|
+
* error rather than a silent default — a scattered `if` gives a new realm the *web* answer, which
|
|
14
|
+
* is the answer most likely to look plausible and be wrong. That is the whole reason this is a
|
|
15
|
+
* table and not a lookup function with a fallback.
|
|
16
|
+
*
|
|
17
|
+
* Deliberately NOT here: anything a realm DOES rather than is. Which screenshot backend to call,
|
|
18
|
+
* how to patch a build config, what a connect snippet looks like — those are code and live with the
|
|
19
|
+
* code that runs them. This table holds facts you could write on an index card.
|
|
20
|
+
*/
|
|
21
|
+
import { ResumeStrategy, resumeStrategy, Surface, } from 'open-verification';
|
|
22
|
+
import { AppRuntime } from '../telemetry-feedback.js';
|
|
23
|
+
import { PlatformProfile } from '../wire/platform.js';
|
|
24
|
+
/**
|
|
25
|
+
* Every realm Reticle knows about.
|
|
26
|
+
*
|
|
27
|
+
* Adding one is a row here plus a value on `AppRuntime`. The compiler will not let you add the value
|
|
28
|
+
* without the row, which is the point: the alternative is a lookup that quietly answers "web".
|
|
29
|
+
*/
|
|
30
|
+
export const REALMS = {
|
|
31
|
+
[AppRuntime.WEB]: {
|
|
32
|
+
surface: Surface.WEB,
|
|
33
|
+
isDesktopShell: false,
|
|
34
|
+
usesWebKit: false,
|
|
35
|
+
ownsCoverageKinds: false,
|
|
36
|
+
hasOwnBaselineDirectory: false,
|
|
37
|
+
},
|
|
38
|
+
[AppRuntime.ELECTRON]: {
|
|
39
|
+
surface: Surface.DESKTOP,
|
|
40
|
+
isDesktopShell: true,
|
|
41
|
+
// No config file of its own: an Electron app is one that depends on Electron.
|
|
42
|
+
projectMarker: { dependency: 'electron' },
|
|
43
|
+
// Chromium, whatever the host operating system is.
|
|
44
|
+
usesWebKit: false,
|
|
45
|
+
ownsCoverageKinds: true,
|
|
46
|
+
hasOwnBaselineDirectory: true,
|
|
47
|
+
},
|
|
48
|
+
[AppRuntime.TAURI]: {
|
|
49
|
+
surface: Surface.DESKTOP,
|
|
50
|
+
isDesktopShell: true,
|
|
51
|
+
projectMarker: { file: 'src-tauri/tauri.conf.json' },
|
|
52
|
+
// The system webview: WKWebView on macOS, WebKitGTK on Linux.
|
|
53
|
+
usesWebKit: true,
|
|
54
|
+
// A desktop shell that raises none of its own coverage warnings. Its `invoke` is a fetch to a
|
|
55
|
+
// custom protocol, so the IPC is already observed and there is no unobserved-IPC case to report.
|
|
56
|
+
// The obvious grouping -- "the two desktop ones behave alike" -- is wrong here.
|
|
57
|
+
ownsCoverageKinds: false,
|
|
58
|
+
hasOwnBaselineDirectory: true,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Is this a realm this build knows about?
|
|
63
|
+
*
|
|
64
|
+
* Asked where a runtime arrives from the page and has to be accepted or ignored. Derived from the
|
|
65
|
+
* table rather than listed again, because a list repeated somewhere else is a list that gets one
|
|
66
|
+
* entry behind: a realm missing from it is not rejected loudly, its name is simply dropped, and every
|
|
67
|
+
* later question about that session answers as though the page never said what it was.
|
|
68
|
+
*
|
|
69
|
+
* Written as a type guard so the caller gets the narrowing the hand-written chain of comparisons gave
|
|
70
|
+
* it for free. Without that, replacing the chain would have widened a field back to a plain string,
|
|
71
|
+
* and the compiler would stop catching a runtime this package does not know.
|
|
72
|
+
*/
|
|
73
|
+
export function isKnownRealm(runtime) {
|
|
74
|
+
return runtime !== undefined && Object.hasOwn(REALMS, runtime);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The facts for a realm, or the web's, when the page has not said which it is.
|
|
78
|
+
*
|
|
79
|
+
* An older SDK sends no runtime at all. Reading that silence as a desktop shell would show desktop
|
|
80
|
+
* warnings to every browser tab connected by an older client, so the unknown case answers as the web:
|
|
81
|
+
* the realm with the fewest special cases, and the one almost every unknown session actually is.
|
|
82
|
+
*
|
|
83
|
+
* Takes a plain string rather than the enum, deliberately. What arrives here came off the wire from
|
|
84
|
+
* a page that may be newer than this build, so "a realm I have never heard of" is a case that has to
|
|
85
|
+
* exist -- and typing the parameter as the enum would describe a guarantee the wire cannot make.
|
|
86
|
+
*/
|
|
87
|
+
/**
|
|
88
|
+
* Realms a host registered at startup, for domains this package does not ship.
|
|
89
|
+
*
|
|
90
|
+
* `REALMS` above is a compile-checked `Record<AppRuntime, …>` and stays that way: leaving out a
|
|
91
|
+
* shell this package ships must remain a compile error. But that same shape is a wall for everybody else —
|
|
92
|
+
* an Android realm, a game realm, a CLI realm cannot be NAMED without a pull request against
|
|
93
|
+
* `@reticlehq/core`, and a protocol meant for industries that have never heard of this repository
|
|
94
|
+
* cannot require one.
|
|
95
|
+
*
|
|
96
|
+
* Separate map rather than a mutable `REALMS`, so a registration can never shadow or delete a
|
|
97
|
+
* built-in. Extension must not mean an adopter can redefine `web`.
|
|
98
|
+
*/
|
|
99
|
+
const REGISTERED = new Map();
|
|
100
|
+
/** The prefix every extension in this protocol carries. Not decoration — see `registerRealm`. */
|
|
101
|
+
const EXTENSION_PREFIX = 'x-';
|
|
102
|
+
/**
|
|
103
|
+
* Teach this process about a realm it does not ship.
|
|
104
|
+
*
|
|
105
|
+
* The `x-` prefix is required for two reasons that are both about the future: a third-party name
|
|
106
|
+
* can never collide with one this package later ships, and a reader can tell at a glance which
|
|
107
|
+
* realms this package ships and which a host added. It is the same convention `ChannelIdSchema` already
|
|
108
|
+
* enforces for channels.
|
|
109
|
+
*
|
|
110
|
+
* Throws rather than returning a result. A realm that failed to register would answer `web` to
|
|
111
|
+
* everything — the most plausible-looking wrong answer available — and the caller is a host at
|
|
112
|
+
* startup, where a throw is read immediately and a silent miss is not read at all.
|
|
113
|
+
*
|
|
114
|
+
* CEILING, invisible from the signature: there is no host seam in the daemon. `reticle serve`
|
|
115
|
+
* imports no user module, so nothing outside this repository has a moment in which to call this,
|
|
116
|
+
* and every realm Reticle ships is a row in `REALMS` rather than a registration. Adding a realm
|
|
117
|
+
* today means a change to `@reticlehq/core`.
|
|
118
|
+
*/
|
|
119
|
+
export function registerRealm(runtime, traits) {
|
|
120
|
+
if (!runtime.startsWith(EXTENSION_PREFIX)) {
|
|
121
|
+
throw new Error(`realm "${runtime}" must start with "${EXTENSION_PREFIX}" — the prefix keeps a realm this ` +
|
|
122
|
+
'package might later ship from colliding with yours, and tells a reader whose realm it is.');
|
|
123
|
+
}
|
|
124
|
+
if (Object.hasOwn(REALMS, runtime)) {
|
|
125
|
+
throw new Error(`realm "${runtime}" is built in and cannot be redefined`);
|
|
126
|
+
}
|
|
127
|
+
REGISTERED.set(runtime, traits);
|
|
128
|
+
}
|
|
129
|
+
/** Every runtime this process understands: the built-ins, plus whatever a host registered. */
|
|
130
|
+
export function knownRuntimes() {
|
|
131
|
+
return [...Object.keys(REALMS), ...REGISTERED.keys()];
|
|
132
|
+
}
|
|
133
|
+
/** Forget every registered realm. For tests and for a host rebuilding its own registry. */
|
|
134
|
+
export function resetRegisteredRealms() {
|
|
135
|
+
REGISTERED.clear();
|
|
136
|
+
}
|
|
137
|
+
export function realmOf(runtime) {
|
|
138
|
+
const name = runtime ?? '';
|
|
139
|
+
if (Object.hasOwn(REALMS, name))
|
|
140
|
+
return REALMS[name];
|
|
141
|
+
return REGISTERED.get(name) ?? REALMS[AppRuntime.WEB];
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The protocol's surface for a realm.
|
|
145
|
+
*
|
|
146
|
+
* Reads `isDesktopShell` rather than testing the runtime again, which is the whole reason this
|
|
147
|
+
* table exists: a third place branching on `electron || tauri` is a third place to forget a realm,
|
|
148
|
+
* and the answer it would forget into is the web one -- the answer most likely to look plausible
|
|
149
|
+
* and be wrong.
|
|
150
|
+
*
|
|
151
|
+
* An unknown or absent runtime answers `web`, like everything else here. For a surface that IS an
|
|
152
|
+
* assumption rather than a fact: a `SubjectRef` requires one and the handshake carries no other
|
|
153
|
+
* tell, so the error is a desktop app identified as a page, which understates the subject rather
|
|
154
|
+
* than misdescribing it.
|
|
155
|
+
*/
|
|
156
|
+
export function surfaceOf(runtime) {
|
|
157
|
+
return realmOf(runtime).surface;
|
|
158
|
+
}
|
|
159
|
+
/** The protocol's identity for a connected subject. */
|
|
160
|
+
export function subjectOf(facts) {
|
|
161
|
+
const epoch = facts.currentEditEpoch;
|
|
162
|
+
return {
|
|
163
|
+
surface: surfaceOf(facts.runtime),
|
|
164
|
+
// The document id when there is one. Falling back to the session id is a WEAKER identity --
|
|
165
|
+
// it survives a navigation that should have invalidated it -- so it is used only before the
|
|
166
|
+
// first document is known, never as a substitute for one.
|
|
167
|
+
instance: facts.currentDocumentId ?? facts.id,
|
|
168
|
+
...(epoch === undefined ? {} : { epoch }),
|
|
169
|
+
locator: facts.url,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Which realm a project on disk is, judged only by its markers.
|
|
174
|
+
*
|
|
175
|
+
* A project can carry more than one marker, so precedence has to be decided rather than inherited
|
|
176
|
+
* from whatever order the table happens to be written in.
|
|
177
|
+
*
|
|
178
|
+
* A CONFIG FILE beats a DEPENDENCY. A file like `src-tauri/tauri.conf.json` exists because somebody
|
|
179
|
+
* set this project up to be that kind of app; a dependency can be transitive, vestigial, or left
|
|
180
|
+
* behind by something that was tried and abandoned. The stronger claim wins, which is also what the
|
|
181
|
+
* hand-written checks this replaces already did.
|
|
182
|
+
*
|
|
183
|
+
* Returns undefined rather than the web when nothing matches. "This is a plain web project" and "I
|
|
184
|
+
* could not tell" are the same observation here, and naming it `web` would state more than was seen.
|
|
185
|
+
*/
|
|
186
|
+
export function realmOfProject(hasFile, hasDependency) {
|
|
187
|
+
const marked = Object.entries(REALMS).filter(([, realm]) => realm.projectMarker !== undefined);
|
|
188
|
+
for (const [runtime, realm] of marked) {
|
|
189
|
+
const marker = realm.projectMarker;
|
|
190
|
+
if (marker !== undefined && 'file' in marker && hasFile(marker.file))
|
|
191
|
+
return runtime;
|
|
192
|
+
}
|
|
193
|
+
for (const [runtime, realm] of marked) {
|
|
194
|
+
const marker = realm.projectMarker;
|
|
195
|
+
if (marker !== undefined && 'dependency' in marker && hasDependency(marker.dependency)) {
|
|
196
|
+
return runtime;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Which kind of surface each known shell presents.
|
|
203
|
+
*
|
|
204
|
+
* The bridge between the two vocabularies, kept here rather than beside `PlatformProfile` so that
|
|
205
|
+
* the profile list itself depends on nothing. A connection that says which shell it is, and not
|
|
206
|
+
* which surface, still gets a surface -- which is what lets an older SDK keep working.
|
|
207
|
+
*
|
|
208
|
+
* `Record<AppRuntime, PlatformProfile>` means a new shell cannot be added without answering this.
|
|
209
|
+
*/
|
|
210
|
+
const PROFILE_OF_RUNTIME = {
|
|
211
|
+
[AppRuntime.WEB]: PlatformProfile.WEB,
|
|
212
|
+
// Both are a web page in somebody else's window. That they are one profile is the entire point.
|
|
213
|
+
[AppRuntime.ELECTRON]: PlatformProfile.WEBVIEW,
|
|
214
|
+
[AppRuntime.TAURI]: PlatformProfile.WEBVIEW,
|
|
215
|
+
};
|
|
216
|
+
/** The kind of surface a shell presents, or undefined if we have never heard of the shell. */
|
|
217
|
+
export function profileOfRuntime(runtime) {
|
|
218
|
+
if (runtime === undefined)
|
|
219
|
+
return undefined;
|
|
220
|
+
return PROFILE_OF_RUNTIME[runtime];
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* How each kind of surface may be DRIVEN.
|
|
224
|
+
*
|
|
225
|
+
* "Resume is nearly free, just re-run the prefix at 27 ms a step" is true of a browser and FALSE
|
|
226
|
+
* AND DANGEROUS on hardware, where re-driving a prefix moves a physical
|
|
227
|
+
* arm, costs real time, and may not be idempotent. The protocol already decides this from a declared
|
|
228
|
+
* profile via `resumeStrategy`; what was missing was anywhere for server code to GET a profile,
|
|
229
|
+
* because a `Realm` object is constructed only by the conformance client and the code that resumes a
|
|
230
|
+
* replay has no realm to ask.
|
|
231
|
+
*
|
|
232
|
+
* A determinism profile is a property of the KIND of subject, not of one realm instance, so it lives
|
|
233
|
+
* here beside the other facts about kinds. That is what makes the rule enforceable on the path that
|
|
234
|
+
* actually resumes, today, rather than after some future wiring.
|
|
235
|
+
*
|
|
236
|
+
* Every surface the vocabulary names is declared. A missing entry would fall through to the web
|
|
237
|
+
* answer, and the web answer is the permissive one — which is the wrong direction to be wrong in
|
|
238
|
+
* when the question is "may I silently re-send this payment".
|
|
239
|
+
*/
|
|
240
|
+
export const DETERMINISM_BY_SURFACE = {
|
|
241
|
+
[Surface.WEB]: {
|
|
242
|
+
reset: 'cheap',
|
|
243
|
+
replayPrefix: 'free',
|
|
244
|
+
time: 'injectable',
|
|
245
|
+
observation: 'exact',
|
|
246
|
+
actions: 'reversible',
|
|
247
|
+
},
|
|
248
|
+
/** A browser in a shell: the page behaves the same, the shell adds windows and menus. */
|
|
249
|
+
[Surface.DESKTOP]: {
|
|
250
|
+
reset: 'cheap',
|
|
251
|
+
replayPrefix: 'free',
|
|
252
|
+
time: 'injectable',
|
|
253
|
+
observation: 'exact',
|
|
254
|
+
actions: 'reversible',
|
|
255
|
+
},
|
|
256
|
+
/** A cold start is the reset, and it is not cheap. */
|
|
257
|
+
[Surface.MOBILE]: {
|
|
258
|
+
reset: 'costly',
|
|
259
|
+
replayPrefix: 'costly',
|
|
260
|
+
time: 'wall',
|
|
261
|
+
observation: 'exact',
|
|
262
|
+
actions: 'reversible',
|
|
263
|
+
},
|
|
264
|
+
/** A POST is not idempotent. Re-driving a prefix to reach step N re-sends everything before it. */
|
|
265
|
+
[Surface.SERVICE]: {
|
|
266
|
+
reset: 'costly',
|
|
267
|
+
replayPrefix: 'unsafe',
|
|
268
|
+
time: 'wall',
|
|
269
|
+
observation: 'exact',
|
|
270
|
+
actions: 'irreversible',
|
|
271
|
+
},
|
|
272
|
+
/** Frame-stepped and seedable, which makes a game the MOST deterministic subject here. */
|
|
273
|
+
[Surface.GAME]: {
|
|
274
|
+
reset: 'cheap',
|
|
275
|
+
replayPrefix: 'free',
|
|
276
|
+
time: 'stepped',
|
|
277
|
+
observation: 'exact',
|
|
278
|
+
actions: 'reversible',
|
|
279
|
+
},
|
|
280
|
+
/** A sensor reads a region, not a value, and an actuator cannot be un-moved. */
|
|
281
|
+
[Surface.DEVICE]: {
|
|
282
|
+
reset: 'costly',
|
|
283
|
+
replayPrefix: 'unsafe',
|
|
284
|
+
time: 'wall',
|
|
285
|
+
observation: 'sampled',
|
|
286
|
+
actions: 'irreversible',
|
|
287
|
+
},
|
|
288
|
+
};
|
|
289
|
+
/** The declared profile for a surface. */
|
|
290
|
+
export function determinismFor(surface) {
|
|
291
|
+
return DETERMINISM_BY_SURFACE[surface];
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* May a resume re-drive the steps before the one asked for?
|
|
295
|
+
*
|
|
296
|
+
* The one question the resume path has to ask before it silently repeats somebody's actions. Derived
|
|
297
|
+
* through the protocol's own `resumeStrategy` rather than by reading `replayPrefix` here, so this
|
|
298
|
+
* cannot drift from the rule the specification publishes.
|
|
299
|
+
*/
|
|
300
|
+
export function mayResumeByReplayingPrefix(surface) {
|
|
301
|
+
return ResumeStrategy.REFUSE !== resumeStrategy(determinismFor(surface));
|
|
302
|
+
}
|
|
@@ -32,19 +32,19 @@ export declare const DevServerEntrySchema: z.ZodObject<{
|
|
|
32
32
|
*/
|
|
33
33
|
projectId: z.ZodOptional<z.ZodString>;
|
|
34
34
|
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
url: string;
|
|
35
36
|
port: number;
|
|
36
37
|
pid: number;
|
|
37
38
|
startedAt: number;
|
|
38
39
|
root: string;
|
|
39
|
-
url: string;
|
|
40
40
|
projectId?: string | undefined;
|
|
41
41
|
sdkVersion?: string | undefined;
|
|
42
42
|
}, {
|
|
43
|
+
url: string;
|
|
43
44
|
port: number;
|
|
44
45
|
pid: number;
|
|
45
46
|
startedAt: number;
|
|
46
47
|
root: string;
|
|
47
|
-
url: string;
|
|
48
48
|
projectId?: string | undefined;
|
|
49
49
|
sdkVersion?: string | undefined;
|
|
50
50
|
}>;
|
|
@@ -62,11 +62,10 @@ export type DevServerEntry = z.infer<typeof DevServerEntrySchema>;
|
|
|
62
62
|
/**
|
|
63
63
|
* The live entries that belong to THIS project.
|
|
64
64
|
*
|
|
65
|
-
* Scoping is
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* and handed them app B's URL: confident, specific, and about a project they were not setting up.
|
|
65
|
+
* Scoping is the difference between a diagnosis and a wrong answer. The registry is machine-wide —
|
|
66
|
+
* one directory holds every app on the box — so unscoped, "a dev server is running" is satisfied by
|
|
67
|
+
* somebody else's app, another package in the same monorepo, or yesterday's terminal, and `init`
|
|
68
|
+
* for app A hands the user app B's URL: confident, specific, and about the wrong project.
|
|
70
69
|
*
|
|
71
70
|
* Two ways to belong, because both are true and neither covers the other:
|
|
72
71
|
*
|
|
@@ -2,20 +2,16 @@ import { z } from 'zod';
|
|
|
2
2
|
/**
|
|
3
3
|
* The dev-server discovery registry — the return leg of `daemon-registry.ts`.
|
|
4
4
|
*
|
|
5
|
-
* A live daemon
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* A live daemon drops `daemon-<port>.json` here so a build plugin can FIND it by projectId rather
|
|
6
|
+
* than being told a port in two places. This is the other leg: without it the daemon and `init`
|
|
7
|
+
* cannot know a dev server exists at all, and the commonest setup miss — a plugin added to a config
|
|
8
|
+
* the running dev server already read — is invisible from outside that process.
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* The alternative was for `init` to run the dev command itself. It cannot: the command, the script
|
|
15
|
-
* name, the package manager, the port and the framework are all things the user or their agent may
|
|
16
|
-
* change, and a setup step that hardcodes any of them is a setup step that breaks on the project it
|
|
17
|
-
* was most needed for. So nothing here starts anything or names a command. The plugin ALREADY runs
|
|
18
|
-
* Node-side when the dev server boots; it announces there, and the reader waits.
|
|
10
|
+
* Nothing here starts anything or names a command. `init` cannot run the dev command itself: the
|
|
11
|
+
* command, the script name, the package manager, the port and the framework are all things the user
|
|
12
|
+
* or their agent may change, and hardcoding any of them breaks on the project it was most needed
|
|
13
|
+
* for. The plugin ALREADY runs Node-side when the dev server boots; it announces there, and the
|
|
14
|
+
* reader waits.
|
|
19
15
|
*
|
|
20
16
|
* With both legs present the diagnosis is three-way and every branch is an observed fact:
|
|
21
17
|
*
|
|
@@ -81,11 +77,10 @@ export const DevServerEntrySchema = z.object({
|
|
|
81
77
|
/**
|
|
82
78
|
* The live entries that belong to THIS project.
|
|
83
79
|
*
|
|
84
|
-
* Scoping is
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* and handed them app B's URL: confident, specific, and about a project they were not setting up.
|
|
80
|
+
* Scoping is the difference between a diagnosis and a wrong answer. The registry is machine-wide —
|
|
81
|
+
* one directory holds every app on the box — so unscoped, "a dev server is running" is satisfied by
|
|
82
|
+
* somebody else's app, another package in the same monorepo, or yesterday's terminal, and `init`
|
|
83
|
+
* for app A hands the user app B's URL: confident, specific, and about the wrong project.
|
|
89
84
|
*
|
|
90
85
|
* Two ways to belong, because both are true and neither covers the other:
|
|
91
86
|
*
|
|
@@ -110,7 +105,21 @@ export function devServersForProject(entries, scope) {
|
|
|
110
105
|
function isWithin(path, base) {
|
|
111
106
|
if (base === undefined || 0 === base.length)
|
|
112
107
|
return false;
|
|
113
|
-
|
|
108
|
+
/*
|
|
109
|
+
* Trailing separators are trimmed with a loop rather than `/\/+$/`, which is a polynomial-ReDoS
|
|
110
|
+
* shape: on a run of slashes followed by anything else the engine retries `\/+` from every start
|
|
111
|
+
* position and rescans to the end each time, so the cost is quadratic in the length of the run.
|
|
112
|
+
* Flagged by CodeQL on this line. A registry root is not obviously hostile input, but this is
|
|
113
|
+
* `@reticlehq/core` — the package everything else depends on — and the loop is O(n), boring, and
|
|
114
|
+
* the same length as the regex it replaces.
|
|
115
|
+
*/
|
|
116
|
+
const norm = (p) => {
|
|
117
|
+
const forward = p.split('\\').join('/');
|
|
118
|
+
let end = forward.length;
|
|
119
|
+
while (end > 0 && '/' === forward[end - 1])
|
|
120
|
+
end -= 1;
|
|
121
|
+
return forward.slice(0, end);
|
|
122
|
+
};
|
|
114
123
|
const target = norm(path);
|
|
115
124
|
const parent = norm(base);
|
|
116
125
|
return target === parent || target.startsWith(`${parent}/`);
|
|
@@ -2,11 +2,11 @@ import { z } from 'zod';
|
|
|
2
2
|
/**
|
|
3
3
|
* Which directory a projectId lives in, on this machine.
|
|
4
4
|
*
|
|
5
|
-
* Config discovery answers the same question by walking out from the daemon's
|
|
6
|
-
* which
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* Config discovery answers the same question by walking out from the daemon's working directory,
|
|
6
|
+
* which works only when the daemon and the app share a tree. A daemon started in one repo, driving
|
|
7
|
+
* an app in a sibling checkout, never finds that app's `.reticle.json` however far it walks — and
|
|
8
|
+
* since an editor starts a user-scoped MCP server wherever it likes, that is the default
|
|
9
|
+
* arrangement.
|
|
10
10
|
*
|
|
11
11
|
* `init` holds both halves at the moment it runs — the directory it is initialising and the
|
|
12
12
|
* projectId it has just written into that directory's `.reticle.json`. Recording the pair once makes
|
|
@@ -2,11 +2,11 @@ import { z } from 'zod';
|
|
|
2
2
|
/**
|
|
3
3
|
* Which directory a projectId lives in, on this machine.
|
|
4
4
|
*
|
|
5
|
-
* Config discovery answers the same question by walking out from the daemon's
|
|
6
|
-
* which
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* Config discovery answers the same question by walking out from the daemon's working directory,
|
|
6
|
+
* which works only when the daemon and the app share a tree. A daemon started in one repo, driving
|
|
7
|
+
* an app in a sibling checkout, never finds that app's `.reticle.json` however far it walks — and
|
|
8
|
+
* since an editor starts a user-scoped MCP server wherever it likes, that is the default
|
|
9
|
+
* arrangement.
|
|
10
10
|
*
|
|
11
11
|
* `init` holds both halves at the moment it runs — the directory it is initialising and the
|
|
12
12
|
* projectId it has just written into that directory's `.reticle.json`. Recording the pair once makes
|