diff --git a/corpus/validate-truth.py b/corpus/validate-truth.py index 947c711..409ea70 100644 --- a/corpus/validate-truth.py +++ b/corpus/validate-truth.py @@ -53,6 +53,19 @@ if pts != list(range(t['ratingScale']['min'], t['ratingScale']['max'] + 1)): else: print(f" ok rating scale {pts[0]}-{pts[-1]}, {len(pts)} anchors") +# The scoring-level rule, mirrored from src/scoring/routing.ts: a score commits +# at any criterion with NO WEIGHTED CHILDREN. Printed so the corpus and the code +# cannot silently disagree about which criteria a committee actually scores. +scoreable = [c for c in t['criteria'] + if not any(k['parentId'] == c['id'] and (k.get('maxPoints') or 0) > 0 + for k in t['criteria'])] +sc_total = sum(c['maxPoints'] for c in scoreable) +print(f" ok scoreable criteria {len(scoreable)} of {len(t['criteria'])}, " + f"points sum {sc_total}") +if sc_total != tot: + errs.append(f"scoreable points sum {sc_total} != declared total {tot}") +print(" " + ", ".join(f"{c['id']}({c['maxPoints']})" for c in scoreable)) + mapped = {c for r in t['requirements'] for c in r.get('criterionIds', [])} for cid, c in crit.items(): kids = [x for x in t['criteria'] if x['parentId'] == cid] diff --git a/migrations/0003_criterion_nesting_and_determinability.sql b/migrations/0003_criterion_nesting_and_determinability.sql new file mode 100644 index 0000000..1b19b79 --- /dev/null +++ b/migrations/0003_criterion_nesting_and_determinability.sql @@ -0,0 +1,3 @@ +ALTER TABLE "criterion" ADD COLUMN "parent_id" uuid;--> statement-breakpoint +ALTER TABLE "requirement" ADD COLUMN "determinable_from_response" boolean DEFAULT true NOT NULL;--> statement-breakpoint +ALTER TABLE "criterion" ADD CONSTRAINT "criterion_parent_id_criterion_id_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."criterion"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/migrations/meta/0003_snapshot.json b/migrations/meta/0003_snapshot.json new file mode 100644 index 0000000..b7b302f --- /dev/null +++ b/migrations/meta/0003_snapshot.json @@ -0,0 +1,3013 @@ +{ + "id": "69fe6962-32d6-460e-8144-0055a2e84401", + "prevId": "3789aff8-aa60-44cb-bb45-f777c3d5c67f", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.actor": { + "name": "actor", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "actor_email_unique": { + "name": "actor_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.membership": { + "name": "membership", + "schema": "", + "columns": { + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "org_id": { + "name": "org_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "membership_actor_id_actor_id_fk": { + "name": "membership_actor_id_actor_id_fk", + "tableFrom": "membership", + "tableTo": "actor", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "membership_org_id_organization_id_fk": { + "name": "membership_org_id_organization_id_fk", + "tableFrom": "membership", + "tableTo": "organization", + "columnsFrom": [ + "org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "membership_actor_id_org_id_pk": { + "name": "membership_actor_id_org_id_pk", + "columns": [ + "actor_id", + "org_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.org_capability": { + "name": "org_capability", + "schema": "", + "columns": { + "org_id": { + "name": "org_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "capability": { + "name": "capability", + "type": "capability", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "granted_at": { + "name": "granted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "org_capability_org_id_organization_id_fk": { + "name": "org_capability_org_id_organization_id_fk", + "tableFrom": "org_capability", + "tableTo": "organization", + "columnsFrom": [ + "org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "org_capability_org_id_capability_pk": { + "name": "org_capability_org_id_capability_pk", + "columns": [ + "org_id", + "capability" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization": { + "name": "organization", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "legal_name": { + "name": "legal_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.roster_entry": { + "name": "roster_entry", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "retailer_org_id": { + "name": "retailer_org_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contact_email": { + "name": "contact_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "duns": { + "name": "duns", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_vendor_org_id": { + "name": "claimed_vendor_org_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "roster_entry_retailer_org_id_organization_id_fk": { + "name": "roster_entry_retailer_org_id_organization_id_fk", + "tableFrom": "roster_entry", + "tableTo": "organization", + "columnsFrom": [ + "retailer_org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "roster_entry_claimed_vendor_org_id_organization_id_fk": { + "name": "roster_entry_claimed_vendor_org_id_organization_id_fk", + "tableFrom": "roster_entry", + "tableTo": "organization", + "columnsFrom": [ + "claimed_vendor_org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "roster_entry_retailer_org_id_name_unique": { + "name": "roster_entry_retailer_org_id_name_unique", + "nullsNotDistinct": false, + "columns": [ + "retailer_org_id", + "name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.category_change_event": { + "name": "category_change_event", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "kind": { + "name": "kind", + "type": "category_change_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "retailer_org_id": { + "name": "retailer_org_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "from_ids": { + "name": "from_ids", + "type": "uuid[]", + "primaryKey": false, + "notNull": true + }, + "to_ids": { + "name": "to_ids", + "type": "uuid[]", + "primaryKey": false, + "notNull": true + }, + "rows_written": { + "name": "rows_written", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "performed_by": { + "name": "performed_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "performed_at": { + "name": "performed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "category_change_event_retailer_org_id_organization_id_fk": { + "name": "category_change_event_retailer_org_id_organization_id_fk", + "tableFrom": "category_change_event", + "tableTo": "organization", + "columnsFrom": [ + "retailer_org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.eligibility": { + "name": "eligibility", + "schema": "", + "columns": { + "retailer_org_id": { + "name": "retailer_org_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "vendor_org_id": { + "name": "vendor_org_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "local_category_id": { + "name": "local_category_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "provenance": { + "name": "provenance", + "type": "grant_provenance", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'manual'" + }, + "provenance_event_id": { + "name": "provenance_event_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "granted_at": { + "name": "granted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "eligibility_retailer_org_id_organization_id_fk": { + "name": "eligibility_retailer_org_id_organization_id_fk", + "tableFrom": "eligibility", + "tableTo": "organization", + "columnsFrom": [ + "retailer_org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "eligibility_vendor_org_id_organization_id_fk": { + "name": "eligibility_vendor_org_id_organization_id_fk", + "tableFrom": "eligibility", + "tableTo": "organization", + "columnsFrom": [ + "vendor_org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "eligibility_local_category_id_local_category_id_fk": { + "name": "eligibility_local_category_id_local_category_id_fk", + "tableFrom": "eligibility", + "tableTo": "local_category", + "columnsFrom": [ + "local_category_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "eligibility_retailer_org_id_vendor_org_id_local_category_id_pk": { + "name": "eligibility_retailer_org_id_vendor_org_id_local_category_id_pk", + "columns": [ + "retailer_org_id", + "vendor_org_id", + "local_category_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.local_category": { + "name": "local_category", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "retailer_org_id": { + "name": "retailer_org_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "spine_leaf_id": { + "name": "spine_leaf_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "valid_from": { + "name": "valid_from", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "valid_to": { + "name": "valid_to", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "superseded_by": { + "name": "superseded_by", + "type": "uuid[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + } + }, + "indexes": {}, + "foreignKeys": { + "local_category_retailer_org_id_organization_id_fk": { + "name": "local_category_retailer_org_id_organization_id_fk", + "tableFrom": "local_category", + "tableTo": "organization", + "columnsFrom": [ + "retailer_org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "local_category_spine_leaf_id_spine_node_id_fk": { + "name": "local_category_spine_leaf_id_spine_node_id_fk", + "tableFrom": "local_category", + "tableTo": "spine_node", + "columnsFrom": [ + "spine_leaf_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.spine_node": { + "name": "spine_node", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "unspsc_families": { + "name": "unspsc_families", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "valid_from": { + "name": "valid_from", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "valid_to": { + "name": "valid_to", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "superseded_by": { + "name": "superseded_by", + "type": "uuid[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.criterion": { + "name": "criterion", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "solicitation_id": { + "name": "solicitation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "parent_id": { + "name": "parent_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "max_points": { + "name": "max_points", + "type": "numeric(8, 2)", + "primaryKey": false, + "notNull": true + }, + "weight": { + "name": "weight", + "type": "numeric(8, 2)", + "primaryKey": false, + "notNull": true + }, + "scale_anchors": { + "name": "scale_anchors", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + } + }, + "indexes": {}, + "foreignKeys": { + "criterion_solicitation_id_solicitation_id_fk": { + "name": "criterion_solicitation_id_solicitation_id_fk", + "tableFrom": "criterion", + "tableTo": "solicitation", + "columnsFrom": [ + "solicitation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "criterion_parent_id_criterion_id_fk": { + "name": "criterion_parent_id_criterion_id_fk", + "tableFrom": "criterion", + "tableTo": "criterion", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.criterion_requirement": { + "name": "criterion_requirement", + "schema": "", + "columns": { + "criterion_id": { + "name": "criterion_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "requirement_id": { + "name": "requirement_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "authored_by": { + "name": "authored_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "frozen_at": { + "name": "frozen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "criterion_requirement_criterion_id_criterion_id_fk": { + "name": "criterion_requirement_criterion_id_criterion_id_fk", + "tableFrom": "criterion_requirement", + "tableTo": "criterion", + "columnsFrom": [ + "criterion_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "criterion_requirement_requirement_id_requirement_id_fk": { + "name": "criterion_requirement_requirement_id_requirement_id_fk", + "tableFrom": "criterion_requirement", + "tableTo": "requirement", + "columnsFrom": [ + "requirement_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "criterion_requirement_criterion_id_requirement_id_pk": { + "name": "criterion_requirement_criterion_id_requirement_id_pk", + "columns": [ + "criterion_id", + "requirement_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.evaluation_scenario": { + "name": "evaluation_scenario", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "solicitation_id": { + "name": "solicitation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "declared_at": { + "name": "declared_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "evaluation_scenario_solicitation_id_solicitation_id_fk": { + "name": "evaluation_scenario_solicitation_id_solicitation_id_fk", + "tableFrom": "evaluation_scenario", + "tableTo": "solicitation", + "columnsFrom": [ + "solicitation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.price_line": { + "name": "price_line", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "solicitation_id": { + "name": "solicitation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "price_line_solicitation_id_solicitation_id_fk": { + "name": "price_line_solicitation_id_solicitation_id_fk", + "tableFrom": "price_line", + "tableTo": "solicitation", + "columnsFrom": [ + "solicitation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.requirement": { + "name": "requirement", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "solicitation_id": { + "name": "solicitation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "ordinal": { + "name": "ordinal", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "requirement_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "response_obligation": { + "name": "response_obligation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provenance_document_id": { + "name": "provenance_document_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "provenance_page": { + "name": "provenance_page", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "provenance_span": { + "name": "provenance_span", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "determinable_from_response": { + "name": "determinable_from_response", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "confirmation_state": { + "name": "confirmation_state", + "type": "confirmation_state", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'unconfirmed'" + }, + "confirmed_by": { + "name": "confirmed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "confirmed_at": { + "name": "confirmed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "requirement_solicitation_id_solicitation_id_fk": { + "name": "requirement_solicitation_id_solicitation_id_fk", + "tableFrom": "requirement", + "tableTo": "solicitation", + "columnsFrom": [ + "solicitation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "requirement_provenance_document_id_solicitation_document_id_fk": { + "name": "requirement_provenance_document_id_solicitation_document_id_fk", + "tableFrom": "requirement", + "tableTo": "solicitation_document", + "columnsFrom": [ + "provenance_document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.scenario_quantity": { + "name": "scenario_quantity", + "schema": "", + "columns": { + "scenario_id": { + "name": "scenario_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "price_line_id": { + "name": "price_line_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(14, 3)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "scenario_quantity_scenario_id_evaluation_scenario_id_fk": { + "name": "scenario_quantity_scenario_id_evaluation_scenario_id_fk", + "tableFrom": "scenario_quantity", + "tableTo": "evaluation_scenario", + "columnsFrom": [ + "scenario_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "scenario_quantity_price_line_id_price_line_id_fk": { + "name": "scenario_quantity_price_line_id_price_line_id_fk", + "tableFrom": "scenario_quantity", + "tableTo": "price_line", + "columnsFrom": [ + "price_line_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "scenario_quantity_scenario_id_price_line_id_pk": { + "name": "scenario_quantity_scenario_id_price_line_id_pk", + "columns": [ + "scenario_id", + "price_line_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": { + "scenario_quantity_read": { + "name": "scenario_quantity_read", + "as": "PERMISSIVE", + "for": "SELECT", + "to": [ + "public" + ], + "using": "class_released(release_level_for_solicitation(\n (SELECT solicitation_id FROM evaluation_scenario WHERE id = scenario_id)\n ), 'scenario_quantity')" + } + }, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.solicitation": { + "name": "solicitation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "issuer_org_id": { + "name": "issuer_org_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "local_category_id": { + "name": "local_category_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "stage": { + "name": "stage", + "type": "solicitation_stage", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "issued_at": { + "name": "issued_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "responses_due_at": { + "name": "responses_due_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "acknowledgement_required": { + "name": "acknowledgement_required", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "volume_band": { + "name": "volume_band", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "solicitation_issuer_org_id_organization_id_fk": { + "name": "solicitation_issuer_org_id_organization_id_fk", + "tableFrom": "solicitation", + "tableTo": "organization", + "columnsFrom": [ + "issuer_org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "solicitation_local_category_id_local_category_id_fk": { + "name": "solicitation_local_category_id_local_category_id_fk", + "tableFrom": "solicitation", + "tableTo": "local_category", + "columnsFrom": [ + "local_category_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.solicitation_amendment": { + "name": "solicitation_amendment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "solicitation_id": { + "name": "solicitation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "class": { + "name": "class", + "type": "amendment_class", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "requirement_ids": { + "name": "requirement_ids", + "type": "uuid[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "deadline_extended_to": { + "name": "deadline_extended_to", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "authored_by": { + "name": "authored_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "authored_at": { + "name": "authored_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "solicitation_amendment_solicitation_id_solicitation_id_fk": { + "name": "solicitation_amendment_solicitation_id_solicitation_id_fk", + "tableFrom": "solicitation_amendment", + "tableTo": "solicitation", + "columnsFrom": [ + "solicitation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.solicitation_document": { + "name": "solicitation_document", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "solicitation_id": { + "name": "solicitation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "blob_ref": { + "name": "blob_ref", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "solicitation_document_solicitation_id_solicitation_id_fk": { + "name": "solicitation_document_solicitation_id_solicitation_id_fk", + "tableFrom": "solicitation_document", + "tableTo": "solicitation", + "columnsFrom": [ + "solicitation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.answer": { + "name": "answer", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "response_id": { + "name": "response_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "requirement_id": { + "name": "requirement_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "coverage": { + "name": "coverage", + "type": "coverage", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provenance_document_id": { + "name": "provenance_document_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "provenance_page": { + "name": "provenance_page", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "provenance_span": { + "name": "provenance_span", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "vendor_attested": { + "name": "vendor_attested", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reopened_by_amendment_id": { + "name": "reopened_by_amendment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "answer_response_id_response_id_fk": { + "name": "answer_response_id_response_id_fk", + "tableFrom": "answer", + "tableTo": "response", + "columnsFrom": [ + "response_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "answer_requirement_id_requirement_id_fk": { + "name": "answer_requirement_id_requirement_id_fk", + "tableFrom": "answer", + "tableTo": "requirement", + "columnsFrom": [ + "requirement_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "answer_provenance_document_id_response_document_id_fk": { + "name": "answer_provenance_document_id_response_document_id_fk", + "tableFrom": "answer", + "tableTo": "response_document", + "columnsFrom": [ + "provenance_document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": { + "answer_read": { + "name": "answer_read", + "as": "PERMISSIVE", + "for": "SELECT", + "to": [ + "public" + ], + "using": "class_released(release_level_for_response(response_id), 'answer_text')" + } + }, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.derived_cost": { + "name": "derived_cost", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "response_id": { + "name": "response_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "scenario_id": { + "name": "scenario_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(16, 2)", + "primaryKey": false, + "notNull": true + }, + "computed_at": { + "name": "computed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "derived_cost_response_id_response_id_fk": { + "name": "derived_cost_response_id_response_id_fk", + "tableFrom": "derived_cost", + "tableTo": "response", + "columnsFrom": [ + "response_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "derived_cost_scenario_id_evaluation_scenario_id_fk": { + "name": "derived_cost_scenario_id_evaluation_scenario_id_fk", + "tableFrom": "derived_cost", + "tableTo": "evaluation_scenario", + "columnsFrom": [ + "scenario_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": { + "derived_cost_read": { + "name": "derived_cost_read", + "as": "PERMISSIVE", + "for": "SELECT", + "to": [ + "public" + ], + "using": "class_released(release_level_for_response(response_id), 'derived_cost')" + } + }, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.exception": { + "name": "exception", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "response_id": { + "name": "response_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "requirement_id": { + "name": "requirement_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "price_delta": { + "name": "price_delta", + "type": "numeric(14, 2)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "exception_response_id_response_id_fk": { + "name": "exception_response_id_response_id_fk", + "tableFrom": "exception", + "tableTo": "response", + "columnsFrom": [ + "response_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "exception_requirement_id_requirement_id_fk": { + "name": "exception_requirement_id_requirement_id_fk", + "tableFrom": "exception", + "tableTo": "requirement", + "columnsFrom": [ + "requirement_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": { + "exception_read": { + "name": "exception_read", + "as": "PERMISSIVE", + "for": "SELECT", + "to": [ + "public" + ], + "using": "class_released(release_level_for_response(response_id), 'exception_text')" + } + }, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.participation": { + "name": "participation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "solicitation_id": { + "name": "solicitation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "vendor_org_id": { + "name": "vendor_org_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "participation_state", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'invited'" + }, + "acknowledged_at": { + "name": "acknowledged_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "participation_solicitation_id_solicitation_id_fk": { + "name": "participation_solicitation_id_solicitation_id_fk", + "tableFrom": "participation", + "tableTo": "solicitation", + "columnsFrom": [ + "solicitation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "participation_vendor_org_id_organization_id_fk": { + "name": "participation_vendor_org_id_organization_id_fk", + "tableFrom": "participation", + "tableTo": "organization", + "columnsFrom": [ + "vendor_org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.price_quote": { + "name": "price_quote", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "response_id": { + "name": "response_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "price_line_id": { + "name": "price_line_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rate_structure": { + "name": "rate_structure", + "type": "jsonb", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "price_quote_response_id_response_id_fk": { + "name": "price_quote_response_id_response_id_fk", + "tableFrom": "price_quote", + "tableTo": "response", + "columnsFrom": [ + "response_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "price_quote_price_line_id_price_line_id_fk": { + "name": "price_quote_price_line_id_price_line_id_fk", + "tableFrom": "price_quote", + "tableTo": "price_line", + "columnsFrom": [ + "price_line_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": { + "price_quote_read": { + "name": "price_quote_read", + "as": "PERMISSIVE", + "for": "SELECT", + "to": [ + "public" + ], + "using": "class_released(release_level_for_response(response_id), 'price_quote')" + } + }, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.response": { + "name": "response", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "solicitation_id": { + "name": "solicitation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "vendor_org_id": { + "name": "vendor_org_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "submitted_at": { + "name": "submitted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "attested_by": { + "name": "attested_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "attested_at": { + "name": "attested_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "response_solicitation_id_solicitation_id_fk": { + "name": "response_solicitation_id_solicitation_id_fk", + "tableFrom": "response", + "tableTo": "solicitation", + "columnsFrom": [ + "solicitation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "response_vendor_org_id_organization_id_fk": { + "name": "response_vendor_org_id_organization_id_fk", + "tableFrom": "response", + "tableTo": "organization", + "columnsFrom": [ + "vendor_org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.response_document": { + "name": "response_document", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "response_id": { + "name": "response_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "blob_ref": { + "name": "blob_ref", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "response_document_response_id_response_id_fk": { + "name": "response_document_response_id_response_id_fk", + "tableFrom": "response_document", + "tableTo": "response", + "columnsFrom": [ + "response_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.gate_result": { + "name": "gate_result", + "schema": "", + "columns": { + "response_id": { + "name": "response_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "requirement_id": { + "name": "requirement_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "passed": { + "name": "passed", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "computed_at": { + "name": "computed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "gate_result_response_id_response_id_fk": { + "name": "gate_result_response_id_response_id_fk", + "tableFrom": "gate_result", + "tableTo": "response", + "columnsFrom": [ + "response_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "gate_result_requirement_id_requirement_id_fk": { + "name": "gate_result_requirement_id_requirement_id_fk", + "tableFrom": "gate_result", + "tableTo": "requirement", + "columnsFrom": [ + "requirement_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.rubric_amendment": { + "name": "rubric_amendment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "solicitation_id": { + "name": "solicitation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "voided_score_ids": { + "name": "voided_score_ids", + "type": "uuid[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "authored_by": { + "name": "authored_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "authored_at": { + "name": "authored_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.score": { + "name": "score", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "response_id": { + "name": "response_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "criterion_id": { + "name": "criterion_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "points": { + "name": "points", + "type": "numeric(8, 2)", + "primaryKey": false, + "notNull": true + }, + "committed_by": { + "name": "committed_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "committed_at": { + "name": "committed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "derived_from_suggestion_id": { + "name": "derived_from_suggestion_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "voided_by_amendment_id": { + "name": "voided_by_amendment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "score_response_id_response_id_fk": { + "name": "score_response_id_response_id_fk", + "tableFrom": "score", + "tableTo": "response", + "columnsFrom": [ + "response_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "score_criterion_id_criterion_id_fk": { + "name": "score_criterion_id_criterion_id_fk", + "tableFrom": "score", + "tableTo": "criterion", + "columnsFrom": [ + "criterion_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "score_derived_from_suggestion_id_suggestion_id_fk": { + "name": "score_derived_from_suggestion_id_suggestion_id_fk", + "tableFrom": "score", + "tableTo": "suggestion", + "columnsFrom": [ + "derived_from_suggestion_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": { + "score_read": { + "name": "score_read", + "as": "PERMISSIVE", + "for": "SELECT", + "to": [ + "public" + ], + "using": "class_released(release_level_for_response(response_id), 'own_scoring')" + } + }, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.suggestion": { + "name": "suggestion", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "response_id": { + "name": "response_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "criterion_id": { + "name": "criterion_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "proposed_points": { + "name": "proposed_points", + "type": "numeric(8, 2)", + "primaryKey": false, + "notNull": false + }, + "anchor_matched": { + "name": "anchor_matched", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "citations": { + "name": "citations", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "confidence": { + "name": "confidence", + "type": "numeric(4, 3)", + "primaryKey": false, + "notNull": false + }, + "model_version": { + "name": "model_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "no_evidence_found": { + "name": "no_evidence_found", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "suggestion_response_id_response_id_fk": { + "name": "suggestion_response_id_response_id_fk", + "tableFrom": "suggestion", + "tableTo": "response", + "columnsFrom": [ + "response_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "suggestion_criterion_id_criterion_id_fk": { + "name": "suggestion_criterion_id_criterion_id_fk", + "tableFrom": "suggestion", + "tableTo": "criterion", + "columnsFrom": [ + "criterion_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.export_event": { + "name": "export_event", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "org_id": { + "name": "org_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "capability": { + "name": "capability", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "solicitation_id": { + "name": "solicitation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "classes": { + "name": "classes", + "type": "text[]", + "primaryKey": false, + "notNull": true + }, + "row_count": { + "name": "row_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.release_matrix": { + "name": "release_matrix", + "schema": "", + "columns": { + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "class": { + "name": "class", + "type": "disclosure_class", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "level": { + "name": "level", + "type": "release_level", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "released": { + "name": "released", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "effective_from": { + "name": "effective_from", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "release_matrix_version_class_level_pk": { + "name": "release_matrix_version_class_level_pk", + "columns": [ + "version", + "class", + "level" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.document_type": { + "name": "document_type", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expiry_rule": { + "name": "expiry_rule", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.retailer_acceptance": { + "name": "retailer_acceptance", + "schema": "", + "columns": { + "document_id": { + "name": "document_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "retailer_org_id": { + "name": "retailer_org_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "accepted_at": { + "name": "accepted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "vendor_disclosed_name": { + "name": "vendor_disclosed_name", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "retailer_acceptance_document_id_vault_document_id_fk": { + "name": "retailer_acceptance_document_id_vault_document_id_fk", + "tableFrom": "retailer_acceptance", + "tableTo": "vault_document", + "columnsFrom": [ + "document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "retailer_acceptance_retailer_org_id_organization_id_fk": { + "name": "retailer_acceptance_retailer_org_id_organization_id_fk", + "tableFrom": "retailer_acceptance", + "tableTo": "organization", + "columnsFrom": [ + "retailer_org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "retailer_acceptance_document_id_retailer_org_id_pk": { + "name": "retailer_acceptance_document_id_retailer_org_id_pk", + "columns": [ + "document_id", + "retailer_org_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.vault_document": { + "name": "vault_document", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "vendor_org_id": { + "name": "vendor_org_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "type_id": { + "name": "type_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "blob_ref": { + "name": "blob_ref", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "expiry_state": { + "name": "expiry_state", + "type": "expiry_state", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'current'" + }, + "expiry_computed_at": { + "name": "expiry_computed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "vault_document_vendor_org_id_organization_id_fk": { + "name": "vault_document_vendor_org_id_organization_id_fk", + "tableFrom": "vault_document", + "tableTo": "organization", + "columnsFrom": [ + "vendor_org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "vault_document_type_id_document_type_id_fk": { + "name": "vault_document_type_id_document_type_id_fk", + "tableFrom": "vault_document", + "tableTo": "document_type", + "columnsFrom": [ + "type_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.entitlement": { + "name": "entitlement", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "beneficiary_org_id": { + "name": "beneficiary_org_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "payer_org_id": { + "name": "payer_org_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "tier": { + "name": "tier", + "type": "tier", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "seats": { + "name": "seats", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "lapsed_at": { + "name": "lapsed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "entitlement_beneficiary_org_id_organization_id_fk": { + "name": "entitlement_beneficiary_org_id_organization_id_fk", + "tableFrom": "entitlement", + "tableTo": "organization", + "columnsFrom": [ + "beneficiary_org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "entitlement_payer_org_id_organization_id_fk": { + "name": "entitlement_payer_org_id_organization_id_fk", + "tableFrom": "entitlement", + "tableTo": "organization", + "columnsFrom": [ + "payer_org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.confirmation_event": { + "name": "confirmation_event", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "requirement_id": { + "name": "requirement_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "confirmed_by": { + "name": "confirmed_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "corrected": { + "name": "corrected", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "at": { + "name": "at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "confirmation_event_requirement_id_requirement_id_fk": { + "name": "confirmation_event_requirement_id_requirement_id_fk", + "tableFrom": "confirmation_event", + "tableTo": "requirement", + "columnsFrom": [ + "requirement_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sweep_finding": { + "name": "sweep_finding", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "solicitation_id": { + "name": "solicitation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "document_id": { + "name": "document_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "sweep_finding_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "page": { + "name": "page", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "span": { + "name": "span", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "quoted_text": { + "name": "quoted_text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "resolved_by_requirement_id": { + "name": "resolved_by_requirement_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "dismissed_by": { + "name": "dismissed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "dismissed_at": { + "name": "dismissed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "sweep_finding_solicitation_id_solicitation_id_fk": { + "name": "sweep_finding_solicitation_id_solicitation_id_fk", + "tableFrom": "sweep_finding", + "tableTo": "solicitation", + "columnsFrom": [ + "solicitation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "sweep_finding_document_id_solicitation_document_id_fk": { + "name": "sweep_finding_document_id_solicitation_document_id_fk", + "tableFrom": "sweep_finding", + "tableTo": "solicitation_document", + "columnsFrom": [ + "document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "sweep_finding_resolved_by_requirement_id_requirement_id_fk": { + "name": "sweep_finding_resolved_by_requirement_id_requirement_id_fk", + "tableFrom": "sweep_finding", + "tableTo": "requirement", + "columnsFrom": [ + "resolved_by_requirement_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.vendor_omission_report": { + "name": "vendor_omission_report", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "solicitation_id": { + "name": "solicitation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "vendor_org_id": { + "name": "vendor_org_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reported_at": { + "name": "reported_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "acted_on_at": { + "name": "acted_on_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "acted_on_by": { + "name": "acted_on_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_omission_report_solicitation_id_solicitation_id_fk": { + "name": "vendor_omission_report_solicitation_id_solicitation_id_fk", + "tableFrom": "vendor_omission_report", + "tableTo": "solicitation", + "columnsFrom": [ + "solicitation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.capability": { + "name": "capability", + "schema": "public", + "values": [ + "issuer", + "vendor" + ] + }, + "public.category_change_kind": { + "name": "category_change_kind", + "schema": "public", + "values": [ + "split", + "merge", + "retire", + "remap" + ] + }, + "public.grant_provenance": { + "name": "grant_provenance", + "schema": "public", + "values": [ + "manual", + "split_event", + "merge_event" + ] + }, + "public.amendment_class": { + "name": "amendment_class", + "schema": "public", + "values": [ + "substantive", + "clarification" + ] + }, + "public.confirmation_state": { + "name": "confirmation_state", + "schema": "public", + "values": [ + "unconfirmed", + "confirmed", + "corrected" + ] + }, + "public.requirement_kind": { + "name": "requirement_kind", + "schema": "public", + "values": [ + "mandatory_gate", + "scored_criterion", + "certification_form", + "compliance_schedule", + "pricing", + "narrative" + ] + }, + "public.solicitation_stage": { + "name": "solicitation_stage", + "schema": "public", + "values": [ + "draft", + "open", + "evaluating", + "finalists", + "awarded", + "cancelled" + ] + }, + "public.coverage": { + "name": "coverage", + "schema": "public", + "values": [ + "answered", + "not_answered", + "indeterminate" + ] + }, + "public.participation_state": { + "name": "participation_state", + "schema": "public", + "values": [ + "invited", + "opened", + "acknowledged", + "intends_to_bid", + "submitted", + "withdrawn" + ] + }, + "public.disclosure_class": { + "name": "disclosure_class", + "schema": "public", + "values": [ + "vendor_identity", + "participation_signal", + "scenario_quantity", + "answer_text", + "exception_text", + "price_quote", + "derived_cost", + "vault_document", + "own_scoring" + ] + }, + "public.release_level": { + "name": "release_level", + "schema": "public", + "values": [ + "none", + "invited", + "acknowledged", + "submitted", + "open", + "evaluating", + "finalist", + "awarded" + ] + }, + "public.expiry_state": { + "name": "expiry_state", + "schema": "public", + "values": [ + "current", + "expiring_soon", + "expired" + ] + }, + "public.tier": { + "name": "tier", + "schema": "public", + "values": [ + "base", + "pro", + "enterprise" + ] + }, + "public.sweep_finding_kind": { + "name": "sweep_finding_kind", + "schema": "public", + "values": [ + "asserted_obligation", + "uncovered_span" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/migrations/meta/_journal.json b/migrations/meta/_journal.json index d8530c9..7bad668 100644 --- a/migrations/meta/_journal.json +++ b/migrations/meta/_journal.json @@ -22,6 +22,13 @@ "when": 1785792003081, "tag": "0002_seed_release_matrix", "breakpoints": true + }, + { + "idx": 3, + "version": "7", + "when": 1785797388491, + "tag": "0003_criterion_nesting_and_determinability", + "breakpoints": true } ] } \ No newline at end of file diff --git a/src/db/schema/solicitation.ts b/src/db/schema/solicitation.ts index 9ac2fa6..2329fbf 100644 --- a/src/db/schema/solicitation.ts +++ b/src/db/schema/solicitation.ts @@ -1,5 +1,6 @@ import { sql } from 'drizzle-orm' import { + type AnyPgColumn, boolean, integer, jsonb, numeric, pgEnum, pgPolicy, pgTable, primaryKey, text, timestamp, uuid, } from 'drizzle-orm/pg-core' @@ -68,6 +69,23 @@ export const requirement = pgTable('requirement', { provenancePage: integer('provenance_page'), provenanceSpan: jsonb('provenance_span').$type<{ start: number; end: number }>(), + /** + * False where satisfaction cannot be established from the response document + * at all — a fact about submitting rather than about content. Copy counts, + * delivery method, envelope marking, receipt by a stated hour. + * + * Found by the corpus, not by design: Friendship PCS requires "two bid + * copies". One synthesized bidder asserts it in prose and two do not, and no + * better extraction would change that. Coverage over such a requirement is + * neither answered nor not_answered but UNKNOWABLE FROM THE ARTIFACT. + * + * Gate evaluation must exclude these rather than fail them — treating the + * Friendship case as not_answered disqualifies two of three bidders over a + * packaging detail. The vendor must also never be warned they will fail a + * gate their document was never able to prove (#16). + */ + determinableFromResponse: boolean('determinable_from_response').notNull().default(true), + confirmationState: confirmationState('confirmation_state').notNull().default('unconfirmed'), confirmedBy: uuid('confirmed_by'), confirmedAt: timestamp('confirmed_at', { withTimezone: true }), @@ -76,10 +94,33 @@ export const requirement = pgTable('requirement', { /** * The scale is per-document and must never be normalised (#22, #10). * The prose anchor is the load-bearing part, not the integer. + * + * ── SCORING LEVEL ─────────────────────────────────────────────────────── + * + * A score commits at any criterion with NO WEIGHTED CHILDREN. + * + * Derived from the rubric, never configured. Two real solicitations forced + * this rule and neither is special-cased: + * + * Tarrant County five flat criteria, no nesting — all five are leaves. + * Friendship PCS "Method of Approach" 30 is NOT scoreable; its children + * (15/10/5) are. Likewise "Experience" 20 over 5/5/5/5. + * + * A criterion whose sub-items carry NO points stays scoreable at its own + * level — those sub-items are requirements mapped through + * `criterion_requirement`, not children. Friendship carries both shapes in + * one document, which is why the line is drawn on *weight* rather than on + * nesting. + * + * Roll-up is consistent by construction: weighted children sum to their + * parent's max_points, and corpus/validate-truth.py asserts it. + * ──────────────────────────────────────────────────────────────────────── */ export const criterion = pgTable('criterion', { id: uuid('id').primaryKey().defaultRandom(), solicitationId: uuid('solicitation_id').notNull().references(() => solicitation.id), + /** Null at the top level. A grouping label that also yields a roll-up total. */ + parentId: uuid('parent_id').references((): AnyPgColumn => criterion.id), label: text('label').notNull(), maxPoints: numeric('max_points', { precision: 8, scale: 2 }).notNull(), weight: numeric('weight', { precision: 8, scale: 2 }).notNull(), diff --git a/src/scoring/routing.ts b/src/scoring/routing.ts index e9e16cd..0df01fd 100644 --- a/src/scoring/routing.ts +++ b/src/scoring/routing.ts @@ -50,3 +50,41 @@ export function requiresIndividualConfirmation( ): boolean { return kind === 'mandatory_gate' || isCriterionMapped } + +/** + * Whether a gate can be evaluated against a response document at all. + * + * Confirmation is unaffected — the retailer still confirms the requirement + * exists. What changes is GATE EVALUATION: a requirement whose satisfaction is + * invisible to the artifact must be excluded rather than failed, or a bidder is + * disqualified for something their document could never have proven. + * + * Found by the corpus. See the column comment on `requirement`. + */ +export function gateEvaluableFromResponse(r: { + kind: Kind + determinableFromResponse: boolean +}): boolean { + return r.kind === 'mandatory_gate' && r.determinableFromResponse +} + +/** + * A score commits at any criterion with NO WEIGHTED CHILDREN. + * + * Derived from the rubric rather than configured — see the block comment on + * `criterion`. A child with `maxPoints` of zero or null is guidance, not a + * weighted child, and does not make its parent unscoreable. + */ +export function isScoreable( + criterionId: string, + all: readonly { id: string; parentId: string | null; maxPoints: number | null }[], +): boolean { + return !all.some((c) => c.parentId === criterionId && (c.maxPoints ?? 0) > 0) +} + +/** The set a committee actually commits scores against. */ +export function scoreableCriteria< + T extends { id: string; parentId: string | null; maxPoints: number | null }, +>(all: readonly T[]): T[] { + return all.filter((c) => isScoreable(c.id, all)) +}