TerminalRecordingEntry is the Terminal-owned Entity for one ordered raw PTY recording entry. It stores replayable Terminal transport facts separately from the terminal record so input, output, resize, header, and exit facts can be appended, searched, and replayed without rewriting the Terminal record on every chunk.
TerminalRecordingEntry rows are raw transport evidence. They are not AgentExecution semantic journal records and do not decide AgentExecution lifecycle or owner workflow state.
Terminal-scoped ordered replay query with optional entry kind filter.
TerminalRecordingEntryInputSchema
Append input; the class creates id, assigns sequence, and validates entry-specific required fields.
TerminalRecordingEntryStorageSchema
Persisted terminal_recording_entry table record with reference/index/full-text metadata.
TerminalRecordingEntrySchema
Hydrated Entity data exposed across the Entity boundary.
TerminalRecordingEntryCollectionSchema
Ordered collection returned by find.
TerminalRecordingEntryInputSchema enforces entry-specific payload requirements: input and output require data; header and resize require both cols and rows; exit may carry a nullable exitCode.
ERD
erDiagram
TERMINAL ||--o{ TERMINAL_RECORDING_ENTRY : owns
TERMINAL_RECORDING_ENTRY {
string id PK
string terminalId FK
int sequence
string type
string occurredAt
string data
bool literal
int cols
int rows
int exitCode
}
The terminalId field is a canonical string id at the Entity boundary. The Surreal adapter converts it to a typed record<terminal> reference when writing or querying storage.
Append Flow
flowchart TD
A[TerminalRegistry update] --> B[Terminal recording persistence]
B --> C[TerminalRecordingEntry.append]
C --> D[Wait for per-Terminal append queue]
D --> E[Read last sequence for terminalId]
E --> F[Create next terminal_recording_entry row]
F --> G[Publish data.changed]
G --> H[Terminal.read hydrates ordered recordingEntries]
Replay Query Flow
flowchart TD
A[Terminal.read or replay caller] --> B[TerminalRecordingEntry.find]
B --> C[Parse TerminalRecordingEntryFindSchema]
C --> D[Wait for pending appends for terminalId]
D --> E[Query terminal_recording_entry by terminalId]
E --> F[Optional type filter]
F --> G[Order by sequence ASC]
G --> H[Return TerminalRecordingEntryCollectionSchema]
Cross-Control Checklist
Boundary
Status
Class
TerminalRecordingEntry.ts owns append sequencing, read, and find.
TerminalRecordingEntryContract.ts declares append/read/find and data.changed event metadata.
Storage
terminal_recording_entry.terminalId references terminal; terminalId + sequence is unique.
Reference metadata
terminalId is a zod-surreal reference to terminal with onDelete: cascade; adapter conversion keeps Entity code on canonical string ids.
Event publication
Appended recording rows publish through the generic Entity event capability and are validated against TerminalRecordingEntryContract.
Documentation finding
Append sequencing is serialized in-process per Terminal. Cross-daemon concurrent append would need a datastore transaction or sequence allocator.
Schema metadata finding
TerminalRecordingEntry has the strongest current metadata coverage of the three pages; nested enum/member wording should still be included in any repository-wide schema description audit.