Skip to content

feat(relay,verify): verify_after_edit MCP tools with deterministic style deltas (RFC 0002) - #58

Merged
Narrator merged 2 commits into
mainfrom
claude/domscribe-project-status-ejkwmw
Jul 29, 2026
Merged

feat(relay,verify): verify_after_edit MCP tools with deterministic style deltas (RFC 0002)#58
Narrator merged 2 commits into
mainfrom
claude/domscribe-project-status-ejkwmw

Conversation

@Narrator

Copy link
Copy Markdown
Member

Implements the post-edit verification loop that the v3 annotation schema (verifyHistory, VerifyResult) was built for — the RFC 0002 Task B work the sprint 3071 baseline doc left open.

What this adds

Two new MCP tools on the relay (14 total now):

  • domscribe.verify.baseline — called before an edit. Captures a snapshot of the target element from the live page over the existing WS context channel: the RFC 0001 computed-style allowlist plus the element's bounding rect. Returns a baselineId. Baselines are in-memory and session-scoped (max 100, oldest evicted).
  • domscribe.verify.afterEdit — called after the edit + HMR. Re-captures, computes per-property style deltas and geometry deltas, and returns a deterministic VerifyResult verdict (match/partial/no_change/regression) derived from optional declared expectedChanges. Optionally appends the result to an annotation's verifyHistory.

Design: deltas first

The verdict is computed from computed-style and bounding-rect deltas, not pixel diffs: style deltas are exact, immune to anti-aliasing noise, and directly actionable in code (padding: 8px → 12px tells the agent what to fix). The verdict is intent-agnostic — the tool measures precisely; the calling agent judges whether a delta matches intent. pixelDiffRatio/screenshotRef stay reserved in the schema for a future element-scoped screenshot revision.

Degrades gracefully when runtime captureStyles is off: geometry-only change detection with an explanatory note and a hint (same pattern as query.bySource).

Changes by package

  • @domscribe/verify — new pure delta module: diffStyleMaps, diffBoundingRects (0.5 px epsilon), resolveVerdict, alongside the existing pixel comparator. Fully unit-tested.
  • @domscribe/relayVerifyService, POST /api/v1/verify/baseline + /api/v1/verify/check routes (house route-class pattern), RelayHttpClient methods, two MCP tool classes registered in the adapter. Integration-style specs with real services and a mocked WS server, per relay convention.
  • @domscribe/overlay — WS context:response now includes elementInfo.boundingRect (serialized DOMRect).
  • @domscribe/coreAPI_PATHS.VERIFY_BASELINE/VERIFY_CHECK constants (schemas already existed at v3).
  • docs — reconstructed docs/rfcs/0002-post-edit-verify-mcp-tool.md (fixes the dead link from docs/sprints/3071-rfc-0001-baseline.md); tool tables updated in the root and @domscribe/mcp READMEs.

Agent workflow

1. domscribe.query.bySource / domscribe.resolve  → entryId
2. domscribe.verify.baseline { entryId }         → baselineId
3. edit source, wait for HMR
4. domscribe.verify.afterEdit { baselineId, expectedChanges }
5. no_change → edit didn't land; partial/regression → consult deltas; match → done

Testing

  • nx run-many -t lint test build typecheck green for all 15 projects
  • New specs: 24 delta-module cases, 12 route integration cases (including annotation verifyHistory append and browser-disconnect paths), 11 MCP tool cases; adapter/tool-defs specs updated for the 14-tool surface

🤖 Generated with Claude Code

https://claude.ai/code/session_01QdBkwcY2Wx1KSCgPWV5xtS


Generated by Claude Code

…yle deltas (RFC 0002)

Implements the post-edit verification loop the v3 annotation schema was
built for. Two new MCP tools on the relay:

- domscribe.verify.baseline — captures a pre-edit snapshot (RFC 0001
  computed-style allowlist + bounding rect) of a rendered element over
  the existing WS context channel; baselines are in-memory and
  session-scoped (max 100, oldest evicted)
- domscribe.verify.afterEdit — re-captures, computes per-property style
  deltas and geometry deltas, and returns a deterministic VerifyResult
  verdict (match/partial/no_change/regression) derived from optional
  declared expectedChanges; optionally appends to an annotation's
  verifyHistory

Verdicts are deltas-first by design: computed-style deltas are exact,
noise-free, and directly actionable, unlike pixel diffs or vision-model
judgment. The pixelDiffRatio/screenshotRef path in the schema stays
reserved for a future revision.

- @domscribe/verify: new pure delta module (diffStyleMaps,
  diffBoundingRects, resolveVerdict) alongside the pixel comparator
- @domscribe/relay: VerifyService, POST /v1/verify/baseline and
  /v1/verify/check routes, HTTP client methods, MCP tool registration
- @domscribe/overlay: WS context responses now include the element's
  bounding rect
- docs: reconstructed RFC 0002 (fixes the dead link from the sprint
  3071 baseline doc); tool tables updated in root and mcp READMEs

Degrades gracefully when runtime captureStyles is off: geometry-only
change detection with an explanatory note and a hint to enable styles.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QdBkwcY2Wx1KSCgPWV5xtS
@nx-cloud

nx-cloud Bot commented Jul 29, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit e366b69

Command Status Duration Result
nx run domscribe-test-fixtures:integration--web... ✅ Succeeded 1m 35s View ↗
nx run domscribe-test-fixtures:integration--web... ✅ Succeeded 1m 35s View ↗
nx run domscribe-test-fixtures:integration--web... ✅ Succeeded 1m 34s View ↗
nx run domscribe-test-fixtures:integration--web... ✅ Succeeded 1m 34s View ↗
nx run domscribe-test-fixtures:install-fixture-... ✅ Succeeded 40s View ↗
nx run domscribe-test-fixtures:install-fixture-... ✅ Succeeded 36s View ↗
nx run domscribe-test-fixtures:install-fixture-... ✅ Succeeded 39s View ↗
nx run domscribe-test-fixtures:install-fixture-... ✅ Succeeded 25s View ↗
Additional runs (18) ✅ Succeeded ... View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-07-29 04:49:01 UTC

…alls

npm install fails for the nuxt fixtures with an arborist crash
("Cannot read properties of null (reading 'edgesOut')" in #loadPeerSet)
that reproduces with a bare 'npm install nuxt' and no @domscribe
packages at all: nuxt -> @nuxt/devtools -> @vitejs/devtools@* resolves
to the new 0.4.x devtools family, whose peer topology triggers a known
npm arborist bug. Pre-existing on main; surfaced on this PR because CI
reinstalls fixtures on every run.

Pin @vitejs/devtools to ^0.3.0 via npm overrides in both nuxt fixtures
and the generator template until upstream npm/devtools resolve it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QdBkwcY2Wx1KSCgPWV5xtS
@Narrator
Narrator merged commit f3e5836 into main Jul 29, 2026
24 checks passed
@Narrator
Narrator deleted the claude/domscribe-project-status-ejkwmw branch July 29, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants