Reintent

@reintent/scene/verify

The verifier: what an agent runs right after it writes a scene.

Each failure says what to do about it: the report is read by whoever wrote the scene, which is often a model.

declared       every data-sem path and every <Draw> names a declared thing and one of its parts
expected       each still shows what it says it shows
deterministic  the same moment, drawn twice, is the same pixels
coverage       every pixel drawn belongs to some thing (atmosphere aside)
local          turning a param (or a piece of state) moves only its own instance (or the parts
               it declares it affects), and nothing else in the scene
phase          every declared phase has a still, and each still gets the scene into its phase
language       every word the language layer resolves names something declared
atmosphere     no atmosphere covers most of the frame on its own: what is drawn large is a thing

A running scene verifies itself through window.__scene.verify() (@reintent/scene/stage); the checks that read only data run anywhere.

Interfaces

Issue

Defined in: packages/scene/src/verify.ts

One thing the verifier found, and what to do about it.

Properties

PropertyTypeDescription
check| "expected" | "phase" | "declared" | "deterministic" | "coverage" | "local" | "language" | "atmosphere"-
messagestring-
still?stringThe still it was found at.

Report

Defined in: packages/scene/src/verify.ts

What the verifier found.

Properties

PropertyTypeDescription
atmosphereobject[]-
checkedobject-
checked.paramsnumber-
checked.pathsnumber-
checked.stillsnumber-
checked.wordsnumber-
coverageobject[]-
issuesIssue[]-
okboolean-
perturbationsobject[]One line per param (or piece of state) that was turned: what moved.

VerifyDeps

Defined in: packages/scene/src/verify.ts

A running scene, as the verifier drives it: <Stage> gives these to it.

Properties

PropertyType
clockClock
goto(name) => void
isPlaying() => boolean
languageLanguageLayer | null
phase() => string | null
play() => void
registryRegistry
stillsreadonly Still[]
svg() => SVGSVGElement | null
timelineTimelineSpec

Functions

languageIssues()

function languageIssues(language): Issue[];

Defined in: packages/scene/src/verify.ts

The language check: every span and concept of the language layer resolves to something declared (a thing, one of its parts, or a beat, phase or input of the declared timeline).

Parameters

ParameterType
languageLanguageLayer | null

Returns

Issue[]

Example

import { semantic } from '@reintent/scene/svg';
import { languageIssues } from '@reintent/scene/verify';

semantic({ id: 'wardrobe', kind: 'prop', aka: ['衣柜'], parts: ['door'] }, () => null);
const issues = languageIssues({
  prompt: [['衣柜门', 'wardrobe.door'], '打开'],
  concepts: [],
});
console.log(issues, languageIssues({ prompt: [['灯', 'lamp']], concepts: [] }).length);
// → [] 1

localMoves()

function localMoves(
   path, 
   affects, 
   before, 
   after
): object;

Defined in: packages/scene/src/verify.ts

The locality check, on two measurements: which paths moved when a param of path was turned, and which of them it should not have moved (anything outside its instance, or outside the parts the param says it affects).

Parameters

ParameterType
pathstring
affectsreadonly string[] | undefined
beforeReadonlyMap<string, Box>
afterReadonlyMap<string, Box>

Returns

object

NameType
movedstring[]
straystring[]

Example

import { localMoves } from '@reintent/scene/verify';

const box = (x0: number) => ({ x0, y0: 0, x1: x0 + 10, y1: 10, px: 0 });
const before = new Map([
  ['man.hat', box(0)],
  ['lamp', box(40)],
]);
const after = new Map([
  ['man.hat', box(2)],
  ['lamp', box(45)],
]);
console.log(localMoves('man', ['hat'], before, after));
// → { moved: [ 'man.hat', 'lamp' ], stray: [ 'lamp' ] }

phaseIssues()

function phaseIssues(timeline, stills): Issue[];

Defined in: packages/scene/src/verify.ts

The phase check, on the declarations: every phase of the timeline has a still that goes there.

Parameters

ParameterType
timelineTimelineSpec
stillsreadonly Still[]

Returns

Issue[]

Example

import { phaseIssues } from '@reintent/scene/verify';

const timeline = { beats: {}, phases: { asleep: {}, awake: {} } };
const issues = phaseIssues(timeline, [{ name: 'night', phase: 'asleep' }]);
console.log(issues.map((i) => i.message));
// → [ 'Phase "awake" has no still. Add one ({ name, phase: "awake", expect }) so it can be seen, checked and pointed at.' ]

verify()

function verify(deps): Promise<Report>;

Defined in: packages/scene/src/verify.ts

Runs every check on a running scene: goes to each still, measures it, draws it twice, turns each number param once, and comes back to where it was.

Parameters

ParameterType
depsVerifyDeps

Returns

Promise<Report>

Last updated on

Edit on GitHub