Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions examples/llm-job/expected-receipt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"manifest": {
"format": "grounded-json/receipt",
"version": 1,
"createdAt": "2026-03-04T00:00:00.000Z",
"receiptHash": "sha256:e8903465aca9a28f2deca2fdd7c1abe71534f8f099fefab8a6ccc76973748028"
},
"data": {
"company": "Brightpath Analytics",
"employmentType": "full-time",
"location": "Austin, TX",
"salaryMin": 118000,
"signingBonus": 15000,
"title": "Data Platform Engineer"
},
"sources": [
{
"id": "source:ed0e0436dbec",
"mediaType": "text/html",
"contentHash": "sha256:ed0e0436dbece71e058a5b94189fe63c320ca695e828c2622dbf38e0f786a8e1",
"bytes": 1357
}
],
"evidence": {
"/company": [
{
"pointer": "/company",
"quote": "Brightpath Analytics",
"sourceId": "source:ed0e0436dbec",
"sourceHash": "sha256:ed0e0436dbece71e058a5b94189fe63c320ca695e828c2622dbf38e0f786a8e1",
"status": "grounded",
"observedValue": "Brightpath Analytics"
}
],
"/employmentType": [
{
"pointer": "/employmentType",
"quote": "full-time",
"sourceId": "source:ed0e0436dbec",
"sourceHash": "sha256:ed0e0436dbece71e058a5b94189fe63c320ca695e828c2622dbf38e0f786a8e1",
"status": "grounded",
"observedValue": "full-time"
}
],
"/location": [
{
"pointer": "/location",
"quote": "Austin, TX",
"sourceId": "source:ed0e0436dbec",
"sourceHash": "sha256:ed0e0436dbece71e058a5b94189fe63c320ca695e828c2622dbf38e0f786a8e1",
"status": "grounded",
"observedValue": "Austin, TX"
}
],
"/salaryMin": [
{
"pointer": "/salaryMin",
"quote": "118,000",
"transforms": [
"parse-number"
],
"sourceId": "source:ed0e0436dbec",
"sourceHash": "sha256:ed0e0436dbece71e058a5b94189fe63c320ca695e828c2622dbf38e0f786a8e1",
"status": "grounded",
"observedValue": 118000
}
],
"/signingBonus": [
{
"pointer": "/signingBonus",
"quote": "signing bonus of 15,000 USD",
"transforms": [
"parse-number"
],
"sourceId": "source:ed0e0436dbec",
"sourceHash": "sha256:ed0e0436dbece71e058a5b94189fe63c320ca695e828c2622dbf38e0f786a8e1",
"status": "invalid",
"reason": "Quote was not found at the evidence anchor."
}
],
"/title": [
{
"pointer": "/title",
"quote": "Data Platform Engineer",
"sourceId": "source:ed0e0436dbec",
"sourceHash": "sha256:ed0e0436dbece71e058a5b94189fe63c320ca695e828c2622dbf38e0f786a8e1",
"status": "grounded",
"observedValue": "Data Platform Engineer"
}
]
},
"issues": [
{
"code": "quote-not-found",
"pointer": "/signingBonus",
"sourceId": "source:ed0e0436dbec",
"message": "Quote was not found at the evidence anchor."
}
],
"coverage": {
"grounded": 5,
"total": 6,
"missing": 0,
"ambiguous": 0,
"invalid": 1,
"ratio": 0.8333333333333334
}
}
23 changes: 23 additions & 0 deletions examples/llm-job/llm-response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"_note": "Recorded structured output from an LLM asked to return {value, quote} per field for the posting in page.html. 'signingBonus' is hallucinated: the posting never mentions a signing bonus, so its quote cannot be found in the page.",
"company": {
"quote": "Brightpath Analytics",
"value": "Brightpath Analytics"
},
"employmentType": { "quote": "full-time", "value": "full-time" },
"location": { "quote": "Austin, TX", "value": "Austin, TX" },
"salaryMin": {
"quote": "118,000",
"transforms": ["parse-number"],
"value": 118000
},
"signingBonus": {
"quote": "signing bonus of 15,000 USD",
"transforms": ["parse-number"],
"value": 15000
},
"title": {
"quote": "Data Platform Engineer",
"value": "Data Platform Engineer"
}
}
43 changes: 43 additions & 0 deletions examples/llm-job/page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Data Platform Engineer — Brightpath Analytics</title>
</head>
<body>
<main>
<h1>Data Platform Engineer</h1>
<p class="company">Brightpath Analytics</p>
<p class="location">Austin, TX (on site)</p>
<p class="posted">Posted on March 3, 2026</p>
<section>
<h2>About the role</h2>
<p>
Brightpath is hiring for this role to build and operate the pipelines
that move product data into our warehouse.
</p>
<p>
This is a full-time position based in our Austin office. The salary
range for this role is 118,000–142,000 USD per year, depending on
experience.
</p>
</section>
<section>
<h2>What you will do</h2>
<ul>
<li>Design ETL pipelines in Python and SQL</li>
<li>Operate Airflow and dbt in production</li>
<li>Partner with analytics engineers on data quality</li>
</ul>
</section>
<section>
<h2>Requirements</h2>
<ul>
<li>4+ years of data engineering experience</li>
<li>Strong SQL and Python</li>
<li>Experience with a cloud warehouse (Snowflake preferred)</li>
</ul>
</section>
</main>
</body>
</html>
52 changes: 52 additions & 0 deletions examples/llm-job/run.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Ground a recorded LLM extraction against a saved job posting page.
// Run from the repo root after `npm run build:package`:
// node examples/llm-job/run.mjs
// The receipt is compared with expected-receipt.json; the run fails if
// the two differ. The clock is pinned so the receipt is reproducible.
import { readFileSync } from 'node:fs';
import { ground } from 'grounded-json';
import { z } from 'zod';

const dir = new URL('./', import.meta.url);
const page = readFileSync(new URL('page.html', dir), 'utf8');
const { _note, ...fields } = JSON.parse(
readFileSync(new URL('llm-response.json', dir), 'utf8'),
);

// Prompt pattern: "For every field return { value, quote } where quote is copied verbatim from the source."
const data = Object.fromEntries(
Object.entries(fields).map(([k, f]) => [k, f.value]),
);
const evidence = Object.entries(fields).map(([k, f]) => ({
pointer: `/${k}`,
quote: f.quote,
...(f.transforms && { transforms: f.transforms }),
}));

const receipt = ground({
data,
sources: [{ mediaType: 'text/html', content: page }],
evidence,
schema: z.object({
title: z.string(),
company: z.string(),
location: z.string(),
employmentType: z.string(),
salaryMin: z.number(),
signingBonus: z.number(),
}),
options: { now: () => new Date('2026-03-04T00:00:00.000Z') },
});

console.log('coverage:', receipt.coverage);
for (const issue of receipt.issues)
console.log(`REJECT ${issue.pointer}: ${issue.code}`);

const expected = JSON.parse(
readFileSync(new URL('expected-receipt.json', dir), 'utf8'),
);
if (JSON.stringify(receipt) !== JSON.stringify(expected)) {
console.error('FAIL receipt differs from expected-receipt.json');
process.exit(1);
}
console.log('PASS receipt matches expected-receipt.json');