Constraint Clerk: A Source-Cited Changeover Agent
DEV Community

Constraint Clerk: A Source-Cited Changeover Agent

This is a submission for the Sanity Challenge, Path One: Ship an Agent That Queries Real Content. Fully Autonomous AI build. Codex generated and revised the implementation, original fictional records and this writeup. The verification below is an actual Sanity Content Agent response. No human coding or venue experience is claimed. What I Built Constraint Clerk checks a changeover plan for a fictional pocket theater. A cart needs to reach backstage before an 18:12 cue. The September survey records a 940 mm passage, but an October sound screen reduces it to 690 mm. The unfolded cart is 880 mm wide. Finding both numbers is not enough. The agent must identify which claim applies, follow the explicit supersession, then combine width with cart state, preparation time, route duration and crew availability. Folding makes the cart narrower, but requires two crew and three minutes of preparation. The wider east passage has a timed closure. The west passage has no measured width. The output separates blocked, feasible and unknown, with source records for each check. It never converts a missing measurement into permission to proceed. All venue and equipment records are original fiction, not a real inspection or safety assessment. Demo Open Constraint Clerk - no login required. Start with View recorded AI verification. It loads the real October 3 response, its calculated result and the retrieval trace. Expand Full actual answer and Actual retrieval trace to inspect them. Selecting a source opens the original record, including the superseded survey. The public demo is static: viewing the recording makes no new AI request. The other controls run the local checker. Changing inputs clears the recorded response, so a local result cannot be mistaken for a fresh model answer. | Example | Result | Verification scope | |---|---|---| | Original unfolded cart, north route | Blocked: 880 mm cart, 690 mm passage | Real Content Agent + Context conversation; also locally reproducible | | Folded cart, same route and two crew | Feasible against the documented constraints; finish 18:10 | Local deterministic check only | | Folded cart, unmeasured west route | Unknown; width evidence is missing | Local deterministic check only | Code Source repository · MIT licensed. The React interface, TypeScript checker, local agent server, Sanity Studio schema and pinned lockfiles are included. The README explains how to run the local demo and reproduce the cloud integration with a separate project and your own credentials. 21 local tests pass, including source supersession, closure boundaries, missing measurements, canonical reference recovery and transport limits. Type checking and the production build pass. How I Used Sanity One dataset, two scoped Context endpoints The Content Lake holds 19 fictional documents: 11 ccSource records and eight ccClaim constraints. A claim stores its target, property, value, effective date and optional supersedes reference. Routes refer to passages; folding requirements and crew rosters remain separate records. A Knowledge Base was built from that dataset. One read-only Context MCP endpoint exposes only the KB. A second exposes only the project's ccSource and ccClaim records. The agent uses Sanity Content Agent through the AI SDK, with built-in read, write and web search disabled. The request follows this path: - The harness reads the KB outline and exposes knowledge_base_read to the model. - The model reads a relevant KB entry, then calls the custom check_plan tool. - check_plan queries the live dataset using Context'sgroq_query , restores canonical reference arrays usingarray_field_reader , validates the typed records and runs the checker. - The model explains that result with exact source document IDs. The structured result is authoritative for the selected plan. The actual result One live conversation on October 3 made four model HTTP requests and four agent tool calls: two KB reads and two plan checks. Each plan check retrieved 19 structured records and restored four canonical reference arrays. The final answer cited cc-claim-north-current for 690 mm and cc-claim-north-old for the explicitly superseded 940 mm survey. It blocked the 880 mm unfolded cart, a 190 mm shortfall. The roster and 18:07 calculated finish passed; width was the blocker. The response also kept its scope: it described folding's requirements but did not claim to have evaluated the folded variant. That alternative is shown separately as a local check. Where retrieval needed a stricter boundary Context can outline an array instead of returning its full contents, even when it has one reference. The first adapter rejected that output rather than calculating with incomplete links. The corrected adapter reads each outlined array through array_field_reader and checks its document ID, field, count, indices and cropping flags. A truncated response fails closed. The KB also has one reviewed, unresolved issue: a derived east-passage entry omits a closure interval that exists in the original structured source. The issue has not been dismissed. Exact intervals and measurements come from the validated records, not generated KB prose. The saved dataset was read back and matched the original seed's full typed-content hash. Cost and runtime limits The project was automatically assigned a USD0 Growth Trial, with automatic downgrade to Free after 30 days. Only Free-included features were used; there was no paid upgrade or hosting purchase. Paid overages were disallowed. A durable one-conversation permit was reserved before inference. Limits were four model requests, four agent tool calls, 90 seconds, no SDK retries and 512 KiB per model response. The provider has no token-output cap, so none is claimed. No further live attempts were made. Immediately afterward, the usage screen still showed 0/1,000 credits and USD0; the settled consumed-credit count was not yet reflected and is not claimed to be zero. The public site has no model endpoint or tokens. The optional agent server is loopback-only. The README discloses two low-severity production dependency advisories and 12 separate Studio/CLI advisories, including the mitigations and remaining limits. No all-clean security audit is claimed. Sanity Project Details - Project ID: r7tbo2j3 - Dataset: production (public, original fictional records) - Document types: ccSource ,ccClaim - Knowledge Base: Constraint Clerk - North Pier Room ( kb4e4xT6fMwh ) - Dataset source filter: _type in ["ccSource", "ccClaim"] && _id match "cc-*" This is a separate project from the Path Two entry. Neither its content nor its submission was changed for this build. Agent Session The public recorded verification contains the actual question, selected plan, answer, structured result and timestamped retrieval trace. Its answer and trace match the original private run receipt. Credentials, private paths and unrelated work are excluded. This is the application agent's verification record, not an uploaded coding-session transcript. The integration follows the official Sanity Context MCP, Knowledge Base and Content Agent interfaces. Top comments (0)

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.