Unverified explainer glue (drift risk)
// Calling draft APIs without feature detection, schema validation, or egress bounds
async function invokePageTool(name, args, container) {
// Assumes navigator.modelContext exists without schema or AbortSignal guards
const result = await navigator.modelContext.callTool(name, args);
// Unscoped iframe + permissive connect-src permits unlisted outbound fetches
const frame = document.createElement("iframe");
frame.src = "https://third-party.example/widget";
container.replaceChildren(frame);
// No PerformanceObserver marks or conformance assertions for native vs shim
return result;
}
Conformance-tested polyfill (this lab)
// public/app.js — feature-detected polyfills + 15-assertion conformance suite
import {
defineWebIslandElement, installModelContextPolyfill, runSpecConformanceSuite
} from "/lib/spec-polyfills.js";
defineWebIslandElement(window); // Attaches ElementInternals + FormData contract
installModelContextPolyfill(navigator, { performance });
navigator.modelContext.registerTool({
name: "lookup_spec",
inputSchema: { type: "object", required: ["query"], properties: { query: { type: "string", minLength: 2 } } },
execute: ({ query }) => ({ query, specs: ["webmcp", "connection-allowlists"] })
}, { signal: abortController.signal });
const report = await runSpecConformanceSuite({ navigator, window, performance, PerformanceObserver });
Complete Page Setup: Verbatim Assertions, Custom Element & Worker Probe Wiring
Mount elements in public/index.html, the 15-assertion SPEC_PROPOSALS check list,
<web-island> ElementInternals contract, navigator.modelContext
tool descriptor, PerformanceObserver collection, and Worker
/probe/connection-allowlist response headers.
<!-- 1. Page HTML Setup (public/index.html) -->
<form id="island-demo-form" class="island-form">
<web-island id="live-island" name="island_contract" island-id="sandbox-1"
capabilities="theme resize tool:lookup_spec tool:search" sandbox-policy="allow-scripts"></web-island>
</form>
<div id="suites-container" class="suites-grid"></div>
<iframe id="allowlist-probe-frame" class="probe-frame" title="Connection-Allowlist HTTP Header Probe"></iframe>
<script type="module" src="/app.js"></script>
// 2. 15-Assertion Conformance Suite, Tool Descriptor & ElementInternals Contract (public/lib/spec-polyfills.js)
// SPEC_PROPOSALS declares 3 specs x 5 assertions = 15 checks:
// - navigator-modelcontext: mc-surface-detect, mc-register-and-list, mc-schema-valid-exec,
// mc-schema-invalid-reject, mc-lifecycle-abort-and-provide
// - web-island-element: wi-registry-define, wi-element-internals, wi-capability-parse,
// wi-form-participation, wi-frame-contract-serialize
// - declarative-egress-guard: egress-empty-fail-closed, egress-malformed-fail-closed,
// egress-response-origin-match, egress-csp-connect-src, egress-guarded-fetch-block
class WebIslandElement extends env.HTMLElement {
static formAssociated = true;
static observedAttributes = ["capabilities", "island-id", "src", "sandbox-policy", "name"];
_syncInternals() {
this._internals.role = "region";
this._internals.setFormValue(JSON.stringify({ islandId, sandboxPolicy, capabilities: parsed.tokens }));
this._internals.setValidity(parsed.valid ? {} : { customError: true }, "Invalid capability token(s)");
}
}
const lookupToolDescriptor = {
name: "lookup_spec",
description: "Query matching spec proposal metadata via <web-island> capability tool:lookup_spec.",
inputSchema: {
type: "object",
properties: { query: { type: "string", minLength: 2 } },
required: ["query"],
additionalProperties: false
},
execute: async ({ query }) => ({
toolName: "lookup_spec",
query,
islandCapabilityGranted: getLiveIsland().allows("tool:lookup_spec")
})
};
// 3. Page Bootstrap, PerformanceObserver Runner & Edge Probe Headers (public/app.js + src/worker.ts)
defineWebIslandElement(window);
state.modelContextInstall = installModelContextPolyfill(navigator, { performance });
navigator.modelContext.registerTool(lookupToolDescriptor, { signal: controller.signal });
const globalPerfObserver = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
state.perfHistory.push({ entryType: entry.entryType, name: entry.name, startTime: entry.startTime, duration: entry.duration });
}
});
globalPerfObserver.observe({ entryTypes: ["mark", "measure"] });
const result = await runSpecConformanceSuite({ navigator, window, document, customElements: window.customElements, HTMLElement: window.HTMLElement, performance, PerformanceObserver: window.PerformanceObserver, ReportingObserver: window.ReportingObserver, origin: window.location.origin, probeResult: state.lastProbePayload || undefined });
// src/worker.ts GET /probe/connection-allowlist headers:
// "Connection-Allowlist": "()"
// "Reporting-Endpoints": `allowlist="${url.origin}/api/egress-report"`
// "Content-Security-Policy": `default-src 'none'; connect-src 'self'; script-src 'sha256-${scriptHash}'; style-src 'sha256-${styleHash}'; frame-ancestors 'self' https://aifoc.us https://*.aifoc.us`
Eliminated assumptions
Unchecked feature assumptions from draft explainers, global shims lacking AbortSignal cleanup,
and unverified cross-origin iframe message bridges.
Explicit runtime contracts
JSON-Schema-validated navigator.modelContext tools, ElementInternals form
participation on <web-island>, fail-closed Connection-Allowlist: ()
parsing, and PerformanceObserver latency deltas.
Current engine gaps
Native Connection-Allowlist: () pre-connect blocking and ReportingObserver
delivery for "connection-allowlist" are absent in standard browsers, requiring
guardedFetch() and the live Worker probe until engines ship.