跳到正文
DEV Community· Paul Spread·· 42 分鐘前AI 評分41

無法偽裝「即時」的探索器:我們將誠實設為不變條件,並經審查修正問題

The UI That Can't Fake 'Live' - We Built an Explorer Whose Honesty Is an Invariant, Then Audited It Into Telling the Truth

AI 導讀

團隊建成連接正式 API 的唯讀 Next.js 探索器介面,讓信任狀態根據實際數據更新,並在資料不足或有分歧時呈現未知或不確定狀態。對抗性審查找出三項誠實機制的問題,團隊全部修正;驗證亦發現框架會把失效錯誤畫面永久快取成「即時」頁面,最終 55 項 HTTP 檢查全部通過。

正文

Short answer: the explorer shell is live against our production
API - a read-only Next.js surface where worlds mount map packages,
trusted adapters turn them into scene models, and a bounded proxy is
the only door to upstream data. The interesting part is what the UI
is forbidden to do: the trust banner is mounted outside package
content and recomputes its axes from real data on every poll, "I
don't know" is a first-class state (UNKNOWN, MIXED, unspecified,
dimmed-fallback), and fixture data carries a permanent REFERENCE
strip it cannot remove. An adversarial review found three places
where our honesty machinery was itself lying - we fixed all three -
and then our own verification script caught the framework caching a
dead error screen into a "live" page forever. 55 HTTP checks,
0 failures, real screenshots inside.

A museum window built from interlocking panes - a dark gallery wall where each glass pane is a labeled viewport (world, map, detail); behind the glass, glowing process nodes; a stamp marked TRUST sits on the frame itself, not on the exhibits

This is part of the Arc campaign series. Previous published episode:
proof you can recompute
(EPIC-237). This article is EPIC-268: the explorer shell and map
runtime - one presentation layer for every world, built so it
cannot bluff.

The problem: dashboards draw confidence, not data

Every observability tool has the same quiet failure mode: when the
data stops, the UI keeps its last confident face. Green stays green.
"Live" stays printed. The screen doesn't lie on purpose - it just
was never given a legal way to say "I don't know," so it says
whatever it last knew.

We noticed the risk while building the window for our own agent
economy. EPIC-267 gave us the contract: worlds, maps, processes,
typed trust metadata, pinned snapshots. But a contract only limits
what the API says. Nothing in it stops the surface on top from
rendering LIVE over an empty response.

For a junior: think of an aquarium vs a painting of an aquarium. A
painting always shows fish. An aquarium with a broken pump shows the
truth - murky water - and the honest thing is to put a sign on the
glass saying "pump broken," not to keep pointing at the painted fish
postcard taped next to it. EPIC-268 is the glass, the sign, and the
rulebook that decides when the sign must appear.

The sign on the glass - a robot agent holds a small placard labeled UNKNOWN over a museum display window whose inner lights have dimmed; other panes behind it stay bright with their own placards reading LIVE

What shipped: one mount pipeline for every world

The runtime, end to end - all of it running against the production
API today:

  • World index - / lists published worlds from /api/explorer/worlds, each card carrying its mode as a word (LIVE today) and links to its published maps.
  • Map packages - a world points at map IDs; each map is a versioned package (schema + limits + compat check) declaring its coordinate space, camera bounds, presentation hints, and which source types it serves. pof-map declares SCHEMATIC space and ["shipment"].
  • Trusted adapters - a code-registered registry (builtin:api, builtin:fixture, composite). Packages can't smuggle in renderers; data origin is derived from the adapter that actually ran, not from whatever the manifest claims.
  • Scene model + renderer - the adapter produces a canonical scene model; the PixiJS canvas draws it under a fixed isometric preset (rotation is impossible by construction), a camera bounded by the package's declared limits, and entities with no binding land on a deterministic dimmed periphery ring - we never invent coordinates for an unknown location.
  • Detail surface - selecting an object opens one surface with steps, timeline, and deterministic replay (play/pause/scrub at 1x/2x/4x over the canonical timeline - presentation, never recomputation).
  • Bounded proxy - the browser never talks upstream directly. One route allow-lists worlds|maps|processes, rejects traversal segments, whitelists headers in both directions, pins nosniff, relays ETag/304, and refuses to forward cookies.
  • Trust chrome - a sticky banner mounted outside package content on every surface, recomputed from real data on every poll cycle.

The mount pipeline on one card - world card to map package through the mount gate (schema, limits, compat), resolved by the trusted adapter registry into a canonical scene model, then rendered; a second lane shows the bounded proxy and the trust banner recomputing axes on every poll

The audit found our honesty was lying - in three places

We sent the finished implementation to an adversarial review
(0 critical, 3 high, 9 medium, ~12 nits - all fixed in one
sweep). The criticals are less interesting than the highs, because
all three were failures of the honesty machinery itself:

  • The banner could lie confidently. It computed trust axes once, at server render, and froze them. Poll for updates, lose the upstream, keep the page open - it would keep saying LIVE forever. Fixed: axes recompute from the actual entity cards on every poll. No cards means UNKNOWN in warn-tone, a disagreement means MIXED. The banner structurally cannot paint a confident LIVE over nothing.
  • The fixture mark could vanish. Whether a map was flagged as test data came from the package manifest - a field the package controls, on a code path (world-mounted maps) where it wasn't even read. Fixed: dataOrigin is derived from the adapter that ran, and the schema refuses inconsistent declarations before mount.
  • The detail page guessed its mode. It showed a LIVE chip without resolving which world/map actually serves that process. Fixed: it resolves through worlds to maps to servedSourceTypes; when the answer is ambiguous the chip honestly reads "unspecified."

That is the pattern worth stealing: we did not find places where
data could be wrong - we found places where our honesty layer could
be wrong.
Saying "we show UNKNOWN" is a promise; making UNKNOWN
the only thing renderable without data is an invariant.

The five lies and their fixes - five rows, each pairing the lie the surface could tell (a frozen LIVE banner over empty data, a vanishing FIXTURE mark, a guessed LIVE chip, a baked error screen, a silently empty canvas) with the invariant that now makes it impossible
Figure - five lies the surface could tell, and the invariant that
killed each. The first three came from the adversarial review; the
fourth from the owner verification script; the fifth from the
screenshot session for this very article.

Then our own verification found a fourth lie - in the framework

The sign-off script for this epic is 55 HTTP checks against the live
server: skip-links, banner stickiness, refusal screens for unmounted
and even prototype-key map IDs (/maps/constructor,
/maps/__proto__ return honest MAP_NOT_FOUND), proxy hardening,
keyboard-addressable replay, provenance rendered verbatim.

On the first full run it kept flagging the world index. The cause
was not the upstream - the API was fine. It was this:

  1. / was built as a static page (○ Static in the build log).
  2. At build time the API env var wasn't set, so the fetch failed - and the failure screen got baked into the static HTML forever.
  3. cache: "no-store" couldn't rescue it; the error boundary swallowed the dynamic bailout.
  4. export const dynamic = "force-dynamic"? Forbidden - this app runs Next 16 Cache Components mode.

The page was, quite literally, a cached lie - serving a rendered
error state to every visitor while the API behind it was healthy.
The fix is the only request-time API Cache Components leaves you:
await connection() inside the data-fetching components. Now every
data route is a static shell streaming live content (◐ Partial
Prerender
), and the rerun went 55 PASS / 0 FAIL / 0 SKIP.

Same check also flagged the page for "claiming verification" - the
text matched was the world's own description field, rendered
verbatim from upstream. We kept the data and narrowed the check to
shell chrome. Knowing which words are yours is part of honesty too.

And the screenshots for this article caught a fifth lie. Every
capture of the map page came back with a black canvas - banner,
entity list, everything correct except the scene itself, which was
empty in a way that was itself honest-looking: no error, just
nothing drawn. The Pixi mount effect ran once at mount, before the
async app.init() resolved, saw no render layers, and exited. A ref
doesn't trigger a re-render, and the model props don't change
between polls - so the draw effect never ran again. The canvas had
been silently empty for every visitor, and none of our 124 tests or
55 checks could see it: they assert on markup and logic, not on
pixels. A ready flag after init now re-runs the draw effects, and
the shots below are the fixed build - the green diamond on the map
is the first thing the canvas ever painted in front of a camera.

Look at the real thing

These are unretouched captures of the shell rendering production
data (the shipment dogfood-1794151620383, three custody hops,
13 canonical timeline events):

Real capture of the map surface - the trust banner pinned at top reading PHYSICAL / TESTNET / LIVE, the isometric scene canvas with a rendered process node, and below it the always-visible entity list that doubles as the screen-reader alternative
Real capture - /maps/pof-map on the live API: sticky trust banner
with observed axes, the scene node rendered on the canvas, and the
entity list that is always present as the text-first equivalent.

Real capture of the detail surface - steps with per-step trust badges, the hop chain rendered on canvas, replay controls with scrub and speed, and the canonical timeline as text equivalent
Real capture - /processes/dogfood-1794151620383: per-step trust,
the three-hop custody chain drawn with real edges, deterministic
replay over the canonical timeline.

Real capture of the reference map - permanent REFERENCE / TEST DATA strip, FIXTURE DATA chip, UNKNOWN axes, and the authored fixture scene with labeled hubs, actor, and process nodes connected by edges
Real capture - /maps/reference-map: the permanent REFERENCE strip
and FIXTURE DATA chip are chrome the package cannot remove; the
authored fixture scene renders through the same pipeline.

And here is the honesty machinery doing its least glamorous job -
refusing to render what isn't published:

Real capture of the refusal screen - MAP_NOT_FOUND state with role=alert for a map id that exists in JavaScript but not in the registry: the URL says /maps/constructor
Real capture - /maps/constructor: a JavaScript prototype key
asked as a map ID gets the same honest refusal as any unpublished
map. Lookups are Object.create(null)/hasOwn, so the trick has
nowhere to live.

You can touch the underlying contract yourself - no auth, read-only:

curl -s https://agentbadge.xyz/api/explorer/worlds
curl -s https://agentbadge.xyz/api/explorer/maps/pof-map
curl -s https://agentbadge.xyz/api/explorer/processes/dogfood-1794151620383

And the whole check battery is one script in the repo:
./scripts/verify-epic-268.sh prod - 55 checks, currently green.

Verify without trusting - a lone robot runs a checklist terminal beside the museum window; each line ticks green while one line is being re-run; the window behind shows the same data the terminal is checking

Design decisions worth stealing

  • Mount, don't render. A world never draws data; it mounts a package through a gate (schema, limits, compat) and resolves a code-registered adapter. New domains ship as packages, not forks.
  • "I don't know" is a state, not an edge case. UNKNOWN axes, MIXED disagreement, "unspecified" mode, dimmed fallback placement, declared-limits sections - each is designed, styled, and tested.
  • Truth labels live outside the content they describe. The trust banner is chrome the package cannot reach; marking is derived from code paths, not declared by the thing being marked.
  • The text alternative is primary, not an apology. The entity list and canonical timeline render always - the canvas is the convenience layer over them, and aria-describedby points at the real thing, not a generated summary.
  • Refusal is a screen, not a blank. Unmounted, unpublished, and hostile map IDs all get the same honest MAP_NOT_FOUND with role="alert".
  • Verify the surface, not the source. 124 unit tests check logic; the 55-check script checks what a browser actually receives - and that's the one that caught the framework caching a lie. And it still took a camera to catch what both missed: an empty canvas is valid markup.

Honest caveats

  • The shell is not publicly hosted yet - it runs against the production API from a dev server; the public deploy target is a program-tail decision still open. Screenshots above are real captures of that setup.
  • It's a polling UI by design: ETag/304 snapshots pinned to a registry version. "LIVE" means the world's declared mode, not a websocket - the banner says words, and the words mean what they say.
  • Exactly one source type is served on production today (shipment). The runtime is general; the catalog grows by publishing packages.
  • The upstream is IPv4-only at the moment - an ops quirk we document honestly because it cost us a debugging session.
  • The owner sign-off line in OWNER-VERIFY.md is the last manual step of the epic; the green 55/0/0 run it refers to is recorded.

What's next

With the shell verified, EPIC-270 - the program tail - is unblocked:
public hosting, more source adapters, more maps per world. The
runtime won't change; the packages will multiply.


For AI Agents

Machine-readable entry points used by this explorer, all read-only:

  • GET https://agentbadge.xyz/api/explorer/worlds - published worlds with mode, supportedReality, mapIds, and a pinned snapshot version.
  • GET https://agentbadge.xyz/api/explorer/maps/{id} - map package ref, coordinate space, served source types.
  • GET https://agentbadge.xyz/api/explorer/maps/{id}/processes - process cards for a map.
  • GET https://agentbadge.xyz/api/explorer/processes/{id} - full detail: steps, canonical timeline, typed trust, evidence metadata.
  • GET https://agentbadge.xyz/api/explorer/processes/{id}/timeline
    • paginated canonical timeline.

Unpublished or withdrawn IDs return 404 (NOT_FOUND /
PROCESS_HIDDEN). Trust fields are rendered verbatim from the
contract; ASSERTED/ADVISORY_ONLY mean provenance was declared and
verification signals are advisory - neither is a certification.

Want your agents to query real process data instead of screenshots?
The Agent Guide has the full machine-readable surface.

Read the arc

Don't certify. Measure.

來源:DEV Community · dev.to