Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat(x-content): let a post claim a growing count as a floor so it is not re-filmed every day

nirholas431867975de3
diff --git a/api/_lib/x-content/reel.js b/api/_lib/x-content/reel.js
index 5e8e2d602..5c3d91acd 100644
--- a/api/_lib/x-content/reel.js
+++ b/api/_lib/x-content/reel.js
@@ -211,8 +211,34 @@ export function proofProblems(item, root, now = Date.now()) {
return problems;
}
+// A fact as a number: "2,549 agents" and "2549" both read as 2549.
+export function factNumber(value) {
+ const match = /-?\d[\d,]*(?:\.\d+)?/.exec(String(value ?? ''));
+ return match ? Number(match[0].replace(/,/g, '')) : NaN;
+}
+
+// How each fact the run reads is held when the product is checked again. A
+// fact the copy states exactly (`equals`, `contains`, or a bare citation) must
+// still read the same, or the reel and the post are out of date. A fact the
+// copy states as a floor (`min`) only has to stay at or above it, so a count
+// that grows does not send a true post back to be filmed again. A fact no
+// claim cites may move freely: the reel is stamped with the day it was filmed.
+export function factRules(item) {
+ const rules = {};
+ for (const claim of item?.claims || []) {
+ for (const evidence of claim.evidence || []) {
+ if (evidence.type !== 'proof' || evidence.fact === undefined) continue;
+ const rule = (rules[evidence.fact] ||= { exact: false, min: -Infinity });
+ if (evidence.min !== undefined) rule.min = Math.max(rule.min, Number(evidence.min));
+ else rule.exact = true;
+ }
+ }
+ return rules;
+}
+
// A claim may cite the run: a fact it read off the screen, or a text it waited
-// for. `equals` and `contains` compare against the fact as it was read.
+// for. `equals` and `contains` compare against the fact as it was read, and
+// `min` holds it to a floor.
export function factCheck(evidence, proof) {
if (!proof) return { ok: false, detail: 'no proof on record' };
if (!proof.passed) return { ok: false, detail: 'the last run of the scenario failed' };
@@ -231,6 +257,11 @@ export function factCheck(evidence, proof) {
const ok = String(value) === String(evidence.equals);
return { ok, detail: `the run read ${evidence.fact} = "${value}"${ok ? '' : `; the claim needs "${evidence.equals}"`}` };
}
+ if (evidence.min !== undefined) {
+ const number = factNumber(value);
+ const ok = Number.isFinite(number) && number >= Number(evidence.min);
+ return { ok, detail: `the run read ${evidence.fact} = "${value}"${ok ? `, at least ${evidence.min}` : `; the claim needs at least ${evidence.min}`}` };
+ }
if (evidence.contains !== undefined) {
const ok = String(value).toLowerCase().includes(String(evidence.contains).toLowerCase());
return { ok, detail: `the run read ${evidence.fact} = "${value}"${ok ? '' : `; the claim needs it to contain "${evidence.contains}"`}` };
diff --git a/api/_lib/x-content/verify.js b/api/_lib/x-content/verify.js
index 47473df79..256dad18a 100644
--- a/api/_lib/x-content/verify.js
+++ b/api/_lib/x-content/verify.js
@@ -22,7 +22,7 @@ import { resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import { mentionsIn } from './editorial.js';
import { urlRe, urlsIn } from './quality.js';
-import { factCheck, loadProof, runScenario } from './reel.js';
+import { factCheck, factNumber, factRules, loadProof, runScenario } from './reel.js';
const UA = 'three.ws editorial verifier (+https://three.ws)';
const normalize = (text) => String(text || '').replace(/\s+/g, ' ').trim().toLowerCase();
@@ -300,9 +300,21 @@ async function commandProbe(probe, root) {
return { ok: false, detail: `exit ${run.status ?? run.signal}: ${tail}` };
}
-// The feature still works, and the reel still tells the truth about it: every
-// fact the run reads today has to be the fact the reel was filmed showing. A
-// count that has moved since is a stale reel, and the fix is to film it again.
+// The feature still works, and the post is still true of it. A fact the copy
+// states exactly has to read today what the reel was filmed showing; a fact it
+// states as a floor has to stay at or above it (factRules). A count that broke
+// either is a stale post, and the fix is to film it again.
+export function factDrift(item, proof, facts) {
+ const problems = [];
+ for (const [name, rule] of Object.entries(factRules(item))) {
+ const filmed = proof?.facts?.[name];
+ const live = facts[name];
+ if (rule.exact && live !== filmed) problems.push(`${name} is now "${live}", the reel shows "${filmed}"`);
+ if (Number.isFinite(rule.min) && !(factNumber(live) >= rule.min)) problems.push(`${name} is now "${live}", under the floor of ${rule.min} the post claims`);
+ }
+ return problems;
+}
+
async function scenarioProbe(item, root) {
const proof = loadProof(root, item.id);
const run = await runScenario(item.scenario, { film: false });
@@ -310,11 +322,10 @@ async function scenarioProbe(item, root) {
const failed = run.steps.find((step) => !step.ok);
return { ok: false, detail: `step ${failed.index} (${failed.kind} ${failed.target}): ${failed.detail}` };
}
- const drifted = Object.entries(proof?.facts || {}).filter(([name, value]) => run.facts[name] !== value);
- if (drifted.length) {
- return { ok: false, detail: `${drifted.map(([name, value]) => `${name} is now "${run.facts[name]}", the reel shows "${value}"`).join('; ')}; prove it again` };
- }
- return { ok: true, detail: `${run.steps.length} steps passed against the live product${Object.keys(run.facts).length ? `, facts unchanged (${Object.entries(run.facts).map(([name, value]) => `${name} ${value}`).join(', ')})` : ''}` };
+ const drift = factDrift(item, proof, run.facts);
+ if (drift.length) return { ok: false, detail: `${drift.join('; ')}; prove it again` };
+ const read = Object.entries(run.facts).map(([name, value]) => `${name} ${value}`).join(', ');
+ return { ok: true, detail: `${run.steps.length} steps passed against the live product${read ? `, every claimed fact still holds (${read})` : ''}` };
}
// `where` is 'review' (every probe) or 'publish' (api probes only).
diff --git a/docs/x-content-pipeline.md b/docs/x-content-pipeline.md
index 79fa5407f..24cfd8ac4 100644
--- a/docs/x-content-pipeline.md
+++ b/docs/x-content-pipeline.md
@@ -197,8 +197,10 @@ How it is filmed, and why:
- **The proof is bound to the post.** `data/x-content/proofs/<id>.json` records the hash of the
scenario and of the reel. Change a step, or swap the file, and the item no longer validates. A
proof expires after 14 days.
-- **Reviews run it again.** The `scenario` probe runs the steps unfilmed and compares every fact
- it reads with what the reel shows. A count that has moved is a stale reel: film it again.
+- **Reviews run it again.** The `scenario` probe runs the steps unfilmed. A fact the post states
+ exactly must still read what the reel shows; a fact it states as a floor (`min`) must stay at or
+ above it; a fact no claim cites may move. A fact that broke its rule is a stale post: film it
+ again.
A scenario needs a browser and ffmpeg, so reels are made where posts are reviewed. Production
only checks the record.
@@ -333,7 +335,7 @@ Evidence types:
| `module` | A repo module's `export` has `length` entries, or equals `equals` |
| `github-issue` | `repo#number` has the given `state` and `label` |
| `github-issues` | `repo` has at least `min` issues with the given `state` and `label` |
-| `proof` | The item's filmed run read the `fact` off the screen (`equals`, `contains`), waited for the text in `saw`, or got an answer from the path in `responded` |
+| `proof` | The item's filmed run read the `fact` off the screen (`equals`, `contains`, or at least `min`), waited for the text in `saw`, or got an answer from the path in `responded` |
Feature probes, in `probes`, run as part of every review, and the `api` ones run again seconds before a post goes out:
diff --git a/docs/x-story-authoring.md b/docs/x-story-authoring.md
index ba62f683c..44758ef72 100644
--- a/docs/x-story-authoring.md
+++ b/docs/x-story-authoring.md
@@ -205,15 +205,18 @@ evidence:
| Evidence | Passes when |
|---|---|
| `{ "type": "proof", "fact": "agents", "equals": "600" }` | the run read that fact off the screen (`contains` also works) |
+| `{ "type": "proof", "fact": "agents", "min": 500 }` | the run read a number at least that high; use it for a count that grows, written as "more than 500" |
| `{ "type": "proof", "saw": "Closest to" }` | the run waited for that text and saw it |
| `{ "type": "proof", "responded": "/api/galaxy" }` | an action in the run awaited that request and it answered without an error |
| `{ "type": "page", "url": "https://three.ws/x", "contains": "..." }` | the live page contains the text |
| `{ "type": "file", "path": "src/x.js", "contains": "..." }` | a file in the repo contains the text |
| `{ "type": "module", "path": "src/x.js", "export": "LIST", "length": 15 }` | an export has that many entries |
-A count that can change (agents, entries, downloads) will change. When it does, the next review
-fails and says the reel is stale, and the fix is to film it again. Prefer facts that hold: a price
-set by a tier, a limit in the code, what a tool does.
+A count that can change (agents, entries, downloads) will change. A fact cited exactly (`equals`,
+`contains`, or bare) must read the same at every review, so when it moves the review fails and the
+fix is to film again. A count that only grows is better written as a floor: "more than 500 agents",
+cited with `min`, stays true and only fails if the live number drops below it. Prefer facts that
+hold: a price set by a tier, a limit in the code, what a tool does.
When a post does state a count, give it a probe that runs seconds before the post goes out, so a
count that moved after the review holds the post instead of publishing it wrong. An `api` probe is
diff --git a/tests/x-content-reel.test.js b/tests/x-content-reel.test.js
index 5833cf04a..6e2ddbbe9 100644
--- a/tests/x-content-reel.test.js
+++ b/tests/x-content-reel.test.js
@@ -335,3 +335,31 @@ describe('site chrome', () => {
expect(sheet).toMatch(/\{display:none !important\}$/);
});
});
+
+describe('facts that move', () => {
+ it('reads a count however the page writes it', async () => {
+ const { factNumber } = await import('../api/_lib/x-content/reel.js');
+ expect(factNumber('2,549')).toBe(2549);
+ expect(factNumber('2,549 agents')).toBe(2549);
+ expect(factNumber('14000')).toBe(14000);
+ expect(factNumber('none')).toBeNaN();
+ });
+
+ it('holds a floor claim to its floor, not to the exact number filmed', () => {
+ const filmed = proof({ facts: { agents: '2,546' } });
+ expect(factCheck({ type: 'proof', fact: 'agents', min: 2500 }, filmed)).toEqual({ ok: true, detail: 'the run read agents = "2,546", at least 2500' });
+ expect(factCheck({ type: 'proof', fact: 'agents', min: 3000 }, filmed).ok).toBe(false);
+ });
+
+ it('lets a counted fact grow under a floor claim, and catches an exact one that moved', async () => {
+ const { factDrift } = await import('../api/_lib/x-content/verify.js');
+ const floor = item({ claims: [{ says: 'More than 2,500', evidence: [{ type: 'proof', fact: 'agents', min: 2500 }] }] });
+ const exact = item({ claims: [{ says: '600', evidence: [{ type: 'proof', fact: 'agents', equals: '600' }] }] });
+ const uncited = item({ claims: [] });
+ const filmed = proof({ facts: { agents: '2,546' } });
+ expect(factDrift(floor, filmed, { agents: '2,549' })).toEqual([]);
+ expect(factDrift(floor, filmed, { agents: '2,499' })).toEqual(['agents is now "2,499", under the floor of 2500 the post claims']);
+ expect(factDrift(exact, filmed, { agents: '2,549' })).toEqual(['agents is now "2,549", the reel shows "2,546"']);
+ expect(factDrift(uncited, filmed, { agents: '9' })).toEqual([]);
+ });
+});