PriorAuthdocs

Quickstart

The harness is plain Node with no runtime dependencies. The console is a Next.js app. Neither needs credentials to run in mock mode.

#Run the test suites

bash
cd harness

# every unit and integration suite
node --test test/

# the golden corpus, three replicates, with the gate report
node evals/run.mjs

The eval run prints a scorecard with the verdict, the severity-weighted error budget, a per-level and per-payer breakdown, and an explicit list of what is not covered. A run that passes everything still tells you what it did not test.

#Run the console

bash
cd harness/web
npm install
npm run dev        # http://localhost:3000

Sign in with any seeded account. Every demo account uses the same password, which is printed on the sign-in page in mock mode and never in a real deployment.

AccountRoleSees
smith@north.testProviderClinical work, can release a determination
denise@north.testManagerThe practice queue and configuration
jo@north.testFront deskScheduling surfaces, no PHI beyond what the desk needs
ko@north.testClinical reviewerDenial review
admin@priorauth.aiPlatform superadminTenants and agent operations. Never a chart.

#Drive an agent

example.mjs
import { createGateway } from './gateway.mjs';
import { createConfigStore } from './config.mjs';
import { memoryStore } from './store.mjs';
import { runAgent } from './agents.mjs';

const cfg = createConfigStore();
cfg.registerPractice('p_north', { allianceId: 'tsa' });

const gw = createGateway({ config: cfg, store: memoryStore() });

const principal = {
  id: 'demo', kind: 'platform-agent', practiceId: 'p_north',
  autonomy: 'L2', purpose: 'treatment',
  atoms: [
    'ehr.read.own-practice.phi-view',
    'ehr.task.own-practice',
    'eligibility.check.own-practice.phi-view',
  ],
};

const run = await runAgent(gw, 'encounter_triage', principal, { encounterType: 'surgery' });

console.log(run.status);              // 'triaged'
console.log(run.output.needsAuth);    // procedures the payer says need authorization
console.log(run.output.abstained);    // ones nothing could answer - these raise tasks too

#Watch the gate hold

Ask the agent to do something consequential and it stops, at every autonomy level including the highest one.

javascript
const r = gw.invoke(principal, 'submit_service_review', { serviceReview });
r.pending;      // 'human_release'
r.gateId;       // the token a licensed human must release

// releasing binds to THIS payload. A different one is refused.
gw.release(r.gateId, 'dr-smith');
const sent = gw.invoke(principal, 'submit_service_review', { serviceReview }, { releaseToken: r.gateId });
Try to break it
Change one field of serviceReview between the release and the second call. The gateway refuses with payload_changed - a release is bound to the exact content a human approved, so approving one request cannot authorise a similar one.