The Ministry of ApprovalsEst. this week. Open 24 hours. Closed for lunch.

Internal circular · Not for citizens · Citizens may read it anyway

How the Ministry works

The process is not code. It is a workflow definition stored in Sanity, next to the submissions it acts on. Every run is a document too: which stage it is in, what the clerks said, who pressed what, and when. The public site only reads the workflow back.

  1. Front DeskVacantSEENFront DeskTake a number. The number is also a form.
  2. Ms. Regulation OnaSEENDepartment of PedantrySomething is always missing.
  3. Mr. Approvals TomasDepartment of Rubber StampsWe have never said no.
  4. The ArchivistThe ArchiveEverything is somewhere.
  5. The Minister'sDeskThe MinisterThe Minister's DeskA human. Allegedly.
  6. Office ofCertificatesVacantOffice of CertificatesSuitable for framing.
  7. On theWallVacantOn the WallSuitable for framing.

The corridor

  1. Front Desk. Your form is stamped in automatically. If a department sends it back, this is where you answer.
  2. Department of Pedantry. An AI clerk reads your form and finds the one thing missing. It cites a regulation it made up. Answer it and it accepts, grudgingly.
  3. Department of Rubber Stamps. An AI clerk approves everything and says something that proves it did not read the form.
  4. The Archive. An AI archivist files your form. Every third serial is lost, once. You get a receipt and go back to the Front Desk.
  5. The Minister's Desk. A human. Approves with a note, rejects with a reason, or refers the file back to a department. One hour to rule, or the Department of Delays sends the file back to the Archive, which loses it.
  6. Office of Certificates. A certificate document is written with the clerks' remarks as stamps, rendered to an image, and a Discord webhook announces it.

What is Sanity here

  • Submissions, departments, clerks, certificates and receipts are documents in dataset ministry of project v6745vem.
  • The clerks' personalities are content: a clerk document holds the system prompt. Slide the temperament in Studio and the prompt rewrites itself. Their portraits are generated by Agent Actions from that prompt.
  • The corridor is a Sanity Workflows definition. Each department is a stage; each AI clerk is an effect; each human decision is an action. Both move the run through the same transitions. Guards freeze the form while a department holds it.
  • Effects run in a Sanity Function that wakes when a run gains unclaimed work. The clerks call Agent Actions (Prompt) with the form as a GROQ parameter. A second Function ticks the clock once an hour for the Department of Delays.
  • The Minister's back office is an App SDK app in the Sanity Dashboard: the corridor as a live board, one file open at a time, a workflow diagram, and the same actions the CLI can fire.
  • The definition has a test suite that runs the real engine in memory: the lost loop, the delays, the guards, all without a network.

Built for the Sanity Challenge on DEV. The code is public; the link is in the post.