Recursive AI

Session file .oscope (version 1)

All onescope docs

The open sources of a session, the forks with their poke replays, the shared time cursor, and an opaque blob the shell uses for layout and cameras. All integers are little endian. Reading a session and writing it again gives the same bytes.

Header (24 bytes)

OffsetSizeField
04magic OSCP
42version, 1
62flags, 0
88time cursor, an absolute step number, 0 or more (i64)
164source count, at most 4096
204layout length, at most 16 MiB

Sources

Source count records follow the header, parents before their forks. Each has a 27-byte fixed part, then three strings, then a payload:

OffsetSizeField
01kind: 0 embedded, 1 referenced
14parent source index, or -1; always an earlier source (i32)
58fork step, an absolute step number of the parent; 0 when there is no parent (i64)
134keyframe interval for the source's history, at least 1
172module id length, 1 to 4096
192name length, 0 to 4096
212path length, 0 to 4096; 0 for embedded, at least 1 for referenced
234payload length

then the module id, name and path as UTF-8, then the payload:

  • Embedded: the source's replay in the module's own replay format. A fork is always embedded, because its replay holds the pokes; its parent index and fork step say what it was forked from.
  • Referenced: a 32-byte SHA-256 of the file as it was when saved. Opening the session reads the file by its path and refuses one whose hash differs.

After the last source come exactly layout-length bytes of layout, then the end of the file. The SDK never interprets them.

Limits and errors

The reader enforces a file size limit (1 GiB by default), the source and layout limits above, and checks every length against the bytes that remain before allocating. Errors are ScopeFormatException naming the input and what was expected at which offset or source.

Opening

SessionRestore.Open opens each source with the module whose id it names, builds a history for each at the saved cursor, and for a fork computes its divergence from its parent's recording. A fork reopens from its own replay, so it reproduces the hashes it had when saved.