@reticlehq/core 2.13.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/artifacts/artifacts-entry.d.ts +20 -0
- package/dist/artifacts/artifacts-entry.js +20 -0
- 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} +97 -3
- package/dist/{flow-constants.js → artifacts/flow-constants.js} +103 -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-savings.d.ts → artifacts/impact-savings.d.ts} +7 -3
- package/dist/{impact-savings.js → artifacts/impact-savings.js} +27 -4
- package/dist/{impact.d.ts → artifacts/impact.d.ts} +122 -54
- package/dist/{impact.js → artifacts/impact.js} +30 -0
- package/dist/{journal.d.ts → artifacts/journal.d.ts} +50 -6
- package/dist/{journal.js → artifacts/journal.js} +38 -2
- 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/{brand.d.ts → identity/brand.d.ts} +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 +69 -42
- package/dist/index.js +78 -44
- 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} +4 -5
- 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-message.json +1 -0
- package/dist/schema/event-payloads.json +791 -0
- package/dist/schema/event-type.json +1 -0
- package/dist/schema/hello-message.json +76 -2
- package/dist/schema/reticle-event.json +1 -0
- package/dist/schema/reticle-message.json +77 -2
- package/dist/telemetry-entry.d.ts +15 -0
- package/dist/telemetry-entry.js +15 -0
- package/dist/telemetry-feedback.d.ts +13 -14
- 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 +49 -57
- package/dist/telemetry-session.js +47 -55
- package/dist/telemetry.d.ts +229 -198
- package/dist/telemetry.js +83 -98
- 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} +35 -11
- package/dist/{consequence.js → verdict/consequence.js} +9 -22
- package/dist/{finding-fingerprint.js → verdict/finding-fingerprint.js} +1 -1
- package/dist/{findings.d.ts → verdict/findings.d.ts} +149 -41
- package/dist/{findings.js → verdict/findings.js} +169 -48
- package/dist/{instrumentation-gap.d.ts → verdict/instrumentation-gap.d.ts} +22 -14
- package/dist/{instrumentation-gap.js → verdict/instrumentation-gap.js} +23 -15
- package/dist/{intent.d.ts → verdict/intent.d.ts} +41 -52
- 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} +369 -93
- package/dist/{verification-run.js → verdict/verification-run.js} +157 -21
- package/dist/{verified-constants.d.ts → verdict/verified-constants.d.ts} +36 -13
- package/dist/{verified-constants.js → verdict/verified-constants.js} +36 -13
- package/dist/verdict/verify-progress.d.ts +129 -0
- package/dist/verdict/verify-progress.js +74 -0
- 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} +124 -28
- package/dist/{constants.js → wire/constants/constants.js} +137 -28
- package/dist/{session-constants.d.ts → wire/constants/session-constants.d.ts} +9 -2
- package/dist/{session-constants.js → wire/constants/session-constants.js} +9 -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} +229 -17
- package/dist/{event-payloads.js → wire/event-payloads.js} +61 -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/wire/global-press.d.ts +30 -0
- package/dist/wire/global-press.js +54 -0
- package/dist/{messages.d.ts → wire/messages.d.ts} +290 -38
- package/dist/{messages.js → wire/messages.js} +93 -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} +49 -10
- package/dist/{net.js → wire/net.js} +49 -10
- package/dist/wire/platform.d.ts +37 -0
- package/dist/wire/platform.js +36 -0
- package/dist/{redaction.d.ts → wire/redaction.d.ts} +30 -0
- package/dist/wire/redaction.js +274 -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} +106 -66
- package/dist/{types.js → wire/types.js} +24 -4
- 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} +24 -12
- package/dist/{notices.js → words/notices.js} +27 -12
- package/package.json +22 -5
- package/dist/flow-types.d.ts +0 -1473
- package/dist/flow-types.js +0 -195
- package/dist/redaction.js +0 -149
- /package/dist/{brand.js → identity/brand.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/{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} +0 -0
- /package/dist/{upgrade.js → words/upgrade.js} +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@reticlehq/core/artifacts` — the on-disk and registry formats.
|
|
3
|
+
*
|
|
4
|
+
* Nothing here crosses the browser↔bridge wire. These are files the CLI, the bridge and the vite
|
|
5
|
+
* plugin read and write on the developer's machine: the `.reticle/` journal, the intent ledger, the
|
|
6
|
+
* run context, the daemon/dev-server/project registries, the self-update policy, and the
|
|
7
|
+
* instrumentation gaps the server reports back.
|
|
8
|
+
*
|
|
9
|
+
* Every name below is ALSO exported from the root entry point, which stays as it was — this path
|
|
10
|
+
* exists so a Node-side importer can say which half of core it depends on, and so
|
|
11
|
+
* `core-boundary.test.ts` in @reticlehq/browser can fail when the DOM side reaches for one of them.
|
|
12
|
+
*/
|
|
13
|
+
export * from '../registry/daemon-registry.js';
|
|
14
|
+
export * from '../registry/dev-server-registry.js';
|
|
15
|
+
export * from '../registry/project-registry.js';
|
|
16
|
+
export * from '../verdict/intent.js';
|
|
17
|
+
export * from '../verdict/run-context.js';
|
|
18
|
+
export * from '../verdict/instrumentation-gap.js';
|
|
19
|
+
export * from '../words/upgrade.js';
|
|
20
|
+
export * from './journal.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@reticlehq/core/artifacts` — the on-disk and registry formats.
|
|
3
|
+
*
|
|
4
|
+
* Nothing here crosses the browser↔bridge wire. These are files the CLI, the bridge and the vite
|
|
5
|
+
* plugin read and write on the developer's machine: the `.reticle/` journal, the intent ledger, the
|
|
6
|
+
* run context, the daemon/dev-server/project registries, the self-update policy, and the
|
|
7
|
+
* instrumentation gaps the server reports back.
|
|
8
|
+
*
|
|
9
|
+
* Every name below is ALSO exported from the root entry point, which stays as it was — this path
|
|
10
|
+
* exists so a Node-side importer can say which half of core it depends on, and so
|
|
11
|
+
* `core-boundary.test.ts` in @reticlehq/browser can fail when the DOM side reaches for one of them.
|
|
12
|
+
*/
|
|
13
|
+
export * from '../registry/daemon-registry.js';
|
|
14
|
+
export * from '../registry/dev-server-registry.js';
|
|
15
|
+
export * from '../registry/project-registry.js';
|
|
16
|
+
export * from '../verdict/intent.js';
|
|
17
|
+
export * from '../verdict/run-context.js';
|
|
18
|
+
export * from '../verdict/instrumentation-gap.js';
|
|
19
|
+
export * from '../words/upgrade.js';
|
|
20
|
+
export * from './journal.js';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { FlowExpect, FlowFile } from './flow-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Whether one flow may be replayed straight after another.
|
|
4
|
+
*
|
|
5
|
+
* Replaying journeys back to back only works when the state one leaves is the state the next
|
|
6
|
+
* expects. Two flows that each pass alone can fail composed, and the reverse, and the red looks
|
|
7
|
+
* like a regression — the most expensive kind, because it sends somebody to read product code that
|
|
8
|
+
* is fine.
|
|
9
|
+
*
|
|
10
|
+
* It answers over DECLARATIONS, not over a running app: a pure comparison of what B says it needs
|
|
11
|
+
* against what A says it leaves, so it can be asked before either flow runs.
|
|
12
|
+
*
|
|
13
|
+
* SILENCE IS PERMISSIVE. A flow that declares neither `requires` nor `ensures` says nothing, and
|
|
14
|
+
* unknown means unchecked rather than unsafe; `unmet` names the claims that could not be
|
|
15
|
+
* discharged, so the answer is never a bare boolean.
|
|
16
|
+
*
|
|
17
|
+
* NOT ENFORCED AT REPLAY TIME. An unmet precondition reported as a step result would read as a
|
|
18
|
+
* FAILURE — `FlowStepResult` has `ok: boolean` and no third state — and honestly it is `unknown`:
|
|
19
|
+
* nothing ran, so nothing was proved.
|
|
20
|
+
*/
|
|
21
|
+
export interface CompositionCheck {
|
|
22
|
+
/** True when nothing B requires is left undischarged by A. Vacuously true when either is silent. */
|
|
23
|
+
readonly ok: boolean;
|
|
24
|
+
/** The claims B requires that A does not ensure. Empty when `ok`. */
|
|
25
|
+
readonly unmet: readonly FlowExpect[];
|
|
26
|
+
/** True when neither flow declared anything, so the answer is "unchecked" rather than "safe". */
|
|
27
|
+
readonly unchecked: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** Can `next` be replayed immediately after `previous`? */
|
|
30
|
+
export declare function canFollow(previous: FlowFile, next: FlowFile): CompositionCheck;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compared by VALUE, because a precondition is a claim and two claims are the same claim when they
|
|
3
|
+
* say the same thing. Deep equality over a small JSON-shaped object, which is what these are: no
|
|
4
|
+
* functions, no cycles, no class instances. A structural compare here would need a schema-aware
|
|
5
|
+
* walk to be any better and would be wrong in ways that are hard to see.
|
|
6
|
+
*/
|
|
7
|
+
function sameClaim(a, b) {
|
|
8
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
9
|
+
}
|
|
10
|
+
/** Can `next` be replayed immediately after `previous`? */
|
|
11
|
+
export function canFollow(previous, next) {
|
|
12
|
+
const required = next.requires ?? [];
|
|
13
|
+
const ensured = previous.ensures ?? [];
|
|
14
|
+
if (0 === required.length) {
|
|
15
|
+
return { ok: true, unmet: [], unchecked: 0 === ensured.length };
|
|
16
|
+
}
|
|
17
|
+
const unmet = required.filter((claim) => !ensured.some((have) => sameClaim(have, claim)));
|
|
18
|
+
return { ok: 0 === unmet.length, unmet, unchecked: false };
|
|
19
|
+
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* On-disk artifact constants: the project history, flow files, replay/drift status, the recorder
|
|
3
|
-
* lifecycle, heal outcomes, and the structured-annotation vocabulary.
|
|
4
|
-
* each file stays one cohesive unit under the size cap; re-exported from constants.ts (and so from
|
|
5
|
-
* the package index) — every existing `@reticlehq/core` import is unchanged.
|
|
3
|
+
* lifecycle, heal outcomes, and the structured-annotation vocabulary.
|
|
6
4
|
*/
|
|
7
5
|
/**
|
|
8
6
|
* Schema version stamped into project.json so a reader can reject/upgrade old files.
|
|
@@ -16,6 +14,14 @@ export declare const PROJECT_FILE_VERSION = 1;
|
|
|
16
14
|
export declare const ProjectReadError: {
|
|
17
15
|
readonly MISSING: "project-missing";
|
|
18
16
|
readonly MALFORMED: "project-malformed";
|
|
17
|
+
/**
|
|
18
|
+
* Readable, and written by a version of Reticle this one does not know.
|
|
19
|
+
*
|
|
20
|
+
* Kept apart from MALFORMED because the two need opposite handling. A malformed file has nothing
|
|
21
|
+
* left to lose, so recording a run repairs it. A file from another version is intact, and
|
|
22
|
+
* repairing it would overwrite history a later release could still read.
|
|
23
|
+
*/
|
|
24
|
+
readonly WRONG_VERSION: "project-wrong-version";
|
|
19
25
|
};
|
|
20
26
|
export type ProjectReadError = (typeof ProjectReadError)[keyof typeof ProjectReadError];
|
|
21
27
|
/** How a run record was produced. */
|
|
@@ -72,6 +78,31 @@ export declare const FlowErrorCode: {
|
|
|
72
78
|
};
|
|
73
79
|
export type FlowErrorCode = (typeof FlowErrorCode)[keyof typeof FlowErrorCode];
|
|
74
80
|
/** A flow name must be a single safe path segment (no '/', '\\', '..', leading dot). */
|
|
81
|
+
/**
|
|
82
|
+
* ONE safe path segment: the guard for anything that becomes a single directory or file name.
|
|
83
|
+
*
|
|
84
|
+
* Session ids and run ids are this. They are joined into `.reticle/sessions/<id>/` and written to,
|
|
85
|
+
* and a session LABEL is supplied by the tab — so a separator here is a tab choosing where on disk
|
|
86
|
+
* Reticle writes. Flow names were this too until they became namespaced, and the two guards shared
|
|
87
|
+
* one pattern; widening the flow pattern silently widened these, which a test caught immediately.
|
|
88
|
+
* They answer different questions and now have different patterns: a flow name may be a path, a
|
|
89
|
+
* session id may never be one.
|
|
90
|
+
*/
|
|
91
|
+
export declare const SAFE_SEGMENT_PATTERN: RegExp;
|
|
92
|
+
/**
|
|
93
|
+
* A flow name: one or more `/`-separated segments.
|
|
94
|
+
*
|
|
95
|
+
* Namespaced because the replay grammar addresses documents by path — `onboarding/signup` is how a
|
|
96
|
+
* composite names the sub-journey it invokes, and the protocol's `FlowNameSchema` has said so since
|
|
97
|
+
* grammar v2. This pattern is the PERSISTENCE half, and while it stayed single-segment
|
|
98
|
+
* `reticle_flow_save` refused every name the language is built on. Found by driving a composite:
|
|
99
|
+
* recording worked, closing the boundary worked, saving it was refused.
|
|
100
|
+
*
|
|
101
|
+
* Traversal is impossible by CONSTRUCTION rather than by a filter. No segment may contain a dot at
|
|
102
|
+
* all, so `..` cannot be spelled; every segment must START with a letter or digit, so a leading,
|
|
103
|
+
* trailing or doubled separator cannot either. That is stronger than checking for `..`, because
|
|
104
|
+
* there is no encoding of it left to miss.
|
|
105
|
+
*/
|
|
75
106
|
export declare const FLOW_NAME_PATTERN: RegExp;
|
|
76
107
|
/**
|
|
77
108
|
* The outcome of replaying an on-disk flow by re-resolving its
|
|
@@ -100,8 +131,30 @@ export declare const DriftReason: {
|
|
|
100
131
|
* hunting for the nearest testid to the literal word "unresolved".
|
|
101
132
|
*/
|
|
102
133
|
readonly ANCHOR_DEGRADED: "anchor_degraded";
|
|
134
|
+
/**
|
|
135
|
+
* The step's anchor resolved and its action ran; the testid its `expect.element` names was absent
|
|
136
|
+
* afterwards. Distinct from TESTID_NOT_FOUND for the same reason ANCHOR_DEGRADED is: "the element
|
|
137
|
+
* you clicked is gone" and "the thing you asserted afterwards never appeared" need different
|
|
138
|
+
* fixes, and reporting the second as the first sends the caller looking for a renamed anchor on a
|
|
139
|
+
* step whose anchor was fine.
|
|
140
|
+
*/
|
|
141
|
+
readonly EXPECT_ELEMENT_NOT_FOUND: "expect_element_not_found";
|
|
103
142
|
};
|
|
104
143
|
export type DriftReason = (typeof DriftReason)[keyof typeof DriftReason];
|
|
144
|
+
/**
|
|
145
|
+
* Did the step's anchor resolve and its action RUN, leaving only the declared consequence unmet?
|
|
146
|
+
*
|
|
147
|
+
* The three reasons below all mean the same thing about the app's state: the element was found, the
|
|
148
|
+
* action was dispatched, and the page is where the step left it. Only the assertion failed. The
|
|
149
|
+
* other reasons mean the anchor itself was never resolved, so the page is somewhere the flow never
|
|
150
|
+
* described and every later step would run against a state nobody predicted.
|
|
151
|
+
*
|
|
152
|
+
* That difference is what lets a replay CONTINUE past a failure without turning one wrong result
|
|
153
|
+
* into several — see the sweep option on replayFlow. Halting on both was correct while there was no
|
|
154
|
+
* way to tell them apart; it stopped a 6-step bug sweep at its first defect and reported the other
|
|
155
|
+
* five as `notAttempted`.
|
|
156
|
+
*/
|
|
157
|
+
export declare function isConsequenceDrift(reason: DriftReason): boolean;
|
|
105
158
|
/** Default timeout (ms) a signal anchor waits to be observed at replay. */
|
|
106
159
|
export declare const FLOW_SIGNAL_TIMEOUT_MS = 4000;
|
|
107
160
|
/**
|
|
@@ -141,12 +194,32 @@ export type RecordedSaveError = (typeof RecordedSaveError)[keyof typeof Recorded
|
|
|
141
194
|
* Rebinds testid anchors only (role/name/signal re-anchoring is future). A confident nearest-match
|
|
142
195
|
* is required before any disk write — the "never silently rewrite" invariant.
|
|
143
196
|
*/
|
|
197
|
+
/**
|
|
198
|
+
* Whether a suite should run this flow at all.
|
|
199
|
+
*
|
|
200
|
+
* Absent means `active` — every flow already on disk stays exactly as it was.
|
|
201
|
+
*
|
|
202
|
+
* `quarantined` exists because a permanently failing flow is worse than no flow: measured on this
|
|
203
|
+
* repo's own ledger, one flow has failed 366 of 366 runs and is still replayed on every suite. That
|
|
204
|
+
* is not a regression signal, it is noise, and noise is what teaches people to stop reading the
|
|
205
|
+
* suite. Quarantine takes it out of the verdict while keeping it VISIBLE and owned -- a silent skip
|
|
206
|
+
* would just be the same problem with the evidence removed.
|
|
207
|
+
*
|
|
208
|
+
* `draft` is for a flow being authored: saved, not yet part of anybody's verdict.
|
|
209
|
+
*/
|
|
210
|
+
export declare const FlowStatus: {
|
|
211
|
+
readonly ACTIVE: "active";
|
|
212
|
+
readonly QUARANTINED: "quarantined";
|
|
213
|
+
readonly DRAFT: "draft";
|
|
214
|
+
};
|
|
215
|
+
export type FlowStatus = (typeof FlowStatus)[keyof typeof FlowStatus];
|
|
144
216
|
export declare const HealStatus: {
|
|
145
217
|
readonly HEALED: "healed";
|
|
146
218
|
readonly DRIFT: "drift";
|
|
147
219
|
readonly UNHEALABLE: "unhealable";
|
|
148
220
|
readonly NOTHING_TO_HEAL: "nothing_to_heal";
|
|
149
221
|
readonly CONSEQUENCE_BROKEN: "consequence_broken";
|
|
222
|
+
readonly UNFALSIFIABLE: "unfalsifiable";
|
|
150
223
|
readonly ERROR: "error";
|
|
151
224
|
};
|
|
152
225
|
export type HealStatus = (typeof HealStatus)[keyof typeof HealStatus];
|
|
@@ -182,3 +255,24 @@ export declare const AnnotationErrorCode: {
|
|
|
182
255
|
export type AnnotationErrorCode = (typeof AnnotationErrorCode)[keyof typeof AnnotationErrorCode];
|
|
183
256
|
/** Leading word of the compiled-predicate confirmation ("will assert …"). */
|
|
184
257
|
export declare const COMPILED_PREDICATE_PREFIX = "will";
|
|
258
|
+
/**
|
|
259
|
+
* How a suite kept its flows apart from each other.
|
|
260
|
+
*
|
|
261
|
+
* Sequential replay runs every flow in ONE live session, so each starts wherever the last one left
|
|
262
|
+
* the app. MEASURED on the bench app: four flows that click a nav item behind a sign-in, and never
|
|
263
|
+
* sign in, pass sequentially because an earlier flow signed in — and fail under per-flow leases,
|
|
264
|
+
* which is the correct answer. The same corpus reported 13/34 and 11/34 with nothing changed but
|
|
265
|
+
* this, and both numbers were reproducible.
|
|
266
|
+
*
|
|
267
|
+
* Resetting between sequential flows was tried and reverted (see flow-tools.ts): storageState
|
|
268
|
+
* restores cookies and localStorage but not sessionStorage, which leaves an app holding two thirds
|
|
269
|
+
* of an auth session. So the modes genuinely differ, and the verdict names which one it is rather
|
|
270
|
+
* than letting two incomparable numbers look like a regression.
|
|
271
|
+
*/
|
|
272
|
+
export declare const SuiteIsolation: {
|
|
273
|
+
/** Every flow replayed in the agent's live session, in order. State carries between them. */
|
|
274
|
+
readonly SHARED_SESSION: "shared-session";
|
|
275
|
+
/** Every flow got its own leased context, seeded once. Flows cannot affect each other. */
|
|
276
|
+
readonly PER_FLOW_LEASE: "per-flow-lease";
|
|
277
|
+
};
|
|
278
|
+
export type SuiteIsolation = (typeof SuiteIsolation)[keyof typeof SuiteIsolation];
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* On-disk artifact constants: the project history, flow files, replay/drift status, the recorder
|
|
3
|
-
* lifecycle, heal outcomes, and the structured-annotation vocabulary.
|
|
4
|
-
* each file stays one cohesive unit under the size cap; re-exported from constants.ts (and so from
|
|
5
|
-
* the package index) — every existing `@reticlehq/core` import is unchanged.
|
|
3
|
+
* lifecycle, heal outcomes, and the structured-annotation vocabulary.
|
|
6
4
|
*/
|
|
7
5
|
/**
|
|
8
6
|
* Schema version stamped into project.json so a reader can reject/upgrade old files.
|
|
@@ -16,6 +14,14 @@ export const PROJECT_FILE_VERSION = 1;
|
|
|
16
14
|
export const ProjectReadError = {
|
|
17
15
|
MISSING: 'project-missing', // no .reticle/project.json on disk
|
|
18
16
|
MALFORMED: 'project-malformed', // present but not valid JSON / fails schema
|
|
17
|
+
/**
|
|
18
|
+
* Readable, and written by a version of Reticle this one does not know.
|
|
19
|
+
*
|
|
20
|
+
* Kept apart from MALFORMED because the two need opposite handling. A malformed file has nothing
|
|
21
|
+
* left to lose, so recording a run repairs it. A file from another version is intact, and
|
|
22
|
+
* repairing it would overwrite history a later release could still read.
|
|
23
|
+
*/
|
|
24
|
+
WRONG_VERSION: 'project-wrong-version',
|
|
19
25
|
};
|
|
20
26
|
/** How a run record was produced. */
|
|
21
27
|
export const RunKind = {
|
|
@@ -67,7 +73,32 @@ export const FlowErrorCode = {
|
|
|
67
73
|
NO_RECORDING: 'flow_no_recording', // save with no compiled program by that name
|
|
68
74
|
};
|
|
69
75
|
/** A flow name must be a single safe path segment (no '/', '\\', '..', leading dot). */
|
|
70
|
-
|
|
76
|
+
/**
|
|
77
|
+
* ONE safe path segment: the guard for anything that becomes a single directory or file name.
|
|
78
|
+
*
|
|
79
|
+
* Session ids and run ids are this. They are joined into `.reticle/sessions/<id>/` and written to,
|
|
80
|
+
* and a session LABEL is supplied by the tab — so a separator here is a tab choosing where on disk
|
|
81
|
+
* Reticle writes. Flow names were this too until they became namespaced, and the two guards shared
|
|
82
|
+
* one pattern; widening the flow pattern silently widened these, which a test caught immediately.
|
|
83
|
+
* They answer different questions and now have different patterns: a flow name may be a path, a
|
|
84
|
+
* session id may never be one.
|
|
85
|
+
*/
|
|
86
|
+
export const SAFE_SEGMENT_PATTERN = /^[a-z0-9][a-z0-9-_]{0,63}$/i;
|
|
87
|
+
/**
|
|
88
|
+
* A flow name: one or more `/`-separated segments.
|
|
89
|
+
*
|
|
90
|
+
* Namespaced because the replay grammar addresses documents by path — `onboarding/signup` is how a
|
|
91
|
+
* composite names the sub-journey it invokes, and the protocol's `FlowNameSchema` has said so since
|
|
92
|
+
* grammar v2. This pattern is the PERSISTENCE half, and while it stayed single-segment
|
|
93
|
+
* `reticle_flow_save` refused every name the language is built on. Found by driving a composite:
|
|
94
|
+
* recording worked, closing the boundary worked, saving it was refused.
|
|
95
|
+
*
|
|
96
|
+
* Traversal is impossible by CONSTRUCTION rather than by a filter. No segment may contain a dot at
|
|
97
|
+
* all, so `..` cannot be spelled; every segment must START with a letter or digit, so a leading,
|
|
98
|
+
* trailing or doubled separator cannot either. That is stronger than checking for `..`, because
|
|
99
|
+
* there is no encoding of it left to miss.
|
|
100
|
+
*/
|
|
101
|
+
export const FLOW_NAME_PATTERN = /^[a-z0-9][a-z0-9-_]{0,63}(?:\/[a-z0-9][a-z0-9-_]{0,63})*$/i;
|
|
71
102
|
/**
|
|
72
103
|
* The outcome of replaying an on-disk flow by re-resolving its
|
|
73
104
|
* semantic anchors against the live DOM. `drift` (an anchor missed → contract changed) is
|
|
@@ -94,7 +125,33 @@ export const DriftReason = {
|
|
|
94
125
|
* hunting for the nearest testid to the literal word "unresolved".
|
|
95
126
|
*/
|
|
96
127
|
ANCHOR_DEGRADED: 'anchor_degraded',
|
|
128
|
+
/**
|
|
129
|
+
* The step's anchor resolved and its action ran; the testid its `expect.element` names was absent
|
|
130
|
+
* afterwards. Distinct from TESTID_NOT_FOUND for the same reason ANCHOR_DEGRADED is: "the element
|
|
131
|
+
* you clicked is gone" and "the thing you asserted afterwards never appeared" need different
|
|
132
|
+
* fixes, and reporting the second as the first sends the caller looking for a renamed anchor on a
|
|
133
|
+
* step whose anchor was fine.
|
|
134
|
+
*/
|
|
135
|
+
EXPECT_ELEMENT_NOT_FOUND: 'expect_element_not_found',
|
|
97
136
|
};
|
|
137
|
+
/**
|
|
138
|
+
* Did the step's anchor resolve and its action RUN, leaving only the declared consequence unmet?
|
|
139
|
+
*
|
|
140
|
+
* The three reasons below all mean the same thing about the app's state: the element was found, the
|
|
141
|
+
* action was dispatched, and the page is where the step left it. Only the assertion failed. The
|
|
142
|
+
* other reasons mean the anchor itself was never resolved, so the page is somewhere the flow never
|
|
143
|
+
* described and every later step would run against a state nobody predicted.
|
|
144
|
+
*
|
|
145
|
+
* That difference is what lets a replay CONTINUE past a failure without turning one wrong result
|
|
146
|
+
* into several — see the sweep option on replayFlow. Halting on both was correct while there was no
|
|
147
|
+
* way to tell them apart; it stopped a 6-step bug sweep at its first defect and reported the other
|
|
148
|
+
* five as `notAttempted`.
|
|
149
|
+
*/
|
|
150
|
+
export function isConsequenceDrift(reason) {
|
|
151
|
+
return (DriftReason.SIGNAL_NOT_OBSERVED === reason ||
|
|
152
|
+
DriftReason.STATE_MISMATCH === reason ||
|
|
153
|
+
DriftReason.EXPECT_ELEMENT_NOT_FOUND === reason);
|
|
154
|
+
}
|
|
98
155
|
/** Default timeout (ms) a signal anchor waits to be observed at replay. */
|
|
99
156
|
export const FLOW_SIGNAL_TIMEOUT_MS = 4000;
|
|
100
157
|
/**
|
|
@@ -135,12 +192,34 @@ export const RecordedSaveError = {
|
|
|
135
192
|
* Rebinds testid anchors only (role/name/signal re-anchoring is future). A confident nearest-match
|
|
136
193
|
* is required before any disk write — the "never silently rewrite" invariant.
|
|
137
194
|
*/
|
|
195
|
+
/**
|
|
196
|
+
* Whether a suite should run this flow at all.
|
|
197
|
+
*
|
|
198
|
+
* Absent means `active` — every flow already on disk stays exactly as it was.
|
|
199
|
+
*
|
|
200
|
+
* `quarantined` exists because a permanently failing flow is worse than no flow: measured on this
|
|
201
|
+
* repo's own ledger, one flow has failed 366 of 366 runs and is still replayed on every suite. That
|
|
202
|
+
* is not a regression signal, it is noise, and noise is what teaches people to stop reading the
|
|
203
|
+
* suite. Quarantine takes it out of the verdict while keeping it VISIBLE and owned -- a silent skip
|
|
204
|
+
* would just be the same problem with the evidence removed.
|
|
205
|
+
*
|
|
206
|
+
* `draft` is for a flow being authored: saved, not yet part of anybody's verdict.
|
|
207
|
+
*/
|
|
208
|
+
export const FlowStatus = {
|
|
209
|
+
ACTIVE: 'active',
|
|
210
|
+
QUARANTINED: 'quarantined',
|
|
211
|
+
DRAFT: 'draft',
|
|
212
|
+
};
|
|
138
213
|
export const HealStatus = {
|
|
139
214
|
HEALED: 'healed', // apply:true and >=1 anchor rewritten on disk
|
|
140
215
|
DRIFT: 'drift', // apply:false: confident proposal(s) returned, file untouched
|
|
141
216
|
UNHEALABLE: 'unhealable', // drift exists but no proposal cleared the confidence floor
|
|
142
217
|
NOTHING_TO_HEAL: 'nothing_to_heal', // replay was green
|
|
143
218
|
CONSEQUENCE_BROKEN: 'consequence_broken', // rebind resolves a locator but the flow's success consequence no longer fires — REFUSED (file untouched)
|
|
219
|
+
// the flow asserts nothing a wrong rebind could fail — REFUSED before replaying (file untouched).
|
|
220
|
+
// Distinct from CONSEQUENCE_BROKEN: there the consequence exists and stopped firing; here there is
|
|
221
|
+
// no consequence at all, so a heal could never be checked and would pass forever.
|
|
222
|
+
UNFALSIFIABLE: 'unfalsifiable',
|
|
144
223
|
ERROR: 'error', // flow missing/malformed/invalid-name, or a resolved action failed
|
|
145
224
|
};
|
|
146
225
|
/**
|
|
@@ -173,3 +252,23 @@ export const AnnotationErrorCode = {
|
|
|
173
252
|
};
|
|
174
253
|
/** Leading word of the compiled-predicate confirmation ("will assert …"). */
|
|
175
254
|
export const COMPILED_PREDICATE_PREFIX = 'will';
|
|
255
|
+
/**
|
|
256
|
+
* How a suite kept its flows apart from each other.
|
|
257
|
+
*
|
|
258
|
+
* Sequential replay runs every flow in ONE live session, so each starts wherever the last one left
|
|
259
|
+
* the app. MEASURED on the bench app: four flows that click a nav item behind a sign-in, and never
|
|
260
|
+
* sign in, pass sequentially because an earlier flow signed in — and fail under per-flow leases,
|
|
261
|
+
* which is the correct answer. The same corpus reported 13/34 and 11/34 with nothing changed but
|
|
262
|
+
* this, and both numbers were reproducible.
|
|
263
|
+
*
|
|
264
|
+
* Resetting between sequential flows was tried and reverted (see flow-tools.ts): storageState
|
|
265
|
+
* restores cookies and localStorage but not sessionStorage, which leaves an app holding two thirds
|
|
266
|
+
* of an auth session. So the modes genuinely differ, and the verdict names which one it is rather
|
|
267
|
+
* than letting two incomparable numbers look like a regression.
|
|
268
|
+
*/
|
|
269
|
+
export const SuiteIsolation = {
|
|
270
|
+
/** Every flow replayed in the agent's live session, in order. State carries between them. */
|
|
271
|
+
SHARED_SESSION: 'shared-session',
|
|
272
|
+
/** Every flow got its own leased context, seeded once. Flows cannot affect each other. */
|
|
273
|
+
PER_FLOW_LEASE: 'per-flow-lease',
|
|
274
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a flow DECLARED it depends on, and the two things worth doing with that.
|
|
3
|
+
*
|
|
4
|
+
* Both live here because both answer the same question first — which endpoints did this flow name
|
|
5
|
+
* in its own words, at record time — and then diverge only in what they do next: break one
|
|
6
|
+
* (mutation), or slow them all by different amounts (perturbation). Splitting them would let two
|
|
7
|
+
* files drift about what "declared" means, which is the one thing neither can afford.
|
|
8
|
+
*
|
|
9
|
+
* This is the decision that makes a mutation score mean anything, and the single place it can
|
|
10
|
+
* quietly stop meaning anything. Break an endpoint the flow never touches and the flow survives —
|
|
11
|
+
* which reads as *"this test is worthless"* and is really *"we broke the wrong thing"*. A mutation
|
|
12
|
+
* set that aims badly reports a suite full of bad tests and is itself the bug.
|
|
13
|
+
*
|
|
14
|
+
* A flow that declared a network consequence has already said what it depends on, in its own words,
|
|
15
|
+
* at record time. That declaration is the target: break exactly what the flow claims to need, and a
|
|
16
|
+
* flow that still passes has genuinely proved nothing about it.
|
|
17
|
+
*
|
|
18
|
+
* A flow that declared none yields NOTHING, and that is a finding rather than a gap to paper over.
|
|
19
|
+
* Guessing a target would manufacture the demotion instead of measuring it.
|
|
20
|
+
*/
|
|
21
|
+
import type { FlowFile } from './flow-types.js';
|
|
22
|
+
/** Every endpoint this flow's own declarations name, in order, once each. */
|
|
23
|
+
export declare function mutationTargetsFor(flow: FlowFile): string[];
|
|
24
|
+
/** The shape a network mock needs from us: which endpoint, and how much later. Nothing else. */
|
|
25
|
+
export interface Perturbation {
|
|
26
|
+
urlContains: string;
|
|
27
|
+
delayMs: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Which endpoints to slow, and by how much, for this seed.
|
|
31
|
+
*
|
|
32
|
+
* Every endpoint the flow DECLARED it depends on gets its own delay, drawn independently, so the
|
|
33
|
+
* spread is what reorders them. One uniform delay would slow everything equally and race nothing —
|
|
34
|
+
* the app would see the same order it always sees, just later.
|
|
35
|
+
*
|
|
36
|
+
* `targets` comes from what the flow itself declared (`mutationTargetsFor`), so chaos is applied to
|
|
37
|
+
* the endpoints the flow claims to care about rather than to traffic it never mentioned.
|
|
38
|
+
*/
|
|
39
|
+
export declare function perturbationFor(seed: number, targets: readonly string[]): Perturbation[];
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a flow DECLARED it depends on, and the two things worth doing with that.
|
|
3
|
+
*
|
|
4
|
+
* Both live here because both answer the same question first — which endpoints did this flow name
|
|
5
|
+
* in its own words, at record time — and then diverge only in what they do next: break one
|
|
6
|
+
* (mutation), or slow them all by different amounts (perturbation). Splitting them would let two
|
|
7
|
+
* files drift about what "declared" means, which is the one thing neither can afford.
|
|
8
|
+
*
|
|
9
|
+
* This is the decision that makes a mutation score mean anything, and the single place it can
|
|
10
|
+
* quietly stop meaning anything. Break an endpoint the flow never touches and the flow survives —
|
|
11
|
+
* which reads as *"this test is worthless"* and is really *"we broke the wrong thing"*. A mutation
|
|
12
|
+
* set that aims badly reports a suite full of bad tests and is itself the bug.
|
|
13
|
+
*
|
|
14
|
+
* A flow that declared a network consequence has already said what it depends on, in its own words,
|
|
15
|
+
* at record time. That declaration is the target: break exactly what the flow claims to need, and a
|
|
16
|
+
* flow that still passes has genuinely proved nothing about it.
|
|
17
|
+
*
|
|
18
|
+
* A flow that declared none yields NOTHING, and that is a finding rather than a gap to paper over.
|
|
19
|
+
* Guessing a target would manufacture the demotion instead of measuring it.
|
|
20
|
+
*/
|
|
21
|
+
/** Every endpoint this flow's own declarations name, in order, once each. */
|
|
22
|
+
export function mutationTargetsFor(flow) {
|
|
23
|
+
const targets = [];
|
|
24
|
+
const add = (url) => {
|
|
25
|
+
if (url === undefined || '' === url)
|
|
26
|
+
return;
|
|
27
|
+
if (!targets.includes(url))
|
|
28
|
+
targets.push(url);
|
|
29
|
+
};
|
|
30
|
+
const walk = (steps) => {
|
|
31
|
+
for (const step of steps) {
|
|
32
|
+
add(step.expect?.net?.urlContains);
|
|
33
|
+
// A sequence is where the real journeys live, so its children are where the real dependencies
|
|
34
|
+
// are declared. A walk that stopped at the top level would find nothing in the common case.
|
|
35
|
+
if (step.steps !== undefined)
|
|
36
|
+
walk(step.steps);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
walk(flow.steps);
|
|
40
|
+
add(flow.success?.net?.urlContains);
|
|
41
|
+
return targets;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The widest delay injected, in ms.
|
|
45
|
+
*
|
|
46
|
+
* Big enough that a later request can beat an earlier one home — that is the whole mechanism — and
|
|
47
|
+
* small enough to stay under an ordinary settle budget, so a perturbed replay still finishes rather
|
|
48
|
+
* than timing out and reporting a stall it caused itself.
|
|
49
|
+
*/
|
|
50
|
+
const MAX_DELAY_MS = 400;
|
|
51
|
+
/** The narrowest non-zero delay. Below this the scheduler noise IS the perturbation. */
|
|
52
|
+
const MIN_DELAY_MS = 40;
|
|
53
|
+
/**
|
|
54
|
+
* mulberry32 — small, fast, and famously well-distributed for a 32-bit seed.
|
|
55
|
+
*
|
|
56
|
+
* Written out rather than imported because the only thing that matters is that it never changes:
|
|
57
|
+
* a seed's meaning is a promise to whoever recorded a repro against it, and a dependency bump that
|
|
58
|
+
* silently reshuffled the sequence would break every one of them without a test going red.
|
|
59
|
+
*/
|
|
60
|
+
function mulberry32(seed) {
|
|
61
|
+
let a = seed >>> 0;
|
|
62
|
+
return () => {
|
|
63
|
+
a = (a + 0x6d2b79f5) >>> 0;
|
|
64
|
+
let t = a;
|
|
65
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
66
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
67
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Which endpoints to slow, and by how much, for this seed.
|
|
72
|
+
*
|
|
73
|
+
* Every endpoint the flow DECLARED it depends on gets its own delay, drawn independently, so the
|
|
74
|
+
* spread is what reorders them. One uniform delay would slow everything equally and race nothing —
|
|
75
|
+
* the app would see the same order it always sees, just later.
|
|
76
|
+
*
|
|
77
|
+
* `targets` comes from what the flow itself declared (`mutationTargetsFor`), so chaos is applied to
|
|
78
|
+
* the endpoints the flow claims to care about rather than to traffic it never mentioned.
|
|
79
|
+
*/
|
|
80
|
+
export function perturbationFor(seed, targets) {
|
|
81
|
+
if (0 === targets.length)
|
|
82
|
+
return [];
|
|
83
|
+
const rand = mulberry32(seed);
|
|
84
|
+
const span = MAX_DELAY_MS - MIN_DELAY_MS;
|
|
85
|
+
return targets.map((urlContains) => ({
|
|
86
|
+
urlContains,
|
|
87
|
+
delayMs: MIN_DELAY_MS + Math.floor(rand() * span),
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The order a suite runs its flows in, from what each one declares it needs.
|
|
3
|
+
*
|
|
4
|
+
* "Checkout" assumes a signed-in user. Run it first and it fails for a reason that has nothing to do
|
|
5
|
+
* with checkout, which costs somebody a debugging session on working code. Directory order is not an
|
|
6
|
+
* answer to that — it is alphabetical luck.
|
|
7
|
+
*
|
|
8
|
+
* A FOLD, not a scheduler. It says what must come before what; a cycle or a missing prerequisite is
|
|
9
|
+
* REPORTED, never resolved. Inventing an order for a contradictory declaration would produce a suite
|
|
10
|
+
* that runs in an order nobody asked for and cannot be reasoned about when it fails — and a flow
|
|
11
|
+
* whose prerequisite is absent is not "run it anyway", it is a question nobody has answered.
|
|
12
|
+
*
|
|
13
|
+
* Stable among independents: declaration order is preserved, because a suite whose order shuffles
|
|
14
|
+
* between runs makes a flaky flow impossible to attribute — what ran before it changed too.
|
|
15
|
+
*
|
|
16
|
+
* Pure: flows in, an order and its problems out.
|
|
17
|
+
*/
|
|
18
|
+
import type { FlowFile } from './flow-types.js';
|
|
19
|
+
export interface OrderedFlows {
|
|
20
|
+
/** What to run, prerequisites first. */
|
|
21
|
+
run: FlowFile[];
|
|
22
|
+
/** Flows caught in a dependency cycle. None of them run. */
|
|
23
|
+
cycles: string[];
|
|
24
|
+
/** A flow that needs something not in this run, named with what it wanted. */
|
|
25
|
+
unsatisfied: {
|
|
26
|
+
flow: string;
|
|
27
|
+
needs: string;
|
|
28
|
+
}[];
|
|
29
|
+
}
|
|
30
|
+
export declare function orderFlows(flows: readonly FlowFile[]): OrderedFlows;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The order a suite runs its flows in, from what each one declares it needs.
|
|
3
|
+
*
|
|
4
|
+
* "Checkout" assumes a signed-in user. Run it first and it fails for a reason that has nothing to do
|
|
5
|
+
* with checkout, which costs somebody a debugging session on working code. Directory order is not an
|
|
6
|
+
* answer to that — it is alphabetical luck.
|
|
7
|
+
*
|
|
8
|
+
* A FOLD, not a scheduler. It says what must come before what; a cycle or a missing prerequisite is
|
|
9
|
+
* REPORTED, never resolved. Inventing an order for a contradictory declaration would produce a suite
|
|
10
|
+
* that runs in an order nobody asked for and cannot be reasoned about when it fails — and a flow
|
|
11
|
+
* whose prerequisite is absent is not "run it anyway", it is a question nobody has answered.
|
|
12
|
+
*
|
|
13
|
+
* Stable among independents: declaration order is preserved, because a suite whose order shuffles
|
|
14
|
+
* between runs makes a flaky flow impossible to attribute — what ran before it changed too.
|
|
15
|
+
*
|
|
16
|
+
* Pure: flows in, an order and its problems out.
|
|
17
|
+
*/
|
|
18
|
+
export function orderFlows(flows) {
|
|
19
|
+
const present = new Map(flows.map((flow) => [flow.name, flow]));
|
|
20
|
+
const unsatisfied = [];
|
|
21
|
+
for (const flow of flows) {
|
|
22
|
+
for (const need of flow.needs ?? []) {
|
|
23
|
+
if (!present.has(need))
|
|
24
|
+
unsatisfied.push({ flow: flow.name, needs: need });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const blocked = new Set(unsatisfied.map((entry) => entry.flow));
|
|
28
|
+
const run = [];
|
|
29
|
+
const done = new Set();
|
|
30
|
+
const cycles = new Set();
|
|
31
|
+
// Repeated passes rather than a recursive walk: a pass that places nothing means every remaining
|
|
32
|
+
// flow is waiting on another that is also waiting, which IS the cycle — found without having to
|
|
33
|
+
// track a traversal stack.
|
|
34
|
+
let remaining = flows.filter((flow) => !blocked.has(flow.name));
|
|
35
|
+
while (remaining.length > 0) {
|
|
36
|
+
const ready = remaining.filter((flow) => (flow.needs ?? []).every((need) => done.has(need) || !present.has(need)));
|
|
37
|
+
if (0 === ready.length) {
|
|
38
|
+
for (const flow of remaining)
|
|
39
|
+
cycles.add(flow.name);
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
for (const flow of ready) {
|
|
43
|
+
run.push(flow);
|
|
44
|
+
done.add(flow.name);
|
|
45
|
+
}
|
|
46
|
+
remaining = remaining.filter((flow) => !done.has(flow.name));
|
|
47
|
+
}
|
|
48
|
+
return { run, cycles: [...cycles].sort(), unsatisfied };
|
|
49
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which flows a run replays, which it refused to — and which it runs AGAIN.
|
|
3
|
+
*
|
|
4
|
+
* Two jobs that must stay distinguishable in the answer. SELECTION is what the caller asked for.
|
|
5
|
+
* EXCLUSION is what the suite declined to run despite being asked. A run that silently returns fewer
|
|
6
|
+
* flows than were selected is a run whose coverage nobody can account for — so anything held back
|
|
7
|
+
* comes back NAMED, never subtracted.
|
|
8
|
+
*
|
|
9
|
+
* The same reasoning applies to a selection that matched nothing. Quietly passing over a typo is how
|
|
10
|
+
* "all green" comes to mean "nothing ran", which is the failure this product exists to prevent
|
|
11
|
+
* wearing a different hat.
|
|
12
|
+
*
|
|
13
|
+
* Pure: flows and a selection in, three lists out. No store, no clock, no IO.
|
|
14
|
+
*/
|
|
15
|
+
import { type FlowFile } from './flow-types.js';
|
|
16
|
+
export interface FlowSelection {
|
|
17
|
+
/** Run flows carrying ANY of these labels. A set is the union of what you named, not the overlap. */
|
|
18
|
+
labels?: readonly string[];
|
|
19
|
+
/** Run exactly these flows, by name. */
|
|
20
|
+
names?: readonly string[];
|
|
21
|
+
}
|
|
22
|
+
export interface SelectedFlows {
|
|
23
|
+
/** What will actually replay, in the order given. */
|
|
24
|
+
run: FlowFile[];
|
|
25
|
+
/** Held back by a justified quarantine, named so the verdict can report them. */
|
|
26
|
+
quarantined: string[];
|
|
27
|
+
/** Labels and names that matched nothing — a typo, or a set that no longer exists. */
|
|
28
|
+
unmatched: string[];
|
|
29
|
+
}
|
|
30
|
+
export declare function selectFlows(flows: readonly FlowFile[], selection: FlowSelection): SelectedFlows;
|
|
31
|
+
/** How many times a flow may be re-attempted, and on what evidence. */
|
|
32
|
+
export interface RetryPolicy {
|
|
33
|
+
attempts: number;
|
|
34
|
+
/** `flake-classified` asks the ledger first; `any` does not, and the caller owns the cost. */
|
|
35
|
+
on: 'any' | 'flake-classified';
|
|
36
|
+
}
|
|
37
|
+
/** What the flake ledger knows about one flow: replays on UNCHANGED code, and how many failed. */
|
|
38
|
+
export interface FlakeHistory {
|
|
39
|
+
runs: number;
|
|
40
|
+
fails: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Should this flow be re-attempted?
|
|
44
|
+
*
|
|
45
|
+
* Held back until there was a ledger to ask, because without one "retry on failure" is
|
|
46
|
+
* retry-everything with extra steps: a genuinely broken flow is run three times to fail three times,
|
|
47
|
+
* and the suite pays triple to learn what it already knew after the first attempt.
|
|
48
|
+
*
|
|
49
|
+
* The ledger answers the one question that makes retry honest — has this flow been seen to BOTH pass
|
|
50
|
+
* and fail on unchanged code? A flow that has only ever failed is not flaky, it is broken, and
|
|
51
|
+
* re-running it is how a suite turns a real regression into a slow one. A flow with no history has
|
|
52
|
+
* not been classified at all, and guessing is the same mistake with less evidence.
|
|
53
|
+
*
|
|
54
|
+
* Silence is never an opt-in: no policy means no retry.
|
|
55
|
+
*/
|
|
56
|
+
export declare function shouldRetry(policy: RetryPolicy | undefined, history: FlakeHistory | undefined, attemptsSoFar: number): boolean;
|