Edge Attribution & Hypermedia Metering Lab

Attribution & Metering Protocol Lab

When automated retrieval pipelines summarize publisher pages without returning verifiable referrals, publishers absorb crawl bandwidth costs with no feedback loop. Test an edge Worker and SQLite Durable Object issuing signed X-Attribution-Receipt tokens with #:~:text= links, settling verified clicks, and modeling publisher sustainability.

Hypothesis

Issuing signed X-Attribution-Receipt headers paired with #:~:text= deep links creates verifiable referral signals for metered discovery without forcing binary crawler bans or hard paywalls.

Confirm signal

/api/quote/:docId issues HMAC-SHA256 receipts that settle cleanly inside the Durable Object AttributionLedger (/api/click-receipt), separating verified referred clicks from replays and tampered tokens.

Falsify signal

Strip-on-copy URL transformations by chat interfaces or aggregator proxies discard #:~:text= parameters and receipt headers unless browsers propagate provenance natively.

Quick Experiments

Execute the attribution cycle directly against the edge Worker and SQLite Durable Object.

01 · Mint

Request Quoted Span

Call GET /api/quote/:docId to mint an X-Attribution-Receipt header and #:~:text= link while incrementing transclusion_reads.

02 · Confirm vs. Falsify

Click, Tamper, or Strip-on-Copy

Settle a valid receipt (HTTP 200), mutate a signature byte (HTTP 401), or simulate an aggregator stripping fragments and receipts on copy (HTTP 400).

03 · Economics

Compare Sustainability Curves

Compare monthly net economics across Zero-Click Scraping, Hard Paywall, and Metered Attribution below and above break-even CTR.

Quote Issuer & Durable Object Ledger

X-Attribution-Receipt Token Structure

Tokens use three dot-separated Base64URL segments: v1.<payloadB64>.<hmacSha256B64>.

  • jti: 96-bit unique receipt identifier for replay deduplication
  • docId & spanHash: SHA-256 digest of normalized quoted text
  • sessionId: binds receipt to one AttributionLedger DO
  • iat / exp: epoch seconds validity window (3600s default)
Transclusion Reads 0
Verified Clicks 0
Observed CTR 0.0%
Rejected / Dup 0 / 0

Session DO Key Fingerprint: uninitialized

Select an essay and span to issue a receipt.
Ready
Issue a quote to generate a deep-linked #:~:text= fragment URL and X-Attribution-Receipt token.
Text Fragment Link (#:~:text=)
—
HTTP Header X-Attribution-Receipt
—

3-Model Publisher Sustainability

1,000,000
2.5x
4.0%
$0.50
$0.08
Break-even CTR for Model C: 0.63%

HTTP Receipt & Durable Object Inspector

Live HTTP status, response headers, SQLite ledger rows, and decoded HMAC signature trace.

Live HTTP Wire & Header Exchange No request yet
GET /api/docs —

Response Headers

Waiting for request...

Response JSON Payload

Waiting for request...
Durable Object SQLite Audit Log (AttributionLedger) 0 events
No ledger events recorded for this session yet.
Receipt Token Payload & SubtleCrypto Verification Trace HMAC-SHA256
Issue or verify a quote receipt to inspect decoded Base64URL fields.
Session HMAC secret lives inside SQLite Durable Object storage
Attribution Metering Architecture Four-stage flow: Publisher Origin issues Quoted Span with X-Attribution-Receipt header and text fragment URL, client navigates via Reader Click-Through, and Edge AttributionLedger SQLite Durable Object verifies signatures and reconciles read-to-click counters. STAGE 1 Publisher Origin GET /api/quote/:docId Selects essay & span Mints HMAC-SHA256 token STAGE 2 · HTTP 200 Quoted Span + Headers X-Attribution-Receipt #:~:text=start%20tokens DO: transclusion_reads++ STAGE 3 Reader Click-Through POST /api/click-receipt Submits signed token Tampered / stripped -> 401/400 STAGE 4 · SQLITE DO AttributionLedger ledger_meta (HMAC key) transclusion_reads click_throughs redeemed_receipts / 401 Trust boundary: session HMAC secret remains isolated inside AttributionLedger SQLite storage; clients receive compact v1.<payload>.<hmac> receipts only.
Every quote issuance and click verification writes atomically to the session's SQLite Durable Object (AttributionLedger), producing an auditable read-to-click ratio.
How This Is Set Up

Implementation & Metering Contract

Attaches HMAC-SHA256 X-Attribution-Receipt headers, W3C #:~:text= deep-link fragments, and a Durable Object SQLite AttributionLedger to reconcile span fetches with verified referral clicks.

Without attribution receipts
GET /hypermedia/ HTTP/1.1
User-Agent: AutomatedFetcher/1.0

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
<!-- Full document fetched; downstream summary omits span provenance.
     Publisher pays egress cost with no cryptographic receipt
     connecting transcluded passages back to referral clicks. -->
With signed receipts & #:~:text=
GET /api/quote/hypermedia?session=demo&span=span-1 HTTP/1.1

HTTP/1.1 200 OK
X-Attribution-Receipt: v1.eyJ2IjoxLCJqdGkiOi...sigB64
X-Attribution-Policy: metered-transclusion; v=1
X-Text-Fragment: https://aifoc.us/hypermedia/#:~:text=Hypermedia%20responses...

// Client cites fragmentUrl and settles verified referral clicks:
POST /api/click-receipt { "sessionId": "demo", "receipt": "v1..." }
Complete Receipt Minting, SQLite Schema & Settlement Wiring (src/metering.ts + src/worker.ts + public/app.js)

Matches the live endpoints in src/worker.ts, HMAC-SHA256 signing/verification in src/metering.ts, and fragment encoding in public/lib/economics.js.

// 1. Mint HMAC-SHA256 Receipt & Encode #:~:text= Fragment (src/metering.ts + public/lib/economics.js)
const fragmentUrl = buildTextFragmentUrl(doc.url, selectedSpan.text, {
  prefix: selectedSpan.prefix,
  suffix: selectedSpan.suffix,
});
const receipt = await mintQuoteReceipt({
  docId: doc.id,
  spanText: selectedSpan.text,
  origin: url.origin,
  issuedAt: nowSec,
  sessionId: meta.session_id,
  keySecret: meta.hmac_secret,
}); // Format: "v1." + base64url(payload) + "." + hmacSha256B64

// 2. Durable Object SQLite Ledger Settlement (src/worker.ts -> AttributionLedger)
// GET /api/quote/:docId?session=...&span=... -> increments transclusion_reads, emits X-Attribution-Receipt
// POST /api/click-receipt { sessionId, receipt } -> verifies HMAC, checks redeemed_receipts for replays:
const verification = await verifyQuoteReceipt({
  receipt: params.receipt,
  keySecret: meta.hmac_secret,
  nowSec,
});
// Valid first click -> 200 (click_throughs++), replay -> 200 (deduplicated: true),
// tampered signature -> 401 (rejected_clicks++), strip-on-copy loss -> 400.
What disappears

Unattributed full-page scraping and binary allow-all vs. 403-block postures with zero verifiable referral feedback.

What becomes explicit

Signed HMAC-SHA256 X-Attribution-Receipt headers, W3C #:~:text= deep links, replay deduplication in SQLite, and break-even CTR curves.

Platform constraints

Chat interfaces and aggregator proxies frequently strip URL fragments and custom headers on copy; durable attribution needs native browser provenance propagation.