@e2edev/e2e 0.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/LICENSE +21 -0
- package/README.md +104 -0
- package/dist/agent/act-validation.d.ts +27 -0
- package/dist/agent/act-validation.d.ts.map +1 -0
- package/dist/agent/act-validation.js +121 -0
- package/dist/agent/act-validation.js.map +1 -0
- package/dist/agent/act.d.ts +27 -0
- package/dist/agent/act.d.ts.map +1 -0
- package/dist/agent/act.js +775 -0
- package/dist/agent/act.js.map +1 -0
- package/dist/agent/actions.d.ts +66 -0
- package/dist/agent/actions.d.ts.map +1 -0
- package/dist/agent/actions.js +82 -0
- package/dist/agent/actions.js.map +1 -0
- package/dist/agent/ai-sdk.d.ts +16 -0
- package/dist/agent/ai-sdk.d.ts.map +1 -0
- package/dist/agent/ai-sdk.js +59 -0
- package/dist/agent/ai-sdk.js.map +1 -0
- package/dist/agent/call-options.d.ts +10 -0
- package/dist/agent/call-options.d.ts.map +1 -0
- package/dist/agent/call-options.js +28 -0
- package/dist/agent/call-options.js.map +1 -0
- package/dist/agent/default-agent.d.ts +22 -0
- package/dist/agent/default-agent.d.ts.map +1 -0
- package/dist/agent/default-agent.js +354 -0
- package/dist/agent/default-agent.js.map +1 -0
- package/dist/agent/error.d.ts +53 -0
- package/dist/agent/error.d.ts.map +1 -0
- package/dist/agent/error.js +94 -0
- package/dist/agent/error.js.map +1 -0
- package/dist/agent/executor.d.ts +238 -0
- package/dist/agent/executor.d.ts.map +1 -0
- package/dist/agent/executor.js +56 -0
- package/dist/agent/executor.js.map +1 -0
- package/dist/agent/index.d.ts +15 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +304 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/invocation.d.ts +194 -0
- package/dist/agent/invocation.d.ts.map +1 -0
- package/dist/agent/invocation.js +389 -0
- package/dist/agent/invocation.js.map +1 -0
- package/dist/agent/ledger.d.ts +24 -0
- package/dist/agent/ledger.d.ts.map +1 -0
- package/dist/agent/ledger.js +48 -0
- package/dist/agent/ledger.js.map +1 -0
- package/dist/agent/loop-guards.d.ts +35 -0
- package/dist/agent/loop-guards.d.ts.map +1 -0
- package/dist/agent/loop-guards.js +110 -0
- package/dist/agent/loop-guards.js.map +1 -0
- package/dist/agent/model/adapter.d.ts +97 -0
- package/dist/agent/model/adapter.d.ts.map +1 -0
- package/dist/agent/model/adapter.js +40 -0
- package/dist/agent/model/adapter.js.map +1 -0
- package/dist/agent/model/router.d.ts +36 -0
- package/dist/agent/model/router.d.ts.map +1 -0
- package/dist/agent/model/router.js +45 -0
- package/dist/agent/model/router.js.map +1 -0
- package/dist/agent/model/schema.d.ts +16 -0
- package/dist/agent/model/schema.d.ts.map +1 -0
- package/dist/agent/model/schema.js +37 -0
- package/dist/agent/model/schema.js.map +1 -0
- package/dist/agent/model/sdk.d.ts +28 -0
- package/dist/agent/model/sdk.d.ts.map +1 -0
- package/dist/agent/model/sdk.js +258 -0
- package/dist/agent/model/sdk.js.map +1 -0
- package/dist/agent/observation.d.ts +70 -0
- package/dist/agent/observation.d.ts.map +1 -0
- package/dist/agent/observation.js +174 -0
- package/dist/agent/observation.js.map +1 -0
- package/dist/agent/phases.d.ts +71 -0
- package/dist/agent/phases.d.ts.map +1 -0
- package/dist/agent/phases.js +124 -0
- package/dist/agent/phases.js.map +1 -0
- package/dist/agent/prompts.d.ts +40 -0
- package/dist/agent/prompts.d.ts.map +1 -0
- package/dist/agent/prompts.js +104 -0
- package/dist/agent/prompts.js.map +1 -0
- package/dist/agent/protocol.d.ts +31 -0
- package/dist/agent/protocol.d.ts.map +1 -0
- package/dist/agent/protocol.js +67 -0
- package/dist/agent/protocol.js.map +1 -0
- package/dist/agent/public.d.ts +12 -0
- package/dist/agent/public.d.ts.map +1 -0
- package/dist/agent/public.js +12 -0
- package/dist/agent/public.js.map +1 -0
- package/dist/agent/replay.d.ts +61 -0
- package/dist/agent/replay.d.ts.map +1 -0
- package/dist/agent/replay.js +185 -0
- package/dist/agent/replay.js.map +1 -0
- package/dist/agent/secrets.d.ts +22 -0
- package/dist/agent/secrets.d.ts.map +1 -0
- package/dist/agent/secrets.js +63 -0
- package/dist/agent/secrets.js.map +1 -0
- package/dist/agent/step-cache.d.ts +156 -0
- package/dist/agent/step-cache.d.ts.map +1 -0
- package/dist/agent/step-cache.js +301 -0
- package/dist/agent/step-cache.js.map +1 -0
- package/dist/agent/tool-loop.d.ts +51 -0
- package/dist/agent/tool-loop.d.ts.map +1 -0
- package/dist/agent/tool-loop.js +331 -0
- package/dist/agent/tool-loop.js.map +1 -0
- package/dist/agent/tool.d.ts +39 -0
- package/dist/agent/tool.d.ts.map +1 -0
- package/dist/agent/tool.js +52 -0
- package/dist/agent/tool.js.map +1 -0
- package/dist/backend/contract.d.ts +186 -0
- package/dist/backend/contract.d.ts.map +1 -0
- package/dist/backend/contract.js +65 -0
- package/dist/backend/contract.js.map +1 -0
- package/dist/backend/index.d.ts +316 -0
- package/dist/backend/index.d.ts.map +1 -0
- package/dist/backend/index.js +219 -0
- package/dist/backend/index.js.map +1 -0
- package/dist/backend/session.d.ts +23 -0
- package/dist/backend/session.d.ts.map +1 -0
- package/dist/backend/session.js +213 -0
- package/dist/backend/session.js.map +1 -0
- package/dist/backend/surface.d.ts +83 -0
- package/dist/backend/surface.d.ts.map +1 -0
- package/dist/backend/surface.js +11 -0
- package/dist/backend/surface.js.map +1 -0
- package/dist/cache/anchors.d.ts +37 -0
- package/dist/cache/anchors.d.ts.map +1 -0
- package/dist/cache/anchors.js +89 -0
- package/dist/cache/anchors.js.map +1 -0
- package/dist/cache/context.d.ts +74 -0
- package/dist/cache/context.d.ts.map +1 -0
- package/dist/cache/context.js +82 -0
- package/dist/cache/context.js.map +1 -0
- package/dist/cache/decide.d.ts +42 -0
- package/dist/cache/decide.d.ts.map +1 -0
- package/dist/cache/decide.js +47 -0
- package/dist/cache/decide.js.map +1 -0
- package/dist/cache/identity.d.ts +113 -0
- package/dist/cache/identity.d.ts.map +1 -0
- package/dist/cache/identity.js +109 -0
- package/dist/cache/identity.js.map +1 -0
- package/dist/cache/recorder.d.ts +76 -0
- package/dist/cache/recorder.d.ts.map +1 -0
- package/dist/cache/recorder.js +143 -0
- package/dist/cache/recorder.js.map +1 -0
- package/dist/cache/relocate.d.ts +69 -0
- package/dist/cache/relocate.d.ts.map +1 -0
- package/dist/cache/relocate.js +125 -0
- package/dist/cache/relocate.js.map +1 -0
- package/dist/cache/store.d.ts +68 -0
- package/dist/cache/store.d.ts.map +1 -0
- package/dist/cache/store.js +106 -0
- package/dist/cache/store.js.map +1 -0
- package/dist/cache/trace.d.ts +146 -0
- package/dist/cache/trace.d.ts.map +1 -0
- package/dist/cache/trace.js +249 -0
- package/dist/cache/trace.js.map +1 -0
- package/dist/cli/bin.d.ts +3 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +4 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/index.d.ts +4 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +108 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/init.d.ts +6 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +101 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/collect/collect.d.ts +44 -0
- package/dist/collect/collect.d.ts.map +1 -0
- package/dist/collect/collect.js +89 -0
- package/dist/collect/collect.js.map +1 -0
- package/dist/collect/registry.d.ts +47 -0
- package/dist/collect/registry.d.ts.map +1 -0
- package/dist/collect/registry.js +262 -0
- package/dist/collect/registry.js.map +1 -0
- package/dist/collect/select.d.ts +54 -0
- package/dist/collect/select.d.ts.map +1 -0
- package/dist/collect/select.js +230 -0
- package/dist/collect/select.js.map +1 -0
- package/dist/config/agent.d.ts +91 -0
- package/dist/config/agent.d.ts.map +1 -0
- package/dist/config/agent.js +232 -0
- package/dist/config/agent.js.map +1 -0
- package/dist/config/load.d.ts +23 -0
- package/dist/config/load.d.ts.map +1 -0
- package/dist/config/load.js +75 -0
- package/dist/config/load.js.map +1 -0
- package/dist/config/resolve.d.ts +94 -0
- package/dist/config/resolve.d.ts.map +1 -0
- package/dist/config/resolve.js +500 -0
- package/dist/config/resolve.js.map +1 -0
- package/dist/config/validate.d.ts +6 -0
- package/dist/config/validate.d.ts.map +1 -0
- package/dist/config/validate.js +21 -0
- package/dist/config/validate.js.map +1 -0
- package/dist/credentials.d.ts +7 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +42 -0
- package/dist/credentials.js.map +1 -0
- package/dist/expect/async.d.ts +5 -0
- package/dist/expect/async.d.ts.map +1 -0
- package/dist/expect/async.js +186 -0
- package/dist/expect/async.js.map +1 -0
- package/dist/expect/index.d.ts +7 -0
- package/dist/expect/index.d.ts.map +1 -0
- package/dist/expect/index.js +23 -0
- package/dist/expect/index.js.map +1 -0
- package/dist/expect/values.d.ts +4 -0
- package/dist/expect/values.d.ts.map +1 -0
- package/dist/expect/values.js +108 -0
- package/dist/expect/values.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/ai-trace.d.ts +151 -0
- package/dist/internal/ai-trace.d.ts.map +1 -0
- package/dist/internal/ai-trace.js +360 -0
- package/dist/internal/ai-trace.js.map +1 -0
- package/dist/internal/brands.d.ts +9 -0
- package/dist/internal/brands.d.ts.map +1 -0
- package/dist/internal/brands.js +9 -0
- package/dist/internal/brands.js.map +1 -0
- package/dist/internal/debug.d.ts +43 -0
- package/dist/internal/debug.d.ts.map +1 -0
- package/dist/internal/debug.js +102 -0
- package/dist/internal/debug.js.map +1 -0
- package/dist/internal/errors.d.ts +98 -0
- package/dist/internal/errors.d.ts.map +1 -0
- package/dist/internal/errors.js +212 -0
- package/dist/internal/errors.js.map +1 -0
- package/dist/internal/globs.d.ts +29 -0
- package/dist/internal/globs.d.ts.map +1 -0
- package/dist/internal/globs.js +126 -0
- package/dist/internal/globs.js.map +1 -0
- package/dist/internal/ids.d.ts +32 -0
- package/dist/internal/ids.d.ts.map +1 -0
- package/dist/internal/ids.js +124 -0
- package/dist/internal/ids.js.map +1 -0
- package/dist/internal/json-value.d.ts +15 -0
- package/dist/internal/json-value.d.ts.map +1 -0
- package/dist/internal/json-value.js +61 -0
- package/dist/internal/json-value.js.map +1 -0
- package/dist/internal/package-version.d.ts +6 -0
- package/dist/internal/package-version.d.ts.map +1 -0
- package/dist/internal/package-version.js +14 -0
- package/dist/internal/package-version.js.map +1 -0
- package/dist/internal/realm-slot.d.ts +13 -0
- package/dist/internal/realm-slot.d.ts.map +1 -0
- package/dist/internal/realm-slot.js +23 -0
- package/dist/internal/realm-slot.js.map +1 -0
- package/dist/internal/redact.d.ts +33 -0
- package/dist/internal/redact.d.ts.map +1 -0
- package/dist/internal/redact.js +56 -0
- package/dist/internal/redact.js.map +1 -0
- package/dist/internal/regexp.d.ts +10 -0
- package/dist/internal/regexp.d.ts.map +1 -0
- package/dist/internal/regexp.js +27 -0
- package/dist/internal/regexp.js.map +1 -0
- package/dist/internal/text.d.ts +39 -0
- package/dist/internal/text.d.ts.map +1 -0
- package/dist/internal/text.js +66 -0
- package/dist/internal/text.js.map +1 -0
- package/dist/internal/time.d.ts +37 -0
- package/dist/internal/time.d.ts.map +1 -0
- package/dist/internal/time.js +91 -0
- package/dist/internal/time.js.map +1 -0
- package/dist/internal/trace.d.ts +18 -0
- package/dist/internal/trace.d.ts.map +1 -0
- package/dist/internal/trace.js +46 -0
- package/dist/internal/trace.js.map +1 -0
- package/dist/internal/urls.d.ts +31 -0
- package/dist/internal/urls.d.ts.map +1 -0
- package/dist/internal/urls.js +95 -0
- package/dist/internal/urls.js.map +1 -0
- package/dist/locator/engine.d.ts +65 -0
- package/dist/locator/engine.d.ts.map +1 -0
- package/dist/locator/engine.js +164 -0
- package/dist/locator/engine.js.map +1 -0
- package/dist/locator/expression.d.ts +19 -0
- package/dist/locator/expression.d.ts.map +1 -0
- package/dist/locator/expression.js +85 -0
- package/dist/locator/expression.js.map +1 -0
- package/dist/locator/screen.d.ts +36 -0
- package/dist/locator/screen.d.ts.map +1 -0
- package/dist/locator/screen.js +281 -0
- package/dist/locator/screen.js.map +1 -0
- package/dist/report/build.d.ts +214 -0
- package/dist/report/build.d.ts.map +1 -0
- package/dist/report/build.js +346 -0
- package/dist/report/build.js.map +1 -0
- package/dist/report/code-frame.d.ts +20 -0
- package/dist/report/code-frame.d.ts.map +1 -0
- package/dist/report/code-frame.js +73 -0
- package/dist/report/code-frame.js.map +1 -0
- package/dist/report/debug-steps.d.ts +14 -0
- package/dist/report/debug-steps.d.ts.map +1 -0
- package/dist/report/debug-steps.js +85 -0
- package/dist/report/debug-steps.js.map +1 -0
- package/dist/report/list.d.ts +80 -0
- package/dist/report/list.d.ts.map +1 -0
- package/dist/report/list.js +372 -0
- package/dist/report/list.js.map +1 -0
- package/dist/report/live-status.d.ts +51 -0
- package/dist/report/live-status.d.ts.map +1 -0
- package/dist/report/live-status.js +162 -0
- package/dist/report/live-status.js.map +1 -0
- package/dist/report/write.d.ts +4 -0
- package/dist/report/write.d.ts.map +1 -0
- package/dist/report/write.js +13 -0
- package/dist/report/write.js.map +1 -0
- package/dist/run/app-process.d.ts +18 -0
- package/dist/run/app-process.d.ts.map +1 -0
- package/dist/run/app-process.js +112 -0
- package/dist/run/app-process.js.map +1 -0
- package/dist/run/artifacts.d.ts +51 -0
- package/dist/run/artifacts.d.ts.map +1 -0
- package/dist/run/artifacts.js +114 -0
- package/dist/run/artifacts.js.map +1 -0
- package/dist/run/events.d.ts +100 -0
- package/dist/run/events.d.ts.map +1 -0
- package/dist/run/events.js +59 -0
- package/dist/run/events.js.map +1 -0
- package/dist/run/execute.d.ts +119 -0
- package/dist/run/execute.d.ts.map +1 -0
- package/dist/run/execute.js +555 -0
- package/dist/run/execute.js.map +1 -0
- package/dist/run/fixtures.d.ts +40 -0
- package/dist/run/fixtures.d.ts.map +1 -0
- package/dist/run/fixtures.js +408 -0
- package/dist/run/fixtures.js.map +1 -0
- package/dist/run/in-process.d.ts +24 -0
- package/dist/run/in-process.d.ts.map +1 -0
- package/dist/run/in-process.js +120 -0
- package/dist/run/in-process.js.map +1 -0
- package/dist/run/public.d.ts +19 -0
- package/dist/run/public.d.ts.map +1 -0
- package/dist/run/public.js +11 -0
- package/dist/run/public.js.map +1 -0
- package/dist/run/realm.d.ts +52 -0
- package/dist/run/realm.d.ts.map +1 -0
- package/dist/run/realm.js +101 -0
- package/dist/run/realm.js.map +1 -0
- package/dist/run/records.d.ts +87 -0
- package/dist/run/records.d.ts.map +1 -0
- package/dist/run/records.js +3 -0
- package/dist/run/records.js.map +1 -0
- package/dist/run/retry.d.ts +18 -0
- package/dist/run/retry.d.ts.map +1 -0
- package/dist/run/retry.js +33 -0
- package/dist/run/retry.js.map +1 -0
- package/dist/run/runner.d.ts +49 -0
- package/dist/run/runner.d.ts.map +1 -0
- package/dist/run/runner.js +375 -0
- package/dist/run/runner.js.map +1 -0
- package/dist/run/scheduler.d.ts +45 -0
- package/dist/run/scheduler.d.ts.map +1 -0
- package/dist/run/scheduler.js +512 -0
- package/dist/run/scheduler.js.map +1 -0
- package/dist/run/serial.d.ts +52 -0
- package/dist/run/serial.d.ts.map +1 -0
- package/dist/run/serial.js +247 -0
- package/dist/run/serial.js.map +1 -0
- package/dist/run/sessions.d.ts +54 -0
- package/dist/run/sessions.d.ts.map +1 -0
- package/dist/run/sessions.js +221 -0
- package/dist/run/sessions.js.map +1 -0
- package/dist/run/steps.d.ts +196 -0
- package/dist/run/steps.d.ts.map +1 -0
- package/dist/run/steps.js +151 -0
- package/dist/run/steps.js.map +1 -0
- package/dist/run/unit-runner.d.ts +30 -0
- package/dist/run/unit-runner.d.ts.map +1 -0
- package/dist/run/unit-runner.js +11 -0
- package/dist/run/unit-runner.js.map +1 -0
- package/dist/run/units.d.ts +50 -0
- package/dist/run/units.d.ts.map +1 -0
- package/dist/run/units.js +103 -0
- package/dist/run/units.js.map +1 -0
- package/dist/run/worker/entry.d.ts +8 -0
- package/dist/run/worker/entry.d.ts.map +1 -0
- package/dist/run/worker/entry.js +137 -0
- package/dist/run/worker/entry.js.map +1 -0
- package/dist/run/worker/handle.d.ts +10 -0
- package/dist/run/worker/handle.d.ts.map +1 -0
- package/dist/run/worker/handle.js +74 -0
- package/dist/run/worker/handle.js.map +1 -0
- package/dist/run/worker/protocol.d.ts +129 -0
- package/dist/run/worker/protocol.d.ts.map +1 -0
- package/dist/run/worker/protocol.js +18 -0
- package/dist/run/worker/protocol.js.map +1 -0
- package/dist/run/worker/session.d.ts +69 -0
- package/dist/run/worker/session.d.ts.map +1 -0
- package/dist/run/worker/session.js +123 -0
- package/dist/run/worker/session.js.map +1 -0
- package/dist/types.d.ts +630 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zero-turn trace replay (RFC0001 layer 3, cache-in decision).
|
|
3
|
+
*
|
|
4
|
+
* Replays one recorded trace through the same action grammar the executor
|
|
5
|
+
* uses — every replayed action runs under the step's deadline, action budget,
|
|
6
|
+
* origin policy, secret authorization, and recording. No model is called.
|
|
7
|
+
*
|
|
8
|
+
* Adaptive, never fatal: any reason the trace cannot finish — a gap, a target
|
|
9
|
+
* that moved, an action the live app rejected — ends the replayed prefix and
|
|
10
|
+
* hands the step to the executor mid-step. Runtime hard stops (budget,
|
|
11
|
+
* timeout, cancellation) rethrow untouched; they are the step's truth, not a
|
|
12
|
+
* divergence.
|
|
13
|
+
*/
|
|
14
|
+
import { anchorsPresent } from '../cache/anchors.js';
|
|
15
|
+
import { relocateDescriptor } from '../cache/relocate.js';
|
|
16
|
+
import { sleep } from '../internal/time.js';
|
|
17
|
+
import { isRuntimeHardStop, } from './executor.js';
|
|
18
|
+
/** Backoff between looks at the screen while it settles. */
|
|
19
|
+
const RETRY_DELAYS_MS = [100, 300, 600, 1_000, 3_000];
|
|
20
|
+
/** Ceiling on one poll's total wait, inside whatever the deadline allows. */
|
|
21
|
+
const RETRY_TIMEOUT_MS = 15_000;
|
|
22
|
+
function planCall(action, actions) {
|
|
23
|
+
switch (action.name) {
|
|
24
|
+
case 'tool':
|
|
25
|
+
return { kind: 'gap' };
|
|
26
|
+
case 'tap':
|
|
27
|
+
return { kind: 'targeted', descriptor: action.target, invoke: (t) => actions.tap(t) };
|
|
28
|
+
case 'type':
|
|
29
|
+
return {
|
|
30
|
+
kind: 'targeted',
|
|
31
|
+
descriptor: action.target,
|
|
32
|
+
invoke: (t) => actions.type(t, action.value),
|
|
33
|
+
};
|
|
34
|
+
case 'typeSecret':
|
|
35
|
+
return {
|
|
36
|
+
kind: 'targeted',
|
|
37
|
+
descriptor: action.target,
|
|
38
|
+
invoke: (t) => actions.typeSecret(t, action.secret),
|
|
39
|
+
};
|
|
40
|
+
case 'press':
|
|
41
|
+
return {
|
|
42
|
+
kind: 'targeted',
|
|
43
|
+
descriptor: action.target,
|
|
44
|
+
invoke: (t) => actions.press(t, action.key),
|
|
45
|
+
};
|
|
46
|
+
case 'select':
|
|
47
|
+
return {
|
|
48
|
+
kind: 'targeted',
|
|
49
|
+
descriptor: action.target,
|
|
50
|
+
invoke: (t) => actions.select(t, action.value),
|
|
51
|
+
};
|
|
52
|
+
case 'scroll':
|
|
53
|
+
return action.target === undefined
|
|
54
|
+
? { kind: 'free', invoke: () => actions.scroll(action.direction) }
|
|
55
|
+
: {
|
|
56
|
+
kind: 'targeted',
|
|
57
|
+
descriptor: action.target,
|
|
58
|
+
invoke: (t) => actions.scroll(action.direction, t),
|
|
59
|
+
};
|
|
60
|
+
case 'navigate':
|
|
61
|
+
return { kind: 'free', invoke: () => actions.navigate(action.url) };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/** Replays one trace until it completes or diverges. */
|
|
65
|
+
export async function replayTrace(host, trace) {
|
|
66
|
+
const summaries = [];
|
|
67
|
+
const total = trace.actions.length;
|
|
68
|
+
const stop = (stopReason) => ({
|
|
69
|
+
completed: false,
|
|
70
|
+
executed: summaries.length,
|
|
71
|
+
total,
|
|
72
|
+
summaries,
|
|
73
|
+
stopReason,
|
|
74
|
+
});
|
|
75
|
+
for (const action of trace.actions) {
|
|
76
|
+
const planned = planCall(action, host.actions);
|
|
77
|
+
if (planned.kind === 'gap')
|
|
78
|
+
return stop('gap');
|
|
79
|
+
try {
|
|
80
|
+
if (planned.kind === 'targeted') {
|
|
81
|
+
const relocated = await relocate(host, planned.descriptor);
|
|
82
|
+
if (relocated.kind === 'failed')
|
|
83
|
+
return stop(relocated.failure);
|
|
84
|
+
await planned.invoke({ id: relocated.id });
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
await planned.invoke();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (cause) {
|
|
91
|
+
if (isReplayFatal(cause, host.signal))
|
|
92
|
+
throw cause;
|
|
93
|
+
if (isUncertainCommit(cause)) {
|
|
94
|
+
// Input may have reached the app (spec 09): the hand-off must name
|
|
95
|
+
// the uncertain action so the executor verifies before re-acting —
|
|
96
|
+
// the runner never repeats an unknown-commit operation itself.
|
|
97
|
+
return { ...stop('action-uncertain'), uncertainAction: action.summary };
|
|
98
|
+
}
|
|
99
|
+
return stop('action-failed');
|
|
100
|
+
}
|
|
101
|
+
summaries.push(action.summary);
|
|
102
|
+
}
|
|
103
|
+
return { completed: true, executed: summaries.length, total, summaries };
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Verifies a trace's recorded end anchors against the live screen: every
|
|
107
|
+
* anchor must be present again (`anchors.ts`, every recorded field equal) or
|
|
108
|
+
* the replay must not pass on its own. Waits on the same settling backoff
|
|
109
|
+
* relocation uses, because the recording run's final look came seconds of
|
|
110
|
+
* model latency after its last action and a replay's comes right away: a
|
|
111
|
+
* save still in flight is a wait, not a divergence. A surface that cannot be
|
|
112
|
+
* observed at all is a mismatch too — the executor gets the step and judges
|
|
113
|
+
* the live state; only runtime hard stops propagate.
|
|
114
|
+
*/
|
|
115
|
+
export async function verifyAnchors(host, anchors) {
|
|
116
|
+
if (anchors.length === 0)
|
|
117
|
+
return true;
|
|
118
|
+
try {
|
|
119
|
+
const present = await pollSettled(host, (nodes) => anchorsPresent(anchors, nodes, host) ? true : undefined);
|
|
120
|
+
return present === true;
|
|
121
|
+
}
|
|
122
|
+
catch (cause) {
|
|
123
|
+
if (isReplayFatal(cause, host.signal))
|
|
124
|
+
throw cause;
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Relocates one descriptor against the settling screen. Only a missing target
|
|
130
|
+
* is worth another look; ambiguity never retries — two matching nodes will
|
|
131
|
+
* not become one by waiting, and acting on either would be a guess.
|
|
132
|
+
*/
|
|
133
|
+
async function relocate(host, descriptor) {
|
|
134
|
+
const options = { redact: host.redact, testIdAttribute: host.testIdAttribute };
|
|
135
|
+
const settled = await pollSettled(host, (nodes) => {
|
|
136
|
+
const result = relocateDescriptor(descriptor, nodes, options);
|
|
137
|
+
return result.kind === 'failed' && result.failure === 'target-not-found' ? undefined : result;
|
|
138
|
+
});
|
|
139
|
+
return settled ?? { kind: 'failed', failure: 'target-not-found' };
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Probes a settled observation, then re-probes fresh raw captures on a fixed
|
|
143
|
+
* backoff until the probe answers or the wait runs out: a screen
|
|
144
|
+
* mid-transition gets a few looks before replay gives the step up. The first
|
|
145
|
+
* look settles because replay executes recorded actions far faster than the
|
|
146
|
+
* run that recorded them; without that wait an action can land while the app
|
|
147
|
+
* is still reacting to the previous one — a form mid-clear, a list mid-update
|
|
148
|
+
* — and commit something the recorded run never did.
|
|
149
|
+
*/
|
|
150
|
+
async function pollSettled(host, probe) {
|
|
151
|
+
const startedMs = Date.now();
|
|
152
|
+
let nodes = await host.observeSettled();
|
|
153
|
+
for (let attempt = 0;; attempt += 1) {
|
|
154
|
+
const answer = probe(nodes);
|
|
155
|
+
if (answer !== undefined)
|
|
156
|
+
return answer;
|
|
157
|
+
const delay = RETRY_DELAYS_MS[attempt];
|
|
158
|
+
if (delay === undefined ||
|
|
159
|
+
Date.now() - startedMs + delay > RETRY_TIMEOUT_MS ||
|
|
160
|
+
host.remainingMs() <= delay) {
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
await sleep(delay, host.signal);
|
|
164
|
+
nodes = await host.observe();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/** True when any error in the cause chain reports an unknown commit state. */
|
|
168
|
+
function isUncertainCommit(cause) {
|
|
169
|
+
for (let error = cause, depth = 0; depth < 8; depth += 1) {
|
|
170
|
+
if (typeof error !== 'object' || error === null)
|
|
171
|
+
return false;
|
|
172
|
+
if (error.code === 'ACTION_MAY_HAVE_COMMITTED')
|
|
173
|
+
return true;
|
|
174
|
+
error = error.cause;
|
|
175
|
+
}
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* True for errors a replay must surface rather than absorb as divergence:
|
|
180
|
+
* runtime hard stops and cancellation are the step's own accounting.
|
|
181
|
+
*/
|
|
182
|
+
function isReplayFatal(cause, signal) {
|
|
183
|
+
return signal.aborted || isRuntimeHardStop(cause);
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=replay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay.js","sourceRoot":"","sources":["../../src/agent/replay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAyB,MAAM,sBAAsB,CAAC;AAGjF,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EACL,iBAAiB,GAIlB,MAAM,eAAe,CAAC;AAEvB,4DAA4D;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MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC;QACxC,MAAM,KAAK,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;QACvC,IACE,KAAK,KAAK,SAAS;YACnB,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,KAAK,GAAG,gBAAgB;YACjD,IAAI,CAAC,WAAW,EAAE,IAAI,KAAK,EAC3B,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAChC,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IAC/B,CAAC;AACH,CAAC;AAED,8EAA8E;AAC9E,SAAS,iBAAiB,CAAC,KAAc;IACvC,KAAK,IAAI,KAAK,GAAG,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACzD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,KAAK,CAAC;QAC9D,IAAK,KAA4B,CAAC,IAAI,KAAK,2BAA2B;YAAE,OAAO,IAAI,CAAC;QACpF,KAAK,GAAI,KAA6B,CAAC,KAAK,CAAC;IAC/C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,SAAS,aAAa,CAAC,KAAc,EAAE,MAAmB;IACxD,OAAO,MAAM,CAAC,OAAO,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Host-side secret fill authorization (spec 04-resources.md, 14-security.md). */
|
|
2
|
+
import type { TargetSession, OperationContext, SemanticNode } from '../backend/surface.ts';
|
|
3
|
+
import type { Secret } from '../types.ts';
|
|
4
|
+
import type { AgentContext } from './invocation.ts';
|
|
5
|
+
/**
|
|
6
|
+
* The narrow surface a secret fill needs from its step machinery: the act
|
|
7
|
+
* dispatch is its one caller today, and any future tier that fills secrets
|
|
8
|
+
* satisfies the same three members rather than re-deriving the policy.
|
|
9
|
+
*/
|
|
10
|
+
interface SecretFillHost {
|
|
11
|
+
readonly session: TargetSession;
|
|
12
|
+
operation(): OperationContext;
|
|
13
|
+
recordPolicy(name: string, decision: 'allowed' | 'denied', code?: string): void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Authorizes one secret fill and resolves the plaintext only after every check
|
|
17
|
+
* passes. The value is returned to the caller for a single immediate handoff to
|
|
18
|
+
* the trusted backend and is never logged, cached, or sent to a model.
|
|
19
|
+
*/
|
|
20
|
+
export declare function authorizeSecretFill(host: SecretFillHost, runtime: AgentContext, secret: Secret, node: SemanticNode): Promise<string>;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=secrets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../src/agent/secrets.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAElF,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC3F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;GAIG;AACH,UAAU,cAAc;IACtB,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,SAAS,IAAI,gBAAgB,CAAC;IAC9B,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,GAAG,QAAQ,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACjF;AAKD;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC,MAAM,CAAC,CA+CjB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** Host-side secret fill authorization (spec 04-resources.md, 14-security.md). */
|
|
2
|
+
import { AgentError, toAgentError } from './error.js';
|
|
3
|
+
/** Roles that expose an editable secure input sink. */
|
|
4
|
+
const EDITABLE_ROLES = new Set(['textbox', 'searchbox', 'combobox']);
|
|
5
|
+
/**
|
|
6
|
+
* Authorizes one secret fill and resolves the plaintext only after every check
|
|
7
|
+
* passes. The value is returned to the caller for a single immediate handoff to
|
|
8
|
+
* the trusted backend and is never logged, cached, or sent to a model.
|
|
9
|
+
*/
|
|
10
|
+
export async function authorizeSecretFill(host, runtime, secret, node) {
|
|
11
|
+
const credential = runtime.config.credentials.get(secret.name);
|
|
12
|
+
if (credential === undefined) {
|
|
13
|
+
host.recordPolicy('secret.registered', 'denied', 'AUTH_CREDENTIAL_UNAVAILABLE');
|
|
14
|
+
throw new AgentError('AUTH_CREDENTIAL_UNAVAILABLE', `credential "${secret.name}" is not configured`);
|
|
15
|
+
}
|
|
16
|
+
const origin = await currentOrigin(host);
|
|
17
|
+
const appAllows = runtime.config.app.allowedOrigins.includes(origin);
|
|
18
|
+
const credentialAllows = credential.allowedOrigins === undefined || credential.allowedOrigins.includes(origin);
|
|
19
|
+
if (!appAllows || !credentialAllows) {
|
|
20
|
+
host.recordPolicy('secret.origin', 'denied', 'POLICY_DENIED');
|
|
21
|
+
throw new AgentError('POLICY_DENIED', `origin ${origin} is not authorized for secret "${secret.name}"`);
|
|
22
|
+
}
|
|
23
|
+
if (node.states?.disabled === true) {
|
|
24
|
+
host.recordPolicy('secret.sink', 'denied', 'POLICY_DENIED');
|
|
25
|
+
throw new AgentError('POLICY_DENIED', 'the target field is disabled');
|
|
26
|
+
}
|
|
27
|
+
if (node.role === undefined || !EDITABLE_ROLES.has(node.role)) {
|
|
28
|
+
host.recordPolicy('secret.sink', 'denied', 'POLICY_DENIED');
|
|
29
|
+
throw new AgentError('POLICY_DENIED', `the target is not an editable input (role ${node.role ?? 'none'})`);
|
|
30
|
+
}
|
|
31
|
+
if (node.inputPurpose !== secret.purpose) {
|
|
32
|
+
host.recordPolicy('secret.purpose', 'denied', 'POLICY_DENIED');
|
|
33
|
+
throw new AgentError('POLICY_DENIED', `field purpose ${node.inputPurpose ?? 'none'} is incompatible with secret purpose ${secret.purpose}`);
|
|
34
|
+
}
|
|
35
|
+
host.recordPolicy('secret.fill', 'allowed');
|
|
36
|
+
try {
|
|
37
|
+
return await runtime.secrets.resolve(secret);
|
|
38
|
+
}
|
|
39
|
+
catch (cause) {
|
|
40
|
+
throw toAgentError(cause);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Reads the current top-level origin for origin policy checks. */
|
|
44
|
+
async function currentOrigin(host) {
|
|
45
|
+
const url = host.session.url;
|
|
46
|
+
if (url === undefined) {
|
|
47
|
+
throw new AgentError('POLICY_DENIED', 'secret fills require a backend that exposes the current top-level URL');
|
|
48
|
+
}
|
|
49
|
+
let href;
|
|
50
|
+
try {
|
|
51
|
+
href = await url(host.operation());
|
|
52
|
+
}
|
|
53
|
+
catch (cause) {
|
|
54
|
+
throw toAgentError(cause);
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
return new URL(href).origin;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
throw new AgentError('POLICY_DENIED', `the current URL ${href} is not a valid origin`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=secrets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../src/agent/secrets.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAIlF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AActD,uDAAuD;AACvD,MAAM,cAAc,GAAG,IAAI,GAAG,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C,KAAK,CAAC,CAAC;IAC5B,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,UAAU,CAAC,eAAe,EAAE,mBAAmB,IAAI,wBAAwB,CAAC,CAAC;IACzF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One step's trace-cache session (RFC0001 layer 3, cache-in decision): key
|
|
3
|
+
* derivation, the replay attempt, live recording, and the stage-or-evict
|
|
4
|
+
* decision once the step has settled — everything cache-shaped about one
|
|
5
|
+
* dispatched act step, kept beside the dispatch rather than threaded through
|
|
6
|
+
* it. The dispatch owns budgets, the grammar, and the verdict; this class owns
|
|
7
|
+
* nothing but the cache.
|
|
8
|
+
*
|
|
9
|
+
* Cost: in read-write mode the session takes two settled looks at the screen
|
|
10
|
+
* the executor never asked for — one before any action, one after the passing
|
|
11
|
+
* verdict — because the trace's end anchors are the delta between them. A
|
|
12
|
+
* read-only run pays neither.
|
|
13
|
+
*/
|
|
14
|
+
import type { AgentCacheContext } from '../cache/context.ts';
|
|
15
|
+
import type { StepCacheInfo } from '../run/steps.ts';
|
|
16
|
+
import type { JsonValue } from '../types.ts';
|
|
17
|
+
import type { RecordableAction } from './actions.ts';
|
|
18
|
+
import { type ReplayedPrefix, type StepVerdict } from './executor.ts';
|
|
19
|
+
import { type ReplayHost } from './replay.ts';
|
|
20
|
+
/**
|
|
21
|
+
* The replay host plus the one session-level probe replay itself never needs:
|
|
22
|
+
* the current location path, read at both ends of the step for the trace's
|
|
23
|
+
* start-path precondition and end-path postcondition.
|
|
24
|
+
*/
|
|
25
|
+
export interface StepCacheHost extends ReplayHost {
|
|
26
|
+
currentPath(): Promise<string | undefined>;
|
|
27
|
+
}
|
|
28
|
+
/** What the session needs from the dispatch beyond the host itself. */
|
|
29
|
+
export interface StepCacheOptions {
|
|
30
|
+
readonly cache: AgentCacheContext;
|
|
31
|
+
readonly instruction: string;
|
|
32
|
+
readonly params: Readonly<Record<string, JsonValue>> | undefined;
|
|
33
|
+
readonly executor: {
|
|
34
|
+
readonly name: string;
|
|
35
|
+
readonly version?: string;
|
|
36
|
+
};
|
|
37
|
+
readonly redact: (text: string) => string;
|
|
38
|
+
readonly testIdAttribute: string;
|
|
39
|
+
readonly maxActions: number;
|
|
40
|
+
/** Timeline index of the step being dispatched. */
|
|
41
|
+
readonly stepIndex: number;
|
|
42
|
+
}
|
|
43
|
+
/** How the step settled, as the write-side decision sees it. */
|
|
44
|
+
export type StepOutcome = 'passed' | 'failed' | 'cancelled';
|
|
45
|
+
export declare class StepTraceSession {
|
|
46
|
+
private readonly host;
|
|
47
|
+
private readonly cache;
|
|
48
|
+
private readonly keyHash;
|
|
49
|
+
private readonly recorder;
|
|
50
|
+
private readonly options;
|
|
51
|
+
private info;
|
|
52
|
+
private prefix;
|
|
53
|
+
private startPath;
|
|
54
|
+
/**
|
|
55
|
+
* The screen before any action, captured only when this step may write: the
|
|
56
|
+
* staged trace's end anchors are the delta between this and the passing
|
|
57
|
+
* observation, so a replay must reproduce the step's effect to pass alone.
|
|
58
|
+
* Undefined after `begin` when the surface could not be observed; the step
|
|
59
|
+
* still runs — an executor that never looks at the screen owes the cache
|
|
60
|
+
* nothing — but nothing is staged, because a trace without its baseline has
|
|
61
|
+
* no anchors and would replay on mechanics alone.
|
|
62
|
+
*/
|
|
63
|
+
private startNodes;
|
|
64
|
+
/**
|
|
65
|
+
* The trace a full replay reproduced, kept for the re-stage: its executor
|
|
66
|
+
* is the write's provenance, and its summary is the original verdict prose.
|
|
67
|
+
* The step's own summary after a replay is the synthesized "replayed N
|
|
68
|
+
* actions…" wrapper; storing that would nest the summary one level deeper
|
|
69
|
+
* on every replay until the bound truncated it.
|
|
70
|
+
*/
|
|
71
|
+
private replayed;
|
|
72
|
+
/** True once a cached entry's actions were run this step, fully or partly. */
|
|
73
|
+
private consumedReplay;
|
|
74
|
+
/** Grammar actions recorded so far when an end-mismatch hand-off happened. */
|
|
75
|
+
private actionsAtEndMismatch;
|
|
76
|
+
constructor(host: StepCacheHost, options: StepCacheOptions);
|
|
77
|
+
/** How the cache participated, for the step's report detail. */
|
|
78
|
+
get cacheInfo(): StepCacheInfo | undefined;
|
|
79
|
+
/** The mid-step hand-off, when a replay diverged after real progress. */
|
|
80
|
+
get replayedPrefix(): ReplayedPrefix | undefined;
|
|
81
|
+
/** Records one committed grammar action into the step trace. */
|
|
82
|
+
record(action: RecordableAction): void;
|
|
83
|
+
/** Records one mutating project-tool call as a replay-ending gap. */
|
|
84
|
+
recordGap(toolName: string): void;
|
|
85
|
+
/**
|
|
86
|
+
* Opens the step: captures the write-side preconditions — the start path
|
|
87
|
+
* and, when this step may write, the baseline screen — then attempts a
|
|
88
|
+
* zero-turn replay. Returns the self-finalized verdict on a full replay
|
|
89
|
+
* whose postcondition holds; undefined dispatches the executor — after a
|
|
90
|
+
* miss from the top, after a divergence mid-step with `replayedPrefix` set.
|
|
91
|
+
* Every failure to replay is a miss, never an error; only runtime hard stops
|
|
92
|
+
* propagate.
|
|
93
|
+
*/
|
|
94
|
+
begin(): Promise<StepVerdict | undefined>;
|
|
95
|
+
/**
|
|
96
|
+
* Closes the session once the step has settled. The whole write-side
|
|
97
|
+
* decision lives here, in read-write mode only:
|
|
98
|
+
*
|
|
99
|
+
* - passed, after an end-mismatch the executor had to act to repair: evict.
|
|
100
|
+
* Every recorded action ran and the effect was still missing, so the
|
|
101
|
+
* recorded flow is proven not to produce it. Re-staging would freeze the
|
|
102
|
+
* failed flow plus its repair — a typo, its deletion, the retype — as the
|
|
103
|
+
* thing to replay forever; the next pass records a clean flow instead. A
|
|
104
|
+
* hand-off the executor settled without acting is different: the flow was
|
|
105
|
+
* fine and only the anchors were stale, so it heals by re-staging.
|
|
106
|
+
* - passed otherwise: stage the recorded trace for attempt-end settlement.
|
|
107
|
+
* - failed after consuming a replay: evict. Without this, a diverged replay
|
|
108
|
+
* whose step then fails stages nothing — and the poisoned entry would
|
|
109
|
+
* replay its bad prefix on every future first attempt.
|
|
110
|
+
* - cancelled: nothing, exactly like an interrupted attempt.
|
|
111
|
+
*/
|
|
112
|
+
conclude(outcome: StepOutcome, verdictSummary: string | undefined): Promise<void>;
|
|
113
|
+
/**
|
|
114
|
+
* One store read, revalidated through the trace-1 framing whichever store
|
|
115
|
+
* produced it: a custom store's entry can never be trusted more loosely
|
|
116
|
+
* than a file entry, however the store author built their read path. A
|
|
117
|
+
* store outage is a slower run, never a failed test — every failure to read
|
|
118
|
+
* degrades to a miss.
|
|
119
|
+
*/
|
|
120
|
+
private readEntry;
|
|
121
|
+
/**
|
|
122
|
+
* The trace's postcondition against the live screen: the recorded end path
|
|
123
|
+
* (pathname only, when the live location is known) and every recorded end
|
|
124
|
+
* anchor present again.
|
|
125
|
+
*/
|
|
126
|
+
private endStateMatches;
|
|
127
|
+
private selfFinalize;
|
|
128
|
+
private handOff;
|
|
129
|
+
/**
|
|
130
|
+
* Stages the recorded trace for attempt-end settlement. The write is
|
|
131
|
+
* deferred, not immediate: the trace is confirmed or evicted at attempt end
|
|
132
|
+
* (`flushStagedTraces`), because the verification step after this one — not
|
|
133
|
+
* the verdict alone — is what proves the flow reached the right state. A
|
|
134
|
+
* replayed step re-stages its own entry with fresh descriptors, which is
|
|
135
|
+
* how staleness self-heals.
|
|
136
|
+
*
|
|
137
|
+
* The end path and a fresh settled observation are the trace's
|
|
138
|
+
* postcondition — the state the step passed in. The delta between the
|
|
139
|
+
* baseline and the passing observation becomes the end anchors. When the
|
|
140
|
+
* step moved to another pathname the whole screen is the delta and the path
|
|
141
|
+
* is the postcondition, so anchors are recorded only for a step that ended
|
|
142
|
+
* where it began (or on a surface without a location at all, where they are
|
|
143
|
+
* the only check). A postcondition that cannot be captured stages nothing:
|
|
144
|
+
* a trace without its check would replay on mechanics alone.
|
|
145
|
+
*/
|
|
146
|
+
private stage;
|
|
147
|
+
/**
|
|
148
|
+
* Awaited so the step does not close — and a later read cannot be served
|
|
149
|
+
* the stale flow — before the eviction has settled. The cache is
|
|
150
|
+
* disposable; a failed eviction is a slower next run only.
|
|
151
|
+
*/
|
|
152
|
+
private evict;
|
|
153
|
+
private repairedAfterEndMismatch;
|
|
154
|
+
private missed;
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=step-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-cache.d.ts","sourceRoot":"","sources":["../../src/agent/step-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAS7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAqB,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACzF,OAAO,EAIL,KAAK,UAAU,EAEhB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,WAAW,aAAc,SAAQ,UAAU;IAC/C,WAAW,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CAC5C;AAED,uEAAuE;AACvE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,GAAG,SAAS,CAAC;IACjE,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC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