nw.bodies#
Body schemas for nw’s project-graph annotations.
Importing this package registers the schemas with lacing so any annotation
with a matching body_schema_uri validates correctly. The schemas are:
annot://schema/section/v1— timeline section (verse, scene-1, …)annot://schema/shot/v1— renderable visual unitannot://schema/character-ref/v1— pointer to a character folderannot://schema/environment-ref/v1— pointer to an environment folderannot://schema/decision/v1— provenance-rich decision log entryannot://schema/render-result/v1— output of a render Transformannot://schema/verifying-trace/v1— upstream value digests, for early cutoffannot://schema/unproduced-output/v1— why a planned output was never produced (nw#44), retired by a later successful retryannot://schema/genre-envelope/v1— the resolved {genre, template, params} the project was created as (singleton per project)
These are deliberately small and project-agnostic. Reelee will be able to walk the same graph for freshness analysis (“what’s downstream of this character description?”) without bespoke storage.
Functions
|
Build the trace annotation for one derived annotation, or |
Classes
|
Body of a character-ref annotation. |
|
Body of a decision annotation. |
|
Body of an environment-ref annotation. |
|
Body of the (singleton) genre-envelope annotation. |
|
Body of a render-result annotation. |
|
Body of a section annotation. |
|
Body of a shot annotation. |
|
Body of an unproduced-output record. |
|
One |
|
Body of a verifying-trace annotation. |
- class nw.bodies.CharacterRefBodyV1(**data)[source]#
Bases:
BaseModelBody of a character-ref annotation.
Every field beyond
nameis optional with a benign default, so dumps written by any earlier version of this schema load unchanged — this is an additive enrichment of v1, not a new version, and needs no lacing migration.
- class nw.bodies.DecisionBodyV1(**data)[source]#
Bases:
BaseModelBody of a decision annotation.
kindnames the operation (e.g."render_shot","set_character_anchor","clone_project").payloadis a free-form dict so producers don’t need a schema-versioned table per kind. If a kind earns a richer schema later, it can graduate into its own body URI without disturbing this one.
- class nw.bodies.EnvironmentRefBodyV1(**data)[source]#
Bases:
BaseModelBody of an environment-ref annotation.
- class nw.bodies.GenreEnvelopeBodyV1(**data)[source]#
Bases:
BaseModelBody of the (singleton) genre-envelope annotation.
Field-for-field the
nw.genres.resolve_genre()envelope, so the persisted record and the creation-time contract can never drift apart.
- class nw.bodies.RenderResultBodyV1(**data)[source]#
Bases:
BaseModelBody of a render-result annotation.
- class nw.bodies.UnproducedOutputBodyV1(**data)[source]#
Bases:
BaseModelBody of an unproduced-output record.
statusmirrorsnw.transforms.fanout.UnitStatus’s two unproduced cases:"failed"(the call itself failed) or"blocked"(an upstream call in the same plan failed first).upstreamis stored for thecall_indexfallback identity (see the module docstring); it is not itself a sufficient key.
- class nw.bodies.UpstreamDigestV1(**data)[source]#
Bases:
BaseModelOne
(upstream annotation, its value digest)pair.
- class nw.bodies.VerifyingTraceBodyV1(**data)[source]#
Bases:
BaseModelBody of a verifying-trace annotation.
digest_schemeis recorded rather than assumed: lacing documents that changingVALUE_FIELDSor the canonicalisation is a breaking cache-invalidation event and bumps the scheme string. A trace written under an older scheme is not comparable, sonw.freshnesstreats the mismatch as unverifiable (therefore stale) instead of comparing digests that mean different things.
- nw.bodies.build_verifying_trace(*, for_annotation_id, parent_ids, upstream, asset_id)[source]#
Build the trace annotation for one derived annotation, or
None.- Parameters:
for_annotation_id (
UUID) – Id of the annotation being described.parent_ids (
Iterable[UUID|str]) – Itsprovenance.was_derived_from— annotation ids (UUID) and artifact asset ids (64-hexstr, nw#55). Duplicates are collapsed, order preserved.upstream (
Sequence[Annotation]) – The resolved parent annotations. **Must cover every annotation id in ``parent_ids``** — a trace that omits a parent would let that parent change unnoticed. Asset ids need no resolving: they are recorded as they are.asset_id (
str) – The project’s asset id, for the sentinel reference.
- Return type:
Optional[Annotation]- Returns:
The trace annotation, or
Nonewhen there is nothing to verify (no parents) or the trace would be incomplete (a parent could not be resolved, or its value could not be digested).Noneis the safe answer in both cases:nw.freshnessreads no trace as unverifiable, so the annotation keeps today’s conservative reachability behaviour instead of being silently declared fresh.
Modules
Body schema for character refs — pointers to a character folder. |
|
Body schema for decision-log entries. |
|
Body schema for environment refs. |
|
Body schema for the project's resolved genre envelope. |
|
Body schema for render results — the output of a render Transform. |
|
Body schema for timeline sections (verse, chorus, scene-1, …). |
|
Body schema for shots — the renderable visual unit. |
|
Body schema for unproduced-output records — nw#44. |
|
Body schema for verifying traces — what makes early cutoff possible. |