vibesketch.server.store

The server’s documents: in memory, revisioned, optionally backed by a file.

Human and agent edit the same document through the revision counter (roadmap, section 3.2): every write names the revision it read, and a stale write gets a conflict and must re-read. A document opened from a file on the command line (vibe-sketch serve scheme.vsk) can be saved back to that file, and only to it: the HTTP API never takes a filesystem path.

Classes

Entry(id, document, path, saved_revision, ...)

Store()

Exceptions

Conflict(current, given)

The write named a revision that is no longer current.

NotFound

No document with that id.

exception vibesketch.server.store.Conflict(current, given)

Bases: RuntimeError

The write named a revision that is no longer current.

Parameters:
Return type:

None

class vibesketch.server.store.Entry(id: 'str', document: 'Document', path: 'Path | None' = None, saved_revision: 'int | None' = None, warnings: 'list[str]' = <factory>)

Bases: object

Parameters:
id: str
document: Document
path: Path | None = None

The file it was opened from and saves to, if any.

saved_revision: int | None = None

The revision last written to path.

warnings: list[str]
property dirty: bool
exception vibesketch.server.store.NotFound

Bases: KeyError

No document with that id.

class vibesketch.server.store.Store

Bases: object

default_id: str | None

The document the browser opens first, when the server was started with one.

add(document, *, path=None)
Parameters:
Return type:

Entry

get(identifier)
Parameters:

identifier (str)

Return type:

Entry

entries()
Return type:

list[Entry]

replace(identifier, document, *, expected, warnings=None)

Store document as the next revision, if expected is current.

Parameters:
Return type:

Entry

remove(identifier)
Parameters:

identifier (str)

Return type:

None

save(identifier)

Write the document back to the file it came from.

Parameters:

identifier (str)

Return type:

Entry