- Add README for @settlekit/attribution (reuse-detection, lineage, proofs) - Add README for apps/creator-dashboard (real-domain-logic earnings view) - Move attribution + creator-dashboard from 'not yet built' to 'built & green' in docs/LEPTON_REMAINING.md; bump health to 948 tests + 27 contract tests - List creator-dashboard in the README apps tree
2.7 KiB
2.7 KiB
@settlekit/attribution
Reuse-detection, weighted provenance lineage, and signed proofs-of-citation (Lepton RFB 6.01).
The citation toll (@settlekit/citation-toll) charges an agent that explicitly fetches a gated source. Attribution closes the other half of the loop — charging for implicit reuse, fanning a payment recursively through every ancestor, and proving after the fact that an agent cited and paid. Everything here is pure: no I/O, no clocks except the ones you pass in.
What's in it
- Reuse detection —
detectReuse(text, candidates, options?)returns aReuseReport: a containment-scored, shingle-based match of generated text against candidate sources, so a toll can be charged for grounding the agent never declared. Tunables:shingleSize(default 4),threshold(default 0.18),minMatched(default 2). Helpers:tokenize,shingleSet,textFingerprint. - Provenance lineage —
LineageGraphis a generic weighted "derives-from" DAG.computeAttributionShares(graph, rootId)fans a root work's value recursively through its ancestors as fractionalAttributionShares (cycle-safe, money-conserving), reusable by any consumer: money, credit, or ranking.validateLineageEdgerejects out-of-range weights. - Proof-of-citation —
issueCitationProof(input, secret)mints an HMAC-SHA256CitationProofan agent presents to a seller or audit log attesting it cited and paid for a set of sources;verifyCitationProof(proof, secret, now?)checks the signature, expiry, and replay nonce without trusting the agent. Lower-level:signClaim,signCitationProof. - Stores —
LineageStore/ProofStoreinterfaces withInMemoryLineageStore/InMemoryProofStore. Postgres implementations (PgLineageStore/PgProofStoreoverlepton_lineage_edges+lepton_citation_proofs) live in@settlekit/persistence.
import { detectReuse, issueCitationProof, verifyCitationProof } from "@settlekit/attribution";
const report = detectReuse(answer, [{ id: "src_1", text: source, wallet }]);
if (report.grounded) {
// charge the toll for report.matches, then issue the proof
const proof = issueCitationProof(
{ agent, sourceIds: report.matches.map((m) => m.sourceId), accessId, ttlSeconds: 3600 },
proofSecret,
);
// ... later, downstream:
const ok = verifyCitationProof(proof, proofSecret).ok;
}
Wired live
The rsshub-citation-toll sidecar exposes this over HTTP:
POST /attribution/detect—{ text }→ReuseReportPOST /attribution/proof— mint aCitationProofPOST /attribution/verify—{ proof }→ verification result
The proofSecret is configured via CITATION_PROOF_SECRET (see the sidecar config).