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)[source]

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>, result: 'dict[str, Any] | None'=None, digest: 'str | None' = None)[source]

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]
result: dict[str, Any] | None = None

What the QVF job container it was opened from says about its calculation.

digest: str | None = None

The file’s bytes as last read or written (digest_of()), so a save never replaces a change made outside vibe-sketch.

property dirty: bool[source]
exception vibesketch.server.store.NotFound[source]

Bases: KeyError

No document with that id.

class vibesketch.server.store.Store[source]

Bases: object

default_id: str | None

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

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

Entry

get(identifier)[source]
Parameters:

identifier (str)

Return type:

Entry

entries()[source]
Return type:

list[Entry]

replace(identifier, document, *, expected, warnings=None)[source]

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

Parameters:
Return type:

Entry

remove(identifier)[source]
Parameters:

identifier (str)

Return type:

None

save(identifier)[source]

Write the document back to the file it came from.

Refused with SaveRefused (a ValueError) when the file changed since it was opened or last saved.

Parameters:

identifier (str)

Return type:

Entry