cleandataengineering.aiDrug-Safety Agent on Databricks, drawn simply
You are here: Desk and approval

Drug-Safety Agent on Databricks · Desk and approval

The desk: where a person decides

The agent produces a draft. What happens next is the part that matters to the business: the draft is saved, a named person sees it, and their decision is recorded. This page and the two inside it show how that works, and what is still a stand-in.

partly built Store (local SQLite, not Delta)   partly built Desk (a local page, no login)   built Decisions are final   built Hand-offs recorded once

The rule the code enforces. The agent can create a draft and nothing else. It has no tool to approve, reject or edit. Those are done by a person through the desk, under their own name, and a decided assessment cannot be decided again.

What is still a stand-in. The store is a local database file with the same columns a Delta table would have. The desk is a standard-library web page: the reviewer types their name, which is recorded but not verified. Nothing is connected to a real safety record, and nobody is notified that a draft is waiting.

The real code

Cut from the repository each time this site is built, so it always matches what runs. Each header names the file and the line it was cut from.

clean-ai-engineering/drafts/examples/drug-safety-signal-investigator.aoas.yaml:164The specification: a draft has four states and three ways out, all by a person
state_machines:
  assessment_status:
    states: [drafted, approved, rejected, edited]
    terminal: [approved, rejected, edited]
    transitions:
      - {from: drafted, to: approved, by: approve_assessment}
      - {from: drafted, to: rejected, by: reject_assessment}
      - {from: drafted, to: edited, by: edit_assessment}
    concurrent_writers: [reviewer]
src/drugsafety/store.py:68The store: one class, drafts in and decisions out
class AssessmentStore:
    def __init__(self, path: Path | str = ":memory:") -> None:
        if str(path) != ":memory:":
            Path(path).parent.mkdir(parents=True, exist_ok=True)
        self.db = sqlite3.connect(str(path), check_same_thread=False)
        self.db.row_factory = sqlite3.Row
        self.db.executescript(SCHEMA)

Look inside