Files
causius/drizzle/0002_helpers.sql
CatoandClaude e3dcbda881 feat(helpers): a directory of helpers, lawyers checked and still pseudonymous (#25)
- Helpers list themselves (AI service, legal assistant, licensed lawyer) under
  a name or pseudonym; the same account keeps matters of its own. Directory
  search and filters through searchkit and listkit, with the typo suite.
- A lawyer's admission is submitted privately (evidence sealed per
  credential), checked by a staff reviewer, and published as an SD-JWT signed
  with Ed25519: the place in clear, the legal name only as a salted digest.
  Key at /.well-known/jwks.json; anyone can check at /verify. A lawyer is
  listed only where verified.
- An owner asks a helper about a matter, with or without their personal
  details; the request is previewed exactly as it will be read. Accepted, the
  helper becomes a participant; anonymisation is applied in the store, so no
  route can forget it. A lawyer hands over the checked name with proof.
  Ending it removes access in the same transaction.
- Reviewers are staff/admin accounts, granted by the Grant role workflow.
- Who may do what is lib/professions.ts, the one domain file, so Diplodoctor
  reuses the engine by changing it.
- Fixes: the account menu label template; one site URL instead of three, with
  a dev-only origin so local sign-in works.


Claude-Session: https://claude.ai/code/session_018Lem7GyhyyjKhmwjG8G7Ud

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-21 05:48:41 +02:00

56 lines
2.9 KiB
SQL

CREATE TABLE "credentials" (
"id" uuid PRIMARY KEY NOT NULL,
"helper_id" uuid NOT NULL,
"kind" text NOT NULL,
"jurisdiction" text NOT NULL,
"status" text DEFAULT 'pending' NOT NULL,
"sealed_key" text NOT NULL,
"sealed_evidence" text NOT NULL,
"sealed_disclosures" text,
"token" text,
"review_note" text,
"submitted_at" timestamp with time zone DEFAULT now() NOT NULL,
"reviewed_by_sub" text,
"reviewed_at" timestamp with time zone,
"expires_at" timestamp with time zone
);
--> statement-breakpoint
CREATE TABLE "engagements" (
"id" uuid PRIMARY KEY NOT NULL,
"matter_id" uuid NOT NULL,
"helper_id" uuid NOT NULL,
"status" text DEFAULT 'requested' NOT NULL,
"sees" text DEFAULT 'anonymised' NOT NULL,
"sealed_request" text NOT NULL,
"sealed_disclosure" text,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"decided_at" timestamp with time zone
);
--> statement-breakpoint
CREATE TABLE "helpers" (
"id" uuid PRIMARY KEY NOT NULL,
"sub" text NOT NULL,
"kind" text NOT NULL,
"name" text NOT NULL,
"headline" text DEFAULT '' NOT NULL,
"bio" text DEFAULT '' NOT NULL,
"jurisdictions" text[] DEFAULT '{}'::text[] NOT NULL,
"areas" text[] DEFAULT '{}'::text[] NOT NULL,
"languages" text[] DEFAULT '{}'::text[] NOT NULL,
"service_url" text,
"status" text DEFAULT 'draft' NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "participants" ADD COLUMN "sees" text DEFAULT 'full' NOT NULL;--> statement-breakpoint
ALTER TABLE "credentials" ADD CONSTRAINT "credentials_helper_id_helpers_id_fk" FOREIGN KEY ("helper_id") REFERENCES "public"."helpers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "engagements" ADD CONSTRAINT "engagements_matter_id_matters_id_fk" FOREIGN KEY ("matter_id") REFERENCES "public"."matters"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "engagements" ADD CONSTRAINT "engagements_helper_id_helpers_id_fk" FOREIGN KEY ("helper_id") REFERENCES "public"."helpers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "credentials_helper_idx" ON "credentials" USING btree ("helper_id");--> statement-breakpoint
CREATE INDEX "credentials_status_idx" ON "credentials" USING btree ("status");--> statement-breakpoint
CREATE INDEX "engagements_matter_idx" ON "engagements" USING btree ("matter_id");--> statement-breakpoint
CREATE INDEX "engagements_helper_idx" ON "engagements" USING btree ("helper_id","status");--> statement-breakpoint
CREATE UNIQUE INDEX "engagements_open_idx" ON "engagements" USING btree ("matter_id","helper_id") WHERE status in ('requested', 'accepted');--> statement-breakpoint
CREATE UNIQUE INDEX "helpers_sub_idx" ON "helpers" USING btree ("sub");--> statement-breakpoint
CREATE INDEX "helpers_status_idx" ON "helpers" USING btree ("status","kind");