Skip to content

osrforge.contracts.run

Run metadata: the run.json contract.

run.json is operational metadata — per-stage status, timestamps, and token usage for one conversion run. Timestamps are legal here and only here: the pure artifacts (adventure.json, report.json, previews) must contain none, or assembly purity's byte-stability guarantee dies.

StageState module-attribute

StageState = Literal['pending', 'running', 'completed', 'failed']

One stage's lifecycle state.

RunMeta

Bases: BaseModel

The run.json document: source identity, settings echo, and stage table.

schema_version class-attribute instance-attribute

schema_version: int = SCHEMA_VERSION

osrforge_version class-attribute instance-attribute

osrforge_version: str = Field(default_factory=osrforge_version)

source_sha256 instance-attribute

source_sha256: str

source_bytes class-attribute instance-attribute

source_bytes: int = Field(ge=0)

page_count class-attribute instance-attribute

page_count: int = Field(ge=0)

settings instance-attribute

provider class-attribute instance-attribute

provider: str | None = None

model_id class-attribute instance-attribute

model_id: str | None = None

stages instance-attribute

with_stage

with_stage(stage: Stage, status: StageStatus) -> RunMeta

Return a copy with one stage's status replaced.

Parameters:

Name Type Description Default
stage Stage

The stage to update.

required
status StageStatus

Its new status entry.

required

Returns:

Type Description
RunMeta

A new RunMeta; this one is unchanged.

with_model

with_model(provider: str, model_id: str) -> RunMeta

Return a copy with the provider and model identity set.

Parameters:

Name Type Description Default
provider str

The provider class name, e.g. FoundryProvider.

required
model_id str

The model identifier the service returned.

required

Returns:

Type Description
RunMeta

A new RunMeta; this one is unchanged.

Stage

Bases: StrEnum

The pipeline stage names, as run.json wire values.

These key run.json's stage table; changing one is a schema-version event. They do not name the stages/ cache files — the workdir layout pins those separately, and only the model-calling stages have caches. Geometry is deterministic and recomputed inside every assembly rather than cached; its run.json entry completes inside every assemble(), tracked separately so a failure in the build leaves an honest geometry: completed.

PREPROCESS class-attribute instance-attribute

PREPROCESS = 'preprocess'

SURVEY class-attribute instance-attribute

SURVEY = 'survey'

CONTENT class-attribute instance-attribute

CONTENT = 'content'

MONSTERS class-attribute instance-attribute

MONSTERS = 'monsters'

MAPREAD class-attribute instance-attribute

MAPREAD = 'mapread'

GEOMETRY class-attribute instance-attribute

GEOMETRY = 'geometry'

ASSEMBLE class-attribute instance-attribute

ASSEMBLE = 'assemble'

StageStatus

Bases: BaseModel

One stage's status entry in run.json.

status class-attribute instance-attribute

status: StageState = 'pending'

error class-attribute instance-attribute

error: str | None = None

started_at class-attribute instance-attribute

started_at: datetime | None = None

finished_at class-attribute instance-attribute

finished_at: datetime | None = None

usage class-attribute instance-attribute

usage: TokenUsage | None = None

TokenUsage

Bases: BaseModel

Model token consumption, as reported by the provider.

input_tokens class-attribute instance-attribute

input_tokens: int = Field(default=0, ge=0)

output_tokens class-attribute instance-attribute

output_tokens: int = Field(default=0, ge=0)