Replays architecture
Components, data flow, authorization, cutoff rules, limits and failure handling for Replays and trials.
This page is the system view of Replays. For using it, start at Replays. Lower-level contracts live in historical data preservation, replay timeline and prepare replay environments.
Components
| Component | Where | Job |
|---|---|---|
| Setup service | services/history/replays-setup.service.ts | Turn on, confirm, pause, resume, remove, per-integration recording, status. |
| Preset repository and helper | repositories/history-preset.repository.ts, helpers/history-preset.helper.ts | Standard policies, consent events, reconcile, replayable window, due removals. |
| Integration-write hook | followIntegrationWrite in repositories/integration.repository.ts | Re-stamp or narrow a preset policy after each integration write. |
| Boot sweep | reconcileHistoryPresetForAllOrganizations in src/index.ts | Repair anything the hook missed, once at backend start. |
| Observation recording | services/history/recording/recorded-interaction.service.ts, called from the gateways | Record tool calls that match an enabled binding. |
| Internal-state trigger | oblive_record_internal_state (database) | Append a revision when the organization, a profile, a task spec or profile memory changes. |
| History cycle | helpers/history-capture.background.helper.ts | Scheduled collection, reconcile, expiry and due removals. |
| Insights day copy | jobs/observationbeat.background.job.ts, services/insight-publication.service.ts | Freeze one Insights copy per business day. |
| Packet freeze | services/business-world-snapshot/business-world-snapshot.service.ts | Preview and freeze a day’s snapshot from a declaration. |
| Trial day and start | services/replay/trials/trial-day.service.ts, trial-start.service.ts, helpers/trial-declaration.helper.ts | Day states, generated declarations, on-demand freeze, trial creation. |
| Replay runner | commands/replay-environment.command.ts, services/replay/trials/trial-supervisor.service.ts, services/replay/sandbox/provisioner.service.ts | Prepare, send the initiative, release. |
| Replay environment | Isolated Docker stack built by the provisioner | Run the trial with recorded readers, the cutoff guard and relays. |
| Frontend server | apps/frontend/src/lib/replays.server.ts | Staff check, server-held tokens, actor. |
| Replays pages | apps/frontend/src/routes/organizations.$organizationId.replays*.tsx | Timeline, Trials, New trial, trial detail, Setup. |
Paths are under apps/backend/src unless shown.
System map
flowchart TB
subgraph Browser["Browser (staff)"]
Pages["Replays pages<br/>Timeline · Trials · Setup"]
end
subgraph Frontend["Frontend server"]
FS["replays.server.ts<br/>staff check + server-held tokens"]
end
subgraph Backend["Main backend"]
Routes["Replay routes<br/>timeline · eval-runs · replay-trials · replays/setup"]
Setup["Setup service + preset"]
TrialSvc["Trial day + start"]
Freeze["Packet freeze"]
Gateways["Integration gateways<br/>MCP · CLI · git"]
Obs["Observation recording"]
SA["Source-authority check<br/>/internal/replay-source-authorization"]
Jobs["History cycle + observationbeat<br/>collection · Insights copies · expiry · removals"]
end
subgraph Data["Business data"]
PG[("Postgres<br/>policies · events · revisions<br/>archive rows · eval runs")]
Store[("Archive store<br/>encrypted objects")]
end
subgraph Host["Trusted host"]
Runner["Replay runner<br/>replay:environment run"]
subgraph Env["Replay environment (one per trial)"]
EnvStack["Isolated backend + worker<br/>own Postgres · queue · storage"]
end
end
Model["Model provider"]
Providers["Live providers"]
Pages --> FS --> Routes
Routes --> Setup & TrialSvc
TrialSvc --> Freeze
Gateways --> Providers
Gateways --> Obs --> Store
Obs --> PG
Setup --> PG
Jobs --> PG & Store
Freeze --> PG & Store
Runner --> PG & Store
Runner -->|Docker| Env
EnvStack -->|source-authority relay| SA
EnvStack -->|model gateway| Modelflowchart TB
subgraph Browser["Browser (staff)"]
Pages["Replays pages<br/>Timeline · Trials · Setup"]
end
subgraph Frontend["Frontend server"]
FS["replays.server.ts<br/>staff check + server-held tokens"]
end
subgraph Backend["Main backend"]
Routes["Replay routes<br/>timeline · eval-runs · replay-trials · replays/setup"]
Setup["Setup service + preset"]
TrialSvc["Trial day + start"]
Freeze["Packet freeze"]
Gateways["Integration gateways<br/>MCP · CLI · git"]
Obs["Observation recording"]
SA["Source-authority check<br/>/internal/replay-source-authorization"]
Jobs["History cycle + observationbeat<br/>collection · Insights copies · expiry · removals"]
end
subgraph Data["Business data"]
PG[("Postgres<br/>policies · events · revisions<br/>archive rows · eval runs")]
Store[("Archive store<br/>encrypted objects")]
end
subgraph Host["Trusted host"]
Runner["Replay runner<br/>replay:environment run"]
subgraph Env["Replay environment (one per trial)"]
EnvStack["Isolated backend + worker<br/>own Postgres · queue · storage"]
end
end
Model["Model provider"]
Providers["Live providers"]
Pages --> FS --> Routes
Routes --> Setup & TrialSvc
TrialSvc --> Freeze
Gateways --> Providers
Gateways --> Obs --> Store
Obs --> PG
Setup --> PG
Jobs --> PG & Store
Freeze --> PG & Store
Runner --> PG & Store
Runner -->|Docker| Env
EnvStack -->|source-authority relay| SA
EnvStack -->|model gateway| ModelThe main backend never runs Docker. The runner is the only process that starts replay environments, and an environment can reach only the live backend’s source-authority checks and the model provider. It never reaches a live provider.
Data flow
Turning Replays on
sequenceDiagram autonumber actor Staff participant Tab as Setup tab participant FS as Frontend server participant API as POST /replays/setup participant Svc as Setup service participant DB as Postgres Staff->>Tab: Turn on, agreement reference Tab->>FS: action apply, basis, reviewed FS->>FS: verified staff session, read actor email FS->>API: setup token, actor, action API->>Svc: status() API->>API: reviewed equals pending set? (else 409 setup_conflict) Svc->>Svc: history capture on? not paused? Svc->>DB: consent event started (actor, basis) Svc->>DB: Standard run-input policy Svc->>DB: observation policy per integration (managed_by preset) Svc->>DB: checkpoint owners with no revision yet Svc->>DB: replaysEnabled = true Svc->>DB: consent event completed (revisions) API-->>FS: status + applied FS-->>Tab: updated status
sequenceDiagram autonumber actor Staff participant Tab as Setup tab participant FS as Frontend server participant API as POST /replays/setup participant Svc as Setup service participant DB as Postgres Staff->>Tab: Turn on, agreement reference Tab->>FS: action apply, basis, reviewed FS->>FS: verified staff session, read actor email FS->>API: setup token, actor, action API->>Svc: status() API->>API: reviewed equals pending set? (else 409 setup_conflict) Svc->>Svc: history capture on? not paused? Svc->>DB: consent event started (actor, basis) Svc->>DB: Standard run-input policy Svc->>DB: observation policy per integration (managed_by preset) Svc->>DB: checkpoint owners with no revision yet Svc->>DB: replaysEnabled = true Svc->>DB: consent event completed (revisions) API-->>FS: status + applied FS-->>Tab: updated status
The command line (replays:setup --basis) calls the same service, with the operating system user as
the actor and no reviewed check.
Recording a tool call
sequenceDiagram autonumber participant Agent participant GW as Integration gateway participant Obs as Observation service participant P as Live provider participant DB as Postgres participant S as Archive store Agent->>GW: tool call GW->>Obs: capture on? free slot? (8 per process, 2 per business) Obs->>DB: reserve occurrence (checks pause, policy, binding) alt no slot, capture off, or reserve refused (paused or no binding) GW->>P: call P-->>GW: answer else reserved GW->>P: call P-->>GW: answer Obs->>DB: outcome Obs->>S: encrypt and store request and answer Obs->>DB: archive row + evidence availability (pending) Note over DB: a scheduled sweep confirms it later (confirmedAt) end GW-->>Agent: answer (recording never changes it)
sequenceDiagram autonumber participant Agent participant GW as Integration gateway participant Obs as Observation service participant P as Live provider participant DB as Postgres participant S as Archive store Agent->>GW: tool call GW->>Obs: capture on? free slot? (8 per process, 2 per business) Obs->>DB: reserve occurrence (checks pause, policy, binding) alt no slot, capture off, or reserve refused (paused or no binding) GW->>P: call P-->>GW: answer else reserved GW->>P: call P-->>GW: answer Obs->>DB: outcome Obs->>S: encrypt and store request and answer Obs->>DB: archive row + evidence availability (pending) Note over DB: a scheduled sweep confirms it later (confirmedAt) end GW-->>Agent: answer (recording never changes it)
Recording waits at most 5 seconds per call. A recording failure leaves a coverage gap and a log line; the business call still succeeds.
Internal state
flowchart LR
W["Write to organization, profile,<br/>task spec or profile memory"] --> T{"oblive_record_internal_state<br/>trigger"}
T -->|"scope enabled and not paused"| R[("Revision appended<br/>(same transaction)")]
T -->|"scope off or paused"| N["Nothing recorded"]
Setup["Setup or resume"] -->|"checkpoint"| Rflowchart LR
W["Write to organization, profile,<br/>task spec or profile memory"] --> T{"oblive_record_internal_state<br/>trigger"}
T -->|"scope enabled and not paused"| R[("Revision appended<br/>(same transaction)")]
T -->|"scope off or paused"| N["Nothing recorded"]
Setup["Setup or resume"] -->|"checkpoint"| RTriggers only fire on change. Setup saves a starting copy of every owner that has none, so a day before the first change still has state. Resume saves a fresh copy of owners that changed while paused and records owners removed meanwhile.
Integration edits
flowchart TD
E["Integration write commits"] --> H["followIntegrationWrite<br/>(own transaction)"]
H --> Q{"Business set up, not paused,<br/>policy not written by hand?"}
Q -->|no| Skip["Leave policy as is"]
Q -->|yes| Dis{"Integration disabled?"}
Dis -->|yes| FR["Frozen: leave as is"]
Dis -->|no| D{"Compare Standard bindings<br/>with stored bindings"}
D -->|"same tools"| RS["Re-stamp fingerprint"]
D -->|"tool removed"| NA["Narrow: drop binding"]
D -->|"new reviewed read"| PW["Re-stamp kept tools; the new tool waits for confirm"]
D -->|"no policy yet (new integration)"| PN["Disabled placeholder,<br/>wait for confirm"]
H -. "failure is logged,<br/>write still succeeds" .-> L["Boot sweep and next<br/>setup run repair it"]flowchart TD
E["Integration write commits"] --> H["followIntegrationWrite<br/>(own transaction)"]
H --> Q{"Business set up, not paused,<br/>policy not written by hand?"}
Q -->|no| Skip["Leave policy as is"]
Q -->|yes| Dis{"Integration disabled?"}
Dis -->|yes| FR["Frozen: leave as is"]
Dis -->|no| D{"Compare Standard bindings<br/>with stored bindings"}
D -->|"same tools"| RS["Re-stamp fingerprint"]
D -->|"tool removed"| NA["Narrow: drop binding"]
D -->|"new reviewed read"| PW["Re-stamp kept tools; the new tool waits for confirm"]
D -->|"no policy yet (new integration)"| PN["Disabled placeholder,<br/>wait for confirm"]
H -. "failure is logged,<br/>write still succeeds" .-> L["Boot sweep and next<br/>setup run repair it"]Daily Insights copy
flowchart TD
Tick["observationbeat tick"] --> G{"History capture on,<br/>not recovery mode?"}
G -->|no| Stop["Skip"]
G -->|yes| O["Businesses with a completed setup"]
O --> Z{"Valid time zone?"}
Z -->|no| Log["Skip and log once"]
Z -->|yes| Day["Last business day that ended"]
Day --> W{"Ended less than<br/>6 hours ago?"}
W -->|no| Miss["Day stays without a copy"]
W -->|yes| Has{"Copy already exists, or a<br/>collection job with insights<br/>started since it ended?"}
Has -->|yes| Done["Nothing to do"]
Has -->|no| F["Freeze one copy<br/>(insight_publication archive,<br/>trigger business_day)"]
F -->|failure| Retry["Log, retry in 5 minutes"]flowchart TD
Tick["observationbeat tick"] --> G{"History capture on,<br/>not recovery mode?"}
G -->|no| Stop["Skip"]
G -->|yes| O["Businesses with a completed setup"]
O --> Z{"Valid time zone?"}
Z -->|no| Log["Skip and log once"]
Z -->|yes| Day["Last business day that ended"]
Day --> W{"Ended less than<br/>6 hours ago?"}
W -->|no| Miss["Day stays without a copy"]
W -->|yes| Has{"Copy already exists, or a<br/>collection job with insights<br/>started since it ended?"}
Has -->|yes| Done["Nothing to do"]
Has -->|no| F["Freeze one copy<br/>(insight_publication archive,<br/>trigger business_day)"]
F -->|failure| Retry["Log, retry in 5 minutes"]At most one copy is frozen per tick. The archive id comes from the business, integration, day and time zone, so retries never write a second copy.
Reading the Timeline
sequenceDiagram
autonumber
actor Staff
participant FS as Frontend server
participant API as GET /replays/timeline
participant DB as Postgres
participant S as Archive store
Staff->>FS: open Timeline, pick a range
FS->>API: read token, from, to, cursor
API->>DB: replaysEnabled? business active?
API->>DB: entries by available time, filtered by the read-time rule
API-->>FS: start state + up to 1,000 entries
Staff->>FS: open one entry
FS->>API: GET /replays/entries/{entryId}
API->>S: read object, verify hash and access
API-->>FS: content, or 410 when past retentionsequenceDiagram
autonumber
actor Staff
participant FS as Frontend server
participant API as GET /replays/timeline
participant DB as Postgres
participant S as Archive store
Staff->>FS: open Timeline, pick a range
FS->>API: read token, from, to, cursor
API->>DB: replaysEnabled? business active?
API->>DB: entries by available time, filtered by the read-time rule
API-->>FS: start state + up to 1,000 entries
Staff->>FS: open one entry
FS->>API: GET /replays/entries/{entryId}
API->>S: read object, verify hash and access
API-->>FS: content, or 410 when past retentionStarting a trial
sequenceDiagram autonumber actor Staff participant FS as Frontend server participant API as POST /replay-trials participant Day as Trial day service participant Snap as Packet freeze participant DB as Postgres Staff->>FS: day, initiative, purpose FS->>API: trial token API->>API: day in the last 13? fewer than 3 open trials? API->>Day: prepare(day, time zone) alt day has a packet, and (not set up, or its integrations are enabled and it is complete or current) Day->>DB: reuse it else set-up business Day->>DB: owners and recorded requests before the cutoff Day->>Snap: preview generated declaration Day->>Snap: freeze pruned declaration else not set up, no packet for the day Day->>Snap: freeze with the newest packet's declaration end Note over Day: not set up, packet's integration now disabled: 403 forbidden_source Day->>Day: runner integrity check, regenerate once if stranded API->>DB: replay environment request + eval-run row API-->>FS: 202 trial id, snapshot, omitted
sequenceDiagram autonumber actor Staff participant FS as Frontend server participant API as POST /replay-trials participant Day as Trial day service participant Snap as Packet freeze participant DB as Postgres Staff->>FS: day, initiative, purpose FS->>API: trial token API->>API: day in the last 13? fewer than 3 open trials? API->>Day: prepare(day, time zone) alt day has a packet, and (not set up, or its integrations are enabled and it is complete or current) Day->>DB: reuse it else set-up business Day->>DB: owners and recorded requests before the cutoff Day->>Snap: preview generated declaration Day->>Snap: freeze pruned declaration else not set up, no packet for the day Day->>Snap: freeze with the newest packet's declaration end Note over Day: not set up, packet's integration now disabled: 403 forbidden_source Day->>Day: runner integrity check, regenerate once if stranded API->>DB: replay environment request + eval-run row API-->>FS: 202 trial id, snapshot, omitted
Generating a day’s declaration
flowchart TD
C["Cutoff T = end of the business day"] --> Own["Required: organization, each existing profile,<br/>its profile memory (revision before T)"]
Own --> Ctx["Optional: published Context"]
Ctx --> Col["Optional: each Workspace feed's newest<br/>complete snapshot before T"]
Col --> TL["Optional: each integration's tool list<br/>(that day, else newest earlier)"]
TL --> Calls["Optional: the day's recorded calls,<br/>round-robin across integrations, busiest first"]
Calls --> Cap{"Over 50 external,<br/>100 total or 32 integrations?"}
Cap -->|yes| Om["Omitted: counted by kind and reason,<br/>written into the packet"]
Cap -->|no| Pre["Preview: drop slots that won't resolve"]
Om --> Pre
Pre --> Fr["Freeze: hashed packet"]flowchart TD
C["Cutoff T = end of the business day"] --> Own["Required: organization, each existing profile,<br/>its profile memory (revision before T)"]
Own --> Ctx["Optional: published Context"]
Ctx --> Col["Optional: each Workspace feed's newest<br/>complete snapshot before T"]
Col --> TL["Optional: each integration's tool list<br/>(that day, else newest earlier)"]
TL --> Calls["Optional: the day's recorded calls,<br/>round-robin across integrations, busiest first"]
Calls --> Cap{"Over 50 external,<br/>100 total or 32 integrations?"}
Cap -->|yes| Om["Omitted: counted by kind and reason,<br/>written into the packet"]
Cap -->|no| Pre["Preview: drop slots that won't resolve"]
Om --> Pre
Pre --> Fr["Freeze: hashed packet"]Task specs, failed or unhashed recordings, recorded Workspace writes, disabled integrations and scheduled-collection data other than Workspace change feeds are left out.
Workspace history
Workspace history records changes, not copies. Each scheduled run reads one Google change feed per resource, from the position the last complete run saved:
| Feed | Selection | Position | Expired position |
|---|---|---|---|
workspace_drive_changes | folderIds | Drive changes page token | 400 or 404: new baseline |
workspace_gmail_changes | labelIds | Gmail historyId | 404: new baseline |
workspace_calendar_changes | calendarIds | A sync token per calendar | 410: new baseline |
workspace_tasks_changes | every list | updatedMin of the last run | never expires |
The first run stores a baseline. Later runs store only changed items, a removal marker for each
deleted or deselected item, and the new position. A run’s snapshot holds the last complete
snapshot’s other items by reference, so the newest complete snapshot before a cutoff is the whole
state as of that cutoff. Positions move only with a complete snapshot. A new baseline is taken at
least every 30 days, so no snapshot leans on pages near their 90-day expiry. At freeze each feed is
an optional connector requirement; the Workspace reader rebuilds gws answers from its items. Nothing
calls Google at freeze or trial time.
Workspace CLI recordings split reads (gmail:read) from writes (gmail:write). The Standard preset
records reads; writes need their own binding and are never declared in a trial.
Existing baseline-referenced API
The older explicit staff Trial API stores a current-harness baseline’s profile IDs, catalog revisions and skill
selections in its replay environment request. A candidate references that trial in the same
organization, rechecks access to its exact frozen snapshot, and copies the initiative. The runner
checks the baseline’s recorded application image digests and model authentication mode before
preparation. It validates immutable catalog files, resolves the selected profiles’ packs and seeds
those pins in the isolated database. Inline developer/model overrides are rejected. Selected packs
can contain the declared prompts/task-run.json resource. The normal backend prompt loader reads
that resource and the normal builder renders the task input; the worker has no replay prompt branch.
Eval build metadata exposes the arm, content revision, selected profiles, effective packs, and the baseline trial ID for candidates. The metadata omits prompt text. The immutable pack retains the authored content and protected execution evidence includes the rendered initial prompt. The planning-only gateway, cutoff and source authorization continue to apply. Source visibility and the trial runner’s configuration can block a comparison when they change between arms. This legacy API is separate from the candidate editor, whose saved versions run independently without a baseline execution or reference.
Running a trial
sequenceDiagram autonumber participant R as Replay runner participant DB as Main Postgres participant S as Archive store participant D as Docker participant E as Replay environment loop every 5 seconds R->>DB: claim a preparing environment (lease) end R->>DB: read pinned packet and selection R->>S: read and verify archives R->>D: compose up isolated stack R->>E: readiness probes (write denial, clock, network) R->>DB: ready or ready_with_gaps R->>E: send the pinned initiative (idempotency key) E->>E: Steve works, writes become proposed actions R->>E: watch until done, failed, cancelled or time limit R->>E: export evidence (trajectory, outputs) R->>DB: finish eval run: outcome, usage, gaps, artifacts R->>D: remove containers, volumes, files
sequenceDiagram autonumber participant R as Replay runner participant DB as Main Postgres participant S as Archive store participant D as Docker participant E as Replay environment loop every 5 seconds R->>DB: claim a preparing environment (lease) end R->>DB: read pinned packet and selection R->>S: read and verify archives R->>D: compose up isolated stack R->>E: readiness probes (write denial, clock, network) R->>DB: ready or ready_with_gaps R->>E: send the pinned initiative (idempotency key) E->>E: Steve works, writes become proposed actions R->>E: watch until done, failed, cancelled or time limit R->>E: export evidence (trajectory, outputs) R->>DB: finish eval run: outcome, usage, gaps, artifacts R->>D: remove containers, volumes, files
The read-time rule
Writing a recording checks the integration’s exact permission fingerprint. Reading one back does not. A stored recording stays readable (Timeline, freeze, verify, replay) while:
- the integration belongs to the business,
- it is enabled, and
- it still offers the recorded operation: an enabled MCP tool, a custom MCP tool still reviewed as a read, an enabled Workspace service, or git for GitHub.
Renames, settings, repositories, grants, access mode, credentials and revisions do not retire it. Removing the tool or disabling the integration does; adding the tool back restores it. Collection pages, connector snapshots, attempts and Insights copies follow the same rule. Insights copies still pass live per-source access, and replay still checks the reading profile’s current grants. One rule serves TypeScript and the timeline’s SQL.
flowchart LR
Rec["Stored recording"] --> B{"Integration belongs<br/>to the business?"}
B -->|no| X["Not readable"]
B -->|yes| En{"Integration enabled?"}
En -->|no| X
En -->|yes| Op{"Still offers the<br/>recorded operation?"}
Op -->|no| X
Op -->|yes| OK["Readable<br/>(then hash and source access checks)"]flowchart LR
Rec["Stored recording"] --> B{"Integration belongs<br/>to the business?"}
B -->|no| X["Not readable"]
B -->|yes| En{"Integration enabled?"}
En -->|no| X
En -->|yes| Op{"Still offers the<br/>recorded operation?"}
Op -->|no| X
Op -->|yes| OK["Readable<br/>(then hash and source access checks)"]Consent and the preset
Consent covers a binding set per integration. The preset writes policies with managed_by = 'preset'
and never touches manual ones.
| Change | What happens |
|---|---|
| Same bindings, other edits | Re-stamped automatically |
| A tool removed, or no longer a reviewed read | Narrowed automatically |
| A new reviewed read tool | Pending until confirm; old bindings keep recording |
| A new integration after setup | Disabled placeholder; bindings wait for confirm |
| Integration disabled | Left as is |
| Credential refresh | Not followed; outside the fingerprint |
Staff turning recording off writes a disabled manual policy with no bindings. “Off by staff” is
derived: the latest completed recording change is recording_off and the stored revision is the one
it wrote. Turning it on writes the current Standard bindings as preset again, inside one
transaction with its event, after checking reviewed.
Business lifecycle
stateDiagram-v2 [*] --> NotSetUp NotSetUp --> Recording: apply (agreement) Recording --> Recording: confirm new tools / recording off or on Recording --> Paused: pause Paused --> Recording: resume Recording --> RemovalScheduled: remove (confirm id) Paused --> RemovalScheduled: remove (confirm id) RemovalScheduled --> Paused: cancel removal (within 7 days) RemovalScheduled --> Removed: 7 days pass (maintenance cycle) Removed --> Recording: resume, then apply with a new agreement NotSetUp: Not set up<br/>nothing recorded Recording: Recording<br/>replaysEnabled on Paused: Paused<br/>no new capture, history readable RemovalScheduled: Removal scheduled<br/>paused, cancellable Removed: Removed<br/>recordings, revisions, run captures expired<br/>replaysEnabled off, still paused<br/>archives wait for their own expiry
stateDiagram-v2 [*] --> NotSetUp NotSetUp --> Recording: apply (agreement) Recording --> Recording: confirm new tools / recording off or on Recording --> Paused: pause Paused --> Recording: resume Recording --> RemovalScheduled: remove (confirm id) Paused --> RemovalScheduled: remove (confirm id) RemovalScheduled --> Paused: cancel removal (within 7 days) RemovalScheduled --> Removed: 7 days pass (maintenance cycle) Removed --> Recording: resume, then apply with a new agreement NotSetUp: Not set up<br/>nothing recorded Recording: Recording<br/>replaysEnabled on Paused: Paused<br/>no new capture, history readable RemovalScheduled: Removal scheduled<br/>paused, cancellable Removed: Removed<br/>recordings, revisions, run captures expired<br/>replaysEnabled off, still paused<br/>archives wait for their own expiry
capture_paused_at on the run-input policy row is the pause. Every capture path checks it; reads never
do. The removal grace is removalGraceDays (7) in history-preset.repository.ts.
Authorization and tenancy
Backend replay tokens are not tied to one business. The business check lives in the frontend server. Keep the backend reachable only by the frontend server.
flowchart LR B["Browser"] -->|"Clerk session<br/>(verified staff email)"| FS["Frontend server"] FS -->|REPLAY_READ_TOKEN| R1["timeline · entries · eval-runs"] FS -->|REPLAY_TRIAL_TOKEN| R2["replay-trials"] FS -->|REPLAY_SETUP_TOKEN| R3["replays/setup"] Op["Operator tools"] -->|AGENT_SERVICE_TOKEN| R4["replay-environments<br/>(Replay control API)"] Agents["Agents"] -. "no replay tokens" .-x R1 subgraph BE["Backend: each group accepts only its own token"] R1 R2 R3 R4 end
flowchart LR B["Browser"] -->|"Clerk session<br/>(verified staff email)"| FS["Frontend server"] FS -->|REPLAY_READ_TOKEN| R1["timeline · entries · eval-runs"] FS -->|REPLAY_TRIAL_TOKEN| R2["replay-trials"] FS -->|REPLAY_SETUP_TOKEN| R3["replays/setup"] Op["Operator tools"] -->|AGENT_SERVICE_TOKEN| R4["replay-environments<br/>(Replay control API)"] Agents["Agents"] -. "no replay tokens" .-x R1 subgraph BE["Backend: each group accepts only its own token"] R1 R2 R3 R4 end
- Staff gate. The frontend server serves Replays only with Clerk sign-in on, to a user with a
verified
@skyfall.aiemail. Setup changes send that email as the actor; the browser never sends one. Trial start and cancel send only the staff user id, for the audit line. - One token per route group.
REPLAY_READ_TOKEN(timeline, entries, eval runs),REPLAY_TRIAL_TOKEN(trial options, start, cancel),REPLAY_SETUP_TOKEN(setup). Each route group accepts only its own token and refuses agent capabilities and every other service token. A missing or repeated token makes those routes answer503, and env validation rejects a repeat. - Agents never hold them. The stack writes the tokens to the backend and frontend server env only.
- Replay control API (
/replay-environments) usesAGENT_SERVICE_TOKEN; scoped agent tokens cannot use it. - Audit. Setup and trial routes write one audit line per call, served or refused, including refusals before authorization. Agreement text stays in the consent record, never in logs.
- Source access. Every archive read rechecks current tenant and source access, before and after. In a replay environment, a source-authority relay asks the live backend.
Cutoff correctness
flowchart LR subgraph Before["Before T"] A["Source finished<br/>and confirmed"] end subgraph After["At or after T"] B["Finished before T,<br/>confirmed after T"] C["Saved after T about<br/>an earlier time"] D["Answer holding a record<br/>dated at or after T"] end A -->|selected| Use["Visible to the trial"] B -->|refused| No["Never visible"] C -->|refused| No D -->|"cutoff guard: post_cutoff_evidence"| No
flowchart LR subgraph Before["Before T"] A["Source finished<br/>and confirmed"] end subgraph After["At or after T"] B["Finished before T,<br/>confirmed after T"] C["Saved after T about<br/>an earlier time"] D["Answer holding a record<br/>dated at or after T"] end A -->|selected| Use["Visible to the trial"] B -->|refused| No["Never visible"] C -->|refused| No D -->|"cutoff guard: post_cutoff_evidence"| No
- A source counts at T only when it finished strictly before T and its evidence-availability record was confirmed strictly before T. Nothing is backdated.
- The business day ends at the next UTC midnight; trials fall back to UTC.
- Generated declarations take internal-state revisions and recordings known before the cutoff.
- In the environment, one guard (
services/replay/sources/connectors/cutoff.ts) refuses any request window past T and any answer holding a record dated at or after T (post_cutoff_evidence). - Insights answers use the business clock:
generatedAtequals T. - The worker’s business time is fixed at T through the run context, prompt and a
dateshim. System timers use real time.
Inside a replay environment
flowchart TB
subgraph Env["Replay environment (Docker project per trial)"]
BE["backend<br/>recorded readers + cutoff guard"]
WK["worker<br/>Steve (Codex)"]
PG[("postgres")]
Q[("queue")]
GA[("garage")]
DB[("mongo / business-redis<br/>restored backups, optional")]
SA["source-authority relay"]
MG["model-gateway relay"]
BS["bootstrap<br/>(seed, no background jobs)"]
end
Live["Live backend<br/>source access checks"]
Model["Model provider"]
Net["Public internet and<br/>live providers"]
WK --> BE
WK --> MG
WK --> Q & GA
BE --> PG & Q & GA & DB
BE --> SA
SA -->|"current source access"| Live
MG -->|"Responses inference only"| Model
WK -. blocked .-x Net
BE -. blocked .-x Netflowchart TB
subgraph Env["Replay environment (Docker project per trial)"]
BE["backend<br/>recorded readers + cutoff guard"]
WK["worker<br/>Steve (Codex)"]
PG[("postgres")]
Q[("queue")]
GA[("garage")]
DB[("mongo / business-redis<br/>restored backups, optional")]
SA["source-authority relay"]
MG["model-gateway relay"]
BS["bootstrap<br/>(seed, no background jobs)"]
end
Live["Live backend<br/>source access checks"]
Model["Model provider"]
Net["Public internet and<br/>live providers"]
WK --> BE
WK --> MG
WK --> Q & GA
BE --> PG & Q & GA & DB
BE --> SA
SA -->|"current source access"| Live
MG -->|"Responses inference only"| Model
WK -. blocked .-x Net
BE -. blocked .-x NetEach environment has its own Postgres, queue, object storage and worker workspace. Firewalls allow only
in-stack destinations. Writes become actions in the isolated database (proposed or approved) and are
never executed. The model gateway rejects hosted search, remote MCP and other live tools. Service names
come from createReplayCompose in helpers/replay-stack.helper.ts.
Environment and trial lifecycle
stateDiagram-v2 [*] --> preparing: trial start (202) preparing --> ready: probes pass preparing --> ready_with_gaps: probes pass, gaps reported preparing --> blocked: unrecoverable ready --> running: initiative sent ready_with_gaps --> running: initiative sent running --> releasing: done, failed or cancelled running --> releasing: time limit (timed_out) blocked --> releasing ready --> releasing: cancel ready_with_gaps --> releasing: cancel preparing --> releasing: cancel releasing --> released: evidence exported, stack removed released --> [*] running: initiative running<br/>(environment status stays ready)
stateDiagram-v2 [*] --> preparing: trial start (202) preparing --> ready: probes pass preparing --> ready_with_gaps: probes pass, gaps reported preparing --> blocked: unrecoverable ready --> running: initiative sent ready_with_gaps --> running: initiative sent running --> releasing: done, failed or cancelled running --> releasing: time limit (timed_out) blocked --> releasing ready --> releasing: cancel ready_with_gaps --> releasing: cancel preparing --> releasing: cancel releasing --> released: evidence exported, stack removed released --> [*] running: initiative running<br/>(environment status stays ready)
For a stack with evidence to export, the runner stops the worker before stopping the model gateway and copying evidence. Docker allows 60 seconds for the worker to stop, including its 30-second shutdown budget for aborting runs, syncing partial output and reporting failure. This time budget allows an orderly flush when dependencies respond.
The trial finishes in the transaction that records the verified evidence manifest. Release retries
retain recorded timeout and cutoff guard gaps. A recorded timeout produces timed_out even if
the initiative completes before export.
Limits
| Limit | Value | Where |
|---|---|---|
| Bindings per observation policy | 200 | history-preset.helper.ts |
| Requirements per declaration | 100 | historyRequirementLimit |
| External requirements per declaration | 50 | historyExternalRequirementLimit |
| Integrations per environment | 32 | replayLimits.integrations |
| Standard retention | 90 days | standardRetentionDays |
| Removal grace | 7 days | removalGraceDays |
| Trial days offered / unfinished trials | 14 / 3 | replayTrialDays, replayTrialOpenLimit |
| Trial time limit | 60 min default | runner trialTimeLimitMinutes |
| Stale initiative send | 2 minutes | staleClaimMs |
| Recording wait per call | 5 s; 8 slots per process, 2 per business | recorded-interaction.service.ts |
Limits fail explicitly. Omissions are written into the packet. Nothing is truncated or filled with current data. Raising the 50 external cap needs a stored-schema widening rolled out to the runner first.
Failure handling
| Failure | Handling |
|---|---|
| Recording fails or is saturated | The business call still succeeds. A coverage gap or classified log is written. |
| Integration-write reconcile fails | Logged; never fails the write. The boot sweep and the next setup run repair it. |
| Setup interrupted | The event stays incomplete in status. Re-running setup finishes the work; the old event stays listed. |
| Insights day copy fails | Logged; retried after five minutes within the six-hour window. Other stages are unaffected. |
| Required owner briefly unreadable at freeze | Trial start fails with a retryable 503. |
| Required owner never readable | The day freezes as missing_data, naming the owner. |
| Packet no longer verifies | Regenerated once for a set-up business, else 409 naming the reason. |
| Runner restarts mid-send | A send idle for 2 minutes is resent with the same idempotency key; no second task. |
| Preparation blocked | The runner releases the environment; the trial finishes. |
| Due removal fails | Logged as history_removal_failed and retried on the next cycle. |
| Recovery mode | Capture, Insights copies and maintenance writes stop. |
| Deploy overlap | An older backend ignores the pause column outside the trigger. Don’t pause or remove during a deploy. |
Built and planned
Built on development: the timeline API and page, trials and eval runs, the replay runner, the
Standard preset and reconcile, on-demand day freezes, pause/resume/remove, collection seeds for
Stripe, Crisp, Paddle and GA4, daily Insights copies, the Setup tab with its page switch,
integration cards, per-integration recording and pause and remove, recordings surviving edits, and
Workspace history from change feeds, declared in a day’s snapshot.
Planned, not built:
- Pinning snapshot members a trial used, so they outlive the 90-day expiry.
- Turning daily collection on from the Setup tab.
- A Replays row on the Integrations page.
- Declaring scheduled-collection data in a day’s snapshot for connectors other than Workspace.
- Seeds for the remaining connectors.
- Recording health counts on the Setup tab.
The repository’s decision ledger and planning notes record why each part is the way it is.
Candidate editor and single-run admission
The full-page New trial workflow pins a historical snapshot and the currently assigned candidate packs. Snapshot harness files are editor references only; they do not schedule a baseline. Optional per-agent edits apply to the current candidate. Historical built-in model prompt text is not archived; the candidate uses the current replay runtime and historical model settings.
replay_candidates owns bounded typed patches, immutable source pins, CAS draft revisions, numbered
versions and parent lineage. File reads and writes use the existing staff Trial authorization. Paths,
UTF-8 and sizes are validated before materialization. Shared skills are cloned per edited profile,
so edits cannot affect other profiles. Generated packs hydrate only into the isolated sandbox store.
POST /replay-trials/candidates/{candidateId}/run verifies the saved content hash, retained snapshot
and current profile access, then creates exactly one environment and eval row. The existing admission
lock enforces the open-trial limit; retries reuse the same trial and conflicting versions are refused.
No baseline is created, rerun, selected, or mutated. Saved-version candidates carry their version ID
and do not require a baseline build or environment. Existing explicit baseline-referenced API callers
retain snapshot/build parity checks and accept pack substitutions only.
Trial detail exposes the candidate version before its build starts and uses the existing progress, output and evidence views. Candidate version readback remains available after snapshot expiry; execution revalidates retention and authorization. Baseline result linking, outcome comparison, evaluation and promotion are outside this flow. Git catalogs and live profile pins remain unchanged.
Task prompt content is declared by catalog.json.taskPrompt, validated during publication and
candidate saving, and included in the pack hash. readTaskPromptSource is shared by normal and
replay task execution. It returns the selected text plus a hash-pinned context descriptor, so capture,
workspace hydration and the execution claim use the same source. Declared missing/corrupt files fail;
old catalogs without the declaration use installed default text. Earlier virtual-field versions remain
readable, but save/iteration/admission reject them instead of silently changing their semantics.