@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 thingA 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
| Property | Type | Description |
|---|---|---|
check | | "expected" | "phase" | "declared" | "deterministic" | "coverage" | "local" | "language" | "atmosphere" | - |
message | string | - |
still? | string | The still it was found at. |
Report
Defined in: packages/scene/src/verify.ts
What the verifier found.
Properties
| Property | Type | Description |
|---|---|---|
atmosphere | object[] | - |
checked | object | - |
checked.params | number | - |
checked.paths | number | - |
checked.stills | number | - |
checked.words | number | - |
coverage | object[] | - |
issues | Issue[] | - |
ok | boolean | - |
perturbations | object[] | 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
| Property | Type |
|---|---|
clock | Clock |
goto | (name) => void |
isPlaying | () => boolean |
language | LanguageLayer | null |
phase | () => string | null |
play | () => void |
registry | Registry |
stills | readonly Still[] |
svg | () => SVGSVGElement | null |
timeline | TimelineSpec |
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
| Parameter | Type |
|---|---|
language | LanguageLayer | 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);
// → [] 1localMoves()
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
| Parameter | Type |
|---|---|
path | string |
affects | readonly string[] | undefined |
before | ReadonlyMap<string, Box> |
after | ReadonlyMap<string, Box> |
Returns
object
| Name | Type |
|---|---|
moved | string[] |
stray | string[] |
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
| Parameter | Type |
|---|---|
timeline | TimelineSpec |
stills | readonly 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
| Parameter | Type |
|---|---|
deps | VerifyDeps |
Returns
Promise<Report>
Last updated on
Edit on GitHub