vibe-sketcherDocumentation

vibesketcher.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-sketcher 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 vibesketcher.server.store.Conflict(current, given)[source]

Bases: RuntimeError

The write named a revision that is no longer current.

Parameters:
Return type:

None

class vibesketcher.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-sketcher.

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

Bases: KeyError

No document with that id.

class vibesketcher.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]

Add a document; a supplied file binding must describe that same document.

Use open() to parse and bind a file in one read. For compatibility, callers may still supply both a document and path, but stale or edited contents cannot be paired with that file’s current digest. A missing destination starts unsaved and may be created by its first save.

Parameters:
Return type:

Entry

open(path)[source]

Read and bind one file snapshot, or a new unsaved document if absent.

Parameters:

path (Path)

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, or its path no longer resolves to the destination selected by add().

Parameters:

identifier (str)

Return type:

Entry